Repository navigation
Lasm 0.9.0
Lasm 0.9.0
A minor release with many breaking changes: the first release of Stage 0, which settles Lasm's public API before 1.0. Upgrade with npm install -D @lasm/cli@0.9.0; ^0.8.0 does not pick it up. Every breaking change has a migration note below, under "Breaking changes and migration".
What breaks: the function platforms (AWS Lambda and Lambda@Edge, Vercel, Netlify, Azure Functions, Google Cloud Functions) no longer run an HTTP server inside the function; the program publishes a fetch handler with exportDefault and the generated platform file calls it directly (#222). The fetch and hono templates write one entry module per serving model, the Lambda container image is Lambda's own Node image, and HTTP on WASI is wasi-http only (#322); the fullstack template speaks plain REST and keeps its todos through each platform's own store (#331, #344). Lasm.RPC is deleted (#341). On the CLI, lasm build takes one Lean source and names its output only with --output, --output names the package on function platforms, lasm version is gone, and lasm init --deploy lambda now writes the .zip setup (#304, #316). The generated bindings follow one set of rules, which renames two FormData methods and makes Node's integer arguments Nat (#301). Lasm.UI is cut to its core: its HTTP, storage, focus, title and other browser commands are gone, and effects go through Cmd.task with the generated browser bindings (#311). Lasm.JS.Web is the whole web platform, one module per spec with no umbrella module, and Lasm.JS.Web.Browser is gone (#319); lasm build --target refuses a web API the target lacks unless the program checks for it with the API's guard X? (#319, #337); Lasm.JS.Node, Lasm.JS.Deno, Lasm.JS.Bun and Lasm.JS.Cloudflare have no umbrella modules either, so every program imports the binding modules it uses (#317, #320, #329). A few generated names change (#301, #307, #312, #317, #319, #320).
What's new: Node.serve, a Lean server on Node shaped like Bun.serve, with no npm dependencies (#222); Lasm.JS.Cloudflare, every API of Cloudflare Workers' own declarations (KV, D1, R2, Durable Objects, Queues, Workers AI, Vectorize, Hyperdrive and the rest), with the Worker's env typed (#216, #320); Lasm.JS.Node is every documented Node core module, with typed event listeners (#220, #317); the whole web platform from Lean: IndexedDB, WebGL, WebGPU, Web Audio, WebRTC and every other spec of webref (#319); Lasm.JS.Deno and Lasm.JS.Bun are the whole Deno and Bun namespaces, with Deno KV, bun:sqlite and WebSockets in Bun.serve (#307, #312); Lasm.JS binds the project's own JavaScript files and defines JavaScript classes from Lean (#309); checked downcasts (I.cast?) on every generated interface (#301); helpers for whole bodies and responses in Lasm.WASI.Http (#306). Generated binding modules outside a small core set now ship as Lean source and compile on first import, so the package does not grow with them (#313, #321), and Lake builds them in the editor too (#332).
Lasm.Fetch and Lasm.KV still ship in 0.9.0; their removal is decided and follows in a later release. Every API decision is recorded, with its alternatives, in docs/API_DECISIONS.md and the per-milestone files in docs/api/decisions/, each pending Jordan's sign-off at the end of its milestone.
Breaking changes and migration
Function platforms call the program's fetch handler directly (#222)
-
lasm packageandlasm build --target netlify|vercel|lambda|lambda-edge|azure|gcf
no longer run an HTTP server. The program publishes a fetch handler with
Lasm.JS.exportDefault, as on Cloudflare Workers. The platform file that
Lasm generates exports the handler the platform expects and calls it in the
same process: there is no$HOST/$PORTserver, no free port and no
loopback forwarding.- Netlify:
export default async (request, context) => …. - Vercel and Google Cloud Functions: Node's
(req, res)as a webRequest,
with theResponsestreamed back. - AWS Lambda and Lambda@Edge: each event shape as a
Request, and the
Responseas the event's result. - Azure Functions: the
Request, and theResponseasHttpResponseInit.
The security fixes stay in place: the Host checks, the Cookie and
Set-Cookie handling, base64 bodies,__proto__header names, decoded paths,
and empty replies (#80, #82). - Netlify:
-
What breaks: a program that brings its own HTTP server (Express,
Fastify,Std.Http, orNode.serve) can no longer be packaged for a
function platform. Port it to a fetch handler:Before Now mainlistens on$HOST:$PORT(Express, Hono on@hono/node-server,Std.Http)def main : IO Unit := exportDefault handle, withhandle : Request → Async Response(orexportDefault appfor a Hono app)src/serverless/lasm-server.mjsin the packagelasm-function.mjsandlasm-node-serve.mjsRepeated response fields other than Set-Cookie now reach Lambda REST and ALB
multi-value replies joined (x: p, q), as a webResponseholds them. A
handler that throws is answered with a 500. A request that no webRequest
can hold (TRACE, CONNECT, the target*) is answered with a 400.
Templates serve with one entry module per platform kind (#322)
-
lasm init --template fetchwritesHandler.lean(the handler),
Main.lean(Node:Node.serve { fetch := Handler.handle }) and
Export.lean(exportDefault Handler.handle, built bybuild:bun,
build:denoand every edge and function-platformbuild:<target>). It no
longer importsLasm.Fetch, and no program branches onLasm.JS.onEdge. -
lasm init --template honowritesRoutes.lean(the Hono app),
Main.lean(Node,@hono/node-server) andExport.lean
(exportDefault (← Routes.app)). -
The function platforms (
--deploy lambda,lambda-container,lambda-edge,
vercel,netlify,azure,gcf) take the fetch and hono templates.
express, fastify and std-http bring their own server, so they have no
--deploytarget: they run wherever theirDockerfileruns. -
--deploy lambda-container'sDockerfile.lambdais Lambda's own Node 24 image with
the .zip package's files andCMD ["lasm-lambda.handler"]: the runtime calls
the handlerExport.leanpublishes. The AWS Lambda Web Adapter (which ran a
server inside the function) is gone, withdeploy/lambda/Dockerfile. -
--deploy wasiis for the plain template (command-line programs). The
fetch template'sCgi.leanis gone: HTTP on WASI is wasi-http
(--deploy wasi-http,spin). -
lasm init --template fullstackspeaks plain REST (#331). The
server answersGET/POST /api/todos,PATCH/DELETE /api/todos/ID
(JSON in and out,{"error"}on 4xx) instead ofPOST /rpc/<name>, and the
browser app calls it with the web'sfetchthroughCmd.task. The template
no longer importsLasm.RPCorLasm.Fetch:Server.leanserves Node with
Node.serve,Export.leanpublishes the default export for Bun, Vercel
Edge and Netlify Edge,Fastly.leanandWasiHttp.leanserve their
platforms, andHttp.lean,Embed.leanandSite.leanare the template's
own code. It has a program per store, each through the platform's own API,
and noLasm.KV(#344):Workers.leantakes the Worker's bindings as a
typedEnv(TODOS : KVNamespace;wrangler.tomldeclares the binding),
Deno.leanuses Deno KV,Fastly.leanthe Fastly KV StoreTODOS; Node,
Bun, Vercel Edge, Netlify Edge and wasi-http keep them in memory. A declared
store that is missing is an error naming it, never a silent fallback to
memory.build:workersbuildsWorkers.lean, andbuild:denoand
build:deno-deploybuildDeno.lean. The
store still takes only validated titles:ValidTitle, a title with its
proof. Migrating a project made by 0.8.0: replace theEndpointdefinitions
with routes in amatchon method and path segments, and eache.callwith
aCmd.taskthat callsLasm.JS.Web.fetch, as the new template does.
Migrating a project made by 0.8.0's fetch template:
| Before | Now |
|---|---|
Main.lean: handle, then if ← onEdge then exportDefault … else serveNode |
Handler.lean: handle; Main.lean: def main := Node.serve { fetch := Handler.handle }; Export.lean: def main := exportDefault Handler.handle |
"build:workers": "lasm build Main.lean --target workers" (and the other edge, Bun, Deno and function targets) |
lasm build Export.lean --target … |
Cgi.lean, "build:wasi" |
WasiHttp.lean, "build:wasi-http" |
The CLI (#304, #316, #318)
lasm buildtakes one Lean source; the output is named only with
--output(0.7-2).lasm build Main.lean distnow
fails withUnexpected argument "dist": lasm build takes one Lean source. Name the output with --output.Migration:lasm build Main.lean dist→
lasm build Main.lean --output dist.- With a function platform,
--outputnames the package (0.7-5).
lasm build Main.lean --target lambda --output app.zipwrites
app.zip; before,--outputnamed the Node build and the package went to
its default place. As with the edge, WASI and browser targets since 0.5.0,
the Node build a package is made from now stays in the build cache
(.lake/lasm/), solasm build --target lambda(lambda-edge,vercel,
netlify,azure,gcf) no longer writesdist/. Migration: drop
--outputto keep the default package place, or pass the package's path;
to also keep a Node build, runlasm build Main.lean(writesdist/) and
lasm package --target lambda. lasm versionis gone;lasm --versionandlasm -vprint the
version (0.7-1). Migration:lasm version→lasm --version.lasm init --deploy lambdawrites the Lambda.zipsetup
(npm run build:lambda, which was--deploy lambda-zip); the container image
(Dockerfile.lambda) is now--deploy lambda-container(0.7-9). Every
--deployname is now thelasm build --targetit builds, except
lambda-containerandspin. Migration:--deploy lambda-zip→
--deploy lambda;--deploy lambda→--deploy lambda-container. Existing
projects are unchanged (lasm initwrites files once).- The same option rules in every command (0.7-23):
lasm devrefuses--dev
with--release(Choose one of --dev and --release) and a repeated
--target,--port,--hostor--output(Specify --port only once), as
lasm builddoes;lasm initrefuses a repeated--template. An unknown
lasm dev --target,lasm init --templateorlasm init --deployvalue
names the closest one, aslasm build --targetdoes:
lasm dev --target worker→… not "worker" (did you mean --target workers?).
Migration: give each option once. lasm build lasm.jsonis refused as not a Lean source (0.7-15,
#318):Expected a Lean source file (Main.lean), not lasm.json, like any
other non-.leaninput. Thelasm.jsonpipeline was retired on 2026-11-03;
only its stale message is gone. No migration: such builds already failed.
Generated bindings follow one set of rules (#301)
- One set of rules for every generated binding
(docs/BINDING_RULES.md, API decisions A9–A12). FormData.appendWithBlobValueis nowFormData.appendBlob, and
FormData.setWithBlobValueis nowFormData.setBlob(A9.1). Migration:
rename the calls.- In
Lasm.JS.Node, a documented{number}that is an integer is nowNat
(orIntforpid) instead ofFloat(A11.1). Migration: pass whole
numbers (crypto.randomBytes 32, not32.0). This affects:crypto.randomBytes,crypto.pbkdf2,crypto.hkdfandcrypto.scrypt
(sizes, key lengths, iterations, andScryptOptions);process.kill'spid(Int);FileHandle.fd;- the
uid,gid,timeoutandmaxBufferoptions ofchild_process; highWaterMarkin the stream options.
Lasm.JS.Web is the whole web platform, one module per spec (#319)
-
Lasm.JS.Webis the whole web platform, one module per spec, and
Lasm.JS.Web.Browseris gone (decisions 0.3-1, 0.3-2, 0.3-18). Every spec
of w3c/webref is generated as it is, and each spec is the module
Lasm.JS.Web.<Spec>. There is no umbrella module. Migration: names do not
change; imports do:Before Now import Lasm.JS.Web(the WinterTC subset)the modules you use: import Lasm.JS.Web.Fetch,Lasm.JS.Web.Url,Lasm.JS.Web.Dom(events,AbortController),Lasm.JS.Web.Webcrypto(crypto),Lasm.JS.Web.Html(timers,atob,structuredClone,navigator,MessageChannel),Lasm.JS.Web.Streams,Lasm.JS.Web.Encoding,Lasm.JS.Web.FileAPI(Blob),Lasm.JS.Web.Xhr(FormData),Lasm.JS.Web.Webidl(DOMException)import Lasm.JS.Web.Browserimport Lasm.JS.Web.DomandLasm.JS.Web.Html(the tree, the elements, the window, canvas 2D),Lasm.JS.Web.Uievents,Lasm.JS.Web.Cssom,Lasm.JS.Web.Geometry,Lasm.JS.Web.Websockets, …import Lasm.JS.Web.Messaging,.Timers,.Globalimport Lasm.JS.Web.Htmlimport Lasm.JS.Web.File,.Crypto,.Performance,.Wasm,.WebSocket.FileAPI,.Webcrypto,.HrTime,.WasmJsApi,.WebsocketsThe members the browser tier had left out, or that are in other specs, are
now there too (CanvasRenderingContext2D.filter,Element.animate,
Navigator.clipboard). -
lasm build --target Xrefuses a web API that X does not provide
(decision 0.3-10), with an error that names the API, the target and where it
is available, from@mdn/browser-compat-data(browsers, Node, Deno) and
runtime-compat data (Bun, Workers, Vercel Edge, Netlify Edge). A program that
used, say,documentin a server build now fails to build instead of
failing when it runs. -
Web enums are strings with named values (decision 0.3-17).
RequestMode,
KeyUsageand every other WebIDL enum is
structure E where unsafeOfString :: val : String, with one match pattern
per value (.noCors). Equality and construction are unchanged
((← res.type) == .basic). Migration: amatchon an enum needs a final
| _ => …, because a runtime may return a value newer than the pinned IDL,
which now reads as it is instead of failing. -
Lasm.JS.Web.Support's helpers moved toLasm.JS.Web.Internal
(decision 0.3-3). They are internal to the generated bindings: use
Lasm.JSdirectly.Lasm.JS.Web.Recordis unchanged. -
An overload that differs only in its argument types is named after them
(A9.2):RTCDataChannel.sendWithBlob,sendWithArrayBuffer.
Lasm.JS.Node, Lasm.JS.Deno, Lasm.JS.Bun and Lasm.JS.Cloudflare have no umbrella modules (#317, #320, #329)
import Lasm.JS.Node,import Lasm.JS.Deno,import Lasm.JS.Bunand
import Lasm.JS.Cloudflareare gone (0.4-21 and the 0.4 and 0.5
decisions). Import the modules whose members you call, and a program
compiles and links only those:- Node:
import Lasm.JS.Node.Fs,.Path,.Crypto,.Http, … - Deno:
import Lasm.JS.Deno.ServeforDeno.serve,import Lasm.JS.Deno.Kv
for Deno KV, … - Bun:
import Lasm.JS.Bun.ServeforBun.serve,import Lasm.JS.Bun.Sqlite
forbun:sqlite, … - Cloudflare:
import Lasm.JS.Cloudflare.Kv,.D1,.Workers,.Handlers
(ExportedHandler),.Queues(the queue handler), …
- Node:
Lasm.JS.Node:crypto.randomUUID(andgetRandomValues,subtle)
moved toLasm.JS.Web:import Lasm.JS.Web.Webcrypto, then
(← Lasm.JS.Web.crypto).randomUUID.Buffer.from s (some "hex")is
Buffer.fromWithString s (some "hex")(Buffer.fromhas four documented
forms:fromWithString,fromWithArrayBuffer,fromWithBuffer,
fromWithObject). Other names whose documented form gained overloads follow
the same rule;scripts/bindings/node-surface.jsonlists every generated
name.Lasm.JS.Cloudflare: overloads with the same parameter names give the
plain name to the least constrained one (R2Bucket.get key (options?)), and
overloads are named for what they do (0.5-17, #336):KVNamespace.getMany
(andgetManyText,getManyJson,getManyWithMetadata…) read several keys
at once;Ai.runis the common call, andrunStream,runWebSocket,
runRawResponseandrunOtherModelare its other forms;
AiSearch*.chatCompletionsStream,ToMarkdownService.transformMany,
Ai.toMarkdownFile/toMarkdownFilesand
WorkflowStep.doWithDelayFunction/doWithStaticDelaycomplete the set.
Lasm.UI is cut to its core; browser effects go through Cmd.task (#311)
-
Cmd.task (run : Async Msg)runs any action with the generated browser
bindings (import Lasm.JS.Web.Dom,Lasm.JS.Web.Html,Lasm.JS.Web.Fetch, …) and delivers its message;
Lasm.UI.afterFramewaits for the next frame.Cmd.delay,Cmd.pushUrland
Cmd.replaceUrlstay (0.6-8, A35). Migration:Before After Http.get url .loadedCmd.task do let r ← Lasm.JS.Web.fetch (.usvString url); return .loaded (← r.text)(catch errors withtry … catch)Http.post url body h,Http.request req hthe same, with some { method := some "POST", body := some (.usvString body), headers := … }Cmd.storageSet k vCmd.ofEffect (.task fun _ => do (← Lasm.JS.Web.localStorage).setItem k v)Cmd.storageGet k hCmd.task do return h (← (← Lasm.JS.Web.localStorage).getItem k)Cmd.storageRemove k… (← Lasm.JS.Web.localStorage).removeItem kCmd.focus id,Cmd.blur idCmd.ofEffect (.task fun _ => do afterFrame; …getElementById id… .focus)(docs/UI.md, "Commands")Cmd.title t… (← Lasm.JS.Web.document).setTitle tCmd.port name v… (← Lasm.UI.Mount.port name).send vCmd.now h,Cmd.randomBytes n hCmd.taskwithDate.now/crypto.getRandomValues, or Lean'sIO.monoMsNow/IO.getRandomBytesCmd.back n,Cmd.forward n,Cmd.load urlhistory.go,location.assignthroughCmd.ofEffect (.task …)Cmd.io runCmd.ofEffect (.task fun deliver => run deliver)Apps that want to test their effects declare them as data and interpret
them (docs/UI.md, "Effects you can test"; examples/ui/todomvc).
Lasm.JS.Deno and Lasm.JS.Bun (#307, #312)
Lasm.JS.Deno.TlsCertifiedKeyPemKeyFormatis now
Lasm.JS.Deno.ServeTcpTlsOptionsKeyFormat(the type of
ServeTcpTlsOptions.keyFormat; its constructor.pemis unchanged).Lasm.JS.Deno.NetAddrmoved fromLasm.JS.Deno.ServetoLasm.JS.Deno.Net
(import Lasm.JS.Deno.Servestill brings it).Deno.utime,utimeSyncandFsFile.utimetakeDatafor the times (a
number of seconds or aDate):toJS (1000000 : Float). A union with an
object member (number | Date) is nowData.Lasm.JS.Bun.ServeOptions.fetchis optional (Option ServeOptionsFetch): a
value still coerces ({ fetch, port := … }compiles unchanged).
ServeOptionsgainsroutes,websocket,unix,tls,developmentand
thehttp1/http2/http3flags.
Lasm.RPC is deleted (#341)
Lasm.RPC,Lasm.RPC.Core,Lasm.RPC.ServerandLasm.RPC.Clientare
gone (API decision 0.6-13), with docs/RPC.md, their 13 proved propositions
and 4 candidates (library/PROOFS.md) and thelean-rpcfuzz target. A server
and a browser app share plain Lean types and talk plain REST over each
host's own fetch API. Migration, aslasm init --template fullstacknow
does it (templates/fullstack):- server: replace each
EndpointandEndpoint.servewith a route, a
matchon the request's method and path segments (GET/POST /api/todos,
PATCH/DELETE /api/todos/ID) that reads the JSON body, validates it once
and hands the handler the validated value as a subtype
(ValidTitle := { t : String // checkTitle t = .ok () }), answering JSON
and{"error"}with a 4xx status when validation fails; - browser: replace each
e.call req onResultwith aCmd.taskthat calls
Lasm.JS.Web.fetchand decodes the answer withFromJson; - for request bodies from the network, use a
parseJsonthat refuses
exponents of more than four digits (Lean's parser computes
10 ^ exponent), as the template'sShared.leanand the examples'
SafeJsonmodules do.
- server: replace each
Lake projects require Lasm's library as a package (#332)
-
A Lake project requires Lasm's library as a Lake package (decision 0.3-7).
lasm initwrites this in the templates that use the library, and
npx lasm editoradds it to an existing project:[[require]] name = "lasm" path = ".lake/lasm-library"
Every lasm command also writes Lasm's package into
lake-manifest.json, as
lake updatedoes, keeping the project's other packages (#338).
Migration: runnpx lasm editoronce in an existing Lake project to add the
require. On a fresh clone, run any lasm command once (npm run dev,
npx lasm editor) before a plainlake build.
Lasm.WASI.Http exports respond (#306)
Lasm.WASI.Httpnow importsLasm.WASI.Http.Respond, which defines
respondand the other helpers below. Migration: a program that defines its
own top-levelrespondwhileopen Lasm.WASI.Httprenames it or refers to
it with its namespace.
New
Node.serve (#222)
Node.serve(import Lasm.JS.Node.Serve) serves a Lean
Request → Async Responseon Node:Node.serve { fetch := handle, port := some 3000 }.
It is provided by Lasm, not a Node API, and shaped likeBun.serve.- Options:
fetch,port,hostname,signal,onListen,error. - Server handle (passed to
onListen):hostname,port,url,
stop,finished. - Lifetime: it returns once the server stops (
stop, the signal,
SIGTERM or SIGINT). - Behavior: bodies stream both ways with backpressure, and a client that
goes away abortsrequest.signal. Each Set-Cookie line is sent on its
own. HEAD and null-body statuses send no body. An empty body is sent with
content-length: 0and no content type added. A forged Host cannot change
the request's URL. - Dependencies: none from npm.
- Options:
- Typed
exportDefault:exportDefault handletakes a Lean function
directly, and anyToJSvalue (it took aValue), so a handler object such
as anExportedHandlercan be published as it is.exportDefault (v : Value)
still works.
Lasm.JS.Cloudflare, Cloudflare Workers' runtime APIs (#216, #320)
-
Lasm.JS.Cloudflare.*(import Lasm.JS.Cloudflare.Kv,.D1,.Workers, …) binds the runtime APIs of Cloudflare
Workers, generated from Cloudflare's own TypeScript declarations
(@cloudflare/workers-types5.20261019.1, pinned by hash): Workers KV
(KVNamespace), D1 (D1Database, prepared statements, batches, sessions),
R2 (R2Bucket, objects, ranges, conditions, checksums, multipart uploads),
Durable Objects (namespaces, ids, stubs,DurableObjectStateand its
storage, transactions and alarms), Queues (Queue.send,sendBatch;
MessageBatchandMessagein the queue handler), the handler's
ExecutionContext(waitUntil,passThroughOnException), the Cache API
(caches), TCP sockets (connectofcloudflare:sockets) andenvof
cloudflare:workers. Lasm.JS.Web'sRequest,Responseand streams are
their web types. A Worker publishes anExportedHandlerwithfetch,
scheduledandqueue:import Lasm.JS import Lasm.JS.Cloudflare.Kv import Lasm.JS.Cloudflare.Workers import Lasm.JS.Cloudflare.Handlers open Lasm.JS Lasm.JS.Web Lasm.JS.Cloudflare structure Env where KV : KVNamespace -- wrangler.toml: [[kv_namespaces]] binding = "KV" deriving FromJS def main : IO Unit := do let fetch ← ExportedHandlerFetchHandler.ofFn fun _request (env : Env) ctx => do let hits := ((← env.KV.get "hits").bind String.toNat?).getD 0 ctx.waitUntil (← Async.toPromise (env.KV.put "hits" (.domString (toString (hits + 1))))) Response.new (some (.usvString s!"{hits + 1}")) none let scheduled ← ExportedHandlerScheduledHandler.ofFn fun controller (env : Env) _ => do env.KV.put "last-cron" (.domString (← controller.cron)) exportDefault ({ fetch := some fetch, scheduled := some scheduled } : ExportedHandler)
The handlers receive the Worker's
envtyped: the program declares its
bindings as a structure withderiving FromJS, and each handler'sofFntakes
it as a type parameter (Dataalso works). Build with
lasm build Main.lean --target workers. A Durable Object's
class stays a few lines of JavaScript that call Lean functions. Guide,
coverage and mapping rules: docs/JS_BINDINGS.md, "Cloudflare Workers:
Lasm.JS.Cloudflare". Tested underwrangler devwith local emulation only. -
Every API of Cloudflare's own in
@cloudflare/workers-typesis
generated (#320), 838 declarations in 24 modules: besides KV, D1, R2,
Durable Objects and Queues, also Workers AI with every model's inputs and
outputs (Lasm.JS.Cloudflare.Ai), AI Gateway and AI Search, Vectorize,
Hyperdrive, Images, Email, Tail Workers and tracing, Containers, Workflows,
service bindings and RPC, Browser Rendering, Analytics Engine, Stream,
HTMLRewriter and the other bindings.Support,Kv,D1andWorkers
ship compiled; the others compile on first import. -
Lasm.JS.Async.toPromise : Async α → IO Valuestarts a LeanAsync
computation and returns a JavaScript promise of its result, for APIs that take
a promise of running work (Workers'ctx.waitUntil,state.waitUntil). -
The Workers entry forwards cron triggers, queue batches and the other
events. The generatedworkers/worker.mjsnow exportsscheduled,
queue,email,tail,trace,tailStream,connectandtestbesides
fetch, calling the published object's methods of those names (a handler
without them fails those events with a message saying so), and imports
cloudflare:workersandcloudflare:socketsforLasm.JS.Cloudflare.
Lasm.JS core (#309)
- Bind your own JavaScript files (A6.1):
@[js "./ffi/stream.mjs" "writeAndEnd"]names an ES module of the project,
relative to the Lean file, andlasm buildships it, with the files it
imports by relative path, on every target. A localfile:npm package used
only for this can become a project file. - JavaScript classes from Lean (A6.2):
Lasm.JS.Class.define(import Lasm.JS.Class) makes a realclass Name extends Basewhose constructor,
methods and getters are Lean functions giventhis, for APIs that take a
class (customElements.define,Errorsubclasses). - Functions made with
Function.ofFnreport theirlength(A4).
ofFn,ofFnReplyandofSyncFntake(length := 0);ofFn1reports 1,
ofFn2andofSyncFn2report 2. APIs that read a function'slengthnow
work with Lean handlers:Deno.servepasses its request to an
ofFn1/ofFn2handler, andFunction.ofFn (length := 4)is an Express
error handler. A program that relied onofFn1orofFn2reporting 0
passesFunction.ofFninstead. - The binding check only warns about a global the build's target provides
(A5).@[js "globalThis" "Deno.serve"]and other globals that Node lacks
now build for--target deno,bun, the edge targets andbrowser, with a
warning; a Node build still fails on them.
Standard bindings: Node, Deno and Bun (#220, #307, #312)
Lasm.JS.Nodeis every Node core module (#317; decisions 0.4-33 to
0.4-38): all of Node's documented modules (zlib,dns,tls,http2,
worker_threads,util,v8,vm,sqlite,readline,node:test, …),
the callback and synchronous forms ofnode:fs, and Experimental,
Deprecated and Legacy members (marked in their doc comments), plus what only
Node 26 documents (marked "Node.js 26 and later"). Example:
examples/node-core. The core set (fs,path,os,process,buffer,
crypto,child_process,events,stream, withasync_hooks,netand
readline) ships compiled; every other module compiles on first use.node:net,node:httpandnode:https(#220):
import Lasm.JS.Node.Net,.Http,.Httpsgives
net.createServer,net.connect,net.Server,net.Socket,
net.BlockList,net.SocketAddress;http.createServer,http.request,
http.get,http.Server,http.IncomingMessage,http.ServerResponse,
http.ClientRequest,http.Agent; and thehttpsequivalents, generated
from Node 24.22.2's documentation like the rest ofLasm.JS.Node
(docs/JS_BINDINGS.md, "Standard bindings for Node"; API decisions A18,
0.4-30 to 0.4-32).- Documented Node events are typed listeners.
server.onRequest,
socket.onData,req.onceResponse,child.onceExit,stream.onEnd, …
take a listener made from a Lean function of the event's documented
arguments (http.Server.RequestListener.ofFn fun req res => …), on every
generated class.ChildProcess's'exit'and'close'give the exit code
and signal asOptions. stream.Readableandstream.WritableareEventEmitters and gain
pause,resume,isPaused,setEncoding,destroy,writeandend;
stream.Duplexis new (toWeb,fromWeb).Lasm.JS.Denois the wholeDenonamespace (#307). Generated from Deno
2.9.6's own TypeScript declarations (lib.deno.ns.d.ts,lib.deno_net.d.ts,
and Deno KV andDeno.cronfromlib.deno.unstable.d.ts) by the new
scripts/bindings/ts-auto.mjs: the file system (Deno.readFile,Deno.open,
FsFile,Deno.readDir,watchFs, …), subprocesses (Deno.Command,
ChildProcess), TCP, TLS and Unix sockets and DNS (Deno.listen,
Deno.connect,Deno.resolveDnsMx, …), the process (Deno.env,
Deno.args,Deno.exit, signals), permissions, standard streams,
Deno.upgradeWebSocket,Deno.createHttpClient, and Deno KV
(Deno.openKv,Kv,AtomicOperation,KvU64) withDeno.cron. New
modules:Lasm.JS.Deno.Runtime,.Permissions,.Io,.Fs,.Subprocess,
.Net,.WebSockets,.Fetch,.Kv(import the ones you use). Exclusions, each with its reason, are in
scripts/bindings/deno-tier2.mjs(FFI,Deno.test, in-place buffer reads).
docs/JS_BINDINGS.md, "Standard bindings for Deno"; API decisions 0.4-5,
0.4-7, 0.4-9, 0.4-10 to 0.4-15.- Deno KV needs Deno's
--unstable-kvflag on the Deno CLI (deno run -A --unstable-kv deno/main.mjs); Deno Deploy provides KV without it. Deno.serveWithUnixOptionsserves on a Unix domain socket.- Async iterables (
Deno.readDir,Kv.list, a listener's connections,
FsWatcher) havevalues(every value, read to the end) anditerator
withnext(one at a time). - Deno's experimental and unstable APIs that work from Wasm are generated
too (#312):Deno.spawn, VSOCK (serveWithVsockOptions,listen,
connect), QUIC (Deno.connectQuic,QuicEndpoint),
Deno.listenDatagram. Run them with Deno's--unstable-*flags.
- Deno KV needs Deno's
Lasm.JS.Bunis the wholeBunnamespace andbun:sqlite(#312).
Generated from Bun 1.4.4'sbun-typesby the same generator: files
(Bun.file,Bun.write), processes (Bun.spawn,Bun.spawnSync), TCP and
UDP sockets (Bun.listen,Bun.connect,Bun.udpSocket),bun:sqlite
(Bun.Database,Bun.Statement),Bun.SQL,Bun.RedisClient,
Bun.S3Client,Bun.password,Bun.CryptoHasher,Bun.Glob, compression,
Bun.TOML/YAML/JSON5/XML, and WebSockets inBun.serve
(websockethandlers,Server.upgrade,Server.publish,
ServerWebSocket). New modulesLasm.JS.Bun.Core,.Shell,.Sqlite,
.Sql,.Redis,.S3. Excluded with reasons: the$shell and thesql
tagged templates, the bundler,Bun.fetch(Lasm.JS.Web's), deprecated and
experimental members. docs/JS_BINDINGS.md, "Standard bindings for Bun"; API
decisions 0.4-4, 0.4-7, 0.4-8, A24.1, 0.4-17.x.Lasm.JS.DenoandLasm.JS.Bunare not prebuilt. Their modules ship as
source and compile on the first build that imports them (0.4-20), so the
package does not grow with them.- New examples: examples/deno-kv, a todo API on Deno
KV, and examples/bun-sqlite, a todo API on
bun:sqlite, both built and checked by CI.
The whole web platform from Lean (#319)
-
IndexedDB, WebGL 1 and 2, WebGPU, Web Audio, WebRTC, Media Capture,
WebCodecs, SVG, Web Animations, the observers, Service Workers, and every
other spec, asLasm.JS.Web.<Spec>
(docs/JS_BINDINGS.md).
Modules outside the small prebuilt core compile on first import (0.3-6). -
Availability guards for feature detection (decision 0.3-11, #337).
Every web binding that some target lacks has a guardX?, which checks the
platform when the program runs ('gpu' in navigator) and gives the typed
value ornone:if let some gpu ← (← navigator).gpu? then IO.println (← gpu.getPreferredCanvasFormat).val else IO.println "no WebGPU"
lasm build --targetaccepts guarded uses on targets without the API,
including the members of what the guard gives
(gpu.getPreferredCanvasFormat), and the program runs theelsebranch
there. Unguarded uses are still refused, and the error names the guard. -
Errors from generated bindings name the binding, for example
Lasm.JS.Web.URL.new: …(0.3-12). -
Lasm.UI.Mount.signal: anAbortSignalthat aborts when the app is
unmounted, for the platform's own cleanup (addEventListener'ssignal,
fetch's) (A14.1).
Generated bindings (#301)
- Checked downcasts:
I.cast? (v : Value) : IO (Option I)(instanceof)
for every generated interface JavaScript can name (A12), for example
if let some input ← HTMLInputElement.cast? e.val then …. The unchecked
{ val := v }stays.
Lasm.WASI.Http (#306)
- Helpers for whole bodies and responses (A31):
InputStream.readAll,
OutputStream.writeAll(4,096 bytes per call),IncomingRequest.readBody
andrespond out status headers body, inLasm.WASI.Http.Respond, imported
byLasm.WASI.Http. Programs may replace their own copies of these helpers.
Changes
-
Generated binding modules are compiled on first import (decision 0.3-6,
#313, #321, docs/HOW_LASM_WORKS.md). Modules of
Lasm.JS.Web,Lasm.JS.Node,Lasm.JS.Deno,Lasm.JS.Bunand
Lasm.JS.Cloudflareoutside the small core set ship as Lean source. The
first build (ornpx lasm editor) that imports one compiles it once into
Lasm's cache ([lasm] Compiling Lasm.JS.Web.IndexedDB (first use)…), and
every later build reuses it. The cache's lock lives outside the installed
prefix, so the next build's integrity check passes (#321). -
Lake builds Lasm's library modules compiled on first import, in the editor
too (#332, decision 0.3-7)..lake/lasm-libraryis a link (a junction on
Windows) that every lasm command makes or repairs. An editor opening
import Lasm.JS.Web.IndexedDBnow builds the module instead of reporting a
missing.olean.lasm buildtakes those modules from Lake and links them
once. -
Missing-import hints (decision 0.3-20, #334). The generated bindings
have no catch-all import, so a program that uses, for example,fetchmust
import its module. Whenlasm buildorlasm devfails on a name that a
generated module defines, the error is followed by the import to add:Main.lean:4:12: error: Unknown identifier `fetch` hint: fetch is defined in Lasm.JS.Web.Fetch; add: import Lasm.JS.Web.FetchA name that several runtimes define lists one import per runtime (
serve:
Lasm.JS.Node.Serve,Lasm.JS.Deno.Serve,Lasm.JS.Bun.Serve). -
One help text (0.7-1):
lasm --helpprints the same usage whether or not
the CLI is a release candidate, with every command, the targets of
lasm buildandlasm package, and what--outputnames. -
lasm dev --helplists--verbose,--devand thesupabase-edgetarget
(0.7-6);lasm package --helplists thebrowsertarget (0.7-7, #318). -
npm create @lasmwith no directory prints a usage line that no longer lists
only four templates;npx @lasm/cli init --helplists them all. -
npm create @lasmno longer reads the CLI's files for its template list
(0.7-20, #318). -
The README's environment variables list
LASM_VM_STACK_MB(0.7-13) and
LASM_DEV_SERVER, whichlasm devsets (0.7-14, #318).
Fixes
- A program on a function platform no longer fails at start-up with "The
Lean program ended (exit code 0) without publishing a fetch handler" (#327).
The platform file took the exit code that Emscripten sets while the runtime
starts for the end of the program. It now waits for the runtime's own end
(Module.onExit) or a nonzero exit code, somaincan publish its handler
withexportDefault(found by the serverless platform check after the
direct handler calls landed).
Internals (no change to how programs build or run)
- Every public surface is inventoried (#300, #302, #314): each
Lasm.*
namespace, generated binding, CLI command and flag, target, template and
LASM_*environment variable is named in
docs/API_DECISIONS.md, with its decision in the
milestone files under docs/api/decisions/, and
scripts/api/inventory.mjsfails the unit job when one is missing. Release
notes are now collected as one file per pull request in
docs/release/next/. - Instances of generated
Lasm.JS.Nodetypes now have explicit names
(instFromJSFsStats); nothing refers to the automatic ones (#220). Lasm.Serverlessleft Lasm's library (#324, API decisions A23 and
0.2-7). It had no runtime API: it was a Lean model of the function-platform
files (src/serverless/) and its 20 proved propositions. The files moved
unchanged toverification/cli/Lasm/Serverless/, beside the other models of
the CLI's JavaScript, andverification/cli/README.mdlists the
propositions instead oflibrary/PROOFS.md. No program imported it.- The library prebuilt is smaller (#333): 96.3 MB instead of 114.4 MB, with
the generated bindings outside each core set compiled on first import. lasm:ui-domis private to Lasm.UI, and the error corpus has 5 new cases
(#330).- Conduit and Ledger keep their own hardened JSON parser (#308) instead of
importingLasm.RPC.Core, a step toward removingLasm.RPC. No behaviour
change. - Candidates keep building on Lean 4.35.0 (#325): Lean 4.36.0 shipped on
2026-11-16, and its upgrade follows Stage 0's binding work; the acceptance
pins defer exactly 4.36.0. - The roadmap is in seven stages (#300, #310, #326): Stage 0 settles the
API surface; Stage 1 requires every platform at evidence level L3 and adds
selective testing on pull requests (ROADMAP.md).