ruact 0.0.2 → 0.0.4

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.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.codecov.yml +31 -0
  3. data/.github/workflows/ci.yml +160 -94
  4. data/.github/workflows/server-functions-bench.yml +54 -0
  5. data/.rubocop.yml +19 -1
  6. data/.rubocop_todo.yml +175 -0
  7. data/CHANGELOG.md +88 -5
  8. data/README.md +2 -0
  9. data/RELEASING.md +9 -3
  10. data/bench/server_functions_dispatch_bench.rb +309 -0
  11. data/bench/server_functions_dispatch_bench.results.md +121 -0
  12. data/docs/internal/README.md +9 -0
  13. data/docs/internal/decisions/server-functions-api.md +1779 -0
  14. data/lib/generators/ruact/install/install_generator.rb +43 -0
  15. data/lib/generators/ruact/install/templates/application.jsx.tt +1 -1
  16. data/lib/generators/ruact/install/templates/initializer.rb.tt +1 -1
  17. data/lib/ruact/client_manifest.rb +125 -12
  18. data/lib/ruact/configuration.rb +264 -23
  19. data/lib/ruact/controller.rb +459 -32
  20. data/lib/ruact/doctor.rb +34 -2
  21. data/lib/ruact/erb_preprocessor.rb +6 -6
  22. data/lib/ruact/errors.rb +100 -0
  23. data/lib/ruact/flight/serializer.rb +2 -2
  24. data/lib/ruact/html_converter.rb +131 -31
  25. data/lib/ruact/query.rb +107 -0
  26. data/lib/ruact/railtie.rb +220 -3
  27. data/lib/ruact/render_context.rb +30 -0
  28. data/lib/ruact/render_pipeline.rb +201 -59
  29. data/lib/ruact/routing.rb +81 -0
  30. data/lib/ruact/serializable.rb +11 -11
  31. data/lib/ruact/server.rb +341 -0
  32. data/lib/ruact/server_action.rb +131 -0
  33. data/lib/ruact/server_functions/backtrace_cleaner.rb +32 -0
  34. data/lib/ruact/server_functions/bucket_two_payload.rb +109 -0
  35. data/lib/ruact/server_functions/codegen.rb +344 -0
  36. data/lib/ruact/server_functions/codegen_v2.rb +212 -0
  37. data/lib/ruact/server_functions/endpoint_controller.rb +237 -0
  38. data/lib/ruact/server_functions/error_payload.rb +93 -0
  39. data/lib/ruact/server_functions/error_rendering.rb +190 -0
  40. data/lib/ruact/server_functions/error_suggestion.rb +38 -0
  41. data/lib/ruact/server_functions/name_bridge.rb +118 -0
  42. data/lib/ruact/server_functions/query_context.rb +62 -0
  43. data/lib/ruact/server_functions/query_dispatch.rb +313 -0
  44. data/lib/ruact/server_functions/query_source.rb +150 -0
  45. data/lib/ruact/server_functions/registry.rb +148 -0
  46. data/lib/ruact/server_functions/registry_entry.rb +26 -0
  47. data/lib/ruact/server_functions/route_source.rb +201 -0
  48. data/lib/ruact/server_functions/snapshot.rb +195 -0
  49. data/lib/ruact/server_functions/snapshot_writer.rb +65 -0
  50. data/lib/ruact/server_functions/standalone_context.rb +103 -0
  51. data/lib/ruact/server_functions/standalone_dispatcher.rb +178 -0
  52. data/lib/ruact/server_functions.rb +111 -0
  53. data/lib/ruact/version.rb +1 -1
  54. data/lib/ruact/view_helper.rb +17 -9
  55. data/lib/ruact.rb +85 -6
  56. data/lib/rubocop/cop/ruact/no_shared_state.rb +1 -1
  57. data/lib/tasks/benchmark.rake +15 -11
  58. data/lib/tasks/ruact.rake +81 -0
  59. data/spec/benchmarks/render_pipeline_benchmark_spec.rb +1 -1
  60. data/spec/fixtures/flight/README.md +55 -7
  61. data/spec/fixtures/flight/bigint.txt +1 -0
  62. data/spec/fixtures/flight/infinity.txt +1 -0
  63. data/spec/fixtures/flight/nan.txt +1 -0
  64. data/spec/fixtures/flight/negative_infinity.txt +1 -0
  65. data/spec/fixtures/flight/undefined.txt +1 -0
  66. data/spec/fixtures/story_7_9_views/controller_request_spec_support/demo/show.html.erb +3 -0
  67. data/spec/ruact/client_manifest_spec.rb +108 -0
  68. data/spec/ruact/configuration_spec.rb +501 -0
  69. data/spec/ruact/controller_request_spec.rb +204 -0
  70. data/spec/ruact/controller_spec.rb +427 -39
  71. data/spec/ruact/doctor_spec.rb +118 -0
  72. data/spec/ruact/erb_preprocessor_hook_spec.rb +3 -3
  73. data/spec/ruact/erb_preprocessor_spec.rb +7 -7
  74. data/spec/ruact/errors_spec.rb +95 -0
  75. data/spec/ruact/flight/renderer_spec.rb +14 -3
  76. data/spec/ruact/flight/serializer_spec.rb +129 -88
  77. data/spec/ruact/html_converter_spec.rb +183 -5
  78. data/spec/ruact/install_generator_spec.rb +93 -0
  79. data/spec/ruact/query_request_spec.rb +598 -0
  80. data/spec/ruact/query_spec.rb +105 -0
  81. data/spec/ruact/railtie_spec.rb +2 -3
  82. data/spec/ruact/render_context_spec.rb +58 -0
  83. data/spec/ruact/render_pipeline_concurrency_spec.rb +78 -0
  84. data/spec/ruact/render_pipeline_spec.rb +784 -330
  85. data/spec/ruact/serializable_spec.rb +8 -8
  86. data/spec/ruact/server_bucket_request_spec.rb +352 -0
  87. data/spec/ruact/server_function_name_spec.rb +53 -0
  88. data/spec/ruact/server_functions/backtrace_cleaner_spec.rb +63 -0
  89. data/spec/ruact/server_functions/bucket_two_payload_spec.rb +200 -0
  90. data/spec/ruact/server_functions/codegen_spec.rb +508 -0
  91. data/spec/ruact/server_functions/csrf_request_spec.rb +380 -0
  92. data/spec/ruact/server_functions/dispatch_request_spec.rb +819 -0
  93. data/spec/ruact/server_functions/error_payload_spec.rb +222 -0
  94. data/spec/ruact/server_functions/error_suggestion_spec.rb +79 -0
  95. data/spec/ruact/server_functions/name_bridge_spec.rb +212 -0
  96. data/spec/ruact/server_functions/query_context_spec.rb +72 -0
  97. data/spec/ruact/server_functions/query_source_spec.rb +142 -0
  98. data/spec/ruact/server_functions/railtie_integration_spec.rb +412 -0
  99. data/spec/ruact/server_functions/rake_spec.rb +86 -0
  100. data/spec/ruact/server_functions/registry_spec.rb +199 -0
  101. data/spec/ruact/server_functions/route_source_spec.rb +202 -0
  102. data/spec/ruact/server_functions/snapshot_spec.rb +256 -0
  103. data/spec/ruact/server_functions/snapshot_writer_spec.rb +71 -0
  104. data/spec/ruact/server_functions/standalone_action_spec.rb +224 -0
  105. data/spec/ruact/server_functions/standalone_context_spec.rb +142 -0
  106. data/spec/ruact/server_functions/standalone_dispatcher_spec.rb +273 -0
  107. data/spec/ruact/server_rescue_request_spec.rb +416 -0
  108. data/spec/ruact/server_spec.rb +180 -0
  109. data/spec/ruact/server_upload_request_spec.rb +311 -0
  110. data/spec/ruact/view_helper_spec.rb +23 -17
  111. data/spec/spec_helper.rb +52 -1
  112. data/spec/support/fixtures/pixel.png +0 -0
  113. data/spec/support/flight_wire_parser.rb +135 -0
  114. data/spec/support/flight_wire_parser_spec.rb +93 -0
  115. data/spec/support/matchers/flight_fixture_matcher.rb +356 -0
  116. data/spec/support/matchers/flight_fixture_matcher_spec.rb +250 -0
  117. data/spec/support/rails_stub.rb +75 -5
  118. data/vendor/javascript/ruact-server-functions-runtime/index.d.ts +173 -0
  119. data/vendor/javascript/ruact-server-functions-runtime/index.js +614 -0
  120. data/vendor/javascript/ruact-server-functions-runtime/index.test.mjs +827 -0
  121. data/vendor/javascript/ruact-server-functions-runtime/package.json +29 -0
  122. data/vendor/javascript/ruact-server-functions-runtime/usequery.test.mjs +181 -0
  123. data/vendor/javascript/vite-plugin-ruact/index.js +164 -0
  124. data/vendor/javascript/vite-plugin-ruact/package-lock.json +1429 -0
  125. data/vendor/javascript/vite-plugin-ruact/package.json +15 -0
  126. data/vendor/javascript/vite-plugin-ruact/server-functions-codegen.mjs +804 -0
  127. data/vendor/javascript/vite-plugin-ruact/server-functions-codegen.test.mjs +961 -0
  128. data/vendor/javascript/vite-plugin-ruact/vitest.config.mjs +21 -0
  129. metadata +91 -5
  130. data/lib/ruact/component_registry.rb +0 -31
  131. data/lib/tasks/rsc.rake +0 -9
