@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.cjs
CHANGED
|
@@ -2209,48 +2209,8 @@ var ts2 = __toESM(require("typescript"), 1);
|
|
|
2209
2209
|
// src/analyzer/tsdoc-parser.ts
|
|
2210
2210
|
var ts = __toESM(require("typescript"), 1);
|
|
2211
2211
|
var import_internal2 = require("@formspec/analysis/internal");
|
|
2212
|
-
var import_tsdoc = require("@microsoft/tsdoc");
|
|
2213
2212
|
var import_internals4 = require("@formspec/core/internals");
|
|
2214
2213
|
var import_internals5 = require("@formspec/core/internals");
|
|
2215
|
-
var TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
|
|
2216
|
-
function createFormSpecTSDocConfig(extensionTagNames = []) {
|
|
2217
|
-
const config = new import_tsdoc.TSDocConfiguration();
|
|
2218
|
-
for (const tagName of Object.keys(import_internals4.BUILTIN_CONSTRAINT_DEFINITIONS)) {
|
|
2219
|
-
config.addTagDefinition(
|
|
2220
|
-
new import_tsdoc.TSDocTagDefinition({
|
|
2221
|
-
tagName: "@" + tagName,
|
|
2222
|
-
syntaxKind: import_tsdoc.TSDocTagSyntaxKind.BlockTag,
|
|
2223
|
-
allowMultiple: true
|
|
2224
|
-
})
|
|
2225
|
-
);
|
|
2226
|
-
}
|
|
2227
|
-
for (const tagName of ["apiName", "displayName", "format", "placeholder"]) {
|
|
2228
|
-
config.addTagDefinition(
|
|
2229
|
-
new import_tsdoc.TSDocTagDefinition({
|
|
2230
|
-
tagName: "@" + tagName,
|
|
2231
|
-
syntaxKind: import_tsdoc.TSDocTagSyntaxKind.BlockTag,
|
|
2232
|
-
allowMultiple: true
|
|
2233
|
-
})
|
|
2234
|
-
);
|
|
2235
|
-
}
|
|
2236
|
-
for (const tagName of extensionTagNames) {
|
|
2237
|
-
config.addTagDefinition(
|
|
2238
|
-
new import_tsdoc.TSDocTagDefinition({
|
|
2239
|
-
tagName: "@" + tagName,
|
|
2240
|
-
syntaxKind: import_tsdoc.TSDocTagSyntaxKind.BlockTag,
|
|
2241
|
-
allowMultiple: true
|
|
2242
|
-
})
|
|
2243
|
-
);
|
|
2244
|
-
}
|
|
2245
|
-
return config;
|
|
2246
|
-
}
|
|
2247
|
-
function sharedCommentSyntaxOptions(options, offset) {
|
|
2248
|
-
const extensions = options?.extensionRegistry?.extensions;
|
|
2249
|
-
return {
|
|
2250
|
-
...offset !== void 0 ? { offset } : {},
|
|
2251
|
-
...extensions !== void 0 ? { extensions } : {}
|
|
2252
|
-
};
|
|
2253
|
-
}
|
|
2254
2214
|
function sharedTagValueOptions(options) {
|
|
2255
2215
|
return {
|
|
2256
2216
|
...options?.extensionRegistry !== void 0 ? { registry: options.extensionRegistry } : {},
|
|
@@ -2350,6 +2310,30 @@ function pushUniqueCompilerDiagnostics(target, additions) {
|
|
|
2350
2310
|
target.push(diagnostic);
|
|
2351
2311
|
}
|
|
2352
2312
|
}
|
|
2313
|
+
function processConstraintTag(tagName, text, parsedTag, provenance, node, sourceFile, supportingDeclarations, options, constraints, diagnostics) {
|
|
2314
|
+
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
2315
|
+
node,
|
|
2316
|
+
sourceFile,
|
|
2317
|
+
tagName,
|
|
2318
|
+
parsedTag,
|
|
2319
|
+
provenance,
|
|
2320
|
+
supportingDeclarations,
|
|
2321
|
+
options
|
|
2322
|
+
);
|
|
2323
|
+
if (compilerDiagnostics.length > 0) {
|
|
2324
|
+
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2325
|
+
return;
|
|
2326
|
+
}
|
|
2327
|
+
const constraintNode = (0, import_internal2.parseConstraintTagValue)(
|
|
2328
|
+
tagName,
|
|
2329
|
+
text,
|
|
2330
|
+
provenance,
|
|
2331
|
+
sharedTagValueOptions(options)
|
|
2332
|
+
);
|
|
2333
|
+
if (constraintNode) {
|
|
2334
|
+
constraints.push(constraintNode);
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2353
2337
|
function renderSyntheticArgumentExpression(valueKind, argumentText) {
|
|
2354
2338
|
const trimmed = argumentText.trim();
|
|
2355
2339
|
if (trimmed === "") {
|
|
@@ -2635,10 +2619,9 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
2635
2619
|
)
|
|
2636
2620
|
];
|
|
2637
2621
|
}
|
|
2638
|
-
var parserCache = /* @__PURE__ */ new Map();
|
|
2639
2622
|
var parseResultCache = /* @__PURE__ */ new Map();
|
|
2640
|
-
function
|
|
2641
|
-
|
|
2623
|
+
function getExtensionTagNames(options) {
|
|
2624
|
+
return [
|
|
2642
2625
|
...options?.extensionRegistry?.extensions.flatMap(
|
|
2643
2626
|
(extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal2.normalizeFormSpecTagName)(tag.tagName))
|
|
2644
2627
|
) ?? [],
|
|
@@ -2646,14 +2629,6 @@ function getParser(options) {
|
|
|
2646
2629
|
(extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal2.normalizeFormSpecTagName)(slot.tagName))
|
|
2647
2630
|
) ?? []
|
|
2648
2631
|
].sort();
|
|
2649
|
-
const cacheKey = extensionTagNames.join("|");
|
|
2650
|
-
const existing = parserCache.get(cacheKey);
|
|
2651
|
-
if (existing) {
|
|
2652
|
-
return existing;
|
|
2653
|
-
}
|
|
2654
|
-
const parser = new import_tsdoc.TSDocParser(createFormSpecTSDocConfig(extensionTagNames));
|
|
2655
|
-
parserCache.set(cacheKey, parser);
|
|
2656
|
-
return parser;
|
|
2657
2632
|
}
|
|
2658
2633
|
function getExtensionRegistryCacheKey(registry) {
|
|
2659
2634
|
if (registry === void 0) {
|
|
@@ -2704,13 +2679,13 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2704
2679
|
let placeholder;
|
|
2705
2680
|
let displayNameProvenance;
|
|
2706
2681
|
let placeholderProvenance;
|
|
2707
|
-
const rawTextTags = [];
|
|
2708
2682
|
const sourceFile = node.getSourceFile();
|
|
2709
2683
|
const sourceText = sourceFile.getFullText();
|
|
2710
2684
|
const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
|
|
2711
2685
|
const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
|
|
2712
2686
|
const commentRanges = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
|
|
2713
2687
|
const rawTextFallbacks = collectRawTextFallbacks(node, file);
|
|
2688
|
+
const extensionTagNames = getExtensionTagNames(options);
|
|
2714
2689
|
if (commentRanges) {
|
|
2715
2690
|
for (const range of commentRanges) {
|
|
2716
2691
|
if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
|
|
@@ -2720,38 +2695,18 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2720
2695
|
if (!commentText.startsWith("/**")) {
|
|
2721
2696
|
continue;
|
|
2722
2697
|
}
|
|
2723
|
-
const
|
|
2724
|
-
const
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
);
|
|
2732
|
-
let parsedTagCursor = 0;
|
|
2733
|
-
const nextParsedTag = (normalizedTagName) => {
|
|
2734
|
-
while (parsedTagCursor < parsedComment.tags.length) {
|
|
2735
|
-
const candidate = parsedComment.tags[parsedTagCursor];
|
|
2736
|
-
parsedTagCursor += 1;
|
|
2737
|
-
if (candidate?.normalizedTagName === normalizedTagName) {
|
|
2738
|
-
return candidate;
|
|
2739
|
-
}
|
|
2740
|
-
}
|
|
2741
|
-
return null;
|
|
2742
|
-
};
|
|
2743
|
-
for (const parsedTag of parsedComment.tags) {
|
|
2744
|
-
if (TAGS_REQUIRING_RAW_TEXT.has(parsedTag.normalizedTagName)) {
|
|
2745
|
-
rawTextTags.push({ tag: parsedTag, commentText, commentOffset: range.pos });
|
|
2746
|
-
}
|
|
2747
|
-
}
|
|
2748
|
-
for (const block of docComment.customBlocks) {
|
|
2749
|
-
const tagName = (0, import_internals4.normalizeConstraintTagName)(block.blockTag.tagName.substring(1));
|
|
2750
|
-
const parsedTag = nextParsedTag(tagName);
|
|
2698
|
+
const extensions = options?.extensionRegistry?.extensions;
|
|
2699
|
+
const unified = (0, import_internal2.parseUnifiedComment)(commentText, {
|
|
2700
|
+
offset: range.pos,
|
|
2701
|
+
extensionTagNames,
|
|
2702
|
+
...extensions !== void 0 ? { extensions } : {}
|
|
2703
|
+
});
|
|
2704
|
+
for (const tag of unified.tags) {
|
|
2705
|
+
const tagName = tag.normalizedTagName;
|
|
2751
2706
|
if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
|
|
2752
|
-
const text2 =
|
|
2707
|
+
const text2 = tag.resolvedPayloadText;
|
|
2753
2708
|
if (text2 === "") continue;
|
|
2754
|
-
const provenance2 =
|
|
2709
|
+
const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
|
|
2755
2710
|
switch (tagName) {
|
|
2756
2711
|
case "displayName":
|
|
2757
2712
|
if (!isMemberTargetDisplayName(text2) && displayName === void 0) {
|
|
@@ -2776,64 +2731,69 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2776
2731
|
}
|
|
2777
2732
|
continue;
|
|
2778
2733
|
}
|
|
2779
|
-
if (TAGS_REQUIRING_RAW_TEXT.has(tagName))
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2734
|
+
if (import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
|
|
2735
|
+
const fallback = rawTextFallbacks.get(tagName)?.shift();
|
|
2736
|
+
const text2 = (0, import_internal2.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
|
|
2737
|
+
if (text2 === "") continue;
|
|
2738
|
+
const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
|
|
2739
|
+
if (tagName === "defaultValue") {
|
|
2740
|
+
annotations.push((0, import_internal2.parseDefaultValueTagValue)(text2, provenance2));
|
|
2741
|
+
continue;
|
|
2742
|
+
}
|
|
2743
|
+
processConstraintTag(
|
|
2744
|
+
tagName,
|
|
2745
|
+
text2,
|
|
2746
|
+
tag,
|
|
2747
|
+
provenance2,
|
|
2748
|
+
node,
|
|
2749
|
+
sourceFile,
|
|
2750
|
+
supportingDeclarations,
|
|
2751
|
+
options,
|
|
2752
|
+
constraints,
|
|
2753
|
+
diagnostics
|
|
2754
|
+
);
|
|
2795
2755
|
continue;
|
|
2796
2756
|
}
|
|
2797
|
-
const
|
|
2757
|
+
const text = tag.resolvedPayloadText;
|
|
2758
|
+
const expectedType = (0, import_internals4.isBuiltinConstraintName)(tagName) ? import_internals4.BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
|
|
2759
|
+
if (text === "" && expectedType !== "boolean") continue;
|
|
2760
|
+
const provenance = provenanceForParsedTag(tag, sourceFile, file);
|
|
2761
|
+
processConstraintTag(
|
|
2798
2762
|
tagName,
|
|
2799
2763
|
text,
|
|
2764
|
+
tag,
|
|
2800
2765
|
provenance,
|
|
2801
|
-
|
|
2766
|
+
node,
|
|
2767
|
+
sourceFile,
|
|
2768
|
+
supportingDeclarations,
|
|
2769
|
+
options,
|
|
2770
|
+
constraints,
|
|
2771
|
+
diagnostics
|
|
2802
2772
|
);
|
|
2803
|
-
if (constraintNode) {
|
|
2804
|
-
constraints.push(constraintNode);
|
|
2805
|
-
}
|
|
2806
2773
|
}
|
|
2807
|
-
if (
|
|
2808
|
-
const message = extractBlockText(docComment.deprecatedBlock).trim();
|
|
2774
|
+
if (unified.isDeprecated) {
|
|
2809
2775
|
annotations.push({
|
|
2810
2776
|
kind: "annotation",
|
|
2811
2777
|
annotationKind: "deprecated",
|
|
2812
|
-
...
|
|
2778
|
+
...unified.deprecationMessage !== "" && { message: unified.deprecationMessage },
|
|
2813
2779
|
provenance: provenanceForComment(range, sourceFile, file, "deprecated")
|
|
2814
2780
|
});
|
|
2815
2781
|
}
|
|
2816
|
-
{
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
provenance: provenanceForComment(range, sourceFile, file, "summary")
|
|
2824
|
-
});
|
|
2825
|
-
}
|
|
2782
|
+
if (unified.summaryText !== "") {
|
|
2783
|
+
annotations.push({
|
|
2784
|
+
kind: "annotation",
|
|
2785
|
+
annotationKind: "description",
|
|
2786
|
+
value: unified.summaryText,
|
|
2787
|
+
provenance: provenanceForComment(range, sourceFile, file, "summary")
|
|
2788
|
+
});
|
|
2826
2789
|
}
|
|
2827
|
-
if (
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
provenance: provenanceForComment(range, sourceFile, file, "remarks")
|
|
2835
|
-
});
|
|
2836
|
-
}
|
|
2790
|
+
if (unified.remarksText !== "") {
|
|
2791
|
+
annotations.push({
|
|
2792
|
+
kind: "annotation",
|
|
2793
|
+
annotationKind: "remarks",
|
|
2794
|
+
value: unified.remarksText,
|
|
2795
|
+
provenance: provenanceForComment(range, sourceFile, file, "remarks")
|
|
2796
|
+
});
|
|
2837
2797
|
}
|
|
2838
2798
|
}
|
|
2839
2799
|
}
|
|
@@ -2853,77 +2813,27 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2853
2813
|
provenance: placeholderProvenance
|
|
2854
2814
|
});
|
|
2855
2815
|
}
|
|
2856
|
-
if (rawTextTags.length > 0) {
|
|
2857
|
-
for (const rawTextTag of rawTextTags) {
|
|
2858
|
-
const fallbackQueue = rawTextFallbacks.get(rawTextTag.tag.normalizedTagName);
|
|
2859
|
-
const fallback = fallbackQueue?.shift();
|
|
2860
|
-
const text = choosePreferredPayloadText(
|
|
2861
|
-
getSharedPayloadText(rawTextTag.tag, rawTextTag.commentText, rawTextTag.commentOffset),
|
|
2862
|
-
fallback?.text ?? ""
|
|
2863
|
-
);
|
|
2864
|
-
if (text === "") continue;
|
|
2865
|
-
const provenance = provenanceForParsedTag(rawTextTag.tag, sourceFile, file);
|
|
2866
|
-
if (rawTextTag.tag.normalizedTagName === "defaultValue") {
|
|
2867
|
-
const defaultValueNode = (0, import_internal2.parseDefaultValueTagValue)(text, provenance);
|
|
2868
|
-
annotations.push(defaultValueNode);
|
|
2869
|
-
continue;
|
|
2870
|
-
}
|
|
2871
|
-
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
2872
|
-
node,
|
|
2873
|
-
sourceFile,
|
|
2874
|
-
rawTextTag.tag.normalizedTagName,
|
|
2875
|
-
rawTextTag.tag,
|
|
2876
|
-
provenance,
|
|
2877
|
-
supportingDeclarations,
|
|
2878
|
-
options
|
|
2879
|
-
);
|
|
2880
|
-
if (compilerDiagnostics.length > 0) {
|
|
2881
|
-
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2882
|
-
continue;
|
|
2883
|
-
}
|
|
2884
|
-
const constraintNode = (0, import_internal2.parseConstraintTagValue)(
|
|
2885
|
-
rawTextTag.tag.normalizedTagName,
|
|
2886
|
-
text,
|
|
2887
|
-
provenance,
|
|
2888
|
-
sharedTagValueOptions(options)
|
|
2889
|
-
);
|
|
2890
|
-
if (constraintNode) {
|
|
2891
|
-
constraints.push(constraintNode);
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2895
2816
|
for (const [tagName, fallbacks] of rawTextFallbacks) {
|
|
2896
2817
|
for (const fallback of fallbacks) {
|
|
2897
2818
|
const text = fallback.text.trim();
|
|
2898
2819
|
if (text === "") continue;
|
|
2899
2820
|
const provenance = fallback.provenance;
|
|
2900
2821
|
if (tagName === "defaultValue") {
|
|
2901
|
-
|
|
2902
|
-
annotations.push(defaultValueNode);
|
|
2822
|
+
annotations.push((0, import_internal2.parseDefaultValueTagValue)(text, provenance));
|
|
2903
2823
|
continue;
|
|
2904
2824
|
}
|
|
2905
|
-
|
|
2906
|
-
node,
|
|
2907
|
-
sourceFile,
|
|
2825
|
+
processConstraintTag(
|
|
2908
2826
|
tagName,
|
|
2827
|
+
text,
|
|
2909
2828
|
null,
|
|
2910
2829
|
provenance,
|
|
2830
|
+
node,
|
|
2831
|
+
sourceFile,
|
|
2911
2832
|
supportingDeclarations,
|
|
2912
|
-
options
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2916
|
-
continue;
|
|
2917
|
-
}
|
|
2918
|
-
const constraintNode = (0, import_internal2.parseConstraintTagValue)(
|
|
2919
|
-
tagName,
|
|
2920
|
-
text,
|
|
2921
|
-
provenance,
|
|
2922
|
-
sharedTagValueOptions(options)
|
|
2833
|
+
options,
|
|
2834
|
+
constraints,
|
|
2835
|
+
diagnostics
|
|
2923
2836
|
);
|
|
2924
|
-
if (constraintNode) {
|
|
2925
|
-
constraints.push(constraintNode);
|
|
2926
|
-
}
|
|
2927
2837
|
}
|
|
2928
2838
|
}
|
|
2929
2839
|
const result = { constraints, annotations, diagnostics };
|
|
@@ -2941,8 +2851,8 @@ function extractDisplayNameMetadata(node) {
|
|
|
2941
2851
|
if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) continue;
|
|
2942
2852
|
const commentText = sourceText.substring(range.pos, range.end);
|
|
2943
2853
|
if (!commentText.startsWith("/**")) continue;
|
|
2944
|
-
const
|
|
2945
|
-
for (const tag of
|
|
2854
|
+
const unified = (0, import_internal2.parseUnifiedComment)(commentText);
|
|
2855
|
+
for (const tag of unified.tags) {
|
|
2946
2856
|
if (tag.normalizedTagName !== "displayName") {
|
|
2947
2857
|
continue;
|
|
2948
2858
|
}
|
|
@@ -2961,56 +2871,11 @@ function extractDisplayNameMetadata(node) {
|
|
|
2961
2871
|
memberDisplayNames
|
|
2962
2872
|
};
|
|
2963
2873
|
}
|
|
2964
|
-
function extractBlockText(block) {
|
|
2965
|
-
return extractPlainText(block.content);
|
|
2966
|
-
}
|
|
2967
|
-
function extractPlainText(node) {
|
|
2968
|
-
let result = "";
|
|
2969
|
-
if (node instanceof import_tsdoc.DocExcerpt) {
|
|
2970
|
-
return node.content.toString();
|
|
2971
|
-
}
|
|
2972
|
-
if (node instanceof import_tsdoc.DocPlainText) {
|
|
2973
|
-
return node.text;
|
|
2974
|
-
}
|
|
2975
|
-
if (node instanceof import_tsdoc.DocSoftBreak) {
|
|
2976
|
-
return " ";
|
|
2977
|
-
}
|
|
2978
|
-
if (typeof node.getChildNodes === "function") {
|
|
2979
|
-
for (const child of node.getChildNodes()) {
|
|
2980
|
-
result += extractPlainText(child);
|
|
2981
|
-
}
|
|
2982
|
-
}
|
|
2983
|
-
return result;
|
|
2984
|
-
}
|
|
2985
|
-
function choosePreferredPayloadText(primary, fallback) {
|
|
2986
|
-
const preferred = primary.trim();
|
|
2987
|
-
const alternate = fallback.trim();
|
|
2988
|
-
if (preferred === "") return alternate;
|
|
2989
|
-
if (alternate === "") return preferred;
|
|
2990
|
-
if (alternate.includes("\n")) return alternate;
|
|
2991
|
-
if (alternate.length > preferred.length && alternate.startsWith(preferred)) {
|
|
2992
|
-
return alternate;
|
|
2993
|
-
}
|
|
2994
|
-
return preferred;
|
|
2995
|
-
}
|
|
2996
|
-
function getSharedPayloadText(tag, commentText, commentOffset) {
|
|
2997
|
-
if (tag.payloadSpan === null) {
|
|
2998
|
-
return "";
|
|
2999
|
-
}
|
|
3000
|
-
return (0, import_internal2.sliceCommentSpan)(commentText, tag.payloadSpan, {
|
|
3001
|
-
offset: commentOffset
|
|
3002
|
-
}).trim();
|
|
3003
|
-
}
|
|
3004
|
-
function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
|
|
3005
|
-
const sharedText = tag === null ? "" : getSharedPayloadText(tag, commentText, commentOffset);
|
|
3006
|
-
const blockText = extractBlockText(block).replace(/\s+/g, " ").trim();
|
|
3007
|
-
return choosePreferredPayloadText(sharedText, blockText);
|
|
3008
|
-
}
|
|
3009
2874
|
function collectRawTextFallbacks(node, file) {
|
|
3010
2875
|
const fallbacks = /* @__PURE__ */ new Map();
|
|
3011
2876
|
for (const tag of ts.getJSDocTags(node)) {
|
|
3012
2877
|
const tagName = (0, import_internals4.normalizeConstraintTagName)(tag.tagName.text);
|
|
3013
|
-
if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
2878
|
+
if (!import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
3014
2879
|
const commentText = getTagCommentText(tag)?.trim() ?? "";
|
|
3015
2880
|
if (commentText === "") continue;
|
|
3016
2881
|
const entries = fallbacks.get(tagName) ?? [];
|
|
@@ -4655,7 +4520,7 @@ function typeNodeContainsReference(type, targetName) {
|
|
|
4655
4520
|
}
|
|
4656
4521
|
}
|
|
4657
4522
|
function shouldEmitResolvedObjectProperty(property, declaration) {
|
|
4658
|
-
if (property.name.startsWith("__
|
|
4523
|
+
if (property.name.startsWith("__")) {
|
|
4659
4524
|
return false;
|
|
4660
4525
|
}
|
|
4661
4526
|
if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
|
|
@@ -5646,7 +5511,9 @@ function generateSchemasFromClass(options) {
|
|
|
5646
5511
|
classDecl,
|
|
5647
5512
|
ctx.checker,
|
|
5648
5513
|
options.filePath,
|
|
5514
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5649
5515
|
options.extensionRegistry,
|
|
5516
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5650
5517
|
options.metadata,
|
|
5651
5518
|
options.discriminator
|
|
5652
5519
|
);
|
|
@@ -5654,9 +5521,13 @@ function generateSchemasFromClass(options) {
|
|
|
5654
5521
|
analysis,
|
|
5655
5522
|
{ file: options.filePath },
|
|
5656
5523
|
{
|
|
5524
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5657
5525
|
extensionRegistry: options.extensionRegistry,
|
|
5526
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5658
5527
|
metadata: options.metadata,
|
|
5528
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5659
5529
|
enumSerialization: options.enumSerialization,
|
|
5530
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5660
5531
|
vendorPrefix: options.vendorPrefix
|
|
5661
5532
|
}
|
|
5662
5533
|
);
|
|
@@ -5703,7 +5574,12 @@ function generateSchemasDetailedInternal(options) {
|
|
|
5703
5574
|
diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
|
|
5704
5575
|
};
|
|
5705
5576
|
}
|
|
5706
|
-
return generateSchemasFromDetailedProgramContext(
|
|
5577
|
+
return generateSchemasFromDetailedProgramContext(
|
|
5578
|
+
ctx,
|
|
5579
|
+
options.filePath,
|
|
5580
|
+
options.typeName,
|
|
5581
|
+
options
|
|
5582
|
+
);
|
|
5707
5583
|
}
|
|
5708
5584
|
function generateSchemasFromProgramDetailed(options) {
|
|
5709
5585
|
return generateSchemasFromProgram({
|
|
@@ -5721,7 +5597,12 @@ function generateSchemasFromProgramDetailedInternal(options) {
|
|
|
5721
5597
|
diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
|
|
5722
5598
|
};
|
|
5723
5599
|
}
|
|
5724
|
-
return generateSchemasFromDetailedProgramContext(
|
|
5600
|
+
return generateSchemasFromDetailedProgramContext(
|
|
5601
|
+
ctx,
|
|
5602
|
+
options.filePath,
|
|
5603
|
+
options.typeName,
|
|
5604
|
+
options
|
|
5605
|
+
);
|
|
5725
5606
|
}
|
|
5726
5607
|
function generateSchemasBatch(options) {
|
|
5727
5608
|
const contextCache = /* @__PURE__ */ new Map();
|
|
@@ -5765,13 +5646,27 @@ function generateSchemasBatchFromProgram(options) {
|
|
|
5765
5646
|
);
|
|
5766
5647
|
});
|
|
5767
5648
|
}
|
|
5649
|
+
function resolveOptions(options) {
|
|
5650
|
+
const configRegistry = options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
|
|
5651
|
+
return {
|
|
5652
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5653
|
+
extensionRegistry: options.extensionRegistry ?? configRegistry,
|
|
5654
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5655
|
+
vendorPrefix: options.vendorPrefix ?? options.config?.vendorPrefix,
|
|
5656
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5657
|
+
enumSerialization: options.enumSerialization ?? options.config?.enumSerialization,
|
|
5658
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5659
|
+
metadata: options.metadata ?? options.config?.metadata
|
|
5660
|
+
};
|
|
5661
|
+
}
|
|
5768
5662
|
function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, options) {
|
|
5663
|
+
const resolved = resolveOptions(options);
|
|
5769
5664
|
const analysisResult = analyzeNamedTypeToIRFromProgramContextDetailed(
|
|
5770
5665
|
ctx,
|
|
5771
5666
|
filePath,
|
|
5772
5667
|
typeName,
|
|
5773
|
-
|
|
5774
|
-
|
|
5668
|
+
resolved.extensionRegistry,
|
|
5669
|
+
resolved.metadata,
|
|
5775
5670
|
options.discriminator
|
|
5776
5671
|
);
|
|
5777
5672
|
if (!analysisResult.ok) {
|
|
@@ -5784,10 +5679,10 @@ function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, opti
|
|
|
5784
5679
|
analysisResult.analysis,
|
|
5785
5680
|
{ file: filePath },
|
|
5786
5681
|
{
|
|
5787
|
-
extensionRegistry:
|
|
5788
|
-
metadata:
|
|
5789
|
-
enumSerialization:
|
|
5790
|
-
vendorPrefix:
|
|
5682
|
+
extensionRegistry: resolved.extensionRegistry,
|
|
5683
|
+
metadata: resolved.metadata,
|
|
5684
|
+
enumSerialization: resolved.enumSerialization,
|
|
5685
|
+
vendorPrefix: resolved.vendorPrefix
|
|
5791
5686
|
}
|
|
5792
5687
|
);
|
|
5793
5688
|
}
|
|
@@ -5924,6 +5819,7 @@ function omitApiName(metadata) {
|
|
|
5924
5819
|
}
|
|
5925
5820
|
function enforceRequiredMetadata(metadata, declarationKind, logicalName, options) {
|
|
5926
5821
|
const declarationPolicy = getDeclarationMetadataPolicy(
|
|
5822
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5927
5823
|
normalizeMetadataPolicy(options.metadata),
|
|
5928
5824
|
declarationKind
|
|
5929
5825
|
);
|
|
@@ -5998,6 +5894,7 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
|
|
|
5998
5894
|
provenance: syntheticField.provenance
|
|
5999
5895
|
},
|
|
6000
5896
|
{
|
|
5897
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6001
5898
|
policy: normalizeMetadataPolicy(options?.metadata),
|
|
6002
5899
|
surface: "tsdoc",
|
|
6003
5900
|
rootLogicalName: root.name
|
|
@@ -6006,8 +5903,11 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
|
|
|
6006
5903
|
const schema = generateJsonSchemaFromIR(
|
|
6007
5904
|
ir,
|
|
6008
5905
|
{
|
|
5906
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6009
5907
|
extensionRegistry: options?.extensionRegistry,
|
|
5908
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6010
5909
|
enumSerialization: options?.enumSerialization,
|
|
5910
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6011
5911
|
vendorPrefix: options?.vendorPrefix
|
|
6012
5912
|
}
|
|
6013
5913
|
);
|
|
@@ -6033,9 +5933,13 @@ function generateSchemasFromAnalysis(analysis, filePath, options) {
|
|
|
6033
5933
|
analysis,
|
|
6034
5934
|
{ file: filePath },
|
|
6035
5935
|
{
|
|
5936
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6036
5937
|
extensionRegistry: options?.extensionRegistry,
|
|
5938
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6037
5939
|
enumSerialization: options?.enumSerialization,
|
|
5940
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6038
5941
|
metadata: options?.metadata,
|
|
5942
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6039
5943
|
vendorPrefix: options?.vendorPrefix
|
|
6040
5944
|
}
|
|
6041
5945
|
),
|
|
@@ -6060,7 +5964,9 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
|
|
|
6060
5964
|
typeRegistry,
|
|
6061
5965
|
/* @__PURE__ */ new Set(),
|
|
6062
5966
|
options.sourceNode,
|
|
5967
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6063
5968
|
createAnalyzerMetadataPolicy(options.metadata, options.discriminator),
|
|
5969
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6064
5970
|
options.extensionRegistry,
|
|
6065
5971
|
diagnostics
|
|
6066
5972
|
);
|
|
@@ -6109,7 +6015,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6109
6015
|
options.declaration,
|
|
6110
6016
|
options.context.checker,
|
|
6111
6017
|
filePath,
|
|
6018
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6112
6019
|
options.extensionRegistry,
|
|
6020
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6113
6021
|
options.metadata,
|
|
6114
6022
|
options.discriminator
|
|
6115
6023
|
),
|
|
@@ -6123,7 +6031,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6123
6031
|
options.declaration,
|
|
6124
6032
|
options.context.checker,
|
|
6125
6033
|
filePath,
|
|
6034
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6126
6035
|
options.extensionRegistry,
|
|
6036
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6127
6037
|
options.metadata,
|
|
6128
6038
|
options.discriminator
|
|
6129
6039
|
),
|
|
@@ -6136,7 +6046,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6136
6046
|
options.declaration,
|
|
6137
6047
|
options.context.checker,
|
|
6138
6048
|
filePath,
|
|
6049
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6139
6050
|
options.extensionRegistry,
|
|
6051
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6140
6052
|
options.metadata,
|
|
6141
6053
|
options.discriminator
|
|
6142
6054
|
);
|
|
@@ -6147,7 +6059,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6147
6059
|
options.declaration,
|
|
6148
6060
|
options.context.checker,
|
|
6149
6061
|
filePath,
|
|
6062
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6150
6063
|
options.extensionRegistry,
|
|
6064
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6151
6065
|
options.metadata
|
|
6152
6066
|
);
|
|
6153
6067
|
if (aliasRootInfo.diagnostics.length > 0) {
|
|
@@ -6202,7 +6116,9 @@ function resolveDeclarationMetadata(options) {
|
|
|
6202
6116
|
const analysis = (0, import_internal5.analyzeMetadataForNodeWithChecker)({
|
|
6203
6117
|
checker: options.context.checker,
|
|
6204
6118
|
node: options.declaration,
|
|
6119
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6205
6120
|
metadata: options.metadata,
|
|
6121
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6206
6122
|
extensions: options.extensionRegistry?.extensions,
|
|
6207
6123
|
buildContext: options.context
|
|
6208
6124
|
});
|
|
@@ -6239,7 +6155,9 @@ function buildMixedAuthoringSchemas(options) {
|
|
|
6239
6155
|
const analysis = analyzeNamedTypeToIR(
|
|
6240
6156
|
filePath,
|
|
6241
6157
|
typeName,
|
|
6158
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6242
6159
|
schemaOptions.extensionRegistry,
|
|
6160
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6243
6161
|
schemaOptions.metadata,
|
|
6244
6162
|
schemaOptions.discriminator
|
|
6245
6163
|
);
|
|
@@ -6247,6 +6165,7 @@ function buildMixedAuthoringSchemas(options) {
|
|
|
6247
6165
|
const ir = canonicalizeTSDoc(
|
|
6248
6166
|
composedAnalysis,
|
|
6249
6167
|
{ file: filePath },
|
|
6168
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6250
6169
|
schemaOptions.metadata !== void 0 ? { metadata: schemaOptions.metadata } : void 0
|
|
6251
6170
|
);
|
|
6252
6171
|
return {
|