Skip to content

Lasm 0.4.0

Choose a tag to compare

@lastmjs lastmjs released this 21 Nov 18:18
fac8e5d

Lasm 0.4.0

A release with one breaking change to Lasm.UI, and bug fixes. Upgrade with npm install -D @lasm/cli@0.4.0. 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 preventDefault and stopPropagation for each event (#71).
    • Before: preventDefaultOn and stopPropagationOn applied 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 (a filterMap returning none, a field of the wrong type) leaves the event alone.
    • New: custom event (d : Decoder (Handled Msg)) decides both; Handled is { message, preventDefault := false, stopPropagation := false }. Subscriptions get the same four functions on window and document: Subs.on, Subs.preventDefaultOn, Subs.stopPropagationOn, Subs.custom, which take a Target (.window or .document). Ctrl+S can be prevented while every other key still types. Decoder.isComposing reads event.isComposing, so a chat box can leave Enter alone while an input method (Japanese, Chinese, Korean) is composing a word.
    • Migration:
      • preventDefaultOn e d becomes preventDefaultOn e (d.map (·, true)), and stopPropagationOn e d becomes stopPropagationOn e (d.map (·, true)).
      • Attr.onWith e d (preventDefault := p) (stopPropagation := s) loses its flags: Attr.onWith e d is on e d; use custom e (d.map fun m => { message := m, preventDefault := p, stopPropagation := s }) for the flags.
      • Subs.onWindow e d becomes Subs.on .window e d, and Subs.onDocument e d becomes Subs.on .document e d. Their flags go the same way: Subs.preventDefaultOn .document e (d.map (·, true)).
      • Listener has no preventDefault or stopPropagation fields, an Attr.on handler returns Option (Handled Msg), and SubSpec.window/SubSpec.document are now SubSpec.event target event paths.
      • onSubmit, onClick, onInput, onEnter, onEscape, Subs.onKeyDown and the other shorthands keep their signatures and behaviour.
    • Proofs: onSubmit and the other shorthands now unfold through Attr.custom. A proof that unfolds a view with a local simp set adds Attr.custom to it, as the Conduit example's Proofs/View.lean does.
    • Patch protocol: a listener (attribute op 5) is 5 event decoderId, without the flags (docs/BROWSER.md).
    • See UI.md.

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.
  • Packages with C code build on newer macOS SDKs (#73, PR #85).
    • The bug: Lean's ld64.lld rejected the SDK's libSystem.tbd as "malformed file" when the SDK listed targets it doesn't know, such as arm64e.x1-macos. Packages with extern_lib or precompileModules then 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.
  • lasm editor works for projects whose packages have C code (#72, PR #86).
    • The bug: lasm editor, and the editor setup after init, dev and build, always linked the toolchain without a C compiler. lake build and the language server then failed with lean/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 build does, 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 precompileModules dependency that runs lasm editor, lake setup-file and the language server, then removes the C code and expects the plain toolchain.
  • 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, IO bindings returning a promise and Async calls made inside a callback created with ofSyncFn waited 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.block and 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.mjs and the js-callbacks stress fixture on four platforms, and two new cases in the host-bridge model.
  • 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 pathless ENOSPC … write). An output under a read-only directory printed a bare "Permission denied". lasm init onto an existing file, and an --output that is a file, gave errors that didn't name the file. A program without main got a misleading message about runtime Lean compilation.
    • The fix: each now says what failed, where, why and what to do. A program without main is 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 in test/cli-error-messages.test.mjs.
  • 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.exit on 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.mjs and test/edge-runtime.test.mjs. Found by the new browser differential oracles.

Removed

  • The retired Lean 4.32 lasm.json library pipeline (PR #114). src/build.mjs and the modules, scripts, examples (basic, io, worker, express) and docs that only it used are gone. The published CLI already refused lasm.json and 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-fixtures CI 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 --version reports 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.