@formspec/build 0.1.0-alpha.42 → 0.1.0-alpha.44
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/browser.cjs +2 -2
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +2 -2
- package/dist/browser.js.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 +197 -246
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +202 -259
- 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 +194 -244
- 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 +199 -257
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +273 -377
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +281 -393
- package/dist/internals.js.map +1 -1
- package/package.json +5 -6
package/dist/internals.js
CHANGED
|
@@ -796,7 +796,7 @@ import * as path from "path";
|
|
|
796
796
|
import * as ts3 from "typescript";
|
|
797
797
|
import {
|
|
798
798
|
analyzeMetadataForNodeWithChecker,
|
|
799
|
-
parseCommentBlock
|
|
799
|
+
parseCommentBlock
|
|
800
800
|
} from "@formspec/analysis/internal";
|
|
801
801
|
|
|
802
802
|
// src/analyzer/jsdoc-constraints.ts
|
|
@@ -806,73 +806,25 @@ import * as ts2 from "typescript";
|
|
|
806
806
|
import * as ts from "typescript";
|
|
807
807
|
import {
|
|
808
808
|
checkSyntheticTagApplication,
|
|
809
|
+
choosePreferredPayloadText,
|
|
809
810
|
extractPathTarget as extractSharedPathTarget,
|
|
810
811
|
getTagDefinition,
|
|
811
812
|
hasTypeSemanticCapability,
|
|
812
813
|
normalizeFormSpecTagName,
|
|
813
814
|
parseConstraintTagValue,
|
|
814
815
|
parseDefaultValueTagValue,
|
|
816
|
+
parseTagSyntax,
|
|
817
|
+
parseUnifiedComment,
|
|
815
818
|
resolveDeclarationPlacement,
|
|
816
819
|
resolvePathTargetType,
|
|
817
|
-
|
|
818
|
-
parseCommentBlock,
|
|
819
|
-
parseTagSyntax
|
|
820
|
+
TAGS_REQUIRING_RAW_TEXT
|
|
820
821
|
} from "@formspec/analysis/internal";
|
|
821
|
-
import {
|
|
822
|
-
TSDocParser,
|
|
823
|
-
TSDocConfiguration,
|
|
824
|
-
TSDocTagDefinition,
|
|
825
|
-
TSDocTagSyntaxKind,
|
|
826
|
-
DocExcerpt,
|
|
827
|
-
DocPlainText,
|
|
828
|
-
DocSoftBreak,
|
|
829
|
-
TextRange
|
|
830
|
-
} from "@microsoft/tsdoc";
|
|
831
822
|
import {
|
|
832
823
|
BUILTIN_CONSTRAINT_DEFINITIONS,
|
|
833
824
|
normalizeConstraintTagName,
|
|
834
825
|
isBuiltinConstraintName
|
|
835
826
|
} from "@formspec/core/internals";
|
|
836
827
|
import "@formspec/core/internals";
|
|
837
|
-
var TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
|
|
838
|
-
function createFormSpecTSDocConfig(extensionTagNames = []) {
|
|
839
|
-
const config = new TSDocConfiguration();
|
|
840
|
-
for (const tagName of Object.keys(BUILTIN_CONSTRAINT_DEFINITIONS)) {
|
|
841
|
-
config.addTagDefinition(
|
|
842
|
-
new TSDocTagDefinition({
|
|
843
|
-
tagName: "@" + tagName,
|
|
844
|
-
syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
|
845
|
-
allowMultiple: true
|
|
846
|
-
})
|
|
847
|
-
);
|
|
848
|
-
}
|
|
849
|
-
for (const tagName of ["apiName", "displayName", "format", "placeholder"]) {
|
|
850
|
-
config.addTagDefinition(
|
|
851
|
-
new TSDocTagDefinition({
|
|
852
|
-
tagName: "@" + tagName,
|
|
853
|
-
syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
|
854
|
-
allowMultiple: true
|
|
855
|
-
})
|
|
856
|
-
);
|
|
857
|
-
}
|
|
858
|
-
for (const tagName of extensionTagNames) {
|
|
859
|
-
config.addTagDefinition(
|
|
860
|
-
new TSDocTagDefinition({
|
|
861
|
-
tagName: "@" + tagName,
|
|
862
|
-
syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
|
863
|
-
allowMultiple: true
|
|
864
|
-
})
|
|
865
|
-
);
|
|
866
|
-
}
|
|
867
|
-
return config;
|
|
868
|
-
}
|
|
869
|
-
function sharedCommentSyntaxOptions(options, offset) {
|
|
870
|
-
const extensions = options?.extensionRegistry?.extensions;
|
|
871
|
-
return {
|
|
872
|
-
...offset !== void 0 ? { offset } : {},
|
|
873
|
-
...extensions !== void 0 ? { extensions } : {}
|
|
874
|
-
};
|
|
875
|
-
}
|
|
876
828
|
function sharedTagValueOptions(options) {
|
|
877
829
|
return {
|
|
878
830
|
...options?.extensionRegistry !== void 0 ? { registry: options.extensionRegistry } : {},
|
|
@@ -972,6 +924,30 @@ function pushUniqueCompilerDiagnostics(target, additions) {
|
|
|
972
924
|
target.push(diagnostic);
|
|
973
925
|
}
|
|
974
926
|
}
|
|
927
|
+
function processConstraintTag(tagName, text, parsedTag, provenance, node, sourceFile, supportingDeclarations, options, constraints, diagnostics) {
|
|
928
|
+
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
929
|
+
node,
|
|
930
|
+
sourceFile,
|
|
931
|
+
tagName,
|
|
932
|
+
parsedTag,
|
|
933
|
+
provenance,
|
|
934
|
+
supportingDeclarations,
|
|
935
|
+
options
|
|
936
|
+
);
|
|
937
|
+
if (compilerDiagnostics.length > 0) {
|
|
938
|
+
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
const constraintNode = parseConstraintTagValue(
|
|
942
|
+
tagName,
|
|
943
|
+
text,
|
|
944
|
+
provenance,
|
|
945
|
+
sharedTagValueOptions(options)
|
|
946
|
+
);
|
|
947
|
+
if (constraintNode) {
|
|
948
|
+
constraints.push(constraintNode);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
975
951
|
function renderSyntheticArgumentExpression(valueKind, argumentText) {
|
|
976
952
|
const trimmed = argumentText.trim();
|
|
977
953
|
if (trimmed === "") {
|
|
@@ -1257,10 +1233,9 @@ function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, par
|
|
|
1257
1233
|
)
|
|
1258
1234
|
];
|
|
1259
1235
|
}
|
|
1260
|
-
var parserCache = /* @__PURE__ */ new Map();
|
|
1261
1236
|
var parseResultCache = /* @__PURE__ */ new Map();
|
|
1262
|
-
function
|
|
1263
|
-
|
|
1237
|
+
function getExtensionTagNames(options) {
|
|
1238
|
+
return [
|
|
1264
1239
|
...options?.extensionRegistry?.extensions.flatMap(
|
|
1265
1240
|
(extension) => (extension.constraintTags ?? []).map((tag) => normalizeFormSpecTagName(tag.tagName))
|
|
1266
1241
|
) ?? [],
|
|
@@ -1268,14 +1243,6 @@ function getParser(options) {
|
|
|
1268
1243
|
(extension) => (extension.metadataSlots ?? []).map((slot) => normalizeFormSpecTagName(slot.tagName))
|
|
1269
1244
|
) ?? []
|
|
1270
1245
|
].sort();
|
|
1271
|
-
const cacheKey = extensionTagNames.join("|");
|
|
1272
|
-
const existing = parserCache.get(cacheKey);
|
|
1273
|
-
if (existing) {
|
|
1274
|
-
return existing;
|
|
1275
|
-
}
|
|
1276
|
-
const parser = new TSDocParser(createFormSpecTSDocConfig(extensionTagNames));
|
|
1277
|
-
parserCache.set(cacheKey, parser);
|
|
1278
|
-
return parser;
|
|
1279
1246
|
}
|
|
1280
1247
|
function getExtensionRegistryCacheKey(registry) {
|
|
1281
1248
|
if (registry === void 0) {
|
|
@@ -1326,13 +1293,13 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1326
1293
|
let placeholder;
|
|
1327
1294
|
let displayNameProvenance;
|
|
1328
1295
|
let placeholderProvenance;
|
|
1329
|
-
const rawTextTags = [];
|
|
1330
1296
|
const sourceFile = node.getSourceFile();
|
|
1331
1297
|
const sourceText = sourceFile.getFullText();
|
|
1332
1298
|
const extensionTypeNames = getExtensionTypeNames(options?.extensionRegistry);
|
|
1333
1299
|
const supportingDeclarations = buildSupportingDeclarations(sourceFile, extensionTypeNames);
|
|
1334
1300
|
const commentRanges = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
|
|
1335
1301
|
const rawTextFallbacks = collectRawTextFallbacks(node, file);
|
|
1302
|
+
const extensionTagNames = getExtensionTagNames(options);
|
|
1336
1303
|
if (commentRanges) {
|
|
1337
1304
|
for (const range of commentRanges) {
|
|
1338
1305
|
if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
|
|
@@ -1342,38 +1309,18 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1342
1309
|
if (!commentText.startsWith("/**")) {
|
|
1343
1310
|
continue;
|
|
1344
1311
|
}
|
|
1345
|
-
const
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
);
|
|
1354
|
-
let parsedTagCursor = 0;
|
|
1355
|
-
const nextParsedTag = (normalizedTagName) => {
|
|
1356
|
-
while (parsedTagCursor < parsedComment.tags.length) {
|
|
1357
|
-
const candidate = parsedComment.tags[parsedTagCursor];
|
|
1358
|
-
parsedTagCursor += 1;
|
|
1359
|
-
if (candidate?.normalizedTagName === normalizedTagName) {
|
|
1360
|
-
return candidate;
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
return null;
|
|
1364
|
-
};
|
|
1365
|
-
for (const parsedTag of parsedComment.tags) {
|
|
1366
|
-
if (TAGS_REQUIRING_RAW_TEXT.has(parsedTag.normalizedTagName)) {
|
|
1367
|
-
rawTextTags.push({ tag: parsedTag, commentText, commentOffset: range.pos });
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
for (const block of docComment.customBlocks) {
|
|
1371
|
-
const tagName = normalizeConstraintTagName(block.blockTag.tagName.substring(1));
|
|
1372
|
-
const parsedTag = nextParsedTag(tagName);
|
|
1312
|
+
const extensions = options?.extensionRegistry?.extensions;
|
|
1313
|
+
const unified = parseUnifiedComment(commentText, {
|
|
1314
|
+
offset: range.pos,
|
|
1315
|
+
extensionTagNames,
|
|
1316
|
+
...extensions !== void 0 ? { extensions } : {}
|
|
1317
|
+
});
|
|
1318
|
+
for (const tag of unified.tags) {
|
|
1319
|
+
const tagName = tag.normalizedTagName;
|
|
1373
1320
|
if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
|
|
1374
|
-
const text2 =
|
|
1321
|
+
const text2 = tag.resolvedPayloadText;
|
|
1375
1322
|
if (text2 === "") continue;
|
|
1376
|
-
const provenance2 =
|
|
1323
|
+
const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
|
|
1377
1324
|
switch (tagName) {
|
|
1378
1325
|
case "displayName":
|
|
1379
1326
|
if (!isMemberTargetDisplayName(text2) && displayName === void 0) {
|
|
@@ -1398,64 +1345,69 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1398
1345
|
}
|
|
1399
1346
|
continue;
|
|
1400
1347
|
}
|
|
1401
|
-
if (TAGS_REQUIRING_RAW_TEXT.has(tagName))
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1348
|
+
if (TAGS_REQUIRING_RAW_TEXT.has(tagName)) {
|
|
1349
|
+
const fallback = rawTextFallbacks.get(tagName)?.shift();
|
|
1350
|
+
const text2 = choosePreferredPayloadText(tag.resolvedPayloadText, fallback?.text ?? "");
|
|
1351
|
+
if (text2 === "") continue;
|
|
1352
|
+
const provenance2 = provenanceForParsedTag(tag, sourceFile, file);
|
|
1353
|
+
if (tagName === "defaultValue") {
|
|
1354
|
+
annotations.push(parseDefaultValueTagValue(text2, provenance2));
|
|
1355
|
+
continue;
|
|
1356
|
+
}
|
|
1357
|
+
processConstraintTag(
|
|
1358
|
+
tagName,
|
|
1359
|
+
text2,
|
|
1360
|
+
tag,
|
|
1361
|
+
provenance2,
|
|
1362
|
+
node,
|
|
1363
|
+
sourceFile,
|
|
1364
|
+
supportingDeclarations,
|
|
1365
|
+
options,
|
|
1366
|
+
constraints,
|
|
1367
|
+
diagnostics
|
|
1368
|
+
);
|
|
1417
1369
|
continue;
|
|
1418
1370
|
}
|
|
1419
|
-
const
|
|
1371
|
+
const text = tag.resolvedPayloadText;
|
|
1372
|
+
const expectedType = isBuiltinConstraintName(tagName) ? BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
|
|
1373
|
+
if (text === "" && expectedType !== "boolean") continue;
|
|
1374
|
+
const provenance = provenanceForParsedTag(tag, sourceFile, file);
|
|
1375
|
+
processConstraintTag(
|
|
1420
1376
|
tagName,
|
|
1421
1377
|
text,
|
|
1378
|
+
tag,
|
|
1422
1379
|
provenance,
|
|
1423
|
-
|
|
1380
|
+
node,
|
|
1381
|
+
sourceFile,
|
|
1382
|
+
supportingDeclarations,
|
|
1383
|
+
options,
|
|
1384
|
+
constraints,
|
|
1385
|
+
diagnostics
|
|
1424
1386
|
);
|
|
1425
|
-
if (constraintNode) {
|
|
1426
|
-
constraints.push(constraintNode);
|
|
1427
|
-
}
|
|
1428
1387
|
}
|
|
1429
|
-
if (
|
|
1430
|
-
const message = extractBlockText(docComment.deprecatedBlock).trim();
|
|
1388
|
+
if (unified.isDeprecated) {
|
|
1431
1389
|
annotations.push({
|
|
1432
1390
|
kind: "annotation",
|
|
1433
1391
|
annotationKind: "deprecated",
|
|
1434
|
-
...
|
|
1392
|
+
...unified.deprecationMessage !== "" && { message: unified.deprecationMessage },
|
|
1435
1393
|
provenance: provenanceForComment(range, sourceFile, file, "deprecated")
|
|
1436
1394
|
});
|
|
1437
1395
|
}
|
|
1438
|
-
{
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
provenance: provenanceForComment(range, sourceFile, file, "summary")
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1396
|
+
if (unified.summaryText !== "") {
|
|
1397
|
+
annotations.push({
|
|
1398
|
+
kind: "annotation",
|
|
1399
|
+
annotationKind: "description",
|
|
1400
|
+
value: unified.summaryText,
|
|
1401
|
+
provenance: provenanceForComment(range, sourceFile, file, "summary")
|
|
1402
|
+
});
|
|
1448
1403
|
}
|
|
1449
|
-
if (
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
provenance: provenanceForComment(range, sourceFile, file, "remarks")
|
|
1457
|
-
});
|
|
1458
|
-
}
|
|
1404
|
+
if (unified.remarksText !== "") {
|
|
1405
|
+
annotations.push({
|
|
1406
|
+
kind: "annotation",
|
|
1407
|
+
annotationKind: "remarks",
|
|
1408
|
+
value: unified.remarksText,
|
|
1409
|
+
provenance: provenanceForComment(range, sourceFile, file, "remarks")
|
|
1410
|
+
});
|
|
1459
1411
|
}
|
|
1460
1412
|
}
|
|
1461
1413
|
}
|
|
@@ -1475,77 +1427,27 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1475
1427
|
provenance: placeholderProvenance
|
|
1476
1428
|
});
|
|
1477
1429
|
}
|
|
1478
|
-
if (rawTextTags.length > 0) {
|
|
1479
|
-
for (const rawTextTag of rawTextTags) {
|
|
1480
|
-
const fallbackQueue = rawTextFallbacks.get(rawTextTag.tag.normalizedTagName);
|
|
1481
|
-
const fallback = fallbackQueue?.shift();
|
|
1482
|
-
const text = choosePreferredPayloadText(
|
|
1483
|
-
getSharedPayloadText(rawTextTag.tag, rawTextTag.commentText, rawTextTag.commentOffset),
|
|
1484
|
-
fallback?.text ?? ""
|
|
1485
|
-
);
|
|
1486
|
-
if (text === "") continue;
|
|
1487
|
-
const provenance = provenanceForParsedTag(rawTextTag.tag, sourceFile, file);
|
|
1488
|
-
if (rawTextTag.tag.normalizedTagName === "defaultValue") {
|
|
1489
|
-
const defaultValueNode = parseDefaultValueTagValue(text, provenance);
|
|
1490
|
-
annotations.push(defaultValueNode);
|
|
1491
|
-
continue;
|
|
1492
|
-
}
|
|
1493
|
-
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
1494
|
-
node,
|
|
1495
|
-
sourceFile,
|
|
1496
|
-
rawTextTag.tag.normalizedTagName,
|
|
1497
|
-
rawTextTag.tag,
|
|
1498
|
-
provenance,
|
|
1499
|
-
supportingDeclarations,
|
|
1500
|
-
options
|
|
1501
|
-
);
|
|
1502
|
-
if (compilerDiagnostics.length > 0) {
|
|
1503
|
-
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
1504
|
-
continue;
|
|
1505
|
-
}
|
|
1506
|
-
const constraintNode = parseConstraintTagValue(
|
|
1507
|
-
rawTextTag.tag.normalizedTagName,
|
|
1508
|
-
text,
|
|
1509
|
-
provenance,
|
|
1510
|
-
sharedTagValueOptions(options)
|
|
1511
|
-
);
|
|
1512
|
-
if (constraintNode) {
|
|
1513
|
-
constraints.push(constraintNode);
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
1430
|
for (const [tagName, fallbacks] of rawTextFallbacks) {
|
|
1518
1431
|
for (const fallback of fallbacks) {
|
|
1519
1432
|
const text = fallback.text.trim();
|
|
1520
1433
|
if (text === "") continue;
|
|
1521
1434
|
const provenance = fallback.provenance;
|
|
1522
1435
|
if (tagName === "defaultValue") {
|
|
1523
|
-
|
|
1524
|
-
annotations.push(defaultValueNode);
|
|
1436
|
+
annotations.push(parseDefaultValueTagValue(text, provenance));
|
|
1525
1437
|
continue;
|
|
1526
1438
|
}
|
|
1527
|
-
|
|
1528
|
-
node,
|
|
1529
|
-
sourceFile,
|
|
1439
|
+
processConstraintTag(
|
|
1530
1440
|
tagName,
|
|
1441
|
+
text,
|
|
1531
1442
|
null,
|
|
1532
1443
|
provenance,
|
|
1444
|
+
node,
|
|
1445
|
+
sourceFile,
|
|
1533
1446
|
supportingDeclarations,
|
|
1534
|
-
options
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
pushUniqueCompilerDiagnostics(diagnostics, compilerDiagnostics);
|
|
1538
|
-
continue;
|
|
1539
|
-
}
|
|
1540
|
-
const constraintNode = parseConstraintTagValue(
|
|
1541
|
-
tagName,
|
|
1542
|
-
text,
|
|
1543
|
-
provenance,
|
|
1544
|
-
sharedTagValueOptions(options)
|
|
1447
|
+
options,
|
|
1448
|
+
constraints,
|
|
1449
|
+
diagnostics
|
|
1545
1450
|
);
|
|
1546
|
-
if (constraintNode) {
|
|
1547
|
-
constraints.push(constraintNode);
|
|
1548
|
-
}
|
|
1549
1451
|
}
|
|
1550
1452
|
}
|
|
1551
1453
|
const result = { constraints, annotations, diagnostics };
|
|
@@ -1563,8 +1465,8 @@ function extractDisplayNameMetadata(node) {
|
|
|
1563
1465
|
if (range.kind !== ts.SyntaxKind.MultiLineCommentTrivia) continue;
|
|
1564
1466
|
const commentText = sourceText.substring(range.pos, range.end);
|
|
1565
1467
|
if (!commentText.startsWith("/**")) continue;
|
|
1566
|
-
const
|
|
1567
|
-
for (const tag of
|
|
1468
|
+
const unified = parseUnifiedComment(commentText);
|
|
1469
|
+
for (const tag of unified.tags) {
|
|
1568
1470
|
if (tag.normalizedTagName !== "displayName") {
|
|
1569
1471
|
continue;
|
|
1570
1472
|
}
|
|
@@ -1583,51 +1485,6 @@ function extractDisplayNameMetadata(node) {
|
|
|
1583
1485
|
memberDisplayNames
|
|
1584
1486
|
};
|
|
1585
1487
|
}
|
|
1586
|
-
function extractBlockText(block) {
|
|
1587
|
-
return extractPlainText(block.content);
|
|
1588
|
-
}
|
|
1589
|
-
function extractPlainText(node) {
|
|
1590
|
-
let result = "";
|
|
1591
|
-
if (node instanceof DocExcerpt) {
|
|
1592
|
-
return node.content.toString();
|
|
1593
|
-
}
|
|
1594
|
-
if (node instanceof DocPlainText) {
|
|
1595
|
-
return node.text;
|
|
1596
|
-
}
|
|
1597
|
-
if (node instanceof DocSoftBreak) {
|
|
1598
|
-
return " ";
|
|
1599
|
-
}
|
|
1600
|
-
if (typeof node.getChildNodes === "function") {
|
|
1601
|
-
for (const child of node.getChildNodes()) {
|
|
1602
|
-
result += extractPlainText(child);
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
return result;
|
|
1606
|
-
}
|
|
1607
|
-
function choosePreferredPayloadText(primary, fallback) {
|
|
1608
|
-
const preferred = primary.trim();
|
|
1609
|
-
const alternate = fallback.trim();
|
|
1610
|
-
if (preferred === "") return alternate;
|
|
1611
|
-
if (alternate === "") return preferred;
|
|
1612
|
-
if (alternate.includes("\n")) return alternate;
|
|
1613
|
-
if (alternate.length > preferred.length && alternate.startsWith(preferred)) {
|
|
1614
|
-
return alternate;
|
|
1615
|
-
}
|
|
1616
|
-
return preferred;
|
|
1617
|
-
}
|
|
1618
|
-
function getSharedPayloadText(tag, commentText, commentOffset) {
|
|
1619
|
-
if (tag.payloadSpan === null) {
|
|
1620
|
-
return "";
|
|
1621
|
-
}
|
|
1622
|
-
return sliceCommentSpan(commentText, tag.payloadSpan, {
|
|
1623
|
-
offset: commentOffset
|
|
1624
|
-
}).trim();
|
|
1625
|
-
}
|
|
1626
|
-
function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
|
|
1627
|
-
const sharedText = tag === null ? "" : getSharedPayloadText(tag, commentText, commentOffset);
|
|
1628
|
-
const blockText = extractBlockText(block).replace(/\s+/g, " ").trim();
|
|
1629
|
-
return choosePreferredPayloadText(sharedText, blockText);
|
|
1630
|
-
}
|
|
1631
1488
|
function collectRawTextFallbacks(node, file) {
|
|
1632
1489
|
const fallbacks = /* @__PURE__ */ new Map();
|
|
1633
1490
|
for (const tag of ts.getJSDocTags(node)) {
|
|
@@ -1741,6 +1598,31 @@ function isObjectType(type) {
|
|
|
1741
1598
|
function isIntersectionType(type) {
|
|
1742
1599
|
return !!(type.flags & ts3.TypeFlags.Intersection);
|
|
1743
1600
|
}
|
|
1601
|
+
function isIntegerBrandedType(type) {
|
|
1602
|
+
if (!type.isIntersection()) {
|
|
1603
|
+
return false;
|
|
1604
|
+
}
|
|
1605
|
+
const hasNumberBase = type.types.some(
|
|
1606
|
+
(member) => !!(member.flags & ts3.TypeFlags.Number)
|
|
1607
|
+
);
|
|
1608
|
+
if (!hasNumberBase) {
|
|
1609
|
+
return false;
|
|
1610
|
+
}
|
|
1611
|
+
return type.getProperties().some((prop) => {
|
|
1612
|
+
const declaration = prop.valueDeclaration ?? prop.declarations?.[0];
|
|
1613
|
+
if (declaration === void 0) {
|
|
1614
|
+
return false;
|
|
1615
|
+
}
|
|
1616
|
+
if (!ts3.isPropertySignature(declaration) && !ts3.isPropertyDeclaration(declaration)) {
|
|
1617
|
+
return false;
|
|
1618
|
+
}
|
|
1619
|
+
const name = declaration.name;
|
|
1620
|
+
if (!ts3.isComputedPropertyName(name)) {
|
|
1621
|
+
return false;
|
|
1622
|
+
}
|
|
1623
|
+
return ts3.isIdentifier(name.expression) && name.expression.text === "__integerBrand";
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1744
1626
|
function isResolvableObjectLikeAliasTypeNode(typeNode) {
|
|
1745
1627
|
if (ts3.isParenthesizedTypeNode(typeNode)) {
|
|
1746
1628
|
return isResolvableObjectLikeAliasTypeNode(typeNode.type);
|
|
@@ -2125,7 +2007,7 @@ function getLeadingParsedTags(node) {
|
|
|
2125
2007
|
if (!commentText.startsWith("/**")) {
|
|
2126
2008
|
continue;
|
|
2127
2009
|
}
|
|
2128
|
-
parsedTags.push(...
|
|
2010
|
+
parsedTags.push(...parseCommentBlock(commentText, { offset: range.pos }).tags);
|
|
2129
2011
|
}
|
|
2130
2012
|
return parsedTags;
|
|
2131
2013
|
}
|
|
@@ -2866,6 +2748,9 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
|
|
|
2866
2748
|
if (primitiveAlias) {
|
|
2867
2749
|
return primitiveAlias;
|
|
2868
2750
|
}
|
|
2751
|
+
if (isIntegerBrandedType(type)) {
|
|
2752
|
+
return { kind: "primitive", primitiveKind: "integer" };
|
|
2753
|
+
}
|
|
2869
2754
|
if (type.flags & ts3.TypeFlags.String) {
|
|
2870
2755
|
return { kind: "primitive", primitiveKind: "string" };
|
|
2871
2756
|
}
|
|
@@ -2968,7 +2853,7 @@ function resolveTypeNode(type, checker, file, typeRegistry, visiting, sourceNode
|
|
|
2968
2853
|
return { kind: "primitive", primitiveKind: "string" };
|
|
2969
2854
|
}
|
|
2970
2855
|
function tryResolveNamedPrimitiveAlias(type, checker, file, typeRegistry, visiting, sourceNode, metadataPolicy = createAnalyzerMetadataPolicy(void 0), extensionRegistry, diagnostics) {
|
|
2971
|
-
if (!(type.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null))) {
|
|
2856
|
+
if (!(type.flags & (ts3.TypeFlags.String | ts3.TypeFlags.Number | ts3.TypeFlags.BigInt | ts3.TypeFlags.BigIntLiteral | ts3.TypeFlags.Boolean | ts3.TypeFlags.Null)) && !isIntegerBrandedType(type)) {
|
|
2972
2857
|
return null;
|
|
2973
2858
|
}
|
|
2974
2859
|
const aliasDecl = type.aliasSymbol?.declarations?.find(ts3.isTypeAliasDeclaration) ?? getReferencedTypeAliasDeclaration(sourceNode, checker);
|
|
@@ -3054,6 +2939,9 @@ function resolveAliasedPrimitiveTarget(type, checker, file, typeRegistry, visiti
|
|
|
3054
2939
|
visitedAliases
|
|
3055
2940
|
);
|
|
3056
2941
|
}
|
|
2942
|
+
if (isIntegerBrandedType(type)) {
|
|
2943
|
+
return { kind: "primitive", primitiveKind: "integer" };
|
|
2944
|
+
}
|
|
3057
2945
|
if (type.flags & ts3.TypeFlags.String) {
|
|
3058
2946
|
return { kind: "primitive", primitiveKind: "string" };
|
|
3059
2947
|
}
|
|
@@ -3277,7 +3165,7 @@ function typeNodeContainsReference(type, targetName) {
|
|
|
3277
3165
|
}
|
|
3278
3166
|
}
|
|
3279
3167
|
function shouldEmitResolvedObjectProperty(property, declaration) {
|
|
3280
|
-
if (property.name.startsWith("__
|
|
3168
|
+
if (property.name.startsWith("__")) {
|
|
3281
3169
|
return false;
|
|
3282
3170
|
}
|
|
3283
3171
|
if (declaration !== void 0 && "name" in declaration && declaration.name !== void 0) {
|
|
@@ -4833,7 +4721,7 @@ function generateCustomType(type, ctx) {
|
|
|
4833
4721
|
}
|
|
4834
4722
|
return registration.toJsonSchema(type.payload, ctx.vendorPrefix);
|
|
4835
4723
|
}
|
|
4836
|
-
var
|
|
4724
|
+
var VOCABULARY_MODE_BLOCKED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
4837
4725
|
"$schema",
|
|
4838
4726
|
"$ref",
|
|
4839
4727
|
"$defs",
|
|
@@ -4904,7 +4792,7 @@ function applyCustomConstraint(schema, constraint, ctx) {
|
|
|
4904
4792
|
if (registration.emitsVocabularyKeywords) {
|
|
4905
4793
|
const target = schema;
|
|
4906
4794
|
for (const [key, value] of Object.entries(extensionSchema)) {
|
|
4907
|
-
if (
|
|
4795
|
+
if (VOCABULARY_MODE_BLOCKED_KEYWORDS.has(key)) {
|
|
4908
4796
|
throw new Error(
|
|
4909
4797
|
`Custom constraint "${constraint.constraintId}" with emitsVocabularyKeywords must not overwrite standard JSON Schema keyword "${key}"`
|
|
4910
4798
|
);
|
|
@@ -4948,6 +4836,150 @@ function assignVendorPrefixedExtensionKeywords(schema, extensionSchema, vendorPr
|
|
|
4948
4836
|
}
|
|
4949
4837
|
}
|
|
4950
4838
|
|
|
4839
|
+
// src/extensions/registry.ts
|
|
4840
|
+
import {
|
|
4841
|
+
BUILTIN_CONSTRAINT_DEFINITIONS as BUILTIN_CONSTRAINT_DEFINITIONS2,
|
|
4842
|
+
normalizeConstraintTagName as normalizeConstraintTagName2
|
|
4843
|
+
} from "@formspec/core/internals";
|
|
4844
|
+
import {
|
|
4845
|
+
getTagDefinition as getTagDefinition2,
|
|
4846
|
+
normalizeFormSpecTagName as normalizeFormSpecTagName2
|
|
4847
|
+
} from "@formspec/analysis/internal";
|
|
4848
|
+
var BUILTIN_METADATA_TAGS = /* @__PURE__ */ new Set(["apiName", "displayName"]);
|
|
4849
|
+
function buildConstraintTagSources(extensions) {
|
|
4850
|
+
return extensions.map((extension) => ({
|
|
4851
|
+
extensionId: extension.extensionId,
|
|
4852
|
+
...extension.constraintTags !== void 0 ? {
|
|
4853
|
+
constraintTags: extension.constraintTags.map((tag) => ({
|
|
4854
|
+
tagName: normalizeFormSpecTagName2(tag.tagName)
|
|
4855
|
+
}))
|
|
4856
|
+
} : {}
|
|
4857
|
+
}));
|
|
4858
|
+
}
|
|
4859
|
+
function createExtensionRegistry(extensions) {
|
|
4860
|
+
const reservedTagSources = buildConstraintTagSources(extensions);
|
|
4861
|
+
const typeMap = /* @__PURE__ */ new Map();
|
|
4862
|
+
const typeNameMap = /* @__PURE__ */ new Map();
|
|
4863
|
+
const constraintMap = /* @__PURE__ */ new Map();
|
|
4864
|
+
const constraintTagMap = /* @__PURE__ */ new Map();
|
|
4865
|
+
const builtinBroadeningMap = /* @__PURE__ */ new Map();
|
|
4866
|
+
const annotationMap = /* @__PURE__ */ new Map();
|
|
4867
|
+
const metadataSlotMap = /* @__PURE__ */ new Map();
|
|
4868
|
+
const metadataTagMap = /* @__PURE__ */ new Map();
|
|
4869
|
+
for (const ext of extensions) {
|
|
4870
|
+
if (ext.types !== void 0) {
|
|
4871
|
+
for (const type of ext.types) {
|
|
4872
|
+
const qualifiedId = `${ext.extensionId}/${type.typeName}`;
|
|
4873
|
+
if (typeMap.has(qualifiedId)) {
|
|
4874
|
+
throw new Error(`Duplicate custom type ID: "${qualifiedId}"`);
|
|
4875
|
+
}
|
|
4876
|
+
typeMap.set(qualifiedId, type);
|
|
4877
|
+
for (const sourceTypeName of type.tsTypeNames ?? [type.typeName]) {
|
|
4878
|
+
if (typeNameMap.has(sourceTypeName)) {
|
|
4879
|
+
throw new Error(`Duplicate custom type source name: "${sourceTypeName}"`);
|
|
4880
|
+
}
|
|
4881
|
+
typeNameMap.set(sourceTypeName, {
|
|
4882
|
+
extensionId: ext.extensionId,
|
|
4883
|
+
registration: type
|
|
4884
|
+
});
|
|
4885
|
+
}
|
|
4886
|
+
if (type.builtinConstraintBroadenings !== void 0) {
|
|
4887
|
+
for (const broadening of type.builtinConstraintBroadenings) {
|
|
4888
|
+
const key = `${qualifiedId}:${broadening.tagName}`;
|
|
4889
|
+
if (builtinBroadeningMap.has(key)) {
|
|
4890
|
+
throw new Error(`Duplicate built-in constraint broadening: "${key}"`);
|
|
4891
|
+
}
|
|
4892
|
+
builtinBroadeningMap.set(key, {
|
|
4893
|
+
extensionId: ext.extensionId,
|
|
4894
|
+
registration: broadening
|
|
4895
|
+
});
|
|
4896
|
+
}
|
|
4897
|
+
}
|
|
4898
|
+
}
|
|
4899
|
+
}
|
|
4900
|
+
if (ext.constraints !== void 0) {
|
|
4901
|
+
for (const constraint of ext.constraints) {
|
|
4902
|
+
const qualifiedId = `${ext.extensionId}/${constraint.constraintName}`;
|
|
4903
|
+
if (constraintMap.has(qualifiedId)) {
|
|
4904
|
+
throw new Error(`Duplicate custom constraint ID: "${qualifiedId}"`);
|
|
4905
|
+
}
|
|
4906
|
+
constraintMap.set(qualifiedId, constraint);
|
|
4907
|
+
}
|
|
4908
|
+
}
|
|
4909
|
+
if (ext.constraintTags !== void 0) {
|
|
4910
|
+
for (const tag of ext.constraintTags) {
|
|
4911
|
+
const canonicalTagName = normalizeFormSpecTagName2(tag.tagName);
|
|
4912
|
+
if (constraintTagMap.has(canonicalTagName)) {
|
|
4913
|
+
throw new Error(`Duplicate custom constraint tag: "@${canonicalTagName}"`);
|
|
4914
|
+
}
|
|
4915
|
+
constraintTagMap.set(canonicalTagName, {
|
|
4916
|
+
extensionId: ext.extensionId,
|
|
4917
|
+
registration: tag
|
|
4918
|
+
});
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4921
|
+
if (ext.annotations !== void 0) {
|
|
4922
|
+
for (const annotation of ext.annotations) {
|
|
4923
|
+
const qualifiedId = `${ext.extensionId}/${annotation.annotationName}`;
|
|
4924
|
+
if (annotationMap.has(qualifiedId)) {
|
|
4925
|
+
throw new Error(`Duplicate custom annotation ID: "${qualifiedId}"`);
|
|
4926
|
+
}
|
|
4927
|
+
annotationMap.set(qualifiedId, annotation);
|
|
4928
|
+
}
|
|
4929
|
+
}
|
|
4930
|
+
if (ext.metadataSlots !== void 0) {
|
|
4931
|
+
for (const slot of ext.metadataSlots) {
|
|
4932
|
+
if (metadataSlotMap.has(slot.slotId)) {
|
|
4933
|
+
throw new Error(`Duplicate metadata slot ID: "${slot.slotId}"`);
|
|
4934
|
+
}
|
|
4935
|
+
metadataSlotMap.set(slot.slotId, true);
|
|
4936
|
+
const canonicalTagName = normalizeFormSpecTagName2(slot.tagName);
|
|
4937
|
+
if (slot.allowBare === false && (slot.qualifiers?.length ?? 0) === 0) {
|
|
4938
|
+
throw new Error(
|
|
4939
|
+
`Metadata tag "@${canonicalTagName}" must allow bare usage or declare at least one qualifier.`
|
|
4940
|
+
);
|
|
4941
|
+
}
|
|
4942
|
+
if (metadataTagMap.has(canonicalTagName)) {
|
|
4943
|
+
throw new Error(`Duplicate metadata tag: "@${canonicalTagName}"`);
|
|
4944
|
+
}
|
|
4945
|
+
if (BUILTIN_METADATA_TAGS.has(canonicalTagName)) {
|
|
4946
|
+
throw new Error(
|
|
4947
|
+
`Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
|
|
4948
|
+
);
|
|
4949
|
+
}
|
|
4950
|
+
if (constraintTagMap.has(canonicalTagName)) {
|
|
4951
|
+
throw new Error(
|
|
4952
|
+
`Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${canonicalTagName}".`
|
|
4953
|
+
);
|
|
4954
|
+
}
|
|
4955
|
+
if (Object.hasOwn(BUILTIN_CONSTRAINT_DEFINITIONS2, normalizeConstraintTagName2(canonicalTagName))) {
|
|
4956
|
+
throw new Error(
|
|
4957
|
+
`Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${normalizeConstraintTagName2(canonicalTagName)}".`
|
|
4958
|
+
);
|
|
4959
|
+
}
|
|
4960
|
+
const existingTag = getTagDefinition2(canonicalTagName, reservedTagSources);
|
|
4961
|
+
if (existingTag !== null) {
|
|
4962
|
+
throw BUILTIN_METADATA_TAGS.has(existingTag.canonicalName) ? new Error(
|
|
4963
|
+
`Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
|
|
4964
|
+
) : new Error(
|
|
4965
|
+
`Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${existingTag.canonicalName}".`
|
|
4966
|
+
);
|
|
4967
|
+
}
|
|
4968
|
+
metadataTagMap.set(canonicalTagName, true);
|
|
4969
|
+
}
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
4972
|
+
return {
|
|
4973
|
+
extensions,
|
|
4974
|
+
findType: (typeId) => typeMap.get(typeId),
|
|
4975
|
+
findTypeByName: (typeName) => typeNameMap.get(typeName),
|
|
4976
|
+
findConstraint: (constraintId) => constraintMap.get(constraintId),
|
|
4977
|
+
findConstraintTag: (tagName) => constraintTagMap.get(normalizeFormSpecTagName2(tagName)),
|
|
4978
|
+
findBuiltinConstraintBroadening: (typeId, tagName) => builtinBroadeningMap.get(`${typeId}:${tagName}`),
|
|
4979
|
+
findAnnotation: (annotationId) => annotationMap.get(annotationId)
|
|
4980
|
+
};
|
|
4981
|
+
}
|
|
4982
|
+
|
|
4951
4983
|
// src/ui-schema/schema.ts
|
|
4952
4984
|
import { z } from "zod";
|
|
4953
4985
|
var jsonPointerSchema = z.string();
|
|
@@ -5336,150 +5368,6 @@ function formatLocation(location) {
|
|
|
5336
5368
|
return `${location.file}:${String(location.line)}:${String(location.column)}`;
|
|
5337
5369
|
}
|
|
5338
5370
|
|
|
5339
|
-
// src/extensions/registry.ts
|
|
5340
|
-
import {
|
|
5341
|
-
BUILTIN_CONSTRAINT_DEFINITIONS as BUILTIN_CONSTRAINT_DEFINITIONS2,
|
|
5342
|
-
normalizeConstraintTagName as normalizeConstraintTagName2
|
|
5343
|
-
} from "@formspec/core/internals";
|
|
5344
|
-
import {
|
|
5345
|
-
getTagDefinition as getTagDefinition2,
|
|
5346
|
-
normalizeFormSpecTagName as normalizeFormSpecTagName2
|
|
5347
|
-
} from "@formspec/analysis/internal";
|
|
5348
|
-
var BUILTIN_METADATA_TAGS = /* @__PURE__ */ new Set(["apiName", "displayName"]);
|
|
5349
|
-
function buildConstraintTagSources(extensions) {
|
|
5350
|
-
return extensions.map((extension) => ({
|
|
5351
|
-
extensionId: extension.extensionId,
|
|
5352
|
-
...extension.constraintTags !== void 0 ? {
|
|
5353
|
-
constraintTags: extension.constraintTags.map((tag) => ({
|
|
5354
|
-
tagName: normalizeFormSpecTagName2(tag.tagName)
|
|
5355
|
-
}))
|
|
5356
|
-
} : {}
|
|
5357
|
-
}));
|
|
5358
|
-
}
|
|
5359
|
-
function createExtensionRegistry(extensions) {
|
|
5360
|
-
const reservedTagSources = buildConstraintTagSources(extensions);
|
|
5361
|
-
const typeMap = /* @__PURE__ */ new Map();
|
|
5362
|
-
const typeNameMap = /* @__PURE__ */ new Map();
|
|
5363
|
-
const constraintMap = /* @__PURE__ */ new Map();
|
|
5364
|
-
const constraintTagMap = /* @__PURE__ */ new Map();
|
|
5365
|
-
const builtinBroadeningMap = /* @__PURE__ */ new Map();
|
|
5366
|
-
const annotationMap = /* @__PURE__ */ new Map();
|
|
5367
|
-
const metadataSlotMap = /* @__PURE__ */ new Map();
|
|
5368
|
-
const metadataTagMap = /* @__PURE__ */ new Map();
|
|
5369
|
-
for (const ext of extensions) {
|
|
5370
|
-
if (ext.types !== void 0) {
|
|
5371
|
-
for (const type of ext.types) {
|
|
5372
|
-
const qualifiedId = `${ext.extensionId}/${type.typeName}`;
|
|
5373
|
-
if (typeMap.has(qualifiedId)) {
|
|
5374
|
-
throw new Error(`Duplicate custom type ID: "${qualifiedId}"`);
|
|
5375
|
-
}
|
|
5376
|
-
typeMap.set(qualifiedId, type);
|
|
5377
|
-
for (const sourceTypeName of type.tsTypeNames ?? [type.typeName]) {
|
|
5378
|
-
if (typeNameMap.has(sourceTypeName)) {
|
|
5379
|
-
throw new Error(`Duplicate custom type source name: "${sourceTypeName}"`);
|
|
5380
|
-
}
|
|
5381
|
-
typeNameMap.set(sourceTypeName, {
|
|
5382
|
-
extensionId: ext.extensionId,
|
|
5383
|
-
registration: type
|
|
5384
|
-
});
|
|
5385
|
-
}
|
|
5386
|
-
if (type.builtinConstraintBroadenings !== void 0) {
|
|
5387
|
-
for (const broadening of type.builtinConstraintBroadenings) {
|
|
5388
|
-
const key = `${qualifiedId}:${broadening.tagName}`;
|
|
5389
|
-
if (builtinBroadeningMap.has(key)) {
|
|
5390
|
-
throw new Error(`Duplicate built-in constraint broadening: "${key}"`);
|
|
5391
|
-
}
|
|
5392
|
-
builtinBroadeningMap.set(key, {
|
|
5393
|
-
extensionId: ext.extensionId,
|
|
5394
|
-
registration: broadening
|
|
5395
|
-
});
|
|
5396
|
-
}
|
|
5397
|
-
}
|
|
5398
|
-
}
|
|
5399
|
-
}
|
|
5400
|
-
if (ext.constraints !== void 0) {
|
|
5401
|
-
for (const constraint of ext.constraints) {
|
|
5402
|
-
const qualifiedId = `${ext.extensionId}/${constraint.constraintName}`;
|
|
5403
|
-
if (constraintMap.has(qualifiedId)) {
|
|
5404
|
-
throw new Error(`Duplicate custom constraint ID: "${qualifiedId}"`);
|
|
5405
|
-
}
|
|
5406
|
-
constraintMap.set(qualifiedId, constraint);
|
|
5407
|
-
}
|
|
5408
|
-
}
|
|
5409
|
-
if (ext.constraintTags !== void 0) {
|
|
5410
|
-
for (const tag of ext.constraintTags) {
|
|
5411
|
-
const canonicalTagName = normalizeFormSpecTagName2(tag.tagName);
|
|
5412
|
-
if (constraintTagMap.has(canonicalTagName)) {
|
|
5413
|
-
throw new Error(`Duplicate custom constraint tag: "@${canonicalTagName}"`);
|
|
5414
|
-
}
|
|
5415
|
-
constraintTagMap.set(canonicalTagName, {
|
|
5416
|
-
extensionId: ext.extensionId,
|
|
5417
|
-
registration: tag
|
|
5418
|
-
});
|
|
5419
|
-
}
|
|
5420
|
-
}
|
|
5421
|
-
if (ext.annotations !== void 0) {
|
|
5422
|
-
for (const annotation of ext.annotations) {
|
|
5423
|
-
const qualifiedId = `${ext.extensionId}/${annotation.annotationName}`;
|
|
5424
|
-
if (annotationMap.has(qualifiedId)) {
|
|
5425
|
-
throw new Error(`Duplicate custom annotation ID: "${qualifiedId}"`);
|
|
5426
|
-
}
|
|
5427
|
-
annotationMap.set(qualifiedId, annotation);
|
|
5428
|
-
}
|
|
5429
|
-
}
|
|
5430
|
-
if (ext.metadataSlots !== void 0) {
|
|
5431
|
-
for (const slot of ext.metadataSlots) {
|
|
5432
|
-
if (metadataSlotMap.has(slot.slotId)) {
|
|
5433
|
-
throw new Error(`Duplicate metadata slot ID: "${slot.slotId}"`);
|
|
5434
|
-
}
|
|
5435
|
-
metadataSlotMap.set(slot.slotId, true);
|
|
5436
|
-
const canonicalTagName = normalizeFormSpecTagName2(slot.tagName);
|
|
5437
|
-
if (slot.allowBare === false && (slot.qualifiers?.length ?? 0) === 0) {
|
|
5438
|
-
throw new Error(
|
|
5439
|
-
`Metadata tag "@${canonicalTagName}" must allow bare usage or declare at least one qualifier.`
|
|
5440
|
-
);
|
|
5441
|
-
}
|
|
5442
|
-
if (metadataTagMap.has(canonicalTagName)) {
|
|
5443
|
-
throw new Error(`Duplicate metadata tag: "@${canonicalTagName}"`);
|
|
5444
|
-
}
|
|
5445
|
-
if (BUILTIN_METADATA_TAGS.has(canonicalTagName)) {
|
|
5446
|
-
throw new Error(
|
|
5447
|
-
`Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
|
|
5448
|
-
);
|
|
5449
|
-
}
|
|
5450
|
-
if (constraintTagMap.has(canonicalTagName)) {
|
|
5451
|
-
throw new Error(
|
|
5452
|
-
`Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${canonicalTagName}".`
|
|
5453
|
-
);
|
|
5454
|
-
}
|
|
5455
|
-
if (Object.hasOwn(BUILTIN_CONSTRAINT_DEFINITIONS2, normalizeConstraintTagName2(canonicalTagName))) {
|
|
5456
|
-
throw new Error(
|
|
5457
|
-
`Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${normalizeConstraintTagName2(canonicalTagName)}".`
|
|
5458
|
-
);
|
|
5459
|
-
}
|
|
5460
|
-
const existingTag = getTagDefinition2(canonicalTagName, reservedTagSources);
|
|
5461
|
-
if (existingTag !== null) {
|
|
5462
|
-
throw BUILTIN_METADATA_TAGS.has(existingTag.canonicalName) ? new Error(
|
|
5463
|
-
`Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
|
|
5464
|
-
) : new Error(
|
|
5465
|
-
`Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${existingTag.canonicalName}".`
|
|
5466
|
-
);
|
|
5467
|
-
}
|
|
5468
|
-
metadataTagMap.set(canonicalTagName, true);
|
|
5469
|
-
}
|
|
5470
|
-
}
|
|
5471
|
-
}
|
|
5472
|
-
return {
|
|
5473
|
-
extensions,
|
|
5474
|
-
findType: (typeId) => typeMap.get(typeId),
|
|
5475
|
-
findTypeByName: (typeName) => typeNameMap.get(typeName),
|
|
5476
|
-
findConstraint: (constraintId) => constraintMap.get(constraintId),
|
|
5477
|
-
findConstraintTag: (tagName) => constraintTagMap.get(normalizeFormSpecTagName2(tagName)),
|
|
5478
|
-
findBuiltinConstraintBroadening: (typeId, tagName) => builtinBroadeningMap.get(`${typeId}:${tagName}`),
|
|
5479
|
-
findAnnotation: (annotationId) => annotationMap.get(annotationId)
|
|
5480
|
-
};
|
|
5481
|
-
}
|
|
5482
|
-
|
|
5483
5371
|
// src/generators/method-schema.ts
|
|
5484
5372
|
import { IR_VERSION as IR_VERSION3 } from "@formspec/core/internals";
|
|
5485
5373
|
function typeToJsonSchema(type, checker, options) {
|