@formspec/build 0.1.0-alpha.42 → 0.1.0-alpha.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1604,7 +1604,7 @@ function applyCustomConstraint(schema, constraint, ctx) {
1604
1604
  if (registration.emitsVocabularyKeywords) {
1605
1605
  const target = schema;
1606
1606
  for (const [key, value] of Object.entries(extensionSchema)) {
1607
- if (JSON_SCHEMA_STRUCTURAL_KEYWORDS.has(key)) {
1607
+ if (VOCABULARY_MODE_BLOCKED_KEYWORDS.has(key)) {
1608
1608
  throw new Error(
1609
1609
  `Custom constraint "${constraint.constraintId}" with emitsVocabularyKeywords must not overwrite standard JSON Schema keyword "${key}"`
1610
1610
  );
@@ -1647,13 +1647,13 @@ function assignVendorPrefixedExtensionKeywords(schema, extensionSchema, vendorPr
1647
1647
  schema[key] = value;
1648
1648
  }
1649
1649
  }
1650
- var JSON_SCHEMA_STRUCTURAL_KEYWORDS;
1650
+ var VOCABULARY_MODE_BLOCKED_KEYWORDS;
1651
1651
  var init_ir_generator = __esm({
1652
1652
  "src/json-schema/ir-generator.ts"() {
1653
1653
  "use strict";
1654
1654
  init_metadata();
1655
1655
  init_collision_guards();
1656
- JSON_SCHEMA_STRUCTURAL_KEYWORDS = /* @__PURE__ */ new Set([
1656
+ VOCABULARY_MODE_BLOCKED_KEYWORDS = /* @__PURE__ */ new Set([
1657
1657
  "$schema",
1658
1658
  "$ref",
1659
1659
  "$defs",
@@ -2253,72 +2253,25 @@ var init_schema2 = __esm({
2253
2253
  import * as ts from "typescript";
2254
2254
  import {
2255
2255
  checkSyntheticTagApplication,
2256
+ choosePreferredPayloadText,
2256
2257
  extractPathTarget as extractSharedPathTarget,
2257
2258
  getTagDefinition as getTagDefinition2,
2258
2259
  hasTypeSemanticCapability,
2259
2260
  normalizeFormSpecTagName as normalizeFormSpecTagName2,
2260
2261
  parseConstraintTagValue,
2261
2262
  parseDefaultValueTagValue,
2263
+ parseTagSyntax,
2264
+ parseUnifiedComment,
2262
2265
  resolveDeclarationPlacement,
2263
2266
  resolvePathTargetType,
2264
- sliceCommentSpan,
2265
- parseCommentBlock,
2266
- parseTagSyntax
2267
+ TAGS_REQUIRING_RAW_TEXT
2267
2268
  } from "@formspec/analysis/internal";
2268
- import {
2269
- TSDocParser,
2270
- TSDocConfiguration,
2271
- TSDocTagDefinition,
2272
- TSDocTagSyntaxKind,
2273
- DocExcerpt,
2274
- DocPlainText,
2275
- DocSoftBreak,
2276
- TextRange
2277
- } from "@microsoft/tsdoc";
2278
2269
  import {
2279
2270
  BUILTIN_CONSTRAINT_DEFINITIONS as BUILTIN_CONSTRAINT_DEFINITIONS2,
2280
2271
  normalizeConstraintTagName as normalizeConstraintTagName2,
2281
2272
  isBuiltinConstraintName
2282
2273
  } from "@formspec/core/internals";
2283
2274
  import "@formspec/core/internals";
2284
- function createFormSpecTSDocConfig(extensionTagNames = []) {
2285
- const config = new TSDocConfiguration();
2286
- for (const tagName of Object.keys(BUILTIN_CONSTRAINT_DEFINITIONS2)) {
2287
- config.addTagDefinition(
2288
- new TSDocTagDefinition({
2289
- tagName: "@" + tagName,
2290
- syntaxKind: TSDocTagSyntaxKind.BlockTag,
2291
- allowMultiple: true
2292
- })
2293
- );
2294
- }
2295
- for (const tagName of ["apiName", "displayName", "format", "placeholder"]) {
2296
- config.addTagDefinition(
2297
- new TSDocTagDefinition({
2298
- tagName: "@" + tagName,
2299
- syntaxKind: TSDocTagSyntaxKind.BlockTag,
2300
- allowMultiple: true
2301
- })
2302
- );
2303
- }
2304
- for (const tagName of extensionTagNames) {
2305
- config.addTagDefinition(
2306
- new TSDocTagDefinition({
2307
- tagName: "@" + tagName,
2308
- syntaxKind: TSDocTagSyntaxKind.BlockTag,
2309
- allowMultiple: true
2310
- })
2311
- );
2312
- }
2313
- return config;
2314
- }
2315
- function sharedCommentSyntaxOptions(options, offset) {
2316
- const extensions = options?.extensionRegistry?.extensions;
2317
- return {
2318
- ...offset !== void 0 ? { offset } : {},
2319
- ...extensions !== void 0 ? { extensions } : {}
2320
- };
2321
- }
2322
2275
  function sharedTagValueOptions(options) {
2323
2276
  return {
2324
2277
  ...options?.extensionRegistry !== void 0 ? { registry: options.extensionRegistry } : {},
@@ -2417,6 +2370,30 @@ function pushUniqueCompilerDiagnostics(target, additions) {
2417
2370
  target.push(diagnostic);
2418
2371
  }
2419
2372
  }
2373
+ function processConstraintTag(tagName, text, parsedTag, provenance, node, sourceFile, supportingDeclarations, options, constraints, diagnostics) {
2374
+ const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
2375
+ node,
2376
+ sourceFile,
2377
+ tagName,
2378
+ parsedTag,
2379
+ provenance,
2380
+ supportingDeclarations,
2381
+ options
2382
+ );
2383
+ if (compilerDiagnostics.length > 0) {
2384
+ pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2385
+ return;
2386
+ }
2387
+ const constraintNode = parseConstraintTagValue(
2388
+ tagName,
2389
+ text,
2390
+ provenance,
2391
+ sharedTagValueOptions(options)
2392
+ );
2393
+ if (constraintNode) {
2394
+ constraints.push(constraintNode);
2395
+ }
2396
+ }
2420
2397
  function renderSyntheticArgumentExpression(valueKind, argumentText) {
2421
2398
  const trimmed = argumentText.trim();
2422
2399
  if (trimmed === "") {
@@ -2702,8 +2679,8 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
2702
2679
  )
2703
2680
  ];
2704
2681
  }
2705
- function getParser(options) {
2706
- const extensionTagNames = [
2682
+ function getExtensionTagNames(options) {
2683
+ return [
2707
2684
  ...options?.extensionRegistry?.extensions.flatMap(
2708
2685
  (extension) => (extension.constraintTags ?? []).map((tag) => normalizeFormSpecTagName2(tag.tagName))
2709
2686
  ) ?? [],
@@ -2711,14 +2688,6 @@ function getParser(options) {
2711
2688
  (extension) => (extension.metadataSlots ?? []).map((slot) => normalizeFormSpecTagName2(slot.tagName))
2712
2689
  ) ?? []
2713
2690
  ].sort();
2714
- const cacheKey = extensionTagNames.join("|");
2715
- const existing = parserCache.get(cacheKey);
2716
- if (existing) {
2717
- return existing;
2718
- }
2719
- const parser = new TSDocParser(createFormSpecTSDocConfig(extensionTagNames));
2720
- parserCache.set(cacheKey, parser);
2721
- return parser;
2722
2691
  }
2723
2692
  function getExtensionRegistryCacheKey(registry) {
2724
2693
  if (registry === void 0) {
@@ -2769,13 +2738,13 @@ function parseTSDocTags(node, file = "", options) {
2769
2738
  let placeholder;
2770
2739
  let displayNameProvenance;
2771
2740
  let placeholderProvenance;
2772
- const rawTextTags = [];
2773
2741
  const sourceFile = node.getSourceFile();
2774
2742
  const sourceText = sourceFile.getFullText();
2775
2743
  const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
2776
2744
  const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
2777
2745
  const commentRanges = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
2778
2746
  const rawTextFallbacks = collectRawTextFallbacks(node, file);
2747
+ const extensionTagNames = getExtensionTagNames(options);
2779
2748
  if (commentRanges) {
2780
2749
  for (const range of commentRanges) {
2781
2750
  if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
@@ -2785,38 +2754,18 @@ function parseTSDocTags(node, file = "", options) {
2785
2754
  if (!commentText.startsWith("/**")) {
2786
2755
  continue;
2787
2756
  }
2788
- const parser = getParser(options);
2789
- const parserContext = parser.parseRange(
2790
- TextRange.fromStringRange(sourceText, range.pos, range.end)
2791
- );
2792
- const docComment = parserContext.docComment;
2793
- const parsedComment = parseCommentBlock(
2794
- commentText,
2795
- sharedCommentSyntaxOptions(options, range.pos)
2796
- );
2797
- let parsedTagCursor = 0;
2798
- const nextParsedTag = (normalizedTagName) => {
2799
- while (parsedTagCursor < parsedComment.tags.length) {
2800
- const candidate = parsedComment.tags[parsedTagCursor];
2801
- parsedTagCursor += 1;
2802
- if (candidate?.normalizedTagName === normalizedTagName) {
2803
- return candidate;
2804
- }
2805
- }
2806
- return null;
2807
- };
2808
- for (const parsedTag of parsedComment.tags) {
2809
- if (TAGS_REQUIRING_RAW_TEXT.has(parsedTag.normalizedTagName)) {
2810
- rawTextTags.push({ tag: parsedTag, commentText, commentOffset: range.pos });
2811
- }
2812
- }
2813
- for (const block of docComment.customBlocks) {
2814
- const tagName = normalizeConstraintTagName2(block.blockTag.tagName.substring(1));
2815
- const parsedTag = nextParsedTag(tagName);
2757
+ const extensions = options?.extensionRegistry?.extensions;
2758
+ const unified = parseUnifiedComment(commentText, {
2759
+ offset: range.pos,
2760
+ extensionTagNames,
2761
+ ...extensions !== void 0 ? { extensions } : {}
2762
+ });
2763
+ for (const tag of unified.tags) {
2764
+ const tagName = tag.normalizedTagName;
2816
2765
  if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
2817
- const text2 = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
2766
+ const text2 = tag.resolvedPayloadText;
2818
2767
  if (text2 === "") continue;
2819
- const provenance2 = parsedTag !== null ? provenanceForParsedTag(parsedTag, sourceFile, file) : provenanceForComment(range, sourceFile, file, tagName);
2768
+ const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
2820
2769
  switch (tagName) {
2821
2770
  case "displayName":
2822
2771
  if (!isMemberTargetDisplayName(text2) && displayName === void 0) {
@@ -2841,64 +2790,69 @@ function parseTSDocTags(node, file = "", options) {
2841
2790
  }
2842
2791
  continue;
2843
2792
  }
2844
- if (TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
2845
- const text = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
2846
- const expectedType = isBuiltinConstraintName(tagName) ? BUILTIN_CONSTRAINT_DEFINITIONS2[tagName] : void 0;
2847
- if (text === "" && expectedType !== "boolean") continue;
2848
- const provenance = parsedTag !== null ? provenanceForParsedTag(parsedTag, sourceFile, file) : provenanceForComment(range, sourceFile, file, tagName);
2849
- const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
2850
- node,
2851
- sourceFile,
2852
- tagName,
2853
- parsedTag,
2854
- provenance,
2855
- supportingDeclarations,
2856
- options
2857
- );
2858
- if (compilerDiagnostics.length > 0) {
2859
- pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2793
+ if (TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
2794
+ const fallback = rawTextFallbacks.get(tagName)?.shift();
2795
+ const text2 = choosePreferredPayloadText(tag.resolvedPayloadText, fallback?.text ?? "");
2796
+ if (text2 === "") continue;
2797
+ const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
2798
+ if (tagName === "defaultValue") {
2799
+ annotations.push(parseDefaultValueTagValue(text2, provenance2));
2800
+ continue;
2801
+ }
2802
+ processConstraintTag(
2803
+ tagName,
2804
+ text2,
2805
+ tag,
2806
+ provenance2,
2807
+ node,
2808
+ sourceFile,
2809
+ supportingDeclarations,
2810
+ options,
2811
+ constraints,
2812
+ diagnostics
2813
+ );
2860
2814
  continue;
2861
2815
  }
2862
- const constraintNode = parseConstraintTagValue(
2816
+ const text = tag.resolvedPayloadText;
2817
+ const expectedType = isBuiltinConstraintName(tagName) ? BUILTIN_CONSTRAINT_DEFINITIONS2[tagName] : void 0;
2818
+ if (text === "" && expectedType !== "boolean") continue;
2819
+ const provenance = provenanceForParsedTag(tag, sourceFile, file);
2820
+ processConstraintTag(
2863
2821
  tagName,
2864
2822
  text,
2823
+ tag,
2865
2824
  provenance,
2866
- sharedTagValueOptions(options)
2825
+ node,
2826
+ sourceFile,
2827
+ supportingDeclarations,
2828
+ options,
2829
+ constraints,
2830
+ diagnostics
2867
2831
  );
2868
- if (constraintNode) {
2869
- constraints.push(constraintNode);
2870
- }
2871
2832
  }
2872
- if (docComment.deprecatedBlock !== void 0) {
2873
- const message = extractBlockText(docComment.deprecatedBlock).trim();
2833
+ if (unified.isDeprecated) {
2874
2834
  annotations.push({
2875
2835
  kind: "annotation",
2876
2836
  annotationKind: "deprecated",
2877
- ...message !== "" && { message },
2837
+ ...unified.deprecationMessage !== "" && { message: unified.deprecationMessage },
2878
2838
  provenance: provenanceForComment(range, sourceFile, file, "deprecated")
2879
2839
  });
2880
2840
  }
2881
- {
2882
- const summary = extractPlainText(docComment.summarySection).trim();
2883
- if (summary !== "") {
2884
- annotations.push({
2885
- kind: "annotation",
2886
- annotationKind: "description",
2887
- value: summary,
2888
- provenance: provenanceForComment(range, sourceFile, file, "summary")
2889
- });
2890
- }
2841
+ if (unified.summaryText !== "") {
2842
+ annotations.push({
2843
+ kind: "annotation",
2844
+ annotationKind: "description",
2845
+ value: unified.summaryText,
2846
+ provenance: provenanceForComment(range, sourceFile, file, "summary")
2847
+ });
2891
2848
  }
2892
- if (docComment.remarksBlock !== void 0) {
2893
- const remarksText = extractBlockText(docComment.remarksBlock).trim();
2894
- if (remarksText !== "") {
2895
- annotations.push({
2896
- kind: "annotation",
2897
- annotationKind: "remarks",
2898
- value: remarksText,
2899
- provenance: provenanceForComment(range, sourceFile, file, "remarks")
2900
- });
2901
- }
2849
+ if (unified.remarksText !== "") {
2850
+ annotations.push({
2851
+ kind: "annotation",
2852
+ annotationKind: "remarks",
2853
+ value: unified.remarksText,
2854
+ provenance: provenanceForComment(range, sourceFile, file, "remarks")
2855
+ });
2902
2856
  }
2903
2857
  }
2904
2858
  }
@@ -2918,77 +2872,27 @@ function parseTSDocTags(node, file = "", options) {
2918
2872
  provenance: placeholderProvenance
2919
2873
  });
2920
2874
  }
2921
- if (rawTextTags.length > 0) {
2922
- for (const rawTextTag of rawTextTags) {
2923
- const fallbackQueue = rawTextFallbacks.get(rawTextTag.tag.normalizedTagName);
2924
- const fallback = fallbackQueue?.shift();
2925
- const text = choosePreferredPayloadText(
2926
- getSharedPayloadText(rawTextTag.tag, rawTextTag.commentText, rawTextTag.commentOffset),
2927
- fallback?.text ?? ""
2928
- );
2929
- if (text === "") continue;
2930
- const provenance = provenanceForParsedTag(rawTextTag.tag, sourceFile, file);
2931
- if (rawTextTag.tag.normalizedTagName === "defaultValue") {
2932
- const defaultValueNode = parseDefaultValueTagValue(text, provenance);
2933
- annotations.push(defaultValueNode);
2934
- continue;
2935
- }
2936
- const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
2937
- node,
2938
- sourceFile,
2939
- rawTextTag.tag.normalizedTagName,
2940
- rawTextTag.tag,
2941
- provenance,
2942
- supportingDeclarations,
2943
- options
2944
- );
2945
- if (compilerDiagnostics.length > 0) {
2946
- pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2947
- continue;
2948
- }
2949
- const constraintNode = parseConstraintTagValue(
2950
- rawTextTag.tag.normalizedTagName,
2951
- text,
2952
- provenance,
2953
- sharedTagValueOptions(options)
2954
- );
2955
- if (constraintNode) {
2956
- constraints.push(constraintNode);
2957
- }
2958
- }
2959
- }
2960
2875
  for (const [tagName, fallbacks] of rawTextFallbacks) {
2961
2876
  for (const fallback of fallbacks) {
2962
2877
  const text = fallback.text.trim();
2963
2878
  if (text === "") continue;
2964
2879
  const provenance = fallback.provenance;
2965
2880
  if (tagName === "defaultValue") {
2966
- const defaultValueNode = parseDefaultValueTagValue(text, provenance);
2967
- annotations.push(defaultValueNode);
2881
+ annotations.push(parseDefaultValueTagValue(text, provenance));
2968
2882
  continue;
2969
2883
  }
2970
- const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
2971
- node,
2972
- sourceFile,
2884
+ processConstraintTag(
2973
2885
  tagName,
2886
+ text,
2974
2887
  null,
2975
2888
  provenance,
2889
+ node,
2890
+ sourceFile,
2976
2891
  supportingDeclarations,
2977
- options
2978
- );
2979
- if (compilerDiagnostics.length > 0) {
2980
- pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
2981
- continue;
2982
- }
2983
- const constraintNode = parseConstraintTagValue(
2984
- tagName,
2985
- text,
2986
- provenance,
2987
- sharedTagValueOptions(options)
2892
+ options,
2893
+ constraints,
2894
+ diagnostics
2988
2895
  );
2989
- if (constraintNode) {
2990
- constraints.push(constraintNode);
2991
- }
2992
2896
  }
2993
2897
  }
2994
2898
  const result = { constraints, annotations, diagnostics };
@@ -3006,8 +2910,8 @@ function extractDisplayNameMetadata(node) {
3006
2910
  if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) continue;
3007
2911
  const commentText = sourceText.substring(range.pos, range.end);
3008
2912
  if (!commentText.startsWith("/**")) continue;
3009
- const parsed = parseCommentBlock(commentText);
3010
- for (const tag of parsed.tags) {
2913
+ const unified = parseUnifiedComment(commentText);
2914
+ for (const tag of unified.tags) {
3011
2915
  if (tag.normalizedTagName !== "displayName") {
3012
2916
  continue;
3013
2917
  }
@@ -3026,51 +2930,6 @@ function extractDisplayNameMetadata(node) {
3026
2930
  memberDisplayNames
3027
2931
  };
3028
2932
  }
3029
- function extractBlockText(block) {
3030
- return extractPlainText(block.content);
3031
- }
3032
- function extractPlainText(node) {
3033
- let result = "";
3034
- if (node instanceof DocExcerpt) {
3035
- return node.content.toString();
3036
- }
3037
- if (node instanceof DocPlainText) {
3038
- return node.text;
3039
- }
3040
- if (node instanceof DocSoftBreak) {
3041
- return " ";
3042
- }
3043
- if (typeof node.getChildNodes === "function") {
3044
- for (const child of node.getChildNodes()) {
3045
- result += extractPlainText(child);
3046
- }
3047
- }
3048
- return result;
3049
- }
3050
- function choosePreferredPayloadText(primary, fallback) {
3051
- const preferred = primary.trim();
3052
- const alternate = fallback.trim();
3053
- if (preferred === "") return alternate;
3054
- if (alternate === "") return preferred;
3055
- if (alternate.includes("\n")) return alternate;
3056
- if (alternate.length > preferred.length && alternate.startsWith(preferred)) {
3057
- return alternate;
3058
- }
3059
- return preferred;
3060
- }
3061
- function getSharedPayloadText(tag, commentText, commentOffset) {
3062
- if (tag.payloadSpan === null) {
3063
- return "";
3064
- }
3065
- return sliceCommentSpan(commentText, tag.payloadSpan, {
3066
- offset: commentOffset
3067
- }).trim();
3068
- }
3069
- function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
3070
- const sharedText = tag === null ? "" : getSharedPayloadText(tag, commentText, commentOffset);
3071
- const blockText = extractBlockText(block).replace(/\s+/g, " ").trim();
3072
- return choosePreferredPayloadText(sharedText, blockText);
3073
- }
3074
2933
  function collectRawTextFallbacks(node, file) {
3075
2934
  const fallbacks = /* @__PURE__ */ new Map();
3076
2935
  for (const tag of ts.getJSDocTags(node)) {
@@ -3130,13 +2989,11 @@ function getTagCommentText(tag) {
3130
2989
  }
3131
2990
  return ts.getTextOfJSDocComment(tag.comment);
3132
2991
  }
3133
- var TAGS_REQUIRING_RAW_TEXT, SYNTHETIC_TYPE_FORMAT_FLAGS, parserCache, parseResultCache;
2992
+ var SYNTHETIC_TYPE_FORMAT_FLAGS, parseResultCache;
3134
2993
  var init_tsdoc_parser = __esm({
3135
2994
  "src/analyzer/tsdoc-parser.ts"() {
3136
2995
  "use strict";
3137
- TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
3138
2996
  SYNTHETIC_TYPE_FORMAT_FLAGS = ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
3139
- parserCache = /* @__PURE__ */ new Map();
3140
2997
  parseResultCache = /* @__PURE__ */ new Map();
3141
2998
  }
3142
2999
  });
@@ -3198,7 +3055,7 @@ var init_jsdoc_constraints = __esm({
3198
3055
  import * as ts3 from "typescript";
3199
3056
  import {
3200
3057
  analyzeMetadataForNodeWithChecker,
3201
- parseCommentBlock as parseCommentBlock2
3058
+ parseCommentBlock
3202
3059
  } from "@formspec/analysis/internal";
3203
3060
  function isObjectType(type) {
3204
3061
  return !!(type.flags & ts3.TypeFlags.Object);
@@ -3206,6 +3063,31 @@ function isObjectType(type) {
3206
3063
  function isIntersectionType(type) {
3207
3064
  return !!(type.flags & ts3.TypeFlags.Intersection);
3208
3065
  }
3066
+ function isIntegerBrandedType(type) {
3067
+ if (!type.isIntersection()) {
3068
+ return false;
3069
+ }
3070
+ const hasNumberBase = type.types.some(
3071
+ (member) => !!(member.flags & ts3.TypeFlags.Number)
3072
+ );
3073
+ if (!hasNumberBase) {
3074
+ return false;
3075
+ }
3076
+ return type.getProperties().some((prop) => {
3077
+ const declaration = prop.valueDeclaration ?? prop.declarations?.[0];
3078
+ if (declaration === void 0) {
3079
+ return false;
3080
+ }
3081
+ if (!ts3.isPropertySignature(declaration) && !ts3.isPropertyDeclaration(declaration)) {
3082
+ return false;
3083
+ }
3084
+ const name = declaration.name;
3085
+ if (!ts3.isComputedPropertyName(name)) {
3086
+ return false;
3087
+ }
3088
+ return ts3.isIdentifier(name.expression) && name.expression.text === "__integerBrand";
3089
+ });
3090
+ }
3209
3091
  function isResolvableObjectLikeAliasTypeNode(typeNode) {
3210
3092
  if (ts3.isParenthesizedTypeNode(typeNode)) {
3211
3093
  return isResolvableObjectLikeAliasTypeNode(typeNode.type);
@@ -3585,7 +3467,7 @@ function getLeadingParsedTags(node) {
3585
3467
  if (!commentText.startsWith("/**")) {
3586
3468
  continue;
3587
3469
  }
3588
- parsedTags.push(...parseCommentBlock2(commentText, { offset: range.pos }).tags);
3470
+ parsedTags.push(...parseCommentBlock(commentText, { offset: range.pos }).tags);
3589
3471
  }
3590
3472
  return parsedTags;
3591
3473
  }
@@ -4326,6 +4208,9 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4326
4208
  if (primitiveAlias) {
4327
4209
  return primitiveAlias;
4328
4210
  }
4211
+ if (isIntegerBrandedType(type)) {
4212
+ return { kind: "primitive", primitiveKind: "integer" };
4213
+ }
4329
4214
  if (type.flags & ts3.TypeFlags.String) {
4330
4215
  return { kind: "primitive", primitiveKind: "string" };
4331
4216
  }
@@ -4428,7 +4313,7 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
4428
4313
  return { kind: "primitive", primitiveKind: "string" };
4429
4314
  }
4430
4315
  function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
4431
- if (!(type.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null))) {
4316
+ if (!(type.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
4432
4317
  return null;
4433
4318
  }
4434
4319
  const aliasDecl = type.aliasSymbol?.declarations?.find(ts3.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
@@ -4514,6 +4399,9 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
4514
4399
  visitedAliases
4515
4400
  );
4516
4401
  }
4402
+ if (isIntegerBrandedType(type)) {
4403
+ return { kind: "primitive", primitiveKind: "integer" };
4404
+ }
4517
4405
  if (type.flags & ts3.TypeFlags.String) {
4518
4406
  return { kind: "primitive", primitiveKind: "string" };
4519
4407
  }
@@ -4737,7 +4625,7 @@ function typeNodeContainsReference(type, targetName) {
4737
4625
  }
4738
4626
  }
4739
4627
  function shouldEmitResolvedObjectProperty(property, declaration) {
4740
- if (property.name.startsWith("__@")) {
4628
+ if (property.name.startsWith("__")) {
4741
4629
  return false;
4742
4630
  }
4743
4631
  if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
@@ -5766,7 +5654,9 @@ function generateSchemasFromClass(options) {
5766
5654
  classDecl,
5767
5655
  ctx.checker,
5768
5656
  options.filePath,
5657
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5769
5658
  options.extensionRegistry,
5659
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5770
5660
  options.metadata,
5771
5661
  options.discriminator
5772
5662
  );
@@ -5774,9 +5664,13 @@ function generateSchemasFromClass(options) {
5774
5664
  analysis,
5775
5665
  { file: options.filePath },
5776
5666
  {
5667
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5777
5668
  extensionRegistry: options.extensionRegistry,
5669
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5778
5670
  metadata: options.metadata,
5671
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5779
5672
  enumSerialization: options.enumSerialization,
5673
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5780
5674
  vendorPrefix: options.vendorPrefix
5781
5675
  }
5782
5676
  );
@@ -5823,7 +5717,12 @@ function generateSchemasDetailedInternal(options) {
5823
5717
  diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
5824
5718
  };
5825
5719
  }
5826
- return generateSchemasFromDetailedProgramContext(ctx, options.filePath, options.typeName, options);
5720
+ return generateSchemasFromDetailedProgramContext(
5721
+ ctx,
5722
+ options.filePath,
5723
+ options.typeName,
5724
+ options
5725
+ );
5827
5726
  }
5828
5727
  function generateSchemasFromProgramDetailed(options) {
5829
5728
  return generateSchemasFromProgram({
@@ -5841,7 +5740,12 @@ function generateSchemasFromProgramDetailedInternal(options) {
5841
5740
  diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
5842
5741
  };
5843
5742
  }
5844
- return generateSchemasFromDetailedProgramContext(ctx, options.filePath, options.typeName, options);
5743
+ return generateSchemasFromDetailedProgramContext(
5744
+ ctx,
5745
+ options.filePath,
5746
+ options.typeName,
5747
+ options
5748
+ );
5845
5749
  }
5846
5750
  function generateSchemasBatch(options) {
5847
5751
  const contextCache = /* @__PURE__ */ new Map();
@@ -5885,13 +5789,27 @@ function generateSchemasBatchFromProgram(options) {
5885
5789
  );
5886
5790
  });
5887
5791
  }
5792
+ function resolveOptions(options) {
5793
+ const configRegistry = options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
5794
+ return {
5795
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5796
+ extensionRegistry: options.extensionRegistry ?? configRegistry,
5797
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5798
+ vendorPrefix: options.vendorPrefix ?? options.config?.vendorPrefix,
5799
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5800
+ enumSerialization: options.enumSerialization ?? options.config?.enumSerialization,
5801
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
5802
+ metadata: options.metadata ?? options.config?.metadata
5803
+ };
5804
+ }
5888
5805
  function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, options) {
5806
+ const resolved = resolveOptions(options);
5889
5807
  const analysisResult = analyzeNamedTypeToIRFromProgramContextDetailed(
5890
5808
  ctx,
5891
5809
  filePath,
5892
5810
  typeName,
5893
- options.extensionRegistry,
5894
- options.metadata,
5811
+ resolved.extensionRegistry,
5812
+ resolved.metadata,
5895
5813
  options.discriminator
5896
5814
  );
5897
5815
  if (!analysisResult.ok) {
@@ -5904,10 +5822,10 @@ function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, opti
5904
5822
  analysisResult.analysis,
5905
5823
  { file: filePath },
5906
5824
  {
5907
- extensionRegistry: options.extensionRegistry,
5908
- metadata: options.metadata,
5909
- enumSerialization: options.enumSerialization,
5910
- vendorPrefix: options.vendorPrefix
5825
+ extensionRegistry: resolved.extensionRegistry,
5826
+ metadata: resolved.metadata,
5827
+ enumSerialization: resolved.enumSerialization,
5828
+ vendorPrefix: resolved.vendorPrefix
5911
5829
  }
5912
5830
  );
5913
5831
  }
@@ -5939,6 +5857,7 @@ var init_class_schema = __esm({
5939
5857
  init_class_analyzer();
5940
5858
  init_canonicalize();
5941
5859
  init_ir_generator();
5860
+ init_extensions();
5942
5861
  init_ir_generator2();
5943
5862
  init_validate();
5944
5863
  }
@@ -6061,6 +5980,7 @@ function omitApiName(metadata) {
6061
5980
  }
6062
5981
  function enforceRequiredMetadata(metadata, declarationKind, logicalName, options) {
6063
5982
  const declarationPolicy = getDeclarationMetadataPolicy(
5983
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6064
5984
  normalizeMetadataPolicy(options.metadata),
6065
5985
  declarationKind
6066
5986
  );
@@ -6135,6 +6055,7 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
6135
6055
  provenance: syntheticField.provenance
6136
6056
  },
6137
6057
  {
6058
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6138
6059
  policy: normalizeMetadataPolicy(options?.metadata),
6139
6060
  surface: "tsdoc",
6140
6061
  rootLogicalName: root.name
@@ -6143,8 +6064,11 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
6143
6064
  const schema = generateJsonSchemaFromIR(
6144
6065
  ir,
6145
6066
  {
6067
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6146
6068
  extensionRegistry: options?.extensionRegistry,
6069
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6147
6070
  enumSerialization: options?.enumSerialization,
6071
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6148
6072
  vendorPrefix: options?.vendorPrefix
6149
6073
  }
6150
6074
  );
@@ -6170,9 +6094,13 @@ function generateSchemasFromAnalysis(analysis, filePath, options) {
6170
6094
  analysis,
6171
6095
  { file: filePath },
6172
6096
  {
6097
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6173
6098
  extensionRegistry: options?.extensionRegistry,
6099
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6174
6100
  enumSerialization: options?.enumSerialization,
6101
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6175
6102
  metadata: options?.metadata,
6103
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6176
6104
  vendorPrefix: options?.vendorPrefix
6177
6105
  }
6178
6106
  ),
@@ -6197,7 +6125,9 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
6197
6125
  typeRegistry,
6198
6126
  /* @__PURE__ */ new Set(),
6199
6127
  options.sourceNode,
6128
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6200
6129
  createAnalyzerMetadataPolicy(options.metadata, options.discriminator),
6130
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6201
6131
  options.extensionRegistry,
6202
6132
  diagnostics
6203
6133
  );
@@ -6246,7 +6176,9 @@ function generateSchemasFromDeclaration(options) {
6246
6176
  options.declaration,
6247
6177
  options.context.checker,
6248
6178
  filePath,
6179
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6249
6180
  options.extensionRegistry,
6181
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6250
6182
  options.metadata,
6251
6183
  options.discriminator
6252
6184
  ),
@@ -6260,7 +6192,9 @@ function generateSchemasFromDeclaration(options) {
6260
6192
  options.declaration,
6261
6193
  options.context.checker,
6262
6194
  filePath,
6195
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6263
6196
  options.extensionRegistry,
6197
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6264
6198
  options.metadata,
6265
6199
  options.discriminator
6266
6200
  ),
@@ -6273,7 +6207,9 @@ function generateSchemasFromDeclaration(options) {
6273
6207
  options.declaration,
6274
6208
  options.context.checker,
6275
6209
  filePath,
6210
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6276
6211
  options.extensionRegistry,
6212
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6277
6213
  options.metadata,
6278
6214
  options.discriminator
6279
6215
  );
@@ -6284,7 +6220,9 @@ function generateSchemasFromDeclaration(options) {
6284
6220
  options.declaration,
6285
6221
  options.context.checker,
6286
6222
  filePath,
6223
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6287
6224
  options.extensionRegistry,
6225
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6288
6226
  options.metadata
6289
6227
  );
6290
6228
  if (aliasRootInfo.diagnostics.length > 0) {
@@ -6339,7 +6277,9 @@ function resolveDeclarationMetadata(options) {
6339
6277
  const analysis = analyzeMetadataForNodeWithChecker2({
6340
6278
  checker: options.context.checker,
6341
6279
  node: options.declaration,
6280
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6342
6281
  metadata: options.metadata,
6282
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6343
6283
  extensions: options.extensionRegistry?.extensions,
6344
6284
  buildContext: options.context
6345
6285
  });
@@ -6385,7 +6325,9 @@ function buildMixedAuthoringSchemas(options) {
6385
6325
  const analysis = analyzeNamedTypeToIR(
6386
6326
  filePath,
6387
6327
  typeName,
6328
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6388
6329
  schemaOptions.extensionRegistry,
6330
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6389
6331
  schemaOptions.metadata,
6390
6332
  schemaOptions.discriminator
6391
6333
  );
@@ -6393,6 +6335,7 @@ function buildMixedAuthoringSchemas(options) {
6393
6335
  const ir = canonicalizeTSDoc(
6394
6336
  composedAnalysis,
6395
6337
  { file: filePath },
6338
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
6396
6339
  schemaOptions.metadata !== void 0 ? { metadata: schemaOptions.metadata } : void 0
6397
6340
  );
6398
6341
  return {