@formspec/build 0.1.0-alpha.20 → 0.1.0-alpha.22
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/__tests__/fixtures/class-schema-regressions.d.ts +7 -8
- package/dist/__tests__/fixtures/class-schema-regressions.d.ts.map +1 -1
- package/dist/__tests__/fixtures/example-a-builtins.d.ts +5 -4
- package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +1 -1
- package/dist/__tests__/fixtures/example-interface-types.d.ts +7 -2
- package/dist/__tests__/fixtures/example-interface-types.d.ts.map +1 -1
- package/dist/__tests__/fixtures/sample-forms.d.ts +1 -1
- package/dist/__tests__/parity/utils.d.ts +3 -2
- package/dist/__tests__/parity/utils.d.ts.map +1 -1
- package/dist/analyzer/class-analyzer.d.ts +1 -1
- package/dist/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts +8 -7
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/browser.cjs +6 -3
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +4 -1
- package/dist/browser.js.map +1 -1
- package/dist/build.d.ts +150 -2
- package/dist/cli.cjs +44 -47
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +25 -28
- package/dist/cli.js.map +1 -1
- package/dist/extensions/registry.d.ts +4 -0
- package/dist/extensions/registry.d.ts.map +1 -1
- package/dist/generators/class-schema.d.ts +12 -0
- package/dist/generators/class-schema.d.ts.map +1 -1
- package/dist/generators/mixed-authoring.d.ts +6 -0
- package/dist/generators/mixed-authoring.d.ts.map +1 -1
- package/dist/index.cjs +42 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -28
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +42 -45
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +25 -28
- package/dist/internals.js.map +1 -1
- package/dist/json-schema/generator.d.ts +4 -0
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/json-schema/ir-generator.d.ts +6 -0
- package/dist/json-schema/ir-generator.d.ts.map +1 -1
- package/dist/json-schema/schema.d.ts +7 -0
- package/dist/json-schema/schema.d.ts.map +1 -1
- package/dist/json-schema/types.d.ts +18 -2
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/ui-schema/generator.d.ts +2 -0
- package/dist/ui-schema/generator.d.ts.map +1 -1
- package/dist/ui-schema/schema.d.ts +77 -0
- package/dist/ui-schema/schema.d.ts.map +1 -1
- package/dist/ui-schema/types.d.ts +2 -0
- package/dist/ui-schema/types.d.ts.map +1 -1
- package/dist/validate/constraint-validator.d.ts +1 -1
- package/dist/validate/constraint-validator.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/cli.cjs
CHANGED
|
@@ -794,6 +794,9 @@ function applyAnnotations(schema, annotations, ctx) {
|
|
|
794
794
|
case "description":
|
|
795
795
|
schema.description = annotation.value;
|
|
796
796
|
break;
|
|
797
|
+
case "remarks":
|
|
798
|
+
schema[`${ctx.vendorPrefix}-remarks`] = annotation.value;
|
|
799
|
+
break;
|
|
797
800
|
case "defaultValue":
|
|
798
801
|
schema.default = annotation.value;
|
|
799
802
|
break;
|
|
@@ -1324,7 +1327,7 @@ function createFormSpecTSDocConfig(extensionTagNames = []) {
|
|
|
1324
1327
|
})
|
|
1325
1328
|
);
|
|
1326
1329
|
}
|
|
1327
|
-
for (const tagName of ["displayName", "
|
|
1330
|
+
for (const tagName of ["displayName", "format", "placeholder"]) {
|
|
1328
1331
|
config.addTagDefinition(
|
|
1329
1332
|
new import_tsdoc.TSDocTagDefinition({
|
|
1330
1333
|
tagName: "@" + tagName,
|
|
@@ -1402,12 +1405,12 @@ function supportsConstraintCapability(type, checker, capability) {
|
|
|
1402
1405
|
if (capability === void 0) {
|
|
1403
1406
|
return true;
|
|
1404
1407
|
}
|
|
1405
|
-
if ((0,
|
|
1408
|
+
if ((0, import_internal.hasTypeSemanticCapability)(type, checker, capability)) {
|
|
1406
1409
|
return true;
|
|
1407
1410
|
}
|
|
1408
1411
|
if (capability === "string-like") {
|
|
1409
1412
|
const itemType = getArrayElementType(type, checker);
|
|
1410
|
-
return itemType !== null && (0,
|
|
1413
|
+
return itemType !== null && (0, import_internal.hasTypeSemanticCapability)(itemType, checker, capability);
|
|
1411
1414
|
}
|
|
1412
1415
|
return false;
|
|
1413
1416
|
}
|
|
@@ -1505,11 +1508,11 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1505
1508
|
if (checker === void 0 || subjectType === void 0) {
|
|
1506
1509
|
return [];
|
|
1507
1510
|
}
|
|
1508
|
-
const placement = (0,
|
|
1511
|
+
const placement = (0, import_internal.resolveDeclarationPlacement)(node);
|
|
1509
1512
|
if (placement === null) {
|
|
1510
1513
|
return [];
|
|
1511
1514
|
}
|
|
1512
|
-
const definition = (0,
|
|
1515
|
+
const definition = (0, import_internal.getTagDefinition)(tagName, options?.extensionRegistry?.extensions);
|
|
1513
1516
|
if (definition === null) {
|
|
1514
1517
|
return [];
|
|
1515
1518
|
}
|
|
@@ -1543,7 +1546,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1543
1546
|
)
|
|
1544
1547
|
];
|
|
1545
1548
|
}
|
|
1546
|
-
const resolution = (0,
|
|
1549
|
+
const resolution = (0, import_internal.resolvePathTargetType)(subjectType, checker, target.path.segments);
|
|
1547
1550
|
if (resolution.kind === "missing-property") {
|
|
1548
1551
|
return [
|
|
1549
1552
|
makeDiagnostic(
|
|
@@ -1600,7 +1603,7 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1600
1603
|
const subjectTypeText = checker.typeToString(subjectType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
|
|
1601
1604
|
const hostType = options?.hostType ?? subjectType;
|
|
1602
1605
|
const hostTypeText = checker.typeToString(hostType, node, SYNTHETIC_TYPE_FORMAT_FLAGS);
|
|
1603
|
-
const result = (0,
|
|
1606
|
+
const result = (0, import_internal.checkSyntheticTagApplication)({
|
|
1604
1607
|
tagName,
|
|
1605
1608
|
placement,
|
|
1606
1609
|
hostType: hostTypeText,
|
|
@@ -1681,10 +1684,8 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1681
1684
|
const annotations = [];
|
|
1682
1685
|
const diagnostics = [];
|
|
1683
1686
|
let displayName;
|
|
1684
|
-
let description;
|
|
1685
1687
|
let placeholder;
|
|
1686
1688
|
let displayNameProvenance;
|
|
1687
|
-
let descriptionProvenance;
|
|
1688
1689
|
let placeholderProvenance;
|
|
1689
1690
|
const rawTextTags = [];
|
|
1690
1691
|
const sourceFile = node.getSourceFile();
|
|
@@ -1706,7 +1707,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1706
1707
|
import_tsdoc.TextRange.fromStringRange(sourceText, range.pos, range.end)
|
|
1707
1708
|
);
|
|
1708
1709
|
const docComment = parserContext.docComment;
|
|
1709
|
-
const parsedComment = (0,
|
|
1710
|
+
const parsedComment = (0, import_internal.parseCommentBlock)(
|
|
1710
1711
|
commentText,
|
|
1711
1712
|
sharedCommentSyntaxOptions(options, range.pos)
|
|
1712
1713
|
);
|
|
@@ -1729,7 +1730,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1729
1730
|
for (const block of docComment.customBlocks) {
|
|
1730
1731
|
const tagName = (0, import_core3.normalizeConstraintTagName)(block.blockTag.tagName.substring(1));
|
|
1731
1732
|
const parsedTag = nextParsedTag(tagName);
|
|
1732
|
-
if (tagName === "displayName" || tagName === "
|
|
1733
|
+
if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
|
|
1733
1734
|
const text2 = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
|
|
1734
1735
|
if (text2 === "") continue;
|
|
1735
1736
|
const provenance2 = parsedTag !== null ? provenanceForParsedTag(parsedTag, sourceFile, file) : provenanceForComment(range, sourceFile, file, tagName);
|
|
@@ -1748,10 +1749,6 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1748
1749
|
provenance: provenance2
|
|
1749
1750
|
});
|
|
1750
1751
|
break;
|
|
1751
|
-
case "description":
|
|
1752
|
-
description = text2;
|
|
1753
|
-
descriptionProvenance = provenance2;
|
|
1754
|
-
break;
|
|
1755
1752
|
case "placeholder":
|
|
1756
1753
|
if (placeholder === void 0) {
|
|
1757
1754
|
placeholder = text2;
|
|
@@ -1779,7 +1776,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1779
1776
|
diagnostics.push(...compilerDiagnostics);
|
|
1780
1777
|
continue;
|
|
1781
1778
|
}
|
|
1782
|
-
const constraintNode = (0,
|
|
1779
|
+
const constraintNode = (0, import_internal.parseConstraintTagValue)(
|
|
1783
1780
|
tagName,
|
|
1784
1781
|
text,
|
|
1785
1782
|
provenance,
|
|
@@ -1798,18 +1795,26 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1798
1795
|
provenance: provenanceForComment(range, sourceFile, file, "deprecated")
|
|
1799
1796
|
});
|
|
1800
1797
|
}
|
|
1801
|
-
|
|
1802
|
-
const remarks = extractBlockText(docComment.remarksBlock).trim();
|
|
1803
|
-
if (remarks !== "") {
|
|
1804
|
-
description = remarks;
|
|
1805
|
-
descriptionProvenance = provenanceForComment(range, sourceFile, file, "remarks");
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
if (description === void 0) {
|
|
1798
|
+
{
|
|
1809
1799
|
const summary = extractPlainText(docComment.summarySection).trim();
|
|
1810
1800
|
if (summary !== "") {
|
|
1811
|
-
|
|
1812
|
-
|
|
1801
|
+
annotations.push({
|
|
1802
|
+
kind: "annotation",
|
|
1803
|
+
annotationKind: "description",
|
|
1804
|
+
value: summary,
|
|
1805
|
+
provenance: provenanceForComment(range, sourceFile, file, "summary")
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
if (docComment.remarksBlock !== void 0) {
|
|
1810
|
+
const remarksText = extractBlockText(docComment.remarksBlock).trim();
|
|
1811
|
+
if (remarksText !== "") {
|
|
1812
|
+
annotations.push({
|
|
1813
|
+
kind: "annotation",
|
|
1814
|
+
annotationKind: "remarks",
|
|
1815
|
+
value: remarksText,
|
|
1816
|
+
provenance: provenanceForComment(range, sourceFile, file, "remarks")
|
|
1817
|
+
});
|
|
1813
1818
|
}
|
|
1814
1819
|
}
|
|
1815
1820
|
}
|
|
@@ -1822,14 +1827,6 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1822
1827
|
provenance: displayNameProvenance
|
|
1823
1828
|
});
|
|
1824
1829
|
}
|
|
1825
|
-
if (description !== void 0 && descriptionProvenance !== void 0) {
|
|
1826
|
-
annotations.push({
|
|
1827
|
-
kind: "annotation",
|
|
1828
|
-
annotationKind: "description",
|
|
1829
|
-
value: description,
|
|
1830
|
-
provenance: descriptionProvenance
|
|
1831
|
-
});
|
|
1832
|
-
}
|
|
1833
1830
|
if (placeholder !== void 0 && placeholderProvenance !== void 0) {
|
|
1834
1831
|
annotations.push({
|
|
1835
1832
|
kind: "annotation",
|
|
@@ -1849,7 +1846,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1849
1846
|
if (text === "") continue;
|
|
1850
1847
|
const provenance = provenanceForParsedTag(rawTextTag.tag, sourceFile, file);
|
|
1851
1848
|
if (rawTextTag.tag.normalizedTagName === "defaultValue") {
|
|
1852
|
-
const defaultValueNode = (0,
|
|
1849
|
+
const defaultValueNode = (0, import_internal.parseDefaultValueTagValue)(text, provenance);
|
|
1853
1850
|
annotations.push(defaultValueNode);
|
|
1854
1851
|
continue;
|
|
1855
1852
|
}
|
|
@@ -1866,7 +1863,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1866
1863
|
diagnostics.push(...compilerDiagnostics);
|
|
1867
1864
|
continue;
|
|
1868
1865
|
}
|
|
1869
|
-
const constraintNode = (0,
|
|
1866
|
+
const constraintNode = (0, import_internal.parseConstraintTagValue)(
|
|
1870
1867
|
rawTextTag.tag.normalizedTagName,
|
|
1871
1868
|
text,
|
|
1872
1869
|
provenance,
|
|
@@ -1883,7 +1880,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1883
1880
|
if (text === "") continue;
|
|
1884
1881
|
const provenance = fallback.provenance;
|
|
1885
1882
|
if (tagName === "defaultValue") {
|
|
1886
|
-
const defaultValueNode = (0,
|
|
1883
|
+
const defaultValueNode = (0, import_internal.parseDefaultValueTagValue)(text, provenance);
|
|
1887
1884
|
annotations.push(defaultValueNode);
|
|
1888
1885
|
continue;
|
|
1889
1886
|
}
|
|
@@ -1900,7 +1897,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1900
1897
|
diagnostics.push(...compilerDiagnostics);
|
|
1901
1898
|
continue;
|
|
1902
1899
|
}
|
|
1903
|
-
const constraintNode = (0,
|
|
1900
|
+
const constraintNode = (0, import_internal.parseConstraintTagValue)(
|
|
1904
1901
|
tagName,
|
|
1905
1902
|
text,
|
|
1906
1903
|
provenance,
|
|
@@ -1926,7 +1923,7 @@ function extractDisplayNameMetadata(node) {
|
|
|
1926
1923
|
if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) continue;
|
|
1927
1924
|
const commentText = sourceText.substring(range.pos, range.end);
|
|
1928
1925
|
if (!commentText.startsWith("/**")) continue;
|
|
1929
|
-
const parsed = (0,
|
|
1926
|
+
const parsed = (0, import_internal.parseCommentBlock)(commentText);
|
|
1930
1927
|
for (const tag of parsed.tags) {
|
|
1931
1928
|
if (tag.normalizedTagName !== "displayName") {
|
|
1932
1929
|
continue;
|
|
@@ -1979,7 +1976,7 @@ function getSharedPayloadText(tag, commentText, commentOffset) {
|
|
|
1979
1976
|
if (tag.payloadSpan === null) {
|
|
1980
1977
|
return "";
|
|
1981
1978
|
}
|
|
1982
|
-
return (0,
|
|
1979
|
+
return (0, import_internal.sliceCommentSpan)(commentText, tag.payloadSpan, {
|
|
1983
1980
|
offset: commentOffset
|
|
1984
1981
|
}).trim();
|
|
1985
1982
|
}
|
|
@@ -2005,7 +2002,7 @@ function collectRawTextFallbacks(node, file) {
|
|
|
2005
2002
|
return fallbacks;
|
|
2006
2003
|
}
|
|
2007
2004
|
function isMemberTargetDisplayName(text) {
|
|
2008
|
-
return (0,
|
|
2005
|
+
return (0, import_internal.parseTagSyntax)("displayName", text).target !== null;
|
|
2009
2006
|
}
|
|
2010
2007
|
function provenanceForComment(range, sourceFile, file, tagName) {
|
|
2011
2008
|
const { line, character } = sourceFile.getLineAndCharacterOfPosition(range.pos);
|
|
@@ -2047,12 +2044,12 @@ function getTagCommentText(tag) {
|
|
|
2047
2044
|
}
|
|
2048
2045
|
return ts.getTextOfJSDocComment(tag.comment);
|
|
2049
2046
|
}
|
|
2050
|
-
var ts,
|
|
2047
|
+
var ts, import_internal, import_tsdoc, import_core3, TAGS_REQUIRING_RAW_TEXT, SYNTHETIC_TYPE_FORMAT_FLAGS, parserCache, parseResultCache;
|
|
2051
2048
|
var init_tsdoc_parser = __esm({
|
|
2052
2049
|
"src/analyzer/tsdoc-parser.ts"() {
|
|
2053
2050
|
"use strict";
|
|
2054
2051
|
ts = __toESM(require("typescript"), 1);
|
|
2055
|
-
|
|
2052
|
+
import_internal = require("@formspec/analysis/internal");
|
|
2056
2053
|
import_tsdoc = require("@microsoft/tsdoc");
|
|
2057
2054
|
import_core3 = require("@formspec/core");
|
|
2058
2055
|
TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
|
|
@@ -3324,7 +3321,7 @@ var init_program = __esm({
|
|
|
3324
3321
|
|
|
3325
3322
|
// src/validate/constraint-validator.ts
|
|
3326
3323
|
function validateFieldNode(ctx, field) {
|
|
3327
|
-
const analysis = (0,
|
|
3324
|
+
const analysis = (0, import_internal2.analyzeConstraintTargets)(
|
|
3328
3325
|
field.name,
|
|
3329
3326
|
field.type,
|
|
3330
3327
|
field.constraints,
|
|
@@ -3342,7 +3339,7 @@ function validateFieldNode(ctx, field) {
|
|
|
3342
3339
|
}
|
|
3343
3340
|
function validateObjectProperty(ctx, parentName, property) {
|
|
3344
3341
|
const qualifiedName = `${parentName}.${property.name}`;
|
|
3345
|
-
const analysis = (0,
|
|
3342
|
+
const analysis = (0, import_internal2.analyzeConstraintTargets)(
|
|
3346
3343
|
qualifiedName,
|
|
3347
3344
|
property.type,
|
|
3348
3345
|
property.constraints,
|
|
@@ -3393,11 +3390,11 @@ function validateIR(ir, options) {
|
|
|
3393
3390
|
valid: ctx.diagnostics.every((diagnostic) => diagnostic.severity !== "error")
|
|
3394
3391
|
};
|
|
3395
3392
|
}
|
|
3396
|
-
var
|
|
3393
|
+
var import_internal2;
|
|
3397
3394
|
var init_constraint_validator = __esm({
|
|
3398
3395
|
"src/validate/constraint-validator.ts"() {
|
|
3399
3396
|
"use strict";
|
|
3400
|
-
|
|
3397
|
+
import_internal2 = require("@formspec/analysis/internal");
|
|
3401
3398
|
}
|
|
3402
3399
|
});
|
|
3403
3400
|
|