forked from microsoft/typespec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tsx
60 lines (54 loc) · 1.71 KB
/
main.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { registerMonacoDefaultWorkersForVite } from "@typespec/playground";
import PlaygroundManifest from "@typespec/playground/manifest";
import {
Footer,
FooterItem,
FooterVersionItem,
renderReactPlayground,
} from "@typespec/playground/react";
import { SwaggerUIViewer } from "@typespec/playground/react/viewers";
import samples from "../samples/dist/samples.js";
import { MANIFEST } from "@typespec/compiler";
import "@typespec/playground/styles.css";
import "./style.css";
registerMonacoDefaultWorkersForVite();
declare const __PR__: string | undefined;
declare const __COMMIT_HASH__: string | undefined;
const commit = typeof __COMMIT_HASH__ !== "undefined" ? __COMMIT_HASH__ : undefined;
const pr = typeof __PR__ !== "undefined" ? __PR__ : undefined;
const PlaygroundFooter = () => {
const prItem = pr ? (
<FooterItem link={`https://github.com/microsoft/typespec/pull/${pr}`}>
<span>PR </span>
<span>{pr}</span>
</FooterItem>
) : (
<></>
);
return (
<Footer className={pr && "pr-footer"}>
{prItem}
<FooterVersionItem />
<FooterItem link={`https://github.com/microsoft/typespec/commit/${commit}`}>
<span>Commit </span>
<span>{MANIFEST.commit.slice(0, 6)}</span>
</FooterItem>
</Footer>
);
};
await renderReactPlayground({
...PlaygroundManifest,
samples,
emitterViewers: {
"@typespec/openapi3": [SwaggerUIViewer],
},
importConfig: {
useShim: true,
},
footer: <PlaygroundFooter />,
onFileBug: () => {
const bodyPayload = encodeURIComponent(`\n\n\n[Playground Link](${document.location.href})`);
const url = `https://github.com/microsoft/typespec/issues/new?body=${bodyPayload}`;
window.open(url, "_blank");
},
});