@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.cjs
CHANGED
|
@@ -2267,44 +2267,6 @@ var init_schema2 = __esm({
|
|
|
2267
2267
|
});
|
|
2268
2268
|
|
|
2269
2269
|
// src/analyzer/tsdoc-parser.ts
|
|
2270
|
-
function createFormSpecTSDocConfig(extensionTagNames = []) {
|
|
2271
|
-
const config = new import_tsdoc.TSDocConfiguration();
|
|
2272
|
-
for (const tagName of Object.keys(import_internals4.BUILTIN_CONSTRAINT_DEFINITIONS)) {
|
|
2273
|
-
config.addTagDefinition(
|
|
2274
|
-
new import_tsdoc.TSDocTagDefinition({
|
|
2275
|
-
tagName: "@" + tagName,
|
|
2276
|
-
syntaxKind: import_tsdoc.TSDocTagSyntaxKind.BlockTag,
|
|
2277
|
-
allowMultiple: true
|
|
2278
|
-
})
|
|
2279
|
-
);
|
|
2280
|
-
}
|
|
2281
|
-
for (const tagName of ["apiName", "displayName", "format", "placeholder"]) {
|
|
2282
|
-
config.addTagDefinition(
|
|
2283
|
-
new import_tsdoc.TSDocTagDefinition({
|
|
2284
|
-
tagName: "@" + tagName,
|
|
2285
|
-
syntaxKind: import_tsdoc.TSDocTagSyntaxKind.BlockTag,
|
|
2286
|
-
allowMultiple: true
|
|
2287
|
-
})
|
|
2288
|
-
);
|
|
2289
|
-
}
|
|
2290
|
-
for (const tagName of extensionTagNames) {
|
|
2291
|
-
config.addTagDefinition(
|
|
2292
|
-
new import_tsdoc.TSDocTagDefinition({
|
|
2293
|
-
tagName: "@" + tagName,
|
|
2294
|
-
syntaxKind: import_tsdoc.TSDocTagSyntaxKind.BlockTag,
|
|
2295
|
-
allowMultiple: true
|
|
2296
|
-
})
|
|
2297
|
-
);
|
|
2298
|
-
}
|
|
2299
|
-
return config;
|
|
2300
|
-
}
|
|
2301
|
-
function sharedCommentSyntaxOptions(options, offset) {
|
|
2302
|
-
const extensions = options?.extensionRegistry?.extensions;
|
|
2303
|
-
return {
|
|
2304
|
-
...offset !== void 0 ? { offset } : {},
|
|
2305
|
-
...extensions !== void 0 ? { extensions } : {}
|
|
2306
|
-
};
|
|
2307
|
-
}
|
|
2308
2270
|
function sharedTagValueOptions(options) {
|
|
2309
2271
|
return {
|
|
2310
2272
|
...options?.extensionRegistry !== void 0 ? { registry: options.extensionRegistry } : {},
|
|
@@ -2403,6 +2365,30 @@ function pushUniqueCompilerDiagnostics(target, additions) {
|
|
|
2403
2365
|
target.push(diagnostic);
|
|
2404
2366
|
}
|
|
2405
2367
|
}
|
|
2368
|
+
function processConstraintTag(tagName, text, parsedTag, provenance, node, sourceFile, supportingDeclarations, options, constraints, diagnostics) {
|
|
2369
|
+
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
2370
|
+
node,
|
|
2371
|
+
sourceFile,
|
|
2372
|
+
tagName,
|
|
2373
|
+
parsedTag,
|
|
2374
|
+
provenance,
|
|
2375
|
+
supportingDeclarations,
|
|
2376
|
+
options
|
|
2377
|
+
);
|
|
2378
|
+
if (compilerDiagnostics.length > 0) {
|
|
2379
|
+
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2380
|
+
return;
|
|
2381
|
+
}
|
|
2382
|
+
const constraintNode = (0, import_internal2.parseConstraintTagValue)(
|
|
2383
|
+
tagName,
|
|
2384
|
+
text,
|
|
2385
|
+
provenance,
|
|
2386
|
+
sharedTagValueOptions(options)
|
|
2387
|
+
);
|
|
2388
|
+
if (constraintNode) {
|
|
2389
|
+
constraints.push(constraintNode);
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2406
2392
|
function renderSyntheticArgumentExpression(valueKind, argumentText) {
|
|
2407
2393
|
const trimmed = argumentText.trim();
|
|
2408
2394
|
if (trimmed === "") {
|
|
@@ -2688,8 +2674,8 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
2688
2674
|
)
|
|
2689
2675
|
];
|
|
2690
2676
|
}
|
|
2691
|
-
function
|
|
2692
|
-
|
|
2677
|
+
function getExtensionTagNames(options) {
|
|
2678
|
+
return [
|
|
2693
2679
|
...options?.extensionRegistry?.extensions.flatMap(
|
|
2694
2680
|
(extension) => (extension.constraintTags ?? []).map((tag) => (0, import_internal2.normalizeFormSpecTagName)(tag.tagName))
|
|
2695
2681
|
) ?? [],
|
|
@@ -2697,14 +2683,6 @@ function getParser(options) {
|
|
|
2697
2683
|
(extension) => (extension.metadataSlots ?? []).map((slot) => (0, import_internal2.normalizeFormSpecTagName)(slot.tagName))
|
|
2698
2684
|
) ?? []
|
|
2699
2685
|
].sort();
|
|
2700
|
-
const cacheKey = extensionTagNames.join("|");
|
|
2701
|
-
const existing = parserCache.get(cacheKey);
|
|
2702
|
-
if (existing) {
|
|
2703
|
-
return existing;
|
|
2704
|
-
}
|
|
2705
|
-
const parser = new import_tsdoc.TSDocParser(createFormSpecTSDocConfig(extensionTagNames));
|
|
2706
|
-
parserCache.set(cacheKey, parser);
|
|
2707
|
-
return parser;
|
|
2708
2686
|
}
|
|
2709
2687
|
function getExtensionRegistryCacheKey(registry) {
|
|
2710
2688
|
if (registry === void 0) {
|
|
@@ -2755,13 +2733,13 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2755
2733
|
let placeholder;
|
|
2756
2734
|
let displayNameProvenance;
|
|
2757
2735
|
let placeholderProvenance;
|
|
2758
|
-
const rawTextTags = [];
|
|
2759
2736
|
const sourceFile = node.getSourceFile();
|
|
2760
2737
|
const sourceText = sourceFile.getFullText();
|
|
2761
2738
|
const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
|
|
2762
2739
|
const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
|
|
2763
2740
|
const commentRanges = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
|
|
2764
2741
|
const rawTextFallbacks = collectRawTextFallbacks(node, file);
|
|
2742
|
+
const extensionTagNames = getExtensionTagNames(options);
|
|
2765
2743
|
if (commentRanges) {
|
|
2766
2744
|
for (const range of commentRanges) {
|
|
2767
2745
|
if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
|
|
@@ -2771,38 +2749,18 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2771
2749
|
if (!commentText.startsWith("/**")) {
|
|
2772
2750
|
continue;
|
|
2773
2751
|
}
|
|
2774
|
-
const
|
|
2775
|
-
const
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
);
|
|
2783
|
-
let parsedTagCursor = 0;
|
|
2784
|
-
const nextParsedTag = (normalizedTagName) => {
|
|
2785
|
-
while (parsedTagCursor < parsedComment.tags.length) {
|
|
2786
|
-
const candidate = parsedComment.tags[parsedTagCursor];
|
|
2787
|
-
parsedTagCursor += 1;
|
|
2788
|
-
if (candidate?.normalizedTagName === normalizedTagName) {
|
|
2789
|
-
return candidate;
|
|
2790
|
-
}
|
|
2791
|
-
}
|
|
2792
|
-
return null;
|
|
2793
|
-
};
|
|
2794
|
-
for (const parsedTag of parsedComment.tags) {
|
|
2795
|
-
if (TAGS_REQUIRING_RAW_TEXT.has(parsedTag.normalizedTagName)) {
|
|
2796
|
-
rawTextTags.push({ tag: parsedTag, commentText, commentOffset: range.pos });
|
|
2797
|
-
}
|
|
2798
|
-
}
|
|
2799
|
-
for (const block of docComment.customBlocks) {
|
|
2800
|
-
const tagName = (0, import_internals4.normalizeConstraintTagName)(block.blockTag.tagName.substring(1));
|
|
2801
|
-
const parsedTag = nextParsedTag(tagName);
|
|
2752
|
+
const extensions = options?.extensionRegistry?.extensions;
|
|
2753
|
+
const unified = (0, import_internal2.parseUnifiedComment)(commentText, {
|
|
2754
|
+
offset: range.pos,
|
|
2755
|
+
extensionTagNames,
|
|
2756
|
+
...extensions !== void 0 ? { extensions } : {}
|
|
2757
|
+
});
|
|
2758
|
+
for (const tag of unified.tags) {
|
|
2759
|
+
const tagName = tag.normalizedTagName;
|
|
2802
2760
|
if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
|
|
2803
|
-
const text2 =
|
|
2761
|
+
const text2 = tag.resolvedPayloadText;
|
|
2804
2762
|
if (text2 === "") continue;
|
|
2805
|
-
const provenance2 =
|
|
2763
|
+
const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
|
|
2806
2764
|
switch (tagName) {
|
|
2807
2765
|
case "displayName":
|
|
2808
2766
|
if (!isMemberTargetDisplayName(text2) && displayName === void 0) {
|
|
@@ -2827,64 +2785,69 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2827
2785
|
}
|
|
2828
2786
|
continue;
|
|
2829
2787
|
}
|
|
2830
|
-
if (TAGS_REQUIRING_RAW_TEXT.has(tagName))
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2788
|
+
if (import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
|
|
2789
|
+
const fallback = rawTextFallbacks.get(tagName)?.shift();
|
|
2790
|
+
const text2 = (0, import_internal2.choosePreferredPayloadText)(tag.resolvedPayloadText, fallback?.text ?? "");
|
|
2791
|
+
if (text2 === "") continue;
|
|
2792
|
+
const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
|
|
2793
|
+
if (tagName === "defaultValue") {
|
|
2794
|
+
annotations.push((0, import_internal2.parseDefaultValueTagValue)(text2, provenance2));
|
|
2795
|
+
continue;
|
|
2796
|
+
}
|
|
2797
|
+
processConstraintTag(
|
|
2798
|
+
tagName,
|
|
2799
|
+
text2,
|
|
2800
|
+
tag,
|
|
2801
|
+
provenance2,
|
|
2802
|
+
node,
|
|
2803
|
+
sourceFile,
|
|
2804
|
+
supportingDeclarations,
|
|
2805
|
+
options,
|
|
2806
|
+
constraints,
|
|
2807
|
+
diagnostics
|
|
2808
|
+
);
|
|
2846
2809
|
continue;
|
|
2847
2810
|
}
|
|
2848
|
-
const
|
|
2811
|
+
const text = tag.resolvedPayloadText;
|
|
2812
|
+
const expectedType = (0, import_internals4.isBuiltinConstraintName)(tagName) ? import_internals4.BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
|
|
2813
|
+
if (text === "" && expectedType !== "boolean") continue;
|
|
2814
|
+
const provenance = provenanceForParsedTag(tag, sourceFile, file);
|
|
2815
|
+
processConstraintTag(
|
|
2849
2816
|
tagName,
|
|
2850
2817
|
text,
|
|
2818
|
+
tag,
|
|
2851
2819
|
provenance,
|
|
2852
|
-
|
|
2820
|
+
node,
|
|
2821
|
+
sourceFile,
|
|
2822
|
+
supportingDeclarations,
|
|
2823
|
+
options,
|
|
2824
|
+
constraints,
|
|
2825
|
+
diagnostics
|
|
2853
2826
|
);
|
|
2854
|
-
if (constraintNode) {
|
|
2855
|
-
constraints.push(constraintNode);
|
|
2856
|
-
}
|
|
2857
2827
|
}
|
|
2858
|
-
if (
|
|
2859
|
-
const message = extractBlockText(docComment.deprecatedBlock).trim();
|
|
2828
|
+
if (unified.isDeprecated) {
|
|
2860
2829
|
annotations.push({
|
|
2861
2830
|
kind: "annotation",
|
|
2862
2831
|
annotationKind: "deprecated",
|
|
2863
|
-
...
|
|
2832
|
+
...unified.deprecationMessage !== "" && { message: unified.deprecationMessage },
|
|
2864
2833
|
provenance: provenanceForComment(range, sourceFile, file, "deprecated")
|
|
2865
2834
|
});
|
|
2866
2835
|
}
|
|
2867
|
-
{
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
provenance: provenanceForComment(range, sourceFile, file, "summary")
|
|
2875
|
-
});
|
|
2876
|
-
}
|
|
2836
|
+
if (unified.summaryText !== "") {
|
|
2837
|
+
annotations.push({
|
|
2838
|
+
kind: "annotation",
|
|
2839
|
+
annotationKind: "description",
|
|
2840
|
+
value: unified.summaryText,
|
|
2841
|
+
provenance: provenanceForComment(range, sourceFile, file, "summary")
|
|
2842
|
+
});
|
|
2877
2843
|
}
|
|
2878
|
-
if (
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
provenance: provenanceForComment(range, sourceFile, file, "remarks")
|
|
2886
|
-
});
|
|
2887
|
-
}
|
|
2844
|
+
if (unified.remarksText !== "") {
|
|
2845
|
+
annotations.push({
|
|
2846
|
+
kind: "annotation",
|
|
2847
|
+
annotationKind: "remarks",
|
|
2848
|
+
value: unified.remarksText,
|
|
2849
|
+
provenance: provenanceForComment(range, sourceFile, file, "remarks")
|
|
2850
|
+
});
|
|
2888
2851
|
}
|
|
2889
2852
|
}
|
|
2890
2853
|
}
|
|
@@ -2904,77 +2867,27 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
2904
2867
|
provenance: placeholderProvenance
|
|
2905
2868
|
});
|
|
2906
2869
|
}
|
|
2907
|
-
if (rawTextTags.length > 0) {
|
|
2908
|
-
for (const rawTextTag of rawTextTags) {
|
|
2909
|
-
const fallbackQueue = rawTextFallbacks.get(rawTextTag.tag.normalizedTagName);
|
|
2910
|
-
const fallback = fallbackQueue?.shift();
|
|
2911
|
-
const text = choosePreferredPayloadText(
|
|
2912
|
-
getSharedPayloadText(rawTextTag.tag, rawTextTag.commentText, rawTextTag.commentOffset),
|
|
2913
|
-
fallback?.text ?? ""
|
|
2914
|
-
);
|
|
2915
|
-
if (text === "") continue;
|
|
2916
|
-
const provenance = provenanceForParsedTag(rawTextTag.tag, sourceFile, file);
|
|
2917
|
-
if (rawTextTag.tag.normalizedTagName === "defaultValue") {
|
|
2918
|
-
const defaultValueNode = (0, import_internal2.parseDefaultValueTagValue)(text, provenance);
|
|
2919
|
-
annotations.push(defaultValueNode);
|
|
2920
|
-
continue;
|
|
2921
|
-
}
|
|
2922
|
-
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
2923
|
-
node,
|
|
2924
|
-
sourceFile,
|
|
2925
|
-
rawTextTag.tag.normalizedTagName,
|
|
2926
|
-
rawTextTag.tag,
|
|
2927
|
-
provenance,
|
|
2928
|
-
supportingDeclarations,
|
|
2929
|
-
options
|
|
2930
|
-
);
|
|
2931
|
-
if (compilerDiagnostics.length > 0) {
|
|
2932
|
-
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2933
|
-
continue;
|
|
2934
|
-
}
|
|
2935
|
-
const constraintNode = (0, import_internal2.parseConstraintTagValue)(
|
|
2936
|
-
rawTextTag.tag.normalizedTagName,
|
|
2937
|
-
text,
|
|
2938
|
-
provenance,
|
|
2939
|
-
sharedTagValueOptions(options)
|
|
2940
|
-
);
|
|
2941
|
-
if (constraintNode) {
|
|
2942
|
-
constraints.push(constraintNode);
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
2870
|
for (const [tagName, fallbacks] of rawTextFallbacks) {
|
|
2947
2871
|
for (const fallback of fallbacks) {
|
|
2948
2872
|
const text = fallback.text.trim();
|
|
2949
2873
|
if (text === "") continue;
|
|
2950
2874
|
const provenance = fallback.provenance;
|
|
2951
2875
|
if (tagName === "defaultValue") {
|
|
2952
|
-
|
|
2953
|
-
annotations.push(defaultValueNode);
|
|
2876
|
+
annotations.push((0, import_internal2.parseDefaultValueTagValue)(text, provenance));
|
|
2954
2877
|
continue;
|
|
2955
2878
|
}
|
|
2956
|
-
|
|
2957
|
-
node,
|
|
2958
|
-
sourceFile,
|
|
2879
|
+
processConstraintTag(
|
|
2959
2880
|
tagName,
|
|
2881
|
+
text,
|
|
2960
2882
|
null,
|
|
2961
2883
|
provenance,
|
|
2884
|
+
node,
|
|
2885
|
+
sourceFile,
|
|
2962
2886
|
supportingDeclarations,
|
|
2963
|
-
options
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
2967
|
-
continue;
|
|
2968
|
-
}
|
|
2969
|
-
const constraintNode = (0, import_internal2.parseConstraintTagValue)(
|
|
2970
|
-
tagName,
|
|
2971
|
-
text,
|
|
2972
|
-
provenance,
|
|
2973
|
-
sharedTagValueOptions(options)
|
|
2887
|
+
options,
|
|
2888
|
+
constraints,
|
|
2889
|
+
diagnostics
|
|
2974
2890
|
);
|
|
2975
|
-
if (constraintNode) {
|
|
2976
|
-
constraints.push(constraintNode);
|
|
2977
|
-
}
|
|
2978
2891
|
}
|
|
2979
2892
|
}
|
|
2980
2893
|
const result = { constraints, annotations, diagnostics };
|
|
@@ -2992,8 +2905,8 @@ function extractDisplayNameMetadata(node) {
|
|
|
2992
2905
|
if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) continue;
|
|
2993
2906
|
const commentText = sourceText.substring(range.pos, range.end);
|
|
2994
2907
|
if (!commentText.startsWith("/**")) continue;
|
|
2995
|
-
const
|
|
2996
|
-
for (const tag of
|
|
2908
|
+
const unified = (0, import_internal2.parseUnifiedComment)(commentText);
|
|
2909
|
+
for (const tag of unified.tags) {
|
|
2997
2910
|
if (tag.normalizedTagName !== "displayName") {
|
|
2998
2911
|
continue;
|
|
2999
2912
|
}
|
|
@@ -3012,56 +2925,11 @@ function extractDisplayNameMetadata(node) {
|
|
|
3012
2925
|
memberDisplayNames
|
|
3013
2926
|
};
|
|
3014
2927
|
}
|
|
3015
|
-
function extractBlockText(block) {
|
|
3016
|
-
return extractPlainText(block.content);
|
|
3017
|
-
}
|
|
3018
|
-
function extractPlainText(node) {
|
|
3019
|
-
let result = "";
|
|
3020
|
-
if (node instanceof import_tsdoc.DocExcerpt) {
|
|
3021
|
-
return node.content.toString();
|
|
3022
|
-
}
|
|
3023
|
-
if (node instanceof import_tsdoc.DocPlainText) {
|
|
3024
|
-
return node.text;
|
|
3025
|
-
}
|
|
3026
|
-
if (node instanceof import_tsdoc.DocSoftBreak) {
|
|
3027
|
-
return " ";
|
|
3028
|
-
}
|
|
3029
|
-
if (typeof node.getChildNodes === "function") {
|
|
3030
|
-
for (const child of node.getChildNodes()) {
|
|
3031
|
-
result += extractPlainText(child);
|
|
3032
|
-
}
|
|
3033
|
-
}
|
|
3034
|
-
return result;
|
|
3035
|
-
}
|
|
3036
|
-
function choosePreferredPayloadText(primary, fallback) {
|
|
3037
|
-
const preferred = primary.trim();
|
|
3038
|
-
const alternate = fallback.trim();
|
|
3039
|
-
if (preferred === "") return alternate;
|
|
3040
|
-
if (alternate === "") return preferred;
|
|
3041
|
-
if (alternate.includes("\n")) return alternate;
|
|
3042
|
-
if (alternate.length > preferred.length && alternate.startsWith(preferred)) {
|
|
3043
|
-
return alternate;
|
|
3044
|
-
}
|
|
3045
|
-
return preferred;
|
|
3046
|
-
}
|
|
3047
|
-
function getSharedPayloadText(tag, commentText, commentOffset) {
|
|
3048
|
-
if (tag.payloadSpan === null) {
|
|
3049
|
-
return "";
|
|
3050
|
-
}
|
|
3051
|
-
return (0, import_internal2.sliceCommentSpan)(commentText, tag.payloadSpan, {
|
|
3052
|
-
offset: commentOffset
|
|
3053
|
-
}).trim();
|
|
3054
|
-
}
|
|
3055
|
-
function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
|
|
3056
|
-
const sharedText = tag === null ? "" : getSharedPayloadText(tag, commentText, commentOffset);
|
|
3057
|
-
const blockText = extractBlockText(block).replace(/\s+/g, " ").trim();
|
|
3058
|
-
return choosePreferredPayloadText(sharedText, blockText);
|
|
3059
|
-
}
|
|
3060
2928
|
function collectRawTextFallbacks(node, file) {
|
|
3061
2929
|
const fallbacks = /* @__PURE__ */ new Map();
|
|
3062
2930
|
for (const tag of ts.getJSDocTags(node)) {
|
|
3063
2931
|
const tagName = (0, import_internals4.normalizeConstraintTagName)(tag.tagName.text);
|
|
3064
|
-
if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
2932
|
+
if (!import_internal2.TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
3065
2933
|
const commentText = getTagCommentText(tag)?.trim() ?? "";
|
|
3066
2934
|
if (commentText === "") continue;
|
|
3067
2935
|
const entries = fallbacks.get(tagName) ?? [];
|
|
@@ -3116,18 +2984,15 @@ function getTagCommentText(tag) {
|
|
|
3116
2984
|
}
|
|
3117
2985
|
return ts.getTextOfJSDocComment(tag.comment);
|
|
3118
2986
|
}
|
|
3119
|
-
var ts, import_internal2,
|
|
2987
|
+
var ts, import_internal2, import_internals4, import_internals5, SYNTHETIC_TYPE_FORMAT_FLAGS, parseResultCache;
|
|
3120
2988
|
var init_tsdoc_parser = __esm({
|
|
3121
2989
|
"src/analyzer/tsdoc-parser.ts"() {
|
|
3122
2990
|
"use strict";
|
|
3123
2991
|
ts = __toESM(require("typescript"), 1);
|
|
3124
2992
|
import_internal2 = require("@formspec/analysis/internal");
|
|
3125
|
-
import_tsdoc = require("@microsoft/tsdoc");
|
|
3126
2993
|
import_internals4 = require("@formspec/core/internals");
|
|
3127
2994
|
import_internals5 = require("@formspec/core/internals");
|
|
3128
|
-
TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
|
|
3129
2995
|
SYNTHETIC_TYPE_FORMAT_FLAGS = ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
|
|
3130
|
-
parserCache = /* @__PURE__ */ new Map();
|
|
3131
2996
|
parseResultCache = /* @__PURE__ */ new Map();
|
|
3132
2997
|
}
|
|
3133
2998
|
});
|
|
@@ -4724,7 +4589,7 @@ function typeNodeContainsReference(type, targetName) {
|
|
|
4724
4589
|
}
|
|
4725
4590
|
}
|
|
4726
4591
|
function shouldEmitResolvedObjectProperty(property, declaration) {
|
|
4727
|
-
if (property.name.startsWith("__
|
|
4592
|
+
if (property.name.startsWith("__")) {
|
|
4728
4593
|
return false;
|
|
4729
4594
|
}
|
|
4730
4595
|
if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
|
|
@@ -5754,7 +5619,9 @@ function generateSchemasFromClass(options) {
|
|
|
5754
5619
|
classDecl,
|
|
5755
5620
|
ctx.checker,
|
|
5756
5621
|
options.filePath,
|
|
5622
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5757
5623
|
options.extensionRegistry,
|
|
5624
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5758
5625
|
options.metadata,
|
|
5759
5626
|
options.discriminator
|
|
5760
5627
|
);
|
|
@@ -5762,9 +5629,13 @@ function generateSchemasFromClass(options) {
|
|
|
5762
5629
|
analysis,
|
|
5763
5630
|
{ file: options.filePath },
|
|
5764
5631
|
{
|
|
5632
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5765
5633
|
extensionRegistry: options.extensionRegistry,
|
|
5634
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5766
5635
|
metadata: options.metadata,
|
|
5636
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5767
5637
|
enumSerialization: options.enumSerialization,
|
|
5638
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5768
5639
|
vendorPrefix: options.vendorPrefix
|
|
5769
5640
|
}
|
|
5770
5641
|
);
|
|
@@ -5811,7 +5682,12 @@ function generateSchemasDetailedInternal(options) {
|
|
|
5811
5682
|
diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
|
|
5812
5683
|
};
|
|
5813
5684
|
}
|
|
5814
|
-
return generateSchemasFromDetailedProgramContext(
|
|
5685
|
+
return generateSchemasFromDetailedProgramContext(
|
|
5686
|
+
ctx,
|
|
5687
|
+
options.filePath,
|
|
5688
|
+
options.typeName,
|
|
5689
|
+
options
|
|
5690
|
+
);
|
|
5815
5691
|
}
|
|
5816
5692
|
function generateSchemasFromProgramDetailed(options) {
|
|
5817
5693
|
return generateSchemasFromProgram({
|
|
@@ -5829,7 +5705,12 @@ function generateSchemasFromProgramDetailedInternal(options) {
|
|
|
5829
5705
|
diagnostics: [createProgramContextFailureDiagnostic(options.filePath, error)]
|
|
5830
5706
|
};
|
|
5831
5707
|
}
|
|
5832
|
-
return generateSchemasFromDetailedProgramContext(
|
|
5708
|
+
return generateSchemasFromDetailedProgramContext(
|
|
5709
|
+
ctx,
|
|
5710
|
+
options.filePath,
|
|
5711
|
+
options.typeName,
|
|
5712
|
+
options
|
|
5713
|
+
);
|
|
5833
5714
|
}
|
|
5834
5715
|
function generateSchemasBatch(options) {
|
|
5835
5716
|
const contextCache = /* @__PURE__ */ new Map();
|
|
@@ -5873,13 +5754,27 @@ function generateSchemasBatchFromProgram(options) {
|
|
|
5873
5754
|
);
|
|
5874
5755
|
});
|
|
5875
5756
|
}
|
|
5757
|
+
function resolveOptions(options) {
|
|
5758
|
+
const configRegistry = options.config?.extensions !== void 0 ? createExtensionRegistry(options.config.extensions) : void 0;
|
|
5759
|
+
return {
|
|
5760
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5761
|
+
extensionRegistry: options.extensionRegistry ?? configRegistry,
|
|
5762
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5763
|
+
vendorPrefix: options.vendorPrefix ?? options.config?.vendorPrefix,
|
|
5764
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5765
|
+
enumSerialization: options.enumSerialization ?? options.config?.enumSerialization,
|
|
5766
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
5767
|
+
metadata: options.metadata ?? options.config?.metadata
|
|
5768
|
+
};
|
|
5769
|
+
}
|
|
5876
5770
|
function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, options) {
|
|
5771
|
+
const resolved = resolveOptions(options);
|
|
5877
5772
|
const analysisResult = analyzeNamedTypeToIRFromProgramContextDetailed(
|
|
5878
5773
|
ctx,
|
|
5879
5774
|
filePath,
|
|
5880
5775
|
typeName,
|
|
5881
|
-
|
|
5882
|
-
|
|
5776
|
+
resolved.extensionRegistry,
|
|
5777
|
+
resolved.metadata,
|
|
5883
5778
|
options.discriminator
|
|
5884
5779
|
);
|
|
5885
5780
|
if (!analysisResult.ok) {
|
|
@@ -5892,10 +5787,10 @@ function generateSchemasFromDetailedProgramContext(ctx, filePath, typeName, opti
|
|
|
5892
5787
|
analysisResult.analysis,
|
|
5893
5788
|
{ file: filePath },
|
|
5894
5789
|
{
|
|
5895
|
-
extensionRegistry:
|
|
5896
|
-
metadata:
|
|
5897
|
-
enumSerialization:
|
|
5898
|
-
vendorPrefix:
|
|
5790
|
+
extensionRegistry: resolved.extensionRegistry,
|
|
5791
|
+
metadata: resolved.metadata,
|
|
5792
|
+
enumSerialization: resolved.enumSerialization,
|
|
5793
|
+
vendorPrefix: resolved.vendorPrefix
|
|
5899
5794
|
}
|
|
5900
5795
|
);
|
|
5901
5796
|
}
|
|
@@ -5929,6 +5824,7 @@ var init_class_schema = __esm({
|
|
|
5929
5824
|
init_class_analyzer();
|
|
5930
5825
|
init_canonicalize();
|
|
5931
5826
|
init_ir_generator();
|
|
5827
|
+
init_extensions();
|
|
5932
5828
|
init_ir_generator2();
|
|
5933
5829
|
init_validate();
|
|
5934
5830
|
}
|
|
@@ -6049,6 +5945,7 @@ function omitApiName(metadata) {
|
|
|
6049
5945
|
}
|
|
6050
5946
|
function enforceRequiredMetadata(metadata, declarationKind, logicalName, options) {
|
|
6051
5947
|
const declarationPolicy = getDeclarationMetadataPolicy(
|
|
5948
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6052
5949
|
normalizeMetadataPolicy(options.metadata),
|
|
6053
5950
|
declarationKind
|
|
6054
5951
|
);
|
|
@@ -6123,6 +6020,7 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
|
|
|
6123
6020
|
provenance: syntheticField.provenance
|
|
6124
6021
|
},
|
|
6125
6022
|
{
|
|
6023
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6126
6024
|
policy: normalizeMetadataPolicy(options?.metadata),
|
|
6127
6025
|
surface: "tsdoc",
|
|
6128
6026
|
rootLogicalName: root.name
|
|
@@ -6131,8 +6029,11 @@ function toStandaloneJsonSchema(root, typeRegistry, options) {
|
|
|
6131
6029
|
const schema = generateJsonSchemaFromIR(
|
|
6132
6030
|
ir,
|
|
6133
6031
|
{
|
|
6032
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6134
6033
|
extensionRegistry: options?.extensionRegistry,
|
|
6034
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6135
6035
|
enumSerialization: options?.enumSerialization,
|
|
6036
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6136
6037
|
vendorPrefix: options?.vendorPrefix
|
|
6137
6038
|
}
|
|
6138
6039
|
);
|
|
@@ -6158,9 +6059,13 @@ function generateSchemasFromAnalysis(analysis, filePath, options) {
|
|
|
6158
6059
|
analysis,
|
|
6159
6060
|
{ file: filePath },
|
|
6160
6061
|
{
|
|
6062
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6161
6063
|
extensionRegistry: options?.extensionRegistry,
|
|
6064
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6162
6065
|
enumSerialization: options?.enumSerialization,
|
|
6066
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6163
6067
|
metadata: options?.metadata,
|
|
6068
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6164
6069
|
vendorPrefix: options?.vendorPrefix
|
|
6165
6070
|
}
|
|
6166
6071
|
),
|
|
@@ -6185,7 +6090,9 @@ function generateSchemasFromResolvedType(options, skipNamedDeclaration = false,
|
|
|
6185
6090
|
typeRegistry,
|
|
6186
6091
|
/* @__PURE__ */ new Set(),
|
|
6187
6092
|
options.sourceNode,
|
|
6093
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6188
6094
|
createAnalyzerMetadataPolicy(options.metadata, options.discriminator),
|
|
6095
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6189
6096
|
options.extensionRegistry,
|
|
6190
6097
|
diagnostics
|
|
6191
6098
|
);
|
|
@@ -6234,7 +6141,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6234
6141
|
options.declaration,
|
|
6235
6142
|
options.context.checker,
|
|
6236
6143
|
filePath,
|
|
6144
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6237
6145
|
options.extensionRegistry,
|
|
6146
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6238
6147
|
options.metadata,
|
|
6239
6148
|
options.discriminator
|
|
6240
6149
|
),
|
|
@@ -6248,7 +6157,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6248
6157
|
options.declaration,
|
|
6249
6158
|
options.context.checker,
|
|
6250
6159
|
filePath,
|
|
6160
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6251
6161
|
options.extensionRegistry,
|
|
6162
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6252
6163
|
options.metadata,
|
|
6253
6164
|
options.discriminator
|
|
6254
6165
|
),
|
|
@@ -6261,7 +6172,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6261
6172
|
options.declaration,
|
|
6262
6173
|
options.context.checker,
|
|
6263
6174
|
filePath,
|
|
6175
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6264
6176
|
options.extensionRegistry,
|
|
6177
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6265
6178
|
options.metadata,
|
|
6266
6179
|
options.discriminator
|
|
6267
6180
|
);
|
|
@@ -6272,7 +6185,9 @@ function generateSchemasFromDeclaration(options) {
|
|
|
6272
6185
|
options.declaration,
|
|
6273
6186
|
options.context.checker,
|
|
6274
6187
|
filePath,
|
|
6188
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6275
6189
|
options.extensionRegistry,
|
|
6190
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6276
6191
|
options.metadata
|
|
6277
6192
|
);
|
|
6278
6193
|
if (aliasRootInfo.diagnostics.length > 0) {
|
|
@@ -6327,7 +6242,9 @@ function resolveDeclarationMetadata(options) {
|
|
|
6327
6242
|
const analysis = (0, import_internal5.analyzeMetadataForNodeWithChecker)({
|
|
6328
6243
|
checker: options.context.checker,
|
|
6329
6244
|
node: options.declaration,
|
|
6245
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6330
6246
|
metadata: options.metadata,
|
|
6247
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6331
6248
|
extensions: options.extensionRegistry?.extensions,
|
|
6332
6249
|
buildContext: options.context
|
|
6333
6250
|
});
|
|
@@ -6377,7 +6294,9 @@ function buildMixedAuthoringSchemas(options) {
|
|
|
6377
6294
|
const analysis = analyzeNamedTypeToIR(
|
|
6378
6295
|
filePath,
|
|
6379
6296
|
typeName,
|
|
6297
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6380
6298
|
schemaOptions.extensionRegistry,
|
|
6299
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6381
6300
|
schemaOptions.metadata,
|
|
6382
6301
|
schemaOptions.discriminator
|
|
6383
6302
|
);
|
|
@@ -6385,6 +6304,7 @@ function buildMixedAuthoringSchemas(options) {
|
|
|
6385
6304
|
const ir = canonicalizeTSDoc(
|
|
6386
6305
|
composedAnalysis,
|
|
6387
6306
|
{ file: filePath },
|
|
6307
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- migration bridge reads deprecated fields
|
|
6388
6308
|
schemaOptions.metadata !== void 0 ? { metadata: schemaOptions.metadata } : void 0
|
|
6389
6309
|
);
|
|
6390
6310
|
return {
|