Repository navigation
Conversation
The page has the code on the left and the result on the right, and formats with the formatter compiled to WebAssembly, so the code never leaves the browser and the site still needs no server (openjavaformat/open-java-format#21). The result is what the command line writes for the same input. The module is not in this repository. scripts/fetch-playground.sh downloads open-java-format-wasm-<version>.zip from the GitHub release that ojf_version names, checks it against the release's checksums and unpacks it next to the page. docs.yml runs it before the build, and so do mise run serve and build. A release without the zip is a warning, not an error: the page then says that the playground comes with the next release, and follow-releases.yml turns it on with the redeploy it already runs for that release. A download that fails its checksum fails the build. The script comes through extra_javascript and sets the page up through document$, since the site navigates without reloading. The module, 8 MB over the wire, loads on this page only, once per visit. A browser without WebAssembly GC gets a sentence and a link to the command line instead of an empty pane.
The tab is white on the theme's blue, like the Format button and Get started on Home, so the page is easy to find from any other. It turns to the accent colour on hover and focus. The selector matches the end of the link, since the tab links are relative to the page.
Denis Pavlyuchenko suggested a playground that runs in the browser, on Telegram, and cobr123 built the first WebAssembly version of the formatter, which the module the page runs grew from.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A Playground page at
/playground/, after "Get started" in the navigation. Code goes on the left, the formatted result shows on the right, and the formatting runs in the browser. The formatter is compiled to WebAssembly by openjavaformat/open-java-format#196. The code is not sent anywhere, and the result is what the command line writes for the same input. Part of openjavaformat/open-java-format#21.docs/playground/index.md. Every message is in the Markdown, links included, so the strict build checks them; the script only shows the one that applies.docs/javascripts/playground.jsanddocs/stylesheets/playground.css, throughextra_javascriptandextra_css.document$, because the site navigates without reloading. On other pages it does nothing.GraalVM.runand learns from the promise whether loading failed.scripts/fetch-playground.shtakes the zip from the GitHub release thatojf_versionnames, checks it against that release'schecksums_sha256.txt, and unpacks the two files next to the page.docs.ymlruns it before the build, and so domise run serveandmise run build.OJF_WASM_ZIP=<zip>takes a module built locally instead.Before a release carries the module
21.0.1 has no zip. In that case the script writes a warning and the build carries on. The page then says that the playground comes with the next release and links to the command line.
follow-releases.ymlalready redeploys the site when a new release is out, so the page starts working with no change here. A zip that is present but fails its checksum fails the build.Tests
The tests ran with Playwright on a local build of the site, in Chromium 134, Firefox 135 and WebKit 18.4, against a module built from the formatter PR. All of these passed:
open-java-format-<version>-all.jar -for the starting example.class B {gives aline:columnerror.WebAssembly.validatereturning false, the page shows the unsupported-browser message.zensical build --clean --strictpasses with the module and without it. The fetch script was tried on all three paths: the real 21.0.1 release without the zip (a warning), a local zip, and a wrong checksum (fails).