Lasm 0.5.0
A breaking release. Upgrade with npm install -D @lasm/[email protected]; ^0.4.0 does not pick it up. Three changes need migration (below): Lasm.UI handlers run in the bubble phase, Attr.onWith is removed, and --output names the platform directory for edge, WASI and browser targets. Waits inside synchronous JavaScript callbacks now fail at once instead of hanging.
Breaking changes
Lasm.UI handlers run in the bubble phase. The applier now listens on the mount element in the bubble phase instead of the capture phase (docs/UI.md, "Event order"). A handler that stops propagation no longer keeps the event from its target's own listeners (including a web component's or widget's), from JavaScript listeners inside the app, or from the app's link routing; it still stops the outer Lasm handlers and listeners on the page around the app (
document,window). The order changes: JavaScript listeners on the target and on elements inside the app now run before the Lasm handlers (as with React's root delegation), and a JavaScript listener inside the app that callsstopPropagation()now keeps the event from the Lasm handlers. Events that do not bubble (focus,blur,mouseenter, …) still reach their handler; theirstopPropagationis no longer applied, since such an event goes no further than its target. In an application, a link whose handler stops propagation (without preventing the default) is now routed. Migration: code that relied on a Lasm handler running before JavaScript listeners inside the app should move that logic into Lean or listen in the capture phase.Attr.onWithis removed. It has been the same asonsince 0.4.0. Migration:Attr.onWith e d→on e d; a proof that listsAttr.onWithin asimpset just drops it, sinceonnow unfolds toAttr.custom.--outputnames the deployable directory for edge, WASI and browser targets.lasm build Main.lean --target workers --output DIR(likewisebun,deno,deno-deploy,supabase-edge,wasi,wasi-http,fastly,browser) now writes that target's directory toDIR. Without--outputeach target writes its usual directory in the project (workers/,bun/,wasi/, …), and no Node build is written todist/: the Node build these targets relink stays in the build cache.vercel-edgeandnetlify-edgerefuse--output, since the platform fixes their layout.nodeand the function platforms (lambda,vercel, …) are unchanged.Migration:
- Drop
--outputfrom platform builds that used it to move the Node build out of the way (lasm build Server.lean --target workers --output dist/server→lasm build Server.lean --target workers), or keep it if you want the platform directory there and update your platform config (for examplemaininwrangler.toml). - If you ran or packaged the
dist/that a platform build wrote, build it explicitly:lasm build Main.lean --target node(orlasm build Main.leanunder Node). - Delete a stale Node build left at a platform
--output; Lasm refuses to replace it and says so. - Remove
--outputfromvercel-edgeandnetlify-edgebuilds: it now fails the build. --target browser --output DIRstill writes the static site toDIR; only the default moved (to the project'sdist/, which matters only when building from outside the project).- To check you're done, search your scripts and CI for paths under the
dist/a platform build used to write (for exampledist/server/main.mjs).
- Drop
Fixes
- Lasm.JS: waits inside synchronous callbacks fail at once instead of never finishing. Inside a
Function.ofSyncFncallback, waiting for a Lean task that makes host calls (includingAsyncrun with.block), or for a timer, DNS lookup or socket read started in the callback, used to hang the program. It now ends the callback with an error that says what it waited for, as soon as every other Lean thread waits too (JavaScript gets the error; a Leantryinside the callback cannot catch it).Value.awaitand the…Awaitforms still fail as errors the callback can catch. A wait for a task that needs nothing from Node still works, andValue.toTaskwithout waiting no longer fails: the promise settles after the callback returns. Measured per-call costs (Lean→JS calls, synchronous callbacks, finished-task waits, promise awaits) show no slowdown.
Changes
- Edge and browser: a shorter stack-overflow message. A C-stack overflow on the edge (#115) now stops with "Stack overflow: the program used all of its 1 MiB C stack (deep recursion?). See https://github.com/Millillion/lasm/blob/main/docs/EDGE.md#stack". The original trap is still the error's
cause.
Documentation
- Bun, Deno and the edge: long
Asyncloops. AnAsyncloop (a recursion,for,List.mapM) of steps that complete at once overflows the JavaScript stack withRangeError: Maximum call stack size exceeded. Such steps are synchronous host calls,IOactions andpurevalues. The limit is about 2,000 steps on Deno and Workers and 8,000 on Bun; Node has no such limit. Awaited host calls are not affected. The limit and the workaround (Std.Async.sleep 0every 100 steps, or fewer host calls) are now documented in docs/BUN_DENO.md, docs/EDGE.md and FUNDAMENTAL_LIMITATIONS.md (#90).
Testing (no change to how programs build or run)
- Async loop depth in CI. The new
async-depthjob (differential.yml,scripts/ci/async-depth.mjs) measures the deepestAsyncloop on Node, Deno, Bun and workerd for each kind of step. It fails if a limit drops below half its measured value, or if theStd.Async.sleep 0workaround stops completing 100,000 steps (#90).