@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/cli.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
2706
|
-
|
|
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
|
|
2789
|
-
const
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
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 =
|
|
2766
|
+
const text2 = tag.resolvedPayloadText;
|
|
2818
2767
|
if (text2 === "") continue;
|
|
2819
|
-
const provenance2 =
|
|
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))
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
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
|
|
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
|
-
|
|
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 (
|
|
2873
|
-
const message = extractBlockText(docComment.deprecatedBlock).trim();
|
|
2833
|
+
if (unified.isDeprecated) {
|
|
2874
2834
|
annotations.push({
|
|
2875
2835
|
kind: "annotation",
|
|
2876
2836
|
annotationKind: "deprecated",
|
|
2877
|
-
...
|
|
2837
|
+
...unified.deprecationMessage !== "" && { message: unified.deprecationMessage },
|
|
2878
2838
|
provenance: provenanceForComment(range, sourceFile, file, "deprecated")
|
|
2879
2839
|
});
|
|
2880
2840
|
}
|
|
2881
|
-
{
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
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 (
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
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
|
-
|
|
2967
|
-
annotations.push(defaultValueNode);
|
|
2881
|
+
annotations.push(parseDefaultValueTagValue(text, provenance));
|
|
2968
2882
|
continue;
|
|
2969
2883
|
}
|
|
2970
|
-
|
|
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
|
-
|
|
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
|
|
3010
|
-
for (const tag of
|
|
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
|
|
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
|
|
3058
|
+
parseCommentBlock
|
|
3202
3059
|
} from "@formspec/analysis/internal";
|
|
3203
3060
|
function isObjectType(type) {
|
|
3204
3061
|
return !!(type.flags & ts3.TypeFlags.Object);
|
|
@@ -3585,7 +3442,7 @@ function getLeadingParsedTags(node) {
|
|
|
3585
3442
|
if (!commentText.startsWith("/**")) {
|
|
3586
3443
|
continue;
|
|
3587
3444
|
}
|
|
3588
|
-
parsedTags.push(...
|
|
3445
|
+
parsedTags.push(...parseCommentBlock(commentText, { offset: range.pos }).tags);
|
|
3589
3446
|
}
|
|
3590
3447
|
return parsedTags;
|
|
3591
3448
|
}
|
|
@@ -4737,7 +4594,7 @@ function typeNodeContainsReference(type, targetName) {
|
|
|
4737
4594
|
}
|
|
4738
4595
|
}
|
|
4739
4596
|
function shouldEmitResolvedObjectProperty(property, declaration) {
|
|
4740
|
-
if (property.name.startsWith("__
|
|
4597
|
+
if (property.name.startsWith("__")) {
|
|
4741
4598
|
return false;
|
|
4742
4599
|
}
|
|
4743
4600
|
if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
|
|
@@ -5766,7 +5623,9 @@ function generateSchemasFromClass(options) {
|
|
|
5766
5623
|
classDecl,
|
|
5767
5624
|
ctx.checker,
|
|
5768
5625
|
options.filePath,
|
|
5626
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5769
5627
|
options.extensionRegistry,
|
|
5628
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5770
5629
|
options.metadata,
|
|
5771
5630
|
options.discriminator
|
|
5772
5631
|
);
|
|
@@ -5774,9 +5633,13 @@ function generateSchemasFromClass(options) {
|
|
|
5774
5633
|
analysis,
|
|
5775
5634
|
{ file: options.filePath },
|
|
5776
5635
|
{
|
|
5636
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5777
5637
|
extensionRegistry: options.extensionRegistry,
|
|
5638
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5778
5639
|
metadata: options.metadata,
|
|
5640
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5779
5641
|
enumSerialization: options.enumSerialization,
|
|
5642
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5780
5643
|
vendorPrefix: options.vendorPrefix
|
|
5781
5644
|
}
|
|
5782
5645
|
);
|
|
@@ -5823,7 +5686,12 @@ function generateSchemasDetailedInternal(options) {
|
|
|
5823
5686
|
diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
|
|
5824
5687
|
};
|
|
5825
5688
|
}
|
|
5826
|
-
return generateSchemasFromDetailedProgramContext(
|
|
5689
|
+
return generateSchemasFromDetailedProgramContext(
|
|
5690
|
+
ctx,
|
|
5691
|
+
options.filePath,
|
|
5692
|
+
options.typeName,
|
|
5693
|
+
options
|
|
5694
|
+
);
|
|
5827
5695
|
}
|
|
5828
5696
|
function generateSchemasFromProgramDetailed(options) {
|
|
5829
5697
|
return generateSchemasFromProgram({
|
|
@@ -5841,7 +5709,12 @@ function generateSchemasFromProgramDetailedInternal(options) {
|
|
|
5841
5709
|
diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
|
|
5842
5710
|
};
|
|
5843
5711
|
}
|
|
5844
|
-
return generateSchemasFromDetailedProgramContext(
|
|
5712
|
+
return generateSchemasFromDetailedProgramContext(
|
|
5713
|
+
ctx,
|
|
5714
|
+
options.filePath,
|
|
5715
|
+
options.typeName,
|
|
5716
|
+
options
|
|
5717
|
+
);
|
|
5845
5718
|
}
|
|
5846
5719
|
function generateSchemasBatch(options) {
|
|
5847
5720
|
const contextCache = /* @__PURE__ */ new Map();
|
|
@@ -5885,13 +5758,27 @@ function generateSchemasBatchFromProgram(options) {
|
|
|
5885
5758
|
);
|
|
5886
5759
|
});
|
|
5887
5760
|
}
|
|
5761
|
+
function resolveOptions(options) {
|
|
5762
|
+
const configRegistry = options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
|
|
5763
|
+
return {
|
|
5764
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5765
|
+
extensionRegistry: options.extensionRegistry ?? configRegistry,
|
|
5766
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5767
|
+
vendorPrefix: options.vendorPrefix ?? options.config?.vendorPrefix,
|
|
5768
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5769
|
+
enumSerialization: options.enumSerialization ?? options.config?.enumSerialization,
|
|
5770
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5771
|
+
metadata: options.metadata ?? options.config?.metadata
|
|
5772
|
+
};
|
|
5773
|
+
}
|
|
5888
5774
|
function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, options) {
|
|
5775
|
+
const resolved = resolveOptions(options);
|
|
5889
5776
|
const analysisResult = analyzeNamedTypeToIRFromProgramContextDetailed(
|
|
5890
5777
|
ctx,
|
|
5891
5778
|
filePath,
|
|
5892
5779
|
typeName,
|
|
5893
|
-
|
|
5894
|
-
|
|
5780
|
+
resolved.extensionRegistry,
|
|
5781
|
+
resolved.metadata,
|
|
5895
5782
|
options.discriminator
|
|
5896
5783
|
);
|
|
5897
5784
|
if (!analysisResult.ok) {
|
|
@@ -5904,10 +5791,10 @@ function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, opti
|
|
|
5904
5791
|
analysisResult.analysis,
|
|
5905
5792
|
{ file: filePath },
|
|
5906
5793
|
{
|
|
5907
|
-
extensionRegistry:
|
|
5908
|
-
metadata:
|
|
5909
|
-
enumSerialization:
|
|
5910
|
-
vendorPrefix:
|
|
5794
|
+
extensionRegistry: resolved.extensionRegistry,
|
|
5795
|
+
metadata: resolved.metadata,
|
|
5796
|
+
enumSerialization: resolved.enumSerialization,
|
|
5797
|
+
vendorPrefix: resolved.vendorPrefix
|
|
5911
5798
|
}
|
|
5912
5799
|
);
|
|
5913
5800
|
}
|
|
@@ -5939,6 +5826,7 @@ var init_class_schema = __esm({
|
|
|
5939
5826
|
init_class_analyzer();
|
|
5940
5827
|
init_canonicalize();
|
|
5941
5828
|
init_ir_generator();
|
|
5829
|
+
init_extensions();
|
|
5942
5830
|
init_ir_generator2();
|
|
5943
5831
|
init_validate();
|
|
5944
5832
|
}
|
|
@@ -6061,6 +5949,7 @@ function omitApiName(metadata) {
|
|
|
6061
5949
|
}
|
|
6062
5950
|
function enforceRequiredMetadata(metadata, declarationKind, logicalName, options) {
|
|
6063
5951
|
const declarationPolicy = getDeclarationMetadataPolicy(
|
|
5952
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6064
5953
|
normalizeMetadataPolicy(options.metadata),
|
|
6065
5954
|
declarationKind
|
|
6066
5955
|
);
|
|
@@ -6135,6 +6024,7 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
|
|
|
6135
6024
|
provenance: syntheticField.provenance
|
|
6136
6025
|
},
|
|
6137
6026
|
{
|
|
6027
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6138
6028
|
policy: normalizeMetadataPolicy(options?.metadata),
|
|
6139
6029
|
surface: "tsdoc",
|
|
6140
6030
|
rootLogicalName: root.name
|
|
@@ -6143,8 +6033,11 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
|
|
|
6143
6033
|
const schema = generateJsonSchemaFromIR(
|
|
6144
6034
|
ir,
|
|
6145
6035
|
{
|
|
6036
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6146
6037
|
extensionRegistry: options?.extensionRegistry,
|
|
6038
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6147
6039
|
enumSerialization: options?.enumSerialization,
|
|
6040
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6148
6041
|
vendorPrefix: options?.vendorPrefix
|
|
6149
6042
|
}
|
|
6150
6043
|
);
|
|
@@ -6170,9 +6063,13 @@ function generateSchemasFromAnalysis(analysis, filePath, options) {
|
|
|
6170
6063
|
analysis,
|
|
6171
6064
|
{ file: filePath },
|
|
6172
6065
|
{
|
|
6066
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6173
6067
|
extensionRegistry: options?.extensionRegistry,
|
|
6068
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6174
6069
|
enumSerialization: options?.enumSerialization,
|
|
6070
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6175
6071
|
metadata: options?.metadata,
|
|
6072
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6176
6073
|
vendorPrefix: options?.vendorPrefix
|
|
6177
6074
|
}
|
|
6178
6075
|
),
|
|
@@ -6197,7 +6094,9 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
|
|
|
6197
6094
|
typeRegistry,
|
|
6198
6095
|
/* @__PURE__ */ new Set(),
|
|
6199
6096
|
options.sourceNode,
|
|
6097
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6200
6098
|
createAnalyzerMetadataPolicy(options.metadata, options.discriminator),
|
|
6099
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6201
6100
|
options.extensionRegistry,
|
|
6202
6101
|
diagnostics
|
|
6203
6102
|
);
|
|
@@ -6246,7 +6145,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6246
6145
|
options.declaration,
|
|
6247
6146
|
options.context.checker,
|
|
6248
6147
|
filePath,
|
|
6148
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6249
6149
|
options.extensionRegistry,
|
|
6150
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6250
6151
|
options.metadata,
|
|
6251
6152
|
options.discriminator
|
|
6252
6153
|
),
|
|
@@ -6260,7 +6161,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6260
6161
|
options.declaration,
|
|
6261
6162
|
options.context.checker,
|
|
6262
6163
|
filePath,
|
|
6164
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6263
6165
|
options.extensionRegistry,
|
|
6166
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6264
6167
|
options.metadata,
|
|
6265
6168
|
options.discriminator
|
|
6266
6169
|
),
|
|
@@ -6273,7 +6176,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6273
6176
|
options.declaration,
|
|
6274
6177
|
options.context.checker,
|
|
6275
6178
|
filePath,
|
|
6179
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6276
6180
|
options.extensionRegistry,
|
|
6181
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6277
6182
|
options.metadata,
|
|
6278
6183
|
options.discriminator
|
|
6279
6184
|
);
|
|
@@ -6284,7 +6189,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6284
6189
|
options.declaration,
|
|
6285
6190
|
options.context.checker,
|
|
6286
6191
|
filePath,
|
|
6192
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6287
6193
|
options.extensionRegistry,
|
|
6194
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6288
6195
|
options.metadata
|
|
6289
6196
|
);
|
|
6290
6197
|
if (aliasRootInfo.diagnostics.length > 0) {
|
|
@@ -6339,7 +6246,9 @@ function resolveDeclarationMetadata(options) {
|
|
|
6339
6246
|
const analysis = analyzeMetadataForNodeWithChecker2({
|
|
6340
6247
|
checker: options.context.checker,
|
|
6341
6248
|
node: options.declaration,
|
|
6249
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6342
6250
|
metadata: options.metadata,
|
|
6251
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6343
6252
|
extensions: options.extensionRegistry?.extensions,
|
|
6344
6253
|
buildContext: options.context
|
|
6345
6254
|
});
|
|
@@ -6385,7 +6294,9 @@ function buildMixedAuthoringSchemas(options) {
|
|
|
6385
6294
|
const analysis = analyzeNamedTypeToIR(
|
|
6386
6295
|
filePath,
|
|
6387
6296
|
typeName,
|
|
6297
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6388
6298
|
schemaOptions.extensionRegistry,
|
|
6299
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6389
6300
|
schemaOptions.metadata,
|
|
6390
6301
|
schemaOptions.discriminator
|
|
6391
6302
|
);
|
|
@@ -6393,6 +6304,7 @@ function buildMixedAuthoringSchemas(options) {
|
|
|
6393
6304
|
const ir = canonicalizeTSDoc(
|
|
6394
6305
|
composedAnalysis,
|
|
6395
6306
|
{ file: filePath },
|
|
6307
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6396
6308
|
schemaOptions.metadata !== void 0 ? { metadata: schemaOptions.metadata } : void 0
|
|
6397
6309
|
);
|
|
6398
6310
|
return {
|