@typespec/html-program-viewer 0.75.0-dev.1 → 0.75.0
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/manifest-WKUvygNB.js +6 -0
- package/dist/react/index.js +49 -22
- package/package.json +3 -3
- package/dist/manifest-BqvjRkpI.js +0 -6
package/dist/react/index.js
CHANGED
|
@@ -28424,40 +28424,51 @@ var ListenerFlow;
|
|
|
28424
28424
|
ListenerFlow[ListenerFlow["NoRecursion"] = 1] = "NoRecursion";
|
|
28425
28425
|
})(ListenerFlow || (ListenerFlow = {}));
|
|
28426
28426
|
|
|
28427
|
-
|
|
28428
|
-
|
|
28429
|
-
|
|
28430
|
-
|
|
28431
|
-
|
|
28432
|
-
|
|
28433
|
-
|
|
28427
|
+
/**
|
|
28428
|
+
* Find the syntax node for a TypeSpec diagnostic target.
|
|
28429
|
+
*
|
|
28430
|
+
* This function extracts the AST node from various types of diagnostic targets:
|
|
28431
|
+
* - For template instance targets: returns the node of the template declaration
|
|
28432
|
+
* - For symbols: returns the first declaration node (or symbol source for using symbols)
|
|
28433
|
+
* - For AST nodes: returns the node itself
|
|
28434
|
+
* - For types: returns the node associated with the type
|
|
28435
|
+
*
|
|
28436
|
+
* @param target The diagnostic target to extract a node from. Can be a template instance,
|
|
28437
|
+
* symbol, AST node, or type.
|
|
28438
|
+
* @returns The AST node associated with the target, or undefined if the target is a type
|
|
28439
|
+
* or symbol that doesn't have an associated node.
|
|
28440
|
+
*/
|
|
28441
|
+
function getNodeForTarget(target) {
|
|
28434
28442
|
if (!("kind" in target) && !("entityKind" in target)) {
|
|
28435
28443
|
// TemplateInstanceTarget
|
|
28436
28444
|
if (!("declarations" in target)) {
|
|
28437
|
-
return
|
|
28445
|
+
return target.node;
|
|
28438
28446
|
}
|
|
28439
28447
|
// symbol
|
|
28440
28448
|
if (target.flags & 8192 /* SymbolFlags.Using */) {
|
|
28441
28449
|
target = target.symbolSource;
|
|
28442
28450
|
}
|
|
28443
|
-
|
|
28444
|
-
return createSyntheticSourceLocation();
|
|
28445
|
-
}
|
|
28446
|
-
return getSourceLocationOfNode(target.declarations[0], options);
|
|
28451
|
+
return target.declarations[0];
|
|
28447
28452
|
}
|
|
28448
28453
|
else if ("kind" in target && typeof target.kind === "number") {
|
|
28449
28454
|
// node
|
|
28450
|
-
return
|
|
28455
|
+
return target;
|
|
28451
28456
|
}
|
|
28452
28457
|
else {
|
|
28453
28458
|
// type
|
|
28454
|
-
|
|
28455
|
-
if (targetNode) {
|
|
28456
|
-
return getSourceLocationOfNode(targetNode, options);
|
|
28457
|
-
}
|
|
28458
|
-
return createSyntheticSourceLocation();
|
|
28459
|
+
return target.node;
|
|
28459
28460
|
}
|
|
28460
28461
|
}
|
|
28462
|
+
function getSourceLocation(target, options = {}) {
|
|
28463
|
+
if (target === NoTarget || target === undefined) {
|
|
28464
|
+
return undefined;
|
|
28465
|
+
}
|
|
28466
|
+
if ("file" in target) {
|
|
28467
|
+
return target;
|
|
28468
|
+
}
|
|
28469
|
+
const node = getNodeForTarget(target);
|
|
28470
|
+
return node ? getSourceLocationOfNode(node, options) : createSyntheticSourceLocation();
|
|
28471
|
+
}
|
|
28461
28472
|
function createSyntheticSourceLocation(loc = "<unknown location>") {
|
|
28462
28473
|
return {
|
|
28463
28474
|
file: createSourceFile("", loc),
|
|
@@ -28557,6 +28568,7 @@ function createJSONSchemaValidator(schema, options = { strict: true }) {
|
|
|
28557
28568
|
const ajv = new ajvExports.Ajv({
|
|
28558
28569
|
strict: options.strict,
|
|
28559
28570
|
coerceTypes: options.coerceTypes,
|
|
28571
|
+
allowUnionTypes: true,
|
|
28560
28572
|
allErrors: true,
|
|
28561
28573
|
});
|
|
28562
28574
|
ajv.addFormat("absolute-path", {
|
|
@@ -29662,6 +29674,11 @@ function getStringValue(type) {
|
|
|
29662
29674
|
}
|
|
29663
29675
|
}
|
|
29664
29676
|
|
|
29677
|
+
const nodeRawTextCache = new WeakMap();
|
|
29678
|
+
function getCachedRawText(node) {
|
|
29679
|
+
return nodeRawTextCache.get(node);
|
|
29680
|
+
}
|
|
29681
|
+
|
|
29665
29682
|
//
|
|
29666
29683
|
// Generated by scripts/regen-nonascii-map.js
|
|
29667
29684
|
// on node v18.16.0 with unicode 15.0.
|
|
@@ -31035,7 +31052,10 @@ function getModelName(model, options) {
|
|
|
31035
31052
|
}
|
|
31036
31053
|
else if (model.node?.templateParameters?.length > 0) {
|
|
31037
31054
|
// template
|
|
31038
|
-
const params = model.node.templateParameters.map((t) =>
|
|
31055
|
+
const params = model.node.templateParameters.map((t) => {
|
|
31056
|
+
const cachedRawText = getCachedRawText(t);
|
|
31057
|
+
return getIdentifierName(t.id.sv, options, cachedRawText);
|
|
31058
|
+
});
|
|
31039
31059
|
return `${modelName}<${params.join(", ")}>`;
|
|
31040
31060
|
}
|
|
31041
31061
|
else {
|
|
@@ -31073,6 +31093,13 @@ function getInterfaceName(iface, options) {
|
|
|
31073
31093
|
.map((x) => getEntityName(x, options))
|
|
31074
31094
|
.join(", ")}>`;
|
|
31075
31095
|
}
|
|
31096
|
+
else if (iface.node && iface.node.templateParameters.length > 0) {
|
|
31097
|
+
const params = iface.node.templateParameters.map((t) => {
|
|
31098
|
+
const cachedRawText = getCachedRawText(t);
|
|
31099
|
+
return getIdentifierName(t.id.sv, options, cachedRawText);
|
|
31100
|
+
});
|
|
31101
|
+
interfaceName += `<${params.join(", ")}>`;
|
|
31102
|
+
}
|
|
31076
31103
|
return `${getNamespacePrefix(iface.namespace, options)}${interfaceName}`;
|
|
31077
31104
|
}
|
|
31078
31105
|
function getOperationName(op, options) {
|
|
@@ -31089,8 +31116,8 @@ function getOperationName(op, options) {
|
|
|
31089
31116
|
return `${prefix}${opName}`;
|
|
31090
31117
|
}
|
|
31091
31118
|
}
|
|
31092
|
-
function getIdentifierName(name, options) {
|
|
31093
|
-
return options?.printable ? printIdentifier(name) : name;
|
|
31119
|
+
function getIdentifierName(name, options, nodeIncludeRawText) {
|
|
31120
|
+
return nodeIncludeRawText ?? (options?.printable ? printIdentifier(name) : name);
|
|
31094
31121
|
}
|
|
31095
31122
|
function getStringTemplateName(type) {
|
|
31096
31123
|
if (type.stringValue) {
|
|
@@ -34357,7 +34384,7 @@ let manifest;
|
|
|
34357
34384
|
try {
|
|
34358
34385
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
34359
34386
|
// @ts-ignore
|
|
34360
|
-
manifest = (await import('../manifest-
|
|
34387
|
+
manifest = (await import('../manifest-WKUvygNB.js')).default;
|
|
34361
34388
|
}
|
|
34362
34389
|
catch {
|
|
34363
34390
|
const name = "../dist/manifest.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/html-program-viewer",
|
|
3
|
-
"version": "0.75.0
|
|
3
|
+
"version": "0.75.0",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec library for emitting an html view of the program.",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"!dist/test/**"
|
|
37
37
|
],
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@typespec/compiler": "^1.
|
|
39
|
+
"@typespec/compiler": "^1.5.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@fluentui/react-components": "~9.70.0",
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"@types/node": "~24.3.0",
|
|
55
55
|
"@types/react": "~18.3.11",
|
|
56
56
|
"@types/react-dom": "~18.3.0",
|
|
57
|
-
"@typespec/compiler": "^1.4.0",
|
|
58
57
|
"@vitejs/plugin-react": "~5.0.2",
|
|
59
58
|
"@vitest/coverage-v8": "^3.1.2",
|
|
60
59
|
"@vitest/ui": "^3.1.2",
|
|
@@ -66,6 +65,7 @@
|
|
|
66
65
|
"vite-plugin-dts": "4.5.4",
|
|
67
66
|
"vite-plugin-node-polyfills": "^0.24.0",
|
|
68
67
|
"vitest": "^3.1.2",
|
|
68
|
+
"@typespec/compiler": "^1.5.0",
|
|
69
69
|
"@typespec/react-components": "^0.57.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|