react_on_rails_pro 17.0.0.rc.11 → 17.0.0.rc.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 355e4b67d6e24dfdf3303aa6de3d422a78d15f52c77fd8c330269d20df684364
4
- data.tar.gz: 43821f77ed457678324aedd29ef9ea8f8c1b1eeae1633122ce79a11b82c2a8bf
3
+ metadata.gz: 3d36e0dd82c3e50be01aaf9204135207bd96a86ce4f6dcb4c1deb92e8afd7aba
4
+ data.tar.gz: 4e5285618533469d266be67ff7a654fc3d0703bb9e9e503f09ecba12be980fa3
5
5
  SHA512:
6
- metadata.gz: 374a52f15b4167b4d081cd548dc1d257280cc3014919419c7ca1fdf66fb3d580b47be291727fe034417b883de488205630ba3935f0dcaf07622ceebd7edf0484
7
- data.tar.gz: 88cac8f1d67b6fce6bee50f2ff4fab294cc338afa3ac30c579c1e724527ba39a2d090171b6678eaf287b455d7f3fc76a7ec0e4cfa8128c6648c3502a9996bb7a
6
+ metadata.gz: 2505a9d2b0d1b637d7cfdb15424459092c0ab8cec73e23736dc71179565418d991a8f20ced8fa90d71c1e1275d8e2737cfce3c1851b0c658c568481d4d8ad064
7
+ data.tar.gz: 23b8e1a5185d3846cfa8138e5af0c7b94f7d795cf25c355174e3576d35e4d6f8fefa21bebb0d5e4ce7ede51175168941976fa63ccd8abf4aa956b843d44e4f93
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: ..
11
11
  specs:
12
- react_on_rails (17.0.0.rc.11)
12
+ react_on_rails (17.0.0.rc.12)
13
13
  addressable
14
14
  connection_pool
15
15
  execjs (~> 2.5)
@@ -20,14 +20,14 @@ PATH
20
20
  PATH
21
21
  remote: .
22
22
  specs:
23
- react_on_rails_pro (17.0.0.rc.11)
23
+ react_on_rails_pro (17.0.0.rc.12)
24
24
  async (>= 2.29)
25
25
  async-http (~> 0.95)
26
26
  execjs (~> 2.9)
27
27
  io-endpoint (~> 0.17.0)
28
28
  jwt (>= 2.5, < 4)
29
29
  nokogiri (>= 1.12, < 2)
30
- react_on_rails (= 17.0.0.rc.11)
30
+ react_on_rails (= 17.0.0.rc.12)
31
31
 
32
32
  GEM
33
33
  remote: https://rubygems.org/
@@ -264,6 +264,12 @@ module ReactOnRailsProHelper
264
264
  # @see https://reactonrails.com/docs/pro/react-server-components/how-react-server-components-work
265
265
  # for technical details about the RSC payload format
266
266
  def rsc_payload_react_component(component_name, options = {})
267
+ unless ReactOnRailsPro.configuration.enable_rsc_support
268
+ raise ReactOnRailsPro::Error,
269
+ "rsc_payload_react_component requires enable_rsc_support to be true. " \
270
+ "Set `config.enable_rsc_support = true` in your ReactOnRailsPro configuration."
271
+ end
272
+
267
273
  # rsc_payload_react_component doesn't have the prerender option
268
274
  # Because setting prerender to false will not do anything
269
275
  options[:prerender] = true
@@ -15,6 +15,10 @@
15
15
 
16
16
  module ReactOnRailsPro
17
17
  module ServerRenderingJsCode
18
+ PLAIN_STREAMING_RENDER_FUNCTION_NAME =
19
+ "ReactOnRails.isServerStreamingSupported() ? " \
20
+ "'streamServerRenderedReactComponent' : 'serverRenderReactComponent'"
21
+
18
22
  class << self
19
23
  def ssr_pre_hook_js
20
24
  ReactOnRailsPro.configuration.ssr_pre_hook_js || ""
@@ -106,32 +110,42 @@ module ReactOnRailsPro
106
110
  # @param render_options [Object] Options that control the rendering behavior
