ruff/playground/knot/index.html
Micha Reiser c027979851
Red Knot Playground (#12681)
## Summary

This PR adds a playground for Red Knot

[Screencast from 2024-08-14
10-33-54.webm](https://github.com/user-attachments/assets/ae81d85f-74a3-4ba6-bb61-4a871b622f05)

Sharing does work 😆 I just forgot to start wrangler. 


It supports:

* Multiple files
* Showing the AST
* Showing the tokens
* Sharing
* Persistence to local storage

Future extensions:

* Configuration support: The `pyproject.toml` would *just* be another
file.
* Showing type information on hover

## Blockers

~~Salsa uses `catch_unwind` to break cycles, which Red Knot uses
extensively when inferring types in the standard library.
However, WASM (at least `wasm32-unknown-unknown`) doesn't support
`catch_unwind` today, so the playground always crashes when the type
inference encounters a cycle.~~

~~I created a discussion in the [salsa
zulip](https://salsa.zulipchat.com/#narrow/stream/333573-salsa-3.2E0/topic/WASM.20support)
to see if it would be possible to **not** use catch unwind to break
cycles.~~

~~[Rust tracking issue for WASM catch unwind
support](https://github.com/rust-lang/rust/issues/118168)~~

~~I tried to build the WASM with the nightly compiler option but ran
into problems because wasm-bindgen doesn't support WASM-exceptions. We
could try to write the binding code by hand.~~

~~Another alternative is to use `wasm32-unknown-emscripten` but it's
rather painful to build~~
2025-03-18 17:17:11 +01:00

39 lines
1.6 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="referrer" content="no-referrer-when-downgrade" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<meta name="msapplication-TileColor" content="#d7ff64" />
<meta name="theme-color" content="#ffffff" />
<title>Playground | Red Knot</title>
<meta
name="description"
content="An in-browser playground for Red Knot, an extremely fast Python type-checker written in Rust."
/>
<meta name="keywords" content="ruff, python, rust, webassembly, wasm" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@astral_sh" />
<meta property="og:title" content="Playground | Ruff" />
<meta
property="og:description"
content="An in-browser playground for Ruff, an extremely fast Python type-checker written in Rust."
/>
<meta property="og:url" content="https://play.ruff.rs" />
<meta property="og:image" content="/Astral.png" />
<link rel="canonical" href="https://playknot.ruff.rs" />
<link rel="icon" href="/favicon.ico" />
<script
src="https://cdn.usefathom.com/script.js"
data-site="XWUDIXNB"
defer
></script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>