ruact 0.0.2 → 0.0.3

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 (128) 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 +86 -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 +1680 -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 +89 -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 +330 -0
  36. data/lib/ruact/server_functions/codegen_v2.rb +176 -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 +188 -0
  40. data/lib/ruact/server_functions/error_suggestion.rb +38 -0
  41. data/lib/ruact/server_functions/name_bridge.rb +113 -0
  42. data/lib/ruact/server_functions/query_context.rb +62 -0
  43. data/lib/ruact/server_functions/query_dispatch.rb +248 -0
  44. data/lib/ruact/server_functions/registry.rb +148 -0
  45. data/lib/ruact/server_functions/registry_entry.rb +26 -0
  46. data/lib/ruact/server_functions/route_source.rb +201 -0
  47. data/lib/ruact/server_functions/snapshot.rb +195 -0
  48. data/lib/ruact/server_functions/snapshot_writer.rb +65 -0
  49. data/lib/ruact/server_functions/standalone_context.rb +103 -0
  50. data/lib/ruact/server_functions/standalone_dispatcher.rb +178 -0
  51. data/lib/ruact/server_functions.rb +75 -0
  52. data/lib/ruact/version.rb +1 -1
  53. data/lib/ruact/view_helper.rb +17 -9
  54. data/lib/ruact.rb +85 -6
  55. data/lib/rubocop/cop/ruact/no_shared_state.rb +1 -1
  56. data/lib/tasks/benchmark.rake +15 -11
  57. data/lib/tasks/ruact.rake +81 -0
  58. data/spec/benchmarks/render_pipeline_benchmark_spec.rb +1 -1
  59. data/spec/fixtures/flight/README.md +55 -7
  60. data/spec/fixtures/flight/bigint.txt +1 -0
  61. data/spec/fixtures/flight/infinity.txt +1 -0
  62. data/spec/fixtures/flight/nan.txt +1 -0
  63. data/spec/fixtures/flight/negative_infinity.txt +1 -0
  64. data/spec/fixtures/flight/undefined.txt +1 -0
  65. data/spec/fixtures/story_7_9_views/controller_request_spec_support/demo/show.html.erb +3 -0
  66. data/spec/ruact/client_manifest_spec.rb +108 -0
  67. data/spec/ruact/configuration_spec.rb +501 -0
  68. data/spec/ruact/controller_request_spec.rb +204 -0
  69. data/spec/ruact/controller_spec.rb +427 -39
  70. data/spec/ruact/doctor_spec.rb +118 -0
  71. data/spec/ruact/erb_preprocessor_hook_spec.rb +3 -3
  72. data/spec/ruact/erb_preprocessor_spec.rb +7 -7
  73. data/spec/ruact/errors_spec.rb +95 -0
  74. data/spec/ruact/flight/renderer_spec.rb +14 -3
  75. data/spec/ruact/flight/serializer_spec.rb +129 -88
  76. data/spec/ruact/html_converter_spec.rb +183 -5
  77. data/spec/ruact/install_generator_spec.rb +93 -0
  78. data/spec/ruact/query_request_spec.rb +446 -0
  79. data/spec/ruact/query_spec.rb +105 -0
  80. data/spec/ruact/railtie_spec.rb +2 -3
  81. data/spec/ruact/render_context_spec.rb +58 -0
  82. data/spec/ruact/render_pipeline_concurrency_spec.rb +78 -0
  83. data/spec/ruact/render_pipeline_spec.rb +784 -330
  84. data/spec/ruact/serializable_spec.rb +8 -8
  85. data/spec/ruact/server_bucket_request_spec.rb +352 -0
  86. data/spec/ruact/server_function_name_spec.rb +53 -0
  87. data/spec/ruact/server_functions/backtrace_cleaner_spec.rb +63 -0
  88. data/spec/ruact/server_functions/bucket_two_payload_spec.rb +200 -0
  89. data/spec/ruact/server_functions/codegen_spec.rb +429 -0
  90. data/spec/ruact/server_functions/csrf_request_spec.rb +380 -0
  91. data/spec/ruact/server_functions/dispatch_request_spec.rb +819 -0
  92. data/spec/ruact/server_functions/error_payload_spec.rb +222 -0
  93. data/spec/ruact/server_functions/error_suggestion_spec.rb +79 -0
  94. data/spec/ruact/server_functions/name_bridge_spec.rb +188 -0
  95. data/spec/ruact/server_functions/query_context_spec.rb +72 -0
  96. data/spec/ruact/server_functions/railtie_integration_spec.rb +345 -0
  97. data/spec/ruact/server_functions/rake_spec.rb +86 -0
  98. data/spec/ruact/server_functions/registry_spec.rb +199 -0
  99. data/spec/ruact/server_functions/route_source_spec.rb +202 -0
  100. data/spec/ruact/server_functions/snapshot_spec.rb +256 -0
  101. data/spec/ruact/server_functions/snapshot_writer_spec.rb +71 -0
  102. data/spec/ruact/server_functions/standalone_action_spec.rb +224 -0
  103. data/spec/ruact/server_functions/standalone_context_spec.rb +142 -0
  104. data/spec/ruact/server_functions/standalone_dispatcher_spec.rb +273 -0
  105. data/spec/ruact/server_rescue_request_spec.rb +416 -0
  106. data/spec/ruact/server_spec.rb +180 -0
  107. data/spec/ruact/server_upload_request_spec.rb +311 -0
  108. data/spec/ruact/view_helper_spec.rb +23 -17
  109. data/spec/spec_helper.rb +52 -1
  110. data/spec/support/fixtures/pixel.png +0 -0
  111. data/spec/support/flight_wire_parser.rb +135 -0
  112. data/spec/support/flight_wire_parser_spec.rb +93 -0
  113. data/spec/support/matchers/flight_fixture_matcher.rb +356 -0
  114. data/spec/support/matchers/flight_fixture_matcher_spec.rb +250 -0
  115. data/spec/support/rails_stub.rb +75 -5
  116. data/vendor/javascript/ruact-server-functions-runtime/index.d.ts +139 -0
  117. data/vendor/javascript/ruact-server-functions-runtime/index.js +438 -0
  118. data/vendor/javascript/ruact-server-functions-runtime/index.test.mjs +827 -0
  119. data/vendor/javascript/ruact-server-functions-runtime/package.json +22 -0
  120. data/vendor/javascript/vite-plugin-ruact/index.js +164 -0
  121. data/vendor/javascript/vite-plugin-ruact/package-lock.json +1429 -0
  122. data/vendor/javascript/vite-plugin-ruact/package.json +15 -0
  123. data/vendor/javascript/vite-plugin-ruact/server-functions-codegen.mjs +761 -0
  124. data/vendor/javascript/vite-plugin-ruact/server-functions-codegen.test.mjs +866 -0
  125. data/vendor/javascript/vite-plugin-ruact/vitest.config.mjs +15 -0
  126. metadata +88 -5
  127. data/lib/ruact/component_registry.rb +0 -31
  128. data/lib/tasks/rsc.rake +0 -9
