react_on_rails 14.1.0 → 15.0.0.alpha.1

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: d8ff0817a7547720cf418f0f13cb7e6cdb681e14dd1e429710805534da73cffe
4
- data.tar.gz: 963ac73c65c73a94d602488c63ba97073779100bfed64bb4c731cf24da37a192
3
+ metadata.gz: 7d60051000fbd817b3499b1de6f13c9abeaf5627bee250c50bf0d748ce3532a5
4
+ data.tar.gz: 4eccfe81e12b647503fa6e690c514d4d14d6704ab1e5c7f64282cafa7709d6e2
5
5
  SHA512:
6
- metadata.gz: 9793268e809976118cf7efe90b0dba1ebc32f3a58137c4e0fffec895c2f43c6c68fd0634f1452cca1aebc2776b89325cd945b1e6fa276d94c3576d32a8ad8124
7
- data.tar.gz: 98013bd6cdfa9bb8eee1e7d7cda819f13a747e47e7fa8495f1bec73cca3bbaa363a92c18660948d0d6254d4936ca8bc947482882142e710fad902d88c22c29ea
6
+ metadata.gz: 99004f6792fe209d21474c7b5b311ac8a02cce27740b69164e44079983a5852895aa99ed12530043ba64ad6920d189cb6b19ce3957aca83b6bab06f75bf702ee
7
+ data.tar.gz: 2be5eb3178a913c90c7b4e640812bccc479245d0052d95751317f543c80e7bf9429f9fd61cbc1c5edb917aafbead33502c75fb63fd8ab183480aaa44124f3dc5
data/CHANGELOG.md CHANGED
@@ -18,14 +18,7 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
18
18
  ### [Unreleased]
19
19
  Changes since the last non-beta release.
20
20
 
