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
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const passedUrl = url.searchParams.get("url");
const passedSvg = url.searchParams.get("svg");
return new Response(
/* html */ `<html>
<head>
<script
src="https://cdn.jsdelivr.net/npm/@electric-sql/pglite@0.2.0/dist/index.js"
type="module"
></script>
</head>
<body>
<!-- Include the Repl web component in your page -->
<pglite-repl id="repl"></pglite-repl>
<script type="module">
import { PGlite } from 'https://cdn.jsdelivr.net/npm/@electric-sql/pglite/dist/index.js'
// Create a PGlite instance
const pg = new PGlite()
// Retrieve the Repl element
const repl = document.getElementById('repl')
// REPL to your PGlite instance
repl.pg = pg
</script>
</body>
</html>`,
{ headers: { "Content-Type": "text/html" } },
);
}