Skip to content

refactor: page prop, Page event and page method registries (WP-00 R4) - #74

Merged
AdamMusa merged 5 commits into
mainfrom
refactor/page-registries
Nov 18, 2026
Merged

AdamMusa merged 5 commits into
mainfrom
refactor/page-registries

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

WP-00 R4, the Ruby half. The engine half is AdamMusa/ruflet-engine#103.

Three Page decisions were hard-coded in page.rb. They now live in appendable tables in Ruflet::Page::Registry (new file page_registry.rb), and page.rb seeds each table with exactly what it handled before:

Table API Read by Seed
Page props register_prop(key, view: false) assign_split_prop, which handles page.x =, set_view_props (and so the DSL's page(...)) and update(:page, ...) PAGE_PROP_KEYS; vertical_alignment, horizontal_alignment and scroll also go on the View
Page events register_event(name) Page#on: a registered event gets on_<name>: true on the Page, and on without a block sets it to nil empty, because today Page#on flags View events only
Page methods register_method(name, target: :page | :top_view | :root_view) the 8 Page methods that call the client, through the private invoke_page_method each method's current target
  • The lookups prop_target, event? and method_target accept a String or a Symbol.
  • Registering an entry again with the same options does nothing.
  • These raise ArgumentError: conflicting options, an on_* or dialog-slot prop key, an empty name, and an unknown target.
  • PAGE_PROP_KEYS and DIALOG_PROP_KEYS keep their values and stay frozen.

Later packages register entries here instead of editing page.rb: RT-01, RT-02, RT-04, RT-32 and WP-18.

Behavior changes

None. The only new public name is the constant Ruflet::Page::Registry.

Changes since the Nov 8 review

  • Merged current main (fix: keep helpers added after v0.0.23 off Kernel #67 and the final test: CLI and page compatibility goldens (WP-00 H1) #73) with a merge commit. There were no conflicts.
  • New pin test test_page_methods_on_explicit_views_invoke_the_top_and_root_view, using two explicit Views. Drawers must go to the top View, scroll_to to the root View, and get_device_info to the Page. It also passes against main's pre-refactor page.rb.
  • prop_target and event? now accept a Symbol, as method_target and every register_* already did. Page's own routing is unchanged, because Page always passes a String: normalize_props and method_missing produce String keys, and Page#on passes a String event name.

Proof (head 6ae4f5ef)

  • H1 goldens: cd packages/ruflet && ruby test/compat/compat.rb --jobs 8 checks 234 goldens and exits 0, on Ruby 4.0.5 and on 3.4.5.

  • Suites: every test file in its own process, as CI runs them (cd packages/<pkg> && ruby -Ilib -Itest test/<file>), across ruflet, ruflet_core, ruflet_server, ruflet_rails and ruflet_record.

    • The result is the same on both Rubies: 239 files, 1863 runs, 0 failures, 0 errors.
    • That includes compat_goldens_test.rb (242 runs) and page_registries_test.rb (13 runs).
    • One test skips on both Rubies because it needs RUFLET_ENGINE_ROOT.
    • On 3.4.5, minitest is pinned to 5.25.4, the version Ruby 3.4.5 bundles, which is what CI's setup-ruby gets.
  • Planted bugs: each one was planted alone in a copy of this head. Every plant changed 0 of the 234 goldens, because the fixtures never route a prop through the table (as found on Nov 8). The tests caught every plant:

    Plant Failing test files
    drop theme_mode from the seed page_registries (4), page_compatibility (1)
    drop title from the seed page_registries (5), page_compatibility (1)
    stop mirroring scroll on the View page_registries (4), page_compatibility (1)
    close_drawer → :root_view page_registries (2, including the new explicit-views test), page_view_methods (1)
    scroll_to → :top_view page_registries (4), page_view_methods (1)
    Page#on flags every Page event page_registries (2), page_default_view_events (1)
    get_device_info → :top_view page_registries (4), page_device_info (3)
    a mirrored prop skips the View page_registries (2), page_compatibility (1)
    on without a block keeps the flag page_registries (1)
    prop_target exact again page_registries (1)
  • mruby: page_registry.rb run on the embedded VM's mruby 3.4 (host_vm) gives the same output as CRuby for lookups, Symbol lookups and every validation error.

  • Other open PRs:

  • CI on 6ae4f5ef: every check passes. In the pull_request run, the Linux Explorer job hung for 30 minutes at "Install Linux desktop dependencies", so it was cancelled and re-run once, and then it passed. The same job in the push run passed on the first attempt.

  • Carried over from Nov 8, not re-run: all 183 doc examples gave byte-identical output, and a Page smoke run on a full-framework VM gave identical output.

Notes

  • The ruflet-framework mrbgem picks up page_registry.rb because it globs every lib file. The require_relative only makes sure it loads before page.rb.
  • Registry would shadow a top-level ::Registry referenced inside a subclass or reopening of Ruflet::Page. Nothing in the code, the docs or the doc snippets does that.
  • There is no docs page, because the public DSL is unchanged. The embedded VM archive is not rebuilt here.

Pin, for every built-in page prop key and every entry point that assigns
one (set_view_props, which the DSL's page(...) calls, the public setters,
the method_missing setter and update(:page, ...)), whether it lands on the
Page control, on the implicit View, or on both; that dialog slots are not
props; where page.on_x = and page.on(:x) put event subscription flags and
how they clear; and the exact invoke_control_method payloads (control,
name, args, timeout) of get_device_info, get_device_info_sync,
set_allowed_device_orientations, the drawer methods and scroll_to.

These pass on the current hard-coded tables; the appendable registries that
replace them must keep them green.
WP-00 R4. Three Page decisions were hard-coded in page.rb, so every
feature that adds a page prop (RT-02), a Page event (RT-01, RT-32) or a
page method (RT-04, the image-cache methods) would edit the same lines.
Ruflet::Page::Registry now holds them as appendable tables:

* register_prop(key, view: false): the prop travels on the Page control's
  patch (view: true also mirrors it on the page View). assign_split_prop,
  the one routing point for page.x =, set_view_props / the DSL's
  page(...) and update(:page, ...), reads it instead of PAGE_PROP_KEYS
  and the inline vertical_alignment/horizontal_alignment/scroll check.
* register_event(name): Page#on subscribes the Page control
  (on_<name>: true, cleared by on without a block). View events keep
  their View flag.
* register_method(name, target:): the control a Page method invokes
  (:page, :top_view, :root_view). get_device_info(_sync),
  set_allowed_device_orientations, the drawer methods and scroll_to
  dispatch through it.

page.rb seeds the tables with exactly what it handled before: the
PAGE_PROP_KEYS constant (unchanged, still frozen) with the three
View-mirrored keys, no Page#on event, and the seven methods with their
targets. Lookups match keys exactly, as the old include? did. Nothing
changes until a feature registers an entry. mruby-safe (checked with the
embedded VM's mruby 3.4).
With only the implicit View, the top and root View are both control 20,
so retargeting close_drawer to :root_view or scroll_to to :top_view
passed every base-passing pin test; only the seed snapshot caught it.
Two explicit Views tell them apart: drawers go to the top (last) View,
scroll_to to the root (first) View, get_device_info to the Page.

The test passes on main's pre-refactor page.rb as well.
prop_target and event? matched the name exactly, while method_target and
every register_* call took a String or a Symbol, so
Registry.event?(:resize) was false right after register_event(:resize).
The three lookups now all take a String or a Symbol (to_s).

Page's own lookups are unchanged: assign_split_prop always gets the
String key from normalize_props or method_missing, and Page#on passes
the String event name.
@AdamMusa
AdamMusa merged commit ae874d8 into main Nov 18, 2026
13 of 14 checks passed
AdamMusa added a commit that referenced this pull request Nov 20, 2026
#75 split build_command.rb into cli/build/ modules and turned
prepare_flutter_client's steps into registered contributors. The seam is
carried into that layout:

- build_command.rb requires client_bootstrap and includes ClientBootstrap
  next to FlutterSdk, as before.
- The write_client_bootstrap call, which ran right after the extension
  selection was applied and verified, is now the startup_hooks contributor
  (cli/build/contributors/startup_hooks.rb), registered after :extensions,
  so it still runs at that point, before assets and before Flutter.
- build_contributors_test pins startup_hooks in that place in BUILT_IN and
  checks that the contributor passes the build on and always continues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant