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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsx jsx */
/** @jsxFrag Fragment */
import {
createContext,
type FC,
Fragment,
jsx,
type PropsWithChildren,
useContext,
} from "https://deno.land/x/hono@v4.0.10/jsx/index.ts";
import { Hono } from "https://deno.land/x/hono@v4.0.10/mod.ts";
import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
import { create } from "https://esm.town/v/websandbox/create";
import * as YAML from "jsr:@std/yaml";
const app = new Hono();
const Layout: FC<PropsWithChildren<{ title: string }>> = (props) => {
return (
<html>
<head>
<title>{props.title}</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
{String.raw`
* {
box-sizing: border-box;
}
body, html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
color-scheme: light dark;
}
pre {
font-size: 1rem;
}
`}
</style>
</head>
<body>{props.children}</body>
</html>
);
};
const App: FC<{ code: string }> = ({ code }) => {
const httpToken = crypto.randomUUID();
const frame = (
<iframe
name="output"
id="output"
class="out"
srcdoc={(
<html style={"color-scheme:dark light;text-align:right;background:Canvas;height:100%"}>
<body style={"margin:0;height:100%;display:flex;align-items:center;justify-content:end;"}>
<code style="font-size:1rem">hit run "→"{"\xa0"}</code>
</body>
</html>
).toString()}
>
</iframe>
);
return (
<Layout title="OpenAPI Playground">
<style>
{String.raw`
body {
display: flex;
flex-direction: column;
font-family: system-ui, sans-serif;
}
textarea, .cm-editor {
display: block;
border: 1px solid GrayText;
border-bottom-width: 0;
margin: 0;
resize: none;
font-size: 1rem;
font-family: monospace;
flex-grow: 1;
}
textarea {
padding: 0.5rem;
background: Canvas;
color: CanvasText;
}
textarea:focus, .cm-editor:focus-within {
outline: 0;
border-color: SelectedItem;
border-bottom-width: 1px;
}
.toolbar {
--toolbar-bg: color-mix(in srgb, Canvas, CanvasText 10%);
background: var(--toolbar-bg);
border: 1px solid GrayText;
display: flex;
padding: 0.25rem;
padding-bottom: 0;
align-items: start;