@@ -0,0 +1,21 @@
1
+ // Story 8.0a — minimal vitest harness for the bundled Vite plugin.
2
+ //
3
+ // Story 6.9 (vite-plugin TS modularization) will absorb this into its larger
4
+ // src/ + dist/ layout. Until then, run tests against the in-tree `.mjs` source
5
+ // directly.
6
+
7
+ import { defineConfig } from "vitest/config";
8
+
9
+ export default defineConfig({
10
+ test: {
11
+ environment: "node",
12
+ // The runtime's `index.test.mjs` is node-environment + dependency-free, so
13
+ // it rides along here for a single parity-plus-runtime run. Its jsdom +
14
+ // React hook tests (`usequery.test.mjs`, Story 9.5) need
15
+ // `@testing-library/react` from the runtime package's own node_modules and
16
+ // run via that package's `npm test` — they are intentionally NOT globbed
17
+ // in here (a `*.test.mjs` glob would pull them in and fail to resolve).
18
+ include: ["**/*.test.mjs", "../ruact-server-functions-runtime/index.test.mjs"],
19
+ globals: false,
20
+ },
21
+ });
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruact
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luiz Garcia
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-06-10 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: nokogiri
@@ -23,26 +24,33 @@ dependencies:
23
24
  - - "~>"
