isomorfeus-react 16.10.12 → 16.10.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -5
- data/lib/lucid_app/mixin.rb +1 -1
- data/lib/lucid_app/native_component_constructor.rb +1 -1
- data/lib/lucid_component/mixin.rb +1 -1
- data/lib/lucid_component/native_component_constructor.rb +1 -1
- data/lib/lucid_component/preloading_support.rb +16 -8
- data/lib/lucid_material/app/mixin.rb +1 -1
- data/lib/lucid_material/app/native_component_constructor.rb +1 -1
- data/lib/lucid_material/component/mixin.rb +1 -1
- data/lib/lucid_material/component/native_component_constructor.rb +1 -1
- data/lib/react.rb +1 -4
- data/lib/react/component/resolution.rb +43 -3
- 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: 89d11f7a3996ea44b089e50e65bd9e473edeb12cb877599054790db2705caa8a
|
4
|
+
data.tar.gz: 90ce6397b467688228cce66dcc0f3b1cd59a0aa15c83dd8ce3f15a3997017750
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3bf6b9a9029f53ad7ccdbc674bc166e09b863d7ab088cfcd68c732e1592d2986b514faf6c33e0aa13fa9f12b820f87c11570f46a55fe10130cc87757c423bef
|
7
|
+
data.tar.gz: 84450d0bff23041bcadb040107e72f8086c9631f7849a1b889a9a8e903274acb008f185a1dacb1aef7fe5dafef39863293cbad9c89e5dae9545839b7be39cbe0
|
data/README.md
CHANGED
@@ -71,8 +71,3 @@ https://github.com/facebook/react-devtools
|
|
71
71
|
- clone repo
|
72
72
|
- `bundle install`
|
73
73
|
- `rake`
|
74
|
-
|
75
|
-
Implementations for the [js-framework-benchmark](https://github.com/krausest/js-framework-benchmark):
|
76
|
-
|
77
|
-
- [using LucidComponent](https://github.com/janbiedermann/js-framework-benchmark/tree/master/frameworks/keyed/isomorfeus-lucid)
|
78
|
-
- [using React::Component](https://github.com/janbiedermann/js-framework-benchmark/tree/master/frameworks/keyed/isomorfeus-react)
|
data/lib/lucid_app/mixin.rb
CHANGED
@@ -5,7 +5,7 @@ module LucidApp
|
|
5
5
|
base.extend(::LucidApp::NativeComponentConstructor)
|
6
6
|
base.extend(::LucidPropDeclaration::Mixin)
|
7
7
|
base.extend(::React::Component::EventHandler)
|
8
|
-
base.
|
8
|
+
base.include(::LucidComponent::PreloadingSupport)
|
9
9
|
base.extend(::LucidComponent::EnvironmentSupport)
|
10
10
|
base.include(::LucidComponent::EnvironmentSupport)
|
11
11
|
base.include(::React::Component::Elements)
|
@@ -64,7 +64,7 @@ module LucidApp
|
|
64
64
|
Opal.React.active_components.push(this);
|
65
65
|
Opal.React.active_redux_components.push(this.__ruby_instance);
|
66
66
|
let block_result;
|
67
|
-
if (base.preload_block && !this.state.preloaded
|
67
|
+
if (base.preload_block && base.while_loading_block && !this.state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
|
68
68
|
else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
|
69
69
|
if (block_result && (block_result.constructor === String || block_result.constructor === Number)) { Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result); }
|
70
70
|
Opal.React.active_redux_components.pop();
|
@@ -5,7 +5,7 @@ module LucidComponent
|
|
5
5
|
base.extend(::LucidComponent::NativeComponentConstructor)
|
6
6
|
base.extend(::LucidPropDeclaration::Mixin)
|
7
7
|
base.extend(::React::Component::EventHandler)
|
8
|
-
base.
|
8
|
+
base.include(::LucidComponent::PreloadingSupport)
|
9
9
|
base.extend(::LucidComponent::EnvironmentSupport)
|
10
10
|
base.include(::LucidComponent::EnvironmentSupport)
|
11
11
|
base.include(::React::Component::Elements)
|
@@ -51,7 +51,7 @@ module LucidComponent
|
|
51
51
|
Opal.React.active_components.push(this);
|
52
52
|
Opal.React.active_redux_components.push(this);
|
53
53
|
let block_result;
|
54
|
-
if (base.preload_block && !this.state.preloaded
|
54
|
+
if (base.preload_block && base.while_loading_block && !this.state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
|
55
55
|
else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
|
56
56
|
if (block_result && (block_result.constructor === String || block_result.constructor === Number)) { Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result); }
|
57
57
|
Opal.React.active_redux_components.pop();
|
@@ -1,16 +1,24 @@
|
|
1
1
|
module LucidComponent
|
2
2
|
module PreloadingSupport
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
def self.included(base)
|
4
|
+
base.instance_exec do
|
5
|
+
def preload(&block)
|
6
|
+
`base.preload_block = block`
|
7
|
+
component_did_mount do
|
8
|
+
instance_exec(&self.class.JS[:preload_block]).then do
|
9
|
+
self.state.preloaded = true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def while_loading(&block)
|
15
|
+
`base.while_loading_block = block`
|
8
16
|
end
|
9
17
|
end
|
10
|
-
end
|
11
18
|
|
12
|
-
|
13
|
-
|
19
|
+
def preloaded?
|
20
|
+
!!state.preloaded
|
21
|
+
end
|
14
22
|
end
|
15
23
|
end
|
16
24
|
end
|
@@ -6,7 +6,7 @@ module LucidMaterial
|
|
6
6
|
base.extend(::LucidMaterial::App::NativeComponentConstructor)
|
7
7
|
base.extend(::LucidPropDeclaration::Mixin)
|
8
8
|
base.extend(::React::Component::EventHandler)
|
9
|
-
base.
|
9
|
+
base.include(::LucidComponent::PreloadingSupport)
|
10
10
|
base.extend(::LucidComponent::EnvironmentSupport)
|
11
11
|
base.include(::LucidComponent::EnvironmentSupport)
|
12
12
|
base.include(::React::Component::Elements)
|
@@ -65,7 +65,7 @@ module LucidMaterial
|
|
65
65
|
Opal.React.active_components.push(this);
|
66
66
|
Opal.React.active_redux_components.push(this.__ruby_instance);
|
67
67
|
let block_result;
|
68
|
-
if (base.preload_block && !this.state.preloaded
|
68
|
+
if (base.preload_block && base.while_loading_block && !this.state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
|
69
69
|
else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
|
70
70
|
if (block_result && (block_result.constructor === String || block_result.constructor === Number)) { Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result); }
|
71
71
|
Opal.React.active_redux_components.pop();
|
@@ -6,7 +6,7 @@ module LucidMaterial
|
|
6
6
|
base.extend(::LucidMaterial::Component::NativeComponentConstructor)
|
7
7
|
base.extend(::LucidPropDeclaration::Mixin)
|
8
8
|
base.extend(::React::Component::EventHandler)
|
9
|
-
base.
|
9
|
+
base.include(::LucidComponent::PreloadingSupport)
|
10
10
|
base.extend(::LucidComponent::EnvironmentSupport)
|
11
11
|
base.include(::LucidComponent::EnvironmentSupport)
|
12
12
|
base.include(::React::Component::Elements)
|
@@ -52,7 +52,7 @@ module LucidMaterial
|
|
52
52
|
Opal.React.active_components.push(this);
|
53
53
|
Opal.React.active_redux_components.push(this);
|
54
54
|
let block_result;
|
55
|
-
if (base.preload_block && !this.state.preloaded
|
55
|
+
if (base.preload_block && base.while_loading_block && !this.state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
|
56
56
|
else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
|
57
57
|
if (block_result && (block_result.constructor === String || block_result.constructor === Number)) { Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result); }
|
58
58
|
Opal.React.active_redux_components.pop();
|
data/lib/react.rb
CHANGED
@@ -67,9 +67,7 @@ module React
|
|
67
67
|
|
68
68
|
self.internal_render = function(component, props, string_child, block) {
|
69
69
|
let children;
|
70
|
-
let react_element;
|
71
70
|
let native_props = null;
|
72
|
-
|
73
71
|
if (string_child) {
|
74
72
|
children = string_child;
|
75
73
|
} else if (block && block !== nil) {
|
@@ -85,8 +83,7 @@ module React
|
|
85
83
|
else if (children.length === 0) { children = null; }
|
86
84
|
}
|
87
85
|
if (props && props !== nil) { native_props = Opal.React.to_native_react_props(props); }
|
88
|
-
|
89
|
-
Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(react_element);
|
86
|
+
Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(Opal.global.React.createElement(component, native_props, children));
|
90
87
|
};
|
91
88
|
|
92
89
|
self.active_components = [];
|
@@ -3,7 +3,7 @@ module React
|
|
3
3
|
module Resolution
|
4
4
|
def self.included(base)
|
5
5
|
base.instance_exec do
|
6
|
-
alias
|
6
|
+
alias _react_component_class_resolution_original_const_missing const_missing
|
7
7
|
|
8
8
|
def const_missing(const_name)
|
9
9
|
# language=JS
|
@@ -13,7 +13,47 @@ module React
|
|
13
13
|
#{Object.const_set(const_name, `new_const`)};
|
14
14
|
return new_const;
|
15
15
|
} else {
|
16
|
-
return #{
|
16
|
+
return #{_react_component_class_resolution_original_const_missing(const_name)};
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# this is required for autoloading support, as the component may not be loaded and so its method is not registered.
|
22
|
+
# must load it first, done by const_get, and next time the method will be there.
|
23
|
+
alias _react_component_class_resolution_original_method_missing method_missing
|
24
|
+
|
25
|
+
def method_missing(component_name, *args, &block)
|
26
|
+
# check for ruby component and render it
|
27
|
+
# otherwise pass on method missing
|
28
|
+
# language=JS
|
29
|
+
%x{
|
30
|
+
var modules = self.$to_s().split("::");
|
31
|
+
var modules_length = modules.length;
|
32
|
+
var module;
|
33
|
+
var constant;
|
34
|
+
var component;
|
35
|
+
for (var i = modules_length; i > 0; i--) {
|
36
|
+
try {
|
37
|
+
module = modules.slice(0, i).join('::')
|
38
|
+
constant = self.$const_get(module).$const_get(component_name, false);
|
39
|
+
if (typeof constant.react_component !== 'undefined') {
|
40
|
+
component = constant.react_component;
|
41
|
+
break;
|
42
|
+
}
|
43
|
+
} catch(err) { component = null; }
|
44
|
+
}
|
45
|
+
if (!component) {
|
46
|
+
try {
|
47
|
+
constant = Opal.Object.$const_get(component_name);
|
48
|
+
if (typeof constant.react_component !== 'undefined') {
|
49
|
+
component = constant.react_component;
|
50
|
+
}
|
51
|
+
} catch(err) { component = null; }
|
52
|
+
}
|
53
|
+
if (component) {
|
54
|
+
return Opal.React.internal_prepare_args_and_render(component, args, block);
|
55
|
+
} else {
|
56
|
+
return #{_react_component_resolution_original_method_missing(component_name, *args, block)};
|
17
57
|
}
|
18
58
|
}
|
19
59
|
end
|
@@ -67,4 +107,4 @@ module React
|
|
67
107
|
end
|
68
108
|
end
|
69
109
|
end
|
70
|
-
end
|
110
|
+
end
|
data/lib/react/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-react
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 16.10.
|
4
|
+
version: 16.10.13
|
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-10-
|
11
|
+
date: 2019-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|