Stacked on #5 (base feat/executor); the diff shows only M6. Retarget to main once #1–#5 are merged.
What's here
input: mouse events (down, up, move, scroll, click), Modifiers, MouseButton and DispatchPhase. Keyboard input comes with M5.
window (gpui's window.rs, element.rs, view.rs, and Style::paint):
Element model.Element, AnyElement and IntoElement; Render and AnyView, where an entity whose state implements Render works as an element; listener(cx, f) (gpui's cx.listener); and empty().
Frame cycle.Window::draw renders the root view, lays it out to fill the viewport, prepaints, paints and finishes the Scene. Each phase is checked, so painting during layout aborts. draw_if_dirty draws only when needed.
Window state. The content-mask, element-offset, opacity and element-id stacks, and element state kept across frames, keyed by ElementStateKey[S].
Mouse input. Hitboxes, hit testing and occlusion. Mouse dispatch runs a capture pass in paint order and a bubble pass in reverse, and supports stop_propagation.
Invalidation. A change in hover state marks the window dirty, as does notifying any view rendered in the last frame (through the new App::observe_notifications). resize and the rem size also invalidate.
Painting.paint_quad snaps to device pixels as gpui does (snap_bounds, cover_bounds, stroke snapping). Also drop and inset shadows, paint_path, and paint_style.
elements:
div(): Styled via a generated extend list, children, hover, mouse down/up/move/scroll listeners, on_click (needs an .id; the pending press is kept in element state), occlude, overflow clipping and opacity.
canvas().
tools/gen_style.py also emits the Styled extend lists for Div and Canvas. Regenerating followed by moon fmt gives no diff.
The card example now uses this pipeline. A Card view renders a div card in a headless window, and a simulated hover and click change the border colour and expand the card. Text lines are still placeholder bars until M9.
PORTING.md: M6 status and deviations.
Deviations
These are listed in PORTING.md §6:
Element has no associated state types; elements keep per-frame state in their own fields.
Element ids are strings, and there is no separate Stateful<Div> type.
Hover styles apply at paint time only, so hovering can't change layout.
The window is headless; the platform window arrives in M7/M8.
There is no view caching or replay; a window re-renders when any view it rendered is notified.
Quads aren't split into fills and border strips (a renderer optimization).
Not yet ported: focus and keys, active and group styles, drag and drop, tooltips, scroll state, deferred draws, and text.
Testing
moon check --target all and moon test --target all pass: 138 tests on each of wasm, wasm-gc, js and native.
The new end-to-end tests cover:
A view's layout landing in the scene, at 1x and 2x.
Clicks that update the view and invalidate the window.
A click only firing when press and release are over the same element.
Hover styles.
Only rendered views invalidating the window.
Nested views, with events bubbling from a button to its panel.
Occlusion and stop_propagation.
Shadows, borders, opacity and clipping.
canvas, and resize.
Three abort tests: on_click without an id, drawing without a root view, and painting outside the paint phase.
Stacked on #5 (base `feat/executor`); the diff shows only M6. Retarget to `main` once #1–#5 are merged.
## What's here
- **`input`**: mouse events (down, up, move, scroll, click), `Modifiers`, `MouseButton` and `DispatchPhase`. Keyboard input comes with M5.
- **`window`** (gpui's `window.rs`, `element.rs`, `view.rs`, and `Style::paint`):
- **Element model.** `Element`, `AnyElement` and `IntoElement`; `Render` and `AnyView`, where an entity whose state implements `Render` works as an element; `listener(cx, f)` (gpui's `cx.listener`); and `empty()`.
- **Frame cycle.** `Window::draw` renders the root view, lays it out to fill the viewport, prepaints, paints and finishes the `Scene`. Each phase is checked, so painting during layout aborts. `draw_if_dirty` draws only when needed.
- **Window state.** The content-mask, element-offset, opacity and element-id stacks, and element state kept across frames, keyed by `ElementStateKey[S]`.
- **Mouse input.** Hitboxes, hit testing and occlusion. Mouse dispatch runs a capture pass in paint order and a bubble pass in reverse, and supports `stop_propagation`.
- **Invalidation.** A change in hover state marks the window dirty, as does notifying any view rendered in the last frame (through the new `App::observe_notifications`). `resize` and the rem size also invalidate.
- **Painting.** `paint_quad` snaps to device pixels as gpui does (`snap_bounds`, `cover_bounds`, stroke snapping). Also drop and inset shadows, `paint_path`, and `paint_style`.
- **`elements`**:
- `div()`: `Styled` via a generated extend list, children, `hover`, mouse down/up/move/scroll listeners, `on_click` (needs an `.id`; the pending press is kept in element state), `occlude`, overflow clipping and opacity.
- `canvas()`.
- **`tools/gen_style.py`** also emits the `Styled` extend lists for `Div` and `Canvas`. Regenerating followed by `moon fmt` gives no diff.
- **The card example** now uses this pipeline. A `Card` view renders a `div` card in a headless window, and a simulated hover and click change the border colour and expand the card. Text lines are still placeholder bars until M9.
- **PORTING.md**: M6 status and deviations.
## Deviations
These are listed in PORTING.md §6:
- `Element` has no associated state types; elements keep per-frame state in their own fields.
- Element ids are strings, and there is no separate `Stateful<Div>` type.
- Hover styles apply at paint time only, so hovering can't change layout.
- The window is headless; the platform window arrives in M7/M8.
- There is no view caching or replay; a window re-renders when any view it rendered is notified.
- Quads aren't split into fills and border strips (a renderer optimization).
- Not yet ported: focus and keys, active and group styles, drag and drop, tooltips, scroll state, deferred draws, and text.
## Testing
`moon check --target all` and `moon test --target all` pass: 138 tests on each of wasm, wasm-gc, js and native.
The new end-to-end tests cover:
- A view's layout landing in the scene, at 1x and 2x.
- Clicks that update the view and invalidate the window.
- A click only firing when press and release are over the same element.
- Hover styles.
- Only rendered views invalidating the window.
- Nested views, with events bubbling from a button to its panel.
- Occlusion and `stop_propagation`.
- Shadows, borders, opacity and clipping.
- `canvas`, and `resize`.
- Three abort tests: `on_click` without an id, drawing without a root view, and painting outside the paint phase.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
docs/PORTING.md maps GPUI's architecture onto MoonBit packages, separates
pure logic from platform code, surveys mooncakes packages and their backends,
recommends a js + Canvas2D first backend behind a small Platform trait, lists
the Rust idioms that need a different design, and gives an ordered roadmap.
First slice (pure, tested on wasm, wasm-gc, js and native):
- geometry: Pixels/ScaledPixels/DevicePixels/Rems, Absolute/Definite/Length
with parsing, Point/Size/Bounds/Edges/Corners, Anchor, Axis, ContentMask
- color: Rgba/Hsla with conversions, hex parsing, blending, Background
(solid, linear gradient, patterns)
- scene: primitives (Quad, Shadow, Path, Underline, sprites), transformation
matrix, BoundsTree draw ordering, layers, finish/batches, replay
Derived from Zed's GPUI (Apache-2.0); see LICENSE and NOTICE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- layout: port of GPUI's TaffyLayoutEngine (request_layout,
request_measured_layout, compute_layout, layout_bounds,
stretch_auto_size_to_fill) and LayoutStyle::to_taffy, with rem resolution
and device-pixel snapping (round_half_toward_zero, stroke snapping, ceiled
measured sizes). No cross-frame node cache yet (needs element ids, M6).
- Depend on Milky2018/chicle 0.6.3, the maintained successor of
moon_taffy (which no longer compiles), instead of vendoring.
- conformance/chicle: standalone module running moon_taffy's 1,038 taffy
fixtures against chicle; all pass on wasm, wasm-gc, js and native.
- card example now lays out its content with the engine.
- Docs: PORTING.md M2 status, revised decision 3, M2 deviations; README;
NOTICE attribution for the conformance fixtures.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- app: port of GPUI's App effect cycle (update / flush_effects with
deferred subscription activation and notification dedup), EntityMap
(typed cells, leasing, explicit release), Context<T> (notify, emit,
observe, subscribe, observe_self/subscribe_self, on_release,
observe_release, observe_global, defer_call), SubscriberSet and
Subscription.
- TypeId-keyed maps become EventKey[E] / GlobalKey[G]: values cross the
app's untyped maps as closures writing into the key's typed slot.
- No Drop: App::release replaces the last-handle drop; subscriptions end
with unsubscribe() or when their entity is released.
- Fail loudly on re-entrant updates, reads during updates, use after
release, cross-app use, missing globals, global_mut outside an update.
- Tests: GPUI's subscription tests ported, plus app-model and panic tests.
- examples/counter; PORTING.md M3 status, deviations, toolchain notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- executor: coroutines on MoonBit's async intrinsics (%async.suspend /
run / capture_cancellation / raise_cancellation_signal), scheduled by a
Dispatcher trait (the platform hook) instead of core/async's event loop;
works on wasm, wasm-gc, js and native.
- Task[T]: wait (re-raises task errors), cancel (unwinds at the next
suspension point, running defers; waiters get TaskCancelled), ready,
try_result, detach. Executor: spawn, timer, sleep, yield_now, now.
- TestDispatcher: deterministic FIFO queue and virtual clock with GPUI's
advance_clock semantics (run, then step to each due timer).
- app: AsyncApp, App::spawn, Context::spawn (weak handle),
foreground/background executors, run_until_parked / advance_clock;
App::new() owns a TestDispatcher unless given a dispatcher.
- Tests ported/adapted from the scheduler crate; app async tests; the
counter example gains a ticker task. Docs: M4 status and deviations.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- input: mouse events, modifiers, dispatch phases.
- window: Element / AnyElement / IntoElement, Render / AnyView (entities
render as elements), listener(), empty(); Window with the draw cycle
(render, layout to fill the viewport, prepaint, paint, finish) and phase
checks; content-mask / element-offset / opacity / element-id stacks;
element state across frames (ElementStateKey); hitboxes, hit testing,
occlusion; mouse dispatch (capture + bubble, stop_propagation); hover-
and notify-driven invalidation of rendered views; painting: paint_quad
with device-pixel snapping, drop/inset shadows, paint_path, paint_style
(port of Style::paint).
- elements: div() (Styled, children, hover, mouse down/up/move/scroll,
clicks with element state, occlude, overflow clipping, opacity) and
canvas(); Styled extend lists generated by tools/gen_style.py.
- app: observe_notifications hook used by windows.
- Tests: end-to-end views -> scene, clicks, hover, invalidation, nested
views, bubbling, occlusion, shadows/borders/clipping, canvas, resize,
and aborts on misuse. The card example now renders a real view and
simulates hover and click.
- Docs: PORTING.md M6 status and deviations; README.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The squash of M1 there is already contained here in unsquashed form, so this
keeps this branch's tree and adds only the CI workflow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nandi
merged commit 3aa78f6ab1 into main2026-11-29 06:14:49 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Stacked on #5 (base
feat/executor); the diff shows only M6. Retarget tomainonce #1–#5 are merged.What's here
input: mouse events (down, up, move, scroll, click),Modifiers,MouseButtonandDispatchPhase. Keyboard input comes with M5.window(gpui'swindow.rs,element.rs,view.rs, andStyle::paint):Element,AnyElementandIntoElement;RenderandAnyView, where an entity whose state implementsRenderworks as an element;listener(cx, f)(gpui'scx.listener); andempty().Window::drawrenders the root view, lays it out to fill the viewport, prepaints, paints and finishes theScene. Each phase is checked, so painting during layout aborts.draw_if_dirtydraws only when needed.ElementStateKey[S].stop_propagation.App::observe_notifications).resizeand the rem size also invalidate.paint_quadsnaps to device pixels as gpui does (snap_bounds,cover_bounds, stroke snapping). Also drop and inset shadows,paint_path, andpaint_style.elements:div():Styledvia a generated extend list, children,hover, mouse down/up/move/scroll listeners,on_click(needs an.id; the pending press is kept in element state),occlude, overflow clipping and opacity.canvas().tools/gen_style.pyalso emits theStyledextend lists forDivandCanvas. Regenerating followed bymoon fmtgives no diff.Cardview renders adivcard in a headless window, and a simulated hover and click change the border colour and expand the card. Text lines are still placeholder bars until M9.Deviations
These are listed in PORTING.md §6:
Elementhas no associated state types; elements keep per-frame state in their own fields.Stateful<Div>type.Testing
moon check --target allandmoon test --target allpass: 138 tests on each of wasm, wasm-gc, js and native.The new end-to-end tests cover:
stop_propagation.canvas, andresize.on_clickwithout an id, drawing without a root view, and painting outside the paint phase.🤖 Generated with Claude Code