isomorfeus-react 16.6.6 → 16.6.7

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.
@@ -7,9 +7,9 @@ module React
7
7
  var last_arg = args[args.length - 1];
8
8
  if (typeof last_arg === 'string' || last_arg instanceof String) {
9
9
  if (args.length === 1) { Opal.React.internal_render(React.Fragment, null, last_arg, null); }
10
- else { Opal.React.internal_render(React.Fragment, args[0], last_arg, null); }
11
- } else { Opal.React.internal_render(React.Fragment, args[0], null, block); }
12
- } else { Opal.React.internal_render(React.Fragment, null, null, block); }
10
+ else { Opal.React.internal_render(Opal.global.React.Fragment, args[0], last_arg, null); }
11
+ } else { Opal.React.internal_render(Opal.global.React.Fragment, args[0], null, block); }
12
+ } else { Opal.React.internal_render(Opal.global.React.Fragment, null, null, block); }
13
13
  }
14
14
  end
15
15
 
@@ -27,7 +27,7 @@ module React
27
27
  Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result);
28
28
  }
29
29
  }
30
- var react_element = React.createPortal(Opal.React.render_buffer.pop(), dom_node);
30
+ var react_element = Opal.global.React.createPortal(Opal.React.render_buffer.pop(), dom_node);
31
31
  Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(react_element);
32
32
  return null;
33
33
  }
@@ -38,10 +38,10 @@ module React
38
38
  if (args.length > 0) {
39
39
  var last_arg = args[args.length - 1];
40
40
  if (typeof last_arg === 'string' || last_arg instanceof String) {
41
- if (args.length === 1) { Opal.React.internal_render(React.StrictMode, null, last_arg, null); }
42
- else { Opal.React.internal_render(React.StrictMode, args[0], last_arg, null); }
43
- } else { Opal.React.internal_render(React.StrictMode, args[0], null, block); }
44
- } else { Opal.React.internal_render(React.StrictMode, null, null, block); }
41
+ if (args.length === 1) { Opal.React.internal_render(Opal.global.React.StrictMode, null, last_arg, null); }
42
+ else { Opal.React.internal_render(Opal.global.React.StrictMode, args[0], last_arg, null); }
43
+ } else { Opal.React.internal_render(Opal.global.React.StrictMode, args[0], null, block); }
44
+ } else { Opal.React.internal_render(Opal.global.React.StrictMode, null, null, block); }
45
45
  }
46
46
  end
47
47
 
@@ -50,10 +50,10 @@ module React
50
50
  if (args.length > 0) {
51
51
  var last_arg = args[args.length - 1];
52
52
  if (typeof last_arg === 'string' || last_arg instanceof String) {
53
- if (args.length === 1) { Opal.React.internal_render(React.Suspense, null, last_arg, null); }
54
- else { Opal.React.internal_render(React.Suspense, args[0], last_arg, null); }
55
- } else { Opal.React.internal_render(React.Suspense, args[0], null, block); }
56
- } else { Opal.React.internal_render(React.Suspense, null, null, block); }
53
+ if (args.length === 1) { Opal.React.internal_render(Opal.global.React.Suspense, null, last_arg, null); }
54
+ else { Opal.React.internal_render(Opal.global.React.Suspense, args[0], last_arg, null); }
55
+ } else { Opal.React.internal_render(Opal.global.React.Suspense, args[0], null, block); }
56
+ } else { Opal.React.internal_render(Opal.global.React.Suspense, null, null, block); }
57
57
  }
58
58
  end
59
59
  end
@@ -8,7 +8,7 @@ module React
8
8
  component_name = base.to_s
9
9
  # language=JS
