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
export function sketch(module: string): (req: Request) => Response {
return function(req: Request): Response {
return new Response(
`
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"
integrity="sha512-N4kV7GkNv7QR7RX9YF/olywyIgIwNvfEe2nZtfyj73HdjCUkAfOBDbcuJ/cTaN04JKRnw1YG1wnUyNKMsNgg3g=="
crossorigin="anonymous"
referrerpolicy="no-referrer">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"
integrity="sha512-WzkwpdWEMAY/W8WvP9KS2/VI6zkgejR4/KTxTl4qHx0utqeyVE0JY+S1DlMuxDChC7x0oXtk/ESji6a0lP/Tdg=="
crossorigin="anonymous"
referrerpolicy="no-referrer">
</script>
<link rel="shortcut icon" href="https://p5js.org/assets/img/favicon.ico" />
<link rel="icon" href="https://p5js.org/assets/img/favicon.ico" />
<style>
* {
padding: 0px;
margin: 0px;
}
</style>
<script type="module">
import * as sketch from "${module}";
for (let f of Object.getOwnPropertyNames(sketch)) {
if (f !== "default") {
window[f] = sketch[f];
}
}
</script>
</head>
<body>
</body>
</html>`,
{ headers: { "Content-Type": "text/html" } },
);
};
}
export default async function(req: Request): Promise<Response> {
return new Response(
`
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"
integrity="sha512-N4kV7GkNv7QR7RX9YF/olywyIgIwNvfEe2nZtfyj73HdjCUkAfOBDbcuJ/cTaN04JKRnw1YG1wnUyNKMsNgg3g=="
crossorigin="anonymous"
referrerpolicy="no-referrer">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"
integrity="sha512-WzkwpdWEMAY/W8WvP9KS2/VI6zkgejR4/KTxTl4qHx0utqeyVE0JY+S1DlMuxDChC7x0oXtk/ESji6a0lP/Tdg=="
crossorigin="anonymous"
referrerpolicy="no-referrer">
</script>
<link rel="shortcut icon" href="https://p5js.org/assets/img/favicon.ico" />
<link rel="icon" href="https://p5js.org/assets/img/favicon.ico" />
<style>
* {
padding: 0px;
margin: 0px;
}
</style>
<script type="module">
import * as sketch from "https://esm.town/v/saolsen/p5_sketch";
for (let f of Object.getOwnPropertyNames(sketch)) {
if (f !== "default") {
window[f] = sketch[f];
}
}
</script>
</head>
<body>
</body>
</html>`,
{ headers: { "Content-Type": "text/html" } },
);
}