@formspec/build 0.1.0-alpha.58 → 0.1.0-alpha.59
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/builtin-brands.d.ts +10 -7
- package/dist/analyzer/builtin-brands.d.ts.map +1 -1
- package/dist/analyzer/class-analyzer.d.ts +29 -0
- package/dist/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/browser.cjs +126 -31
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +129 -32
- package/dist/browser.js.map +1 -1
- package/dist/build-alpha.d.ts +431 -12
- package/dist/build-beta.d.ts +399 -12
- package/dist/build-internal.d.ts +460 -12
- package/dist/build.d.ts +399 -12
- package/dist/cli.cjs +590 -338
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +547 -289
- package/dist/cli.js.map +1 -1
- package/dist/extensions/registry.d.ts +19 -1
- package/dist/extensions/registry.d.ts.map +1 -1
- package/dist/extensions/resolve-custom-type.d.ts.map +1 -1
- package/dist/extensions/ts-type-utils.d.ts +0 -11
- package/dist/extensions/ts-type-utils.d.ts.map +1 -1
- package/dist/generators/class-schema.d.ts.map +1 -1
- package/dist/index.cjs +580 -327
- 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 +546 -287
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +554 -301
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +515 -256
- package/dist/internals.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import * as ts from "typescript";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Re-exports {@link _isIntegerBrandedType} from the shared
|
|
3
|
+
* `@formspec/analysis` implementation.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* The detection logic was extracted to `@formspec/analysis` (Phase 4A of the
|
|
6
|
+
* synthetic-checker retirement) so that both the build consumer
|
|
7
|
+
* (`tsdoc-parser.ts`) and the snapshot consumer (`file-snapshots.ts`) can use
|
|
8
|
+
* the same bypass check.
|
|
9
|
+
*
|
|
10
|
+
* Callers inside `@formspec/build` continue to import from this module — no
|
|
11
|
+
* import-site changes required in `class-analyzer.ts` or `tsdoc-parser.ts`.
|
|
9
12
|
*
|
|
10
13
|
* @internal
|
|
11
14
|
*/
|
|
12
|
-
export
|
|
15
|
+
export { _isIntegerBrandedType } from "@formspec/analysis/internal";
|
|
13
16
|
//# sourceMappingURL=builtin-brands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-brands.d.ts","sourceRoot":"","sources":["../../src/analyzer/builtin-brands.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"builtin-brands.d.ts","sourceRoot":"","sources":["../../src/analyzer/builtin-brands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -85,6 +85,35 @@ interface AnalyzerMetadataPolicy {
|
|
|
85
85
|
readonly discriminator: DiscriminatorResolutionOptions | undefined;
|
|
86
86
|
}
|
|
87
87
|
export declare function createAnalyzerMetadataPolicy(input?: MetadataPolicyInput, discriminator?: DiscriminatorResolutionOptions): AnalyzerMetadataPolicy;
|
|
88
|
+
/**
|
|
89
|
+
* Removes duplicate setup diagnostics from an accumulated array, leaving
|
|
90
|
+
* non-setup diagnostics unchanged.
|
|
91
|
+
*
|
|
92
|
+
* Phase 4 Slice C: when an extension registry has setup failures, each field
|
|
93
|
+
* node in a class/interface calls {@link parseTSDocTags} independently, and
|
|
94
|
+
* each call returns the same setup diagnostic (anchored at the extension
|
|
95
|
+
* registration site). Without deduplication, an N-field declaration would
|
|
96
|
+
* produce N identical setup diagnostics. We deduplicate by `code + message`
|
|
97
|
+
* (`\0`-separated to prevent collisions between a code value that matches a
|
|
98
|
+
* message prefix and an actual message) because all copies of a setup
|
|
99
|
+
* diagnostic share the same `primaryLocation` provenance.
|
|
100
|
+
*
|
|
101
|
+
* Dedup is restricted to {@link DEDUPLICATABLE_DIAGNOSTIC_CODES} so that
|
|
102
|
+
* per-field diagnostics with identical messages but distinct locations are
|
|
103
|
+
* always retained — otherwise the helper would silently drop legitimate
|
|
104
|
+
* errors on sibling fields that happen to share a diagnostic code+message.
|
|
105
|
+
*
|
|
106
|
+
* TODO: root fix — instead of deduplicating after accumulation, inject setup
|
|
107
|
+
* diagnostics ONCE at the class/interface/type-alias entry in
|
|
108
|
+
* `analyzeClassToIR` / `analyzeInterfaceToIR` / `analyzeTypeAliasToIR`,
|
|
109
|
+
* before iterating fields. When `extensionRegistry.setupDiagnostics` is
|
|
110
|
+
* non-empty, emit them once and pass `undefined` as the extension registry to
|
|
111
|
+
* per-field `parseTSDocTags` calls so they perform no setup-diag re-emission.
|
|
112
|
+
* That eliminates the need for this deduplication pass entirely.
|
|
113
|
+
* Tracked in
|
|
114
|
+
* `docs/refactors/phase-4-slice-c-deduplicate-diagnostics-root-fix.md`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function deduplicateDiagnostics(diagnostics: readonly ConstraintSemanticDiagnostic[]): readonly ConstraintSemanticDiagnostic[];
|
|
88
117
|
export declare function analyzeDeclarationRootInfo(declaration: ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration, checker: ts.TypeChecker, file?: string, extensionRegistry?: ExtensionRegistry, metadataPolicy?: MetadataPolicyInput): DeclarationRootInfo;
|
|
89
118
|
/**
|
|
90
119
|
* Analyzes a class declaration and produces canonical IR FieldNodes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-analyzer.d.ts","sourceRoot":"","sources":["../../src/analyzer/class-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAA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2B;IAC3B,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;IAClC,oBAAoB;IACpB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,0DAA0D;IAC1D,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iEAAiE;IACjE,QAAQ,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdoc-parser.d.ts","sourceRoot":"","sources":["../../src/analyzer/tsdoc-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAeL,KAAK,4BAA4B,EAIlC,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,KAAK,UAAU,EACf,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"tsdoc-parser.d.ts","sourceRoot":"","sources":["../../src/analyzer/tsdoc-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAeL,KAAK,4BAA4B,EAIlC,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,KAAK,UAAU,EACf,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAy+BhE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,qEAAqE;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/browser.cjs
CHANGED
|
@@ -932,7 +932,7 @@ function generateJsonSchemaFromIR(ir, options) {
|
|
|
932
932
|
applyConstraints(ctx.defs[schemaName], typeDef.constraints, ctx);
|
|
933
933
|
}
|
|
934
934
|
if (typeDef.annotations && typeDef.annotations.length > 0) {
|
|
935
|
-
applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx);
|
|
935
|
+
applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx, typeDef.type);
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
938
|
const properties = {};
|
|
@@ -1005,7 +1005,7 @@ function generateFieldSchema(field, ctx) {
|
|
|
1005
1005
|
}
|
|
1006
1006
|
}
|
|
1007
1007
|
applyResolvedMetadata(schema, field.metadata);
|
|
1008
|
-
applyAnnotations(schema, rootAnnotations, ctx);
|
|
1008
|
+
applyAnnotations(schema, rootAnnotations, ctx, field.type);
|
|
1009
1009
|
if (itemStringSchema !== void 0) {
|
|
1010
1010
|
applyAnnotations(itemStringSchema, itemAnnotations, ctx);
|
|
1011
1011
|
}
|
|
@@ -1048,32 +1048,36 @@ function applyPathTargetedConstraints(schema, pathConstraints, ctx, typeNode) {
|
|
|
1048
1048
|
return schema;
|
|
1049
1049
|
}
|
|
1050
1050
|
if (schema.$ref) {
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
properties: propertyOverrides,
|
|
1055
|
-
...rest
|
|
1051
|
+
return {
|
|
1052
|
+
...schema,
|
|
1053
|
+
properties: propertyOverrides
|
|
1056
1054
|
};
|
|
1057
|
-
return { allOf: [refPart, overridePart] };
|
|
1058
1055
|
}
|
|
1059
1056
|
if (schema.type === "object" && schema.properties) {
|
|
1060
|
-
const missingOverrides = {};
|
|
1061
1057
|
for (const [target, overrideSchema] of Object.entries(propertyOverrides)) {
|
|
1062
|
-
if (schema.properties
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1058
|
+
if (Object.hasOwn(schema.properties, target)) {
|
|
1059
|
+
const existing = schema.properties[target];
|
|
1060
|
+
if (existing) {
|
|
1061
|
+
mergeSchemaOverride(existing, overrideSchema);
|
|
1062
|
+
continue;
|
|
1063
|
+
}
|
|
1066
1064
|
}
|
|
1065
|
+
Object.defineProperty(schema.properties, target, {
|
|
1066
|
+
value: overrideSchema,
|
|
1067
|
+
writable: true,
|
|
1068
|
+
enumerable: true,
|
|
1069
|
+
configurable: true
|
|
1070
|
+
});
|
|
1067
1071
|
}
|
|
1068
|
-
|
|
1069
|
-
return schema;
|
|
1070
|
-
}
|
|
1071
|
-
return {
|
|
1072
|
-
allOf: [schema, { properties: missingOverrides }]
|
|
1073
|
-
};
|
|
1072
|
+
return schema;
|
|
1074
1073
|
}
|
|
1075
1074
|
if (schema.allOf) {
|
|
1076
|
-
|
|
1075
|
+
const overrideMember = { properties: propertyOverrides };
|
|
1076
|
+
const flattened = tryFlattenAllOfToSiblings(schema, overrideMember);
|
|
1077
|
+
if (flattened !== void 0) {
|
|
1078
|
+
return flattened;
|
|
1079
|
+
}
|
|
1080
|
+
schema.allOf = [...schema.allOf, overrideMember];
|
|
1077
1081
|
return schema;
|
|
1078
1082
|
}
|
|
1079
1083
|
return schema;
|
|
@@ -1186,7 +1190,7 @@ function generatePropertySchema(prop, ctx) {
|
|
|
1186
1190
|
const schema = generateTypeNode(prop.type, ctx);
|
|
1187
1191
|
applyConstraints(schema, prop.constraints, ctx);
|
|
1188
1192
|
applyResolvedMetadata(schema, prop.metadata);
|
|
1189
|
-
applyAnnotations(schema, prop.annotations, ctx);
|
|
1193
|
+
applyAnnotations(schema, prop.annotations, ctx, prop.type);
|
|
1190
1194
|
return schema;
|
|
1191
1195
|
}
|
|
1192
1196
|
function generateUnionType(type, ctx) {
|
|
@@ -1289,13 +1293,20 @@ function buildPropertyOverrides(pathConstraints, typeNode, ctx) {
|
|
|
1289
1293
|
grouped.push(constraint);
|
|
1290
1294
|
byTarget.set(target, grouped);
|
|
1291
1295
|
}
|
|
1292
|
-
const overrides =
|
|
1296
|
+
const overrides = /* @__PURE__ */ Object.create(null);
|
|
1293
1297
|
for (const [target, constraints] of byTarget) {
|
|
1294
|
-
|
|
1298
|
+
const resolvedName = resolveSerializedPropertyName(target, typeNode, ctx);
|
|
1299
|
+
const schema = buildPathOverrideSchema(
|
|
1295
1300
|
constraints.map(stripLeadingPathSegment),
|
|
1296
1301
|
resolveTargetTypeNode(target, typeNode, ctx),
|
|
1297
1302
|
ctx
|
|
1298
1303
|
);
|
|
1304
|
+
Object.defineProperty(overrides, resolvedName, {
|
|
1305
|
+
value: schema,
|
|
1306
|
+
writable: true,
|
|
1307
|
+
enumerable: true,
|
|
1308
|
+
configurable: true
|
|
1309
|
+
});
|
|
1299
1310
|
}
|
|
1300
1311
|
return overrides;
|
|
1301
1312
|
}
|
|
@@ -1322,6 +1333,34 @@ function buildPathOverrideSchema(constraints, typeNode, ctx) {
|
|
|
1322
1333
|
schema.properties = buildPropertyOverrides(nestedConstraints, effectiveType, ctx);
|
|
1323
1334
|
return schema;
|
|
1324
1335
|
}
|
|
1336
|
+
function tryFlattenAllOfToSiblings(schema, overrideMember) {
|
|
1337
|
+
if (schema.allOf?.length !== 1) {
|
|
1338
|
+
return void 0;
|
|
1339
|
+
}
|
|
1340
|
+
const [soleMember] = schema.allOf;
|
|
1341
|
+
if (soleMember === void 0) {
|
|
1342
|
+
return void 0;
|
|
1343
|
+
}
|
|
1344
|
+
const { allOf: _allOf, ...outerRest } = schema;
|
|
1345
|
+
const outerKeys = new Set(Object.keys(outerRest));
|
|
1346
|
+
const memberKeys = new Set(Object.keys(soleMember));
|
|
1347
|
+
const overrideKeys = new Set(Object.keys(overrideMember));
|
|
1348
|
+
for (const key of memberKeys) {
|
|
1349
|
+
if (outerKeys.has(key) || overrideKeys.has(key)) {
|
|
1350
|
+
return void 0;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
for (const key of overrideKeys) {
|
|
1354
|
+
if (outerKeys.has(key)) {
|
|
1355
|
+
return void 0;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
return {
|
|
1359
|
+
...outerRest,
|
|
1360
|
+
...soleMember,
|
|
1361
|
+
...overrideMember
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1325
1364
|
function mergeSchemaOverride(target, override) {
|
|
1326
1365
|
const nullableValueBranch = getNullableUnionValueSchema(target);
|
|
1327
1366
|
if (nullableValueBranch !== void 0) {
|
|
@@ -1329,11 +1368,16 @@ function mergeSchemaOverride(target, override) {
|
|
|
1329
1368
|
return;
|
|
1330
1369
|
}
|
|
1331
1370
|
if (override.properties !== void 0) {
|
|
1332
|
-
const mergedProperties = target.properties ??
|
|
1371
|
+
const mergedProperties = target.properties ?? /* @__PURE__ */ Object.create(null);
|
|
1333
1372
|
for (const [name, propertyOverride] of Object.entries(override.properties)) {
|
|
1334
|
-
const existing = mergedProperties[name];
|
|
1373
|
+
const existing = Object.hasOwn(mergedProperties, name) ? mergedProperties[name] : void 0;
|
|
1335
1374
|
if (existing === void 0) {
|
|
1336
|
-
mergedProperties
|
|
1375
|
+
Object.defineProperty(mergedProperties, name, {
|
|
1376
|
+
value: propertyOverride,
|
|
1377
|
+
writable: true,
|
|
1378
|
+
enumerable: true,
|
|
1379
|
+
configurable: true
|
|
1380
|
+
});
|
|
1337
1381
|
} else {
|
|
1338
1382
|
mergeSchemaOverride(existing, propertyOverride);
|
|
1339
1383
|
}
|
|
@@ -1351,7 +1395,12 @@ function mergeSchemaOverride(target, override) {
|
|
|
1351
1395
|
if (key === "properties" || key === "items") {
|
|
1352
1396
|
continue;
|
|
1353
1397
|
}
|
|
1354
|
-
target
|
|
1398
|
+
Object.defineProperty(target, key, {
|
|
1399
|
+
value,
|
|
1400
|
+
writable: true,
|
|
1401
|
+
enumerable: true,
|
|
1402
|
+
configurable: true
|
|
1403
|
+
});
|
|
1355
1404
|
}
|
|
1356
1405
|
}
|
|
1357
1406
|
function stripLeadingPathSegment(constraint) {
|
|
@@ -1451,7 +1500,7 @@ function applyConstraints(schema, constraints, ctx) {
|
|
|
1451
1500
|
}
|
|
1452
1501
|
}
|
|
1453
1502
|
}
|
|
1454
|
-
function applyAnnotations(schema, annotations, ctx) {
|
|
1503
|
+
function applyAnnotations(schema, annotations, ctx, typeNode) {
|
|
1455
1504
|
for (const annotation of annotations) {
|
|
1456
1505
|
switch (annotation.annotationKind) {
|
|
1457
1506
|
case "displayName":
|
|
@@ -1464,7 +1513,7 @@ function applyAnnotations(schema, annotations, ctx) {
|
|
|
1464
1513
|
schema[`${ctx.vendorPrefix}-remarks`] = annotation.value;
|
|
1465
1514
|
break;
|
|
1466
1515
|
case "defaultValue":
|
|
1467
|
-
schema.default = annotation.value;
|
|
1516
|
+
schema.default = coerceDefaultValue(annotation.value, typeNode, schema, ctx);
|
|
1468
1517
|
break;
|
|
1469
1518
|
case "format":
|
|
1470
1519
|
schema.format = annotation.value;
|
|
@@ -1489,6 +1538,34 @@ function applyAnnotations(schema, annotations, ctx) {
|
|
|
1489
1538
|
}
|
|
1490
1539
|
}
|
|
1491
1540
|
}
|
|
1541
|
+
function coerceDefaultValue(value, typeNode, emittedSchema, ctx) {
|
|
1542
|
+
if (typeNode?.kind !== "custom") {
|
|
1543
|
+
return value;
|
|
1544
|
+
}
|
|
1545
|
+
const registration = ctx.extensionRegistry?.findType(typeNode.typeId);
|
|
1546
|
+
if (registration === void 0) {
|
|
1547
|
+
return value;
|
|
1548
|
+
}
|
|
1549
|
+
if (registration.serializeDefault !== void 0) {
|
|
1550
|
+
return registration.serializeDefault(value, typeNode.payload);
|
|
1551
|
+
}
|
|
1552
|
+
const declaredType = emittedSchema["type"];
|
|
1553
|
+
if (declaredType === "string" && typeof value !== "string") {
|
|
1554
|
+
if (typeof value === "number") {
|
|
1555
|
+
if (!Number.isFinite(value)) {
|
|
1556
|
+
return value;
|
|
1557
|
+
}
|
|
1558
|
+
return String(value);
|
|
1559
|
+
}
|
|
1560
|
+
if (typeof value === "boolean") {
|
|
1561
|
+
return String(value);
|
|
1562
|
+
}
|
|
1563
|
+
if (typeof value === "bigint") {
|
|
1564
|
+
return value.toString();
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
return value;
|
|
1568
|
+
}
|
|
1492
1569
|
function generateCustomType(type, ctx) {
|
|
1493
1570
|
const registration = ctx.extensionRegistry?.findType(type.typeId);
|
|
1494
1571
|
if (registration === void 0) {
|
|
@@ -1922,6 +1999,16 @@ function buildConstraintTagSources(extensions) {
|
|
|
1922
1999
|
constraintTags: extension.constraintTags.map((tag) => ({
|
|
1923
2000
|
tagName: (0, import_internal.normalizeFormSpecTagName)(tag.tagName)
|
|
1924
2001
|
}))
|
|
2002
|
+
} : {},
|
|
2003
|
+
// Include customTypes so _validateExtensionSetup can check tsTypeNames for
|
|
2004
|
+
// unsupported built-in overrides and invalid identifier patterns.
|
|
2005
|
+
...extension.types !== void 0 ? {
|
|
2006
|
+
customTypes: extension.types.map((type) => ({
|
|
2007
|
+
// tsTypeNames: deprecated in favour of symbol-based detection, but
|
|
2008
|
+
// still required for name-based validation in _validateExtensionSetup
|
|
2009
|
+
// until the bridge is fully retired (see §synthetic-checker-retirement §4C).
|
|
2010
|
+
tsTypeNames: type.tsTypeNames ?? [type.typeName]
|
|
2011
|
+
}))
|
|
1925
2012
|
} : {}
|
|
1926
2013
|
}));
|
|
1927
2014
|
}
|
|
@@ -1931,7 +2018,13 @@ function createExtensionRegistry(extensions) {
|
|
|
1931
2018
|
extensionCount: extensions.length,
|
|
1932
2019
|
extensionIds: extensions.map((e) => e.extensionId)
|
|
1933
2020
|
});
|
|
1934
|
-
const
|
|
2021
|
+
const extensionTagSources = buildConstraintTagSources(extensions);
|
|
2022
|
+
const setupDiagnostics = (0, import_internal._validateExtensionSetup)(extensionTagSources);
|
|
2023
|
+
(0, import_internal.logSetupDiagnostics)(registryLog, {
|
|
2024
|
+
diagnosticCount: setupDiagnostics.length,
|
|
2025
|
+
codes: setupDiagnostics.map((d) => d.kind)
|
|
2026
|
+
});
|
|
2027
|
+
const reservedTagSources = extensionTagSources;
|
|
1935
2028
|
let symbolMap = /* @__PURE__ */ new Map();
|
|
1936
2029
|
const typeMap = /* @__PURE__ */ new Map();
|
|
1937
2030
|
const typeNameMap = /* @__PURE__ */ new Map();
|
|
@@ -2068,10 +2161,12 @@ function createExtensionRegistry(extensions) {
|
|
|
2068
2161
|
constraintTagCount: constraintTagMap.size,
|
|
2069
2162
|
broadeningCount: builtinBroadeningMap.size,
|
|
2070
2163
|
annotationCount: annotationMap.size,
|
|
2071
|
-
metadataSlotCount: metadataSlotMap.size
|
|
2164
|
+
metadataSlotCount: metadataSlotMap.size,
|
|
2165
|
+
setupDiagnosticCount: setupDiagnostics.length
|
|
2072
2166
|
});
|
|
2073
2167
|
return {
|
|
2074
2168
|
extensions,
|
|
2169
|
+
setupDiagnostics,
|
|
2075
2170
|
findType: (typeId) => typeMap.get(typeId),
|
|
2076
2171
|
findTypeByName: (typeName) => typeNameMap.get(typeName),
|
|
2077
2172
|
findTypeByBrand: (brand) => brandMap.get(brand),
|