Repository navigation
feat(wasmgc): handlers, subscriptions and spawn in the browser - #291
Merged
Merged
Conversation
A lambda (the handler of on_event, on_media, on_visible, on_scroll or spawn) is lifted to a function taking its environment, the cells of the variables it captures. As in JavaScript a handler shares those variables with the code around it, and a variable bound in a loop is that iteration's. The loader turns a closure into a JavaScript handler that returns a promise, as the JavaScript backend's async handlers do: a handler's uncaught error or exit rejects it alone. on_event shares one runtime function, howlFrameOnEvent, with the JavaScript backend, and the table gives a lambda's parameters their kinds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AcSTmyDDtEcBifmcTbNcRW
# Conflicts: # internal/backend/wasmgc/browser_test.go
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AcSTmyDDtEcBifmcTbNcRW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AcSTmyDDtEcBifmcTbNcRW
Owner
Author
|
The merge went through as 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
M3 task 3: closures and event dispatch (plan: "Handlers").
on_event,on_media,on_visible,on_scrollorspawn) is lifted to a function(env, a0, a1); a closure is a$Closure(function reference and an environment of$Cells). Variables any lambda in a function names live in cells made afresh at each binding, so handlers share variables with the code around them, as JavaScript closures do, and a handler made in a loop keeps its iteration's variable. Every binding site of the compiler goes through one binding abstraction now.__hf_invoke; the loader wraps it as a JavaScript function returning a promise, like the JavaScript backend'sasynchandlers: a handler's uncaught error or exit rejects that promise alone.on_eventnow calls one shared runtime function in both backends (howlFrameOnEvent); the subscriptions use the JavaScript backend's runtime; the table gives a lambda's parameters kinds (event, element, bool) that the loader converts by.spawnis a browser import that runs the closure at once (no capability: a task, not a process).spawnoutside the browser, fail closed.Test Impact Assessment
on_event, the subscriptions andspawnbuild for the browser; the JavaScript backend'son_eventemitshowlFrameOnEvent(...)(same effect).TestBrowserHandlersLikeJavaScript(12 programs on both backends; the stand-in page clicks every listened element, scrolls, flips a media query, makes an element visible and records rejections and unhandled rejections: shared and per-iteration captures, captured lists and dicts, nested handlers, handlers made in a function, handler errors and exits, a missing element,spawn, subscriptions andoff),TestBrowserFailsClosedupdated; the existing JavaScript browser tests (on_event, subscriptions) pass unchanged; the differential corpus passes after the binding refactor.HOWLSCENE_HF=… scripts/wasmgc_gate.shon the tree before merging main (d9b884e6); merging main changed no file.247365e. Go 1.26: 4355 passed, 31 skipped by design; Go 1.27.2: 4353 passed, 33 skipped by design; HowlScene HF gates: 6 passed.wasmgc gate: passed.🤖 Generated with Claude Code
https://claude.ai/code/session_01AcSTmyDDtEcBifmcTbNcRW