21
- #### Fixed
22
-
23
- - Incorrect type and confusing name for `ReactOnRails.registerStore`, use `registerStoreGenerators` instead. [PR 1651](https://github.com/shakacode/react_on_rails/pull/1651) by [alexeyr-ci](https://github.com/alexeyr-ci).
24
- - Changed the ReactOnRails' version checker to use `ReactOnRails.configuration.node_modules_location` to determine the location of the package.json that the `react-on-rails` dependency is expected to be set by.
25
- - Also, all errors that would be raised by the version checking have been converted to `Rails.Logger` warnings to avoid any breaking changes. [PR 1657](https://github.com/shakacode/react_on_rails/pull/1657) by [judahmeek](https://github.com/judahmeek).
26
- - Enable use as a `git:` dependency. [PR 1664](https://github.com/shakacode/react_on_rails/pull/1664) by [alexeyr-ci](https://github.com/alexeyr-ci).
27
-
28
- #### Added
21
+ #### Added(https://github.com/AbanoubGhadban).
29
22
  - Added streaming server rendering support:
30
23
  - [PR #1633](https://github.com/shakacode/react_on_rails/pull/1633) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
31
24
  - New `stream_react_component` helper for adding streamed components to views
@@ -33,11 +26,13 @@ Changes since the last non-beta release.
33
26
  - Enables progressive page loading and improved performance for server-rendered React components
34
27
  - Added support for replaying console logs that occur during server rendering of streamed React components. This enables debugging of server-side rendering issues by capturing and displaying console output on the client and on the server output. [PR #1647](https://github.com/shakacode/react_on_rails/pull/1647) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
35
28
  - Added support for handling errors happening during server rendering of streamed React components. It handles errors that happen during the initial render and errors that happen inside suspense boundaries. [PR #1648](https://github.com/shakacode/react_on_rails/pull/1648) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
36
- - Added support for passing options to `YAML.safe_load` when loading locale files with `config.i18n_yml_safe_load_options`. [PR #1668](https://github.com/shakacode/react_on_rails/pull/1668) by [dzirtusss](https://github.com/dzirtusss).
37
29
 
38
30
  #### Changed
39
31
  - Console replay script generation now awaits the render request promise before generating, allowing it to capture console logs from asynchronous operations. This requires using a version of the Node renderer that supports replaying async console logs. [PR #1649](https://github.com/shakacode/react_on_rails/pull/1649) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
40
32
 
33
+ #### Fixed
34
+ - Incorrect type and confusing name for `ReactOnRails.registerStore`, use `registerStoreGenerators` instead. [PR 1651](https://github.com/shakacode/react_on_rails/pull/1651) by [alexeyr-ci](https://github.com/alexeyr-ci).
35
+
41
36
  ### [14.0.5] - 2024-08-20
42
37
  #### Fixed
43
38
  - Should force load react-components which send over turbo-stream [PR #1620](https://github.com/shakacode/react_on_rails/pull/1620) by [theforestvn88](https://github.com/theforestvn88).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- react_on_rails (15.0.0.alpha.1)
4
+ react_on_rails (14.0.5)
5
5
  addressable
6
6
  connection_pool
7
7
  execjs (~> 2.5)
@@ -52,7 +52,6 @@ module ReactOnRails
52
52
  :generated_assets_dirs, :generated_assets_dir, :components_subdirectory,
53
53
  :webpack_generated_files, :rendering_extension, :build_test_command,
54
54
  :build_production_command, :i18n_dir, :i18n_yml_dir, :i18n_output_format,
55
- :i18n_yml_safe_load_options,
56
55
  :server_render_method, :random_dom_id, :auto_load_bundle,
57
56
  :same_bundle_for_client_and_server, :rendering_props_extension,
58
57
  :make_generated_server_bundle_the_entrypoint,
@@ -70,7 +69,7 @@ module ReactOnRails
70
69
  rendering_extension: nil, build_test_command: nil,
71
70
  build_production_command: nil, defer_generated_component_packs: nil,
72
71
  same_bundle_for_client_and_server: nil,
73
- i18n_dir: nil, i18n_yml_dir: nil, i18n_output_format: nil, i18n_yml_safe_load_options: nil,
72
+ i18n_dir: nil, i18n_yml_dir: nil, i18n_output_format: nil,
74
73
  random_dom_id: nil, server_render_method: nil, rendering_props_extension: nil,
75
74
  components_subdirectory: nil, auto_load_bundle: nil, force_load: nil)
76
75
  self.node_modules_location = node_modules_location.present? ? node_modules_location : Rails.root
@@ -81,7 +80,6 @@ module ReactOnRails
81
80
  self.i18n_dir = i18n_dir
82
81
  self.i18n_yml_dir = i18n_yml_dir
83
82
  self.i18n_output_format = i18n_output_format
84
- self.i18n_yml_safe_load_options = i18n_yml_safe_load_options
85
83
 
86
84
  self.random_dom_id = random_dom_id
87
85
  self.prerender = prerender
@@ -5,7 +5,9 @@ require "rails/railtie"
5
5
  module ReactOnRails
6
6
  class Engine < ::Rails::Engine
7
7
  config.to_prepare do
8
- VersionChecker.build.log_if_gem_and_node_package_versions_differ
8
+ if File.exist?(VersionChecker::NodePackageVersion.package_json_path)
9
+ VersionChecker.build.raise_if_gem_and_node_package_versions_differ
10
+ end
9
11
  ReactOnRails::ServerRenderingPool.reset_pool
10
12
  end
11
13
  end
@@ -115,17 +115,11 @@ module ReactOnRails
115
115
  translations = {}
116
116
  defaults = {}
117
117
  locale_files.each do |f|
118
- safe_load_options = ReactOnRails.configuration.i18n_yml_safe_load_options || {}
119
- translation = YAML.safe_load(File.open(f), **safe_load_options)
118
+ translation = YAML.safe_load(File.open(f))
120
119
  key = translation.keys[0]
121
120
  val = flatten(translation[key])
122
121
  translations = translations.deep_merge(key => val)
123
122
  defaults = defaults.deep_merge(flatten_defaults(val)) if key == default_locale
124
- rescue Psych::Exception => e
125
- raise ReactOnRails::Error, <<~MSG
126
- Error parsing #{f}: #{e.message}
127
- Consider fixing unsafe YAML or permitting with config.i18n_yml_safe_load_options
128
- MSG
129
123
  end
130
124
  [translations.to_json, defaults.to_json]
131
125
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "14.1.0"
4
+ VERSION = "15.0.0.alpha.1"
5
5
  end
@@ -19,9 +19,8 @@ module ReactOnRails
19
19
  # For compatibility, the gem and the node package versions should always match,
20
20
  # unless the user really knows what they're doing. So we will give a
21
21
  # warning if they do not.
22
- def log_if_gem_and_node_package_versions_differ
23
- return if node_package_version.raw.nil? || node_package_version.local_path_or_url?
24
- return log_node_semver_version_warning if node_package_version.semver_wildcard?
22
+ def raise_if_gem_and_node_package_versions_differ
23
+ return if node_package_version.relative_path?
25
24
 
26
25
  node_major_minor_patch = node_package_version.major_minor_patch
27
26
  gem_major_minor_patch = gem_major_minor_patch_version
@@ -29,7 +28,9 @@ module ReactOnRails
29
28
  node_major_minor_patch[1] == gem_major_minor_patch[1] &&
30
29
  node_major_minor_patch[2] == gem_major_minor_patch[2]
31
30
 
32
- log_differing_versions_warning unless versions_match
31
+ raise_differing_versions_warning unless versions_match
32
+
33
+ raise_node_semver_version_warning if node_package_version.semver_wildcard?
33
34
  end
34
35
 
35
36
  private
@@ -45,15 +46,15 @@ module ReactOnRails
45
46
  MSG
46
47
  end
47
48
 
48
- def log_differing_versions_warning
49
- msg = "**WARNING** ReactOnRails: ReactOnRails gem and node package versions do not match\n#{common_error_msg}"
50
- Rails.logger.warn(msg)
49
+ def raise_differing_versions_warning
50
+ msg = "**ERROR** ReactOnRails: ReactOnRails gem and node package versions do not match\n#{common_error_msg}"
51
+ raise ReactOnRails::Error, msg
51
52
  end
52
53
 
53
- def log_node_semver_version_warning
54
- msg = "**WARNING** ReactOnRails: Your node package version for react-on-rails contains a " \
54
+ def raise_node_semver_version_warning
55
+ msg = "**ERROR** ReactOnRails: Your node package version for react-on-rails contains a " \
55
56
  "^ or ~\n#{common_error_msg}"
56
- Rails.logger.warn(msg)
57
+ raise ReactOnRails::Error, msg
57
58
  end
58
59
 
59
60
  def gem_version
@@ -73,7 +74,7 @@ module ReactOnRails
73
74
  end
74
75
 
75
76
  def self.package_json_path
76
- Rails.root.join(ReactOnRails.configuration.node_modules_location, "package.json")
77
+ Rails.root.join("client", "package.json")
77
78
  end
78
79
 
79
80
  def initialize(package_json)
@@ -81,41 +82,29 @@ module ReactOnRails
81
82
  end
82
83
 
83
84
  def raw
84
- return @raw if defined?(@raw)
85
-
86
- if File.exist?(package_json)
87
- parsed_package_contents = JSON.parse(package_json_contents)
88
- if parsed_package_contents.key?("dependencies") &&
89
- parsed_package_contents["dependencies"].key?("react-on-rails")
90
- return @raw = parsed_package_contents["dependencies"]["react-on-rails"]
91
- end
85
+ parsed_package_contents = JSON.parse(package_json_contents)
86
+ if parsed_package_contents.key?("dependencies") &&
87
+ parsed_package_contents["dependencies"].key?("react-on-rails")
88
+ parsed_package_contents["dependencies"]["react-on-rails"]
89
+ else
90
+ raise ReactOnRails::Error, "No 'react-on-rails' entry in package.json dependencies"
92
91
  end
93
- msg = "No 'react-on-rails' entry in the dependencies of #{NodePackageVersion.package_json_path}, " \
94
- "which is the expected location according to ReactOnRails.configuration.node_modules_location"
95
- Rails.logger.warn(msg)
96
- @raw = nil
97
92
  end
98
93
 
99
94
  def semver_wildcard?
100
- # See https://docs.npmjs.com/cli/v10/configuring-npm/package-json#dependencies
101
- # We want to disallow all expressions other than exact versions
102
- # and the ones allowed by local_path_or_url?
103
- raw.blank? || raw.match(/[~^><|*-]/).present?
95
+ raw.match(/[~^]/).present?
104
96
  end
105
97
 
106
- def local_path_or_url?
107
- # See https://docs.npmjs.com/cli/v10/configuring-npm/package-json#dependencies
108
- # All path and protocol "version ranges" include / somewhere,
109
- # but we want to make an exception for npm:@scope/pkg@version.
110
- !raw.nil? && raw.include?("/") && !raw.start_with?("npm:")
98
+ def relative_path?
99
+ raw.match(%r{(\.\.|\Afile:///)}).present?
111
100
  end
112
101
 
113
102
  def major_minor_patch
114
- return if local_path_or_url?
103
+ return if relative_path?
115
104
 
116
105
  match = raw.match(MAJOR_MINOR_PATCH_VERSION_REGEX)
117
106
  unless match
118
- raise ReactOnRails::Error, "Cannot parse version number '#{raw}' (only exact versions are supported)"
107
+ raise ReactOnRails::Error, "Cannot parse version number '#{raw}' (wildcard versions are not supported)"
119
108
  end
120
109
 
121
110
  [match[1], match[2], match[3]]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.1.0
4
+ version: 15.0.0.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-06 00:00:00.000000000 Z
11
+ date: 2024-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable