isomorfeus-react 16.13.11 → 16.13.12
Sign up to get free protection for your applications and to get access to all the features.
- 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,37 +1,37 @@
|
|
1
|
-
module LucidComponent
|
2
|
-
module ReactNativeComponentConstructor
|
3
|
-
# for should_component_update we apply ruby semantics for comparing props
|
4
|
-
# to do so, we convert the props to ruby hashes and then compare
|
5
|
-
# this makes sure, that for example rubys Nil object gets handled properly
|
6
|
-
def self.extended(base)
|
7
|
-
component_name = base.to_s + 'Wrapper'
|
8
|
-
# language=JS
|
9
|
-
%x{
|
10
|
-
base.react_component = Opal.global.React.memo(function(props) {
|
11
|
-
let opag = Opal.global;
|
12
|
-
let store;
|
13
|
-
if (base.store_updates) { store = opag.React.useContext(opag.LucidApplicationContext); }
|
14
|
-
const theme = opag.React.useContext(opag.ThemeContext);
|
15
|
-
let classes;
|
16
|
-
if (base.jss_styles) {
|
17
|
-
if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
|
18
|
-
let styles;
|
19
|
-
if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
|
20
|
-
else { styles = base.jss_styles; }
|
21
|
-
base.use_styles = Opal.React.merge_deep(theme, opag.StyleSheet.create(styles));
|
22
|
-
}
|
23
|
-
classes = base.use_styles;
|
24
|
-
} else {
|
25
|
-
classes = theme;
|
26
|
-
}
|
27
|
-
let new_props = Object.assign({}, props);
|
28
|
-
new_props.theme = theme;
|
29
|
-
new_props.classes = classes;
|
30
|
-
new_props.store = store;
|
31
|
-
return opag.React.createElement(base.lucid_react_component, new_props);
|
32
|
-
}, Opal.React.props_are_equal);
|
33
|
-
base.react_component.displayName = #{component_name};
|
34
|
-
}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
1
|
+
module LucidComponent
|
2
|
+
module ReactNativeComponentConstructor
|
3
|
+
# for should_component_update we apply ruby semantics for comparing props
|
4
|
+
# to do so, we convert the props to ruby hashes and then compare
|
5
|
+
# this makes sure, that for example rubys Nil object gets handled properly
|
6
|
+
def self.extended(base)
|
7
|
+
component_name = base.to_s + 'Wrapper'
|
8
|
+
# language=JS
|
9
|
+
%x{
|
10
|
+
base.react_component = Opal.global.React.memo(function(props) {
|
11
|
+
let opag = Opal.global;
|
12
|
+
let store;
|
13
|
+
if (base.store_updates) { store = opag.React.useContext(opag.LucidApplicationContext); }
|
14
|
+
const theme = opag.React.useContext(opag.ThemeContext);
|
15
|
+
let classes;
|
16
|
+
if (base.jss_styles) {
|
17
|
+
if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
|
18
|
+
let styles;
|
19
|
+
if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
|
20
|
+
else { styles = base.jss_styles; }
|
21
|
+
base.use_styles = Opal.React.merge_deep(theme, opag.StyleSheet.create(styles));
|
22
|
+
}
|
23
|
+
classes = base.use_styles;
|
24
|
+
} else {
|
25
|
+
classes = theme;
|
26
|
+
}
|
27
|
+
let new_props = Object.assign({}, props);
|
28
|
+
new_props.theme = theme;
|
29
|
+
new_props.classes = classes;
|
30
|
+
new_props.store = store;
|
31
|
+
return opag.React.createElement(base.lucid_react_component, new_props);
|
32
|
+
}, Opal.React.props_are_equal);
|
33
|
+
base.react_component.displayName = #{component_name};
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,82 +1,82 @@
|
|
1
|
-
module LucidFunc
|
2
|
-
module ReactNativeComponentConstructor
|
3
|
-
def self.extended(base)
|
4
|
-
component_name = base.to_s
|
5
|
-
%x{
|
6
|
-
base.store_updates = true;
|
7
|
-
base.equality_checker = null;
|
8
|
-
base.instance_init = function(initial) {
|
9
|
-
let ruby_state = { instance: #{base.new(`{}`)} };
|
10
|
-
ruby_state.instance.__ruby_instance = ruby_state.instance;
|
11
|
-
ruby_state.instance.data_access = function() { return this.props.store; }
|
12
|
-
ruby_state.instance.data_access.bind(ruby_state.instance);
|
13
|
-
return ruby_state;
|
14
|
-
}
|
15
|
-
base.instance_reducer = function(state, action) { return state; }
|
16
|
-
base.react_component = Opal.global.React.memo(function(props) {
|
17
|
-
const og = Opal.global;
|
18
|
-
const oper = Opal.React;
|
19
|
-
oper.render_buffer.push([]);
|
20
|
-
// console.log("function pushed", oper.render_buffer, oper.render_buffer.toString());
|
21
|
-
// Lucid functionality
|
22
|
-
let classes = null;
|
23
|
-
let store;
|
24
|
-
if (base.store_updates) { store = og.React.useContext(og.LucidApplicationContext); }
|
25
|
-
let theme = og.ReactJSS.useTheme();
|
26
|
-
if (base.jss_styles) {
|
27
|
-
if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
|
28
|
-
let styles;
|
29
|
-
if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
|
30
|
-
else { styles = base.jss_styles; }
|
31
|
-
base.use_styles = og.ReactJSS.createUseStyles(styles);
|
32
|
-
}
|
33
|
-
classes = base.use_styles();
|
34
|
-
}
|
35
|
-
// prepare Ruby instance
|
36
|
-
const [__ruby_state, __ruby_dispatch] = og.React.useReducer(base.instance_reducer, null, base.instance_init);
|
37
|
-
const __ruby_instance = __ruby_state.instance;
|
38
|
-
__ruby_instance.props = Object.assign({}, props);
|
39
|
-
__ruby_instance.props.store = store;
|
40
|
-
__ruby_instance.props.theme = theme;
|
41
|
-
__ruby_instance.props.classes = classes;
|
42
|
-
oper.active_components.push(__ruby_instance);
|
43
|
-
oper.active_redux_components.push(__ruby_instance);
|
44
|
-
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
45
|
-
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
46
|
-
oper.active_redux_components.pop();
|
47
|
-
oper.active_components.pop();
|
48
|
-
// console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
|
49
|
-
let result = oper.render_buffer.pop();
|
50
|
-
if (result.length === 1) { return result[0]; }
|
51
|
-
return result;
|
52
|
-
}, base.equality_checker);
|
53
|
-
base.react_component.displayName = #{component_name};
|
54
|
-
}
|
55
|
-
|
56
|
-
base_module = base.to_s.deconstantize
|
57
|
-
if base_module != ''
|
58
|
-
base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
|
59
|
-
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
60
|
-
end
|
61
|
-
else
|
62
|
-
Object.define_method(base.to_s) do |*args, &block|
|
63
|
-
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def props_are_equal?(&block)
|
68
|
-
%x{
|
69
|
-
base.equality_checker = function (prev_props, next_props) {
|
70
|
-
var prev_ruby_props = Opal.React.Component.Props.$new({props: prev_props});
|
71
|
-
var next_ruby_props = Opal.React.Component.Props.$new({props: next_props});
|
72
|
-
return #{block.call(`prev_ruby_props`, `next_ruby_props`)};
|
73
|
-
}
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
def render(&block)
|
78
|
-
`base.render_block = #{block}`
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
1
|
+
module LucidFunc
|
2
|
+
module ReactNativeComponentConstructor
|
3
|
+
def self.extended(base)
|
4
|
+
component_name = base.to_s
|
5
|
+
%x{
|
6
|
+
base.store_updates = true;
|
7
|
+
base.equality_checker = null;
|
8
|
+
base.instance_init = function(initial) {
|
9
|
+
let ruby_state = { instance: #{base.new(`{}`)} };
|
10
|
+
ruby_state.instance.__ruby_instance = ruby_state.instance;
|
11
|
+
ruby_state.instance.data_access = function() { return this.props.store; }
|
12
|
+
ruby_state.instance.data_access.bind(ruby_state.instance);
|
13
|
+
return ruby_state;
|
14
|
+
}
|
15
|
+
base.instance_reducer = function(state, action) { return state; }
|
16
|
+
base.react_component = Opal.global.React.memo(function(props) {
|
17
|
+
const og = Opal.global;
|
18
|
+
const oper = Opal.React;
|
19
|
+
oper.render_buffer.push([]);
|
20
|
+
// console.log("function pushed", oper.render_buffer, oper.render_buffer.toString());
|
21
|
+
// Lucid functionality
|
22
|
+
let classes = null;
|
23
|
+
let store;
|
24
|
+
if (base.store_updates) { store = og.React.useContext(og.LucidApplicationContext); }
|
25
|
+
let theme = og.ReactJSS.useTheme();
|
26
|
+
if (base.jss_styles) {
|
27
|
+
if (!base.use_styles || (Opal.Isomorfeus.development === true)) {
|
28
|
+
let styles;
|
29
|
+
if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
|
30
|
+
else { styles = base.jss_styles; }
|
31
|
+
base.use_styles = og.ReactJSS.createUseStyles(styles);
|
32
|
+
}
|
33
|
+
classes = base.use_styles();
|
34
|
+
}
|
35
|
+
// prepare Ruby instance
|
36
|
+
const [__ruby_state, __ruby_dispatch] = og.React.useReducer(base.instance_reducer, null, base.instance_init);
|
37
|
+
const __ruby_instance = __ruby_state.instance;
|
38
|
+
__ruby_instance.props = Object.assign({}, props);
|
39
|
+
__ruby_instance.props.store = store;
|
40
|
+
__ruby_instance.props.theme = theme;
|
41
|
+
__ruby_instance.props.classes = classes;
|
42
|
+
oper.active_components.push(__ruby_instance);
|
43
|
+
oper.active_redux_components.push(__ruby_instance);
|
44
|
+
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
45
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
46
|
+
oper.active_redux_components.pop();
|
47
|
+
oper.active_components.pop();
|
48
|
+
// console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
|
49
|
+
let result = oper.render_buffer.pop();
|
50
|
+
if (result.length === 1) { return result[0]; }
|
51
|
+
return result;
|
52
|
+
}, base.equality_checker);
|
53
|
+
base.react_component.displayName = #{component_name};
|
54
|
+
}
|
55
|
+
|
56
|
+
base_module = base.to_s.deconstantize
|
57
|
+
if base_module != ''
|
58
|
+
base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
|
59
|
+
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
60
|
+
end
|
61
|
+
else
|
62
|
+
Object.define_method(base.to_s) do |*args, &block|
|
63
|
+
`Opal.React.internal_prepare_args_and_render(#{base}.react_component, args, block)`
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def props_are_equal?(&block)
|
68
|
+
%x{
|
69
|
+
base.equality_checker = function (prev_props, next_props) {
|
70
|
+
var prev_ruby_props = Opal.React.Component.Props.$new({props: prev_props});
|
71
|
+
var next_ruby_props = Opal.React.Component.Props.$new({props: next_props});
|
72
|
+
return #{block.call(`prev_ruby_props`, `next_ruby_props`)};
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
def render(&block)
|
78
|
+
`base.render_block = #{block}`
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/react_native/react.rb
CHANGED
@@ -1,120 +1,120 @@
|
|
1
|
-
module React
|
2
|
-
%x{
|
3
|
-
self.prop_dictionary = {
|
4
|
-
on_click: 'onPress',
|
5
|
-
onClick: 'onPress',
|
6
|
-
on_touch: 'onPress',
|
7
|
-
onTouch: 'onPress',
|
8
|
-
on_change: 'onChangeText',
|
9
|
-
onChange: 'onChangeText',
|
10
|
-
on_blur: 'onSubmitText',
|
11
|
-
onBlur: 'onSubmitText',
|
12
|
-
};
|
13
|
-
|
14
|
-
self.to_native_react_props = function(ruby_style_props) {
|
15
|
-
let result = {};
|
16
|
-
let keys = ruby_style_props.$$keys;
|
17
|
-
let keys_length = keys.length;
|
18
|
-
let key = '';
|
19
|
-
for (let i = 0; i < keys_length; i++) {
|
20
|
-
key = keys[i];
|
21
|
-
let value = ruby_style_props.$$smap[key];
|
22
|
-
if (key[0] === 'o' && key[1] === 'n' && key[2] === '_') {
|
23
|
-
let type = typeof value;
|
24
|
-
if (type === "function") {
|
25
|
-
let active_c = self.active_component();
|
26
|
-
result[self.lower_camelize(key)] = function(event, info) {
|
27
|
-
let ruby_event = self.native_to_ruby_event(event);
|
28
|
-
#{`active_c.__ruby_instance`.instance_exec(`ruby_event`, `info`, &`value`)};
|
29
|
-
}
|
30
|
-
} else if (type === "object" && typeof value.$call === "function" ) {
|
31
|
-
if (!value.react_event_handler_function) {
|
32
|
-
value.react_event_handler_function = function(event, info) {
|
33
|
-
let ruby_event = self.native_to_ruby_event(event);
|
34
|
-
value.$call(ruby_event, info)
|
35
|
-
};
|
36
|
-
}
|
37
|
-
result[self.lower_camelize(key)] = value.react_event_handler_function;
|
38
|
-
} else if (type === "string" ) {
|
39
|
-
let active_component = self.active_component();
|
40
|
-
let method_ref;
|
41
|
-
let method_name = '$' + value;
|
42
|
-
if (typeof active_component[method_name] === "function") {
|
43
|
-
// got a ruby instance
|
44
|
-
if (active_component.native && active_component.native.method_refs && active_component.native.method_refs[value]) { method_ref = active_component.native.method_refs[value]; } // ruby instance with native
|
45
|
-
else if (active_component.method_refs && active_component.method_refs[value]) { method_ref = active_component.method_refs[value]; } // ruby function component
|
46
|
-
else { method_ref = active_component.$method_ref(value); } // create the ref
|
47
|
-
} else if (typeof active_component.__ruby_instance[method_name] === "function") {
|
48
|
-
// got a native instance
|
49
|
-
if (active_component.method_refs && active_component.method_refs[value]) { method_ref = active_component.method_refs[value]; }
|
50
|
-
else { method_ref = active_component.__ruby_instance.$method_ref(value); } // create ref for native
|
51
|
-
}
|
52
|
-
if (method_ref) {
|
53
|
-
if (!method_ref.react_event_handler_function) {
|
54
|
-
method_ref.react_event_handler_function = function(event, info) {
|
55
|
-
let ruby_event = self.native_to_ruby_event(event);
|
56
|
-
method_ref.$call(ruby_event, info)
|
57
|
-
};
|
58
|
-
}
|
59
|
-
result[self.lower_camelize(key)] = method_ref.react_event_handler_function;
|
60
|
-
} else {
|
61
|
-
let component_name;
|
62
|
-
if (active_component.__ruby_instance) { component_name = active_component.__ruby_instance.$to_s(); }
|
63
|
-
else { component_name = active_component.$to_s(); }
|
64
|
-
#{Isomorfeus.raise_error(message: "Is #{`value`} a valid method of #{`component_name`}? If so then please use: #{`key`}: method_ref(:#{`value`}) within component: #{`component_name`}")}
|
65
|
-
}
|
66
|
-
} else {
|
67
|
-
let active_component = self.active_component();
|
68
|
-
let component_name;
|
69
|
-
if (active_component.__ruby_instance) { component_name = active_component.__ruby_instance.$to_s(); }
|
70
|
-
else { component_name = active_component.$to_s(); }
|
71
|
-
#{Isomorfeus.raise_error(message: "Received invalid value for #{`key`} with #{`value`} within component: #{`component_name`}")}
|
72
|
-
console.error( + key + " event handler:", value, " within component:", self.active_component());
|
73
|
-
}
|
74
|
-
} else if (key[0] === 'a' && key.startsWith("aria_")) {
|
75
|
-
result[key.replace("_", "-")] = value;
|
76
|
-
} else if (key === "style" || key === "theme") {
|
77
|
-
if (typeof value.$to_n === "function") { value = value.$to_n() }
|
78
|
-
result[key] = value;
|
79
|
-
} else {
|
80
|
-
result[self.lower_camelize(key)] = value;
|
81
|
-
}
|
82
|
-
}
|
83
|
-
return result;
|
84
|
-
};
|
85
|
-
|
86
|
-
self.render_block_result = function(block_result, component) {
|
87
|
-
if (block_result.constructor === String || block_result.constructor === Number) {
|
88
|
-
if (component && component === Opal.global.Text) {
|
89
|
-
self.render_buffer[self.render_buffer.length - 1].push(block_result);
|
90
|
-
} else {
|
91
|
-
self.render_buffer[self.render_buffer.length - 1].push(Opal.global.React.createElement(Opal.global.Text, {}, block_result));
|
92
|
-
}
|
93
|
-
}
|
94
|
-
};
|
95
|
-
|
96
|
-
self.internal_render = function(component, props, string_child, block) {
|
97
|
-
const operabu = self.render_buffer;
|
98
|
-
let native_props;
|
99
|
-
if (props && props !== nil) { native_props = self.to_native_react_props(props); }
|
100
|
-
if (string_child) {
|
101
|
-
if (component && component === Opal.global.Text) {
|
102
|
-
operabu[operabu.length - 1].push(Opal.global.React.createElement(component, native_props, string_child));
|
103
|
-
} else {
|
104
|
-
let child = [Opal.global.React.createElement(Opal.global.Text, {}, string_child)];
|
105
|
-
operabu[operabu.length - 1].push(Opal.global.React.createElement(component, native_props, child));
|
106
|
-
}
|
107
|
-
} else if (block && block !== nil) {
|
108
|
-
operabu.push([]);
|
109
|
-
// console.log("internal_render pushed", Opal.React.render_buffer, Opal.React.render_buffer.toString());
|
110
|
-
let block_result = block.$call();
|
111
|
-
if (block_result && block_result !== nil) { Opal.React.render_block_result(block_result, component); }
|
112
|
-
// console.log("internal_render popping", Opal.React.render_buffer, Opal.React.render_buffer.toString());
|
113
|
-
let children = operabu.pop();
|
114
|
-
operabu[operabu.length - 1].push(Opal.global.React.createElement.apply(this, [component, native_props].concat(children)));
|
115
|
-
} else {
|
116
|
-
operabu[operabu.length - 1].push(Opal.global.React.createElement(component, native_props));
|
117
|
-
}
|
118
|
-
};
|
119
|
-
}
|
120
|
-
end
|
1
|
+
module React
|
2
|
+
%x{
|
3
|
+
self.prop_dictionary = {
|
4
|
+
on_click: 'onPress',
|
5
|
+
onClick: 'onPress',
|
6
|
+
on_touch: 'onPress',
|
7
|
+
onTouch: 'onPress',
|
8
|
+
on_change: 'onChangeText',
|
9
|
+
onChange: 'onChangeText',
|
10
|
+
on_blur: 'onSubmitText',
|
11
|
+
onBlur: 'onSubmitText',
|
12
|
+
};
|
13
|
+
|
14
|
+
self.to_native_react_props = function(ruby_style_props) {
|
15
|
+
let result = {};
|
16
|
+
let keys = ruby_style_props.$$keys;
|
17
|
+
let keys_length = keys.length;
|
18
|
+
let key = '';
|
19
|
+
for (let i = 0; i < keys_length; i++) {
|
20
|
+
key = keys[i];
|
21
|
+
let value = ruby_style_props.$$smap[key];
|
22
|
+
if (key[0] === 'o' && key[1] === 'n' && key[2] === '_') {
|
23
|
+
let type = typeof value;
|
24
|
+
if (type === "function") {
|
25
|
+
let active_c = self.active_component();
|
26
|
+
result[self.lower_camelize(key)] = function(event, info) {
|
27
|
+
let ruby_event = self.native_to_ruby_event(event);
|
28
|
+
#{`active_c.__ruby_instance`.instance_exec(`ruby_event`, `info`, &`value`)};
|
29
|
+
}
|
30
|
+
} else if (type === "object" && typeof value.$call === "function" ) {
|
31
|
+
if (!value.react_event_handler_function) {
|
32
|
+
value.react_event_handler_function = function(event, info) {
|
33
|
+
let ruby_event = self.native_to_ruby_event(event);
|
34
|
+
value.$call(ruby_event, info)
|
35
|
+
};
|
36
|
+
}
|
37
|
+
result[self.lower_camelize(key)] = value.react_event_handler_function;
|
38
|
+
} else if (type === "string" ) {
|
39
|
+
let active_component = self.active_component();
|
40
|
+
let method_ref;
|
41
|
+
let method_name = '$' + value;
|
42
|
+
if (typeof active_component[method_name] === "function") {
|
43
|
+
// got a ruby instance
|
44
|
+
if (active_component.native && active_component.native.method_refs && active_component.native.method_refs[value]) { method_ref = active_component.native.method_refs[value]; } // ruby instance with native
|
45
|
+
else if (active_component.method_refs && active_component.method_refs[value]) { method_ref = active_component.method_refs[value]; } // ruby function component
|
46
|
+
else { method_ref = active_component.$method_ref(value); } // create the ref
|
47
|
+
} else if (typeof active_component.__ruby_instance[method_name] === "function") {
|
48
|
+
// got a native instance
|
49
|
+
if (active_component.method_refs && active_component.method_refs[value]) { method_ref = active_component.method_refs[value]; }
|
50
|
+
else { method_ref = active_component.__ruby_instance.$method_ref(value); } // create ref for native
|
51
|
+
}
|
52
|
+
if (method_ref) {
|
53
|
+
if (!method_ref.react_event_handler_function) {
|
54
|
+
method_ref.react_event_handler_function = function(event, info) {
|
55
|
+
let ruby_event = self.native_to_ruby_event(event);
|
56
|
+
method_ref.$call(ruby_event, info)
|
57
|
+
};
|
58
|
+
}
|
59
|
+
result[self.lower_camelize(key)] = method_ref.react_event_handler_function;
|
60
|
+
} else {
|
61
|
+
let component_name;
|
62
|
+
if (active_component.__ruby_instance) { component_name = active_component.__ruby_instance.$to_s(); }
|
63
|
+
else { component_name = active_component.$to_s(); }
|
64
|
+
#{Isomorfeus.raise_error(message: "Is #{`value`} a valid method of #{`component_name`}? If so then please use: #{`key`}: method_ref(:#{`value`}) within component: #{`component_name`}")}
|
65
|
+
}
|
66
|
+
} else {
|
67
|
+
let active_component = self.active_component();
|
68
|
+
let component_name;
|
69
|
+
if (active_component.__ruby_instance) { component_name = active_component.__ruby_instance.$to_s(); }
|
70
|
+
else { component_name = active_component.$to_s(); }
|
71
|
+
#{Isomorfeus.raise_error(message: "Received invalid value for #{`key`} with #{`value`} within component: #{`component_name`}")}
|
72
|
+
console.error( + key + " event handler:", value, " within component:", self.active_component());
|
73
|
+
}
|
74
|
+
} else if (key[0] === 'a' && key.startsWith("aria_")) {
|
75
|
+
result[key.replace("_", "-")] = value;
|
76
|
+
} else if (key === "style" || key === "theme") {
|
77
|
+
if (typeof value.$to_n === "function") { value = value.$to_n() }
|
78
|
+
result[key] = value;
|
79
|
+
} else {
|
80
|
+
result[self.lower_camelize(key)] = value;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
return result;
|
84
|
+
};
|
85
|
+
|
86
|
+
self.render_block_result = function(block_result, component) {
|
87
|
+
if (block_result.constructor === String || block_result.constructor === Number) {
|
88
|
+
if (component && component === Opal.global.Text) {
|
89
|
+
self.render_buffer[self.render_buffer.length - 1].push(block_result);
|
90
|
+
} else {
|
91
|
+
self.render_buffer[self.render_buffer.length - 1].push(Opal.global.React.createElement(Opal.global.Text, {}, block_result));
|
92
|
+
}
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
96
|
+
self.internal_render = function(component, props, string_child, block) {
|
97
|
+
const operabu = self.render_buffer;
|
98
|
+
let native_props;
|
99
|
+
if (props && props !== nil) { native_props = self.to_native_react_props(props); }
|
100
|
+
if (string_child) {
|
101
|
+
if (component && component === Opal.global.Text) {
|
102
|
+
operabu[operabu.length - 1].push(Opal.global.React.createElement(component, native_props, string_child));
|
103
|
+
} else {
|
104
|
+
let child = [Opal.global.React.createElement(Opal.global.Text, {}, string_child)];
|
105
|
+
operabu[operabu.length - 1].push(Opal.global.React.createElement(component, native_props, child));
|
106
|
+
}
|
107
|
+
} else if (block && block !== nil) {
|
108
|
+
operabu.push([]);
|
109
|
+
// console.log("internal_render pushed", Opal.React.render_buffer, Opal.React.render_buffer.toString());
|
110
|
+
let block_result = block.$call();
|
111
|
+
if (block_result && block_result !== nil) { Opal.React.render_block_result(block_result, component); }
|
112
|
+
// console.log("internal_render popping", Opal.React.render_buffer, Opal.React.render_buffer.toString());
|
113
|
+
let children = operabu.pop();
|
114
|
+
operabu[operabu.length - 1].push(Opal.global.React.createElement.apply(this, [component, native_props].concat(children)));
|
115
|
+
} else {
|
116
|
+
operabu[operabu.length - 1].push(Opal.global.React.createElement(component, native_props));
|
117
|
+
}
|
118
|
+
};
|
119
|
+
}
|
120
|
+
end
|
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.13.
|
4
|
+
version: 16.13.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.1.
|
19
|
+
version: 1.1.9
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.1.
|
26
|
+
version: 1.1.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: oj
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.
|
33
|
+
version: 3.12.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.
|
40
|
+
version: 3.12.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: opal
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.11.4
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.11.4
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: isomorfeus-redux
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,28 +128,28 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.7.
|
131
|
+
version: 2.7.11
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 2.7.
|
138
|
+
version: 2.7.11
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: redis
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 4.
|
145
|
+
version: 4.4.0
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 4.
|
152
|
+
version: 4.4.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: zeitwerk
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.4.
|
173
|
+
version: 0.4.1
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.4.
|
180
|
+
version: 0.4.1
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: rake
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -316,7 +316,12 @@ licenses:
|
|
316
316
|
- MIT
|
317
317
|
metadata:
|
318
318
|
github_repo: ssh://github.com/isomorfeus/gems
|
319
|
-
post_install_message:
|
319
|
+
post_install_message: |2+
|
320
|
+
|
321
|
+
isomorfeus-react 16.13.12:
|
322
|
+
|
323
|
+
Isomorfeus-react is obsolete, superseded by isomorfeus-preact https://github.com/isomorfeus/isomorfeus-preact
|
324
|
+
|
320
325
|
rdoc_options: []
|
321
326
|
require_paths:
|
322
327
|
- lib
|
@@ -331,8 +336,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
331
336
|
- !ruby/object:Gem::Version
|
332
337
|
version: '0'
|
333
338
|
requirements: []
|
334
|
-
rubygems_version: 3.
|
339
|
+
rubygems_version: 3.3.7
|
335
340
|
signing_key:
|
336
341
|
specification_version: 4
|
337
|
-
summary:
|
342
|
+
summary: Isomorfeus-react is obsolete, superseded by isomorfeus-preact https://github.com/isomorfeus/isomorfeus-preact
|
338
343
|
test_files: []
|
344
|
+
...
|