24
25
  - !ruby/object:Gem::Version
25
26
  version: '1.15'
27
+ description:
26
28
  email:
27
29
  - luizcg@gmail.com
28
30
  executables: []
29
31
  extensions: []
30
32
  extra_rdoc_files: []
31
33
  files:
34
+ - ".codecov.yml"
32
35
  - ".github/workflows/ci.yml"
36
+ - ".github/workflows/server-functions-bench.yml"
33
37
  - ".rubocop.yml"
38
+ - ".rubocop_todo.yml"
34
39
  - CHANGELOG.md
35
40
  - README.md
36
41
  - RELEASING.md
37
42
  - Rakefile
38
43
  - SECURITY.md
44
+ - bench/server_functions_dispatch_bench.rb
45
+ - bench/server_functions_dispatch_bench.results.md
46
+ - docs/internal/README.md
47
+ - docs/internal/decisions/server-functions-api.md
39
48
  - lib/generators/ruact/install/install_generator.rb
40
49
  - lib/generators/ruact/install/templates/application.jsx.tt
41
50
  - lib/generators/ruact/install/templates/initializer.rb.tt
42
51
  - lib/generators/ruact/install/templates/vite.config.js.tt
43
52
  - lib/ruact.rb
44
53
  - lib/ruact/client_manifest.rb
45
- - lib/ruact/component_registry.rb
46
54
  - lib/ruact/configuration.rb
47
55
  - lib/ruact/controller.rb
48
56
  - lib/ruact/doctor.rb
@@ -56,9 +64,34 @@ files:
56
64
  - lib/ruact/flight/row_emitter.rb
57
65
  - lib/ruact/flight/serializer.rb
58
66
  - lib/ruact/html_converter.rb
67
+ - lib/ruact/query.rb
59
68
  - lib/ruact/railtie.rb
69
+ - lib/ruact/render_context.rb
60
70
  - lib/ruact/render_pipeline.rb
71
+ - lib/ruact/routing.rb
61
72
  - lib/ruact/serializable.rb