@@ -0,0 +1,15 @@
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
+ include: ["**/*.test.mjs", "../ruact-server-functions-runtime/*.test.mjs"],
13
+ globals: false,
14
+ },
15
+ });
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.3
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,33 @@ 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/registry.rb
88
+ - lib/ruact/server_functions/registry_entry.rb
89
+ - lib/ruact/server_functions/route_source.rb
90
+ - lib/ruact/server_functions/snapshot.rb
91
+ - lib/ruact/server_functions/snapshot_writer.rb
92
+ - lib/ruact/server_functions/standalone_context.rb
93
+ - lib/ruact/server_functions/standalone_dispatcher.rb
62
94
  - lib/ruact/version.rb
63
95
  - lib/ruact/view_helper.rb
64
96
  - lib/rubocop/cop/ruact.rb
@@ -66,18 +98,22 @@ files:
66
98
  - lib/rubocop/cop/ruact/no_io_in_flight.rb
67
99
  - lib/rubocop/cop/ruact/no_shared_state.rb
68
100
  - lib/tasks/benchmark.rake
69
- - lib/tasks/rsc.rake
101
+ - lib/tasks/ruact.rake
70
102
  - sig/ruact.rbs
71
103
  - spec/benchmarks/baseline.json
72
104
  - spec/benchmarks/render_pipeline_benchmark_spec.rb
73
105
  - spec/fixtures/flight/README.md
74
106
  - spec/fixtures/flight/array.txt
75
107
  - spec/fixtures/flight/as_json_object.txt
108
+ - spec/fixtures/flight/bigint.txt
76
109
  - spec/fixtures/flight/boolean_false.txt
77
110
  - spec/fixtures/flight/boolean_true.txt
78
111
  - spec/fixtures/flight/client_component_with_props.txt
79
112
  - spec/fixtures/flight/client_reference.txt
80
113
  - spec/fixtures/flight/hash.txt
114
+ - spec/fixtures/flight/infinity.txt
115
+ - spec/fixtures/flight/nan.txt
116
+ - spec/fixtures/flight/negative_infinity.txt
81
117
  - spec/fixtures/flight/nil.txt
82
118
  - spec/fixtures/flight/number_float.txt
83
119
  - spec/fixtures/flight/number_integer.txt
@@ -86,7 +122,11 @@ files:
86
122
  - spec/fixtures/flight/serializable_object.txt
87
123
  - spec/fixtures/flight/string_basic.txt
88
124
  - spec/fixtures/flight/string_dollar_escape.txt
125
+ - spec/fixtures/flight/undefined.txt
126
+ - spec/fixtures/story_7_9_views/controller_request_spec_support/demo/show.html.erb
89
127
  - spec/ruact/client_manifest_spec.rb
128
+ - spec/ruact/configuration_spec.rb
129
+ - spec/ruact/controller_request_spec.rb
90
130
  - spec/ruact/controller_spec.rb
91
131
  - spec/ruact/doctor_spec.rb
92
132
  - spec/ruact/erb_preprocessor_hook_spec.rb
@@ -96,13 +136,54 @@ files:
96
136
  - spec/ruact/flight/serializer_spec.rb
97
137
  - spec/ruact/html_converter_spec.rb
98
138
  - spec/ruact/install_generator_spec.rb
139
+ - spec/ruact/query_request_spec.rb
140
+ - spec/ruact/query_spec.rb
99
141
  - spec/ruact/railtie_spec.rb
142
+ - spec/ruact/render_context_spec.rb
143
+ - spec/ruact/render_pipeline_concurrency_spec.rb
100
144
  - spec/ruact/render_pipeline_spec.rb
101
145
  - spec/ruact/serializable_spec.rb
146
+ - spec/ruact/server_bucket_request_spec.rb
147
+ - spec/ruact/server_function_name_spec.rb
148
+ - spec/ruact/server_functions/backtrace_cleaner_spec.rb
149
+ - spec/ruact/server_functions/bucket_two_payload_spec.rb
150
+ - spec/ruact/server_functions/codegen_spec.rb
151
+ - spec/ruact/server_functions/csrf_request_spec.rb
152
+ - spec/ruact/server_functions/dispatch_request_spec.rb
153
+ - spec/ruact/server_functions/error_payload_spec.rb
154
+ - spec/ruact/server_functions/error_suggestion_spec.rb
155
+ - spec/ruact/server_functions/name_bridge_spec.rb
156
+ - spec/ruact/server_functions/query_context_spec.rb
157
+ - spec/ruact/server_functions/railtie_integration_spec.rb
158
+ - spec/ruact/server_functions/rake_spec.rb
159
+ - spec/ruact/server_functions/registry_spec.rb
160
+ - spec/ruact/server_functions/route_source_spec.rb
161
+ - spec/ruact/server_functions/snapshot_spec.rb
162
+ - spec/ruact/server_functions/snapshot_writer_spec.rb
163
+ - spec/ruact/server_functions/standalone_action_spec.rb
164
+ - spec/ruact/server_functions/standalone_context_spec.rb
165
+ - spec/ruact/server_functions/standalone_dispatcher_spec.rb
166
+ - spec/ruact/server_rescue_request_spec.rb
167
+ - spec/ruact/server_spec.rb
168
+ - spec/ruact/server_upload_request_spec.rb
102
169
  - spec/ruact/view_helper_spec.rb
103
170
  - spec/spec_helper.rb
171
+ - spec/support/fixtures/pixel.png
172
+ - spec/support/flight_wire_parser.rb
173
+ - spec/support/flight_wire_parser_spec.rb
104
174
  - spec/support/matchers/flight_fixture_matcher.rb
175
+ - spec/support/matchers/flight_fixture_matcher_spec.rb
105
176
  - spec/support/rails_stub.rb
177
+ - vendor/javascript/ruact-server-functions-runtime/index.d.ts
178
+ - vendor/javascript/ruact-server-functions-runtime/index.js
179
+ - vendor/javascript/ruact-server-functions-runtime/index.test.mjs
180
+ - vendor/javascript/ruact-server-functions-runtime/package.json
181
+ - vendor/javascript/vite-plugin-ruact/index.js
182
+ - vendor/javascript/vite-plugin-ruact/package-lock.json
183
+ - vendor/javascript/vite-plugin-ruact/package.json
184
+ - vendor/javascript/vite-plugin-ruact/server-functions-codegen.mjs
185
+ - vendor/javascript/vite-plugin-ruact/server-functions-codegen.test.mjs
186
+ - vendor/javascript/vite-plugin-ruact/vitest.config.mjs
106
187
  homepage: https://luizcg.github.io/ruact/
107
188
  licenses:
108
189
  - MIT
@@ -113,6 +194,7 @@ metadata:
113
194
  changelog_uri: https://github.com/luizcg/ruact/blob/main/CHANGELOG.md
114
195
  bug_tracker_uri: https://github.com/luizcg/ruact/issues
115
196
  rubygems_mfa_required: 'true'
197
+ post_install_message:
116
198
  rdoc_options: []
117
199
  require_paths:
118
200
  - lib
@@ -127,7 +209,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
209
  - !ruby/object:Gem::Version
128
210
  version: '0'
129
211
  requirements: []
130
- rubygems_version: 3.7.2
212
+ rubygems_version: 3.5.22
213
+ signing_key:
131
214
  specification_version: 4
132
215
  summary: React Server Components for Rails — render React components from ERB using
133
216
  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