@formspec/build 0.1.0-alpha.32 → 0.1.0-alpha.33

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
@@ -1819,13 +1819,29 @@ var fs = __toESM(require("fs"), 1);
1819
1819
  var path2 = __toESM(require("path"), 1);
1820
1820
 
1821
1821
  // src/extensions/registry.ts
1822
+ var import_internals3 = require("@formspec/core/internals");
1823
+ var import_internal = require("@formspec/analysis/internal");
1824
+ var BUILTIN_METADATA_TAGS = /* @__PURE__ */ new Set(["apiName", "displayName"]);
1825
+ function buildConstraintTagSources(extensions) {
1826
+ return extensions.map((extension) => ({
1827
+ extensionId: extension.extensionId,
1828
+ ...extension.constraintTags !== void 0 ? {
1829
+ constraintTags: extension.constraintTags.map((tag) => ({
1830
+ tagName: (0, import_internal.normalizeFormSpecTagName)(tag.tagName)
1831
+ }))
1832
+ } : {}
1833
+ }));
1834
+ }
1822
1835
  function createExtensionRegistry(extensions) {
1836
+ const reservedTagSources = buildConstraintTagSources(extensions);
1823
1837
  const typeMap = /* @__PURE__ */ new Map();
1824
1838
  const typeNameMap = /* @__PURE__ */ new Map();
1825
1839
  const constraintMap = /* @__PURE__ */ new Map();
1826
1840
  const constraintTagMap = /* @__PURE__ */ new Map();
1827
1841
  const builtinBroadeningMap = /* @__PURE__ */ new Map();
1828
1842
  const annotationMap = /* @__PURE__ */ new Map();
1843
+ const metadataSlotMap = /* @__PURE__ */ new Map();
1844
+ const metadataTagMap = /* @__PURE__ */ new Map();
1829
1845
  for (const ext of extensions) {
1830
1846
  if (ext.types !== void 0) {
1831
1847
  for (const type of ext.types) {
@@ -1868,10 +1884,11 @@ function createExtensionRegistry(extensions) {
1868
1884
  }
1869
1885
  if (ext.constraintTags !== void 0) {
1870
1886
  for (const tag of ext.constraintTags) {
1871
- if (constraintTagMap.has(tag.tagName)) {
1872
- throw new Error(`Duplicate custom constraint tag: "@${tag.tagName}"`);
1887
+ const canonicalTagName = (0, import_internal.normalizeFormSpecTagName)(tag.tagName);
1888
+ if (constraintTagMap.has(canonicalTagName)) {
1889
+ throw new Error(`Duplicate custom constraint tag: "@${canonicalTagName}"`);
1873
1890
  }
1874
- constraintTagMap.set(tag.tagName, {
1891
+ constraintTagMap.set(canonicalTagName, {
1875
1892
  extensionId: ext.extensionId,
1876
1893
  registration: tag
1877
1894
  });
@@ -1886,13 +1903,54 @@ function createExtensionRegistry(extensions) {
1886
1903
  annotationMap.set(qualifiedId, annotation);
1887
1904
  }
1888
1905
  }
1906
+ if (ext.metadataSlots !== void 0) {
1907
+ for (const slot of ext.metadataSlots) {
1908
+ if (metadataSlotMap.has(slot.slotId)) {
1909
+ throw new Error(`Duplicate metadata slot ID: "${slot.slotId}"`);
1910
+ }
1911
+ metadataSlotMap.set(slot.slotId, true);
1912
+ const canonicalTagName = (0, import_internal.normalizeFormSpecTagName)(slot.tagName);
1913
+ if (slot.allowBare === false && (slot.qualifiers?.length ?? 0) === 0) {
1914
+ throw new Error(
1915
+ `Metadata tag "@${canonicalTagName}" must allow bare usage or declare at least one qualifier.`
1916
+ );
1917
+ }
1918
+ if (metadataTagMap.has(canonicalTagName)) {
1919
+ throw new Error(`Duplicate metadata tag: "@${canonicalTagName}"`);
1920
+ }
1921
+ if (BUILTIN_METADATA_TAGS.has(canonicalTagName)) {
1922
+ throw new Error(
1923
+ `Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
1924
+ );
1925
+ }
1926
+ if (constraintTagMap.has(canonicalTagName)) {
1927
+ throw new Error(
1928
+ `Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${canonicalTagName}".`
1929
+ );
1930
+ }
1931
+ if (Object.hasOwn(import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS, (0, import_internals3.normalizeConstraintTagName)(canonicalTagName))) {
1932
+ throw new Error(
1933
+ `Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${(0, import_internals3.normalizeConstraintTagName)(canonicalTagName)}".`
1934
+ );
1935
+ }
1936
+ const existingTag = (0, import_internal.getTagDefinition)(canonicalTagName, reservedTagSources);
1937
+ if (existingTag !== null) {
1938
+ throw BUILTIN_METADATA_TAGS.has(existingTag.canonicalName) ? new Error(
1939
+ `Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
1940
+ ) : new Error(
1941
+ `Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${existingTag.canonicalName}".`
1942
+ );
1943
+ }
1944
+ metadataTagMap.set(canonicalTagName, true);
1945
+ }
1946
+ }
1889
1947
  }
1890
1948
  return {
1891
1949
  extensions,
1892
1950
  findType: (typeId) => typeMap.get(typeId),
1893
1951
  findTypeByName: (typeName) => typeNameMap.get(typeName),
1894
1952
  findConstraint: (constraintId) => constraintMap.get(constraintId),
1895
- findConstraintTag: (tagName) => constraintTagMap.get(tagName),
1953
+ findConstraintTag: (tagName) => constraintTagMap.get((0, import_internal.normalizeFormSpecTagName)(tagName)),
1896
1954
  findBuiltinConstraintBroadening: (typeId, tagName) => builtinBroadeningMap.get(`${typeId}:${tagName}`),
1897
1955
  findAnnotation: (annotationId) => annotationMap.get(annotationId)
1898
1956
  };
@@ -1969,21 +2027,21 @@ var path = __toESM(require("path"), 1);
1969
2027
 
1970
2028
  // src/analyzer/class-analyzer.ts
1971
2029
  var ts3 = __toESM(require("typescript"), 1);
1972
- var import_internal2 = require("@formspec/analysis/internal");
2030
+ var import_internal3 = require("@formspec/analysis/internal");
1973
2031
 
1974
2032
  // src/analyzer/jsdoc-constraints.ts
1975
2033
  var ts2 = __toESM(require("typescript"), 1);
1976
2034
 
1977
2035
  // src/analyzer/tsdoc-parser.ts
1978
2036
  var ts = __toESM(require("typescript"), 1);
1979
- var import_internal = require("@formspec/analysis/internal");
2037
+ var import_internal2 = require("@formspec/analysis/internal");
1980
2038
  var import_tsdoc = require("@microsoft/tsdoc");
1981
- var import_internals3 = require("@formspec/core/internals");
1982
2039
  var import_internals4 = require("@formspec/core/internals");
2040
+ var import_internals5 = require("@formspec/core/internals");
1983
2041
  var TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
1984
2042
  function createFormSpecTSDocConfig(extensionTagNames = []) {
1985
2043
  const config = new import_tsdoc.TSDocConfiguration();
1986
- for (const tagName of Object.keys(import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS)) {
2044
+ for (const tagName of Object.keys(import_internals4.BUILTIN_CONSTRAINT_DEFINITIONS)) {
1987
2045
  config.addTagDefinition(
1988
2046
  new import_tsdoc.TSDocTagDefinition({
1989
2047
  tagName: "@" + tagName,
@@ -1992,7 +2050,7 @@ function createFormSpecTSDocConfig(extensionTagNames = []) {
1992
2050
  })
1993
2051
  );
1994
2052
  }
1995
- for (const tagName of ["displayName", "format", "placeholder"]) {
2053
+ for (const tagName of ["apiName", "displayName", "format", "placeholder"]) {
1996
2054
  config.addTagDefinition(
1997
2055
  new import_tsdoc.TSDocTagDefinition({
1998
2056
  tagName: "@" + tagName,
@@ -2026,6 +2084,16 @@ function sharedTagValueOptions(options) {
2026
2084
  };
2027
2085
  }
2028
2086
  var SYNTHETIC_TYPE_FORMAT_FLAGS = ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
2087
+ function getExtensionTypeNames(registry) {
2088
+ if (registry === void 0) {
2089
+ return /* @__PURE__ */ new Set();
2090
+ }
2091
+ return new Set(
2092
+ registry.extensions.flatMap(
2093
+ (ext) => (ext.types ?? []).flatMap((t) => t.tsTypeNames ?? [t.typeName])
2094
+ )
2095
+ );
2096
+ }
2029
2097
  function collectImportedNames(sourceFile) {
2030
2098
  const importedNames = /* @__PURE__ */ new Set();
2031
2099
  for (const statement of sourceFile.statements) {
@@ -2065,6 +2133,9 @@ function isNonReferenceIdentifier(node) {
2065
2133
  return false;
2066
2134
  }
2067
2135
  function statementReferencesImportedName(statement, importedNames) {
2136
+ if (importedNames.size === 0) {
2137
+ return false;
2138
+ }
2068
2139
  let referencesImportedName = false;
2069
2140
  const visit = (node) => {
2070
2141
  if (referencesImportedName) {
@@ -2079,14 +2150,17 @@ function statementReferencesImportedName(statement, importedNames) {
2079
2150
  visit(statement);
2080
2151
  return referencesImportedName;
2081
2152
  }
2082
- function buildSupportingDeclarations(sourceFile) {
2153
+ function buildSupportingDeclarations(sourceFile, extensionTypeNames) {
2083
2154
  const importedNames = collectImportedNames(sourceFile);
2155
+ const importedNamesToSkip = new Set(
2156
+ [...importedNames].filter((name) => !extensionTypeNames.has(name))
2157
+ );
2084
2158
  return sourceFile.statements.filter((statement) => {
2085
2159
  if (ts.isImportDeclaration(statement)) return false;
2086
2160
  if (ts.isImportEqualsDeclaration(statement)) return false;
2087
2161
  if (ts.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0)
2088
2162
  return false;
2089
- if (importedNames.size > 0 && statementReferencesImportedName(statement, importedNames)) {
2163
+ if (statementReferencesImportedName(statement, importedNamesToSkip)) {
2090
2164
  return false;
2091
2165
  }
2092
2166
  return true;
@@ -2132,12 +2206,12 @@ function supportsConstraintCapability(type, checker, capability) {
2132
2206
  if (capability === void 0) {
2133
2207
  return true;
2134
2208
  }
2135
- if ((0, import_internal.hasTypeSemanticCapability)(type, checker, capability)) {
2209
+ if ((0, import_internal2.hasTypeSemanticCapability)(type, checker, capability)) {
2136
2210
  return true;
2137
2211
  }
2138
2212
  if (capability === "string-like") {
2139
2213
  const itemType = getArrayElementType(type, checker);
2140
- return itemType !== null && (0, import_internal.hasTypeSemanticCapability)(itemType, checker, capability);
2214
+ return itemType !== null && (0, import_internal2.hasTypeSemanticCapability)(itemType, checker, capability);
2141
2215
  }
2142
2216
  return false;
2143
2217
  }
@@ -2227,7 +2301,7 @@ function hasBuiltinConstraintBroadening(tagName, options) {
2227
2301
  return broadenedTypeId !== void 0 && options?.extensionRegistry?.findBuiltinConstraintBroadening(broadenedTypeId, tagName) !== void 0;
2228
2302
  }
2229
2303
  function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, provenance, supportingDeclarations, options) {
2230
- if (!(0, import_internals3.isBuiltinConstraintName)(tagName)) {
2304
+ if (!(0, import_internals4.isBuiltinConstraintName)(tagName)) {
2231
2305
  return [];
2232
2306
  }
2233
2307
  const checker = options?.checker;
@@ -2235,11 +2309,11 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2235
2309
  if (checker === void 0 || subjectType === void 0) {
2236
2310
  return [];
2237
2311
  }
2238
- const placement = (0, import_internal.resolveDeclarationPlacement)(node);
2312
+ const placement = (0, import_internal2.resolveDeclarationPlacement)(node);
2239
2313
  if (placement === null) {
2240
2314
  return [];
2241
2315
  }
2242
- const definition = (0, import_internal.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
2316
+ const definition = (0, import_internal2.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
2243
2317
  if (definition === null) {
2244
2318
  return [];
2245
2319
  }
@@ -2273,7 +2347,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2273
2347
  )
2274
2348
  ];
2275
2349
  }
2276
- const resolution = (0, import_internal.resolvePathTargetType)(subjectType, checker, target.path.segments);
2350
+ const resolution = (0, import_internal2.resolvePathTargetType)(subjectType, checker, target.path.segments);
2277
2351
  if (resolution.kind === "missing-property") {
2278
2352
  return [
2279
2353
  makeDiagnostic(
@@ -2330,7 +2404,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2330
2404
  const subjectTypeText = checker.typeToString(subjectType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
2331
2405
  const hostType = options?.hostType ?? subjectType;
2332
2406
  const hostTypeText = checker.typeToString(hostType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
2333
- const result = (0, import_internal.checkSyntheticTagApplication)({
2407
+ const result = (0, import_internal2.checkSyntheticTagApplication)({
2334
2408
  tagName,
2335
2409
  placement,
2336
2410
  hostType: hostTypeText,
@@ -2343,6 +2417,14 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2343
2417
  extensionId: extension.extensionId,
2344
2418
  ...extension.constraintTags !== void 0 ? {
2345
2419
  constraintTags: extension.constraintTags.map((tag) => ({ tagName: tag.tagName }))
2420
+ } : {},
2421
+ ...extension.metadataSlots !== void 0 ? {
2422
+ metadataSlots: extension.metadataSlots
2423
+ } : {},
2424
+ ...extension.types !== void 0 ? {
2425
+ customTypes: extension.types.map((t) => ({
2426
+ tsTypeNames: t.tsTypeNames ?? [t.typeName]
2427
+ }))
2346
2428
  } : {}
2347
2429
  }))
2348
2430
  } : {}
@@ -2364,7 +2446,10 @@ var parseResultCache = /* @__PURE__ */ new Map();
2364
2446
  function getParser(options) {
2365
2447
  const extensionTagNames = [
2366
2448
  ...options?.extensionRegistry?.extensions.flatMap(
2367
- (extension) => (extension.constraintTags ?? []).map((tag) => tag.tagName)
2449
+ (extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal2.normalizeFormSpecTagName)(tag.tagName))
2450
+ ) ?? [],
2451
+ ...options?.extensionRegistry?.extensions.flatMap(
2452
+ (extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal2.normalizeFormSpecTagName)(slot.tagName))
2368
2453
  ) ?? []
2369
2454
  ].sort();
2370
2455
  const cacheKey = extensionTagNames.join("|");
@@ -2384,7 +2469,16 @@ function getExtensionRegistryCacheKey(registry) {
2384
2469
  (extension) => JSON.stringify({
2385
2470
  extensionId: extension.extensionId,
2386
2471
  typeNames: extension.types?.map((type) => type.typeName) ?? [],
2387
- constraintTags: extension.constraintTags?.map((tag) => tag.tagName) ?? []
2472
+ constraintTags: extension.constraintTags?.map((tag) => (0, import_internal2.normalizeFormSpecTagName)(tag.tagName)) ?? [],
2473
+ metadataSlots: extension.metadataSlots?.map((slot) => ({
2474
+ tagName: (0, import_internal2.normalizeFormSpecTagName)(slot.tagName),
2475
+ declarationKinds: [...slot.declarationKinds].sort(),
2476
+ allowBare: slot.allowBare !== false,
2477
+ qualifiers: (slot.qualifiers ?? []).map((qualifier) => ({
2478
+ qualifier: qualifier.qualifier,
2479
+ ...qualifier.sourceQualifier !== void 0 ? { sourceQualifier: qualifier.sourceQualifier } : {}
2480
+ })).sort((left, right) => left.qualifier.localeCompare(right.qualifier))
2481
+ })) ?? []
2388
2482
  })
2389
2483
  ).join("|");
2390
2484
  }
@@ -2419,7 +2513,8 @@ function parseTSDocTags(node, file = "", options) {
2419
2513
  const rawTextTags = [];
2420
2514
  const sourceFile = node.getSourceFile();
2421
2515
  const sourceText = sourceFile.getFullText();
2422
- const supportingDeclarations = buildSupportingDeclarations(sourceFile);
2516
+ const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
2517
+ const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
2423
2518
  const commentRanges = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
2424
2519
  const rawTextFallbacks = collectRawTextFallbacks(node, file);
2425
2520
  if (commentRanges) {
@@ -2436,7 +2531,7 @@ function parseTSDocTags(node, file = "", options) {
2436
2531
  import_tsdoc.TextRange.fromStringRange(sourceText, range.pos, range.end)
2437
2532
  );
2438
2533
  const docComment = parserContext.docComment;
2439
- const parsedComment = (0, import_internal.parseCommentBlock)(
2534
+ const parsedComment = (0, import_internal2.parseCommentBlock)(
2440
2535
  commentText,
2441
2536
  sharedCommentSyntaxOptions(options, range.pos)
2442
2537
  );
@@ -2457,7 +2552,7 @@ function parseTSDocTags(node, file = "", options) {
2457
2552
  }
2458
2553
  }
2459
2554
  for (const block of docComment.customBlocks) {
2460
- const tagName = (0, import_internals3.normalizeConstraintTagName)(block.blockTag.tagName.substring(1));
2555
+ const tagName = (0, import_internals4.normalizeConstraintTagName)(block.blockTag.tagName.substring(1));
2461
2556
  const parsedTag = nextParsedTag(tagName);
2462
2557
  if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
2463
2558
  const text2 = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
@@ -2489,7 +2584,7 @@ function parseTSDocTags(node, file = "", options) {
2489
2584
  }
2490
2585
  if (TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
2491
2586
  const text = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
2492
- const expectedType = (0, import_internals3.isBuiltinConstraintName)(tagName) ? import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
2587
+ const expectedType = (0, import_internals4.isBuiltinConstraintName)(tagName) ? import_internals4.BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
2493
2588
  if (text === "" && expectedType !== "boolean") continue;
2494
2589
  const provenance = parsedTag !== null ? provenanceForParsedTag(parsedTag, sourceFile, file) : provenanceForComment(range, sourceFile, file, tagName);
2495
2590
  const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
@@ -2505,7 +2600,7 @@ function parseTSDocTags(node, file = "", options) {
2505
2600
  diagnostics.push(...compilerDiagnostics);
2506
2601
  continue;
2507
2602
  }
2508
- const constraintNode = (0, import_internal.parseConstraintTagValue)(
2603
+ const constraintNode = (0, import_internal2.parseConstraintTagValue)(
2509
2604
  tagName,
2510
2605
  text,
2511
2606
  provenance,
@@ -2575,7 +2670,7 @@ function parseTSDocTags(node, file = "", options) {
2575
2670
  if (text === "") continue;
2576
2671
  const provenance = provenanceForParsedTag(rawTextTag.tag, sourceFile, file);
2577
2672
  if (rawTextTag.tag.normalizedTagName === "defaultValue") {
2578
- const defaultValueNode = (0, import_internal.parseDefaultValueTagValue)(text, provenance);
2673
+ const defaultValueNode = (0, import_internal2.parseDefaultValueTagValue)(text, provenance);
2579
2674
  annotations.push(defaultValueNode);
2580
2675
  continue;
2581
2676
  }
@@ -2592,7 +2687,7 @@ function parseTSDocTags(node, file = "", options) {
2592
2687
  diagnostics.push(...compilerDiagnostics);
2593
2688
  continue;
2594
2689
  }
2595
- const constraintNode = (0, import_internal.parseConstraintTagValue)(
2690
+ const constraintNode = (0, import_internal2.parseConstraintTagValue)(
2596
2691
  rawTextTag.tag.normalizedTagName,
2597
2692
  text,
2598
2693
  provenance,
@@ -2609,7 +2704,7 @@ function parseTSDocTags(node, file = "", options) {
2609
2704
  if (text === "") continue;
2610
2705
  const provenance = fallback.provenance;
2611
2706
  if (tagName === "defaultValue") {
2612
- const defaultValueNode = (0, import_internal.parseDefaultValueTagValue)(text, provenance);
2707
+ const defaultValueNode = (0, import_internal2.parseDefaultValueTagValue)(text, provenance);
2613
2708
  annotations.push(defaultValueNode);
2614
2709
  continue;
2615
2710
  }
@@ -2626,7 +2721,7 @@ function parseTSDocTags(node, file = "", options) {
2626
2721
  diagnostics.push(...compilerDiagnostics);
2627
2722
  continue;
2628
2723
  }
2629
- const constraintNode = (0, import_internal.parseConstraintTagValue)(
2724
+ const constraintNode = (0, import_internal2.parseConstraintTagValue)(
2630
2725
  tagName,
2631
2726
  text,
2632
2727
  provenance,
@@ -2652,7 +2747,7 @@ function extractDisplayNameMetadata(node) {
2652
2747
  if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) continue;
2653
2748
  const commentText = sourceText.substring(range.pos, range.end);
2654
2749
  if (!commentText.startsWith("/**")) continue;
2655
- const parsed = (0, import_internal.parseCommentBlock)(commentText);
2750
+ const parsed = (0, import_internal2.parseCommentBlock)(commentText);
2656
2751
  for (const tag of parsed.tags) {
2657
2752
  if (tag.normalizedTagName !== "displayName") {
2658
2753
  continue;
@@ -2708,7 +2803,7 @@ function getSharedPayloadText(tag, commentText, commentOffset) {
2708
2803
  if (tag.payloadSpan === null) {
2709
2804
  return "";
2710
2805
  }
2711
- return (0, import_internal.sliceCommentSpan)(commentText, tag.payloadSpan, {
2806
+ return (0, import_internal2.sliceCommentSpan)(commentText, tag.payloadSpan, {
2712
2807
  offset: commentOffset
2713
2808
  }).trim();
2714
2809
  }
@@ -2720,7 +2815,7 @@ function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
2720
2815
  function collectRawTextFallbacks(node, file) {
2721
2816
  const fallbacks = /* @__PURE__ */ new Map();
2722
2817
  for (const tag of ts.getJSDocTags(node)) {
2723
- const tagName = (0, import_internals3.normalizeConstraintTagName)(tag.tagName.text);
2818
+ const tagName = (0, import_internals4.normalizeConstraintTagName)(tag.tagName.text);
2724
2819
  if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
2725
2820
  const commentText = getTagCommentText(tag)?.trim() ?? "";
2726
2821
  if (commentText === "") continue;
@@ -2734,7 +2829,7 @@ function collectRawTextFallbacks(node, file) {
2734
2829
  return fallbacks;
2735
2830
  }
2736
2831
  function isMemberTargetDisplayName(text) {
2737
- return (0, import_internal.parseTagSyntax)("displayName", text).target !== null;
2832
+ return (0, import_internal2.parseTagSyntax)("displayName", text).target !== null;
2738
2833
  }
2739
2834
  function provenanceForComment(range, sourceFile, file, tagName) {
2740
2835
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(range.pos);
@@ -2847,76 +2942,50 @@ function makeParseOptions(extensionRegistry, fieldType, checker, subjectType, ho
2847
2942
  ...hostType !== void 0 && { hostType }
2848
2943
  };
2849
2944
  }
2850
- function makeExplicitScalarMetadata(value) {
2851
- return value === void 0 || value === "" ? void 0 : { value, source: "explicit" };
2852
- }
2853
- function extractExplicitMetadata(node) {
2854
- let apiName;
2855
- let displayName;
2856
- let apiNamePlural;
2857
- let displayNamePlural;
2858
- for (const tag of getLeadingParsedTags(node)) {
2859
- const value = tag.argumentText.trim();
2860
- if (value === "") {
2861
- continue;
2862
- }
2863
- if (tag.normalizedTagName === "apiName") {
2864
- if (tag.target === null) {
2865
- apiName ??= value;
2866
- } else if (tag.target.kind === "variant") {
2867
- if (tag.target.rawText === "singular") {
2868
- apiName ??= value;
2869
- } else if (tag.target.rawText === "plural") {
2870
- apiNamePlural ??= value;
2871
- }
2872
- }
2873
- continue;
2874
- }
2875
- if (tag.normalizedTagName === "displayName") {
2876
- if (tag.target === null) {
2877
- displayName ??= value;
2878
- } else if (tag.target.kind === "variant") {
2879
- if (tag.target.rawText === "singular") {
2880
- displayName ??= value;
2881
- } else if (tag.target.rawText === "plural") {
2882
- displayNamePlural ??= value;
2883
- }
2884
- }
2885
- }
2886
- }
2887
- const resolvedApiName = makeExplicitScalarMetadata(apiName);
2888
- const resolvedDisplayName = makeExplicitScalarMetadata(displayName);
2889
- const resolvedApiNamePlural = makeExplicitScalarMetadata(apiNamePlural);
2890
- const resolvedDisplayNamePlural = makeExplicitScalarMetadata(displayNamePlural);
2891
- const metadata = {
2892
- ...resolvedApiName !== void 0 && { apiName: resolvedApiName },
2893
- ...resolvedDisplayName !== void 0 && { displayName: resolvedDisplayName },
2894
- ...resolvedApiNamePlural !== void 0 && { apiNamePlural: resolvedApiNamePlural },
2895
- ...resolvedDisplayNamePlural !== void 0 && {
2896
- displayNamePlural: resolvedDisplayNamePlural
2897
- }
2945
+ function createAnalyzerMetadataPolicy(input) {
2946
+ return {
2947
+ raw: input,
2948
+ normalized: normalizeMetadataPolicy(input)
2898
2949
  };
2899
- return Object.keys(metadata).length === 0 ? void 0 : metadata;
2900
2950
  }
2901
- function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node, buildContext) {
2902
- const explicit = extractExplicitMetadata(node);
2903
- return resolveMetadata(
2904
- {
2905
- ...explicit?.apiName !== void 0 && { apiName: explicit.apiName.value },
2906
- ...explicit?.displayName !== void 0 && { displayName: explicit.displayName.value },
2907
- ...explicit?.apiNamePlural !== void 0 && {
2908
- apiNamePlural: explicit.apiNamePlural.value
2909
- },
2910
- ...explicit?.displayNamePlural !== void 0 && {
2911
- displayNamePlural: explicit.displayNamePlural.value
2912
- }
2913
- },
2914
- getDeclarationMetadataPolicy(metadataPolicy, declarationKind),
2915
- makeMetadataContext("tsdoc", declarationKind, logicalName, buildContext)
2951
+ function resolveNodeMetadata(metadataPolicy, declarationKind, logicalName, node, checker, extensionRegistry, buildContext) {
2952
+ const analysis = (0, import_internal3.analyzeMetadataForNodeWithChecker)({
2953
+ checker,
2954
+ node,
2955
+ logicalName,
2956
+ metadata: metadataPolicy.raw,
2957
+ extensions: extensionRegistry?.extensions,
2958
+ ...buildContext !== void 0 && { buildContext }
2959
+ });
2960
+ const resolvedMetadata = analysis?.resolvedMetadata;
2961
+ const declarationPolicy = getDeclarationMetadataPolicy(
2962
+ metadataPolicy.normalized,
2963
+ declarationKind
2916
2964
  );
2965
+ if (resolvedMetadata?.apiName === void 0 && declarationPolicy.apiName.mode === "require-explicit") {
2966
+ throw new Error(
2967
+ `Metadata policy requires explicit apiName for ${declarationKind} "${logicalName}" on the tsdoc surface.`
2968
+ );
2969
+ }
2970
+ if (resolvedMetadata?.displayName === void 0 && declarationPolicy.displayName.mode === "require-explicit") {
2971
+ throw new Error(
2972
+ `Metadata policy requires explicit displayName for ${declarationKind} "${logicalName}" on the tsdoc surface.`
2973
+ );
2974
+ }
2975
+ if (resolvedMetadata?.apiNamePlural === void 0 && declarationPolicy.apiName.pluralization.mode === "require-explicit") {
2976
+ throw new Error(
2977
+ `Metadata policy requires explicit apiNamePlural for ${declarationKind} "${logicalName}" on the tsdoc surface.`
2978
+ );
2979
+ }
2980
+ if (resolvedMetadata?.displayNamePlural === void 0 && declarationPolicy.displayName.pluralization.mode === "require-explicit") {
2981
+ throw new Error(
2982
+ `Metadata policy requires explicit displayNamePlural for ${declarationKind} "${logicalName}" on the tsdoc surface.`
2983
+ );
2984
+ }
2985
+ return resolvedMetadata;
2917
2986
  }
2918
2987
  function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRegistry, metadataPolicy) {
2919
- const normalizedMetadataPolicy = normalizeMetadataPolicy(metadataPolicy);
2988
+ const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
2920
2989
  const declarationType = checker.getTypeAtLocation(declaration);
2921
2990
  const logicalName = ts3.isClassDeclaration(declaration) ? declaration.name?.text ?? "AnonymousClass" : declaration.name.text;
2922
2991
  const docResult = extractJSDocParseResult(
@@ -2924,12 +2993,20 @@ function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRe
2924
2993
  file,
2925
2994
  makeParseOptions(extensionRegistry, void 0, checker, declarationType, declarationType)
2926
2995
  );
2927
- const metadata = resolveNodeMetadata(normalizedMetadataPolicy, "type", logicalName, declaration, {
2928
- checker,
2996
+ const metadata = resolveNodeMetadata(
2997
+ normalizedMetadataPolicy,
2998
+ "type",
2999
+ logicalName,
2929
3000
  declaration,
2930
- subjectType: declarationType,
2931
- hostType: declarationType
2932
- });
3001
+ checker,
3002
+ extensionRegistry,
3003
+ {
3004
+ checker,
3005
+ declaration,
3006
+ subjectType: declarationType,
3007
+ hostType: declarationType
3008
+ }
3009
+ );
2933
3010
  return {
2934
3011
  ...metadata !== void 0 && { metadata },
2935
3012
  annotations: docResult.annotations,
@@ -2937,7 +3014,7 @@ function analyzeDeclarationRootInfo(declaration, checker, file = "", extensionRe
2937
3014
  };
2938
3015
  }
2939
3016
  function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, metadataPolicy) {
2940
- const normalizedMetadataPolicy = normalizeMetadataPolicy(metadataPolicy);
3017
+ const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
2941
3018
  const name = classDecl.name?.text ?? "AnonymousClass";
2942
3019
  const fields = [];
2943
3020
  const fieldLayouts = [];
@@ -2992,12 +3069,20 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
2992
3069
  diagnostics,
2993
3070
  normalizedMetadataPolicy
2994
3071
  );
2995
- const metadata = resolveNodeMetadata(normalizedMetadataPolicy, "type", name, classDecl, {
3072
+ const metadata = resolveNodeMetadata(
3073
+ normalizedMetadataPolicy,
3074
+ "type",
3075
+ name,
3076
+ classDecl,
2996
3077
  checker,
2997
- declaration: classDecl,
2998
- subjectType: classType,
2999
- hostType: classType
3000
- });
3078
+ extensionRegistry,
3079
+ {
3080
+ checker,
3081
+ declaration: classDecl,
3082
+ subjectType: classType,
3083
+ hostType: classType
3084
+ }
3085
+ );
3001
3086
  return {
3002
3087
  name,
3003
3088
  ...metadata !== void 0 && { metadata },
@@ -3011,7 +3096,7 @@ function analyzeClassToIR(classDecl, checker, file = "", extensionRegistry, meta
3011
3096
  };
3012
3097
  }
3013
3098
  function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegistry, metadataPolicy) {
3014
- const normalizedMetadataPolicy = normalizeMetadataPolicy(metadataPolicy);
3099
+ const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
3015
3100
  const name = interfaceDecl.name.text;
3016
3101
  const fields = [];
3017
3102
  const typeRegistry = {};
@@ -3053,12 +3138,20 @@ function analyzeInterfaceToIR(interfaceDecl, checker, file = "", extensionRegist
3053
3138
  normalizedMetadataPolicy
3054
3139
  );
3055
3140
  const fieldLayouts = specializedFields.map(() => ({}));
3056
- const metadata = resolveNodeMetadata(normalizedMetadataPolicy, "type", name, interfaceDecl, {
3141
+ const metadata = resolveNodeMetadata(
3142
+ normalizedMetadataPolicy,
3143
+ "type",
3144
+ name,
3145
+ interfaceDecl,
3057
3146
  checker,
3058
- declaration: interfaceDecl,
3059
- subjectType: interfaceType,
3060
- hostType: interfaceType
3061
- });
3147
+ extensionRegistry,
3148
+ {
3149
+ checker,
3150
+ declaration: interfaceDecl,
3151
+ subjectType: interfaceType,
3152
+ hostType: interfaceType
3153
+ }
3154
+ );
3062
3155
  return {
3063
3156
  name,
3064
3157
  ...metadata !== void 0 && { metadata },
@@ -3082,7 +3175,7 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3082
3175
  };
3083
3176
  }
3084
3177
  const typeLiteral = typeAlias.type;
3085
- const normalizedMetadataPolicy = normalizeMetadataPolicy(metadataPolicy);
3178
+ const normalizedMetadataPolicy = createAnalyzerMetadataPolicy(metadataPolicy);
3086
3179
  const name = typeAlias.name.text;
3087
3180
  const fields = [];
3088
3181
  const typeRegistry = {};
@@ -3123,12 +3216,20 @@ function analyzeTypeAliasToIR(typeAlias, checker, file = "", extensionRegistry,
3123
3216
  diagnostics,
3124
3217
  normalizedMetadataPolicy
3125
3218
  );
3126
- const metadata = resolveNodeMetadata(normalizedMetadataPolicy, "type", name, typeAlias, {
3219
+ const metadata = resolveNodeMetadata(
3220
+ normalizedMetadataPolicy,
3221
+ "type",
3222
+ name,
3223
+ typeAlias,
3127
3224
  checker,
3128
- declaration: typeAlias,
3129
- subjectType: aliasType,
3130
- hostType: aliasType
3131
- });
3225
+ extensionRegistry,
3226
+ {
3227
+ checker,
3228
+ declaration: typeAlias,
3229
+ subjectType: aliasType,
3230
+ hostType: aliasType
3231
+ }
3232
+ );
3132
3233
  return {
3133
3234
  ok: true,
3134
3235
  analysis: {
@@ -3169,7 +3270,7 @@ function getLeadingParsedTags(node) {
3169
3270
  if (!commentText.startsWith("/**")) {
3170
3271
  continue;
3171
3272
  }
3172
- parsedTags.push(...(0, import_internal2.parseCommentBlock)(commentText, { offset: range.pos }).tags);
3273
+ parsedTags.push(...(0, import_internal3.parseCommentBlock)(commentText, { offset: range.pos }).tags);
3173
3274
  }
3174
3275
  return parsedTags;
3175
3276
  }
@@ -3381,6 +3482,8 @@ function resolveDiscriminatorApiName(boundType, checker, metadataPolicy) {
3381
3482
  "type",
3382
3483
  getDiscriminatorLogicalName(boundType, declaration, checker),
3383
3484
  declaration,
3485
+ checker,
3486
+ void 0,
3384
3487
  {
3385
3488
  checker,
3386
3489
  declaration,
@@ -3617,12 +3720,20 @@ function analyzeFieldToIR(prop, checker, file, typeRegistry, visiting, diagnosti
3617
3720
  annotations.push(defaultAnnotation);
3618
3721
  }
3619
3722
  ({ type, annotations } = applyEnumMemberDisplayNames(type, annotations));
3620
- const metadata = resolveNodeMetadata(metadataPolicy, "field", name, prop, {
3723
+ const metadata = resolveNodeMetadata(
3724
+ metadataPolicy,
3725
+ "field",
3726
+ name,
3727
+ prop,
3621
3728
  checker,
3622
- declaration: prop,
3623
- subjectType: tsType,
3624
- hostType
3625
- });
3729
+ extensionRegistry,
3730
+ {
3731
+ checker,
3732
+ declaration: prop,
3733
+ subjectType: tsType,
3734
+ hostType
3735
+ }
3736
+ );
3626
3737
  return {
3627
3738
  kind: "field",
3628
3739
  name,
@@ -3669,12 +3780,20 @@ function analyzeInterfacePropertyToIR(prop, checker, file, typeRegistry, visitin
3669
3780
  let annotations = [];
3670
3781
  annotations.push(...docResult.annotations);
3671
3782
  ({ type, annotations } = applyEnumMemberDisplayNames(type, annotations));
3672
- const metadata = resolveNodeMetadata(metadataPolicy, "field", name, prop, {
3783
+ const metadata = resolveNodeMetadata(
3784
+ metadataPolicy,
3785
+ "field",
3786
+ name,
3787
+ prop,
3673
3788
  checker,
3674
- declaration: prop,
3675
- subjectType: tsType,
3676
- hostType
3677
- });
3789
+ extensionRegistry,
3790
+ {
3791
+ checker,
3792
+ declaration: prop,
3793
+ subjectType: tsType,
3794
+ hostType
3795
+ }
3796
+ );
3678
3797
  return {
3679
3798
  kind: "field",
3680
3799
  name,
@@ -3803,7 +3922,7 @@ function getTypeNodeRegistrationName(typeNode) {
3803
3922
  }
3804
3923
  return null;
3805
3924
  }
3806
- function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = normalizeMetadataPolicy(void 0), extensionRegistry, diagnostics) {
3925
+ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
3807
3926
  const customType = resolveRegisteredCustomType(sourceNode, extensionRegistry, checker);
3808
3927
  if (customType) {
3809
3928
  return customType;
@@ -3893,7 +4012,7 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
3893
4012
  }
3894
4013
  return { kind: "primitive", primitiveKind: "string" };
3895
4014
  }
3896
- function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = normalizeMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4015
+ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
3897
4016
  if (!(type.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null))) {
3898
4017
  return null;
3899
4018
  }
@@ -3913,11 +4032,19 @@ function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiti
3913
4032
  file,
3914
4033
  makeParseOptions(extensionRegistry)
3915
4034
  );
3916
- const metadata = resolveNodeMetadata(metadataPolicy, "type", aliasName, aliasDecl, {
4035
+ const metadata = resolveNodeMetadata(
4036
+ metadataPolicy,
4037
+ "type",
4038
+ aliasName,
4039
+ aliasDecl,
3917
4040
  checker,
3918
- declaration: aliasDecl,
3919
- subjectType: aliasType
3920
- });
4041
+ extensionRegistry,
4042
+ {
4043
+ checker,
4044
+ declaration: aliasDecl,
4045
+ subjectType: aliasType
4046
+ }
4047
+ );
3921
4048
  typeRegistry[aliasName] = {
3922
4049
  name: aliasName,
3923
4050
  ...metadata !== void 0 && { metadata },
@@ -3956,7 +4083,7 @@ function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
3956
4083
  const resolved = checker.getTypeFromTypeNode(aliasDecl.type);
3957
4084
  return !!(resolved.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null));
3958
4085
  }
3959
- function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiting, metadataPolicy = normalizeMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4086
+ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiting, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
3960
4087
  const nestedAliasDecl = type.aliasSymbol?.declarations?.find(ts3.isTypeAliasDeclaration);
3961
4088
  if (nestedAliasDecl !== void 0) {
3962
4089
  return resolveAliasedPrimitiveTarget(
@@ -3982,7 +4109,7 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
3982
4109
  diagnostics
3983
4110
  );
3984
4111
  }
3985
- function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = normalizeMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4112
+ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
3986
4113
  const typeName = getNamedTypeName(type);
3987
4114
  const namedDecl = getNamedTypeDeclaration(type);
3988
4115
  if (typeName && typeName in typeRegistry) {
@@ -4017,11 +4144,19 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4017
4144
  return result;
4018
4145
  }
4019
4146
  const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
4020
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(metadataPolicy, "type", typeName, namedDecl, {
4147
+ const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
4148
+ metadataPolicy,
4149
+ "type",
4150
+ typeName,
4151
+ namedDecl,
4021
4152
  checker,
4022
- declaration: namedDecl,
4023
- subjectType: type
4024
- }) : void 0;
4153
+ extensionRegistry,
4154
+ {
4155
+ checker,
4156
+ declaration: namedDecl,
4157
+ subjectType: type
4158
+ }
4159
+ ) : void 0;
4025
4160
  typeRegistry[typeName] = {
4026
4161
  name: typeName,
4027
4162
  ...metadata !== void 0 && { metadata },
@@ -4106,7 +4241,7 @@ function resolveUnionType(type, checker, file, typeRegistry, visiting, sourceNod
4106
4241
  }
4107
4242
  return registerNamed({ kind: "union", members });
4108
4243
  }
4109
- function resolveArrayType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = normalizeMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4244
+ function resolveArrayType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4110
4245
  const typeArgs = isTypeReference(type) ? type.typeArguments : void 0;
4111
4246
  const elementType = typeArgs?.[0];
4112
4247
  const elementSourceNode = extractArrayElementTypeNode(sourceNode, checker);
@@ -4123,7 +4258,7 @@ function resolveArrayType(type, checker, file, typeRegistry, visiting, sourceNod
4123
4258
  ) : { kind: "primitive", primitiveKind: "string" };
4124
4259
  return { kind: "array", items };
4125
4260
  }
4126
- function tryResolveRecordType(type, checker, file, typeRegistry, visiting, metadataPolicy = normalizeMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4261
+ function tryResolveRecordType(type, checker, file, typeRegistry, visiting, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4127
4262
  if (type.getProperties().length > 0) {
4128
4263
  return null;
4129
4264
  }
@@ -4184,7 +4319,7 @@ function shouldEmitResolvedObjectProperty(property, declaration) {
4184
4319
  }
4185
4320
  return true;
4186
4321
  }
4187
- function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = normalizeMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4322
+ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4188
4323
  const collectedDiagnostics = diagnostics ?? [];
4189
4324
  const typeName = getNamedTypeName(type);
4190
4325
  const namedTypeName = typeName ?? void 0;
@@ -4260,11 +4395,19 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
4260
4395
  return recordNode;
4261
4396
  }
4262
4397
  const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
4263
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(metadataPolicy, "type", registryTypeName, namedDecl, {
4398
+ const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
4399
+ metadataPolicy,
4400
+ "type",
4401
+ registryTypeName,
4402
+ namedDecl,
4264
4403
  checker,
4265
- declaration: namedDecl,
4266
- subjectType: type
4267
- }) : void 0;
4404
+ extensionRegistry,
4405
+ {
4406
+ checker,
4407
+ declaration: namedDecl,
4408
+ subjectType: type
4409
+ }
4410
+ ) : void 0;
4268
4411
  typeRegistry[registryTypeName] = {
4269
4412
  name: registryTypeName,
4270
4413
  ...metadata !== void 0 && { metadata },
@@ -4360,11 +4503,19 @@ function resolveObjectType(type, checker, file, typeRegistry, visiting, sourceNo
4360
4503
  };
4361
4504
  if (registryTypeName !== void 0 && shouldRegisterNamedType) {
4362
4505
  const annotations = namedDecl ? extractJSDocAnnotationNodes(namedDecl, file, makeParseOptions(extensionRegistry)) : void 0;
4363
- const metadata = namedDecl !== void 0 ? resolveNodeMetadata(metadataPolicy, "type", registryTypeName, namedDecl, {
4506
+ const metadata = namedDecl !== void 0 ? resolveNodeMetadata(
4507
+ metadataPolicy,
4508
+ "type",
4509
+ registryTypeName,
4510
+ namedDecl,
4364
4511
  checker,
4365
- declaration: namedDecl,
4366
- subjectType: type
4367
- }) : void 0;
4512
+ extensionRegistry,
4513
+ {
4514
+ checker,
4515
+ declaration: namedDecl,
4516
+ subjectType: type
4517
+ }
4518
+ ) : void 0;
4368
4519
  typeRegistry[registryTypeName] = {
4369
4520
  name: registryTypeName,
4370
4521
  ...metadata !== void 0 && { metadata },
@@ -4776,9 +4927,9 @@ function analyzeNamedTypeToIRFromProgramContext(ctx, filePath, typeName, extensi
4776
4927
  }
4777
4928
 
4778
4929
  // src/validate/constraint-validator.ts
4779
- var import_internal3 = require("@formspec/analysis/internal");
4930
+ var import_internal4 = require("@formspec/analysis/internal");
4780
4931
  function validateFieldNode(ctx, field) {
4781
- const analysis = (0, import_internal3.analyzeConstraintTargets)(
4932
+ const analysis = (0, import_internal4.analyzeConstraintTargets)(
4782
4933
  field.name,
4783
4934
  field.type,
4784
4935
  field.constraints,
@@ -4796,7 +4947,7 @@ function validateFieldNode(ctx, field) {
4796
4947
  }
4797
4948
  function validateObjectProperty(ctx, parentName, property) {
4798
4949
  const qualifiedName = `${parentName}.${property.name}`;
4799
- const analysis = (0, import_internal3.analyzeConstraintTargets)(
4950
+ const analysis = (0, import_internal4.analyzeConstraintTargets)(
4800
4951
  qualifiedName,
4801
4952
  property.type,
4802
4953
  property.constraints,
@@ -4972,7 +5123,7 @@ function resolveModuleExportDeclaration(context, exportName = "default") {
4972
5123
 
4973
5124
  // src/generators/discovered-schema.ts
4974
5125
  var ts7 = __toESM(require("typescript"), 1);
4975
- var import_internals5 = require("@formspec/core/internals");
5126
+ var import_internals6 = require("@formspec/core/internals");
4976
5127
  function toDiscoveredTypeSchemas(result) {
4977
5128
  return result;
4978
5129
  }
@@ -5084,7 +5235,7 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
5084
5235
  {
5085
5236
  kind: "form-ir",
5086
5237
  name: root.name,
5087
- irVersion: import_internals5.IR_VERSION,
5238
+ irVersion: import_internals6.IR_VERSION,
5088
5239
  elements: [syntheticField],
5089
5240
  ...root.metadata !== void 0 && { metadata: root.metadata },
5090
5241
  ...root.annotations !== void 0 && root.annotations.length > 0 && { rootAnnotations: root.annotations },
@@ -5143,7 +5294,7 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
5143
5294
  typeRegistry,
5144
5295
  /* @__PURE__ */ new Set(),
5145
5296
  options.sourceNode,
5146
- normalizeMetadataPolicy(options.metadata),
5297
+ createAnalyzerMetadataPolicy(options.metadata),
5147
5298
  options.extensionRegistry,
5148
5299
  diagnostics
5149
5300
  );