@typespec/html-program-viewer 0.41.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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/src/common.d.ts +14 -0
- package/dist/src/common.d.ts.map +1 -0
- package/dist/src/common.js +30 -0
- package/dist/src/common.js.map +1 -0
- package/dist/src/constants.d.ts +5 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +5 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/emitter.d.ts +20 -0
- package/dist/src/emitter.d.ts.map +1 -0
- package/dist/src/emitter.js +29 -0
- package/dist/src/emitter.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/inspect.d.ts +2 -0
- package/dist/src/inspect.d.ts.map +1 -0
- package/dist/src/inspect.js +46 -0
- package/dist/src/inspect.js.map +1 -0
- package/dist/src/testing/index.d.ts +3 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +8 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/type-ui-base.d.ts +19 -0
- package/dist/src/type-ui-base.d.ts.map +1 -0
- package/dist/src/type-ui-base.js +22 -0
- package/dist/src/type-ui-base.js.map +1 -0
- package/dist/src/ui.d.ts +13 -0
- package/dist/src/ui.d.ts.map +1 -0
- package/dist/src/ui.js +266 -0
- package/dist/src/ui.js.map +1 -0
- package/dist/src/utils.d.ts +6 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +28 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# TypeSpec Html Program viewer emitter.
|
|
2
|
+
|
|
3
|
+
## See also
|
|
4
|
+
|
|
5
|
+
- [TypeSpec Getting Started](https://github.com/microsoft/typespec#getting-started)
|
|
6
|
+
- [TypeSpec Website](https://microsoft.github.io/typespec)
|
|
7
|
+
- [TypeSpec for the OpenAPI Developer](https://github.com/microsoft/typespec/blob/main/docs/typespec-for-openapi-dev.md)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FunctionComponent, PropsWithChildren, ReactElement } from "react";
|
|
2
|
+
export interface ItemProps {
|
|
3
|
+
title: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
hide?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const Item: FunctionComponent<PropsWithChildren<ItemProps>>;
|
|
8
|
+
export declare const Literal: FunctionComponent<{
|
|
9
|
+
children: any;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const KeyValueSection: FunctionComponent<{
|
|
12
|
+
children: ReactElement | ReactElement[];
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/common.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG3E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAgBD,eAAO,MAAM,IAAI,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAehE,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,CAExD,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC;IAAE,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,CAAA;CAAE,CAe1F,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
|
+
import { Colors } from "./constants.js";
|
|
4
|
+
const ItemStyles = css({
|
|
5
|
+
border: "1px solid #c5c5c5",
|
|
6
|
+
});
|
|
7
|
+
const ItemTitleStyles = css({
|
|
8
|
+
border: "1px solid #c5c5c5",
|
|
9
|
+
backgroundColor: "#dedede",
|
|
10
|
+
padding: "2px 5px",
|
|
11
|
+
});
|
|
12
|
+
const ItemContentStyles = css({
|
|
13
|
+
padding: "1rem",
|
|
14
|
+
});
|
|
15
|
+
export const Item = ({ id, title, hide, children, }) => {
|
|
16
|
+
if (hide) {
|
|
17
|
+
return _jsx("div", {});
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs("div", { css: ItemStyles, id: id, children: [_jsx("div", { css: ItemTitleStyles, children: title }), _jsx("div", { css: ItemContentStyles, children: children })] }));
|
|
20
|
+
};
|
|
21
|
+
export const Literal = ({ children }) => (_jsx("div", { css: { color: "#5da713", display: "inline" }, children: children }));
|
|
22
|
+
export const KeyValueSection = ({ children, }) => {
|
|
23
|
+
return (_jsx("ul", { css: {
|
|
24
|
+
margin: 0,
|
|
25
|
+
padding: "0 0 0 16px",
|
|
26
|
+
borderLeft: `1px dashed ${Colors.indentationGuide}`,
|
|
27
|
+
overflow: "auto",
|
|
28
|
+
}, children: children }));
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC,MAAM,UAAU,GAAG,GAAG,CAAC;IACrB,MAAM,EAAE,mBAAmB;CAC5B,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,GAAG,CAAC;IAC1B,MAAM,EAAE,mBAAmB;IAC3B,eAAe,EAAE,SAAS;IAC1B,OAAO,EAAE,SAAS;CACnB,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,GAAG,CAAC;IAC5B,OAAO,EAAE,MAAM;CAChB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,IAAI,GAAoD,CAAC,EACpE,EAAE,EACF,KAAK,EACL,IAAI,EACJ,QAAQ,GACT,EAAE,EAAE;IACH,IAAI,IAAI,EAAE;QACR,OAAO,eAAW,CAAC;KACpB;IACD,OAAO,CACL,eAAK,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,aAC1B,cAAK,GAAG,EAAE,eAAe,YAAG,KAAK,GAAO,EACxC,cAAK,GAAG,EAAE,iBAAiB,YAAG,QAAQ,GAAO,IACzC,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAyC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC7E,cAAK,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAG,QAAQ,GAAO,CACpE,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAmE,CAAC,EAC9F,QAAQ,GACT,EAAE,EAAE;IACH,OAAO,CACL,aACE,GAAG,EAAE;YACH,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,YAAY;YACrB,UAAU,EAAE,cAAc,MAAM,CAAC,gBAAgB,EAAE;YACnD,QAAQ,EAAE,MAAM;SACjB,YAEA,QAAQ,GACN,CACN,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;CAGlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,QAAQ,EAAE,SAAS;IACnB,gBAAgB,EAAE,MAAM;CACzB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EmitContext } from "@typespec/compiler";
|
|
2
|
+
import { JSONSchemaType } from "@typespec/compiler";
|
|
3
|
+
export interface HtmlProgramViewerOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Override compiler output-dir
|
|
6
|
+
*/
|
|
7
|
+
"output-dir"?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const libDef: {
|
|
10
|
+
readonly name: "@typespec/openapi3";
|
|
11
|
+
readonly diagnostics: {};
|
|
12
|
+
readonly emitter: {
|
|
13
|
+
readonly options: JSONSchemaType<HtmlProgramViewerOptions>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
17
|
+
[code: string]: import("@typespec/compiler").DiagnosticMessages;
|
|
18
|
+
}, HtmlProgramViewerOptions>;
|
|
19
|
+
export declare function $onEmit(context: EmitContext<HtmlProgramViewerOptions>): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAyB,MAAM,oBAAoB,CAAC;AAGxE,OAAO,EAAyB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE3E,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAWD,eAAO,MAAM,MAAM;;;;;;CAMT,CAAC;AAEX,eAAO,MAAM,IAAI;;4BAAgC,CAAC;AAElD,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,wBAAwB,CAAC,iBAQ3E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { emitFile, resolvePath } from "@typespec/compiler";
|
|
2
|
+
import { renderProgram } from "./ui.js";
|
|
3
|
+
import { createTypeSpecLibrary } from "@typespec/compiler";
|
|
4
|
+
const EmitterOptionsSchema = {
|
|
5
|
+
type: "object",
|
|
6
|
+
additionalProperties: false,
|
|
7
|
+
properties: {
|
|
8
|
+
"output-dir": { type: "string", nullable: true },
|
|
9
|
+
},
|
|
10
|
+
required: [],
|
|
11
|
+
};
|
|
12
|
+
export const libDef = {
|
|
13
|
+
name: "@typespec/openapi3",
|
|
14
|
+
diagnostics: {},
|
|
15
|
+
emitter: {
|
|
16
|
+
options: EmitterOptionsSchema,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export const $lib = createTypeSpecLibrary(libDef);
|
|
20
|
+
export async function $onEmit(context) {
|
|
21
|
+
const html = renderProgram(context.program);
|
|
22
|
+
const outputDir = context.emitterOutputDir;
|
|
23
|
+
const htmlPath = resolvePath(outputDir, "typespec-program.html");
|
|
24
|
+
await emitFile(context.program, {
|
|
25
|
+
path: htmlPath,
|
|
26
|
+
content: `<!DOCTYPE html><html lang="en"><link rel="stylesheet" href="style.css"><body>${html}</body></html>`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,qBAAqB,EAAkB,MAAM,oBAAoB,CAAC;AAS3E,MAAM,oBAAoB,GAA6C;IACrE,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;KACjD;IACD,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,EAAE;IACf,OAAO,EAAE;QACP,OAAO,EAAE,oBAAgE;KAC1E;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAElD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAA8C;IAC1E,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAC3C,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;IACjE,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE;QAC9B,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,gFAAgF,IAAI,gBAAgB;KAC9G,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/inspect.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE5C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const MAX_DEPTH = 2;
|
|
2
|
+
export function inspect(obj) {
|
|
3
|
+
return formatValue({ depth: 0 }, obj);
|
|
4
|
+
}
|
|
5
|
+
function formatValue(ctx, obj) {
|
|
6
|
+
switch (typeof obj) {
|
|
7
|
+
case "undefined":
|
|
8
|
+
return "undefined";
|
|
9
|
+
case "string":
|
|
10
|
+
return `"${obj}"`;
|
|
11
|
+
case "number":
|
|
12
|
+
case "bigint":
|
|
13
|
+
case "boolean":
|
|
14
|
+
case "symbol":
|
|
15
|
+
return obj.toString();
|
|
16
|
+
case "object":
|
|
17
|
+
if (obj === null) {
|
|
18
|
+
return "null";
|
|
19
|
+
}
|
|
20
|
+
return formatObject(ctx, obj);
|
|
21
|
+
default:
|
|
22
|
+
return "?";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function formatObject(ctx, obj) {
|
|
26
|
+
if (ctx.depth > MAX_DEPTH) {
|
|
27
|
+
return obj.toString();
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(obj)) {
|
|
30
|
+
return formatArray(ctx, obj);
|
|
31
|
+
}
|
|
32
|
+
const props = Object.entries(obj).map(([k, v]) => {
|
|
33
|
+
return ` `.repeat(ctx.depth) + `${k}: ${formatValue({ ...ctx, depth: ctx.depth + 1 }, v)}`;
|
|
34
|
+
});
|
|
35
|
+
return ["{", ...props, "}"].join("\n");
|
|
36
|
+
}
|
|
37
|
+
function formatArray(ctx, obj) {
|
|
38
|
+
if (ctx.depth > MAX_DEPTH) {
|
|
39
|
+
return obj.toString();
|
|
40
|
+
}
|
|
41
|
+
const items = obj.map((v) => {
|
|
42
|
+
return ` `.repeat(ctx.depth) + `${formatValue({ ...ctx, depth: ctx.depth + 1 }, v)}`;
|
|
43
|
+
});
|
|
44
|
+
return ["[", ...items, "]"].join("\n");
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=inspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/inspect.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,MAAM,UAAU,OAAO,CAAC,GAAY;IAClC,OAAO,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC;AAKD,SAAS,WAAW,CAAC,GAAmB,EAAE,GAAY;IACpD,QAAQ,OAAO,GAAG,EAAE;QAClB,KAAK,WAAW;YACd,OAAO,WAAW,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,IAAI,GAAG,GAAG,CAAC;QACpB,KAAK,QAAQ,C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AG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,WAAW,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;IACvF,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGpF,eAAO,MAAM,wBAAwB,EAAE,mBAGrC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { resolvePath } from "@typespec/compiler";
|
|
2
|
+
import { createTestLibrary } from "@typespec/compiler/testing";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
export const ProgramViewerTestLibrary = createTestLibrary({
|
|
5
|
+
name: "@typespec/html-program-viewer",
|
|
6
|
+
packageRoot: resolvePath(fileURLToPath(import.meta.url), "../../../../"),
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAuB,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,CAAC,MAAM,wBAAwB,GAAwB,iBAAiB,CAAC;IAC7E,IAAI,EAAE,+BAA+B;IACrC,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC;CACzE,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Type } from "@typespec/compiler";
|
|
2
|
+
import { FunctionComponent } from "react";
|
|
3
|
+
export interface TypeUIBaseProperty {
|
|
4
|
+
name: string;
|
|
5
|
+
value: any;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TypeUIBaseProps {
|
|
9
|
+
type: Type;
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Alternate id
|
|
13
|
+
* @default getIdForType(type)
|
|
14
|
+
*/
|
|
15
|
+
id?: string;
|
|
16
|
+
properties: TypeUIBaseProperty[];
|
|
17
|
+
}
|
|
18
|
+
export declare const TypeUIBase: FunctionComponent<TypeUIBaseProps>;
|
|
19
|
+
//# sourceMappingURL=type-ui-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-ui-base.d.ts","sourceRoot":"","sources":["../../src/type-ui-base.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAK1C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,kBAAkB,EAAE,CAAC;CAClC;AAOD,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CA6BzD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
|
+
import { KeyValueSection } from "./common.js";
|
|
4
|
+
import { Colors } from "./constants.js";
|
|
5
|
+
import { getIdForType } from "./utils.js";
|
|
6
|
+
const TypeNameStyles = css({
|
|
7
|
+
display: "inline",
|
|
8
|
+
color: "#333333",
|
|
9
|
+
});
|
|
10
|
+
export const TypeUIBase = (props) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : getIdForType(props.type);
|
|
13
|
+
const properties = props.properties.map((prop) => {
|
|
14
|
+
return (_jsxs("li", { children: [_jsx("span", { css: { color: "#9c5d27" }, title: prop.description, children: prop.name }), ": ", _jsx("span", { children: prop.value })] }, prop.name));
|
|
15
|
+
});
|
|
16
|
+
return (_jsxs("div", { children: [_jsxs("div", { id: id, children: [_jsx("span", { css: {
|
|
17
|
+
display: "inline",
|
|
18
|
+
color: Colors.typeKind,
|
|
19
|
+
marginRight: "5px",
|
|
20
|
+
}, children: props.type.kind }), _jsx("span", { css: TypeNameStyles, children: props.name })] }), _jsx(KeyValueSection, { children: properties })] }));
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=type-ui-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-ui-base.js","sourceRoot":"","sources":["../../src/type-ui-base.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAmB1C,MAAM,cAAc,GAAG,GAAG,CAAC;IACzB,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,SAAS;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAuC,CAAC,KAAK,EAAE,EAAE;;IACtE,MAAM,EAAE,GAAG,MAAA,KAAK,CAAC,EAAE,mCAAI,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/C,OAAO,CACL,yBACE,eAAM,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,YACrD,IAAI,CAAC,IAAI,GACL,QACL,yBAAO,IAAI,CAAC,KAAK,GAAQ,KAJpB,IAAI,CAAC,IAAI,CAKb,CACN,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,CACL,0BACE,eAAK,EAAE,EAAE,EAAE,aACT,eACE,GAAG,EAAE;4BACH,OAAO,EAAE,QAAQ;4BACjB,KAAK,EAAE,MAAM,CAAC,QAAQ;4BACtB,WAAW,EAAE,KAAK;yBACnB,YAEA,KAAK,CAAC,IAAI,CAAC,IAAI,GACX,EACP,eAAM,GAAG,EAAE,cAAc,YAAG,KAAK,CAAC,IAAI,GAAQ,IAC1C,EACN,KAAC,eAAe,cAAE,UAAU,GAAmB,IAC3C,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/src/ui.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Program } from "@typespec/compiler";
|
|
2
|
+
import { FunctionComponent, ReactElement } from "react";
|
|
3
|
+
export declare function renderProgram(program: Program): string;
|
|
4
|
+
export interface TypeSpecProgramViewerProps {
|
|
5
|
+
program: Program;
|
|
6
|
+
}
|
|
7
|
+
export declare const TypeSpecProgramViewer: FunctionComponent<TypeSpecProgramViewerProps>;
|
|
8
|
+
export interface ItemListProps<T> {
|
|
9
|
+
items: Map<string, T> | T[];
|
|
10
|
+
render: (t: T) => ReactElement<any, any> | null;
|
|
11
|
+
}
|
|
12
|
+
export declare const ItemList: <T extends object>(props: ItemListProps<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/ui.tsx"],"names":[],"mappings":"AACA,OAAO,EAUL,OAAO,EAKR,MAAM,oBAAoB,CAAC;AAC5B,OAAc,EAAE,iBAAiB,EAAE,YAAY,EAAc,MAAM,OAAO,CAAC;AAa3E,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,UAG7C;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAC;CAClB;AAYD,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,0BAA0B,CAkB/E,CAAC;AAEF,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,QAAQ,iGAiBpB,CAAC"}
|
package/dist/src/ui.js
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
|
+
import { getNamespaceFullName, getTypeName, } from "@typespec/compiler";
|
|
4
|
+
import React, { useContext } from "react";
|
|
5
|
+
import ReactDOMServer from "react-dom/server";
|
|
6
|
+
import { KeyValueSection, Literal } from "./common.js";
|
|
7
|
+
import { inspect } from "./inspect.js";
|
|
8
|
+
import { TypeUIBase } from "./type-ui-base.js";
|
|
9
|
+
import { getIdForType, isNamedUnion } from "./utils.js";
|
|
10
|
+
function expandNamespaces(namespace) {
|
|
11
|
+
return [namespace, ...[...namespace.namespaces.values()].flatMap(expandNamespaces)];
|
|
12
|
+
}
|
|
13
|
+
const ProgramContext = React.createContext({});
|
|
14
|
+
export function renderProgram(program) {
|
|
15
|
+
const html = ReactDOMServer.renderToString(_jsx(TypeSpecProgramViewer, { program: program }));
|
|
16
|
+
return html;
|
|
17
|
+
}
|
|
18
|
+
const ProgramViewerStyles = css({
|
|
19
|
+
fontFamily: "monospace",
|
|
20
|
+
backgroundColor: "#f3f3f3",
|
|
21
|
+
li: {
|
|
22
|
+
margin: 0,
|
|
23
|
+
listStyle: "none",
|
|
24
|
+
position: "relative",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
export const TypeSpecProgramViewer = ({ program, }) => {
|
|
28
|
+
const root = program.checker.getGlobalNamespaceType();
|
|
29
|
+
const namespaces = expandNamespaces(root);
|
|
30
|
+
return (_jsx(ProgramContext.Provider, { value: program, children: _jsx("div", { css: ProgramViewerStyles, children: _jsx("ul", { css: { padding: "0 0 0 10px", margin: 0 }, children: namespaces.map((namespace) => (_jsx("li", { children: _jsx(NamespaceUI, { type: namespace }) }, getNamespaceFullName(namespace)))) }) }) }));
|
|
31
|
+
};
|
|
32
|
+
export const ItemList = (props) => {
|
|
33
|
+
if (Array.isArray(props.items)) {
|
|
34
|
+
if (props.items.length === 0) {
|
|
35
|
+
return _jsx(_Fragment, { children: "[]" });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (props.items.size === 0) {
|
|
40
|
+
return _jsx(_Fragment, { children: "{}" });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return (_jsx(KeyValueSection, { children: [...props.items.entries()].map(([k, v]) => (_jsx("li", { children: props.render(v) }, k))) }));
|
|
44
|
+
};
|
|
45
|
+
const omittedProps = [
|
|
46
|
+
"kind",
|
|
47
|
+
"name",
|
|
48
|
+
"node",
|
|
49
|
+
"symbol",
|
|
50
|
+
"namespace",
|
|
51
|
+
"templateNode",
|
|
52
|
+
"templateArguments",
|
|
53
|
+
"templateMapper",
|
|
54
|
+
"instantiationParameters",
|
|
55
|
+
"decorators",
|
|
56
|
+
"projectionBase",
|
|
57
|
+
"projectionsByName",
|
|
58
|
+
"projectionSource",
|
|
59
|
+
"projector",
|
|
60
|
+
"projections",
|
|
61
|
+
];
|
|
62
|
+
const omittedPropsSet = new Set(omittedProps);
|
|
63
|
+
const NamedTypeUI = ({ type, name, properties }) => {
|
|
64
|
+
name !== null && name !== void 0 ? name : (name = type.name);
|
|
65
|
+
const propsUI = Object.entries(type)
|
|
66
|
+
.map(([key, value]) => {
|
|
67
|
+
if (omittedPropsSet.has(key)) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const action = properties[key];
|
|
71
|
+
if (action === "skip") {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const render = (x) => action === "ref" ? _jsx(TypeReference, { type: value }) : _jsx(TypeUI, { type: x });
|
|
75
|
+
let valueUI;
|
|
76
|
+
if (value === undefined) {
|
|
77
|
+
valueUI = value;
|
|
78
|
+
}
|
|
79
|
+
else if (value.kind) {
|
|
80
|
+
valueUI = render(value);
|
|
81
|
+
}
|
|
82
|
+
else if (value instanceof Map || Array.isArray(value)) {
|
|
83
|
+
valueUI = _jsx(ItemList, { items: value, render: render });
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
valueUI = value;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
name: key,
|
|
90
|
+
value: valueUI,
|
|
91
|
+
};
|
|
92
|
+
})
|
|
93
|
+
.filter((x) => Boolean(x));
|
|
94
|
+
return (_jsx(TypeUIBase, { type: type, name: name, properties: propsUI.concat([getDataProperty(type)]) }));
|
|
95
|
+
};
|
|
96
|
+
const TypeUI = ({ type }) => {
|
|
97
|
+
switch (type.kind) {
|
|
98
|
+
case "Namespace":
|
|
99
|
+
return _jsx(NamespaceUI, { type: type });
|
|
100
|
+
case "Interface":
|
|
101
|
+
return _jsx(InterfaceUI, { type: type });
|
|
102
|
+
case "Operation":
|
|
103
|
+
return _jsx(OperationUI, { type: type });
|
|
104
|
+
case "Model":
|
|
105
|
+
return _jsx(ModelUI, { type: type });
|
|
106
|
+
case "Scalar":
|
|
107
|
+
return _jsx(ScalarUI, { type: type });
|
|
108
|
+
case "ModelProperty":
|
|
109
|
+
return _jsx(ModelPropertyUI, { type: type });
|
|
110
|
+
case "Union":
|
|
111
|
+
return _jsx(UnionUI, { type: type });
|
|
112
|
+
case "UnionVariant":
|
|
113
|
+
return _jsx(UnionVariantUI, { type: type });
|
|
114
|
+
case "Enum":
|
|
115
|
+
return _jsx(EnumUI, { type: type });
|
|
116
|
+
case "EnumMember":
|
|
117
|
+
return _jsx(EnumMemberUI, { type: type });
|
|
118
|
+
default:
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const NamespaceUI = ({ type }) => {
|
|
123
|
+
const name = getNamespaceFullName(type) || "(global)";
|
|
124
|
+
return (_jsx(NamedTypeUI, { name: name, type: type, properties: {
|
|
125
|
+
namespaces: "skip",
|
|
126
|
+
models: "nested",
|
|
127
|
+
scalars: "nested",
|
|
128
|
+
interfaces: "nested",
|
|
129
|
+
operations: "nested",
|
|
130
|
+
unions: "nested",
|
|
131
|
+
enums: "nested",
|
|
132
|
+
decoratorDeclarations: "nested",
|
|
133
|
+
functionDeclarations: "nested",
|
|
134
|
+
} }));
|
|
135
|
+
};
|
|
136
|
+
const InterfaceUI = ({ type }) => {
|
|
137
|
+
return (_jsx(NamedTypeUI, { type: type, properties: {
|
|
138
|
+
operations: "nested",
|
|
139
|
+
} }));
|
|
140
|
+
};
|
|
141
|
+
const OperationUI = ({ type }) => {
|
|
142
|
+
return (_jsx(NamedTypeUI, { type: type, properties: {
|
|
143
|
+
interface: "skip",
|
|
144
|
+
parameters: "nested",
|
|
145
|
+
returnType: "ref",
|
|
146
|
+
} }));
|
|
147
|
+
};
|
|
148
|
+
function getDataProperty(type) {
|
|
149
|
+
return {
|
|
150
|
+
name: "data",
|
|
151
|
+
description: "in program.stateMap()",
|
|
152
|
+
value: _jsx(TypeData, { type: type }),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const ModelUI = ({ type }) => {
|
|
156
|
+
return (_jsx(NamedTypeUI, { type: type, properties: {
|
|
157
|
+
indexer: "skip",
|
|
158
|
+
baseModel: "ref",
|
|
159
|
+
derivedModels: "ref",
|
|
160
|
+
properties: "nested",
|
|
161
|
+
} }));
|
|
162
|
+
};
|
|
163
|
+
const ScalarUI = ({ type }) => {
|
|
164
|
+
return (_jsx(NamedTypeUI, { type: type, properties: {
|
|
165
|
+
baseScalar: "ref",
|
|
166
|
+
derivedScalars: "ref",
|
|
167
|
+
} }));
|
|
168
|
+
};
|
|
169
|
+
const ModelPropertyUI = ({ type }) => {
|
|
170
|
+
return (_jsx(NamedTypeUI, { type: type, properties: {
|
|
171
|
+
model: "skip",
|
|
172
|
+
type: "ref",
|
|
173
|
+
optional: "value",
|
|
174
|
+
sourceProperty: "ref",
|
|
175
|
+
default: "value",
|
|
176
|
+
} }));
|
|
177
|
+
};
|
|
178
|
+
const EnumUI = ({ type }) => {
|
|
179
|
+
return (_jsx(NamedTypeUI, { type: type, properties: {
|
|
180
|
+
members: "nested",
|
|
181
|
+
} }));
|
|
182
|
+
};
|
|
183
|
+
const EnumMemberUI = ({ type }) => {
|
|
184
|
+
return (_jsx(NamedTypeUI, { type: type, properties: {
|
|
185
|
+
enum: "skip",
|
|
186
|
+
sourceMember: "ref",
|
|
187
|
+
value: "value",
|
|
188
|
+
} }));
|
|
189
|
+
};
|
|
190
|
+
const UnionUI = ({ type }) => {
|
|
191
|
+
if (!isNamedUnion(type)) {
|
|
192
|
+
return _jsx(_Fragment, {});
|
|
193
|
+
}
|
|
194
|
+
return (_jsx(NamedTypeUI, { type: type, properties: {
|
|
195
|
+
expression: "skip",
|
|
196
|
+
options: "skip",
|
|
197
|
+
variants: "nested",
|
|
198
|
+
} }));
|
|
199
|
+
};
|
|
200
|
+
const UnionVariantUI = ({ type }) => {
|
|
201
|
+
if (typeof type.name === "symbol") {
|
|
202
|
+
return _jsx(_Fragment, {});
|
|
203
|
+
}
|
|
204
|
+
return (_jsx(NamedTypeUI, { type: type, properties: {
|
|
205
|
+
union: "skip",
|
|
206
|
+
type: "ref",
|
|
207
|
+
} }));
|
|
208
|
+
};
|
|
209
|
+
const NamedTypeRef = ({ type }) => {
|
|
210
|
+
const id = getIdForType(type);
|
|
211
|
+
const href = `#${id}`;
|
|
212
|
+
return (_jsx("a", { css: {
|
|
213
|
+
color: "#268bd2",
|
|
214
|
+
textDecoration: "none",
|
|
215
|
+
"&:hover": {
|
|
216
|
+
textDecoration: "underline",
|
|
217
|
+
},
|
|
218
|
+
}, href: href, title: type.kind + ": " + id, children: getTypeName(type) }));
|
|
219
|
+
};
|
|
220
|
+
const TypeReference = ({ type }) => {
|
|
221
|
+
switch (type.kind) {
|
|
222
|
+
case "Namespace":
|
|
223
|
+
case "Operation":
|
|
224
|
+
case "Interface":
|
|
225
|
+
case "Enum":
|
|
226
|
+
case "ModelProperty":
|
|
227
|
+
case "Scalar":
|
|
228
|
+
return _jsx(NamedTypeRef, { type: type });
|
|
229
|
+
case "Model":
|
|
230
|
+
if (type.name === "") {
|
|
231
|
+
return (_jsx(KeyValueSection, { children: _jsx(TypeUI, { type: type }) }));
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
return _jsx(NamedTypeRef, { type: type });
|
|
235
|
+
}
|
|
236
|
+
case "Union":
|
|
237
|
+
if (isNamedUnion(type)) {
|
|
238
|
+
return _jsx(NamedTypeRef, { type: type });
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
return (_jsx(_Fragment, { children: [...type.variants.values()].map((variant, i) => {
|
|
242
|
+
return (_jsxs("span", { children: [_jsx(TypeReference, { type: variant.type }), i < type.variants.size - 1 ? " | " : ""] }, i));
|
|
243
|
+
}) }));
|
|
244
|
+
}
|
|
245
|
+
case "TemplateParameter":
|
|
246
|
+
return _jsxs("span", { children: ["Template Param: ", type.node.id.sv] });
|
|
247
|
+
case "String":
|
|
248
|
+
return _jsxs(Literal, { children: ["\"", type.value, "\""] });
|
|
249
|
+
case "Number":
|
|
250
|
+
case "Boolean":
|
|
251
|
+
return _jsx(_Fragment, { children: type.value });
|
|
252
|
+
default:
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const TypeData = ({ type }) => {
|
|
257
|
+
const program = useContext(ProgramContext);
|
|
258
|
+
const entries = [...program.stateMaps.entries()]
|
|
259
|
+
.map(([k, v]) => { var _a; return [k, (_a = v.get(undefined)) === null || _a === void 0 ? void 0 : _a.get(type)]; })
|
|
260
|
+
.filter(([k, v]) => !!v);
|
|
261
|
+
if (entries.length === 0) {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
return (_jsx(KeyValueSection, { children: entries.map(([k, v], i) => (_jsxs("div", { css: { display: "flex" }, children: [_jsxs("div", { css: { color: "#333", marginRight: "5px" }, children: [k.toString(), ":"] }), " ", _jsx("div", { children: inspect(v) })] }, i))) }));
|
|
265
|
+
};
|
|
266
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/ui.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAGL,oBAAoB,EACpB,WAAW,GAWZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAmC,UAAU,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAsB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAExD,SAAS,gBAAgB,CAAC,SAAoB;I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eAAe,cACb,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAC1B,eAAK,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAC3B,eAAK,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,aAAG,CAAC,CAAC,QAAQ,EAAE,SAAQ,EAAC,GAAG,EAC1E,wBAAM,OAAO,CAAC,CAAC,CAAC,GAAO,KAFW,CAAC,CAG/B,CACP,CAAC,GACc,CACnB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEvE,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAgB3D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAE5E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getNamespaceFullName } from "@typespec/compiler";
|
|
2
|
+
export function getIdForType(type) {
|
|
3
|
+
var _a;
|
|
4
|
+
if (type.kind === "Namespace") {
|
|
5
|
+
return getNamespaceFullName(type);
|
|
6
|
+
}
|
|
7
|
+
else if ("interface" in type && type.interface) {
|
|
8
|
+
return `${getIdForType(type.interface)}.${type.name}`;
|
|
9
|
+
}
|
|
10
|
+
else if ("model" in type && type.model) {
|
|
11
|
+
return `${getIdForType(type.model)}.${type.name}`;
|
|
12
|
+
}
|
|
13
|
+
else if ("namespace" in type && type.namespace) {
|
|
14
|
+
return type.namespace.name === ""
|
|
15
|
+
? type.name
|
|
16
|
+
: `${getNamespaceFullName(type.namespace)}.${type.name}`;
|
|
17
|
+
}
|
|
18
|
+
else if ("name" in type) {
|
|
19
|
+
return (_a = type.name) === null || _a === void 0 ? void 0 : _a.toString();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function isNamedUnion(union) {
|
|
26
|
+
return union.name !== undefined;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAe,MAAM,oBAAoB,CAAC;AAEvE,MAAM,UAAU,YAAY,CAAC,IAAU;;IACrC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE;QAC7B,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;KACnC;SAAM,IAAI,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE;QAChD,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;KACvD;SAAM,IAAI,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;QACxC,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;KACnD;SAAM,IAAI,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE;QAChD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,EAAE;YAC/B,CAAC,CAAC,IAAI,CAAC,IAAI;YACX,CAAC,CAAC,GAAG,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;KAC5D;SAAM,IAAI,MAAM,IAAI,IAAI,EAAE;QACzB,OAAO,MAAA,IAAI,CAAC,IAAI,0CAAE,QAAQ,EAAE,CAAC;KAC9B;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAY;IACvC,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;AAClC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@typespec/html-program-viewer",
|
|
3
|
+
"version": "0.41.0",
|
|
4
|
+
"author": "Microsoft Corporation",
|
|
5
|
+
"description": "TypeSpec library for emitting an html view of the program.",
|
|
6
|
+
"homepage": "https://microsoft.github.io/typespec",
|
|
7
|
+
"readme": "https://github.com/Azure/typespec/blob/master/README.md",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Azure/typespec.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Azure/typespec/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"typespec"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "dist/src/index.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./dist/src/index.js",
|
|
23
|
+
"./testing": "./dist/src/testing/index.js"
|
|
24
|
+
},
|
|
25
|
+
"typesVersions": {
|
|
26
|
+
"*": {
|
|
27
|
+
"*": [
|
|
28
|
+
"./dist/src/index.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"testing": [
|
|
31
|
+
"./dist/src/testing/index.d.ts"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"tspMain": "dist/src/index.js",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=14.0.0"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"lib/*.tsp",
|
|
41
|
+
"dist/**",
|
|
42
|
+
"!dist/test/**"
|
|
43
|
+
],
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@typespec/compiler": "~0.41.0"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"prettier": "~2.8.1",
|
|
49
|
+
"react": "~18.2.0",
|
|
50
|
+
"react-dom": "~18.2.0",
|
|
51
|
+
"react-is": "~18.1.0",
|
|
52
|
+
"@emotion/react": "^11.10.4"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/mocha": "~10.0.0",
|
|
56
|
+
"@types/node": "~18.11.9",
|
|
57
|
+
"@types/prettier": "2.6.0",
|
|
58
|
+
"@types/react": "~18.0.5",
|
|
59
|
+
"@types/react-dom": "~18.0.1",
|
|
60
|
+
"@typespec/compiler": "~0.41.0",
|
|
61
|
+
"@typespec/eslint-config-typespec": "~0.6.0",
|
|
62
|
+
"@babel/core": "^7.0.0",
|
|
63
|
+
"eslint": "^8.12.0",
|
|
64
|
+
"mocha": "~10.1.0",
|
|
65
|
+
"mocha-junit-reporter": "~2.2.0",
|
|
66
|
+
"mocha-multi-reporters": "~1.5.1",
|
|
67
|
+
"c8": "~7.12.0",
|
|
68
|
+
"rimraf": "~3.0.2",
|
|
69
|
+
"typescript": "~4.9.3"
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"clean": "rimraf ./dist ./temp",
|
|
73
|
+
"build": "tsc -p .",
|
|
74
|
+
"watch": "tsc -p . --watch",
|
|
75
|
+
"test": "mocha",
|
|
76
|
+
"test-official": "c8 mocha --forbid-only --reporter mocha-multi-reporters",
|
|
77
|
+
"lint": "eslint . --ext .ts --max-warnings=0",
|
|
78
|
+
"lint:fix": "eslint . --fix --ext .ts"
|
|
79
|
+
}
|
|
80
|
+
}
|