@formspec/build 0.1.0-alpha.42 → 0.1.0-alpha.43
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/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts +5 -7
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/build-alpha.d.ts +807 -1
- package/dist/build-beta.d.ts +807 -1
- package/dist/build-internal.d.ts +807 -1
- package/dist/build.d.ts +807 -1
- package/dist/cli.cjs +162 -242
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +167 -255
- package/dist/cli.js.map +1 -1
- package/dist/generators/class-schema.d.ts +15 -2
- package/dist/generators/class-schema.d.ts.map +1 -1
- package/dist/generators/discovered-schema.d.ts.map +1 -1
- package/dist/generators/mixed-authoring.d.ts.map +1 -1
- package/dist/index.cjs +160 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +165 -254
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +239 -374
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +247 -390
- package/dist/internals.js.map +1 -1
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -2150,7 +2150,7 @@ import * as path from "path";
|
|
|
2150
2150
|
import * as ts3 from "typescript";
|
|
2151
2151
|
import {
|
|
2152
2152
|
analyzeMetadataForNodeWithChecker,
|
|
2153
|
-
parseCommentBlock
|
|
2153
|
+
parseCommentBlock
|
|
2154
2154
|
} from "@formspec/analysis/internal";
|
|
2155
2155
|
|
|
2156
2156
|
// src/analyzer/jsdoc-constraints.ts
|
|
@@ -2160,73 +2160,25 @@ import * as ts2 from "typescript";
|
|
|
2160
2160
|
import * as ts from "typescript";
|
|
2161
2161
|
import {
|
|
2162
2162
|
checkSyntheticTagApplication,
|
|
2163
|
+
choosePreferredPayloadText,
|
|
2163
2164
|
extractPathTarget as extractSharedPathTarget,
|
|
2164
2165
|
getTagDefinition as getTagDefinition2,
|
|
2165
2166
|
hasTypeSemanticCapability,
|
|
2166
2167
|
normalizeFormSpecTagName as normalizeFormSpecTagName2,
|
|
2167
2168
|
parseConstraintTagValue,
|
|
2168
2169
|
parseDefaultValueTagValue,
|
|
2170
|
+
parseTagSyntax,
|
|
2171
|
+
parseUnifiedComment,
|
|
2169
2172
|
resolveDeclarationPlacement,
|
|
2170
2173
|
resolvePathTargetType,
|
|
2171
|
-
|
|
2172
|
-
parseCommentBlock,
|
|
2173
|
-
parseTagSyntax
|
|
2174
|
+
TAGS_REQUIRING_RAW_TEXT
|
|
2174
2175
|
} from "@formspec/analysis/internal";
|
|
2175
|
-
import {
|
|
2176
|
-
TSDocParser,
|
|
2177
|
-
TSDocConfiguration,
|
|
2178
|
-
TSDocTagDefinition,
|
|
2179
|
-
TSDocTagSyntaxKind,
|
|
2180
|
-
DocExcerpt,
|
|
2181
|
-
DocPlainText,
|
|
2182
|
-
DocSoftBreak,
|
|
2183
|
-
TextRange
|
|
2184
|
-
} from "@microsoft/tsdoc";
|
|
2185
2176
|
import {
|
|
2186
2177
|
BUILTIN_CONSTRAINT_DEFINITIONS as BUILTIN_CONSTRAINT_DEFINITIONS2,
|
|
2187
2178
|
normalizeConstraintTagName as normalizeConstraintTagName2,
|
|
2188
2179
|
isBuiltinConstraintName
|
|
2189
2180
|
} from "@formspec/core/internals";
|
|
2190
2181
|
import "@formspec/core/internals";
|
|
2191
|
-
var TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
|
|
2192
|
-
function createFormSpecTSDocConfig(extensionTagNames = []) {
|
|
2193
|
-
const config = new TSDocConfiguration();
|
|
2194
|
-
for (const tagName of Object.keys(BUILTIN_CONSTRAINT_DEFINITIONS2)) {
|
|
2195
|
-
config.addTagDefinition(
|
|
2196
|
-
new TSDocTagDefinition({
|
|
2197
|
-
tagName: "@" + tagName,
|
|
2198
|
-
syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
|
2199
|
-
allowMultiple: true
|
|
2200
|
-
})
|
|
2201
|
-
);
|
|
2202
|
-
}
|
|
2203
|
-
for (const tagName of ["apiName", "displayName", "format", "placeholder"]) {
|
|
2204
|
-
config.addTagDefinition(
|
|
2205
|
-
new TSDocTagDefinition({
|
|
2206
|
-
tagName: "@" + tagName,
|
|
2207
|
-
syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
|
2208
|
-
allowMultiple: true
|
|
2209
|
-
})
|
|
2210
|
-
);
|
|
2211
|
-
}
|
|
2212
|
-
for (const tagName of extensionTagNames) {
|
|
2213
|
-
config.addTagDefinition(
|
|
2214
|
-
new TSDocTagDefinition({
|
|
2215
|
-
tagName: "@" + tagName,
|
|
2216
|
-
syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
|
2217
|
-
allowMultiple: true
|
|
2218
|
-
})
|
|
2219
|
-
);
|
|
2220
|
-
}
|
|
2221
|
-
return config;
|
|
2222
|
-
}
|
|
2223
|
-
function sharedCommentSyntaxOptions(options, offset) {
|
|
2224
|
-
const extensions = options?.extensionRegistry?.extensions;
|
|
2225
|
-
return {
|
|
2226
|
-
...offset !== void 0 ? { offset } : {},
|
|
2227
|
-
...extensions !== void 0 ? { extensions } : {}
|
|
2228
|
-
};
|
|
2229
|
-
}
|
|
2230
2182
|
function sharedTagValueOptions(options) {
|
|
2231
2183
|
return {
|
|
2232
2184
|
...options?.extensionRegistry !== void 0 ? { registry: options.extensionRegistry } : {},
|
|
@@ -2326,6 +2278,30 @@ function pushUniqueCompilerDiagnostics(target, additions) {
|
|
|
2326
2278
|
target.push(diagnostic);
|
|
2327
2279
|
}
|
|
2328
2280
|
}
|
|
2281
|
+
function processConstraintTag(tagName, text, parsedTag, provenance, node, sourceFile, supportingDeclarations, options, constraints, diagnostics) {
|
|
2282
|
+
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
2283
|
+
node,
|
|
2284
|
+
sourceFile,
|
|
2285
|
+
tagName,
|
|
2286
|
+
parsedTag,
|
|
2287
|
+
provenance,
|
|
2288
|
+
supportingDeclarations,
|
|
2289
|
+
options
|
|
2290
|
+
);
|
|
2291
|
+
if (compilerDiagnostics.length > 0) {
|
|
2292
|
+
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2293
|
+
return;
|
|
2294
|
+
}
|
|
2295
|
+
const constraintNode = parseConstraintTagValue(
|
|
2296
|
+
tagName,
|
|
2297
|
+
text,
|
|
2298
|
+
provenance,
|
|
2299
|
+
sharedTagValueOptions(options)
|
|
2300
|
+
);
|
|
2301
|
+
if (constraintNode) {
|
|
2302
|
+
constraints.push(constraintNode);
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2329
2305
|
function renderSyntheticArgumentExpression(valueKind, argumentText) {
|
|
2330
2306
|
const trimmed = argumentText.trim();
|
|
2331
2307
|
if (trimmed === "") {
|
|
@@ -2611,10 +2587,9 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
2611
2587
|
)
|
|
2612
2588
|
];
|
|
2613
2589
|
}
|
|
2614
|
-
var parserCache = /* @__PURE__ */ new Map();
|
|
2615
2590
|
var parseResultCache = /* @__PURE__ */ new Map();
|
|
2616
|
-
function
|
|
2617
|
-
|
|
2591
|
+
function getExtensionTagNames(options) {
|
|
2592
|
+
return [
|
|
2618
2593
|
...options?.extensionRegistry?.extensions.flatMap(
|
|
2619
2594
|
(extension) => (extension.constraintTags ?? []).map((tag) => normalizeFormSpecTagName2(tag.tagName))
|
|
2620
2595
|
) ?? [],
|
|
@@ -2622,14 +2597,6 @@ function getParser(options) {
|
|
|
2622
2597
|
(extension) => (extension.metadataSlots ?? []).map((slot) => normalizeFormSpecTagName2(slot.tagName))
|
|
2623
2598
|
) ?? []
|
|
2624
2599
|
].sort();
|
|
2625
|
-
const cacheKey = extensionTagNames.join("|");
|
|
2626
|
-
const existing = parserCache.get(cacheKey);
|
|
2627
|
-
if (existing) {
|
|
2628
|
-
return existing;
|
|
2629
|
-
}
|
|
2630
|
-
const parser = new TSDocParser(createFormSpecTSDocConfig(extensionTagNames));
|
|
2631
|
-
parserCache.set(cacheKey, parser);
|
|
2632
|
-
return parser;
|
|
2633
2600
|
}
|
|
2634
2601
|
function getExtensionRegistryCacheKey(registry) {
|
|
2635
2602
|
if (registry === void 0) {
|
|
@@ -2680,13 +2647,13 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2680
2647
|
let placeholder;
|
|
2681
2648
|
let displayNameProvenance;
|
|
2682
2649
|
let placeholderProvenance;
|
|
2683
|
-
const rawTextTags = [];
|
|
2684
2650
|
const sourceFile = node.getSourceFile();
|
|
2685
2651
|
const sourceText = sourceFile.getFullText();
|
|
2686
2652
|
const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
|
|
2687
2653
|
const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
|
|
2688
2654
|
const commentRanges = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
|
|
2689
2655
|
const rawTextFallbacks = collectRawTextFallbacks(node, file);
|
|
2656
|
+
const extensionTagNames = getExtensionTagNames(options);
|
|
2690
2657
|
if (commentRanges) {
|
|
2691
2658
|
for (const range of commentRanges) {
|
|
2692
2659
|
if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
|
|
@@ -2696,38 +2663,18 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2696
2663
|
if (!commentText.startsWith("/**")) {
|
|
2697
2664
|
continue;
|
|
2698
2665
|
}
|
|
2699
|
-
const
|
|
2700
|
-
const
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
);
|
|
2708
|
-
let parsedTagCursor = 0;
|
|
2709
|
-
const nextParsedTag = (normalizedTagName) => {
|
|
2710
|
-
while (parsedTagCursor < parsedComment.tags.length) {
|
|
2711
|
-
const candidate = parsedComment.tags[parsedTagCursor];
|
|
2712
|
-
parsedTagCursor += 1;
|
|
2713
|
-
if (candidate?.normalizedTagName === normalizedTagName) {
|
|
2714
|
-
return candidate;
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
return null;
|
|
2718
|
-
};
|
|
2719
|
-
for (const parsedTag of parsedComment.tags) {
|
|
2720
|
-
if (TAGS_REQUIRING_RAW_TEXT.has(parsedTag.normalizedTagName)) {
|
|
2721
|
-
rawTextTags.push({ tag: parsedTag, commentText, commentOffset: range.pos });
|
|
2722
|
-
}
|
|
2723
|
-
}
|
|
2724
|
-
for (const block of docComment.customBlocks) {
|
|
2725
|
-
const tagName = normalizeConstraintTagName2(block.blockTag.tagName.substring(1));
|
|
2726
|
-
const parsedTag = nextParsedTag(tagName);
|
|
2666
|
+
const extensions = options?.extensionRegistry?.extensions;
|
|
2667
|
+
const unified = parseUnifiedComment(commentText, {
|
|
2668
|
+
offset: range.pos,
|
|
2669
|
+
extensionTagNames,
|
|
2670
|
+
...extensions !== void 0 ? { extensions } : {}
|
|
2671
|
+
});
|
|
2672
|
+
for (const tag of unified.tags) {
|
|
2673
|
+
const tagName = tag.normalizedTagName;
|
|
2727
2674
|
if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
|
|
2728
|
-
const text2 =
|
|
2675
|
+
const text2 = tag.resolvedPayloadText;
|
|
2729
2676
|
if (text2 === "") continue;
|
|
2730
|
-
const provenance2 =
|
|
2677
|
+
const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
|
|
2731
2678
|
switch (tagName) {
|
|
2732
2679
|
case "displayName":
|
|
2733
2680
|
if (!isMemberTargetDisplayName(text2) && displayName === void 0) {
|
|
@@ -2752,64 +2699,69 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2752
2699
|
}
|
|
2753
2700
|
continue;
|
|
2754
2701
|
}
|
|
2755
|
-
if (TAGS_REQUIRING_RAW_TEXT.has(tagName))
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2702
|
+
if (TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
|
|
2703
|
+
const fallback = rawTextFallbacks.get(tagName)?.shift();
|
|
2704
|
+
const text2 = choosePreferredPayloadText(tag.resolvedPayloadText, fallback?.text ?? "");
|
|
2705
|
+
if (text2 === "") continue;
|
|
2706
|
+
const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
|
|
2707
|
+
if (tagName === "defaultValue") {
|
|
2708
|
+
annotations.push(parseDefaultValueTagValue(text2, provenance2));
|
|
2709
|
+
continue;
|
|
2710
|
+
}
|
|
2711
|
+
processConstraintTag(
|
|
2712
|
+
tagName,
|
|
2713
|
+
text2,
|
|
2714
|
+
tag,
|
|
2715
|
+
provenance2,
|
|
2716
|
+
node,
|
|
2717
|
+
sourceFile,
|
|
2718
|
+
supportingDeclarations,
|
|
2719
|
+
options,
|
|
2720
|
+
constraints,
|
|
2721
|
+
diagnostics
|
|
2722
|
+
);
|
|
2771
2723
|
continue;
|
|
2772
2724
|
}
|
|
2773
|
-
const
|
|
2725
|
+
const text = tag.resolvedPayloadText;
|
|
2726
|
+
const expectedType = isBuiltinConstraintName(tagName) ? BUILTIN_CONSTRAINT_DEFINITIONS2[tagName] : void 0;
|
|
2727
|
+
if (text === "" && expectedType !== "boolean") continue;
|
|
2728
|
+
const provenance = provenanceForParsedTag(tag, sourceFile, file);
|
|
2729
|
+
processConstraintTag(
|
|
2774
2730
|
tagName,
|
|
2775
2731
|
text,
|
|
2732
|
+
tag,
|
|
2776
2733
|
provenance,
|
|
2777
|
-
|
|
2734
|
+
node,
|
|
2735
|
+
sourceFile,
|
|
2736
|
+
supportingDeclarations,
|
|
2737
|
+
options,
|
|
2738
|
+
constraints,
|
|
2739
|
+
diagnostics
|
|
2778
2740
|
);
|
|
2779
|
-
if (constraintNode) {
|
|
2780
|
-
constraints.push(constraintNode);
|
|
2781
|
-
}
|
|
2782
2741
|
}
|
|
2783
|
-
if (
|
|
2784
|
-
const message = extractBlockText(docComment.deprecatedBlock).trim();
|
|
2742
|
+
if (unified.isDeprecated) {
|
|
2785
2743
|
annotations.push({
|
|
2786
2744
|
kind: "annotation",
|
|
2787
2745
|
annotationKind: "deprecated",
|
|
2788
|
-
...
|
|
2746
|
+
...unified.deprecationMessage !== "" && { message: unified.deprecationMessage },
|
|
2789
2747
|
provenance: provenanceForComment(range, sourceFile, file, "deprecated")
|
|
2790
2748
|
});
|
|
2791
2749
|
}
|
|
2792
|
-
{
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
provenance: provenanceForComment(range, sourceFile, file, "summary")
|
|
2800
|
-
});
|
|
2801
|
-
}
|
|
2750
|
+
if (unified.summaryText !== "") {
|
|
2751
|
+
annotations.push({
|
|
2752
|
+
kind: "annotation",
|
|
2753
|
+
annotationKind: "description",
|
|
2754
|
+
value: unified.summaryText,
|
|
2755
|
+
provenance: provenanceForComment(range, sourceFile, file, "summary")
|
|
2756
|
+
});
|
|
2802
2757
|
}
|
|
2803
|
-
if (
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
provenance: provenanceForComment(range, sourceFile, file, "remarks")
|
|
2811
|
-
});
|
|
2812
|
-
}
|
|
2758
|
+
if (unified.remarksText !== "") {
|
|
2759
|
+
annotations.push({
|
|
2760
|
+
kind: "annotation",
|
|
2761
|
+
annotationKind: "remarks",
|
|
2762
|
+
value: unified.remarksText,
|
|
2763
|
+
provenance: provenanceForComment(range, sourceFile, file, "remarks")
|
|
2764
|
+
});
|
|
2813
2765
|
}
|
|
2814
2766
|
}
|
|
2815
2767
|
}
|
|
@@ -2829,77 +2781,27 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2829
2781
|
provenance: placeholderProvenance
|
|
2830
2782
|
});
|
|
2831
2783
|
}
|
|
2832
|
-
if (rawTextTags.length > 0) {
|
|
2833
|
-
for (const rawTextTag of rawTextTags) {
|
|
2834
|
-
const fallbackQueue = rawTextFallbacks.get(rawTextTag.tag.normalizedTagName);
|
|
2835
|
-
const fallback = fallbackQueue?.shift();
|
|
2836
|
-
const text = choosePreferredPayloadText(
|
|
2837
|
-
getSharedPayloadText(rawTextTag.tag, rawTextTag.commentText, rawTextTag.commentOffset),
|
|
2838
|
-
fallback?.text ?? ""
|
|
2839
|
-
);
|
|
2840
|
-
if (text === "") continue;
|
|
2841
|
-
const provenance = provenanceForParsedTag(rawTextTag.tag, sourceFile, file);
|
|
2842
|
-
if (rawTextTag.tag.normalizedTagName === "defaultValue") {
|
|
2843
|
-
const defaultValueNode = parseDefaultValueTagValue(text, provenance);
|
|
2844
|
-
annotations.push(defaultValueNode);
|
|
2845
|
-
continue;
|
|
2846
|
-
}
|
|
2847
|
-
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
2848
|
-
node,
|
|
2849
|
-
sourceFile,
|
|
2850
|
-
rawTextTag.tag.normalizedTagName,
|
|
2851
|
-
rawTextTag.tag,
|
|
2852
|
-
provenance,
|
|
2853
|
-
supportingDeclarations,
|
|
2854
|
-
options
|
|
2855
|
-
);
|
|
2856
|
-
if (compilerDiagnostics.length > 0) {
|
|
2857
|
-
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2858
|
-
continue;
|
|
2859
|
-
}
|
|
2860
|
-
const constraintNode = parseConstraintTagValue(
|
|
2861
|
-
rawTextTag.tag.normalizedTagName,
|
|
2862
|
-
text,
|
|
2863
|
-
provenance,
|
|
2864
|
-
sharedTagValueOptions(options)
|
|
2865
|
-
);
|
|
2866
|
-
if (constraintNode) {
|
|
2867
|
-
constraints.push(constraintNode);
|
|
2868
|
-
}
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
2784
|
for (const [tagName, fallbacks] of rawTextFallbacks) {
|
|
2872
2785
|
for (const fallback of fallbacks) {
|
|
2873
2786
|
const text = fallback.text.trim();
|
|
2874
2787
|
if (text === "") continue;
|
|
2875
2788
|
const provenance = fallback.provenance;
|
|
2876
2789
|
if (tagName === "defaultValue") {
|
|
2877
|
-
|
|
2878
|
-
annotations.push(defaultValueNode);
|
|
2790
|
+
annotations.push(parseDefaultValueTagValue(text, provenance));
|
|
2879
2791
|
continue;
|
|
2880
2792
|
}
|
|
2881
|
-
|
|
2882
|
-
node,
|
|
2883
|
-
sourceFile,
|
|
2793
|
+
processConstraintTag(
|
|
2884
2794
|
tagName,
|
|
2795
|
+
text,
|
|
2885
2796
|
null,
|
|
2886
2797
|
provenance,
|
|
2798
|
+
node,
|
|
2799
|
+
sourceFile,
|
|
2887
2800
|
supportingDeclarations,
|
|
2888
|
-
options
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2892
|
-
continue;
|
|
2893
|
-
}
|
|
2894
|
-
const constraintNode = parseConstraintTagValue(
|
|
2895
|
-
tagName,
|
|
2896
|
-
text,
|
|
2897
|
-
provenance,
|
|
2898
|
-
sharedTagValueOptions(options)
|
|
2801
|
+
options,
|
|
2802
|
+
constraints,
|
|
2803
|
+
diagnostics
|
|
2899
2804
|
);
|
|
2900
|
-
if (constraintNode) {
|
|
2901
|
-
constraints.push(constraintNode);
|
|
2902
|
-
}
|
|
2903
2805
|
}
|
|
2904
2806
|
}
|
|
2905
2807
|
const result = { constraints, annotations, diagnostics };
|
|
@@ -2917,8 +2819,8 @@ function extractDisplayNameMetadata(node) {
|
|
|
2917
2819
|
if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) continue;
|
|
2918
2820
|
const commentText = sourceText.substring(range.pos, range.end);
|
|
2919
2821
|
if (!commentText.startsWith("/**")) continue;
|
|
2920
|
-
const
|
|
2921
|
-
for (const tag of
|
|
2822
|
+
const unified = parseUnifiedComment(commentText);
|
|
2823
|
+
for (const tag of unified.tags) {
|
|
2922
2824
|
if (tag.normalizedTagName !== "displayName") {
|
|
2923
2825
|
continue;
|
|
2924
2826
|
}
|
|
@@ -2937,51 +2839,6 @@ function extractDisplayNameMetadata(node) {
|
|
|
2937
2839
|
memberDisplayNames
|
|
2938
2840
|
};
|
|
2939
2841
|
}
|
|
2940
|
-
function extractBlockText(block) {
|
|
2941
|
-
return extractPlainText(block.content);
|
|
2942
|
-
}
|
|
2943
|
-
function extractPlainText(node) {
|
|
2944
|
-
let result = "";
|
|
2945
|
-
if (node instanceof DocExcerpt) {
|
|
2946
|
-
return node.content.toString();
|
|
2947
|
-
}
|
|
2948
|
-
if (node instanceof DocPlainText) {
|
|
2949
|
-
return node.text;
|
|
2950
|
-
}
|
|
2951
|
-
if (node instanceof DocSoftBreak) {
|
|
2952
|
-
return " ";
|
|
2953
|
-
}
|
|
2954
|
-
if (typeof node.getChildNodes === "function") {
|
|
2955
|
-
for (const child of node.getChildNodes()) {
|
|
2956
|
-
result += extractPlainText(child);
|
|
2957
|
-
}
|
|
2958
|
-
}
|
|
2959
|
-
return result;
|
|
2960
|
-
}
|
|
2961
|
-
function choosePreferredPayloadText(primary, fallback) {
|
|
2962
|
-
const preferred = primary.trim();
|
|
2963
|
-
const alternate = fallback.trim();
|
|
2964
|
-
if (preferred === "") return alternate;
|
|
2965
|
-
if (alternate === "") return preferred;
|
|
2966
|
-
if (alternate.includes("\n")) return alternate;
|
|
2967
|
-
if (alternate.length > preferred.length && alternate.startsWith(preferred)) {
|
|
2968
|
-
return alternate;
|
|
2969
|
-
}
|
|
2970
|
-
return preferred;
|
|
2971
|
-
}
|
|
2972
|
-
function getSharedPayloadText(tag, commentText, commentOffset) {
|
|
2973
|
-
if (tag.payloadSpan === null) {
|
|
2974
|
-
return "";
|
|
2975
|
-
}
|
|
2976
|
-
return sliceCommentSpan(commentText, tag.payloadSpan, {
|
|
2977
|
-
offset: commentOffset
|
|
2978
|
-
}).trim();
|
|
2979
|
-
}
|
|
2980
|
-
function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
|
|
2981
|
-
const sharedText = tag === null ? "" : getSharedPayloadText(tag, commentText, commentOffset);
|
|
2982
|
-
const blockText = extractBlockText(block).replace(/\s+/g, " ").trim();
|
|
2983
|
-
return choosePreferredPayloadText(sharedText, blockText);
|
|
2984
|
-
}
|
|
2985
2842
|
function collectRawTextFallbacks(node, file) {
|
|
2986
2843
|
const fallbacks = /* @__PURE__ */ new Map();
|
|
2987
2844
|
for (const tag of ts.getJSDocTags(node)) {
|
|
@@ -3479,7 +3336,7 @@ function getLeadingParsedTags(node) {
|
|
|
3479
3336
|
if (!commentText.startsWith("/**")) {
|
|
3480
3337
|
continue;
|
|
3481
3338
|
}
|
|
3482
|
-
parsedTags.push(...
|
|
3339
|
+
parsedTags.push(...parseCommentBlock(commentText, { offset: range.pos }).tags);
|
|
3483
3340
|
}
|
|
3484
3341
|
return parsedTags;
|
|
3485
3342
|
}
|
|
@@ -4631,7 +4488,7 @@ function typeNodeContainsReference(type, targetName) {
|
|
|
4631
4488
|
}
|
|
4632
4489
|
}
|
|
4633
4490
|
function shouldEmitResolvedObjectProperty(property, declaration) {
|
|
4634
|
-
if (property.name.startsWith("__
|
|
4491
|
+
if (property.name.startsWith("__")) {
|
|
4635
4492
|
return false;
|
|
4636
4493
|
}
|
|
4637
4494
|
if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
|
|
@@ -5624,7 +5481,9 @@ function generateSchemasFromClass(options) {
|
|
|
5624
5481
|
classDecl,
|
|
5625
5482
|
ctx.checker,
|
|
5626
5483
|
options.filePath,
|
|
5484
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5627
5485
|
options.extensionRegistry,
|
|
5486
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5628
5487
|
options.metadata,
|
|
5629
5488
|
options.discriminator
|
|
5630
5489
|
);
|
|
@@ -5632,9 +5491,13 @@ function generateSchemasFromClass(options) {
|
|
|
5632
5491
|
analysis,
|
|
5633
5492
|
{ file: options.filePath },
|
|
5634
5493
|
{
|
|
5494
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5635
5495
|
extensionRegistry: options.extensionRegistry,
|
|
5496
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5636
5497
|
metadata: options.metadata,
|
|
5498
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5637
5499
|
enumSerialization: options.enumSerialization,
|
|
5500
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5638
5501
|
vendorPrefix: options.vendorPrefix
|
|
5639
5502
|
}
|
|
5640
5503
|
);
|
|
@@ -5681,7 +5544,12 @@ function generateSchemasDetailedInternal(options) {
|
|
|
5681
5544
|
diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
|
|
5682
5545
|
};
|
|
5683
5546
|
}
|
|
5684
|
-
return generateSchemasFromDetailedProgramContext(
|
|
5547
|
+
return generateSchemasFromDetailedProgramContext(
|
|
5548
|
+
ctx,
|
|
5549
|
+
options.filePath,
|
|
5550
|
+
options.typeName,
|
|
5551
|
+
options
|
|
5552
|
+
);
|
|
5685
5553
|
}
|
|
5686
5554
|
function generateSchemasFromProgramDetailed(options) {
|
|
5687
5555
|
return generateSchemasFromProgram({
|
|
@@ -5699,7 +5567,12 @@ function generateSchemasFromProgramDetailedInternal(options) {
|
|
|
5699
5567
|
diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
|
|
5700
5568
|
};
|
|
5701
5569
|
}
|
|
5702
|
-
return generateSchemasFromDetailedProgramContext(
|
|
5570
|
+
return generateSchemasFromDetailedProgramContext(
|
|
5571
|
+
ctx,
|
|
5572
|
+
options.filePath,
|
|
5573
|
+
options.typeName,
|
|
5574
|
+
options
|
|
5575
|
+
);
|
|
5703
5576
|
}
|
|
5704
5577
|
function generateSchemasBatch(options) {
|
|
5705
5578
|
const contextCache = /* @__PURE__ */ new Map();
|
|
@@ -5743,13 +5616,27 @@ function generateSchemasBatchFromProgram(options) {
|
|
|
5743
5616
|
);
|
|
5744
5617
|
});
|
|
5745
5618
|
}
|
|
5619
|
+
function resolveOptions(options) {
|
|
5620
|
+
const configRegistry = options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
|
|
5621
|
+
return {
|
|
5622
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5623
|
+
extensionRegistry: options.extensionRegistry ?? configRegistry,
|
|
5624
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5625
|
+
vendorPrefix: options.vendorPrefix ?? options.config?.vendorPrefix,
|
|
5626
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5627
|
+
enumSerialization: options.enumSerialization ?? options.config?.enumSerialization,
|
|
5628
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5629
|
+
metadata: options.metadata ?? options.config?.metadata
|
|
5630
|
+
};
|
|
5631
|
+
}
|
|
5746
5632
|
function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, options) {
|
|
5633
|
+
const resolved = resolveOptions(options);
|
|
5747
5634
|
const analysisResult = analyzeNamedTypeToIRFromProgramContextDetailed(
|
|
5748
5635
|
ctx,
|
|
5749
5636
|
filePath,
|
|
5750
5637
|
typeName,
|
|
5751
|
-
|
|
5752
|
-
|
|
5638
|
+
resolved.extensionRegistry,
|
|
5639
|
+
resolved.metadata,
|
|
5753
5640
|
options.discriminator
|
|
5754
5641
|
);
|
|
5755
5642
|
if (!analysisResult.ok) {
|
|
@@ -5762,10 +5649,10 @@ function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, opti
|
|
|
5762
5649
|
analysisResult.analysis,
|
|
5763
5650
|
{ file: filePath },
|
|
5764
5651
|
{
|
|
5765
|
-
extensionRegistry:
|
|
5766
|
-
metadata:
|
|
5767
|
-
enumSerialization:
|
|
5768
|
-
vendorPrefix:
|
|
5652
|
+
extensionRegistry: resolved.extensionRegistry,
|
|
5653
|
+
metadata: resolved.metadata,
|
|
5654
|
+
enumSerialization: resolved.enumSerialization,
|
|
5655
|
+
vendorPrefix: resolved.vendorPrefix
|
|
5769
5656
|
}
|
|
5770
5657
|
);
|
|
5771
5658
|
}
|
|
@@ -5902,6 +5789,7 @@ function omitApiName(metadata) {
|
|
|
5902
5789
|
}
|
|
5903
5790
|
function enforceRequiredMetadata(metadata, declarationKind, logicalName, options) {
|
|
5904
5791
|
const declarationPolicy = getDeclarationMetadataPolicy(
|
|
5792
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5905
5793
|
normalizeMetadataPolicy(options.metadata),
|
|
5906
5794
|
declarationKind
|
|
5907
5795
|
);
|
|
@@ -5976,6 +5864,7 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
|
|
|
5976
5864
|
provenance: syntheticField.provenance
|
|
5977
5865
|
},
|
|
5978
5866
|
{
|
|
5867
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5979
5868
|
policy: normalizeMetadataPolicy(options?.metadata),
|
|
5980
5869
|
surface: "tsdoc",
|
|
5981
5870
|
rootLogicalName: root.name
|
|
@@ -5984,8 +5873,11 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
|
|
|
5984
5873
|
const schema = generateJsonSchemaFromIR(
|
|
5985
5874
|
ir,
|
|
5986
5875
|
{
|
|
5876
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5987
5877
|
extensionRegistry: options?.extensionRegistry,
|
|
5878
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5988
5879
|
enumSerialization: options?.enumSerialization,
|
|
5880
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5989
5881
|
vendorPrefix: options?.vendorPrefix
|
|
5990
5882
|
}
|
|
5991
5883
|
);
|
|
@@ -6011,9 +5903,13 @@ function generateSchemasFromAnalysis(analysis, filePath, options) {
|
|
|
6011
5903
|
analysis,
|
|
6012
5904
|
{ file: filePath },
|
|
6013
5905
|
{
|
|
5906
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6014
5907
|
extensionRegistry: options?.extensionRegistry,
|
|
5908
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6015
5909
|
enumSerialization: options?.enumSerialization,
|
|
5910
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6016
5911
|
metadata: options?.metadata,
|
|
5912
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6017
5913
|
vendorPrefix: options?.vendorPrefix
|
|
6018
5914
|
}
|
|
6019
5915
|
),
|
|
@@ -6038,7 +5934,9 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
|
|
|
6038
5934
|
typeRegistry,
|
|
6039
5935
|
/* @__PURE__ */ new Set(),
|
|
6040
5936
|
options.sourceNode,
|
|
5937
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6041
5938
|
createAnalyzerMetadataPolicy(options.metadata, options.discriminator),
|
|
5939
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6042
5940
|
options.extensionRegistry,
|
|
6043
5941
|
diagnostics
|
|
6044
5942
|
);
|
|
@@ -6087,7 +5985,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6087
5985
|
options.declaration,
|
|
6088
5986
|
options.context.checker,
|
|
6089
5987
|
filePath,
|
|
5988
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6090
5989
|
options.extensionRegistry,
|
|
5990
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6091
5991
|
options.metadata,
|
|
6092
5992
|
options.discriminator
|
|
6093
5993
|
),
|
|
@@ -6101,7 +6001,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6101
6001
|
options.declaration,
|
|
6102
6002
|
options.context.checker,
|
|
6103
6003
|
filePath,
|
|
6004
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6104
6005
|
options.extensionRegistry,
|
|
6006
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6105
6007
|
options.metadata,
|
|
6106
6008
|
options.discriminator
|
|
6107
6009
|
),
|
|
@@ -6114,7 +6016,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6114
6016
|
options.declaration,
|
|
6115
6017
|
options.context.checker,
|
|
6116
6018
|
filePath,
|
|
6019
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6117
6020
|
options.extensionRegistry,
|
|
6021
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6118
6022
|
options.metadata,
|
|
6119
6023
|
options.discriminator
|
|
6120
6024
|
);
|
|
@@ -6125,7 +6029,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6125
6029
|
options.declaration,
|
|
6126
6030
|
options.context.checker,
|
|
6127
6031
|
filePath,
|
|
6032
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6128
6033
|
options.extensionRegistry,
|
|
6034
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6129
6035
|
options.metadata
|
|
6130
6036
|
);
|
|
6131
6037
|
if (aliasRootInfo.diagnostics.length > 0) {
|
|
@@ -6180,7 +6086,9 @@ function resolveDeclarationMetadata(options) {
|
|
|
6180
6086
|
const analysis = analyzeMetadataForNodeWithChecker2({
|
|
6181
6087
|
checker: options.context.checker,
|
|
6182
6088
|
node: options.declaration,
|
|
6089
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6183
6090
|
metadata: options.metadata,
|
|
6091
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6184
6092
|
extensions: options.extensionRegistry?.extensions,
|
|
6185
6093
|
buildContext: options.context
|
|
6186
6094
|
});
|
|
@@ -6217,7 +6125,9 @@ function buildMixedAuthoringSchemas(options) {
|
|
|
6217
6125
|
const analysis = analyzeNamedTypeToIR(
|
|
6218
6126
|
filePath,
|
|
6219
6127
|
typeName,
|
|
6128
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6220
6129
|
schemaOptions.extensionRegistry,
|
|
6130
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6221
6131
|
schemaOptions.metadata,
|
|
6222
6132
|
schemaOptions.discriminator
|
|
6223
6133
|
);
|
|
@@ -6225,6 +6135,7 @@ function buildMixedAuthoringSchemas(options) {
|
|
|
6225
6135
|
const ir = canonicalizeTSDoc(
|
|
6226
6136
|
composedAnalysis,
|
|
6227
6137
|
{ file: filePath },
|
|
6138
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6228
6139
|
schemaOptions.metadata !== void 0 ? { metadata: schemaOptions.metadata } : void 0
|
|
6229
6140
|
);
|
|
6230
6141
|
return {
|