Lasm 0.4.0
A release with one breaking change to Lasm.UI, and bug fixes. Upgrade with npm install -D @lasm/[email protected]. It is 0.4.0, not 0.3.10, because npm treats a change in the minor version as breaking before 1.0: ^0.3.9 never picks up 0.4.0 by itself.
Breaking changes
- Lasm.UI handlers decide
preventDefaultandstopPropagationfor each event (#71).- Before:
preventDefaultOnandstopPropagationOnapplied a fixed option to every event the handler received, even when its decoder produced no message. A chat box could not send on Enter without either blocking all typing or inserting a newline. - Now: the decoder returns the decision with the message, as in Elm's
Html.Events. The applier already calls Lean synchronously from its DOM listener, so the decision is applied while the event is still being dispatched. A handler that produces no message (afilterMapreturningnone, a field of the wrong type) leaves the event alone. - New:
custom event (d : Decoder (Handled Msg))decides both;Handledis{ message, preventDefault := false, stopPropagation := false }. Subscriptions get the same four functions onwindowanddocument:Subs.on,Subs.preventDefaultOn,Subs.stopPropagationOn,Subs.custom, which take aTarget(.windowor.document). Ctrl+S can be prevented while every other key still types.Decoder.isComposingreadsevent.isComposing, so a chat box can leave Enter alone while an input method (Japanese, Chinese, Korean) is composing a word. - Migration:
preventDefaultOn e dbecomespreventDefaultOn e (d.map (·, true)), andstopPropagationOn e dbecomesstopPropagationOn e (d.map (·, true)).Attr.onWith e d (preventDefault := p) (stopPropagation := s)loses its flags:Attr.onWith e dison e d; usecustom e (d.map fun m => { message := m, preventDefault := p, stopPropagation := s })for the flags.Subs.onWindow e dbecomesSubs.on .window e d, andSubs.onDocument e dbecomesSubs.on .document e d. Their flags go the same way:Subs.preventDefaultOn .document e (d.map (·, true)).Listenerhas nopreventDefaultorstopPropagationfields, anAttr.onhandler returnsOption (Handled Msg), andSubSpec.window/SubSpec.documentare nowSubSpec.event target event paths.onSubmit,onClick,onInput,onEnter,onEscape,Subs.onKeyDownand the other shorthands keep their signatures and behaviour.
- Proofs:
onSubmitand the other shorthands now unfold throughAttr.custom. A proof that unfolds a view with a local simp set addsAttr.customto it, as the Conduit example'sProofs/View.leandoes. - Patch protocol: a listener (attribute op 5) is
5 event decoderId, without the flags (docs/BROWSER.md). - See UI.md.
- Before:
Fixes
- Downloads cut short are retried (PR #91).
- The bug: when a server closed the connection before the whole body arrived (
UND_ERR_RES_CONTENT_LENGTH_MISMATCH), installing Lean or a build tool failed on the first attempt. - The fix: that error is now retried like other network errors. A complete response that is too short is still an error.
- Tests: a new regression test in
test/managed-download.test.mjs. Found by a release-checks run on Linux arm64.
- The bug: when a server closed the connection before the whole body arrived (
- Packages with C code build on newer macOS SDKs (#73, PR #85).
- The bug: Lean's
ld64.lldrejected the SDK'slibSystem.tbdas "malformed file" when the SDK listed targets it doesn't know, such asarm64e.x1-macos. Packages withextern_liborprecompileModulesthen failed to link. - The fix: Lasm's copy of the stub keeps only the targets that linker reads. Your SDK is never modified. If the linker still refuses the copy, the build stops at once with an error that names the SDK and suggests
SDKROOT. - Tests: unit tests on synthetic stubs (tbd v3, v4 and v5), and a new CI job on macOS 15 (arm64 and Intel) and macOS 26 that builds a package with C code, first checking that the linker rejects the unfiltered stub.
- The bug: Lean's
lasm editorworks for projects whose packages have C code (#72, PR #86).- The bug:
lasm editor, and the editor setup afterinit,devandbuild, always linked the toolchain without a C compiler.lake buildand the language server then failed withlean/lean.h: No such file or directory, for example with lean-markdown's UnicodeBasic dependency. - The fix: the editor setup asks Lake which packages have C code, as
lasm builddoes, and links the toolchain with Lean's C compiler and headers when any do. Its message names those packages. The answer is cached, so a rerun takes about 0.6 s. - Tests: unit tests for the choice of toolchain, and a new editor CI project with a
precompileModulesdependency that runslasm editor,lake setup-fileand the language server, then removes the C code and expects the plain toolchain.
- The bug:
- A click shows its result in the same frame, even while another frame is waiting (PR #112).
- The bug: when a click or link click landed just after a response had scheduled a render, the applier only scheduled one more. A link click changed the address one animation frame before the page changed. Found as a one-off Conduit end-to-end failure on the Lambda image.
- The fix: discrete input and link clicks render at once when Lean asks for a frame or one is already waiting.
- Tests: a regression test in
test/ui-dom-applier.test.mjs(a click, a link click and a mousemove while a frame is waiting).
- Waiting for a JS promise inside a synchronous JS callback fails at once instead of hanging (PR #101).
- The bug:
Value.await,Value.toTask,callAwait,callMethodAwait,IObindings returning a promise andAsynccalls made inside a callback created withofSyncFnwaited forever, because the promise can only settle once the callback returns. - The fix: they now fail with a catchable IO error that names the reason. Starting a promise there without waiting for it fails too, since the host can't tell whether Lean will wait.
Async.blockand waits on a timer or socket the callback started still never finish (docs/JS_BINDINGS.md). - Also: host calls made by work Emscripten runs on the callback's thread are now served while the callback runs, where they could hang before.
- Tests: regression tests in
test/node-js-bridge.test.mjs,test/full-host-rpc-channel.test.mjsand the js-callbacks stress fixture on four platforms, and two new cases in the host-bridge model.
- The bug:
- Clearer errors, and no stack traces, from the CLI (PR #100, PR #103).
- The bugs: some file-system errors reached users as raw Node text (
EACCES … mkdir '…/.lake',ENOTDIR … scandir, a pathlessENOSPC … write). An output under a read-only directory printed a bare "Permission denied".lasm initonto an existing file, and an--outputthat is a file, gave errors that didn't name the file. A program withoutmaingot a misleading message about runtime Lean compilation. - The fix: each now says what failed, where, why and what to do. A program without
mainis told so. - Tests: an error corpus of 60 user-triggerable errors (
scripts/tooling/error-corpus.mjs), run in CI against the packed commit and the published CLI, plus regression tests intest/cli-error-messages.test.mjs.
- The bugs: some file-system errors reached users as raw Node text (
- Dev builds for the browser and the edge are reproducible and don't embed local paths (PR #103).
- The bug: they embedded the build's work directory (with a per-build ID) and the install directory, so two clean dev builds differed and the output exposed local paths.
- The fix: only file names are kept.
- Tests: a regression test in
test/edge-link-plan.test.mjs, and the new metamorphic tests (below).
- Rebuilds that change nothing leave the output alone (PR #103). A browser, edge or WASI rebuild used to delete and rewrite its whole output directory; an identical output is now left in place, which also helps file watchers. Regression test:
test/output-directory.test.mjs. IO.Process.exiton the edge and in the browser says why the instance stopped (PR #109).- The bug: an edge isolate (Workers, the other edge platforms, a browser page) can't exit, and the host refused the call with "Lean called IO.Process.exit n; an edge isolate cannot exit". The runtime then trapped at once, so users saw only "unreachable" (or Firefox's and WebKit's own wording).
- The fix: the refusal is kept and reported as the reason the instance stopped. The instance still stops.
- Tests: regression tests in
test/edge-host.test.mjsandtest/edge-runtime.test.mjs. Found by the new browser differential oracles.
Removed
- The retired Lean 4.32
lasm.jsonlibrary pipeline (PR #114).src/build.mjsand the modules, scripts, examples (basic,io,worker,express) and docs that only it used are gone. The published CLI already refusedlasm.jsonand still does, with the same message; only a source checkout could reach that code. The package loses those files and gains none.
Testing (no change to how programs build or run)
- Differential testing on Bun and in browsers (PR #109): Bun (release and
-O0) and headless Chromium, Firefox and WebKit run the generated programs and are compared with native Lean; Bun and Chromium on every PR, all five nightly. - Dependable tooling: metamorphic tests of the build (deterministic across directories and cold caches; incremental builds behave like clean ones; reverting a change restores the output) and fault injection (builds and installs killed at each stage, downloads cut, full disks, read-only and corrupted caches; 43 of 43 scenarios pass), nightly and on PRs that change them (docs/TESTING.md).
- The Lean 4.32 test files are ported (31 programs compared with Lean 4.35.0 in a new
host-fixturesCI job) or retired. Porting them found that, in a working directory without search permission, no Lean thread or child process could start; that is fixed, with regression tests. - Tested on Node 26.13.0 and 24.22.2 (PR #98). CI, the installed-package acceptance checks and the container images moved from 26.12.1 and 24.22.1.
lasm --versionreports the Node the package was built and tested with. - Tandem, a fifth example app: a collaborative text editor on a CRDT, with proofs, Yjs as a differential oracle, a live simulation, a protocol fuzzer and browser tests. Its sync server runs on Node, Bun, Deno, Workers and Docker, and its editor is a Lasm.UI app.