73
+ - lib/ruact/server.rb
74
+ - lib/ruact/server_action.rb
75
+ - lib/ruact/server_functions.rb
76
+ - lib/ruact/server_functions/backtrace_cleaner.rb
77
+ - lib/ruact/server_functions/bucket_two_payload.rb
78
+ - lib/ruact/server_functions/codegen.rb
79
+ - lib/ruact/server_functions/codegen_v2.rb
80
+ - lib/ruact/server_functions/endpoint_controller.rb
81
+ - lib/ruact/server_functions/error_payload.rb
82
+ - lib/ruact/server_functions/error_rendering.rb
83
+ - lib/ruact/server_functions/error_suggestion.rb
84
+ - lib/ruact/server_functions/name_bridge.rb
85
+ - lib/ruact/server_functions/query_context.rb
86
+ - lib/ruact/server_functions/query_dispatch.rb
87
+ - lib/ruact/server_functions/query_source.rb
88
+ - lib/ruact/server_functions/registry.rb
89
+ - lib/ruact/server_functions/registry_entry.rb
90
+ - lib/ruact/server_functions/route_source.rb
91
+ - lib/ruact/server_functions/snapshot.rb
92
+ - lib/ruact/server_functions/snapshot_writer.rb
93
+ - lib/ruact/server_functions/standalone_context.rb
94
+ - lib/ruact/server_functions/standalone_dispatcher.rb
62
95
  - lib/ruact/version.rb
63
96
  - lib/ruact/view_helper.rb
64
97
  - lib/rubocop/cop/ruact.rb
@@ -66,18 +99,22 @@ files:
66
99
  - lib/rubocop/cop/ruact/no_io_in_flight.rb
67
100
  - lib/rubocop/cop/ruact/no_shared_state.rb
68
101
  - lib/tasks/benchmark.rake
69
- - lib/tasks/rsc.rake
102
+ - lib/tasks/ruact.rake
70
103
  - sig/ruact.rbs
71
104
  - spec/benchmarks/baseline.json
72
105
  - spec/benchmarks/render_pipeline_benchmark_spec.rb
73
106
  - spec/fixtures/flight/README.md
74
107
  - spec/fixtures/flight/array.txt
75
108
  - spec/fixtures/flight/as_json_object.txt
109
+ - spec/fixtures/flight/bigint.txt
76
110
  - spec/fixtures/flight/boolean_false.txt
77
111
  - spec/fixtures/flight/boolean_true.txt
78
112
  - spec/fixtures/flight/client_component_with_props.txt
79
113
  - spec/fixtures/flight/client_reference.txt
80
114
  - spec/fixtures/flight/hash.txt
115
+ - spec/fixtures/flight/infinity.txt
116
+ - spec/fixtures/flight/nan.txt
117
+ - spec/fixtures/flight/negative_infinity.txt
81
118
  - spec/fixtures/flight/nil.txt
82
119
  - spec/fixtures/flight/number_float.txt
83
120
  - spec/fixtures/flight/number_integer.txt
@@ -86,7 +123,11 @@ files:
86
123
  - spec/fixtures/flight/serializable_object.txt
87
124
  - spec/fixtures/flight/string_basic.txt
88
125
  - spec/fixtures/flight/string_dollar_escape.txt
126
+ - spec/fixtures/flight/undefined.txt
127
+ - spec/fixtures/story_7_9_views/controller_request_spec_support/demo/show.html.erb
89
128
  - spec/ruact/client_manifest_spec.rb
129
+ - spec/ruact/configuration_spec.rb
130
+ - spec/ruact/controller_request_spec.rb
90
131
  - spec/ruact/controller_spec.rb
91
132
  - spec/ruact/doctor_spec.rb
92
133
  - spec/ruact/erb_preprocessor_hook_spec.rb
@@ -96,13 +137,56 @@ files:
96
137
  - spec/ruact/flight/serializer_spec.rb
97
138
  - spec/ruact/html_converter_spec.rb
98
139
  - spec/ruact/install_generator_spec.rb
140
+ - spec/ruact/query_request_spec.rb
141
+ - spec/ruact/query_spec.rb
99
142
  - spec/ruact/railtie_spec.rb
143
+ - spec/ruact/render_context_spec.rb
144
+ - spec/ruact/render_pipeline_concurrency_spec.rb
100
145
  - spec/ruact/render_pipeline_spec.rb
101
146
  - spec/ruact/serializable_spec.rb
