isomorfeus-react 16.13.11 → 16.13.12
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 +4 -4
- data/README.md +3 -1
- data/lib/isomorfeus/react/config.rb +189 -189
- data/lib/isomorfeus/react/memcached_component_cache.rb +19 -19
- data/lib/isomorfeus/react/redis_component_cache.rb +19 -19
- data/lib/isomorfeus/react/thread_local_component_cache.rb +15 -15
- data/lib/isomorfeus/react_view_helper.rb +231 -231
- data/lib/isomorfeus/top_level.rb +103 -103
- data/lib/isomorfeus/top_level_ssr.rb +42 -42
- data/lib/isomorfeus-react-material-ui.rb +4 -4
- data/lib/isomorfeus-react-native.rb +5 -5
- data/lib/isomorfeus-react-paper.rb +4 -4
- data/lib/isomorfeus-react.rb +120 -120
- data/lib/isomorfeus_react/lucid_app/api.rb +26 -26
- data/lib/isomorfeus_react/lucid_app/base.rb +7 -7
- data/lib/isomorfeus_react/lucid_app/mixin.rb +23 -23
- data/lib/isomorfeus_react/lucid_app/native_component_constructor.rb +48 -48
- data/lib/isomorfeus_react/lucid_app/native_lucid_component_constructor.rb +94 -95
- data/lib/isomorfeus_react/lucid_component/api.rb +75 -75
- data/lib/isomorfeus_react/lucid_component/app_store_proxy.rb +37 -37
- data/lib/isomorfeus_react/lucid_component/base.rb +7 -7
- data/lib/isomorfeus_react/lucid_component/class_store_proxy.rb +44 -44
- data/lib/isomorfeus_react/lucid_component/initializer.rb +14 -14
- data/lib/isomorfeus_react/lucid_component/instance_store_proxy.rb +44 -44
- data/lib/isomorfeus_react/lucid_component/mixin.rb +22 -22
- data/lib/isomorfeus_react/lucid_component/native_component_constructor.rb +35 -35
- data/lib/isomorfeus_react/lucid_component/native_lucid_component_constructor.rb +82 -83
- data/lib/isomorfeus_react/lucid_component/styles_api.rb +34 -34
- data/lib/isomorfeus_react/lucid_func/base.rb +7 -7
- data/lib/isomorfeus_react/lucid_func/initializer.rb +11 -11
- data/lib/isomorfeus_react/lucid_func/mixin.rb +18 -18
- data/lib/isomorfeus_react/lucid_func/native_component_constructor.rb +81 -81
- data/lib/isomorfeus_react/react/function_component/api.rb +105 -105
- data/lib/isomorfeus_react/react/function_component/base.rb +8 -8
- data/lib/isomorfeus_react/react/function_component/initializer.rb +10 -10
- data/lib/isomorfeus_react/react/function_component/mixin.rb +17 -17
- data/lib/isomorfeus_react/react/function_component/native_component_constructor.rb +48 -48
- data/lib/isomorfeus_react/react/memo_component/base.rb +8 -8
- data/lib/isomorfeus_react/react/memo_component/mixin.rb +17 -17
- data/lib/isomorfeus_react/react/memo_component/native_component_constructor.rb +49 -49
- data/lib/isomorfeus_react_material/lucid_material/app/base.rb +8 -8
- data/lib/isomorfeus_react_material/lucid_material/app/mixin.rb +20 -20
- data/lib/isomorfeus_react_material/lucid_material/app/native_component_constructor.rb +50 -50
- data/lib/isomorfeus_react_material/lucid_material/component/base.rb +9 -9
- data/lib/isomorfeus_react_material/lucid_material/component/mixin.rb +19 -19
- data/lib/isomorfeus_react_material/lucid_material/component/native_component_constructor.rb +36 -36
- data/lib/isomorfeus_react_material/lucid_material/func/base.rb +9 -9
- data/lib/isomorfeus_react_material/lucid_material/func/mixin.rb +15 -15
- data/lib/isomorfeus_react_material/lucid_material/func/native_component_constructor.rb +83 -83
- data/lib/isomorfeus_react_paper/lucid_paper/app/base.rb +9 -9
- data/lib/isomorfeus_react_paper/lucid_paper/app/mixin.rb +19 -19
- data/lib/isomorfeus_react_paper/lucid_paper/app/native_component_constructor.rb +32 -32
- data/lib/isomorfeus_react_paper/lucid_paper/component/base.rb +9 -9
- data/lib/isomorfeus_react_paper/lucid_paper/component/mixin.rb +18 -18
- data/lib/isomorfeus_react_paper/lucid_paper/component/native_component_constructor.rb +25 -25
- data/lib/isomorfeus_react_paper/lucid_paper/func/base.rb +9 -9
- data/lib/isomorfeus_react_paper/lucid_paper/func/mixin.rb +14 -14
- data/lib/isomorfeus_react_paper/lucid_paper/func/native_component_constructor.rb +71 -71
- data/lib/lucid_app/context.rb +7 -7
- data/lib/lucid_prop_declaration/mixin.rb +126 -126
- data/lib/react/children.rb +34 -34
- data/lib/react/component/api.rb +134 -134
- data/lib/react/component/base.rb +8 -8
- data/lib/react/component/callbacks.rb +115 -115
- data/lib/react/component/elements.rb +60 -60
- data/lib/react/component/features.rb +48 -48
- data/lib/react/component/history.rb +69 -65
- data/lib/react/component/initializer.rb +11 -11
- data/lib/react/component/location.rb +19 -15
- data/lib/react/component/match.rb +35 -31
- data/lib/react/component/mixin.rb +20 -20
- data/lib/react/component/native_component_constructor.rb +69 -70
- data/lib/react/component/props.rb +83 -83
- data/lib/react/component/resolution.rb +97 -97
- data/lib/react/component/state.rb +58 -54
- data/lib/react/component/styles.rb +66 -66
- data/lib/react/context_wrapper.rb +48 -44
- data/lib/react/native_constant_wrapper.rb +29 -29
- data/lib/react/ref.rb +16 -12
- data/lib/react/synthetic_event.rb +52 -52
- data/lib/react/version.rb +3 -3
- data/lib/react.rb +296 -296
- data/lib/react_dom.rb +41 -41
- data/lib/react_dom_server.rb +18 -18
- data/lib/react_native/component/elements.rb +203 -203
- data/lib/react_native/lucid_app/react_native_component_constructor.rb +51 -51
- data/lib/react_native/lucid_component/react_native_component_constructor.rb +37 -37
- data/lib/react_native/lucid_func/react_native_component_constructor.rb +82 -82
- data/lib/react_native/react.rb +120 -120
- metadata +23 -17
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
module LucidPaper
|
|
2
|
-
module App
|
|
3
|
-
module Mixin
|
|
4
|
-
def self.included(base)
|
|
5
|
-
base.include(::Native::Wrapper)
|
|
6
|
-
base.extend(::LucidApp::NativeLucidComponentConstructor)
|
|
7
|
-
base.extend(::LucidPaper::App::NativeComponentConstructor)
|
|
8
|
-
base.extend(::LucidPropDeclaration::Mixin)
|
|
9
|
-
base.include(::React::Component::Elements)
|
|
10
|
-
base.include(::React::Component::Api)
|
|
11
|
-
base.include(::React::Component::Callbacks)
|
|
12
|
-
base.include(::LucidComponent::Api)
|
|
13
|
-
base.include(::LucidApp::Api)
|
|
14
|
-
base.include(::LucidComponent::Initializer)
|
|
15
|
-
base.include(::React::Component::Features)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
1
|
+
module LucidPaper
|
|
2
|
+
module App
|
|
3
|
+
module Mixin
|
|
4
|
+
def self.included(base)
|
|
5
|
+
base.include(::Native::Wrapper)
|
|
6
|
+
base.extend(::LucidApp::NativeLucidComponentConstructor)
|
|
7
|
+
base.extend(::LucidPaper::App::NativeComponentConstructor)
|
|
8
|
+
base.extend(::LucidPropDeclaration::Mixin)
|
|
9
|
+
base.include(::React::Component::Elements)
|
|
10
|
+
base.include(::React::Component::Api)
|
|
11
|
+
base.include(::React::Component::Callbacks)
|
|
12
|
+
base.include(::LucidComponent::Api)
|
|
13
|
+
base.include(::LucidApp::Api)
|
|
14
|
+
base.include(::LucidComponent::Initializer)
|
|
15
|
+
base.include(::React::Component::Features)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
module LucidPaper
|
|
2
|
-
module App
|
|
3
|
-
module NativeComponentConstructor
|
|
4
|
-
# for should_component_update we apply ruby semantics for comparing props
|
|
5
|
-
# to do so, we convert the props to ruby hashes and then compare
|
|
6
|
-
# this makes sure, that for example rubys Nil object gets handled properly
|
|
7
|
-
def self.extended(base)
|
|
8
|
-
%x{
|
|
9
|
-
base.jss_theme = Opal.global.Paper.DefaultTheme;
|
|
10
|
-
base.themed_component = Opal.global.Paper.withTheme(base.lucid_react_component);
|
|
11
|
-
base.react_component = class extends Opal.global.React.Component {
|
|
12
|
-
constructor(props) {
|
|
13
|
-
super(props);
|
|
14
|
-
if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
|
|
15
|
-
}
|
|
16
|
-
static get displayName() {
|
|
17
|
-
return "IsomorfeusTopLevelComponent";
|
|
18
|
-
}
|
|
19
|
-
static set displayName(new_name) {
|
|
20
|
-
// dont do anything here except returning the set value
|
|
21
|
-
return new_name;
|
|
22
|
-
}
|
|
23
|
-
render() {
|
|
24
|
-
let themed_component = Opal.global.React.createElement(base.themed_component, this.props);
|
|
25
|
-
return Opal.global.React.createElement(Opal.global.Paper.Provider, { theme: base.jss_theme }, themed_component);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
1
|
+
module LucidPaper
|
|
2
|
+
module App
|
|
3
|
+
module NativeComponentConstructor
|
|
4
|
+
# for should_component_update we apply ruby semantics for comparing props
|
|
5
|
+
# to do so, we convert the props to ruby hashes and then compare
|
|
6
|
+
# this makes sure, that for example rubys Nil object gets handled properly
|
|
7
|
+
def self.extended(base)
|
|
8
|
+
%x{
|
|
9
|
+
base.jss_theme = Opal.global.Paper.DefaultTheme;
|
|
10
|
+
base.themed_component = Opal.global.Paper.withTheme(base.lucid_react_component);
|
|
11
|
+
base.react_component = class extends Opal.global.React.Component {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
|
|
15
|
+
}
|
|
16
|
+
static get displayName() {
|
|
17
|
+
return "IsomorfeusTopLevelComponent";
|
|
18
|
+
}
|
|
19
|
+
static set displayName(new_name) {
|
|
20
|
+
// dont do anything here except returning the set value
|
|
21
|
+
return new_name;
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
let themed_component = Opal.global.React.createElement(base.themed_component, this.props);
|
|
25
|
+
return Opal.global.React.createElement(Opal.global.Paper.Provider, { theme: base.jss_theme }, themed_component);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
module LucidPaper
|
|
2
|
-
module Component
|
|
3
|
-
class Base
|
|
4
|
-
def self.inherited(base)
|
|
5
|
-
base.include(::LucidPaper::Component::Mixin)
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
end
|
|
1
|
+
module LucidPaper
|
|
2
|
+
module Component
|
|
3
|
+
class Base
|
|
4
|
+
def self.inherited(base)
|
|
5
|
+
base.include(::LucidPaper::Component::Mixin)
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
module LucidPaper
|
|
2
|
-
module Component
|
|
3
|
-
module Mixin
|
|
4
|
-
def self.included(base)
|
|
5
|
-
base.include(::Native::Wrapper)
|
|
6
|
-
base.extend(::LucidComponent::NativeLucidComponentConstructor)
|
|
7
|
-
base.extend(::LucidPaper::Component::NativeComponentConstructor)
|
|
8
|
-
base.extend(::LucidPropDeclaration::Mixin)
|
|
9
|
-
base.include(::React::Component::Elements)
|
|
10
|
-
base.include(::React::Component::Api)
|
|
11
|
-
base.include(::React::Component::Callbacks)
|
|
12
|
-
base.include(::LucidComponent::Api)
|
|
13
|
-
base.include(::LucidComponent::Initializer)
|
|
14
|
-
base.include(::React::Component::Features)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
1
|
+
module LucidPaper
|
|
2
|
+
module Component
|
|
3
|
+
module Mixin
|
|
4
|
+
def self.included(base)
|
|
5
|
+
base.include(::Native::Wrapper)
|
|
6
|
+
base.extend(::LucidComponent::NativeLucidComponentConstructor)
|
|
7
|
+
base.extend(::LucidPaper::Component::NativeComponentConstructor)
|
|
8
|
+
base.extend(::LucidPropDeclaration::Mixin)
|
|
9
|
+
base.include(::React::Component::Elements)
|
|
10
|
+
base.include(::React::Component::Api)
|
|
11
|
+
base.include(::React::Component::Callbacks)
|
|
12
|
+
base.include(::LucidComponent::Api)
|
|
13
|
+
base.include(::LucidComponent::Initializer)
|
|
14
|
+
base.include(::React::Component::Features)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
module LucidPaper
|
|
2
|
-
module Component
|
|
3
|
-
module NativeComponentConstructor
|
|
4
|
-
# for should_component_update we apply ruby semantics for comparing props
|
|
5
|
-
# to do so, we convert the props to ruby hashes and then compare
|
|
6
|
-
# this makes sure, that for example rubys Nil object gets handled properly
|
|
7
|
-
def self.extended(base)
|
|
8
|
-
component_name = base.to_s + 'Wrapper'
|
|
9
|
-
# language=JS
|
|
10
|
-
%x{
|
|
11
|
-
base.react_component = Opal.global.React.memo(function(props) {
|
|
12
|
-
let classes = null;
|
|
13
|
-
let store;
|
|
14
|
-
if (base.store_updates) { store = Opal.global.React.useContext(Opal.global.LucidApplicationContext); }
|
|
15
|
-
let new_props = Object.assign({}, props)
|
|
16
|
-
new_props.store = store;
|
|
17
|
-
new_props.theme = Opal.global.Paper.useTheme();
|
|
18
|
-
return Opal.global.React.createElement(base.lucid_react_component, new_props);
|
|
19
|
-
}, Opal.React.props_are_equal);
|
|
20
|
-
base.react_component.displayName = #{component_name};
|
|
21
|
-
}
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
1
|
+
module LucidPaper
|
|
2
|
+
module Component
|
|
3
|
+
module NativeComponentConstructor
|
|
4
|
+
# for should_component_update we apply ruby semantics for comparing props
|
|
5
|
+
# to do so, we convert the props to ruby hashes and then compare
|
|
6
|
+
# this makes sure, that for example rubys Nil object gets handled properly
|
|
7
|
+
def self.extended(base)
|
|
8
|
+
component_name = base.to_s + 'Wrapper'
|
|
9
|
+
# language=JS
|
|
10
|
+
%x{
|
|
11
|
+
base.react_component = Opal.global.React.memo(function(props) {
|
|
12
|
+
let classes = null;
|
|
13
|
+
let store;
|
|
14
|
+
if (base.store_updates) { store = Opal.global.React.useContext(Opal.global.LucidApplicationContext); }
|
|
15
|
+
let new_props = Object.assign({}, props)
|
|
16
|
+
new_props.store = store;
|
|
17
|
+
new_props.theme = Opal.global.Paper.useTheme();
|
|
18
|
+
return Opal.global.React.createElement(base.lucid_react_component, new_props);
|
|
19
|
+
}, Opal.React.props_are_equal);
|
|
20
|
+
base.react_component.displayName = #{component_name};
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
module LucidPaper
|
|
2
|
-
module Func
|
|
3
|
-
class Base
|
|
4
|
-
def self.inherited(base)
|
|
5
|
-
base.include(::LucidPaper::Func::Mixin)
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
end
|
|
1
|
+
module LucidPaper
|
|
2
|
+
module Func
|
|
3
|
+
class Base
|
|
4
|
+
def self.inherited(base)
|
|
5
|
+
base.include(::LucidPaper::Func::Mixin)
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
module LucidPaper
|
|
2
|
-
module Func
|
|
3
|
-
module Mixin
|
|
4
|
-
def self.included(base)
|
|
5
|
-
base.include(::React::Component::Elements)
|
|
6
|
-
base.include(::React::Component::Features)
|
|
7
|
-
base.include(::LucidFunc::Initializer)
|
|
8
|
-
base.include(::React::FunctionComponent::Api)
|
|
9
|
-
base.extend(::LucidPaper::Func::NativeComponentConstructor)
|
|
10
|
-
base.include(::LucidComponent::Api)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
1
|
+
module LucidPaper
|
|
2
|
+
module Func
|
|
3
|
+
module Mixin
|
|
4
|
+
def self.included(base)
|
|
5
|
+
base.include(::React::Component::Elements)
|
|
6
|
+
base.include(::React::Component::Features)
|
|
7
|
+
base.include(::LucidFunc::Initializer)
|
|
8
|
+
base.include(::React::FunctionComponent::Api)
|
|
9
|
+
base.extend(::LucidPaper::Func::NativeComponentConstructor)
|
|
10
|
+
base.include(::LucidComponent::Api)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
module LucidPaper
|
|
2
|
-
module Func
|
|
3
|
-
module NativeComponentConstructor
|
|
4
|
-
def self.extended(base)
|
|
5
|
-
component_name = "#{base.to_s}Wrapper"
|
|
6
|
-
%x{
|
|
7
|
-
base.store_updates = true;
|
|
8
|
-
base.equality_checker = null;
|
|
9
|
-
base.instance_init = function(initial) {
|
|
10
|
-
let ruby_state = { instance: #{base.new(`{}`)} };
|
|
11
|
-
ruby_state.instance.__ruby_instance = ruby_state.instance;
|
|
12
|
-
ruby_state.instance.data_access = function() { return this.props.store; }
|
|
13
|
-
ruby_state.instance.data_access.bind(ruby_state.instance);
|
|
14
|
-
return ruby_state;
|
|
15
|
-
}
|
|
16
|
-
base.instance_reducer = function(state, action) { return state; }
|
|
17
|
-
base.react_component = Opal.global.React.memo(function(props) {
|
|
18
|
-
const og = Opal.global;
|
|
19
|
-
const oper = Opal.React;
|
|
20
|
-
oper.render_buffer.push([]);
|
|
21
|
-
// console.log("function pushed", oper.render_buffer, oper.render_buffer.toString());
|
|
22
|
-
// Lucid functionality
|
|
23
|
-
let store;
|
|
24
|
-
if (base.store_updates) { store = og.React.useContext(og.LucidApplicationContext); }
|
|
25
|
-
// prepare Ruby instance
|
|
26
|
-
const [__ruby_state, __ruby_dispatch] = og.React.useReducer(base.instance_reducer, null, base.instance_init);
|
|
27
|
-
const __ruby_instance = __ruby_state.instance;
|
|
28
|
-
__ruby_instance.props = Object.assign({}, props);
|
|
29
|
-
__ruby_instance.props.store = store;
|
|
30
|
-
__ruby_instance.props.theme = Opal.global.Paper.useTheme();
|
|
31
|
-
oper.active_components.push(__ruby_instance);
|
|
32
|
-
oper.active_redux_components.push(__ruby_instance);
|
|
33
|
-
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
|
34
|
-
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
|
35
|
-
oper.active_redux_components.pop();
|
|
36
|
-
oper.active_components.pop();
|
|
37
|
-
// console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
|
|
38
|
-
let result = oper.render_buffer.pop();
|
|
39
|
-
return (result.length === 1) ? result[0] : result;
|
|
40
|
-
}, base.equality_checker);
|
|
41
|
-
base.react_component.displayName = #{component_name};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
base_module = base.to_s.deconstantize
|
|
45
|
-
if base_module != ''
|
|
46
|
-
base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
|
|
47
|
-
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
|
48
|
-
end
|
|
49
|
-
else
|
|
50
|
-
Object.define_method(base.to_s) do |*args, &block|
|
|
51
|
-
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def props_are_equal?(&block)
|
|
56
|
-
%x{
|
|
57
|
-
base.equality_checker = function (prev_props, next_props) {
|
|
58
|
-
var prev_ruby_props = Opal.React.Component.Props.$new({props: prev_props});
|
|
59
|
-
var next_ruby_props = Opal.React.Component.Props.$new({props: next_props});
|
|
60
|
-
return #{block.call(`prev_ruby_props`, `next_ruby_props`)};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def render(&block)
|
|
66
|
-
`base.render_block = #{block}`
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
1
|
+
module LucidPaper
|
|
2
|
+
module Func
|
|
3
|
+
module NativeComponentConstructor
|
|
4
|
+
def self.extended(base)
|
|
5
|
+
component_name = "#{base.to_s}Wrapper"
|
|
6
|
+
%x{
|
|
7
|
+
base.store_updates = true;
|
|
8
|
+
base.equality_checker = null;
|
|
9
|
+
base.instance_init = function(initial) {
|
|
10
|
+
let ruby_state = { instance: #{base.new(`{}`)} };
|
|
11
|
+
ruby_state.instance.__ruby_instance = ruby_state.instance;
|
|
12
|
+
ruby_state.instance.data_access = function() { return this.props.store; }
|
|
13
|
+
ruby_state.instance.data_access.bind(ruby_state.instance);
|
|
14
|
+
return ruby_state;
|
|
15
|
+
}
|
|
16
|
+
base.instance_reducer = function(state, action) { return state; }
|
|
17
|
+
base.react_component = Opal.global.React.memo(function(props) {
|
|
18
|
+
const og = Opal.global;
|
|
19
|
+
const oper = Opal.React;
|
|
20
|
+
oper.render_buffer.push([]);
|
|
21
|
+
// console.log("function pushed", oper.render_buffer, oper.render_buffer.toString());
|
|
22
|
+
// Lucid functionality
|
|
23
|
+
let store;
|
|
24
|
+
if (base.store_updates) { store = og.React.useContext(og.LucidApplicationContext); }
|
|
25
|
+
// prepare Ruby instance
|
|
26
|
+
const [__ruby_state, __ruby_dispatch] = og.React.useReducer(base.instance_reducer, null, base.instance_init);
|
|
27
|
+
const __ruby_instance = __ruby_state.instance;
|
|
28
|
+
__ruby_instance.props = Object.assign({}, props);
|
|
29
|
+
__ruby_instance.props.store = store;
|
|
30
|
+
__ruby_instance.props.theme = Opal.global.Paper.useTheme();
|
|
31
|
+
oper.active_components.push(__ruby_instance);
|
|
32
|
+
oper.active_redux_components.push(__ruby_instance);
|
|
33
|
+
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
|
34
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
|
35
|
+
oper.active_redux_components.pop();
|
|
36
|
+
oper.active_components.pop();
|
|
37
|
+
// console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
|
|
38
|
+
let result = oper.render_buffer.pop();
|
|
39
|
+
return (result.length === 1) ? result[0] : result;
|
|
40
|
+
}, base.equality_checker);
|
|
41
|
+
base.react_component.displayName = #{component_name};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
base_module = base.to_s.deconstantize
|
|
45
|
+
if base_module != ''
|
|
46
|
+
base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
|
|
47
|
+
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
|
48
|
+
end
|
|
49
|
+
else
|
|
50
|
+
Object.define_method(base.to_s) do |*args, &block|
|
|
51
|
+
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def props_are_equal?(&block)
|
|
56
|
+
%x{
|
|
57
|
+
base.equality_checker = function (prev_props, next_props) {
|
|
58
|
+
var prev_ruby_props = Opal.React.Component.Props.$new({props: prev_props});
|
|
59
|
+
var next_ruby_props = Opal.React.Component.Props.$new({props: next_props});
|
|
60
|
+
return #{block.call(`prev_ruby_props`, `next_ruby_props`)};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def render(&block)
|
|
66
|
+
`base.render_block = #{block}`
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
data/lib/lucid_app/context.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
module LucidApp
|
|
2
|
-
module Context
|
|
3
|
-
def self.create_application_context
|
|
4
|
-
React.create_context('LucidApplicationContext', Isomorfeus.store)
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
end
|
|
1
|
+
module LucidApp
|
|
2
|
+
module Context
|
|
3
|
+
def self.create_application_context
|
|
4
|
+
React.create_context('LucidApplicationContext', Isomorfeus.store)
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
end
|