rooibos 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSES/BSD-2-Clause.txt +9 -0
- data/REUSE.toml +5 -0
- data/exe/.gitkeep +0 -0
- data/lib/rooibos/cli/commands/new.rb +24 -0
- data/lib/rooibos/command/batch.rb +10 -0
- data/lib/rooibos/command/bubble.rb +34 -0
- data/lib/rooibos/command/custom.rb +3 -2
- data/lib/rooibos/command/deliver.rb +50 -0
- data/lib/rooibos/command/http.rb +1 -1
- data/lib/rooibos/command/lifecycle.rb +3 -1
- data/lib/rooibos/command/outlet.rb +19 -9
- data/lib/rooibos/command.rb +107 -3
- data/lib/rooibos/configuration.rb +29 -0
- data/lib/rooibos/message/bubbled.rb +29 -0
- data/lib/rooibos/message.rb +24 -6
- data/lib/rooibos/router/action.rb +36 -0
- data/lib/rooibos/router/flow/dispatch.rb +39 -0
- data/lib/rooibos/router/flow/inward.rb +41 -0
- data/lib/rooibos/router/flow/outward.rb +44 -0
- data/lib/rooibos/router/guard.rb +56 -0
- data/lib/rooibos/router/predicate.rb +65 -0
- data/lib/rooibos/router/registry/actions.rb +41 -0
- data/lib/rooibos/router/registry/forwards.rb +58 -0
- data/lib/rooibos/router/registry/observes.rb +57 -0
- data/lib/rooibos/router/registry/otherwises.rb +29 -0
- data/lib/rooibos/router/registry/receives.rb +57 -0
- data/lib/rooibos/router/registry/routes.rb +59 -0
- data/lib/rooibos/router/registry.rb +26 -0
- data/lib/rooibos/router/route.rb +42 -0
- data/lib/rooibos/router/router_update.rb +53 -0
- data/lib/rooibos/router/rule/forward.rb +39 -0
- data/lib/rooibos/router/rule/observe.rb +22 -0
- data/lib/rooibos/router/rule/otherwise.rb +26 -0
- data/lib/rooibos/router/rule/receive.rb +22 -0
- data/lib/rooibos/router/rule.rb +40 -0
- data/lib/rooibos/router.rb +424 -438
- data/lib/rooibos/runtime.rb +37 -52
- data/lib/rooibos/test_helper.rb +22 -0
- data/lib/rooibos/transition.rb +92 -0
- data/lib/rooibos/version.rb +1 -1
- data/lib/rooibos.rb +2 -57
- data/sig/rooibos/cli.rbs +1 -0
- data/sig/rooibos/command.rbs +44 -0
- data/sig/rooibos/configuration.rbs +20 -0
- data/sig/rooibos/message.rbs +12 -0
- data/sig/rooibos/router/action.rbs +33 -0
- data/sig/rooibos/router/actions.rbs +27 -0
- data/sig/rooibos/router/flow/dispatch.rbs +29 -0
- data/sig/rooibos/router/flow/inward.rbs +37 -0
- data/sig/rooibos/router/flow/outward.rbs +36 -0
- data/sig/rooibos/router/forward.rbs +35 -0
- data/sig/rooibos/router/forwards.rbs +34 -0
- data/sig/rooibos/router/guard.rbs +21 -0
- data/sig/rooibos/router/observe.rbs +20 -0
- data/sig/rooibos/router/observes.rbs +38 -0
- data/sig/rooibos/router/otherwise.rbs +22 -0
- data/sig/rooibos/router/otherwises.rbs +20 -0
- data/sig/rooibos/router/predicate.rbs +51 -0
- data/sig/rooibos/router/receive.rbs +20 -0
- data/sig/rooibos/router/receives.rbs +38 -0
- data/sig/rooibos/router/registry.rbs +24 -0
- data/sig/rooibos/router/route.rbs +46 -0
- data/sig/rooibos/router/router_update.rbs +33 -0
- data/sig/rooibos/router/routes.rbs +41 -0
- data/sig/rooibos/router/rule.rbs +36 -0
- data/sig/rooibos/router.rbs +216 -161
- data/sig/rooibos/runtime.rbs +0 -1
- data/sig/rooibos/test_helper.rbs +6 -0
- data/sig/rooibos/transition.rbs +33 -0
- data/sig/rooibos.rbs +0 -10
- metadata +144 -198
- data/.builds/ruby-3.2.yml +0 -55
- data/.builds/ruby-3.3.yml +0 -55
- data/.builds/ruby-3.4.yml +0 -55
- data/.builds/ruby-4.0.0.yml +0 -55
- data/.pre-commit-config.yaml +0 -16
- data/.rubocop.yml +0 -8
- data/AGENTS.md +0 -108
- data/CHANGELOG.md +0 -308
- data/README.md +0 -183
- data/README.rdoc +0 -374
- data/Rakefile +0 -16
- data/Steepfile +0 -13
- data/doc/best_practices/forms_and_validation.md +0 -20
- data/doc/best_practices/http_workflows.md +0 -20
- data/doc/best_practices/index.md +0 -26
- data/doc/best_practices/lists_and_tables.md +0 -20
- data/doc/best_practices/modal_dialogs.md +0 -20
- data/doc/best_practices/no_stateful_widgets.md +0 -184
- data/doc/best_practices/orchestration.md +0 -20
- data/doc/best_practices/streaming_data.md +0 -20
- data/doc/contributors/design/commands_and_outlets.md +0 -214
- data/doc/contributors/design/mvu_tea_implementations_research.md +0 -373
- data/doc/contributors/documentation_plan.md +0 -616
- data/doc/contributors/documentation_stub_audit.md +0 -112
- data/doc/contributors/documentation_style.md +0 -275
- data/doc/contributors/e2e_pty.md +0 -168
- data/doc/contributors/maybe_stateful_router.md +0 -56
- data/doc/contributors/specs/earliest_tutorial_steps_per_story.md +0 -70
- data/doc/contributors/specs/file_browser.md +0 -789
- data/doc/contributors/specs/file_browser_stories.md +0 -784
- data/doc/contributors/specs/tutorials_to_stories.rb +0 -167
- data/doc/contributors/todo/scrollbar.md +0 -118
- data/doc/contributors/tutorial_old/01_project_setup.md +0 -20
- data/doc/contributors/tutorial_old/02_hello_world.md +0 -24
- data/doc/contributors/tutorial_old/03_adding_state.md +0 -26
- data/doc/contributors/tutorial_old/06_organizing_your_code.md +0 -20
- data/doc/contributors/tutorial_old/07_your_first_command.md +0 -21
- data/doc/contributors/tutorial_old/08_the_preview_pane.md +0 -20
- data/doc/contributors/tutorial_old/09_loading_states.md +0 -20
- data/doc/contributors/tutorial_old/10_testing_your_app.md +0 -20
- data/doc/contributors/tutorial_old/11_polish_and_refine.md +0 -20
- data/doc/contributors/tutorial_old/12_going_further.md +0 -20
- data/doc/contributors/tutorial_old/index.md +0 -20
- data/doc/custom.css +0 -22
- data/doc/essentials/commands.md +0 -20
- data/doc/essentials/index.md +0 -31
- data/doc/essentials/messages.md +0 -21
- data/doc/essentials/models.md +0 -21
- data/doc/essentials/shortcuts.md +0 -19
- data/doc/essentials/the_elm_architecture.md +0 -24
- data/doc/essentials/the_runtime.md +0 -21
- data/doc/essentials/update_functions.md +0 -20
- data/doc/essentials/views.md +0 -22
- data/doc/getting_started/for_go_developers.md +0 -16
- data/doc/getting_started/for_python_developers.md +0 -16
- data/doc/getting_started/for_rails_developers.md +0 -17
- data/doc/getting_started/for_ratatui_ruby_developers.md +0 -17
- data/doc/getting_started/for_react_developers.md +0 -17
- data/doc/getting_started/index.md +0 -52
- data/doc/getting_started/install.md +0 -20
- data/doc/getting_started/quickstart.md +0 -20
- data/doc/getting_started/ruby_primer.md +0 -19
- data/doc/getting_started/why_rooibos.md +0 -20
- data/doc/images/verify_readme_usage.png +0 -0
- data/doc/images/widget_cmd_exec.png +0 -0
- data/doc/index.md +0 -93
- data/doc/scaling_up/async_patterns.md +0 -20
- data/doc/scaling_up/command_composition.md +0 -20
- data/doc/scaling_up/custom_commands.md +0 -21
- data/doc/scaling_up/fractal_architecture.md +0 -20
- data/doc/scaling_up/index.md +0 -30
- data/doc/scaling_up/message_routing.md +0 -20
- data/doc/scaling_up/ractor_safety.md +0 -20
- data/doc/scaling_up/testing.md +0 -21
- data/doc/troubleshooting/common_errors.md +0 -20
- data/doc/troubleshooting/debugging.md +0 -21
- data/doc/troubleshooting/index.md +0 -23
- data/doc/troubleshooting/performance.md +0 -20
- data/doc/tutorial/01_project_setup.md +0 -44
- data/doc/tutorial/02_hello_world.md +0 -45
- data/doc/tutorial/03_static_file_list.md +0 -44
- data/doc/tutorial/04_arrow_navigation.md +0 -47
- data/doc/tutorial/05_real_files.md +0 -45
- data/doc/tutorial/06_safe_refactoring.md +0 -21
- data/doc/tutorial/07_red_first_tdd.md +0 -26
- data/doc/tutorial/08_file_metadata.md +0 -42
- data/doc/tutorial/09_text_preview.md +0 -44
- data/doc/tutorial/10_directory_tree.md +0 -42
- data/doc/tutorial/11_pane_focus.md +0 -40
- data/doc/tutorial/12_sorting.md +0 -41
- data/doc/tutorial/13_filtering.md +0 -43
- data/doc/tutorial/14_toggle_hidden.md +0 -41
- data/doc/tutorial/15_text_input_widget.md +0 -43
- data/doc/tutorial/16_rename_files.md +0 -42
- data/doc/tutorial/17_confirmation_dialogs.md +0 -43
- data/doc/tutorial/18_progress_indicators.md +0 -43
- data/doc/tutorial/19_atomic_operations.md +0 -42
- data/doc/tutorial/20_external_editor.md +0 -42
- data/doc/tutorial/21_modal_overlays.md +0 -41
- data/doc/tutorial/22_error_handling.md +0 -43
- data/doc/tutorial/23_terminal_capabilities.md +0 -53
- data/doc/tutorial/24_mouse_events.md +0 -43
- data/doc/tutorial/25_resize_events.md +0 -43
- data/doc/tutorial/26_loading_states.md +0 -42
- data/doc/tutorial/27_performance.md +0 -43
- data/doc/tutorial/28_color_schemes.md +0 -47
- data/doc/tutorial/29_configuration.md +0 -124
- data/doc/tutorial/30_going_further.md +0 -17
- data/doc/tutorial/index.md +0 -17
- data/examples/app_fractal_dashboard/README.md +0 -60
- data/examples/app_fractal_dashboard/app.rb +0 -63
- data/examples/app_fractal_dashboard/dashboard/base.rb +0 -73
- data/examples/app_fractal_dashboard/dashboard/update_helpers.rb +0 -86
- data/examples/app_fractal_dashboard/dashboard/update_manual.rb +0 -87
- data/examples/app_fractal_dashboard/dashboard/update_router.rb +0 -43
- data/examples/app_fractal_dashboard/fragments/custom_shell_input.rb +0 -81
- data/examples/app_fractal_dashboard/fragments/custom_shell_modal.rb +0 -82
- data/examples/app_fractal_dashboard/fragments/custom_shell_output.rb +0 -90
- data/examples/app_fractal_dashboard/fragments/disk_usage.rb +0 -47
- data/examples/app_fractal_dashboard/fragments/network_panel.rb +0 -45
- data/examples/app_fractal_dashboard/fragments/ping.rb +0 -47
- data/examples/app_fractal_dashboard/fragments/stats_panel.rb +0 -45
- data/examples/app_fractal_dashboard/fragments/system_info.rb +0 -47
- data/examples/app_fractal_dashboard/fragments/uptime.rb +0 -47
- data/examples/tutorial/01/app.rb +0 -50
- data/examples/tutorial/02/app.rb +0 -64
- data/examples/tutorial/03/app.rb +0 -91
- data/examples/tutorial/06_safe_refactoring/app.rb +0 -124
- data/examples/verify_readme_usage/README.md +0 -54
- data/examples/verify_readme_usage/app.rb +0 -47
- data/examples/verify_website_first_app/app.rb +0 -85
- data/examples/verify_website_hello_mvu/app.rb +0 -31
- data/examples/widget_command_system/README.md +0 -70
- data/examples/widget_command_system/app.rb +0 -134
- data/generate_tutorial_stubs.rb +0 -126
- data/mise.toml +0 -8
- data/rbs_collection.lock.yaml +0 -108
- data/rbs_collection.yaml +0 -15
- data/tasks/example_viewer.html.erb +0 -172
- data/tasks/install.rake +0 -29
- data/tasks/resources/build.yml.erb +0 -55
- data/tasks/resources/index.html.erb +0 -44
- data/tasks/resources/rubies.yml +0 -7
- data/tasks/steep.rake +0 -11
- /data/{vendor/goodcop/base.yml → lib/rooibos/rubocop.yml} +0 -0
data/sig/rooibos/router.rbs
CHANGED
|
@@ -4,171 +4,226 @@
|
|
|
4
4
|
#++
|
|
5
5
|
|
|
6
6
|
module Rooibos
|
|
7
|
-
#
|
|
8
|
-
module Router
|
|
9
|
-
def self.included: (Class base) -> void
|
|
10
|
-
|
|
11
|
-
# Duck type for Data-like models that support `with`.
|
|
7
|
+
# Duck type for Data-like models that support `with` and `public_send`.
|
|
12
8
|
interface _DataModel
|
|
13
9
|
def public_send: (Symbol, *Object) -> Object
|
|
14
10
|
def with: (**Object) -> self
|
|
15
11
|
end
|
|
16
12
|
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
13
|
+
# Fractal routing DSL for composing hierarchical updates.
|
|
14
|
+
module Router
|
|
15
|
+
# Sentinel type for broadcasting to all routes.
|
|
16
|
+
type all_routes_sentinel = Object
|
|
17
|
+
|
|
18
|
+
# Handler callable - zero or two argument form.
|
|
19
|
+
type handler = ^(message, _DataModel) -> Runtime::update_result
|
|
20
|
+
| ^() -> Runtime::update_result
|
|
21
|
+
|
|
22
|
+
# Handler or action name symbol.
|
|
23
|
+
type handler_or_action = handler | Symbol
|
|
24
|
+
|
|
25
|
+
# Guard predicate callable.
|
|
26
|
+
type guard = ^(message, _DataModel) -> boolish
|
|
27
|
+
|
|
28
|
+
# Route target: model attribute symbol, fragment module, or Route.
|
|
29
|
+
type route_target = Symbol | Module | Route
|
|
30
|
+
|
|
31
|
+
# Sentinel for "all routes" broadcast.
|
|
32
|
+
ALL_ROUTES: all_routes_sentinel
|
|
33
|
+
|
|
34
|
+
# Module inclusion hook.
|
|
35
|
+
def self.included: (Class base) -> void
|
|
36
|
+
|
|
37
|
+
# Class methods added when Router is included.
|
|
38
|
+
module ClassMethods : Module
|
|
39
|
+
@routes: Routes
|
|
40
|
+
@actions: Actions
|
|
41
|
+
@forwards: Forwards
|
|
42
|
+
@receives: Receives
|
|
43
|
+
@observes: Observes
|
|
44
|
+
@otherwises: Otherwises
|
|
45
|
+
@_scoped_target: route_target?
|
|
46
|
+
|
|
47
|
+
# Assembles all declarations into a frozen RouterUpdate callable.
|
|
48
|
+
def from_router: () -> ^(message, _DataModel) -> [_DataModel, Command::execution?]
|
|
49
|
+
|
|
50
|
+
# Declares a child route binding a nested fragment to a model slice.
|
|
51
|
+
def route: (
|
|
52
|
+
?Symbol? prefix,
|
|
53
|
+
to: Module,
|
|
54
|
+
?read: (^(_DataModel) -> _DataModel)?,
|
|
55
|
+
?write: (^(_DataModel, _DataModel) -> _DataModel)?
|
|
56
|
+
) -> Route
|
|
57
|
+
|
|
58
|
+
# Forwards all instances of a class to routes.
|
|
59
|
+
def forward_instances_of: (
|
|
60
|
+
Class klass,
|
|
61
|
+
?to: route_target?,
|
|
62
|
+
?as: Symbol?,
|
|
63
|
+
?broadcast: bool,
|
|
64
|
+
?broadcast_to: Array[route_target]?
|
|
65
|
+
) -> void
|
|
66
|
+
|
|
67
|
+
# Defines a named action referenceable by symbol.
|
|
68
|
+
def action: (?Symbol? name, ?handler? handler_arg) -> void
|
|
69
|
+
|
|
70
|
+
# Handles matching key events. Stops further processing.
|
|
71
|
+
def receive_events: (
|
|
72
|
+
Symbol | Array[Symbol] keys,
|
|
73
|
+
handler_or_action handler,
|
|
74
|
+
?guard: guard?,
|
|
75
|
+
?when: guard?,
|
|
76
|
+
?unless: guard?
|
|
77
|
+
) -> void
|
|
78
|
+
|
|
79
|
+
# Handles matching routed messages. Stops further processing.
|
|
80
|
+
def receive_routed: (
|
|
81
|
+
Symbol envelope,
|
|
82
|
+
handler_or_action handler,
|
|
83
|
+
?guard: guard?
|
|
84
|
+
) -> void
|
|
85
|
+
|
|
86
|
+
# Handles matching class instances. Stops further processing.
|
|
87
|
+
def receive_instances_of: (
|
|
88
|
+
Class klass,
|
|
89
|
+
handler_or_action handler,
|
|
90
|
+
?guard: guard?
|
|
91
|
+
) -> void
|
|
92
|
+
|
|
93
|
+
# Handles any message. Stops further processing.
|
|
94
|
+
def receive_all: (
|
|
95
|
+
handler_or_action handler,
|
|
96
|
+
?guard: guard?,
|
|
97
|
+
?when: guard?,
|
|
98
|
+
?unless: guard?
|
|
99
|
+
) -> void
|
|
100
|
+
|
|
101
|
+
# Handles messages matching a custom predicate. Stops further processing.
|
|
102
|
+
def receive: (
|
|
103
|
+
guard predicate,
|
|
104
|
+
handler_or_action handler,
|
|
105
|
+
?guard: guard?
|
|
106
|
+
) -> void
|
|
107
|
+
|
|
108
|
+
# Alias for receive_events.
|
|
109
|
+
alias intercept_events receive_events
|
|
110
|
+
# Alias for receive_routed.
|
|
111
|
+
alias intercept_routed receive_routed
|
|
112
|
+
# Alias for receive_instances_of.
|
|
113
|
+
alias intercept_instances_of receive_instances_of
|
|
114
|
+
# Alias for receive_all.
|
|
115
|
+
alias intercept_all receive_all
|
|
116
|
+
# Alias for receive.
|
|
117
|
+
alias intercept receive
|
|
118
|
+
|
|
119
|
+
# Routes matching key events to a declared route.
|
|
120
|
+
def forward_events: (
|
|
121
|
+
Symbol | Array[Symbol] keys,
|
|
122
|
+
?to: route_target?,
|
|
123
|
+
?as: Symbol?,
|
|
124
|
+
?guard: guard?,
|
|
125
|
+
?when: guard?,
|
|
126
|
+
?unless: guard?
|
|
127
|
+
) -> void
|
|
128
|
+
|
|
129
|
+
# Routes matching routed messages to a declared route.
|
|
130
|
+
def forward_routed: (
|
|
131
|
+
Symbol | Array[Symbol] envelopes,
|
|
132
|
+
?to: route_target?,
|
|
133
|
+
?as: Symbol?
|
|
134
|
+
) -> void
|
|
135
|
+
|
|
136
|
+
# Routes messages matching a custom predicate.
|
|
137
|
+
def forward: (
|
|
138
|
+
guard predicate,
|
|
139
|
+
?to: route_target?,
|
|
140
|
+
?as: Symbol?
|
|
141
|
+
) -> void
|
|
142
|
+
|
|
143
|
+
# Observes matching key events. Does not stop further processing.
|
|
144
|
+
def observe_events: (
|
|
145
|
+
Symbol | Array[Symbol] keys,
|
|
146
|
+
handler_or_action handler,
|
|
147
|
+
?guard: guard?,
|
|
148
|
+
?when: guard?,
|
|
149
|
+
?unless: guard?
|
|
150
|
+
) -> void
|
|
151
|
+
|
|
152
|
+
# Observes matching routed messages. Does not stop further processing.
|
|
153
|
+
def observe_routed: (
|
|
154
|
+
Symbol envelope,
|
|
155
|
+
handler_or_action handler,
|
|
156
|
+
?guard: guard?
|
|
157
|
+
) -> void
|
|
158
|
+
|
|
159
|
+
# Observes matching class instances. Does not stop further processing.
|
|
160
|
+
def observe_instances_of: (
|
|
161
|
+
Class klass,
|
|
162
|
+
handler_or_action handler,
|
|
163
|
+
?guard: guard?
|
|
164
|
+
) -> void
|
|
165
|
+
|
|
166
|
+
# Observes any message. Does not stop further processing.
|
|
167
|
+
def observe_all: (
|
|
168
|
+
handler_or_action handler,
|
|
169
|
+
?guard: guard?,
|
|
170
|
+
?when: guard?,
|
|
171
|
+
?unless: guard?
|
|
172
|
+
) -> void
|
|
173
|
+
|
|
174
|
+
# Observes messages matching a custom predicate. Does not stop further processing.
|
|
175
|
+
def observe: (
|
|
176
|
+
guard predicate,
|
|
177
|
+
handler_or_action handler,
|
|
178
|
+
?guard: guard?,
|
|
179
|
+
?when: guard?,
|
|
180
|
+
?unless: guard?
|
|
181
|
+
) -> void
|
|
182
|
+
|
|
183
|
+
# Catches unhandled messages as a router-level fallback.
|
|
184
|
+
def otherwise: (
|
|
185
|
+
?route_to: route_target,
|
|
186
|
+
?guard: guard?,
|
|
187
|
+
?when: guard?,
|
|
188
|
+
?unless: guard?
|
|
189
|
+
) -> void
|
|
190
|
+
|
|
191
|
+
private
|
|
192
|
+
|
|
193
|
+
# Route registry for this router.
|
|
194
|
+
def routes: () -> Routes
|
|
195
|
+
|
|
196
|
+
# Action registry for this router.
|
|
197
|
+
def actions: () -> Actions
|
|
198
|
+
|
|
199
|
+
# Forward rule registry for this router.
|
|
200
|
+
def forwards: () -> Forwards
|
|
201
|
+
|
|
202
|
+
# Receive rule registry for this router.
|
|
203
|
+
def receives: () -> Receives
|
|
204
|
+
|
|
205
|
+
# Observe rule registry for this router.
|
|
206
|
+
def observes: () -> Observes
|
|
207
|
+
|
|
208
|
+
# Otherwise rule registry for this router.
|
|
209
|
+
def otherwises: () -> Otherwises
|
|
210
|
+
|
|
211
|
+
# Routes any message to a declared route.
|
|
212
|
+
def forward_all: (
|
|
213
|
+
?to: route_target?,
|
|
214
|
+
?guard: guard?,
|
|
215
|
+
?when: guard?,
|
|
216
|
+
?unless: guard?
|
|
217
|
+
) -> void
|
|
218
|
+
|
|
219
|
+
# Scopes a positive guard over declarations.
|
|
220
|
+
def only: (?when: guard?, ?if: guard?) ?{ () -> void } -> void
|
|
221
|
+
|
|
222
|
+
# Scopes a negative guard over declarations.
|
|
223
|
+
def skip: (?when: guard?, ?if: guard?) ?{ () -> void } -> void
|
|
224
|
+
|
|
225
|
+
# Scopes forward target for a block.
|
|
226
|
+
def route_to: (route_target target) ?{ () -> void } -> void
|
|
227
|
+
end
|
|
172
228
|
end
|
|
173
229
|
end
|
|
174
|
-
end
|
data/sig/rooibos/runtime.rbs
CHANGED
|
@@ -59,7 +59,6 @@ module Rooibos
|
|
|
59
59
|
private
|
|
60
60
|
|
|
61
61
|
def self.validate_view_return!: (renderable? widget) -> void
|
|
62
|
-
def self.normalize_update_return: [Model] (update_result? result, Model? previous_model) -> [Model?, Command::execution?]
|
|
63
62
|
def self.validate_ractor_shareable!: [T] (T object, String name) -> void
|
|
64
63
|
def self.fragment_from_kwargs: (Module? root_fragment, ?model: untyped, ?view: untyped, ?update: untyped, ?command: untyped) -> Module
|
|
65
64
|
def self.fragment_invariant!: (String param) -> void
|
data/sig/rooibos/test_helper.rbs
CHANGED
|
@@ -10,5 +10,11 @@ module Rooibos
|
|
|
10
10
|
# Fails if any Command::Error is present in the messages array.
|
|
11
11
|
# Relies on Minitest's flunk method being available in the including class.
|
|
12
12
|
def assert_no_errors: (Array[untyped] messages, ?String? msg) -> void
|
|
13
|
+
|
|
14
|
+
# Shared fixtures for Ractor-shareable testing patterns
|
|
15
|
+
ClearView: ^(untyped, untyped) -> void
|
|
16
|
+
ExitOnQUpdate: ^(untyped, untyped) -> [untyped, Command::Exit?]
|
|
17
|
+
ExitOnAnyKeyUpdate: ^(untyped, untyped) -> [untyped, Command::Exit]
|
|
13
18
|
end
|
|
14
19
|
end
|
|
20
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
|
|
3
|
+
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
4
|
+
#++
|
|
5
|
+
|
|
6
|
+
module Rooibos
|
|
7
|
+
# Transition represents a normalized [model, command] tuple from Update.
|
|
8
|
+
class Transition < Data
|
|
9
|
+
attr_reader model: _DataModel
|
|
10
|
+
attr_reader command: Command::execution?
|
|
11
|
+
|
|
12
|
+
# Normalizes a DWIM return value into a Transition.
|
|
13
|
+
def self.from: (update_result result, _DataModel previous_model) -> Transition
|
|
14
|
+
|
|
15
|
+
# Creates an initial Transition with no command.
|
|
16
|
+
def self.initial: (_DataModel model) -> Transition
|
|
17
|
+
|
|
18
|
+
# Returns new Transition with updated model, or self if nil.
|
|
19
|
+
def with_model: (_DataModel? new_model) -> Transition
|
|
20
|
+
|
|
21
|
+
# Returns new Transition with updated command, or self if nil.
|
|
22
|
+
def with_command: (Command::execution? new_command) -> Transition
|
|
23
|
+
|
|
24
|
+
# Returns new Transition with command added (batched if existing).
|
|
25
|
+
def with_added_command: (Command::execution? new_command) -> Transition
|
|
26
|
+
|
|
27
|
+
# Returns new Transition with command added via Separate (for observe).
|
|
28
|
+
def with_separate_command: (Command::execution? new_command) -> Transition
|
|
29
|
+
|
|
30
|
+
# Converts to [model, command] tuple.
|
|
31
|
+
def to_a: () -> [_DataModel, Command::execution?]
|
|
32
|
+
end
|
|
33
|
+
end
|
data/sig/rooibos.rbs
CHANGED
|
@@ -30,16 +30,6 @@ module Rooibos
|
|
|
30
30
|
?command: Command::execution?
|
|
31
31
|
) -> Model
|
|
32
32
|
|
|
33
|
-
# Wraps a command with a routing prefix.
|
|
34
|
-
def self.route: (Command::execution command, Symbol prefix) -> Command::Mapped
|
|
35
|
-
|
|
36
|
-
# Delegates a prefixed message to a child fragment's UPDATE.
|
|
37
|
-
def self.delegate: (
|
|
38
|
-
untyped message,
|
|
39
|
-
Symbol prefix,
|
|
40
|
-
^(Array[untyped]?, untyped) -> [untyped, Command::execution?] child_update,
|
|
41
|
-
untyped child_model
|
|
42
|
-
) -> ([untyped, Command::execution?] | nil)
|
|
43
33
|
|
|
44
34
|
# Normalizes Init callable return value to [model, command] tuple.
|
|
45
35
|
def self.normalize_init: [Model] (Runtime::init_result result) -> [Model?, Command::execution?]
|