147
+ - spec/ruact/server_bucket_request_spec.rb
148
+ - spec/ruact/server_function_name_spec.rb
149
+ - spec/ruact/server_functions/backtrace_cleaner_spec.rb
150
+ - spec/ruact/server_functions/bucket_two_payload_spec.rb
151
+ - spec/ruact/server_functions/codegen_spec.rb
152
+ - spec/ruact/server_functions/csrf_request_spec.rb
153
+ - spec/ruact/server_functions/dispatch_request_spec.rb
154
+ - spec/ruact/server_functions/error_payload_spec.rb
155
+ - spec/ruact/server_functions/error_suggestion_spec.rb
156
+ - spec/ruact/server_functions/name_bridge_spec.rb
157
+ - spec/ruact/server_functions/query_context_spec.rb
158
+ - spec/ruact/server_functions/query_source_spec.rb
159
+ - spec/ruact/server_functions/railtie_integration_spec.rb
160
+ - spec/ruact/server_functions/rake_spec.rb
161
+ - spec/ruact/server_functions/registry_spec.rb
162
+ - spec/ruact/server_functions/route_source_spec.rb
163
+ - spec/ruact/server_functions/snapshot_spec.rb
164
+ - spec/ruact/server_functions/snapshot_writer_spec.rb
165
+ - spec/ruact/server_functions/standalone_action_spec.rb
166
+ - spec/ruact/server_functions/standalone_context_spec.rb
167
+ - spec/ruact/server_functions/standalone_dispatcher_spec.rb
168
+ - spec/ruact/server_rescue_request_spec.rb
169
+ - spec/ruact/server_spec.rb
170
+ - spec/ruact/server_upload_request_spec.rb
102
171
  - spec/ruact/view_helper_spec.rb
103
172
  - spec/spec_helper.rb
173
+ - spec/support/fixtures/pixel.png
174
+ - spec/support/flight_wire_parser.rb
175
+ - spec/support/flight_wire_parser_spec.rb
104
176
  - spec/support/matchers/flight_fixture_matcher.rb
177
+ - spec/support/matchers/flight_fixture_matcher_spec.rb
105
178
  - spec/support/rails_stub.rb
179
+ - vendor/javascript/ruact-server-functions-runtime/index.d.ts
180
+ - vendor/javascript/ruact-server-functions-runtime/index.js
181
+ - vendor/javascript/ruact-server-functions-runtime/index.test.mjs
182
+ - vendor/javascript/ruact-server-functions-runtime/package.json
183
+ - vendor/javascript/ruact-server-functions-runtime/usequery.test.mjs
184
+ - vendor/javascript/vite-plugin-ruact/index.js
185
+ - vendor/javascript/vite-plugin-ruact/package-lock.json
186
+ - vendor/javascript/vite-plugin-ruact/package.json
187
+ - vendor/javascript/vite-plugin-ruact/server-functions-codegen.mjs
188
+ - vendor/javascript/vite-plugin-ruact/server-functions-codegen.test.mjs
189
+ - vendor/javascript/vite-plugin-ruact/vitest.config.mjs
106
190
  homepage: https://luizcg.github.io/ruact/
107
191
  licenses:
108
192
  - MIT
@@ -113,6 +197,7 @@ metadata:
113
197
  changelog_uri: https://github.com/luizcg/ruact/blob/main/CHANGELOG.md
114
198
  bug_tracker_uri: https://github.com/luizcg/ruact/issues
115
199
  rubygems_mfa_required: 'true'
200
+ post_install_message:
116
201
  rdoc_options: []
117
202
  require_paths:
118
203
  - lib
@@ -127,7 +212,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
212
  - !ruby/object:Gem::Version
128
213
  version: '0'
129
214
  requirements: []
130
- rubygems_version: 3.7.2
215
+ rubygems_version: 3.5.22
216
+ signing_key:
131
217
  specification_version: 4
132
218
  summary: React Server Components for Rails — render React components from ERB using
133
219
  the Flight wire format.
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruact
4
- # Holds the client components encountered during ERB rendering.
5
- # Thread-local so it's safe under concurrent requests.
6
- module ComponentRegistry
7
- THREAD_KEY = :__rsc_component_registry__
8
-
9
- def self.start
10
- Thread.current[THREAD_KEY] = [] # rubocop:disable Ruact/NoSharedState -- TODO: refactor to explicit arg passing (NFR8)
11
- end
12
-
13
- def self.register(name, props)
14
- token = "__RSC_#{components.length}__"
15
- components << { token: token, name: name, props: props }
16
- token
17
- end
18
-
19
- def self.components
20
- Thread.current[THREAD_KEY] ||= [] # rubocop:disable Ruact/NoSharedState -- TODO: refactor to explicit arg passing (NFR8)
21
- end
22
-
23
- def self.reset
24
- Thread.current[THREAD_KEY] = nil # rubocop:disable Ruact/NoSharedState -- TODO: refactor to explicit arg passing (NFR8)
25
- end
26
-
27
- def self.by_token(token)
28
- components.find { |c| c[:token] == token }
29
- end
30
- end
31
- end
data/lib/tasks/rsc.rake DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :rsc do
4
- desc "Check rails_rsc installation and configuration (FR27)"
5
- task doctor: :environment do
6
- require "rails_rsc/doctor"
7
- exit 1 unless RailsRsc::Doctor.run
8
- end
9
- end