The source of osl-lang.org, the OSL documentation site: an interactive course, code-along projects, a page for every standard package and a reference for the language and its tools.
Pages are Markdown in content/. Every OSL example on them is compiled and run
by the real compiler at build time, and the site plays back what it printed.
Edited code is checked, built and run in the browser, with no server: the
compiler's front end built to WebAssembly turns it into Go, and Go's own
compiler and linker, built to WebAssembly too, build that into a program that
runs in a web worker.
Needs bun, Go and git.
bun install
bun osl:assets # build the compiler osl.json pins, osl.wasm and the package API
bun examples # compile and run new or changed examples, record their output
bun dev # serves on port 5180Before sending a change:
bun typecheck
bun test
bun examples:check # fails if an example has no recording for the pinned OSL
bun run build # static site in dist/, every route prerenderedThe site is deployed to Cloudflare Pages with wrangler pages deploy dist,
run from the repository root so that functions/ goes up with it.
functions/install.sh.ts serves /install.sh (the installer from the
compiler's repository); bun dev doesn't run it.
| Path | What's there |
|---|---|
content/learn/ |
The course, one lesson per page |
content/build/ |
Code-along projects (layout: project, one step per ##) |
content/packages/ |
A page per std: package; the API tables come from generated/api.json |
content/reference/ |
Language and tool reference, and the legacy OSL pages |
src/ |
The Preact app: pages, editor, quizzes, exercises, navigation |
src/nav.ts |
Sidebar order and labels |
vite/ |
Content loading, the .md copy of every page, llms.txt |
scripts/ |
osl-assets, examples and the prerender step |
tools/ |
The wasm and API-dump commands, built inside the pinned compiler |
tests/ |
bun test: the Markdown parser, share links, the router and the in-browser filesystem |
osl.json |
The OSL commit and version the site documents |
A page is Markdown with frontmatter (title, description, and layout for
projects). Fenced osl blocks are examples:
- an
outputfence straight after one is what it must print; osl norunis compiled but not run (servers, windows, files);osl errormust fail to compile,osl failsmust exit with a failure;osl fragmentis shown but not compiled;osl variesruns but its output isn't pinned (random numbers, time).
The full list of flags is at the top of src/lib/markdown.ts. Quizzes and
exercises are :::quiz and :::exercise containers closed by a ::: line;
see any lesson in content/learn/ for the shape. After editing examples, run
bun examples and commit generated/examples.json with the page.
Every page is also served as Markdown at its path plus .md, and the whole
site as /llms.txt and /llms-full.txt.
Point osl.json at the new commit and version, then:
bun osl:assets
bun examples --forceRun on an edited example or in the playground needs nothing but the browser.
bun osl:assets builds what it uses into public/osl/:
osl.wasm: the compiler's front end.oslBuildgives the Go files a js/wasm build of the program compiles: the generatedmain.goand the runtime sources it asks for, picked by build constraints.go/compile.wasm.gzandgo/link.wasm.gz: Go's compile and link commands built for js/wasm, andgo/pkg/: Go's standard library and the modules OSL's packages use, built for js/wasm, withgo/packages.jsonlisting each package's dependencies and the ones that don't build for js/wasm. They're gzipped (the compiler is over Cloudflare Pages' 25 MiB file limit raw).
public/osl/go-build.js runs compile and link over an in-memory filesystem
(memfs.js) holding the program and the archives it needs, and
public/osl/go-run.js runs the result, one fresh worker per run, so Stop ends
it. The first run downloads about 13 MB of compiler plus the packages the
program uses, and the browser caches them. Programs that use a package that
doesn't build for js/wasm (raylib's C code, SQLite) can't build in the
browser, and say so; ones that need a network, a server or other processes
build, but can't do those things there.