isomorfeus-react 16.9.15 → 16.9.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isomorfeus-react.rb +1 -1
- data/lib/isomorfeus/{top_level_browser.rb → top_level.rb} +4 -4
- data/lib/react.rb +20 -20
- data/lib/react/component/features.rb +5 -4
- data/lib/react/component/resolution.rb +3 -7
- data/lib/react/component/styles.rb +4 -2
- data/lib/react/context_wrapper.rb +9 -9
- data/lib/react/function_component/resolution.rb +3 -8
- data/lib/react/native_constant_wrapper.rb +1 -1
- data/lib/react/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fedd5a6611c5c9231a56f9802567a284247618373ae46226a133e8d03e3f789b
|
4
|
+
data.tar.gz: c05a730ae10644277b7ba47d84ea5ee98b3a97e798ee545f7556ea0e7d81b8e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2c4754cad2588166596905a3b356f8661543e74a95a916425d41fec9a30453f12dfabcc778020e7a0afc99aed95091d62fd5b4fb4b357e1e39ba7bf4b932fb0
|
7
|
+
data.tar.gz: bfc8d7f044194d64b2ccec8fe550bfbdb1504e333ff8ee3361c59a00c08d8152abeb1315c206be220e728f9e8c8f313b300cd7990836bf092a288e97c992e823
|
data/lib/isomorfeus-react.rb
CHANGED
@@ -10,7 +10,7 @@ module Isomorfeus
|
|
10
10
|
component = nil
|
11
11
|
begin
|
12
12
|
component = component_name.constantize
|
13
|
-
rescue
|
13
|
+
rescue Exception
|
14
14
|
@timeout_start = Time.now unless @timeout_start
|
15
15
|
if (Time.now - @timeout_start) < 10
|
16
16
|
`setTimeout(Opal.Isomorfeus.TopLevel['$mount!'], 100)`
|
@@ -33,8 +33,8 @@ module Isomorfeus
|
|
33
33
|
}
|
34
34
|
end
|
35
35
|
begin
|
36
|
-
mount_component(component, props, root_element, hydrated)
|
37
|
-
rescue
|
36
|
+
Isomorfeus::TopLevel.mount_component(component, props, root_element, hydrated)
|
37
|
+
rescue Exception
|
38
38
|
@timeout_start = Time.now unless @timeout_start
|
39
39
|
if (Time.now - @timeout_start) < 10
|
40
40
|
`setTimeout(Opal.Isomorfeus.TopLevel['$mount!'], 100)`
|
@@ -61,7 +61,7 @@ module Isomorfeus
|
|
61
61
|
# init in case it hasn't been run yet
|
62
62
|
Isomorfeus.init
|
63
63
|
on_ready do
|
64
|
-
mount_component(component, props, element_query)
|
64
|
+
Isomorfeus::TopLevel.mount_component(component, props, element_query)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
data/lib/react.rb
CHANGED
@@ -60,24 +60,25 @@ module React
|
|
60
60
|
if (args.length > 0) {
|
61
61
|
var last_arg = args[args.length - 1];
|
62
62
|
if (typeof last_arg === 'string' || last_arg instanceof String) {
|
63
|
-
if (args.length === 1) { Opal.React.internal_render(component, null, last_arg, null); }
|
64
|
-
else { Opal.React.internal_render(component, args[0], last_arg, null); }
|
65
|
-
} else { Opal.React.internal_render(component, args[0], null, block); }
|
66
|
-
} else { Opal.React.internal_render(component, null, null, block); }
|
63
|
+
if (args.length === 1) { return Opal.React.internal_render(component, null, last_arg, null); }
|
64
|
+
else { return Opal.React.internal_render(component, args[0], last_arg, null); }
|
65
|
+
} else { return Opal.React.internal_render(component, args[0], null, block); }
|
66
|
+
} else { return Opal.React.internal_render(component, null, null, block); }
|
67
67
|
};
|
68
68
|
|
69
69
|
self.internal_render = function(component, props, string_child, block) {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
var native_props = null;
|
70
|
+
let children;
|
71
|
+
let react_element;
|
72
|
+
let native_props = null;
|
74
73
|
|
75
74
|
if (string_child) {
|
76
75
|
children = string_child;
|
77
76
|
} else if (block && block !== nil) {
|
78
77
|
Opal.React.render_buffer.push([]);
|
79
|
-
block_result = block.$call();
|
80
|
-
|
78
|
+
let block_result = block.$call();
|
79
|
+
let last_buffer_length = Opal.React.render_buffer[Opal.React.render_buffer.length - 1].length;
|
80
|
+
let last_buffer_element = Opal.React.render_buffer[Opal.React.render_buffer.length - 1][last_buffer_length - 1];
|
81
|
+
if (block_result && block_result !== last_buffer_element && (block_result !== nil && (typeof block_result === "string" || typeof block_result.$$typeof === "symbol" ||
|
81
82
|
(typeof block_result.constructor !== "undefined" && block_result.constructor === Array && block_result[0] && typeof block_result[0].$$typeof === "symbol")
|
82
83
|
))) {
|
83
84
|
Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result);
|
@@ -86,9 +87,10 @@ module React
|
|
86
87
|
if (children.length == 1) { children = children[0]; }
|
87
88
|
else if (children.length == 0) { children = null; }
|
88
89
|
}
|
89
|
-
if (props) { native_props = Opal.React.to_native_react_props(props); }
|
90
|
+
if (props && props !== nil) { native_props = Opal.React.to_native_react_props(props); }
|
90
91
|
react_element = Opal.global.React.createElement(component, native_props, children);
|
91
92
|
Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(react_element);
|
93
|
+
return react_element;
|
92
94
|
};
|
93
95
|
|
94
96
|
self.active_components = [];
|
@@ -129,9 +131,8 @@ module React
|
|
129
131
|
|
130
132
|
def self.create_element(type, props = nil, children = nil, &block)
|
131
133
|
%x{
|
132
|
-
|
133
|
-
|
134
|
-
var native_props = null;
|
134
|
+
let component = null;
|
135
|
+
let native_props = null;
|
135
136
|
if (typeof type.react_component !== 'undefined') {
|
136
137
|
component = type.react_component;
|
137
138
|
} else {
|
@@ -139,12 +140,11 @@ module React
|
|
139
140
|
}
|
140
141
|
|
141
142
|
Opal.React.render_buffer.push([]);
|
142
|
-
#{
|
143
|
-
native_props = `Opal.React.to_native_react_props(props)` if props;
|
144
|
-
}
|
145
143
|
if (block !== nil) {
|
146
|
-
block_result = block.$call()
|
147
|
-
|
144
|
+
let block_result = block.$call()
|
145
|
+
let last_buffer_length = Opal.React.render_buffer[Opal.React.render_buffer.length - 1].length;
|
146
|
+
let last_buffer_element = Opal.React.render_buffer[Opal.React.render_buffer.length - 1][last_buffer_length - 1];
|
147
|
+
if (block_result && block_result !== last_buffer_element && (block_result !== nil && (typeof block_result === "string" || typeof block_result.$$typeof === "symbol" ||
|
148
148
|
(typeof block_result.constructor !== "undefined" && block_result.constructor === Array && block_result[0] && typeof block_result[0].$$typeof === "symbol")
|
149
149
|
))) {
|
150
150
|
Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result);
|
@@ -153,6 +153,7 @@ module React
|
|
153
153
|
if (children.length == 1) { children = children[0]; }
|
154
154
|
else if (children.length == 0) { children = null; }
|
155
155
|
}
|
156
|
+
if (props && props !== nil) { native_props = Opal.React.to_native_react_props(props); }
|
156
157
|
return Opal.global.React.createElement(component, native_props, children);
|
157
158
|
}
|
158
159
|
end
|
@@ -162,7 +163,6 @@ module React
|
|
162
163
|
proc { `native_function.call()` }
|
163
164
|
end
|
164
165
|
|
165
|
-
|
166
166
|
def self.create_ref
|
167
167
|
React::Ref.new(`Opal.global.React.createRef()`)
|
168
168
|
end
|
@@ -14,11 +14,12 @@ module React
|
|
14
14
|
element = element_or_query
|
15
15
|
end
|
16
16
|
%x{
|
17
|
-
var block_result = null;
|
18
17
|
Opal.React.render_buffer.push([]);
|
19
18
|
if (block !== nil) {
|
20
|
-
block_result = block.$call()
|
21
|
-
|
19
|
+
let block_result = block.$call()
|
20
|
+
let last_buffer_length = Opal.React.render_buffer[Opal.React.render_buffer.length - 1].length;
|
21
|
+
let last_buffer_element = Opal.React.render_buffer[Opal.React.render_buffer.length - 1][last_buffer_length - 1];
|
22
|
+
if (block_result && block_result !== last_buffer_element && (block_result !== nil && (typeof block_result === "string" || typeof block_result.$$typeof === "symbol" ||
|
22
23
|
(typeof block_result.constructor !== "undefined" && block_result.constructor === Array && block_result[0] && typeof block_result[0].$$typeof === "symbol")
|
23
24
|
))) {
|
24
25
|
Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result);
|
@@ -26,7 +27,7 @@ module React
|
|
26
27
|
}
|
27
28
|
var react_element = Opal.global.React.createPortal(Opal.React.render_buffer.pop(), element);
|
28
29
|
Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(react_element);
|
29
|
-
return
|
30
|
+
return react_element;
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
@@ -47,9 +47,7 @@ module React
|
|
47
47
|
component = constant.react_component;
|
48
48
|
break;
|
49
49
|
}
|
50
|
-
} catch(err) {
|
51
|
-
component = null;
|
52
|
-
}
|
50
|
+
} catch(err) { component = null; }
|
53
51
|
}
|
54
52
|
if (!component) {
|
55
53
|
try {
|
@@ -57,13 +55,11 @@ module React
|
|
57
55
|
if (typeof constant.react_component !== 'undefined') {
|
58
56
|
component = constant.react_component;
|
59
57
|
}
|
60
|
-
} catch(err) {
|
61
|
-
component = null
|
62
|
-
}
|
58
|
+
} catch(err) { component = null; }
|
63
59
|
}
|
64
60
|
}
|
65
61
|
if (component) {
|
66
|
-
Opal.React.internal_prepare_args_and_render(component, args, block);
|
62
|
+
return Opal.React.internal_prepare_args_and_render(component, args, block);
|
67
63
|
} else {
|
68
64
|
return #{_react_component_resolution_original_method_missing(component_name, *args, block)};
|
69
65
|
}
|
@@ -5,8 +5,6 @@ module React
|
|
5
5
|
@native = native
|
6
6
|
end
|
7
7
|
|
8
|
-
# TODO method chain access
|
9
|
-
# we have class.property
|
10
8
|
def method_missing(prop, *args, &block)
|
11
9
|
%x{
|
12
10
|
if (!#@native || typeof #@native[prop] === 'undefined') { return #{nil}; }
|
@@ -17,6 +15,10 @@ module React
|
|
17
15
|
}
|
18
16
|
end
|
19
17
|
|
18
|
+
def to_h
|
19
|
+
`Opal.Hash.$new(#@native)`
|
20
|
+
end
|
21
|
+
|
20
22
|
def to_n
|
21
23
|
@native
|
22
24
|
end
|
@@ -8,18 +8,18 @@ module React
|
|
8
8
|
|
9
9
|
def Consumer(*args, &block)
|
10
10
|
%x{
|
11
|
-
|
12
|
-
|
13
|
-
var props = null;
|
14
|
-
var react_element;
|
11
|
+
let children = null;
|
12
|
+
let props = null;
|
15
13
|
|
16
|
-
if (args.length > 0) { props = args[0]; }
|
14
|
+
if (args.length > 0) { props = Opal.React.to_native_react_props(args[0]); }
|
17
15
|
|
18
|
-
|
16
|
+
let react_element = Opal.global.React.createElement(this.native.Consumer, props, function(value) {
|
19
17
|
if (block !== nil) {
|
20
18
|
Opal.React.render_buffer.push([]);
|
21
|
-
block_result = block.$call();
|
22
|
-
|
19
|
+
let block_result = block.$call();
|
20
|
+
let last_buffer_length = Opal.React.render_buffer[Opal.React.render_buffer.length - 1].length;
|
21
|
+
let last_buffer_element = Opal.React.render_buffer[Opal.React.render_buffer.length - 1][last_buffer_length - 1];
|
22
|
+
if (block_result && block_result !== last_buffer_element && (block_result !== nil && (typeof block_result === "string" || typeof block_result.$$typeof === "symbol" ||
|
23
23
|
(typeof block_result.constructor !== "undefined" && block_result.constructor === Array && block_result[0] && typeof block_result[0].$$typeof === "symbol")
|
24
24
|
))) {
|
25
25
|
Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result);
|
@@ -38,7 +38,7 @@ module React
|
|
38
38
|
def Provider(*args, &block)
|
39
39
|
%x{
|
40
40
|
var props = null;
|
41
|
-
if (args.length > 0) { props = args[0]; }
|
41
|
+
if (args.length > 0) { props = Opal.React.to_native_react_props(args[0]); }
|
42
42
|
Opal.React.internal_render(this.native.Provider, props, null, block);
|
43
43
|
}
|
44
44
|
end
|
@@ -40,10 +40,7 @@ module React
|
|
40
40
|
if (typeof constant.react_component !== 'undefined') {
|
41
41
|
component = constant.react_component;
|
42
42
|
}
|
43
|
-
}
|
44
|
-
catch(err) {
|
45
|
-
component = null;
|
46
|
-
}
|
43
|
+
} catch(err) { component = null; }
|
47
44
|
}
|
48
45
|
if (!component) {
|
49
46
|
try {
|
@@ -51,12 +48,10 @@ module React
|
|
51
48
|
if (typeof constant.react_component !== 'undefined') {
|
52
49
|
component = constant.react_component;
|
53
50
|
}
|
54
|
-
} catch(err) {
|
55
|
-
component = null
|
56
|
-
}
|
51
|
+
} catch(err) { component = null; }
|
57
52
|
}
|
58
53
|
if (component) {
|
59
|
-
Opal.React.internal_prepare_args_and_render(component, args, block);
|
54
|
+
return Opal.React.internal_prepare_args_and_render(component, args, block);
|
60
55
|
} else {
|
61
56
|
return #{_react_function_component_resolution_original_method_missing(component_name, *args, block)};
|
62
57
|
}
|
@@ -16,7 +16,7 @@ module React
|
|
16
16
|
component = #@native[name];
|
17
17
|
}
|
18
18
|
if (component) {
|
19
|
-
Opal.React.internal_prepare_args_and_render(component, args, block);
|
19
|
+
return Opal.React.internal_prepare_args_and_render(component, args, block);
|
20
20
|
} else {
|
21
21
|
#{raise NameError, "No such native Component #@const_name.#{name}"};
|
22
22
|
}
|
data/lib/react/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-react
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 16.9.
|
4
|
+
version: 16.9.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
@@ -173,7 +173,7 @@ files:
|
|
173
173
|
- lib/isomorfeus/props/validate_hash_proxy.rb
|
174
174
|
- lib/isomorfeus/props/validator.rb
|
175
175
|
- lib/isomorfeus/react_view_helper.rb
|
176
|
-
- lib/isomorfeus/
|
176
|
+
- lib/isomorfeus/top_level.rb
|
177
177
|
- lib/isomorfeus/top_level_ssr.rb
|
178
178
|
- lib/lucid_app/api.rb
|
179
179
|
- lib/lucid_app/base.rb
|