@typespec/html-program-viewer 0.58.0-dev.0 → 0.58.0-dev.4
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/emitter/index.js +5779 -0
- package/dist/emitter/style.css +92 -0
- package/dist/{src/emitter.d.ts → emitter.d.ts} +6 -5
- package/dist/emitter.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/manifest-DR4jWHsG.js +6 -0
- package/dist/react/common.d.ts +18 -0
- package/dist/react/common.d.ts.map +1 -0
- package/dist/react/current-path/current-path.d.ts +2 -0
- package/dist/react/current-path/current-path.d.ts.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +42232 -0
- package/dist/react/inspect-type/inspect-type.d.ts +12 -0
- package/dist/react/inspect-type/inspect-type.d.ts.map +1 -0
- package/dist/react/inspect-type/type-data-table.d.ts +10 -0
- package/dist/react/inspect-type/type-data-table.d.ts.map +1 -0
- package/dist/react/js-inspector/index.d.ts +6 -0
- package/dist/react/js-inspector/index.d.ts.map +1 -0
- package/dist/react/js-inspector/js-value/js-value.d.ts +12 -0
- package/dist/react/js-inspector/js-value/js-value.d.ts.map +1 -0
- package/dist/react/js-inspector/js-value/js-value.test.d.ts +2 -0
- package/dist/react/js-inspector/js-value/js-value.test.d.ts.map +1 -0
- package/dist/react/js-inspector/object-inspector.d.ts +18 -0
- package/dist/react/js-inspector/object-inspector.d.ts.map +1 -0
- package/dist/react/js-inspector/object-label.d.ts +12 -0
- package/dist/react/js-inspector/object-label.d.ts.map +1 -0
- package/dist/react/js-inspector/object-name.d.ts +17 -0
- package/dist/react/js-inspector/object-name.d.ts.map +1 -0
- package/dist/react/js-inspector/object-preview.d.ts +7 -0
- package/dist/react/js-inspector/object-preview.d.ts.map +1 -0
- package/dist/react/js-inspector/object-root-label.d.ts +4 -0
- package/dist/react/js-inspector/object-root-label.d.ts.map +1 -0
- package/dist/react/js-inspector/utils/object-prototype.d.ts +3 -0
- package/dist/react/js-inspector/utils/object-prototype.d.ts.map +1 -0
- package/dist/react/js-inspector/utils/property-utils.d.ts +2 -0
- package/dist/react/js-inspector/utils/property-utils.d.ts.map +1 -0
- package/dist/react/list-type-view/list-type-view.d.ts +8 -0
- package/dist/react/list-type-view/list-type-view.d.ts.map +1 -0
- package/dist/react/program-context.d.ts +5 -0
- package/dist/react/program-context.d.ts.map +1 -0
- package/dist/react/tree-navigation.d.ts +9 -0
- package/dist/react/tree-navigation.d.ts.map +1 -0
- package/dist/react/type-config.d.ts +20 -0
- package/dist/react/type-config.d.ts.map +1 -0
- package/dist/react/type-graph.d.ts +9 -0
- package/dist/react/type-graph.d.ts.map +1 -0
- package/dist/react/type-view/type-view.d.ts +8 -0
- package/dist/react/type-view/type-view.d.ts.map +1 -0
- package/dist/react/use-tree-navigation.d.ts +31 -0
- package/dist/react/use-tree-navigation.d.ts.map +1 -0
- package/dist/style.css +244 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +29 -20
- package/dist/src/color-provider.d.ts +0 -8
- package/dist/src/color-provider.d.ts.map +0 -1
- package/dist/src/color-provider.js +0 -13
- package/dist/src/color-provider.js.map +0 -1
- package/dist/src/common.d.ts +0 -8
- package/dist/src/common.d.ts.map +0 -1
- package/dist/src/common.js +0 -12
- package/dist/src/common.js.map +0 -1
- package/dist/src/constants.d.ts +0 -15
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js +0 -23
- package/dist/src/constants.js.map +0 -1
- package/dist/src/emitter.d.ts.map +0 -1
- package/dist/src/emitter.js +0 -29
- package/dist/src/emitter.js.map +0 -1
- package/dist/src/index.d.ts +0 -5
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -4
- package/dist/src/index.js.map +0 -1
- package/dist/src/inspect.d.ts +0 -2
- package/dist/src/inspect.d.ts.map +0 -1
- package/dist/src/inspect.js +0 -46
- package/dist/src/inspect.js.map +0 -1
- package/dist/src/testing/index.d.ts +0 -3
- package/dist/src/testing/index.d.ts.map +0 -1
- package/dist/src/testing/index.js +0 -6
- package/dist/src/testing/index.js.map +0 -1
- package/dist/src/type-ui-base.d.ts +0 -19
- package/dist/src/type-ui-base.d.ts.map +0 -1
- package/dist/src/type-ui-base.js +0 -21
- package/dist/src/type-ui-base.js.map +0 -1
- package/dist/src/ui.d.ts +0 -13
- package/dist/src/ui.d.ts.map +0 -1
- package/dist/src/ui.js +0 -277
- package/dist/src/ui.js.map +0 -1
- package/dist/src/utils.d.ts +0 -6
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -27
- package/dist/src/utils.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/html-program-viewer",
|
|
3
|
-
"version": "0.58.0-dev.
|
|
3
|
+
"version": "0.58.0-dev.4",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec library for emitting an html view of the program.",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -17,23 +17,21 @@
|
|
|
17
17
|
"typespec"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"main": "dist/
|
|
20
|
+
"main": "dist/emitter/index.js",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
-
"
|
|
24
|
-
"default": "./dist/src/index.js"
|
|
23
|
+
"default": "./dist/emitter/index.js"
|
|
25
24
|
},
|
|
26
|
-
"./
|
|
27
|
-
"types": "./dist/
|
|
28
|
-
"default": "./dist/
|
|
29
|
-
}
|
|
25
|
+
"./react": {
|
|
26
|
+
"types": "./dist/react/index.d.ts",
|
|
27
|
+
"default": "./dist/react/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./style.css": "./dist/style.css"
|
|
30
30
|
},
|
|
31
|
-
"tspMain": "dist/src/index.js",
|
|
32
31
|
"engines": {
|
|
33
32
|
"node": ">=14.0.0"
|
|
34
33
|
},
|
|
35
34
|
"files": [
|
|
36
|
-
"lib/*.tsp",
|
|
37
35
|
"dist/**",
|
|
38
36
|
"!dist/test/**"
|
|
39
37
|
],
|
|
@@ -41,29 +39,40 @@
|
|
|
41
39
|
"@typespec/compiler": "~0.57.0 || >=0.58.0-dev <0.58.0"
|
|
42
40
|
},
|
|
43
41
|
"dependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
42
|
+
"@fluentui/react-components": "~9.54.2",
|
|
43
|
+
"@fluentui/react-icons": "^2.0.247",
|
|
44
|
+
"@fluentui/react-list-preview": "^0.2.8",
|
|
46
45
|
"react": "~18.3.1",
|
|
47
46
|
"react-dom": "~18.3.1",
|
|
48
|
-
"react-
|
|
47
|
+
"react-hotkeys-hook": "^4.5.0"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@babel/core": "^7.24.
|
|
50
|
+
"@babel/core": "^7.24.7",
|
|
51
|
+
"@testing-library/dom": "^10.2.0",
|
|
52
|
+
"@testing-library/jest-dom": "^6.4.6",
|
|
53
|
+
"@testing-library/react": "^16.0.0",
|
|
52
54
|
"@types/node": "~18.11.19",
|
|
53
|
-
"@types/react": "~18.3.
|
|
55
|
+
"@types/react": "~18.3.3",
|
|
54
56
|
"@types/react-dom": "~18.3.0",
|
|
55
57
|
"@typespec/compiler": "~0.57.0 || >=0.58.0-dev <0.58.0",
|
|
58
|
+
"@vitejs/plugin-react": "~4.3.1",
|
|
56
59
|
"@vitest/coverage-v8": "^1.6.0",
|
|
57
60
|
"@vitest/ui": "^1.6.0",
|
|
58
|
-
"c8": "^
|
|
61
|
+
"c8": "^10.1.2",
|
|
59
62
|
"rimraf": "~5.0.7",
|
|
60
|
-
"typescript": "~5.
|
|
61
|
-
"
|
|
63
|
+
"typescript": "~5.5.3",
|
|
64
|
+
"vite": "^5.3.2",
|
|
65
|
+
"vite-plugin-checker": "^0.7.0",
|
|
66
|
+
"vite-plugin-dts": "^3.9.1",
|
|
67
|
+
"vitest": "^1.6.0",
|
|
68
|
+
"@typespec/react-components": "~0.57.0"
|
|
62
69
|
},
|
|
63
70
|
"scripts": {
|
|
64
71
|
"clean": "rimraf ./dist ./temp",
|
|
65
|
-
"build": "
|
|
66
|
-
"
|
|
72
|
+
"build": "pnpm build:react && pnpm build:emitter",
|
|
73
|
+
"build:react": "vite build",
|
|
74
|
+
"build:emitter": "vite build --config vite.emitter.config.ts",
|
|
75
|
+
"watch": "vite build --watch",
|
|
67
76
|
"test": "vitest run",
|
|
68
77
|
"test:ui": "vitest --ui",
|
|
69
78
|
"test:ci": "vitest run --coverage --reporter=junit --reporter=default",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from "react";
|
|
2
|
-
import { ColorPalette } from "./constants.js";
|
|
3
|
-
export interface ColorProviderProps {
|
|
4
|
-
colors: Partial<ColorPalette>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const ColorProvider: FunctionComponent<ColorProviderProps>;
|
|
8
|
-
//# sourceMappingURL=color-provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color-provider.d.ts","sourceRoot":"","sources":["../../src/color-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAkC,MAAM,gBAAgB,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,CAU/D,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { ColorsVariables } from "./constants.js";
|
|
4
|
-
export const ColorProvider = ({ children, colors }) => {
|
|
5
|
-
const cssVariables = useMemo(() => {
|
|
6
|
-
const colorArray = Object.entries(colors);
|
|
7
|
-
return Object.fromEntries(colorArray.map(([key, value]) => {
|
|
8
|
-
return [ColorsVariables[key], value];
|
|
9
|
-
}));
|
|
10
|
-
}, [colors]);
|
|
11
|
-
return _jsx("div", { style: cssVariables, children: children });
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=color-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color-provider.js","sourceRoot":"","sources":["../../src/color-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgC,OAAO,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAA+B,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAO9E,MAAM,CAAC,MAAM,aAAa,GAA0C,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE;IAC3F,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAChC,MAAM,UAAU,GAA8B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAQ,CAAC;QAC5E,OAAO,MAAM,CAAC,WAAW,CACvB,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC9B,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,cAAK,KAAK,EAAE,YAAY,YAAG,QAAQ,GAAO,CAAC;AACpD,CAAC,CAAC"}
|
package/dist/src/common.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent, ReactElement } from "react";
|
|
2
|
-
export declare const Literal: FunctionComponent<{
|
|
3
|
-
children: any;
|
|
4
|
-
}>;
|
|
5
|
-
export declare const KeyValueSection: FunctionComponent<{
|
|
6
|
-
children: ReactElement | ReactElement[];
|
|
7
|
-
}>;
|
|
8
|
-
//# sourceMappingURL=common.d.ts.map
|
package/dist/src/common.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/common.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAGxD,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"}
|
package/dist/src/common.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { Colors } from "./constants.js";
|
|
3
|
-
export const Literal = ({ children }) => (_jsx("div", { css: { color: Colors.literal, display: "inline" }, children: children }));
|
|
4
|
-
export const KeyValueSection = ({ children, }) => {
|
|
5
|
-
return (_jsx("ul", { css: {
|
|
6
|
-
margin: 0,
|
|
7
|
-
padding: "0 0 0 16px",
|
|
8
|
-
borderLeft: `1px dashed ${Colors.indentationGuide}`,
|
|
9
|
-
overflow: "auto",
|
|
10
|
-
}, children: children }));
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=common.js.map
|
package/dist/src/common.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,CAAC,MAAM,OAAO,GAAyC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC7E,cAAK,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAG,QAAQ,GAAO,CACzE,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"}
|
package/dist/src/constants.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const ColorsVariables: {
|
|
2
|
-
readonly background: "--tsp-tgv-background";
|
|
3
|
-
readonly dataKey: "--tsp-tgv-data-key";
|
|
4
|
-
readonly indentationGuide: "--tsp-tgv-indentation-guide";
|
|
5
|
-
readonly literal: "--tsp-tgv-literal";
|
|
6
|
-
readonly property: "--tsp-tgv-property";
|
|
7
|
-
readonly ref: "--tsp-tgv-ref";
|
|
8
|
-
readonly typeKind: "--tsp-tgv-type-kind";
|
|
9
|
-
readonly typeName: "--tsp-tgv-type-name";
|
|
10
|
-
};
|
|
11
|
-
export type ColorVariable = keyof typeof ColorsVariables;
|
|
12
|
-
export type ColorPalette = Record<ColorVariable, string>;
|
|
13
|
-
export declare const DefaultColors: ColorPalette;
|
|
14
|
-
export declare const Colors: typeof ColorsVariables;
|
|
15
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe;;;;;;;;;CASlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,eAAe,CAAC;AACzD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AACzD,eAAO,MAAM,aAAa,EAAE,YAS3B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,OAAO,eAEpB,CAAC"}
|
package/dist/src/constants.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const variablePrefix = `--tsp-tgv`;
|
|
2
|
-
export const ColorsVariables = {
|
|
3
|
-
background: `${variablePrefix}-background`,
|
|
4
|
-
dataKey: `${variablePrefix}-data-key`,
|
|
5
|
-
indentationGuide: `${variablePrefix}-indentation-guide`,
|
|
6
|
-
literal: `${variablePrefix}-literal`,
|
|
7
|
-
property: `${variablePrefix}-property`,
|
|
8
|
-
ref: `${variablePrefix}-ref`,
|
|
9
|
-
typeKind: `${variablePrefix}-type-kind`,
|
|
10
|
-
typeName: `${variablePrefix}-type-name`,
|
|
11
|
-
};
|
|
12
|
-
export const DefaultColors = {
|
|
13
|
-
background: "#f3f3f3",
|
|
14
|
-
dataKey: "#333333",
|
|
15
|
-
indentationGuide: "#777",
|
|
16
|
-
literal: "#5da713",
|
|
17
|
-
property: "#9c5d27",
|
|
18
|
-
ref: "#268bd2",
|
|
19
|
-
typeKind: "#7a3e9d",
|
|
20
|
-
typeName: "#333333",
|
|
21
|
-
};
|
|
22
|
-
export const Colors = Object.fromEntries(Object.entries(ColorsVariables).map(([k, v]) => [k, `var(${v}, ${DefaultColors[k]})`]));
|
|
23
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,WAAW,CAAC;AACnC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU,EAAE,GAAG,cAAc,aAAa;IAC1C,OAAO,EAAE,GAAG,cAAc,WAAW;IACrC,gBAAgB,EAAE,GAAG,cAAc,oBAAoB;IACvD,OAAO,EAAE,GAAG,cAAc,UAAU;IACpC,QAAQ,EAAE,GAAG,cAAc,WAAW;IACtC,GAAG,EAAE,GAAG,cAAc,MAAM;IAC5B,QAAQ,EAAE,GAAG,cAAc,YAAY;IACvC,QAAQ,EAAE,GAAG,cAAc,YAAY;CAC/B,CAAC;AAIX,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC,UAAU,EAAE,SAAS;IACrB,OAAO,EAAE,SAAS;IAClB,gBAAgB,EAAE,MAAM;IACxB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,SAAS;IACnB,GAAG,EAAE,SAAS;IACd,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAA2B,MAAM,CAAC,WAAW,CAC9D,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAM,aAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CACzF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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;;mCAAgC,CAAC;AAElD,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,wBAAwB,CAAC,iBAQ3E"}
|
package/dist/src/emitter.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
package/dist/src/emitter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/src/index.d.ts
DELETED
package/dist/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/src/index.js
DELETED
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAsB,MAAM,qBAAqB,CAAC;AAExE,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/src/inspect.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/inspect.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE5C"}
|
package/dist/src/inspect.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
package/dist/src/inspect.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,CAAC;QACnB,KAAK,WAAW;YACd,OAAO,WAAW,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,IAAI,GAAG,GAAG,CAAC;QACpB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;QACxB,KAAK,QAAQ;YACX,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;gBACjB,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,OAAO,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChC;YACE,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAmB,EAAE,GAAW;IACpD,IAAI,GAAG,CAAC,KAAK,GAAG,SAAS,EAAE,CAAC;QAC1B,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,WAAW,CAAC,GAA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,mBAGrC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createTestLibrary, findTestPackageRoot, } from "@typespec/compiler/testing";
|
|
2
|
-
export const ProgramViewerTestLibrary = createTestLibrary({
|
|
3
|
-
name: "@typespec/html-program-viewer",
|
|
4
|
-
packageRoot: await findTestPackageRoot(import.meta.url),
|
|
5
|
-
});
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,CAAC,MAAM,wBAAwB,GAAwB,iBAAiB,CAAC;IAC7E,IAAI,EAAE,+BAA+B;IACrC,WAAW,EAAE,MAAM,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;CACxD,CAAC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/src/type-ui-base.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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: Colors.typeName,
|
|
9
|
-
});
|
|
10
|
-
export const TypeUIBase = (props) => {
|
|
11
|
-
const id = props.id ?? getIdForType(props.type);
|
|
12
|
-
const properties = props.properties.map((prop) => {
|
|
13
|
-
return (_jsxs("li", { children: [_jsx("span", { css: { color: Colors.property }, title: prop.description, children: prop.name }), ": ", _jsx("span", { children: prop.value })] }, prop.name));
|
|
14
|
-
});
|
|
15
|
-
return (_jsxs("div", { children: [_jsxs("div", { id: id, children: [_jsx("span", { css: {
|
|
16
|
-
display: "inline",
|
|
17
|
-
color: Colors.typeKind,
|
|
18
|
-
marginRight: "5px",
|
|
19
|
-
}, children: props.type.kind }), _jsx("span", { css: TypeNameStyles, children: props.name })] }), _jsx(KeyValueSection, { children: properties })] }));
|
|
20
|
-
};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,KAAC,eAAe,cAAE,UAAU,GAAmB,IAC3C,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/src/ui.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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 | symbol, 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
|
package/dist/src/ui.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAc3E,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,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IACrC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,QAAQ,4BAA6B,cAAc,CAAC,CAAC,qDAiBjE,CAAC"}
|