react_on_rails 6.3.1 → 6.3.2

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: 4356fb000ccf27666962248d09af71aa01af2ab9
4
- data.tar.gz: e4c02df069b3b05dc09550d9000c7c67a1e96d7f
3
+ metadata.gz: a33778e55ee63b84756b91066276ae483042df19
4
+ data.tar.gz: 44db20d267ab1bfd34a8e9bff56b171d89376b77
5
5
  SHA512:
6
- metadata.gz: 9b8fca5929a9c4d5584fc908ca20bf2a87978f01a24ab00aaaf01f939d726887f0520356887738446fee0359ff0cd090c9ad28abadb62636e6d3866ae0378a7a
7
- data.tar.gz: 0ff01843b772a5caff20fa915647be727f76c9f8f19e030b631a0385396b2e444839f757be0058d596d435021bc4653c8649aad93c9ebd178b795e9e3e6db44d
6
+ metadata.gz: 3e165be5f9e36001de70e93d594998c9b8107a75cb1b2bdd2b99adbac49682c74581788dd4bdcfe9648597076ca848b5707b4e5b9ad73599c453df6aaa46f9dc
7
+ data.tar.gz: 0b2efd49a3fafe8876d75c16905c5784e0e0521668caf5d63c07cf3623b0c66ebfc19633eda9d76222d19d00dc42e4901f861644c0d1caf0c4baa916690495d9
data/CHANGELOG.md CHANGED
@@ -4,12 +4,19 @@ All notable changes to this project's source code will be documented in this fil
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
+ *Please add entries here for your pull requests.*
7
8
 
8
- ## [6.3.1]
9
+ ## [6.3.2] - 2016-12-5
10
+ ##### Fixed
11
+ - The `react_component` method was raising a `NameError` when `ReactOnRailsHelper` was included in a plain object. [#636](https://github.com/shakacode/react_on_rails/pull/636) by [jtibbertsma](https://github.com/jtibbertsma).
12
+ - "Node parse error" for node server rendering. [#641](https://github.com/shakacode/react_on_rails/pull/641) by [alleycat-at-git](https://github.com/alleycat-at-git) and [rocLv](https://github.com/rocLv)
13
+ - Better error handling when the react-on-rails node package entry is missing.[#602](https://github.com/shakacode/react_on_rails/pull/602) by [benjiwheeler](https://github.com/benjiwheeler).
14
+
15
+ ## [6.3.1] - 2016-11-30
9
16
  ##### Changed
10
17
  - Improved generator post-install help messages. [#631](https://github.com/shakacode/react_on_rails/pull/631) by [justin808](https://github.com/justin808).
11
18
 
12
- ## [6.3.0]
19
+ ## [6.3.0] - 2016-11-30
13
20
  ##### Changed
14
21
  - Modified register API to allow registration of renderers, allowing a user to manually render their app to the DOM. This allows for code splitting and deferred loading. [#581](https://github.com/shakacode/react_on_rails/pull/581) by [jtibbertsma](https://github.com/jtibbertsma).
15
22
 
@@ -397,7 +404,8 @@ Best done with Object destructing:
397
404
  ##### Fixed
398
405
  - Fix several generator related issues.
399
406
 
400
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.3.1...master
407
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.3.2...master
408
+ [6.3.2]: https://github.com/shakacode/react_on_rails/compare/6.3.1...6.3.2
401
409
  [6.3.1]: https://github.com/shakacode/react_on_rails/compare/6.3.0...6.3.1
402
410
  [6.3.0]: https://github.com/shakacode/react_on_rails/compare/6.2.1...6.3.0
403
411
  [6.2.1]: https://github.com/shakacode/react_on_rails/compare/6.2.0...6.2.1
@@ -350,7 +350,7 @@ ReactOnRails.setStore('#{store_name}', store);
350
350
  i18nLocale: I18n.locale,
351
351
  i18nDefaultLocale: I18n.default_locale
352
352
  }
353
- if request.present?
353
+ if defined?(request) && request.present?
354
354
  # Check for encoding of the request's original_url and try to force-encoding the
355
355
  # URLs as UTF-8. This situation can occur in browsers that do not encode the
356
356
  # entire URL as UTF-8 already, mostly on the Windows platform (IE11 and lower).
@@ -402,7 +402,7 @@ ReactOnRails.setStore('#{store_name}', store);
402
402
  end
403
403
 
404
404
  def in_mailer?
405
- return false unless controller.present?
405
+ return false unless defined?(controller)
406
406
  return false unless defined?(ActionMailer::Base)
407
407
 
408
408
  controller.is_a?(ActionMailer::Base)
@@ -35,7 +35,7 @@ Here's an example of how you might use this in practice:
35
35
  import ReactOnRails from 'react-on-rails';
36
36
  import NavigationApp from './NavigationApp';
37
37
 
38
- // Note that we're importing a different RouterApp that in serverRegistration.js
38
+ // Note that we're importing a different RouterApp than in serverRegistration.js
39
39
  // Renderer functions should not be used on the server, because there is no DOM.
40
40
  import RouterApp from './RouterAppRenderer';
41
41
  import applicationStore from '../store/applicationStore';
@@ -52,7 +52,7 @@ ReactOnRails.register({
52
52
  import ReactOnRails from 'react-on-rails';
53
53
  import NavigationApp from './NavigationApp';
54
54
 
55
- // Note that we're importing a different RouterApp that in clientRegistration.js
55
+ // Note that we're importing a different RouterApp than in clientRegistration.js
56
56
  import RouterApp from './RouterAppServer';
57
57
  import applicationStore from '../store/applicationStore';
58
58
 
@@ -2,7 +2,7 @@ const net = require('net');
2
2
  const fs = require('fs');
3
3
 
4
4
  const bundlePath = '../../app/assets/webpack/';
5
- let bundleFileName = 'webpack-bundle.js';
5
+ let bundleFileName = 'server-bundle.js';
6
6
 
7
7
  let currentArg;
8
8
 
@@ -13,13 +13,20 @@ function Handler() {
13
13
 
14
14
  Handler.prototype.handle = (connection) => {
15
15
  const callback = () => {
16
+ const terminator = '\r\n\0';
17
+ let request = '';
16
18
  connection.setEncoding('utf8');
17
19
  connection.on('data', (data) => {
18
- console.log(`Processing request: ${data}`);
19
-
20
- // eslint-disable-next-line no-eval
21
- const result = eval(data);
22
- connection.write(result);
20
+ console.log(`Processing chunk: ${data}`);
21
+ request += data;
22
+ if (data.slice(-terminator.length) === terminator) {
23
+ request = request.slice(0, -terminator.length);
24
+
25
+ // eslint-disable-next-line no-eval
26
+ const response = eval(request);
27
+ connection.write(`${response}${terminator}`);
28
+ request = '';
29
+ }
23
30
  });
24
31
  };
25
32
 
@@ -55,23 +62,32 @@ process.argv.forEach((val) => {
55
62
  }
56
63
  });
57
64
 
65
+ function loadBundle() {
66
+ if (handler.initialized) {
67
+ console.log('Reloading server bundle must be implemented by restarting the node process!');
68
+ return;
69
+ }
70
+
71
+ /* eslint-disable */
72
+ require(bundlePath + bundleFileName);
73
+ /* eslint-enable */
74
+ console.log(`Loaded server bundle: ${bundlePath}${bundleFileName}`);
75
+ handler.initialize();
76
+ }
77
+
58
78
  try {
59
79
  fs.mkdirSync(bundlePath);
60
80
  } catch (e) {
61
- if (e.code !== 'EEXIST') throw e;
81
+ if (e.code !== 'EEXIST') {
82
+ throw e;
83
+ } else {
84
+ loadBundle();
85
+ }
62
86
  }
63
87
 
64
88
  fs.watchFile(bundlePath + bundleFileName, (curr) => {
65
89
  if (curr && curr.blocks && curr.blocks > 0) {
66
- if (handler.initialized) {
67
- console.log('Reloading server bundle must be implemented by restarting the node process!');
68
- return;
69
- }
70
-
71
- // eslint-disable-next-line global-require, import/no-dynamic-require
72
- require(bundlePath + bundleFileName);
73
- console.log(`Loaded server bundle: ${bundlePath + bundleFileName}`);
74
- handler.initialize();
90
+ loadBundle();
75
91
  }
76
92
  });
77
93
 
@@ -51,11 +51,15 @@ module ReactOnRails
51
51
  end
52
52
 
53
53
  def eval_js(js_code)
54
- max_int = (2**(32 - 2) - 1)
54
+ eof_symbol = "\r\n\0".freeze
55
+ max_int = (2**30 - 1)
55
56
  @js_context_pool.with do |js_context|
56
- js_context.send(js_code, 0)
57
- result = js_context.recv(max_int)
58
- result
57
+ js_context.send(js_code + eof_symbol, 0)
58
+ result = ""
59
+ while result[-eof_symbol.length..-1] != eof_symbol
60
+ result += js_context.recv(max_int)
61
+ end
62
+ result[0..-eof_symbol.length]
59
63
  end
60
64
  end
61
65
 
@@ -64,8 +68,8 @@ module ReactOnRails
64
68
  client = UNIXSocket.new("client/node/node.sock")
65
69
  client.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
66
70
  rescue StandardError => e
67
- Rails.logger.error("Unable to connect to socket: client/node/node.sock.
68
- Make sure node server is up and running.")
71
+ Rails.logger.error("Unable to connect to socket: client/node/node.sock. \
72
+ Make sure node server is up and running.")
69
73
  Rails.logger.error(e)
70
74
  raise e
71
75
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ReactOnRails
3
- VERSION = "6.3.1".freeze
3
+ VERSION = "6.3.2".freeze
4
4
  end
@@ -58,7 +58,13 @@ module ReactOnRails
58
58
  end
59
59
 
60
60
  def raw
61
- JSON.parse(package_json_contents)["dependencies"]["react-on-rails"]
61
+ parsed_package_contents = JSON.parse(package_json_contents)
62
+ if parsed_package_contents.key?("dependencies") &&
63
+ parsed_package_contents["dependencies"].key?("react-on-rails")
64
+ parsed_package_contents["dependencies"]["react-on-rails"]
65
+ else
66
+ raise "no 'react-on-rails' entry in package.json dependencies"
67
+ end
62
68
  end
63
69
 
64
70
  def relative_path?
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails",
3
- "version": "6.3.1",
3
+ "version": "6.3.2",
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.3.1
4
+ version: 6.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-01 00:00:00.000000000 Z
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool