react_on_rails 6.10.1 → 7.0.0

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
  SHA1:
3
- metadata.gz: 1b8e8a575ac81a5b58a9fdb4d28efd3e88c04fc7
4
- data.tar.gz: 8dae777aa4200fa6c0c55a242d2162ce0f9175fa
3
+ metadata.gz: 4a64c923e951e8fba50908c5443db96a78ae0fe6
4
+ data.tar.gz: 36e02d24cbb41b280141e38987353c5ddf02c036
5
5
  SHA512:
6
- metadata.gz: 143e5f35ed703170d068f6befe68df596219b8264195ee2e2b2a0b829d9f2cdcfff8452131a64c05cd2960a030c5114741b2dd5947264b42146f52d9b7ae7708
7
- data.tar.gz: 68da88fa5969e6e497cfcf8ccfeb068a5bb162793cb55a8b978cb00a400f469e2a2c656e1aaa01d47d8809680e91a908fe7311536b9505cbb5622f7886eb76a9
6
+ metadata.gz: fe9914d3b089d3852aa5e4f25ddef695f68463b6b7af46027a554ce978c953580d8b034f15b083ee76230d3e115b3a5e22d07647c3996991ab26e568c93b77ba
7
+ data.tar.gz: 6a72dc2499c81435640a33ec33e2dfd7309e8204e8d51e0953e5f197cda891b50d228a04c03a6d6c67bd255e4d7cd529cf0f75b06cef91cdf0efd45237074f06
data/CHANGELOG.md CHANGED
@@ -1,9 +1,16 @@
1
1
  # Change Log
2
- All notable changes to this project's source code will be documented in this file. Items under `Unreleased` is upcoming features that will be out in next version.
2
+ All notable changes to this project's source code will be documented in this file. Items under `Unreleased` is upcoming features that will be out in next version. NOTE: major versions of the npm module and the gem must be kept in sync.
3
3
 
4
4
  Contributors: please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version.
5
5
 
6
6
  ## [Unreleased]
