From 3c5c4b79fafc314fb44c8330ec41b7bf44b7a5e4 Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 16:14:19 +0300 Subject: [PATCH 01/25] move CallbackRegistry to pro directory --- node_package/src/ComponentRegistry.ts | 2 +- node_package/src/StoreRegistry.ts | 2 +- node_package/src/{ => pro}/CallbackRegistry.ts | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename node_package/src/{ => pro}/CallbackRegistry.ts (95%) diff --git a/node_package/src/ComponentRegistry.ts b/node_package/src/ComponentRegistry.ts index d6cf72a482..8d8f1ea96c 100644 --- a/node_package/src/ComponentRegistry.ts +++ b/node_package/src/ComponentRegistry.ts @@ -1,6 +1,6 @@ import { type RegisteredComponent, type ReactComponentOrRenderFunction } from './types/index.ts'; import isRenderFunction from './isRenderFunction.ts'; -import CallbackRegistry from './CallbackRegistry.ts'; +import CallbackRegistry from './pro/CallbackRegistry.ts'; const componentRegistry = new CallbackRegistry('component'); diff --git a/node_package/src/StoreRegistry.ts b/node_package/src/StoreRegistry.ts index 0d559c3e2c..e5be010503 100644 --- a/node_package/src/StoreRegistry.ts +++ b/node_package/src/StoreRegistry.ts @@ -1,4 +1,4 @@ -import CallbackRegistry from './CallbackRegistry.ts'; +import CallbackRegistry from './pro/CallbackRegistry.ts'; import type { Store, StoreGenerator } from './types/index.ts'; const storeGeneratorRegistry = new CallbackRegistry('store generator'); diff --git a/node_package/src/CallbackRegistry.ts b/node_package/src/pro/CallbackRegistry.ts similarity index 95% rename from node_package/src/CallbackRegistry.ts rename to node_package/src/pro/CallbackRegistry.ts index e0d5b5ebcc..03f4a80fbd 100644 --- a/node_package/src/CallbackRegistry.ts +++ b/node_package/src/pro/CallbackRegistry.ts @@ -1,6 +1,6 @@ -import { ItemRegistrationCallback } from './types/index.ts'; -import { onPageLoaded, onPageUnloaded } from './pageLifecycle.ts'; -import { getRailsContext } from './context.ts'; +import { ItemRegistrationCallback } from '../types/index.ts'; +import { onPageLoaded, onPageUnloaded } from '../pageLifecycle.ts'; +import { getRailsContext } from '../context.ts'; /** * Represents information about a registered item including its value, From 52b091543b0441bc8c2bec86d45f4f49697dcfbd Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 16:15:30 +0300 Subject: [PATCH 02/25] move ComponentRegistry to pro directory --- node_package/src/ClientSideRenderer.ts | 2 +- node_package/src/ReactOnRails.client.ts | 2 +- node_package/src/{ => pro}/ComponentRegistry.ts | 6 +++--- node_package/src/serverRenderReactComponent.ts | 2 +- node_package/src/streamServerRenderedReactComponent.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename node_package/src/{ => pro}/ComponentRegistry.ts (91%) diff --git a/node_package/src/ClientSideRenderer.ts b/node_package/src/ClientSideRenderer.ts index 3abdbb05eb..81583e6992 100644 --- a/node_package/src/ClientSideRenderer.ts +++ b/node_package/src/ClientSideRenderer.ts @@ -10,7 +10,7 @@ import { supportsHydrate, supportsRootApi, unmountComponentAtNode } from './reac import reactHydrateOrRender from './reactHydrateOrRender.ts'; import { debugTurbolinks } from './turbolinksUtils.ts'; import * as StoreRegistry from './StoreRegistry.ts'; -import * as ComponentRegistry from './ComponentRegistry.ts'; +import * as ComponentRegistry from './pro/ComponentRegistry.ts'; import { onPageLoaded } from './pageLifecycle.ts'; const REACT_ON_RAILS_STORE_ATTRIBUTE = 'data-js-react-on-rails-store'; diff --git a/node_package/src/ReactOnRails.client.ts b/node_package/src/ReactOnRails.client.ts index 752fba1d4c..89333a6351 100644 --- a/node_package/src/ReactOnRails.client.ts +++ b/node_package/src/ReactOnRails.client.ts @@ -1,7 +1,7 @@ import type { ReactElement } from 'react'; import * as ClientStartup from './clientStartup.ts'; import { renderOrHydrateComponent, hydrateStore } from './ClientSideRenderer.ts'; -import * as ComponentRegistry from './ComponentRegistry.ts'; +import * as ComponentRegistry from './pro/ComponentRegistry.ts'; import * as StoreRegistry from './StoreRegistry.ts'; import buildConsoleReplay from './buildConsoleReplay.ts'; import createReactOutput from './createReactOutput.ts'; diff --git a/node_package/src/ComponentRegistry.ts b/node_package/src/pro/ComponentRegistry.ts similarity index 91% rename from node_package/src/ComponentRegistry.ts rename to node_package/src/pro/ComponentRegistry.ts index 8d8f1ea96c..83c61a75f6 100644 --- a/node_package/src/ComponentRegistry.ts +++ b/node_package/src/pro/ComponentRegistry.ts @@ -1,6 +1,6 @@ -import { type RegisteredComponent, type ReactComponentOrRenderFunction } from './types/index.ts'; -import isRenderFunction from './isRenderFunction.ts'; -import CallbackRegistry from './pro/CallbackRegistry.ts'; +import { type RegisteredComponent, type ReactComponentOrRenderFunction } from '../types/index.ts'; +import isRenderFunction from '../isRenderFunction.ts'; +import CallbackRegistry from './CallbackRegistry.ts'; const componentRegistry = new CallbackRegistry('component'); diff --git a/node_package/src/serverRenderReactComponent.ts b/node_package/src/serverRenderReactComponent.ts index a33bb5c144..5d5c50d15c 100644 --- a/node_package/src/serverRenderReactComponent.ts +++ b/node_package/src/serverRenderReactComponent.ts @@ -1,7 +1,7 @@ import * as React from 'react'; import type { ReactElement } from 'react'; -import * as ComponentRegistry from './ComponentRegistry.ts'; +import * as ComponentRegistry from './pro/ComponentRegistry.ts'; import createReactOutput from './createReactOutput.ts'; import { isPromise, isServerRenderHash } from './isServerRenderResult.ts'; import buildConsoleReplay from './buildConsoleReplay.ts'; diff --git a/node_package/src/streamServerRenderedReactComponent.ts b/node_package/src/streamServerRenderedReactComponent.ts index cf6436021c..9d7036cb6c 100644 --- a/node_package/src/streamServerRenderedReactComponent.ts +++ b/node_package/src/streamServerRenderedReactComponent.ts @@ -1,7 +1,7 @@ import * as React from 'react'; import { PassThrough, Readable } from 'stream'; -import * as ComponentRegistry from './ComponentRegistry.ts'; +import * as ComponentRegistry from './pro/ComponentRegistry.ts'; import createReactOutput from './createReactOutput.ts'; import { isPromise, isServerRenderHash } from './isServerRenderResult.ts'; import buildConsoleReplay from './buildConsoleReplay.ts'; From 0b3c32222ad558f52d76ab127faedd1374ffab15 Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 16:17:07 +0300 Subject: [PATCH 03/25] move StoreRegistry to pro directory --- node_package/src/ClientSideRenderer.ts | 2 +- node_package/src/ReactOnRails.client.ts | 2 +- node_package/src/{ => pro}/StoreRegistry.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename node_package/src/{ => pro}/StoreRegistry.ts (96%) diff --git a/node_package/src/ClientSideRenderer.ts b/node_package/src/ClientSideRenderer.ts index 81583e6992..6abd5649d0 100644 --- a/node_package/src/ClientSideRenderer.ts +++ b/node_package/src/ClientSideRenderer.ts @@ -9,7 +9,7 @@ import { isServerRenderHash } from './isServerRenderResult.ts'; import { supportsHydrate, supportsRootApi, unmountComponentAtNode } from './reactApis.cts'; import reactHydrateOrRender from './reactHydrateOrRender.ts'; import { debugTurbolinks } from './turbolinksUtils.ts'; -import * as StoreRegistry from './StoreRegistry.ts'; +import * as StoreRegistry from './pro/StoreRegistry.ts'; import * as ComponentRegistry from './pro/ComponentRegistry.ts'; import { onPageLoaded } from './pageLifecycle.ts'; diff --git a/node_package/src/ReactOnRails.client.ts b/node_package/src/ReactOnRails.client.ts index 89333a6351..be361f6b21 100644 --- a/node_package/src/ReactOnRails.client.ts +++ b/node_package/src/ReactOnRails.client.ts @@ -2,7 +2,7 @@ import type { ReactElement } from 'react'; import * as ClientStartup from './clientStartup.ts'; import { renderOrHydrateComponent, hydrateStore } from './ClientSideRenderer.ts'; import * as ComponentRegistry from './pro/ComponentRegistry.ts'; -import * as StoreRegistry from './StoreRegistry.ts'; +import * as StoreRegistry from './pro/StoreRegistry.ts'; import buildConsoleReplay from './buildConsoleReplay.ts'; import createReactOutput from './createReactOutput.ts'; import * as Authenticity from './Authenticity.ts'; diff --git a/node_package/src/StoreRegistry.ts b/node_package/src/pro/StoreRegistry.ts similarity index 96% rename from node_package/src/StoreRegistry.ts rename to node_package/src/pro/StoreRegistry.ts index e5be010503..3d602ef3ad 100644 --- a/node_package/src/StoreRegistry.ts +++ b/node_package/src/pro/StoreRegistry.ts @@ -1,5 +1,5 @@ -import CallbackRegistry from './pro/CallbackRegistry.ts'; -import type { Store, StoreGenerator } from './types/index.ts'; +import CallbackRegistry from './CallbackRegistry.ts'; +import type { Store, StoreGenerator } from '../types/index.ts'; const storeGeneratorRegistry = new CallbackRegistry('store generator'); const hydratedStoreRegistry = new CallbackRegistry('hydrated store'); From 74d19ea8621f93d6bd8304508376692a24ea479a Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 16:19:26 +0300 Subject: [PATCH 04/25] move client side renderer to pro directory --- node_package/src/ReactOnRails.client.ts | 2 +- node_package/src/clientStartup.ts | 2 +- .../src/{ => pro}/ClientSideRenderer.ts | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) rename node_package/src/{ => pro}/ClientSideRenderer.ts (94%) diff --git a/node_package/src/ReactOnRails.client.ts b/node_package/src/ReactOnRails.client.ts index be361f6b21..a5f1acd48b 100644 --- a/node_package/src/ReactOnRails.client.ts +++ b/node_package/src/ReactOnRails.client.ts @@ -1,6 +1,6 @@ import type { ReactElement } from 'react'; import * as ClientStartup from './clientStartup.ts'; -import { renderOrHydrateComponent, hydrateStore } from './ClientSideRenderer.ts'; +import { renderOrHydrateComponent, hydrateStore } from './pro/ClientSideRenderer.ts'; import * as ComponentRegistry from './pro/ComponentRegistry.ts'; import * as StoreRegistry from './pro/StoreRegistry.ts'; import buildConsoleReplay from './buildConsoleReplay.ts'; diff --git a/node_package/src/clientStartup.ts b/node_package/src/clientStartup.ts index bffefaa3ad..0166ce9984 100644 --- a/node_package/src/clientStartup.ts +++ b/node_package/src/clientStartup.ts @@ -4,7 +4,7 @@ import { renderOrHydrateAllComponents, renderOrHydrateForceLoadedComponents, unmountAll, -} from './ClientSideRenderer.ts'; +} from './pro/ClientSideRenderer.ts'; import { onPageLoaded, onPageUnloaded } from './pageLifecycle.ts'; import { debugTurbolinks } from './turbolinksUtils.ts'; diff --git a/node_package/src/ClientSideRenderer.ts b/node_package/src/pro/ClientSideRenderer.ts similarity index 94% rename from node_package/src/ClientSideRenderer.ts rename to node_package/src/pro/ClientSideRenderer.ts index 6abd5649d0..2a10cc6362 100644 --- a/node_package/src/ClientSideRenderer.ts +++ b/node_package/src/pro/ClientSideRenderer.ts @@ -1,17 +1,17 @@ /* eslint-disable max-classes-per-file */ import type { ReactElement } from 'react'; -import type { RailsContext, RegisteredComponent, RenderFunction, Root } from './types/index.ts'; - -import { getRailsContext, resetRailsContext } from './context.ts'; -import createReactOutput from './createReactOutput.ts'; -import { isServerRenderHash } from './isServerRenderResult.ts'; -import { supportsHydrate, supportsRootApi, unmountComponentAtNode } from './reactApis.cts'; -import reactHydrateOrRender from './reactHydrateOrRender.ts'; -import { debugTurbolinks } from './turbolinksUtils.ts'; -import * as StoreRegistry from './pro/StoreRegistry.ts'; -import * as ComponentRegistry from './pro/ComponentRegistry.ts'; -import { onPageLoaded } from './pageLifecycle.ts'; +import type { RailsContext, RegisteredComponent, RenderFunction, Root } from '../types/index'; + +import { getRailsContext, resetRailsContext } from '../context.ts'; +import createReactOutput from '../createReactOutput.ts'; +import { isServerRenderHash } from '../isServerRenderResult.ts'; +import { supportsHydrate, supportsRootApi, unmountComponentAtNode } from '../reactApis.cts'; +import reactHydrateOrRender from '../reactHydrateOrRender.ts'; +import { debugTurbolinks } from '../turbolinksUtils.ts'; +import * as StoreRegistry from './StoreRegistry.ts'; +import * as ComponentRegistry from './ComponentRegistry.ts'; +import { onPageLoaded } from '../pageLifecycle.ts'; const REACT_ON_RAILS_STORE_ATTRIBUTE = 'data-js-react-on-rails-store'; const IMMEDIATE_HYDRATION_PRO_WARNING = From 001a433f9cad91bb7f02051579349b8240b15a80 Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 23:23:59 +0300 Subject: [PATCH 05/25] Update licensing information and enhance Pro features integration - Updated LICENSE.md to clarify the MIT License applicability and introduce the React on Rails Pro License for specific directories. - Refactored helper methods in `lib/react_on_rails/helper.rb` to utilize new Pro features, including immediate hydration support. - Introduced `lib/react_on_rails/pro_features/helper.rb` to encapsulate Pro feature logic, including immediate hydration and warning badge generation. - Adjusted imports in `node_package/src/ReactOnRails.node.ts` to reflect the new Pro directory structure. - Added new files for React Server Component handling and RSC payload management in the Pro directory, enhancing server-side rendering capabilities. - Improved error handling and stream management for RSC payloads to optimize performance and debugging. --- LICENSE.md | 16 +++- lib/react_on_rails/helper.rb | 62 ++------------ lib/react_on_rails/pro_features/helper.rb | 85 +++++++++++++++++++ node_package/src/ReactOnRails.node.ts | 2 +- node_package/src/pro/ClientSideRenderer.ts | 2 +- .../src/{ => pro}/PostSSRHookTracker.ts | 0 node_package/src/{ => pro}/RSCProvider.tsx | 2 +- .../src/{ => pro}/RSCRequestTracker.ts | 4 +- node_package/src/{ => pro}/RSCRoute.tsx | 0 node_package/src/{ => pro}/ReactOnRailsRSC.ts | 12 +-- .../{ => pro}/ServerComponentFetchError.ts | 0 .../getReactServerComponent.client.ts | 4 +- .../getReactServerComponent.server.ts | 4 +- .../src/{ => pro}/injectRSCPayload.ts | 4 +- .../registerServerComponent/client.tsx | 4 +- .../registerServerComponent/server.rsc.ts | 4 +- .../registerServerComponent/server.tsx | 4 +- .../streamServerRenderedReactComponent.ts | 16 ++-- .../src/{ => pro}/transformRSCNodeStream.ts | 0 .../transformRSCStreamAndReplayConsoleLogs.ts | 2 +- .../wrapServerComponentRenderer/client.tsx | 6 +- .../server.rsc.tsx | 0 .../wrapServerComponentRenderer/server.tsx | 6 +- 23 files changed, 146 insertions(+), 93 deletions(-) create mode 100644 lib/react_on_rails/pro_features/helper.rb rename node_package/src/{ => pro}/PostSSRHookTracker.ts (100%) rename node_package/src/{ => pro}/RSCProvider.tsx (98%) rename node_package/src/{ => pro}/RSCRequestTracker.ts (98%) rename node_package/src/{ => pro}/RSCRoute.tsx (100%) rename node_package/src/{ => pro}/ReactOnRailsRSC.ts (91%) rename node_package/src/{ => pro}/ServerComponentFetchError.ts (100%) rename node_package/src/{ => pro}/getReactServerComponent.client.ts (98%) rename node_package/src/{ => pro}/getReactServerComponent.server.ts (98%) rename node_package/src/{ => pro}/injectRSCPayload.ts (98%) rename node_package/src/{ => pro}/registerServerComponent/client.tsx (93%) rename node_package/src/{ => pro}/registerServerComponent/server.rsc.ts (85%) rename node_package/src/{ => pro}/registerServerComponent/server.tsx (90%) rename node_package/src/{ => pro}/streamServerRenderedReactComponent.ts (96%) rename node_package/src/{ => pro}/transformRSCNodeStream.ts (100%) rename node_package/src/{ => pro}/transformRSCStreamAndReplayConsoleLogs.ts (97%) rename node_package/src/{ => pro}/wrapServerComponentRenderer/client.tsx (95%) rename node_package/src/{ => pro}/wrapServerComponentRenderer/server.rsc.tsx (100%) rename node_package/src/{ => pro}/wrapServerComponentRenderer/server.tsx (95%) diff --git a/LICENSE.md b/LICENSE.md index a68be50afb..8c240b7600 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -5,7 +5,12 @@ --- -# MIT License +## MIT License for Core React on Rails + +This license applies to all files within this repository, with the exception of the code located in the following directories, which are licensed separately under the React on Rails Pro License: + +- `lib/react_on_rails/pro_features/` +- `node_package/src/pro/` Copyright (c) 2017, 2018 Justin Gordon and ShakaCode Copyright (c) 2015–2025 ShakaCode, LLC @@ -31,3 +36,12 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- + +## React on Rails Pro License + +The code in the directories listed above is part of the React on Rails Pro framework and is licensed under the React on Rails Pro License. + +You can find the full text of the license agreement here: +[REACT-ON-RAILS-PRO-LICENSE.md](./REACT-ON-RAILS-PRO-LICENSE.md) diff --git a/lib/react_on_rails/helper.rb b/lib/react_on_rails/helper.rb index 7f06ba5998..379ec3a23d 100644 --- a/lib/react_on_rails/helper.rb +++ b/lib/react_on_rails/helper.rb @@ -11,15 +11,14 @@ require "react_on_rails/utils" require "react_on_rails/json_output" require "active_support/concern" +require "react_on_rails/pro_features/helper" module ReactOnRails module Helper include ReactOnRails::Utils::Required + include ReactOnRails::ProFeatures::Helper COMPONENT_HTML_KEY = "componentHtml" - IMMEDIATE_HYDRATION_PRO_WARNING = "[REACT ON RAILS] The 'immediate_hydration' feature requires a " \ - "React on Rails Pro license. " \ - "Please visit https://shakacode.com/react-on-rails-pro to learn more." # react_component_name: can be a React function or class component or a "Render-Function". # "Render-Functions" differ from a React function in that they take two parameters, the @@ -452,32 +451,6 @@ def load_pack_for_generated_component(react_component_name, render_options) # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity - # Checks if React on Rails Pro features are available - # @return [Boolean] true if Pro license is valid, false otherwise - def support_pro_features? - ReactOnRails::Utils.react_on_rails_pro_licence_valid? - end - - def pro_warning_badge_if_needed(immediate_hydration) - return "".html_safe unless immediate_hydration - return "".html_safe if support_pro_features? - - puts IMMEDIATE_HYDRATION_PRO_WARNING - Rails.logger.warn IMMEDIATE_HYDRATION_PRO_WARNING - - tooltip_text = "The 'immediate_hydration' feature requires a React on Rails Pro license. Click to learn more." - - badge_html = <<~HTML - -
-
- React On Rails Pro Required -
-
-
- HTML - badge_html.strip.html_safe - end def run_stream_inside_fiber unless ReactOnRails::Utils.react_on_rails_pro? @@ -689,17 +662,9 @@ def internal_react_component(react_component_name, options = {}) "data-component-name" => render_options.react_component_name, "data-trace" => (render_options.trace ? true : nil), "data-dom-id" => render_options.dom_id, - "data-store-dependencies" => render_options.store_dependencies&.to_json, - "data-immediate-hydration" => - (render_options.immediate_hydration ? true : nil)) - - if render_options.immediate_hydration - component_specification_tag.concat( - content_tag(:script, %( -typeof ReactOnRails === 'object' && ReactOnRails.reactOnRailsComponentLoaded('#{render_options.dom_id}'); - ).html_safe) - ) - end + "data-store-dependencies" => render_options.store_dependencies&.to_json) + + component_specification_tag = apply_immediate_hydration_if_supported(component_specification_tag, render_options) load_pack_for_generated_component(react_component_name, render_options) # Create the HTML rendering part @@ -717,18 +682,9 @@ def render_redux_store_data(redux_store_data) store_hydration_data = content_tag(:script, json_safe_and_pretty(redux_store_data[:props]).html_safe, type: "application/json", - "data-js-react-on-rails-store" => redux_store_data[:store_name].html_safe, - "data-immediate-hydration" => - (redux_store_data[:immediate_hydration] ? true : nil)) - - if redux_store_data[:immediate_hydration] - store_hydration_data.concat( - content_tag(:script, <<~JS.strip_heredoc.html_safe - typeof ReactOnRails === 'object' && ReactOnRails.reactOnRailsStoreLoaded('#{redux_store_data[:store_name]}'); - JS - ) - ) - end + "data-js-react-on-rails-store" => redux_store_data[:store_name].html_safe) + + store_hydration_data = apply_store_immediate_hydration_if_supported(store_hydration_data, redux_store_data) prepend_render_rails_context(store_hydration_data) end @@ -874,5 +830,3 @@ def raise_missing_autoloaded_bundle(react_component_name) end end end -# rubocop:enable Metrics/ModuleLength -# rubocop:enable Metrics/MethodLength diff --git a/lib/react_on_rails/pro_features/helper.rb b/lib/react_on_rails/pro_features/helper.rb new file mode 100644 index 0000000000..5ed9280c8d --- /dev/null +++ b/lib/react_on_rails/pro_features/helper.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +# /* +# * Copyright (c) 2025 Shakacode +# * +# * This file, and all other files in this directory, are NOT licensed under the MIT license. +# * +# * This file is part of React on Rails Pro. +# * +# * Unauthorized copying, modification, distribution, or use of this file, via any medium, +# * is strictly prohibited. It is proprietary and confidential. +# * +# * For the full license agreement, see: +# * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md +# */ + +module ReactOnRails + module ProFeatures + module Helper + IMMEDIATE_HYDRATION_PRO_WARNING = "[REACT ON RAILS] The 'immediate_hydration' feature requires a " \ + "React on Rails Pro license. " \ + "Please visit https://shakacode.com/react-on-rails-pro to learn more." + + # This method is responsible for generating the necessary attributes and script tags + # for the immediate_hydration feature. It is enabled only when a valid + # React on Rails Pro license is detected. + def apply_immediate_hydration_if_supported(component_specification_tag, render_options) + return component_specification_tag unless render_options.immediate_hydration && support_pro_features? + + # Add data attribute + component_specification_tag.gsub!(/>\z/, ' data-immediate-hydration="true">') + + # Add immediate invocation script + component_specification_tag.concat( + content_tag(:script, %( + typeof ReactOnRails === 'object' && ReactOnRails.reactOnRailsComponentLoaded('#{render_options.dom_id}'); + ).html_safe) + ) + end + + # Similar logic for redux_store + def apply_store_immediate_hydration_if_supported(store_hydration_data, redux_store_data) + return store_hydration_data unless redux_store_data[:immediate_hydration] && support_pro_features? + + # Add data attribute + store_hydration_data.gsub!(/>\z/, ' data-immediate-hydration="true">') + + # Add immediate invocation script + store_hydration_data.concat( + content_tag(:script, <<~JS.strip_heredoc.html_safe + typeof ReactOnRails === 'object' && ReactOnRails.reactOnRailsStoreLoaded('#{redux_store_data[:store_name]}'); + JS + ) + ) + end + + # Checks if React on Rails Pro features are available + # @return [Boolean] true if Pro license is valid, false otherwise + def support_pro_features? + ReactOnRails::Utils.react_on_rails_pro_licence_valid? + end + + def pro_warning_badge_if_needed(immediate_hydration) + return "".html_safe unless immediate_hydration + return "".html_safe if support_pro_features? + + puts IMMEDIATE_HYDRATION_PRO_WARNING + Rails.logger.warn IMMEDIATE_HYDRATION_PRO_WARNING + + tooltip_text = "The 'immediate_hydration' feature requires a React on Rails Pro license. Click to learn more." + + badge_html = <<~HTML + +
+
+ React On Rails Pro Required +
+
+
+ HTML + badge_html.strip.html_safe + end + end + end +end diff --git a/node_package/src/ReactOnRails.node.ts b/node_package/src/ReactOnRails.node.ts index 407d2658b9..5c68cf352b 100644 --- a/node_package/src/ReactOnRails.node.ts +++ b/node_package/src/ReactOnRails.node.ts @@ -1,5 +1,5 @@ import ReactOnRails from './ReactOnRails.full.ts'; -import streamServerRenderedReactComponent from './streamServerRenderedReactComponent.ts'; +import streamServerRenderedReactComponent from './pro/streamServerRenderedReactComponent.ts'; ReactOnRails.streamServerRenderedReactComponent = streamServerRenderedReactComponent; diff --git a/node_package/src/pro/ClientSideRenderer.ts b/node_package/src/pro/ClientSideRenderer.ts index 2a10cc6362..bdf2dcf0bc 100644 --- a/node_package/src/pro/ClientSideRenderer.ts +++ b/node_package/src/pro/ClientSideRenderer.ts @@ -1,7 +1,7 @@ /* eslint-disable max-classes-per-file */ import type { ReactElement } from 'react'; -import type { RailsContext, RegisteredComponent, RenderFunction, Root } from '../types/index'; +import type { RailsContext, RegisteredComponent, RenderFunction, Root } from '../types/index.ts'; import { getRailsContext, resetRailsContext } from '../context.ts'; import createReactOutput from '../createReactOutput.ts'; diff --git a/node_package/src/PostSSRHookTracker.ts b/node_package/src/pro/PostSSRHookTracker.ts similarity index 100% rename from node_package/src/PostSSRHookTracker.ts rename to node_package/src/pro/PostSSRHookTracker.ts diff --git a/node_package/src/RSCProvider.tsx b/node_package/src/pro/RSCProvider.tsx similarity index 98% rename from node_package/src/RSCProvider.tsx rename to node_package/src/pro/RSCProvider.tsx index 61da252972..f2a7d9f485 100644 --- a/node_package/src/RSCProvider.tsx +++ b/node_package/src/pro/RSCProvider.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import type { ClientGetReactServerComponentProps } from './getReactServerComponent.client.ts'; -import { createRSCPayloadKey } from './utils.ts'; +import { createRSCPayloadKey } from '../utils.ts'; type RSCContextType = { getComponent: (componentName: string, componentProps: unknown) => Promise; diff --git a/node_package/src/RSCRequestTracker.ts b/node_package/src/pro/RSCRequestTracker.ts similarity index 98% rename from node_package/src/RSCRequestTracker.ts rename to node_package/src/pro/RSCRequestTracker.ts index 9c6e3e7c5c..a63ca21cec 100644 --- a/node_package/src/RSCRequestTracker.ts +++ b/node_package/src/pro/RSCRequestTracker.ts @@ -1,10 +1,10 @@ import { PassThrough, Readable } from 'stream'; -import { extractErrorMessage } from './utils.ts'; +import { extractErrorMessage } from '../utils.ts'; import { RSCPayloadStreamInfo, RSCPayloadCallback, RailsContextWithServerComponentMetadata, -} from './types/index.ts'; +} from '../types/index.ts'; /** * Global function provided by React on Rails Pro for generating RSC payloads. diff --git a/node_package/src/RSCRoute.tsx b/node_package/src/pro/RSCRoute.tsx similarity index 100% rename from node_package/src/RSCRoute.tsx rename to node_package/src/pro/RSCRoute.tsx diff --git a/node_package/src/ReactOnRailsRSC.ts b/node_package/src/pro/ReactOnRailsRSC.ts similarity index 91% rename from node_package/src/ReactOnRailsRSC.ts rename to node_package/src/pro/ReactOnRailsRSC.ts index 4089238ca0..34d7195bed 100644 --- a/node_package/src/ReactOnRailsRSC.ts +++ b/node_package/src/pro/ReactOnRailsRSC.ts @@ -7,17 +7,17 @@ import { assertRailsContextWithServerStreamingCapabilities, StreamRenderState, StreamableComponentResult, -} from './types/index.ts'; -import ReactOnRails from './ReactOnRails.full.ts'; -import handleError from './handleError.ts'; -import { convertToError } from './serverRenderUtils.ts'; +} from '../types/index.ts'; +import ReactOnRails from '../ReactOnRails.full.ts'; +import handleError from '../handleError.ts'; +import { convertToError } from '../serverRenderUtils.ts'; import { streamServerRenderedComponent, StreamingTrackers, transformRenderStreamChunksToResultObject, } from './streamServerRenderedReactComponent.ts'; -import loadJsonFile from './loadJsonFile.ts'; +import loadJsonFile from '../loadJsonFile.ts'; let serverRendererPromise: Promise> | undefined; @@ -93,5 +93,5 @@ ReactOnRails.serverRenderRSCReactComponent = (options: RSCRenderParams) => { ReactOnRails.isRSCBundle = true; -export * from './types/index.ts'; +export * from '../types/index.ts'; export default ReactOnRails; diff --git a/node_package/src/ServerComponentFetchError.ts b/node_package/src/pro/ServerComponentFetchError.ts similarity index 100% rename from node_package/src/ServerComponentFetchError.ts rename to node_package/src/pro/ServerComponentFetchError.ts diff --git a/node_package/src/getReactServerComponent.client.ts b/node_package/src/pro/getReactServerComponent.client.ts similarity index 98% rename from node_package/src/getReactServerComponent.client.ts rename to node_package/src/pro/getReactServerComponent.client.ts index 45b1a5b4f8..fd1519247d 100644 --- a/node_package/src/getReactServerComponent.client.ts +++ b/node_package/src/pro/getReactServerComponent.client.ts @@ -1,8 +1,8 @@ import * as React from 'react'; import { createFromReadableStream } from 'react-on-rails-rsc/client.browser'; -import { createRSCPayloadKey, fetch, wrapInNewPromise, extractErrorMessage } from './utils.ts'; +import { createRSCPayloadKey, fetch, wrapInNewPromise, extractErrorMessage } from '../utils.ts'; import transformRSCStreamAndReplayConsoleLogs from './transformRSCStreamAndReplayConsoleLogs.ts'; -import { RailsContext } from './types/index.ts'; +import { RailsContext } from '../types/index.ts'; declare global { interface Window { diff --git a/node_package/src/getReactServerComponent.server.ts b/node_package/src/pro/getReactServerComponent.server.ts similarity index 98% rename from node_package/src/getReactServerComponent.server.ts rename to node_package/src/pro/getReactServerComponent.server.ts index 885a712f16..0c1fff2a7b 100644 --- a/node_package/src/getReactServerComponent.server.ts +++ b/node_package/src/pro/getReactServerComponent.server.ts @@ -1,8 +1,8 @@ import { BundleManifest } from 'react-on-rails-rsc'; import { buildClientRenderer } from 'react-on-rails-rsc/client.node'; import transformRSCStream from './transformRSCNodeStream.ts'; -import loadJsonFile from './loadJsonFile.ts'; -import type { RailsContextWithServerStreamingCapabilities } from './types/index.ts'; +import loadJsonFile from '../loadJsonFile.ts'; +import type { RailsContextWithServerStreamingCapabilities } from '../types/index.ts'; type GetReactServerComponentOnServerProps = { componentName: string; diff --git a/node_package/src/injectRSCPayload.ts b/node_package/src/pro/injectRSCPayload.ts similarity index 98% rename from node_package/src/injectRSCPayload.ts rename to node_package/src/pro/injectRSCPayload.ts index 0dea3ab0bc..e3fc7aa7e8 100644 --- a/node_package/src/injectRSCPayload.ts +++ b/node_package/src/pro/injectRSCPayload.ts @@ -1,7 +1,7 @@ import { PassThrough } from 'stream'; import { finished } from 'stream/promises'; -import { createRSCPayloadKey } from './utils.ts'; -import { PipeableOrReadableStream } from './types/index.ts'; +import { createRSCPayloadKey } from '../utils.ts'; +import { PipeableOrReadableStream } from '../types/index.ts'; import RSCRequestTracker from './RSCRequestTracker.ts'; // In JavaScript, when an escape sequence with a backslash (\) is followed by a character diff --git a/node_package/src/registerServerComponent/client.tsx b/node_package/src/pro/registerServerComponent/client.tsx similarity index 93% rename from node_package/src/registerServerComponent/client.tsx rename to node_package/src/pro/registerServerComponent/client.tsx index e24122a39c..dd8d684fc1 100644 --- a/node_package/src/registerServerComponent/client.tsx +++ b/node_package/src/pro/registerServerComponent/client.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; -import ReactOnRails from '../ReactOnRails.client.ts'; +import ReactOnRails from '../../ReactOnRails.client.ts'; import RSCRoute from '../RSCRoute.tsx'; -import { ReactComponentOrRenderFunction } from '../types/index.ts'; +import { ReactComponentOrRenderFunction } from '../../types/index.ts'; import wrapServerComponentRenderer from '../wrapServerComponentRenderer/client.tsx'; /** diff --git a/node_package/src/registerServerComponent/server.rsc.ts b/node_package/src/pro/registerServerComponent/server.rsc.ts similarity index 85% rename from node_package/src/registerServerComponent/server.rsc.ts rename to node_package/src/pro/registerServerComponent/server.rsc.ts index c5ee59c0be..4a8b4c7d61 100644 --- a/node_package/src/registerServerComponent/server.rsc.ts +++ b/node_package/src/pro/registerServerComponent/server.rsc.ts @@ -1,5 +1,5 @@ -import ReactOnRails from '../ReactOnRails.client.ts'; -import { ReactComponent, RenderFunction } from '../types/index.ts'; +import ReactOnRails from '../../ReactOnRails.client.ts'; +import { ReactComponent, RenderFunction } from '../../types/index.ts'; /** * Registers React Server Components in the RSC bundle. diff --git a/node_package/src/registerServerComponent/server.tsx b/node_package/src/pro/registerServerComponent/server.tsx similarity index 90% rename from node_package/src/registerServerComponent/server.tsx rename to node_package/src/pro/registerServerComponent/server.tsx index 6ece231672..7bb75e94e3 100644 --- a/node_package/src/registerServerComponent/server.tsx +++ b/node_package/src/pro/registerServerComponent/server.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; -import ReactOnRails from '../ReactOnRails.client.ts'; +import ReactOnRails from '../../ReactOnRails.client.ts'; import RSCRoute from '../RSCRoute.tsx'; -import { ReactComponent, RenderFunction } from '../types/index.ts'; +import { ReactComponent, RenderFunction } from '../../types/index.ts'; import wrapServerComponentRenderer from '../wrapServerComponentRenderer/server.tsx'; /** diff --git a/node_package/src/streamServerRenderedReactComponent.ts b/node_package/src/pro/streamServerRenderedReactComponent.ts similarity index 96% rename from node_package/src/streamServerRenderedReactComponent.ts rename to node_package/src/pro/streamServerRenderedReactComponent.ts index 9d7036cb6c..91d9a895dd 100644 --- a/node_package/src/streamServerRenderedReactComponent.ts +++ b/node_package/src/pro/streamServerRenderedReactComponent.ts @@ -1,13 +1,13 @@ import * as React from 'react'; import { PassThrough, Readable } from 'stream'; -import * as ComponentRegistry from './pro/ComponentRegistry.ts'; -import createReactOutput from './createReactOutput.ts'; -import { isPromise, isServerRenderHash } from './isServerRenderResult.ts'; -import buildConsoleReplay from './buildConsoleReplay.ts'; -import handleError from './handleError.ts'; -import { renderToPipeableStream } from './ReactDOMServer.cts'; -import { createResultObject, convertToError, validateComponent } from './serverRenderUtils.ts'; +import * as ComponentRegistry from './ComponentRegistry.ts'; +import createReactOutput from '../createReactOutput.ts'; +import { isPromise, isServerRenderHash } from '../isServerRenderResult.ts'; +import buildConsoleReplay from '../buildConsoleReplay.ts'; +import handleError from '../handleError.ts'; +import { renderToPipeableStream } from '../ReactDOMServer.cjs'; +import { createResultObject, convertToError, validateComponent } from '../serverRenderUtils.ts'; import { assertRailsContextWithServerStreamingCapabilities, RenderParams, @@ -16,7 +16,7 @@ import { PipeableOrReadableStream, RailsContextWithServerStreamingCapabilities, assertRailsContextWithServerComponentMetadata, -} from './types/index.ts'; +} from '../types/index.ts'; import injectRSCPayload from './injectRSCPayload.ts'; import PostSSRHookTracker from './PostSSRHookTracker.ts'; import RSCRequestTracker from './RSCRequestTracker.ts'; diff --git a/node_package/src/transformRSCNodeStream.ts b/node_package/src/pro/transformRSCNodeStream.ts similarity index 100% rename from node_package/src/transformRSCNodeStream.ts rename to node_package/src/pro/transformRSCNodeStream.ts diff --git a/node_package/src/transformRSCStreamAndReplayConsoleLogs.ts b/node_package/src/pro/transformRSCStreamAndReplayConsoleLogs.ts similarity index 97% rename from node_package/src/transformRSCStreamAndReplayConsoleLogs.ts rename to node_package/src/pro/transformRSCStreamAndReplayConsoleLogs.ts index 724706e552..cc30e39fe3 100644 --- a/node_package/src/transformRSCStreamAndReplayConsoleLogs.ts +++ b/node_package/src/pro/transformRSCStreamAndReplayConsoleLogs.ts @@ -1,4 +1,4 @@ -import { RSCPayloadChunk } from './types/index.ts'; +import { RSCPayloadChunk } from '../types/index.ts'; /** * Transforms an RSC stream and replays console logs on the client. diff --git a/node_package/src/wrapServerComponentRenderer/client.tsx b/node_package/src/pro/wrapServerComponentRenderer/client.tsx similarity index 95% rename from node_package/src/wrapServerComponentRenderer/client.tsx rename to node_package/src/pro/wrapServerComponentRenderer/client.tsx index 491b7866b0..dd1c032191 100644 --- a/node_package/src/wrapServerComponentRenderer/client.tsx +++ b/node_package/src/pro/wrapServerComponentRenderer/client.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import * as ReactDOMClient from 'react-dom/client'; -import { ReactComponentOrRenderFunction, RenderFunction } from '../types/index.ts'; -import isRenderFunction from '../isRenderFunction.ts'; -import { ensureReactUseAvailable } from '../reactApis.cts'; +import { ReactComponentOrRenderFunction, RenderFunction } from '../../types/index.ts'; +import isRenderFunction from '../../isRenderFunction.ts'; +import { ensureReactUseAvailable } from '../../reactApis.cjs'; import { createRSCProvider } from '../RSCProvider.tsx'; import getReactServerComponent from '../getReactServerComponent.client.ts'; diff --git a/node_package/src/wrapServerComponentRenderer/server.rsc.tsx b/node_package/src/pro/wrapServerComponentRenderer/server.rsc.tsx similarity index 100% rename from node_package/src/wrapServerComponentRenderer/server.rsc.tsx rename to node_package/src/pro/wrapServerComponentRenderer/server.rsc.tsx diff --git a/node_package/src/wrapServerComponentRenderer/server.tsx b/node_package/src/pro/wrapServerComponentRenderer/server.tsx similarity index 95% rename from node_package/src/wrapServerComponentRenderer/server.tsx rename to node_package/src/pro/wrapServerComponentRenderer/server.tsx index f4c022c474..ff694330a0 100644 --- a/node_package/src/wrapServerComponentRenderer/server.tsx +++ b/node_package/src/pro/wrapServerComponentRenderer/server.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; -import type { RenderFunction, ReactComponentOrRenderFunction } from '../types/index.ts'; +import type { RenderFunction, ReactComponentOrRenderFunction } from '../../types/index.ts'; import getReactServerComponent from '../getReactServerComponent.server.ts'; import { createRSCProvider } from '../RSCProvider.tsx'; -import isRenderFunction from '../isRenderFunction.ts'; -import { assertRailsContextWithServerStreamingCapabilities } from '../types/index.ts'; +import isRenderFunction from '../../isRenderFunction.ts'; +import { assertRailsContextWithServerStreamingCapabilities } from '../../types/index.ts'; /** * Wraps a client component with the necessary RSC context and handling for server-side operations. From c890168f0cec8c10f4446c1213827f4e7887c30f Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 23:32:05 +0300 Subject: [PATCH 06/25] Add proprietary licensing information to multiple Pro files - Introduced a proprietary license notice to various files in the Pro directory, clarifying that these files are not licensed under the MIT license and are part of React on Rails Pro. - This update enhances the legal protection of the codebase and ensures compliance with proprietary usage guidelines. --- node_package/src/pro/CallbackRegistry.ts | 14 ++++++++++++++ node_package/src/pro/ClientSideRenderer.ts | 14 ++++++++++++++ node_package/src/pro/ComponentRegistry.ts | 14 ++++++++++++++ node_package/src/pro/PostSSRHookTracker.ts | 14 ++++++++++++++ node_package/src/pro/RSCProvider.tsx | 14 ++++++++++++++ node_package/src/pro/RSCRequestTracker.ts | 14 ++++++++++++++ node_package/src/pro/RSCRoute.tsx | 14 ++++++++++++++ node_package/src/pro/ReactOnRailsRSC.ts | 14 ++++++++++++++ node_package/src/pro/ServerComponentFetchError.ts | 14 ++++++++++++++ node_package/src/pro/StoreRegistry.ts | 14 ++++++++++++++ .../src/pro/getReactServerComponent.client.ts | 14 ++++++++++++++ .../src/pro/getReactServerComponent.server.ts | 14 ++++++++++++++ node_package/src/pro/injectRSCPayload.ts | 14 ++++++++++++++ .../src/pro/registerServerComponent/client.tsx | 14 ++++++++++++++ .../src/pro/registerServerComponent/server.rsc.ts | 14 ++++++++++++++ .../src/pro/registerServerComponent/server.tsx | 14 ++++++++++++++ .../src/pro/streamServerRenderedReactComponent.ts | 14 ++++++++++++++ node_package/src/pro/transformRSCNodeStream.ts | 14 ++++++++++++++ .../pro/transformRSCStreamAndReplayConsoleLogs.ts | 14 ++++++++++++++ .../src/pro/wrapServerComponentRenderer/client.tsx | 14 ++++++++++++++ .../pro/wrapServerComponentRenderer/server.rsc.tsx | 14 ++++++++++++++ .../src/pro/wrapServerComponentRenderer/server.tsx | 14 ++++++++++++++ 22 files changed, 308 insertions(+) diff --git a/node_package/src/pro/CallbackRegistry.ts b/node_package/src/pro/CallbackRegistry.ts index 03f4a80fbd..665918f134 100644 --- a/node_package/src/pro/CallbackRegistry.ts +++ b/node_package/src/pro/CallbackRegistry.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import { ItemRegistrationCallback } from '../types/index.ts'; import { onPageLoaded, onPageUnloaded } from '../pageLifecycle.ts'; import { getRailsContext } from '../context.ts'; diff --git a/node_package/src/pro/ClientSideRenderer.ts b/node_package/src/pro/ClientSideRenderer.ts index bdf2dcf0bc..807bbb4e94 100644 --- a/node_package/src/pro/ClientSideRenderer.ts +++ b/node_package/src/pro/ClientSideRenderer.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + /* eslint-disable max-classes-per-file */ import type { ReactElement } from 'react'; diff --git a/node_package/src/pro/ComponentRegistry.ts b/node_package/src/pro/ComponentRegistry.ts index 83c61a75f6..bb6f9854b9 100644 --- a/node_package/src/pro/ComponentRegistry.ts +++ b/node_package/src/pro/ComponentRegistry.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import { type RegisteredComponent, type ReactComponentOrRenderFunction } from '../types/index.ts'; import isRenderFunction from '../isRenderFunction.ts'; import CallbackRegistry from './CallbackRegistry.ts'; diff --git a/node_package/src/pro/PostSSRHookTracker.ts b/node_package/src/pro/PostSSRHookTracker.ts index f18de7f1dd..4d84f9ff54 100644 --- a/node_package/src/pro/PostSSRHookTracker.ts +++ b/node_package/src/pro/PostSSRHookTracker.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + type PostSSRHook = () => void; /** diff --git a/node_package/src/pro/RSCProvider.tsx b/node_package/src/pro/RSCProvider.tsx index f2a7d9f485..0101467163 100644 --- a/node_package/src/pro/RSCProvider.tsx +++ b/node_package/src/pro/RSCProvider.tsx @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import * as React from 'react'; import type { ClientGetReactServerComponentProps } from './getReactServerComponent.client.ts'; import { createRSCPayloadKey } from '../utils.ts'; diff --git a/node_package/src/pro/RSCRequestTracker.ts b/node_package/src/pro/RSCRequestTracker.ts index a63ca21cec..bfdf27f6ea 100644 --- a/node_package/src/pro/RSCRequestTracker.ts +++ b/node_package/src/pro/RSCRequestTracker.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import { PassThrough, Readable } from 'stream'; import { extractErrorMessage } from '../utils.ts'; import { diff --git a/node_package/src/pro/RSCRoute.tsx b/node_package/src/pro/RSCRoute.tsx index eb52e2d9f5..43a9798dc1 100644 --- a/node_package/src/pro/RSCRoute.tsx +++ b/node_package/src/pro/RSCRoute.tsx @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import * as React from 'react'; import { useRSC } from './RSCProvider.tsx'; import { ServerComponentFetchError } from './ServerComponentFetchError.ts'; diff --git a/node_package/src/pro/ReactOnRailsRSC.ts b/node_package/src/pro/ReactOnRailsRSC.ts index 34d7195bed..8168fd4590 100644 --- a/node_package/src/pro/ReactOnRailsRSC.ts +++ b/node_package/src/pro/ReactOnRailsRSC.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import { BundleManifest } from 'react-on-rails-rsc'; import { buildServerRenderer } from 'react-on-rails-rsc/server.node'; import { Readable } from 'stream'; diff --git a/node_package/src/pro/ServerComponentFetchError.ts b/node_package/src/pro/ServerComponentFetchError.ts index f1c4d95cce..5fa44934f0 100644 --- a/node_package/src/pro/ServerComponentFetchError.ts +++ b/node_package/src/pro/ServerComponentFetchError.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + /** * Custom error type for when there's an issue fetching or rendering a server component. * This error includes information about the server component and the original error that occurred. diff --git a/node_package/src/pro/StoreRegistry.ts b/node_package/src/pro/StoreRegistry.ts index 3d602ef3ad..dd2f69b2c1 100644 --- a/node_package/src/pro/StoreRegistry.ts +++ b/node_package/src/pro/StoreRegistry.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import CallbackRegistry from './CallbackRegistry.ts'; import type { Store, StoreGenerator } from '../types/index.ts'; diff --git a/node_package/src/pro/getReactServerComponent.client.ts b/node_package/src/pro/getReactServerComponent.client.ts index fd1519247d..7bec42d093 100644 --- a/node_package/src/pro/getReactServerComponent.client.ts +++ b/node_package/src/pro/getReactServerComponent.client.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import * as React from 'react'; import { createFromReadableStream } from 'react-on-rails-rsc/client.browser'; import { createRSCPayloadKey, fetch, wrapInNewPromise, extractErrorMessage } from '../utils.ts'; diff --git a/node_package/src/pro/getReactServerComponent.server.ts b/node_package/src/pro/getReactServerComponent.server.ts index 0c1fff2a7b..eae5ec4352 100644 --- a/node_package/src/pro/getReactServerComponent.server.ts +++ b/node_package/src/pro/getReactServerComponent.server.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import { BundleManifest } from 'react-on-rails-rsc'; import { buildClientRenderer } from 'react-on-rails-rsc/client.node'; import transformRSCStream from './transformRSCNodeStream.ts'; diff --git a/node_package/src/pro/injectRSCPayload.ts b/node_package/src/pro/injectRSCPayload.ts index e3fc7aa7e8..3fdd4b195f 100644 --- a/node_package/src/pro/injectRSCPayload.ts +++ b/node_package/src/pro/injectRSCPayload.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import { PassThrough } from 'stream'; import { finished } from 'stream/promises'; import { createRSCPayloadKey } from '../utils.ts'; diff --git a/node_package/src/pro/registerServerComponent/client.tsx b/node_package/src/pro/registerServerComponent/client.tsx index dd8d684fc1..00144b685f 100644 --- a/node_package/src/pro/registerServerComponent/client.tsx +++ b/node_package/src/pro/registerServerComponent/client.tsx @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import * as React from 'react'; import ReactOnRails from '../../ReactOnRails.client.ts'; import RSCRoute from '../RSCRoute.tsx'; diff --git a/node_package/src/pro/registerServerComponent/server.rsc.ts b/node_package/src/pro/registerServerComponent/server.rsc.ts index 4a8b4c7d61..4f34137a38 100644 --- a/node_package/src/pro/registerServerComponent/server.rsc.ts +++ b/node_package/src/pro/registerServerComponent/server.rsc.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import ReactOnRails from '../../ReactOnRails.client.ts'; import { ReactComponent, RenderFunction } from '../../types/index.ts'; diff --git a/node_package/src/pro/registerServerComponent/server.tsx b/node_package/src/pro/registerServerComponent/server.tsx index 7bb75e94e3..ac8e9203b9 100644 --- a/node_package/src/pro/registerServerComponent/server.tsx +++ b/node_package/src/pro/registerServerComponent/server.tsx @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import * as React from 'react'; import ReactOnRails from '../../ReactOnRails.client.ts'; import RSCRoute from '../RSCRoute.tsx'; diff --git a/node_package/src/pro/streamServerRenderedReactComponent.ts b/node_package/src/pro/streamServerRenderedReactComponent.ts index 91d9a895dd..e0034d9878 100644 --- a/node_package/src/pro/streamServerRenderedReactComponent.ts +++ b/node_package/src/pro/streamServerRenderedReactComponent.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import * as React from 'react'; import { PassThrough, Readable } from 'stream'; diff --git a/node_package/src/pro/transformRSCNodeStream.ts b/node_package/src/pro/transformRSCNodeStream.ts index e26f1a44a5..13d488ee7b 100644 --- a/node_package/src/pro/transformRSCNodeStream.ts +++ b/node_package/src/pro/transformRSCNodeStream.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import { Transform } from 'stream'; /** diff --git a/node_package/src/pro/transformRSCStreamAndReplayConsoleLogs.ts b/node_package/src/pro/transformRSCStreamAndReplayConsoleLogs.ts index cc30e39fe3..decd96983d 100644 --- a/node_package/src/pro/transformRSCStreamAndReplayConsoleLogs.ts +++ b/node_package/src/pro/transformRSCStreamAndReplayConsoleLogs.ts @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import { RSCPayloadChunk } from '../types/index.ts'; /** diff --git a/node_package/src/pro/wrapServerComponentRenderer/client.tsx b/node_package/src/pro/wrapServerComponentRenderer/client.tsx index dd1c032191..f0af6bda55 100644 --- a/node_package/src/pro/wrapServerComponentRenderer/client.tsx +++ b/node_package/src/pro/wrapServerComponentRenderer/client.tsx @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import * as React from 'react'; import * as ReactDOMClient from 'react-dom/client'; import { ReactComponentOrRenderFunction, RenderFunction } from '../../types/index.ts'; diff --git a/node_package/src/pro/wrapServerComponentRenderer/server.rsc.tsx b/node_package/src/pro/wrapServerComponentRenderer/server.rsc.tsx index 2da98f23fc..d279bed868 100644 --- a/node_package/src/pro/wrapServerComponentRenderer/server.rsc.tsx +++ b/node_package/src/pro/wrapServerComponentRenderer/server.rsc.tsx @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + const wrapServerComponentRenderer = () => { // Do nothing // Server component renderers are client components and not needed in the RSC bundle diff --git a/node_package/src/pro/wrapServerComponentRenderer/server.tsx b/node_package/src/pro/wrapServerComponentRenderer/server.tsx index ff694330a0..73c8fc8ea8 100644 --- a/node_package/src/pro/wrapServerComponentRenderer/server.tsx +++ b/node_package/src/pro/wrapServerComponentRenderer/server.tsx @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 Shakacode + * + * This file, and all other files in this directory, are NOT licensed under the MIT license. + * + * This file is part of React on Rails Pro. + * + * Unauthorized copying, modification, distribution, or use of this file, via any medium, + * is strictly prohibited. It is proprietary and confidential. + * + * For the full license agreement, see: + * https://github.com/shakacode/react_on_rails/blob/master/REACT-ON-RAILS-PRO-LICENSE.md + */ + import * as React from 'react'; import type { RenderFunction, ReactComponentOrRenderFunction } from '../../types/index.ts'; import getReactServerComponent from '../getReactServerComponent.server.ts'; From 444af6286acccafe322d439b60dd827f664c2309 Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 23:38:52 +0300 Subject: [PATCH 07/25] Update package.json to reflect new Pro directory structure - Moved various React on Rails files to the Pro directory, updating paths in the exports section of package.json. - This change aligns with the recent restructuring to enhance the organization of Pro features and components. --- package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 757031f5d2..3ce4e03cb5 100644 --- a/package.json +++ b/package.json @@ -6,24 +6,24 @@ "type": "module", "exports": { ".": { - "react-server": "./node_package/lib/ReactOnRailsRSC.js", + "react-server": "./node_package/lib/pro/ReactOnRailsRSC.js", "node": "./node_package/lib/ReactOnRails.node.js", "default": "./node_package/lib/ReactOnRails.full.js" }, "./client": "./node_package/lib/ReactOnRails.client.js", - "./registerServerComponent/client": "./node_package/lib/registerServerComponent/client.js", + "./registerServerComponent/client": "./node_package/lib/pro/registerServerComponent/client.js", "./registerServerComponent/server": { - "react-server": "./node_package/lib/registerServerComponent/server.rsc.js", - "default": "./node_package/lib/registerServerComponent/server.js" + "react-server": "./node_package/lib/pro/registerServerComponent/server.rsc.js", + "default": "./node_package/lib/pro/registerServerComponent/server.js" }, - "./wrapServerComponentRenderer/client": "./node_package/lib/wrapServerComponentRenderer/client.js", + "./wrapServerComponentRenderer/client": "./node_package/lib/pro/wrapServerComponentRenderer/client.js", "./wrapServerComponentRenderer/server": { - "react-server": "./node_package/lib/wrapServerComponentRenderer/server.rsc.js", - "default": "./node_package/lib/wrapServerComponentRenderer/server.js" + "react-server": "./node_package/lib/pro/wrapServerComponentRenderer/server.rsc.js", + "default": "./node_package/lib/pro/wrapServerComponentRenderer/server.js" }, - "./RSCRoute": "./node_package/lib/RSCRoute.js", - "./RSCProvider": "./node_package/lib/RSCProvider.js", - "./ServerComponentFetchError": "./node_package/lib/ServerComponentFetchError.js" + "./RSCRoute": "./node_package/lib/pro/RSCRoute.js", + "./RSCProvider": "./node_package/lib/pro/RSCProvider.js", + "./ServerComponentFetchError": "./node_package/lib/pro/ServerComponentFetchError.js" }, "directories": { "doc": "docs" From 8a9b7cfec297a3d3e61bbde9f7da9ec60cabf5e4 Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 23:42:33 +0300 Subject: [PATCH 08/25] Refactor test imports to align with new Pro directory structure - Updated import paths in multiple test files to reflect the relocation of components to the Pro directory. - This change ensures consistency and maintains the integrity of the testing framework following recent structural adjustments. --- node_package/tests/ComponentRegistry.test.js | 2 +- node_package/tests/StoreRegistry.test.js | 2 +- node_package/tests/injectRSCPayload.test.ts | 4 ++-- node_package/tests/registerServerComponent.client.test.jsx | 4 ++-- node_package/tests/serverRenderReactComponent.test.ts | 2 +- .../tests/streamServerRenderedReactComponent.test.jsx | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/node_package/tests/ComponentRegistry.test.js b/node_package/tests/ComponentRegistry.test.js index 1b5fe51773..c61cbfc931 100644 --- a/node_package/tests/ComponentRegistry.test.js +++ b/node_package/tests/ComponentRegistry.test.js @@ -6,7 +6,7 @@ import * as React from 'react'; import * as createReactClass from 'create-react-class'; -import * as ComponentRegistry from '../src/ComponentRegistry.ts'; +import * as ComponentRegistry from '../src/pro/ComponentRegistry.ts'; const onPageLoadedCallbacks = []; const onPageUnloadedCallbacks = []; diff --git a/node_package/tests/StoreRegistry.test.js b/node_package/tests/StoreRegistry.test.js index 3a498fb345..dd64ef8b86 100644 --- a/node_package/tests/StoreRegistry.test.js +++ b/node_package/tests/StoreRegistry.test.js @@ -1,6 +1,6 @@ import { createStore } from 'redux'; -import * as StoreRegistry from '../src/StoreRegistry.ts'; +import * as StoreRegistry from '../src/pro/StoreRegistry.ts'; function reducer() { return {}; diff --git a/node_package/tests/injectRSCPayload.test.ts b/node_package/tests/injectRSCPayload.test.ts index b13db1c955..e20d67bfa8 100644 --- a/node_package/tests/injectRSCPayload.test.ts +++ b/node_package/tests/injectRSCPayload.test.ts @@ -1,7 +1,7 @@ import { Readable, PassThrough } from 'stream'; import { RailsContextWithServerStreamingCapabilities } from '../src/types/index.ts'; -import injectRSCPayload from '../src/injectRSCPayload.ts'; -import RSCRequestTracker from '../src/RSCRequestTracker.ts'; +import injectRSCPayload from '../src/pro/injectRSCPayload.ts'; +import RSCRequestTracker from '../src/pro/RSCRequestTracker.ts'; // Shared utilities const createMockStream = (chunks: (string | Buffer)[] | { [key: number]: string | string[] }) => { diff --git a/node_package/tests/registerServerComponent.client.test.jsx b/node_package/tests/registerServerComponent.client.test.jsx index e9bad6cf8f..10dc37af84 100644 --- a/node_package/tests/registerServerComponent.client.test.jsx +++ b/node_package/tests/registerServerComponent.client.test.jsx @@ -11,8 +11,8 @@ import * as path from 'path'; import * as fs from 'fs'; import { createNodeReadableStream, getNodeVersion } from './testUtils.js'; import ReactOnRails from '../src/ReactOnRails.client.ts'; -import registerServerComponent from '../src/registerServerComponent/client.tsx'; -import { clear as clearComponentRegistry } from '../src/ComponentRegistry.ts'; +import registerServerComponent from '../src/pro/registerServerComponent/client.tsx'; +import { clear as clearComponentRegistry } from '../src/pro/ComponentRegistry.ts'; enableFetchMocks(); diff --git a/node_package/tests/serverRenderReactComponent.test.ts b/node_package/tests/serverRenderReactComponent.test.ts index 3d684f1495..3a55957896 100644 --- a/node_package/tests/serverRenderReactComponent.test.ts +++ b/node_package/tests/serverRenderReactComponent.test.ts @@ -1,6 +1,6 @@ import * as React from 'react'; import serverRenderReactComponent from '../src/serverRenderReactComponent.ts'; -import * as ComponentRegistry from '../src/ComponentRegistry.ts'; +import * as ComponentRegistry from '../src/pro/ComponentRegistry.ts'; import type { RenderParams, RenderResult, diff --git a/node_package/tests/streamServerRenderedReactComponent.test.jsx b/node_package/tests/streamServerRenderedReactComponent.test.jsx index 7fb0421869..60eb1b2b45 100644 --- a/node_package/tests/streamServerRenderedReactComponent.test.jsx +++ b/node_package/tests/streamServerRenderedReactComponent.test.jsx @@ -4,8 +4,8 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; -import streamServerRenderedReactComponent from '../src/streamServerRenderedReactComponent.ts'; -import * as ComponentRegistry from '../src/ComponentRegistry.ts'; +import streamServerRenderedReactComponent from '../src/pro/streamServerRenderedReactComponent.ts'; +import * as ComponentRegistry from '../src/pro/ComponentRegistry.ts'; import ReactOnRails from '../src/ReactOnRails.node.ts'; const AsyncContent = async ({ throwAsyncError }) => { From 6e3aa5b3da1ec237612160e0c86a87494491a2aa Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 23:47:15 +0300 Subject: [PATCH 09/25] Update import paths in Pro directory to use .cts extensions - Changed import statements in `streamServerRenderedReactComponent.ts` and `client.tsx` to reference the new .cts file extensions for improved module resolution. - This update aligns with recent changes in the Pro directory structure, ensuring compatibility with the latest file organization. --- node_package/src/pro/streamServerRenderedReactComponent.ts | 2 +- node_package/src/pro/wrapServerComponentRenderer/client.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node_package/src/pro/streamServerRenderedReactComponent.ts b/node_package/src/pro/streamServerRenderedReactComponent.ts index e0034d9878..5b3a2a4b6b 100644 --- a/node_package/src/pro/streamServerRenderedReactComponent.ts +++ b/node_package/src/pro/streamServerRenderedReactComponent.ts @@ -20,7 +20,7 @@ import createReactOutput from '../createReactOutput.ts'; import { isPromise, isServerRenderHash } from '../isServerRenderResult.ts'; import buildConsoleReplay from '../buildConsoleReplay.ts'; import handleError from '../handleError.ts'; -import { renderToPipeableStream } from '../ReactDOMServer.cjs'; +import { renderToPipeableStream } from '../ReactDOMServer.cts'; import { createResultObject, convertToError, validateComponent } from '../serverRenderUtils.ts'; import { assertRailsContextWithServerStreamingCapabilities, diff --git a/node_package/src/pro/wrapServerComponentRenderer/client.tsx b/node_package/src/pro/wrapServerComponentRenderer/client.tsx index f0af6bda55..5c2bca8313 100644 --- a/node_package/src/pro/wrapServerComponentRenderer/client.tsx +++ b/node_package/src/pro/wrapServerComponentRenderer/client.tsx @@ -16,7 +16,7 @@ import * as React from 'react'; import * as ReactDOMClient from 'react-dom/client'; import { ReactComponentOrRenderFunction, RenderFunction } from '../../types/index.ts'; import isRenderFunction from '../../isRenderFunction.ts'; -import { ensureReactUseAvailable } from '../../reactApis.cjs'; +import { ensureReactUseAvailable } from '../../reactApis.cts'; import { createRSCProvider } from '../RSCProvider.tsx'; import getReactServerComponent from '../getReactServerComponent.client.ts'; From 050649686b7b5d194d360d8ca462af04b2b37aaa Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 23:50:20 +0300 Subject: [PATCH 10/25] Update test import path to reflect new Pro directory structure - Modified the import statement in `registerServerComponent.client.test.jsx` to point to the updated location of `client.tsx` within the Pro directory. - This change ensures that the test suite remains functional and aligned with recent structural adjustments in the codebase. --- node_package/tests/registerServerComponent.client.test.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_package/tests/registerServerComponent.client.test.jsx b/node_package/tests/registerServerComponent.client.test.jsx index 10dc37af84..abc7f71d31 100644 --- a/node_package/tests/registerServerComponent.client.test.jsx +++ b/node_package/tests/registerServerComponent.client.test.jsx @@ -44,7 +44,7 @@ enableFetchMocks(); expect(() => { // Re-import to trigger the check - jest.requireActual('../src/wrapServerComponentRenderer/client.tsx'); + jest.requireActual('../src/pro/wrapServerComponentRenderer/client.tsx'); }).toThrow('React.use is not defined'); }); From f91c629e26c712dacc68717101e290daeaf0ba8e Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Thu, 18 Sep 2025 23:55:48 +0300 Subject: [PATCH 11/25] fix rubocop errors --- lib/react_on_rails/helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/react_on_rails/helper.rb b/lib/react_on_rails/helper.rb index 379ec3a23d..3b334737a8 100644 --- a/lib/react_on_rails/helper.rb +++ b/lib/react_on_rails/helper.rb @@ -451,7 +451,6 @@ def load_pack_for_generated_component(react_component_name, render_options) # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity - def run_stream_inside_fiber unless ReactOnRails::Utils.react_on_rails_pro? raise ReactOnRails::Error, @@ -830,3 +829,5 @@ def raise_missing_autoloaded_bundle(react_component_name) end end end +# rubocop:enable Metrics/ModuleLength +# rubocop:enable Metrics/MethodLength From 09fb0fcc4fa081f44a6ed3ea31c846ff015490e3 Mon Sep 17 00:00:00 2001 From: Abanoub Ghadban Date: Fri, 19 Sep 2025 00:19:25 +0300 Subject: [PATCH 12/25] Refactor immediate hydration data attribute handling in Pro features - Updated the `helper.rb` file to modify how the `data-immediate-hydration` attribute is added to script tags, ensuring it is correctly applied during immediate hydration. - Adjusted the test helper spec to correct the formatting of the immediate hydration script, enhancing clarity and functionality. --- lib/react_on_rails/pro_features/helper.rb | 4 ++-- spec/dummy/spec/helpers/react_on_rails_helper_spec.rb | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/react_on_rails/pro_features/helper.rb b/lib/react_on_rails/pro_features/helper.rb index 5ed9280c8d..64f468e406 100644 --- a/lib/react_on_rails/pro_features/helper.rb +++ b/lib/react_on_rails/pro_features/helper.rb @@ -28,7 +28,7 @@ def apply_immediate_hydration_if_supported(component_specification_tag, render_o return component_specification_tag unless render_options.immediate_hydration && support_pro_features? # Add data attribute - component_specification_tag.gsub!(/>\z/, ' data-immediate-hydration="true">') + component_specification_tag.gsub!(/\