isomorfeus-react 16.10.6 → 16.10.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isomorfeus/config.rb +1 -1
- data/lib/lucid_app/native_component_constructor.rb +5 -1
- data/lib/lucid_component/app_store_proxy.rb +10 -6
- data/lib/lucid_component/class_store_proxy.rb +12 -4
- data/lib/lucid_component/instance_store_proxy.rb +14 -5
- data/lib/lucid_component/native_component_constructor.rb +12 -8
- data/lib/lucid_component/store_api.rb +4 -0
- data/lib/lucid_material/app/native_component_constructor.rb +5 -1
- data/lib/lucid_material/component/native_component_constructor.rb +12 -8
- data/lib/react/component/native_component_constructor.rb +12 -8
- data/lib/react/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fff27f01dbdc8b61a524126b68105ed1798dd8990cf3af79e5f1eccd080b3b4
|
4
|
+
data.tar.gz: 044d4786c473c66ac97eb09a007a15df3f143e79c7931570acd38bde2ef0fb96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccdba650676405aa60d29cc9d8987ad1157fd874d2190fd71f2c0f7409a6d021eaff9cfc6ea6f9735c66b43c85ab686ca261fa844f5e4147a4bfea9d7f2c30f9
|
7
|
+
data.tar.gz: bce8d8f6c9732b358dc99b6e0f5e2936b6e5b1dbda393a723181409b115d2f52d6dd1d77a0c5dbdd9a98ff9d940f61fa5ae216eaad18100213903149127e2cfb
|
data/lib/isomorfeus/config.rb
CHANGED
@@ -50,7 +50,7 @@ module Isomorfeus
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def env=(env_string)
|
53
|
-
@env = env_string ? env_string
|
53
|
+
@env = env_string ? env_string : 'development'
|
54
54
|
@development = (@env == 'development') ? true : false
|
55
55
|
@production = (@env == 'production') ? true : false
|
56
56
|
@test = (@env == 'test') ? true : false
|
@@ -54,6 +54,7 @@ module LucidApp
|
|
54
54
|
return #{component_name};
|
55
55
|
}
|
56
56
|
render() {
|
57
|
+
this.context = this.state.isomorfeus_store_state;
|
57
58
|
Opal.React.render_buffer.push([]);
|
58
59
|
// console.log("lucid app pushed", Opal.React.render_buffer, Opal.React.render_buffer.toString());
|
59
60
|
Opal.React.active_components.push(this);
|
@@ -66,6 +67,9 @@ module LucidApp
|
|
66
67
|
let children = Opal.React.render_buffer.pop();
|
67
68
|
return Opal.global.React.createElement(Opal.global.LucidApplicationContext.Provider, { value: this.state.isomorfeus_store_state }, children);
|
68
69
|
}
|
70
|
+
data_access() {
|
71
|
+
return this.context;
|
72
|
+
}
|
69
73
|
listener() {
|
70
74
|
let next_state = Opal.Isomorfeus.store.native.getState();
|
71
75
|
this.setState({ isomorfeus_store_state: next_state });
|
@@ -87,7 +91,7 @@ module LucidApp
|
|
87
91
|
let classes = null;
|
88
92
|
let theme = Opal.global.ReactJSS.useTheme();
|
89
93
|
if (base.jss_styles) {
|
90
|
-
if (!base.use_styles || (Opal.Isomorfeus
|
94
|
+
if (!base.use_styles || (Opal.Isomorfeus.development && !Object.is(base.jss_styles, base.jss_styles_used))) {
|
91
95
|
base.jss_styles_used = base.jss_styles;
|
92
96
|
let styles = base.jss_styles
|
93
97
|
if (typeof styles === 'function') { styles = styles(theme); }
|
@@ -12,13 +12,17 @@ module LucidComponent
|
|
12
12
|
Isomorfeus.store.dispatch(action)
|
13
13
|
else
|
14
14
|
# check if we have a component local state value
|
15
|
-
if `this.native_component_instance.context
|
16
|
-
|
15
|
+
if `this.native_component_instance.context`
|
16
|
+
if `this.native_component_instance.context.application_state && this.native_component_instance.context.application_state.hasOwnProperty(key)`
|
17
|
+
return @native_component_instance.JS['context'].JS[:application_state].JS[key]
|
18
|
+
end
|
19
|
+
else
|
20
|
+
a_state = Isomorfeus.store.get_state
|
21
|
+
if a_state.key?(:application_state) && a_state[:application_state].key?(key)
|
22
|
+
return a_state[:application_state][key]
|
23
|
+
end
|
17
24
|
end
|
18
|
-
|
19
|
-
if a_state.key?(:application_state) && a_state[:application_state].key?(key)
|
20
|
-
return a_state[:application_state][key]
|
21
|
-
elsif @component_instance.class.default_app_store_defined && @component_instance.class.app_store.to_h.key?(key)
|
25
|
+
if @component_instance.class.default_app_store_defined && @component_instance.class.app_store.to_h.key?(key)
|
22
26
|
# check if a default value was given
|
23
27
|
return @component_instance.class.app_store.to_h[key]
|
24
28
|
end
|
@@ -14,10 +14,18 @@ module LucidComponent
|
|
14
14
|
else
|
15
15
|
# get class state
|
16
16
|
# check if we have a component local state value
|
17
|
-
if
|
18
|
-
@native_component_instance.JS['context'].JS[:component_class_state].JS[@component_name]
|
19
|
-
|
20
|
-
|
17
|
+
if `this.native_component_instance.context`
|
18
|
+
if @native_component_instance.JS['context'].JS[:component_class_state].JS[@component_name] &&
|
19
|
+
@native_component_instance.JS['context'].JS[:component_class_state].JS[@component_name].JS.hasOwnProperty(key)
|
20
|
+
return @native_component_instance.JS['context'].JS[:component_class_state].JS[@component_name].JS[key]
|
21
|
+
end
|
22
|
+
else
|
23
|
+
a_state = Isomorfeus.store.get_state
|
24
|
+
if a_state.key?(:component_class_state) && a_state[:component_class_state].key?(key)
|
25
|
+
return a_state[:component_class_state][key]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
if @component_instance.class.default_class_store_defined && @component_instance.class.class_store.to_h.key?(key)
|
21
29
|
# check if a default value was given
|
22
30
|
return @component_instance.class.class_store.to_h[key]
|
23
31
|
end
|
@@ -16,11 +16,20 @@ module LucidComponent
|
|
16
16
|
else
|
17
17
|
# get instance state
|
18
18
|
|
19
|
-
if
|
20
|
-
@native_component_instance.JS[:context].JS[:component_state].JS[@component_object_id]
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
if `this.native_component_instance.context`
|
20
|
+
if @native_component_instance.JS[:context].JS[:component_state].JS[@component_object_id] &&
|
21
|
+
@native_component_instance.JS[:context].JS[:component_state].JS[@component_object_id].JS.hasOwnProperty(key)
|
22
|
+
# check if we have a component local state value
|
23
|
+
return @native_component_instance.JS[:context].JS[:component_state].JS[@component_object_id].JS[key]
|
24
|
+
end
|
25
|
+
else
|
26
|
+
a_state = Isomorfeus.store.get_state
|
27
|
+
if a_state.key?(:component_state) && a_state[:component_state].key?(key)
|
28
|
+
return a_state[:component_state][key]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if @component_instance.class.default_instance_store_defined && @component_instance.class.store.to_h.key?(key)
|
24
33
|
# check if a default value was given
|
25
34
|
return @component_instance.class.store.to_h[key]
|
26
35
|
end
|
@@ -57,27 +57,31 @@ module LucidComponent
|
|
57
57
|
return this.context;
|
58
58
|
}
|
59
59
|
shouldComponentUpdate(next_props, next_state) {
|
60
|
+
let counter = 0;
|
60
61
|
for (var property in next_props) {
|
62
|
+
counter++;
|
61
63
|
if (next_props.hasOwnProperty(property)) {
|
62
64
|
if (!this.props.hasOwnProperty(property)) { return true; };
|
63
|
-
if (property
|
64
|
-
else if (typeof next_props[property] !== "undefined" && next_props[property] !== null &&
|
65
|
-
typeof
|
66
|
-
typeof this.props[property] !== "undefined" && this.props[property] !== null &&
|
67
|
-
typeof this.props[property]['$!='] !== "undefined") {
|
65
|
+
if (property === "children") { if (next_props.children !== this.props.children) { return true; }}
|
66
|
+
else if (typeof next_props[property] !== "undefined" && next_props[property] !== null && typeof next_props[property]['$!='] === "function" &&
|
67
|
+
typeof this.props[property] !== "undefined" && this.props[property] !== null ) {
|
68
68
|
if (#{ !! (`next_props[property]` != `this.props[property]`) }) { return true; }
|
69
69
|
} else if (next_props[property] !== this.props[property]) { return true; }
|
70
70
|
}
|
71
71
|
}
|
72
|
+
if (counter !== Object.keys(this.props).length) { return true; }
|
73
|
+
counter = 0;
|
72
74
|
for (var property in next_state) {
|
75
|
+
counter++;
|
73
76
|
if (next_state.hasOwnProperty(property)) {
|
74
77
|
if (!this.state.hasOwnProperty(property)) { return true; };
|
75
|
-
if (next_state[property] !== null && typeof next_state[property]['$!=']
|
76
|
-
this.state[property] !==
|
78
|
+
if (typeof next_state[property] !== "undefined" && next_state[property] !== null && typeof next_state[property]['$!='] === "function" &&
|
79
|
+
typeof this.state[property] !== "undefined" && this.state[property] !== null) {
|
77
80
|
if (#{ !! (`next_state[property]` != `this.state[property]`) }) { return true }
|
78
81
|
} else if (next_state[property] !== this.state[property]) { return true }
|
79
82
|
}
|
80
83
|
}
|
84
|
+
if (counter !== Object.keys(this.state).length) { return true; }
|
81
85
|
return false;
|
82
86
|
}
|
83
87
|
validateProp(props, propName, componentName) {
|
@@ -94,7 +98,7 @@ module LucidComponent
|
|
94
98
|
let classes = null;
|
95
99
|
let theme = Opal.global.ReactJSS.useTheme();
|
96
100
|
if (base.jss_styles) {
|
97
|
-
if (!base.use_styles || (Opal.Isomorfeus
|
101
|
+
if (!base.use_styles || (Opal.Isomorfeus.development && !Object.is(base.jss_styles, base.jss_styles_used))) {
|
98
102
|
base.jss_styles_used = base.jss_styles;
|
99
103
|
let styles = base.jss_styles
|
100
104
|
if (typeof styles === 'function') { styles = base.jss_styles(theme); }
|
@@ -32,6 +32,10 @@ module LucidComponent
|
|
32
32
|
@default_instance_store_defined = true
|
33
33
|
@default_instance_store ||= ::LucidComponent::ComponentInstanceStoreDefaults.new(state, self.to_s)
|
34
34
|
end
|
35
|
+
|
36
|
+
def store_updates_off
|
37
|
+
`delete base.lucid_react_component['contextType']`
|
38
|
+
end
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
@@ -55,6 +55,7 @@ module LucidMaterial
|
|
55
55
|
return #{component_name};
|
56
56
|
}
|
57
57
|
render() {
|
58
|
+
this.context = this.state.isomorfeus_store_state;
|
58
59
|
Opal.React.render_buffer.push([]);
|
59
60
|
// console.log("material app pushed", Opal.React.render_buffer, Opal.React.render_buffer.toString());
|
60
61
|
Opal.React.active_components.push(this);
|
@@ -67,6 +68,9 @@ module LucidMaterial
|
|
67
68
|
var children = Opal.React.render_buffer.pop();
|
68
69
|
return Opal.global.React.createElement(Opal.global.LucidApplicationContext.Provider, { value: this.state.isomorfeus_store_state }, children);
|
69
70
|
}
|
71
|
+
data_access() {
|
72
|
+
return this.context;
|
73
|
+
}
|
70
74
|
listener() {
|
71
75
|
var next_state = Opal.Isomorfeus.store.native.getState();
|
72
76
|
this.setState({ isomorfeus_store_state: next_state });
|
@@ -88,7 +92,7 @@ module LucidMaterial
|
|
88
92
|
let classes = null;
|
89
93
|
let theme = Opal.global.MuiStyles.useTheme();
|
90
94
|
if (base.jss_styles) {
|
91
|
-
if (!base.use_styles || (Opal.Isomorfeus
|
95
|
+
if (!base.use_styles || (Opal.Isomorfeus.development && !Object.is(base.jss_styles, base.jss_styles_used))) {
|
92
96
|
base.jss_styles_used = base.jss_styles;
|
93
97
|
let styles = base.jss_styles
|
94
98
|
if (typeof styles === 'function') { styles = styles(theme); }
|
@@ -58,27 +58,31 @@ module LucidMaterial
|
|
58
58
|
return this.context;
|
59
59
|
}
|
60
60
|
shouldComponentUpdate(next_props, next_state) {
|
61
|
+
let counter = 0;
|
61
62
|
for (var property in next_props) {
|
63
|
+
counter++;
|
62
64
|
if (next_props.hasOwnProperty(property)) {
|
63
65
|
if (!this.props.hasOwnProperty(property)) { return true; };
|
64
|
-
if (property
|
65
|
-
else if (typeof next_props[property] !== "undefined" && next_props[property] !== null &&
|
66
|
-
typeof
|
67
|
-
typeof this.props[property] !== "undefined" && this.props[property] !== null &&
|
68
|
-
typeof this.props[property]['$!='] !== "undefined") {
|
66
|
+
if (property === "children") { if (next_props.children !== this.props.children) { return true; }}
|
67
|
+
else if (typeof next_props[property] !== "undefined" && next_props[property] !== null && typeof next_props[property]['$!='] === "function" &&
|
68
|
+
typeof this.props[property] !== "undefined" && this.props[property] !== null ) {
|
69
69
|
if (#{ !! (`next_props[property]` != `this.props[property]`) }) { return true; }
|
70
70
|
} else if (next_props[property] !== this.props[property]) { return true; }
|
71
71
|
}
|
72
72
|
}
|
73
|
+
if (counter !== Object.keys(this.props).length) { return true; }
|
74
|
+
counter = 0;
|
73
75
|
for (var property in next_state) {
|
76
|
+
counter++;
|
74
77
|
if (next_state.hasOwnProperty(property)) {
|
75
78
|
if (!this.state.hasOwnProperty(property)) { return true; };
|
76
|
-
if (next_state[property] !== null && typeof next_state[property]['$!=']
|
77
|
-
this.state[property] !==
|
79
|
+
if (typeof next_state[property] !== "undefined" && next_state[property] !== null && typeof next_state[property]['$!='] === "function" &&
|
80
|
+
typeof this.state[property] !== "undefined" && this.state[property] !== null) {
|
78
81
|
if (#{ !! (`next_state[property]` != `this.state[property]`) }) { return true }
|
79
82
|
} else if (next_state[property] !== this.state[property]) { return true }
|
80
83
|
}
|
81
84
|
}
|
85
|
+
if (counter !== Object.keys(this.state).length) { return true; }
|
82
86
|
return false;
|
83
87
|
}
|
84
88
|
validateProp(props, propName, componentName) {
|
@@ -95,7 +99,7 @@ module LucidMaterial
|
|
95
99
|
let classes = null;
|
96
100
|
let theme = Opal.global.MuiStyles.useTheme();
|
97
101
|
if (base.jss_styles) {
|
98
|
-
if (!base.use_styles || (Opal.Isomorfeus
|
102
|
+
if (!base.use_styles || (Opal.Isomorfeus.development && !Object.is(base.jss_styles, base.jss_styles_used))) {
|
99
103
|
base.jss_styles_used = base.jss_styles;
|
100
104
|
let styles = base.jss_styles
|
101
105
|
if (typeof styles === 'function') { styles = styles(theme); }
|
@@ -51,27 +51,31 @@ module React
|
|
51
51
|
if (base.should_component_update_block) {
|
52
52
|
return #{!!`this.__ruby_instance`.instance_exec(React::Component::Props.new(`{props: next_props}`), React::Component::State.new(`{state: next_state }`), &`base.should_component_update_block`)};
|
53
53
|
}
|
54
|
+
let counter = 0;
|
54
55
|
for (var property in next_props) {
|
56
|
+
counter++;
|
55
57
|
if (next_props.hasOwnProperty(property)) {
|
56
|
-
if (!this.props.hasOwnProperty(property)) { return true; }
|
57
|
-
if (property
|
58
|
-
else if (typeof next_props[property] !== "undefined" && next_props[property] !== null &&
|
59
|
-
typeof
|
60
|
-
typeof this.props[property] !== "undefined" && this.props[property] !== null &&
|
61
|
-
typeof this.props[property]['$!='] !== "undefined") {
|
58
|
+
if (!this.props.hasOwnProperty(property)) { return true; };
|
59
|
+
if (property === "children") { if (next_props.children !== this.props.children) { return true; }}
|
60
|
+
else if (typeof next_props[property] !== "undefined" && next_props[property] !== null && typeof next_props[property]['$!='] === "function" &&
|
61
|
+
typeof this.props[property] !== "undefined" && this.props[property] !== null ) {
|
62
62
|
if (#{ !! (`next_props[property]` != `this.props[property]`) }) { return true; }
|
63
63
|
} else if (next_props[property] !== this.props[property]) { return true; }
|
64
64
|
}
|
65
65
|
}
|
66
|
+
if (counter !== Object.keys(this.props).length) { return true; }
|
67
|
+
counter = 0;
|
66
68
|
for (var property in next_state) {
|
69
|
+
counter++;
|
67
70
|
if (next_state.hasOwnProperty(property)) {
|
68
71
|
if (!this.state.hasOwnProperty(property)) { return true; };
|
69
|
-
if (next_state[property] !== null && typeof next_state[property]['$!=']
|
70
|
-
this.state[property] !==
|
72
|
+
if (typeof next_state[property] !== "undefined" && next_state[property] !== null && typeof next_state[property]['$!='] === "function" &&
|
73
|
+
typeof this.state[property] !== "undefined" && this.state[property] !== null) {
|
71
74
|
if (#{ !! (`next_state[property]` != `this.state[property]`) }) { return true }
|
72
75
|
} else if (next_state[property] !== this.state[property]) { return true }
|
73
76
|
}
|
74
77
|
}
|
78
|
+
if (counter !== Object.keys(this.state).length) { return true; }
|
75
79
|
return false;
|
76
80
|
}
|
77
81
|
validateProp(props, propName, componentName) {
|
data/lib/react/version.rb
CHANGED