7
+ ## [7.0.0] - 2017-04-25
8
+ ### Changed
9
+ - Any version differences in gem and node package for React on Rails throw an error [#821](https://github.com/shakacode/react_on_rails/pull/821) by [justin808](https://github.com/justin808)
10
+
11
+ ### Fixed
12
+ - Fixes serious performance regression when using String props for rendering. [#821](https://github.com/shakacode/react_on_rails/pull/821) by [justin808](https://github.com/justin808)
13
+
7
14
  ## [6.10.1] - 2017-04-23
8
15
  ### Fixed
9
16
  - Improve json conversion with tests and support for older Rails 3.x. [#787](https://github.com/shakacode/react_on_rails/pull/787) by [cheremukhin23](https://github.com/cheremukhin23) and [Ynote](https://github.com/Ynote).
@@ -534,7 +541,8 @@ Best done with Object destructing:
534
541
  ##### Fixed
535
542
  - Fix several generator related issues.
536
543
 
537
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.10.1...master
544
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/7.0.0...master
545
+ [7.0.0]: https://github.com/shakacode/react_on_rails/compare/6.10.1...7.0.0
538
546
  [6.10.1]: https://github.com/shakacode/react_on_rails/compare/6.10.0...6.10.1
539
547
  [6.10.0]: https://github.com/shakacode/react_on_rails/compare/6.9.3...6.10.0
540
548
  [6.9.3]: https://github.com/shakacode/react_on_rails/compare/6.9.1...6.9.3
@@ -107,12 +107,17 @@ module ReactOnRailsHelper
107
107
  # Setup the page_loaded_js, which is the same regardless of prerendering or not!
108
108
  # The reason is that React is smart about not doing extra work if the server rendering did its job.
109
109
  component_specification_tag = content_tag(:script,
110
- json_safe_and_pretty(options.data).html_safe,
110
+ json_safe_and_pretty(options.props).html_safe,
111
111
  type: "application/json",
112
- class: "js-react-on-rails-component")
112
+ class: "js-react-on-rails-component",
113
+ "data-component-name" => options.name,
114
+ "data-trace" => options.trace,
115
+ "data-dom-id" => options.dom_id)
113
116
 
114
117
  # Create the HTML rendering part
115
- result = server_rendered_react_component_html(options.props, options.name, options.dom_id,
118
+ result = server_rendered_react_component_html(options.props,
119
+ options.name,
120
+ options.dom_id,
116
121
  prerender: options.prerender,
117
122
  trace: options.trace,
118
123
  raise_on_prerender_error: options.raise_on_prerender_error)
@@ -2,7 +2,7 @@ module ReactOnRails
2
2
  class Engine < ::Rails::Engine
3
3
  config.to_prepare do
4
4
  if File.exist?(VersionChecker::NodePackageVersion.package_json_path)
5
- VersionChecker.build.warn_if_gem_and_node_package_versions_differ
5
+ VersionChecker.build.raise_if_gem_and_node_package_versions_differ
6
6
  end
7
7
  ReactOnRails::ServerRenderingPool.reset_pool
8
8
  end
@@ -13,8 +13,7 @@ module ReactOnRails
13
13
  end
14
14
 
15
15
  def props
16
- props = options.fetch(:props) { NO_PROPS }
17
- props.is_a?(String) ? JSON.parse(ERB::Util.json_escape(props)) : props
16
+ options.fetch(:props) { NO_PROPS }
18
17
  end
19
18
 
20
19
  def name
@@ -45,15 +44,6 @@ module ReactOnRails
45
44
  retrieve_key(:raise_on_prerender_error)
46
45
  end
47
46
 
48
- def data
49
- {
50
- component_name: name,
51
- props: props,
52
- trace: trace,
53
- dom_id: dom_id
54
- }
55
- end
56
-
57
47
  private
58
48
 
59
49
  attr_reader :options
@@ -1,3 +1,3 @@
1
1
  module ReactOnRails
2
- VERSION = "6.10.1".freeze
2
+ VERSION = "7.0.0".freeze
3
3
  end
@@ -2,44 +2,49 @@ module ReactOnRails
2
2
  # Responsible for checking versions of rubygem versus yarn node package
3
3
  # against each otherat runtime.
4
4
  class VersionChecker
5
- attr_reader :node_package_version, :logger
6
- MAJOR_VERSION_REGEX = /(\d+)\.?/
5
+ attr_reader :node_package_version
6
+ MAJOR_MINOR_PATCH_VERSION_REGEX = /(\d+)\.(\d+)\.(\d+)/
7
7
 
8
8
  def self.build
9
- new(NodePackageVersion.build, Rails.logger)
9
+ new(NodePackageVersion.build)
10
10
  end
11
11
 
12
- def initialize(node_package_version, logger)
13
- @logger = logger
12
+ def initialize(node_package_version)
14
13
  @node_package_version = node_package_version
15
14
  end
16
15
 
17
16
  # For compatibility, the gem and the node package versions should always match,
18
17
  # unless the user really knows what they're doing. So we will give a
19
18
  # warning if they do not.
20
- def warn_if_gem_and_node_package_versions_differ
19
+ def raise_if_gem_and_node_package_versions_differ
21
20
  return if node_package_version.relative_path?
22
- return if node_package_version.major == gem_major_version
23
- log_differing_versions_warning
21
+ node_major_minor_patch = node_package_version.major_minor_patch
22
+ gem_major_minor_patch = gem_major_minor_patch_version
23
+ return if node_major_minor_patch[0] == gem_major_minor_patch[0] &&
24
+ node_major_minor_patch[1] == gem_major_minor_patch[1] &&
25
+ node_major_minor_patch[2] == gem_major_minor_patch[2]
26
+
27
+ raise_differing_versions_warning
24
28
  end
25
29
 
26
30
  private
27
31
 
28
- def log_differing_versions_warning
29
- msg = "**WARNING** ReactOnRails: ReactOnRails gem and node package MAJOR versions do not match\n" \
32
+ def raise_differing_versions_warning
33
+ msg = "**ERROR** ReactOnRails: ReactOnRails gem and node package versions do not match\n" \
30
34
  " gem: #{gem_version}\n" \
31
35
  " node package: #{node_package_version.raw}\n" \
32
- "Ensure the installed MAJOR version of the gem is the same as the MAJOR version of \n"\
36
+ "Ensure the installed version of the gem is the same as the version of \n"\
33
37
  "your installed node package."
34
- logger.error(msg)
38
+ raise msg
35
39
  end
36
40
 
37
41
  def gem_version
38
42
  ReactOnRails::VERSION
39
43
  end
40
44
 
41
- def gem_major_version
42
- gem_version.match(MAJOR_VERSION_REGEX)[1]
45
+ def gem_major_minor_patch_version
46
+ match = gem_version.match(MAJOR_MINOR_PATCH_VERSION_REGEX)
47
+ [match[1], match[2], match[3]]
43
48
  end
44
49
 
45
50
  class NodePackageVersion
@@ -71,9 +76,10 @@ module ReactOnRails
71
76
  raw.match(%r{(\.\.|\Afile:///)}).present?
72
77
  end
73
78
 
74
- def major
79
+ def major_minor_patch
75
80
  return if relative_path?
76
- raw.match(MAJOR_VERSION_REGEX)[1]
81
+ match = raw.match(MAJOR_MINOR_PATCH_VERSION_REGEX)
82
+ [match[1], match[2], match[3]]
77
83
  end
78
84
 
79
85
  private
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails",
3
- "version": "6.10.1",
3
+ "version": "7.0.0",
4
4
  "description": "react-on-rails JavaScript for react_on_rails Ruby gem",
5
5
  "main": "node_package/lib/ReactOnRails.js",
6
6
  "directories": {
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: 6.10.1
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-23 00:00:00.000000000 Z
11
+ date: 2017-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool