react_on_rails 14.1.1 → 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: b0e439ad231345f667bd0397a191854a1fc1265fd6b53aa4ff07297c52cbea88
4
- data.tar.gz: 80499fba8a3696ba0bca1a07742a36c0bc1c286294ebdab57d0f742c94d8a32b
3
+ metadata.gz: 7d60051000fbd817b3499b1de6f13c9abeaf5627bee250c50bf0d748ce3532a5
4
+ data.tar.gz: 4eccfe81e12b647503fa6e690c514d4d14d6704ab1e5c7f64282cafa7709d6e2
5
5
  SHA512:
6
- metadata.gz: fe4dd909d8ee7f1ee6e7210acdee7fbede95caa508b41d2f43e88aa11113bbb8d3eb88e4c0b24a826b472b2ac5ed234e5c6ba8ea357488d59d21fd995c010e36
7
- data.tar.gz: 83c5ccc2589399f773872291069f591179a2eb3cd13b8420102bd95f65421a6f00cc9d591a578adb5ae20339a7cd5dba7cf0f87bce25a0041a7ef9e7f3497a3a
6
+ metadata.gz: 99004f6792fe209d21474c7b5b311ac8a02cce27740b69164e44079983a5852895aa99ed12530043ba64ad6920d189cb6b19ce3957aca83b6bab06f75bf702ee
7
+ data.tar.gz: 2be5eb3178a913c90c7b4e640812bccc479245d0052d95751317f543c80e7bf9429f9fd61cbc1c5edb917aafbead33502c75fb63fd8ab183480aaa44124f3dc5
data/CHANGELOG.md CHANGED
@@ -18,23 +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
- ### [14.1.1] - 2025-01-15
22
-
23
- #### Fixed
24
-
25
- - Separated streamServerRenderedReactComponent from the ReactOnRails object in order to stop users from getting errors during webpack compilation about needing the `stream-browserify` package. [PR 1680](https://github.com/shakacode/react_on_rails/pull/1680) by [judahmeek](https://github.com/judahmeek).
26
- - Removed obsolete `js-yaml` peer dependency. [PR 1678](https://github.com/shakacode/react_on_rails/pull/1678) by [alexeyr-ci](https://github.com/alexeyr-ci).
27
-
28
- ### [14.1.0] - 2025-01-06
29
-
30
- #### Fixed
31
-
32
- - 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).
33
- - 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.
34
- - 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).
35
- - 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).
36
-
37
- #### Added
21
+ #### Added(https://github.com/AbanoubGhadban).
38
22
  - Added streaming server rendering support:
39
23
  - [PR #1633](https://github.com/shakacode/react_on_rails/pull/1633) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
40
24
  - New `stream_react_component` helper for adding streamed components to views
@@ -42,11 +26,13 @@ Changes since the last non-beta release.
42
26
  - Enables progressive page loading and improved performance for server-rendered React components
43
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).
44
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).
45
- - 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).
46
29
 
47
30
  #### Changed
48
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).
49
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
+
50
36
  ### [14.0.5] - 2024-08-20
51
37
  #### Fixed
52
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).
@@ -1181,9 +1167,7 @@ Best done with Object destructing:
1181
1167
  ##### Fixed
1182
1168
  - Fix several generator-related issues.
1183
1169
 
1184
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.1.1...master
1185
- [14.1.1]: https://github.com/shakacode/react_on_rails/compare/14.1.0...14.1.1
1186
- [14.1.0]: https://github.com/shakacode/react_on_rails/compare/14.0.5...14.1.0
1170
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.0.5...master
1187
1171
  [14.0.5]: https://github.com/shakacode/react_on_rails/compare/14.0.4...14.0.5
1188
1172
  [14.0.4]: https://github.com/shakacode/react_on_rails/compare/14.0.3...14.0.4
1189
1173
  [14.0.3]: https://github.com/shakacode/react_on_rails/compare/14.0.2...14.0.3
data/CONTRIBUTING.md CHANGED
@@ -6,14 +6,20 @@
6
6
 
7
7
  ## To run tests:
8
8
  * [Yalc](https://github.com/whitecolor/yalc) must be installed globally for most local development.
9
- * After updating code via Git, to prepare all examples:
9
+ * After updating code via git, to prepare all examples and run all tests:
10
+
10
11
  ```sh
11
12
  cd react_on_rails/
12
13
  bundle && yarn && rake examples:gen_all && rake node_package && rake
13
14
  ```
14
15
 
15
- See [Dev Initial Setup](#dev-initial-setup) below for, well... initial setup,
16
- and [Running tests](#running-tests) for more details on running tests.
16
+ In order to run tests in browser
17
+ ```
18
+ yarn global add browserify babelify tape-run faucet
19
+ browserify -t babelify node_package/tests/*.js | tape-run | faucet
20
+ ```
21
+
22
+ See Dev Initial Setup, below for, well... initial setup.
17
23
 
18
24
  # IDE/IDE SETUP
19
25
  It's critical to configure your IDE/editor to ignore certain directories. Otherwise your IDE might slow to a crawl!
@@ -147,23 +153,21 @@ script/convert
147
153
  yarn run dummy:spec
148
154
  ```
149
155
 
150
- ## Running tests
151
-
152
- ### JS tests
156
+ ### Run NPM JS tests
153
157
 
154
158
  ```sh
155
159
  cd react_on_rails/
156
- yarn run test
160
+ yarn test
157
161
  ```
158
162
 
159
- ### spec/dummy tests
163
+ ### Run spec/dummy tests
160
164
 
161
165
  ```sh
162
166
  cd react_on_rails/spec/dummy
163
167
  rspec
164
168
  ```
165
169
 
166
- ### Linting, type checking and JS tests together
170
+ ### Run most tests and linting
167
171
 
168
172
  ```sh
169
173
  cd react_on_rails/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- react_on_rails (14.1.0)
4
+ react_on_rails (14.0.5)
5
5
  addressable
6
6
  connection_pool
7
7
  execjs (~> 2.5)
data/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
 
24
24
  -----
25
25
 
26
- *These are the docs for React on Rails 14. To see the older docs and code: [v13](https://github.com/shakacode/react_on_rails/tree/13.4.0), [v12](https://github.com/shakacode/react_on_rails/tree/12.6.0), and [v11](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
26
+ *These are the docs for React on Rails 13. To see the older docs: [v12](https://github.com/shakacode/react_on_rails/tree/12.6.0) and [v11](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
27
27
 
28
28
  # About
29
29
  React on Rails integrates Rails with (server rendering of) [React](https://github.com/facebook/react).
@@ -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.1"
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]]
data/tsconfig.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "allowJs": true,
4
4
  "esModuleInterop": true,
5
- "jsx": "react-jsx",
5
+ "jsx": "react",
6
6
  "lib": ["dom", "es2015"],
7
7
  "module": "CommonJS",
8
8
  "noImplicitAny": true,
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.1
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-17 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