10
10
  %x{
11
- base.react_component = class extends React.Component {
11
+ base.react_component = class extends Opal.global.React.Component {
12
12
  constructor(props) {
13
13
  super(props);
14
14
  if (base.$default_state_defined()) {
@@ -29,7 +29,7 @@ module React
29
29
  }
30
30
  this[ref] = this[ref].bind(this);
31
31
  } else {
32
- this[ref] = React.createRef();
32
+ this[ref] = Opal.global.React.createRef();
33
33
  }
34
34
  }
35
35
  }
@@ -6,8 +6,9 @@ module React
6
6
  alias _react_component_resolution_original_const_missing const_missing
7
7
 
8
8
  def const_missing(const_name)
9
+ # language=JS
9
10
  %x{
10
- if (typeof Opal.global[const_name] == "object") {
11
+ if (typeof Opal.global[const_name] === "object") {
11
12
  var new_const = #{React::NativeConstantWrapper.new(`Opal.global[const_name]`, const_name)};
12
13
  #{Object.const_set(const_name, `new_const`)};
13
14
  return new_const;
@@ -30,7 +31,8 @@ module React
30
31
  # language=JS
31
32
  %x{
32
33
  var component = null;
33
- if (typeof Opal.global[component_name] == "function") {
34
+ var component_type = typeof Opal.global[component_name];
35
+ if (component_type === "function" || component_type === "object") {
34
36
  component = Opal.global[component_name];
35
37
  }
36
38
  else {
@@ -43,7 +45,8 @@ module React
43
45
  try {
44
46
  module = modules.slice(0, i).join('::')
45
47
  constant = self.$class().$const_get(module).$const_get(component_name, false);
46
- if (typeof constant.react_component == "function") {
48
+ component_type = typeof constant.react_component;
49
+ if (component_type === "function" || component_type === "object") {
47
50
  component = constant.react_component;
48
51
  break;
49
52
  }
@@ -11,7 +11,7 @@ module React
11
11
 
12
12
  if (args.length > 0) { props = args[0]; }
13
13
 
14
- var react_element = React.createElement(this.native.Consumer, props, function(value) {
14
+ var react_element = Opal.global.React.createElement(this.native.Consumer, props, function(value) {
15
15
  if (block !== nil) {
16
16
  Opal.React.render_buffer.push([]);
17
17
  block_result = block.$call();
@@ -44,7 +44,7 @@ module React
44
44
 
45
45
  def self.memo_component(component_name, &block)
46
46
  %x{
47
- var fun = React.memo(function(props) {
47
+ var fun = Opal.global.React.memo(function(props) {
48
48
  Opal.React.render_buffer.push([]);
49
49
  Opal.React.active_components.push(Opal.React.FunctionComponent.Runner.event_handlers);
50
50
  #{React::FunctionComponent::Runner.new(`props`).instance_exec(&block)};
@@ -6,8 +6,9 @@ module React
6
6
  alias _react_component_resolution_original_const_missing const_missing
7
7
 
8
8
  def const_missing(const_name)
9
+ # language=JS
9
10
  %x{
10
- if (typeof Opal.global[const_name] == "object") {
11
+ if (typeof Opal.global[const_name] === "object") {
11
12
  var new_const = #{React::NativeConstantWrapper.new(`Opal.global[const_name]`, const_name)};
12
13
  #{Object.const_set(const_name, `new_const`)};
13
14
  return new_const;
@@ -26,16 +27,18 @@ module React
26
27
  # first check for native component and render it, we want to be fast for native components
27
28
  # second check for ruby component and render it, they are a bit slower anyway
28
29
  # third pass on method missing
29
-
30
+ # language=JS
30
31
  %x{
31
32
  var component = null;
32
- if (typeof Opal.global[component_name] == "function") {
33
+ var component_type = typeof Opal.global[component_name];
34
+ if (component_type === "function" || component_type === "object") {
33
35
  component = Opal.global[component_name];
34
36
  }
35
37
  else {
36
38
  try {
37
39
  var constant = self.$class().$const_get(component_name, true);
38
- if (typeof constant.react_component == "function") {
40
+ component_type = typeof constant.react_component;
41
+ if (component_type === "function" || component_type === "object") {
39
42
  component = constant.react_component;
40
43
  }
41
44
  }
@@ -44,7 +47,6 @@ module React
44
47
  }
45
48
  }
46
49
  if (component) {
47
- var props = null;
48
50
  if (args.length > 0) {
49
51
  var last_arg = args[args.length - 1];
50
52
  if (typeof last_arg === 'string' || last_arg instanceof String) {
@@ -8,9 +8,11 @@ module React
8
8
  end
9
9
 
10
10
  def method_missing(name, *args, &block)
11
+ # language=JS
11
12
  %x{
12
13
  var component = null;
13
- if (typeof #@native[name] === "function") {
14
+ var component_type = typeof #@native[name];
15
+ if (component_type === "function" || component_type === "object") {
14
16
  component = #@native[name];
15
17
  }
16
18
 
@@ -10,13 +10,10 @@ module React
10
10
 
11
11
  def method_missing(key, *args, &block)
12
12
  @native_component_instance.JS.register_used_store_path(['application_state', key])
13
-
14
13
  if `args.length > 0`
15
14
  # set class state, simply a dispatch
16
-
17
15
  action = { type: 'APPLICATION_STATE', name: (`key.endsWith('=')` ? key.chop : key), value: args[0] }
18
16
  Isomorfeus.store.dispatch(action)
19
-
20
17
  else
21
18
  # check if we have a component local state value
22
19
  if `this.native_component_instance[this.access_key]["isomorfeus_store"]["application_state"].hasOwnProperty(key)`
@@ -13,13 +13,10 @@ module React
13
13
  @native_component_instance.JS.register_used_store_path(['component_class_state', @component_name, key])
14
14
  if `args.length > 0`
15
15
  # set class state, simply a dispatch
16
-
17
16
  action = { type: 'COMPONENT_CLASS_STATE', class: @component_name, name: (`key.endsWith('=')` ? key.chop : key), value: args[0] }
18
17
  Isomorfeus.store.dispatch(action)
19
-
20
18
  else
21
19
  # get class state
22
-
23
20
  # check if we have a component local state value
24
21
  if @native_component_instance.JS[@access_key].JS[:isomorfeus_store].JS[:component_class_state].JS[@component_name] &&
25
22
  @native_component_instance.JS[@access_key].JS[:isomorfeus_store].JS[:component_class_state].JS[@component_name].JS.hasOwnProperty(key)
@@ -28,7 +25,6 @@ module React
28
25
  # check if a default value was given
29
26
  return @component_instance.class.class_store.to_h[key]
30
27
  end
31
-
32
28
  # otherwise return nil
33
29
  return nil
34
30
  end
@@ -8,7 +8,7 @@ module React
8
8
  component_name = base.to_s
9
9
  # language=JS
10
10
  %x{
11
- base.react_component = class extends React.Component {
11
+ base.react_component = class extends Opal.global.React.Component {
12
12
  constructor(props) {
13
13
  super(props);
14
14
  if (base.$default_state_defined()) {
@@ -41,7 +41,7 @@ module React
41
41
  }
42
42
  this[ref] = this[ref].bind(this);
43
43
  } else {
44
- this[ref] = React.createRef();
44
+ this[ref] = Opal.global.React.createRef();
45
45
  }
46
46
  }
47
47
  this.listener = this.listener.bind(this);
@@ -84,10 +84,13 @@ module React
84
84
  } else if (next_props[property] !== this.props[property]) { return true; };
85
85
  }
86
86
  }
87
+ var used_store_result;
87
88
  for (var property in next_state) {
88
89
  if (property === "isomorfeus_store") {
89
- return this.scu_for_used_store_paths(this, this.state.isomorfeus_store, next_state.isomorfeus_store);
90
- if (res) { return true; }
90
+ used_store_result = this.scu_for_used_store_paths(this, this.state.isomorfeus_store, next_state.isomorfeus_store);
91
+ if (used_store_result) {
92
+ return true;
93
+ }
91
94
  } else if (next_state.hasOwnProperty(property)) {
92
95
  if (!this.state.hasOwnProperty(property)) { return true; };
93
96
  if (typeof next_state[property]['$!='] !== "undefined" && typeof this.state[property]['$!='] !== "undefined") {
data/lib/react/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module React
2
- VERSION = '16.6.6'
2
+ VERSION = '16.6.7'
3
3
  end
data/lib/react_dom.rb CHANGED
@@ -1,31 +1,41 @@
1
1
  module ReactDOM
2
- def create_portal
3
-
4
- end
5
-
6
- def find_dom_node
7
-
8
- end
9
-
10
- def hydrate
11
-
12
- end
13
-
14
- def self.render(native_element, container, &block)
15
- `Opal.React.render_buffer.push([]);`
16
-
17
- result = if block_given?
18
- `ReactDOM.render(native_element, container, function() { block.$call() })`
19
- else
20
- `ReactDOM.render(native_element, container)`
21
- end
22
-
23
- `Opal.React.render_buffer.pop([])`
24
-
25
- result
26
- end
27
-
28
- def unmount_component_at_node
29
-
2
+ class << self
3
+ def create_portal(child, container)
4
+ # container is a native DOM node
5
+ `Opal.global.ReactDOM.createPortal(child, container)`
6
+ end
7
+
8
+ def find_dom_node(native_react_component)
9
+ `Opal.global.ReactDOM.findDomNode(native_react_component)`
10
+ end
11
+
12
+ def hydrate(native_react_element, container, &block)
13
+ # container is a native DOM element
14
+ `Opal.React.render_buffer.push([]);`
15
+ result = if block_given?
16
+ `Opal.global.ReactDOM.hydrate(native_react_element, container, function() { block.$call() })`
17
+ else
18
+ `Opal.global.ReactDOM.hydrate(native_react_element, container)`
19
+ end
20
+ `Opal.React.render_buffer.pop()`
21
+ result
22
+ end
23
+
24
+ def render(native_react_element, container, &block)
25
+ # container is a native DOM element
26
+ `Opal.React.render_buffer.push([]);`
27
+ result = if block_given?
28
+ `Opal.global.ReactDOM.render(native_react_element, container, function() { block.$call() })`
29
+ else
30
+ `Opal.global.ReactDOM.render(native_react_element, container)`
31
+ end
32
+ `Opal.React.render_buffer.pop()`
33
+ result
34
+ end
35
+
36
+ def unmount_component_at_node(container)
37
+ # container is a native DOM element
38
+ `Opal.global.ReactDOM.unmountComponentAtNode(container)`
39
+ end
30
40
  end
31
41
  end
@@ -1,17 +1,19 @@
1
1
  module ReactDOMServer
2
- def render_to_string
2
+ class << self
3
+ def render_to_string(native_react_element)
4
+ `Opal.global.ReactDOMServer.renderToString(native_react_element)`
5
+ end
3
6
 
4
- end
5
-
6
- def render_to_static_markup
7
-
8
- end
9
-
10
- def render_to_node_stream
11
-
12
- end
7
+ def render_to_static_markup(native_react_element)
8
+ `Opal.global.ReactDOMServer.renderToStaticMarkup(native_react_element)`
9
+ end
13
10
 
14
- def render_to_static_node_stream
11
+ def render_to_node_stream(native_react_element)
12
+ `Opal.global.ReactDOMServer.renderToNodeStream(native_react_element)`
13
+ end
15
14
 
15
+ def render_to_static_node_stream(native_react_element)
16
+ `Opal.global.ReactDOMServer.renderToStaticNodeStream(native_react_element)`
17
+ end
16
18
  end
17
19
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-react
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.6.6
4
+ version: 16.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2019-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.6'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: opal
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,34 +66,48 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: 0.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: opal-webpack-loader
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.8.4
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.8.4
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: isomorfeus-redux
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - "~>"
60
88
  - !ruby/object:Gem::Version
61
- version: 4.0.1
89
+ version: 4.0.4
62
90
  type: :runtime
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: 4.0.1
96
+ version: 4.0.4
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: isomorfeus-speednode
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: 0.2.1
103
+ version: 0.2.3
76
104
  type: :runtime
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: 0.2.1
110
+ version: 0.2.3
83
111
  description: Write React Components in Ruby.
84
112
  email:
85
113
  - jan@kursator.com
@@ -87,10 +115,13 @@ executables: []
87
115
  extensions: []
88
116
  extra_rdoc_files: []
89
117
  files:
118
+ - README.md
90
119
  - lib/isomorfeus-react.rb
91
120
  - lib/isomorfeus/config.rb
92
- - lib/isomorfeus/top_level.rb
93
- - lib/isomorfeus/view_helpers.rb
121
+ - lib/isomorfeus/execution_environment.rb
122
+ - lib/isomorfeus/react_view_helper.rb
123
+ - lib/isomorfeus/top_level_browser.rb
124
+ - lib/isomorfeus/top_level_ssr.rb
94
125
  - lib/lucid_app/api.rb
95
126
  - lib/lucid_app/base.rb
96
127
  - lib/lucid_app/context.rb
@@ -102,6 +133,7 @@ files:
102
133
  - lib/lucid_component/initializer.rb
103
134
  - lib/lucid_component/mixin.rb
104
135
  - lib/lucid_component/native_component_constructor.rb
136
+ - lib/lucid_router.rb
105
137
  - lib/react.rb
106
138
  - lib/react/active_support_support.rb
107
139
  - lib/react/component/api.rb
@@ -145,7 +177,6 @@ files:
145
177
  - lib/react/version.rb
146
178
  - lib/react_dom.rb
147
179
  - lib/react_dom_server.rb
148
- - readme.md
149
180
  homepage: http://isomorfeus.com
150
181
  licenses:
151
182
  - MIT