107
111
  # @return [String] JavaScript code that will render the React component on the server
108
112
  def render(props_string, rails_context, redux_stores, react_component_name, render_options)
113
+ rsc_support_enabled = ReactOnRailsPro.configuration.enable_rsc_support
109
114
  render_function_name =
110
- if ReactOnRailsPro.configuration.enable_rsc_support && render_options.streaming?
115
+ if rsc_support_enabled && render_options.streaming?
111
116
  # Select appropriate function based on whether the rendering request is running on server or rsc bundle
112
117
  # As the same rendering request is used to generate the rsc payload and SSR the component.
113
118
  "ReactOnRails.isRSCBundle ? 'serverRenderRSCReactComponent' : 'streamServerRenderedReactComponent'"
119
+ elsif render_options.streaming?
120
+ PLAIN_STREAMING_RENDER_FUNCTION_NAME
114
121
  else
115
122
  "'serverRenderReactComponent'"
116
123
  end
117
- rsc_params = if ReactOnRailsPro.configuration.enable_rsc_support && render_options.streaming?
118
- config = ReactOnRailsPro.configuration
119
- react_client_manifest_file = config.react_client_manifest_file
120
- react_server_client_manifest_file = config.react_server_client_manifest_file
121
- <<-JS
122
- railsContext.reactClientManifestFileName = #{react_client_manifest_file.to_json};
123
- railsContext.reactServerClientManifestFileName = #{react_server_client_manifest_file.to_json};
124
- JS
125
- else
126
- ""
127
- end
124
+ streaming_params = if rsc_support_enabled && render_options.streaming?
125
+ config = ReactOnRailsPro.configuration
126
+ react_client_manifest_file = config.react_client_manifest_file
127
+ react_server_client_manifest_file = config.react_server_client_manifest_file
128
+ <<-JS
129
+ railsContext.reactClientManifestFileName = #{react_client_manifest_file.to_json};
130
+ railsContext.reactServerClientManifestFileName = #{react_server_client_manifest_file.to_json};
131
+ JS
132
+ elsif render_options.streaming?
133
+ # These keys are part of the streaming renderer contract, but non-RSC builds do not
134
+ # produce RSC manifests. Empty names avoid a failed filesystem lookup on the shell path.
135
+ <<-JS
136
+ railsContext.reactClientManifestFileName = "";
137
+ railsContext.reactServerClientManifestFileName = "";
138
+ JS
139
+ else
140
+ ""
141
+ end
128
142
 
129
143
  # This function is called with specific componentName and props when generateRSCPayload is invoked
130
144
  # In that case, it replaces the empty () with ('componentName', props) in the rendering request
131
145
  <<-JS
132
146
  (function(componentName = #{react_component_name.to_json}, props = undefined) {
133
147
  var railsContext = #{rails_context};
134
- #{rsc_params}
148
+ #{streaming_params}
135
149
  #{generate_rsc_payload_js_function(render_options)}
136
150
  #{ssr_pre_hook_js}
137
151
  #{redux_stores}
@@ -14,6 +14,6 @@
14
14
  # https://github.com/shakacode/react_on_rails/blob/main/REACT-ON-RAILS-PRO-LICENSE.md
15
15
 
16
16
  module ReactOnRailsPro
17
- VERSION = "17.0.0.rc.11"
17
+ VERSION = "17.0.0.rc.12"
18
18
  PROTOCOL_VERSION = "2.0.0"
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react_on_rails_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.0.0.rc.11
4
+ version: 17.0.0.rc.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
@@ -111,14 +111,14 @@ dependencies:
111
111
  requirements:
112
112
  - - '='
113
113
  - !ruby/object:Gem::Version
114
- version: 17.0.0.rc.11
114
+ version: 17.0.0.rc.12
115
115
  type: :runtime
116
116
  prerelease: false
117
117
  version_requirements: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - '='
120
120
  - !ruby/object:Gem::Version
121
- version: 17.0.0.rc.11
121
+ version: 17.0.0.rc.12
122
122
  - !ruby/object:Gem::Dependency
123
123
  name: bundler
124
124
  requirement: !ruby/object:Gem::Requirement