isomorfeus-preact 10.6.29 → 10.6.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/isomorfeus/preact_view_helper.rb +9 -7
- data/lib/isomorfeus-preact.rb +15 -0
- data/lib/isomorfeus_preact/lucid_app/api.rb +30 -32
- data/lib/isomorfeus_preact/lucid_app/mixin.rb +12 -13
- data/lib/isomorfeus_preact/lucid_app/native_component_constructor.rb +86 -76
- data/lib/isomorfeus_preact/lucid_component/api.rb +96 -98
- data/lib/isomorfeus_preact/lucid_component/initializer.rb +8 -10
- data/lib/isomorfeus_preact/lucid_component/mixin.rb +11 -12
- data/lib/isomorfeus_preact/lucid_component/native_component_constructor.rb +75 -70
- data/lib/isomorfeus_preact/lucid_func/initializer.rb +7 -9
- data/lib/isomorfeus_preact/lucid_func/mixin.rb +8 -9
- data/lib/isomorfeus_preact/lucid_func/native_component_constructor.rb +48 -45
- data/lib/isomorfeus_preact/preact/function_component/api.rb +102 -106
- data/lib/isomorfeus_preact/preact/function_component/base.rb +5 -7
- data/lib/isomorfeus_preact/preact/function_component/initializer.rb +4 -8
- data/lib/isomorfeus_preact/preact/function_component/mixin.rb +6 -10
- data/lib/isomorfeus_preact/preact/function_component/native_component_constructor.rb +41 -40
- data/lib/preact/component/api.rb +99 -103
- data/lib/preact/component/base.rb +5 -7
- data/lib/preact/component/callbacks.rb +99 -90
- data/lib/preact/component/initializer.rb +5 -9
- data/lib/preact/component/mixin.rb +9 -13
- data/lib/preact/component/native_component_constructor.rb +69 -62
- data/lib/preact/component_resolution.rb +78 -80
- data/lib/preact/context_wrapper.rb +5 -3
- data/lib/preact/elements.rb +55 -57
- data/lib/preact/version.rb +1 -1
- data/lib/preact.rb +2 -0
- metadata +14 -13
@@ -1,46 +1,47 @@
|
|
1
|
-
module Preact
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
return (result.length === 1) ? result[0] : result;
|
25
|
-
}
|
26
|
-
base.preact_component.displayName = #{component_name};
|
1
|
+
module Preact::FunctionComponent::NativeComponentConstructor
|
2
|
+
def self.extended(base)
|
3
|
+
component_name = base.to_s
|
4
|
+
%x{
|
5
|
+
base.instance_init = function(initial) {
|
6
|
+
let ruby_state = { instance: #{base.new(`{}`)} };
|
7
|
+
ruby_state.instance.__ruby_instance = ruby_state.instance;
|
8
|
+
return ruby_state;
|
9
|
+
}
|
10
|
+
base.instance_reducer = function(state, action) { return state; }
|
11
|
+
base.preact_component = function(props) {
|
12
|
+
const oper = Opal.Preact;
|
13
|
+
oper.render_buffer.push([]);
|
14
|
+
const [__ruby_state, __ruby_dispatch] = Opal.global.PreactHooks.useReducer(base.instance_reducer, null, base.instance_init);
|
15
|
+
const __ruby_instance = __ruby_state.instance;
|
16
|
+
__ruby_instance.props = props;
|
17
|
+
oper.register_active_component(__ruby_instance);
|
18
|
+
try {
|
19
|
+
let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
|
20
|
+
if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
|
21
|
+
} catch (e) {
|
22
|
+
if (oper.using_did_catch) { throw e; }
|
23
|
+
else { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
|
27
24
|
}
|
25
|
+
oper.unregister_active_component(__ruby_instance);
|
26
|
+
let result = oper.render_buffer.pop();
|
27
|
+
return (result.length === 1) ? result[0] : result;
|
28
|
+
}
|
29
|
+
base.preact_component.displayName = #{component_name};
|
30
|
+
}
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def render(&block)
|
41
|
-
`base.render_block = #{block}`
|
42
|
-
end
|
32
|
+
base_module = base.to_s.deconstantize
|
33
|
+
if base_module != ''
|
34
|
+
base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
|
35
|
+
`Opal.Preact.internal_prepare_args_and_render(#{base}.preact_component, args, block)`
|
36
|
+
end
|
37
|
+
else
|
38
|
+
Object.define_method(base.to_s) do |*args, &block|
|
39
|
+
`Opal.Preact.internal_prepare_args_and_render(#{base}.preact_component, args, block)`
|
43
40
|
end
|
44
41
|
end
|
42
|
+
|
43
|
+
def render(&block)
|
44
|
+
`base.render_block = #{block}`
|
45
|
+
end
|
45
46
|
end
|
46
47
|
end
|
data/lib/preact/component/api.rb
CHANGED
@@ -1,124 +1,120 @@
|
|
1
|
-
module Preact
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Object.define_method(base.to_s) do |*args, &block|
|
13
|
-
`Opal.Preact.internal_prepare_args_and_render(#{base}.preact_component, args, block)`
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_accessor :props
|
18
|
-
attr_accessor :state
|
19
|
-
|
20
|
-
def ref(ref_name, &block)
|
21
|
-
defined_refs.JS[ref_name] = block_given? ? block : `null`
|
22
|
-
end
|
23
|
-
|
24
|
-
def defined_refs
|
25
|
-
@defined_refs ||= `{}`
|
26
|
-
end
|
27
|
-
|
28
|
-
def default_state_defined
|
29
|
-
@default_state_defined
|
30
|
-
end
|
31
|
-
|
32
|
-
def state
|
33
|
-
return @default_state if @default_state
|
34
|
-
@default_state_defined = true
|
35
|
-
%x{
|
36
|
-
var native_state = {state: {}};
|
37
|
-
native_state.setState = function(new_state, callback) {
|
38
|
-
for (var key in new_state) {
|
39
|
-
this.state[key] = new_state[key];
|
40
|
-
}
|
41
|
-
if (callback) { callback.call(); }
|
42
|
-
}
|
43
|
-
}
|
44
|
-
@default_state = `Opal.Preact.State.$new(native_state)`
|
45
|
-
end
|
46
|
-
|
47
|
-
def render(&block)
|
48
|
-
`base.render_block = #{block}`
|
49
|
-
end
|
50
|
-
|
51
|
-
def should_component_update?(&block)
|
52
|
-
`base.should_component_update_block = block`
|
53
|
-
end
|
1
|
+
module Preact::Component::Api
|
2
|
+
def self.included(base)
|
3
|
+
base.instance_exec do
|
4
|
+
base_module = base.to_s.deconstantize
|
5
|
+
if base_module != ''
|
6
|
+
base_module.constantize.define_singleton_method(base.to_s.demodulize) do |*args, &block|
|
7
|
+
`Opal.Preact.internal_prepare_args_and_render(#{base}.preact_component, args, block)`
|
8
|
+
end
|
9
|
+
else
|
10
|
+
Object.define_method(base.to_s) do |*args, &block|
|
11
|
+
`Opal.Preact.internal_prepare_args_and_render(#{base}.preact_component, args, block)`
|
54
12
|
end
|
55
13
|
end
|
56
14
|
|
57
|
-
|
58
|
-
|
15
|
+
attr_accessor :props
|
16
|
+
attr_accessor :state
|
17
|
+
|
18
|
+
def ref(ref_name, &block)
|
19
|
+
defined_refs.JS[ref_name] = block_given? ? block : `null`
|
59
20
|
end
|
60
21
|
|
61
|
-
def
|
62
|
-
|
63
|
-
# this maybe needs instance_exec too
|
64
|
-
@native.JS.forceUpdate(`function() { block.$call(); }`)
|
65
|
-
else
|
66
|
-
@native.JS.forceUpdate
|
67
|
-
end
|
22
|
+
def defined_refs
|
23
|
+
@defined_refs ||= `{}`
|
68
24
|
end
|
69
25
|
|
70
|
-
def
|
71
|
-
|
72
|
-
# execute block, fetch last element from buffer
|
73
|
-
%x{
|
74
|
-
let last_buffer_length = Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1].length;
|
75
|
-
let last_buffer_element = Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1][last_buffer_length - 1];
|
76
|
-
block.$call();
|
77
|
-
// console.log("get_preact_element popping", Opal.Preact.render_buffer, Opal.Preact.render_buffer.toString())
|
78
|
-
let new_element = Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1].pop();
|
79
|
-
if (last_buffer_element === new_element) { #{Isomorfeus.raise_error(message: "Block did not create any Preact element!")} }
|
80
|
-
return new_element;
|
81
|
-
}
|
82
|
-
else
|
83
|
-
# element was rendered before being passed as arg
|
84
|
-
# fetch last element from buffer
|
85
|
-
# `console.log("get_preact_element popping", Opal.Preact.render_buffer, Opal.Preact.render_buffer.toString())`
|
86
|
-
`Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1].pop()`
|
87
|
-
end
|
26
|
+
def default_state_defined
|
27
|
+
@default_state_defined
|
88
28
|
end
|
89
|
-
alias gpe get_preact_element
|
90
29
|
|
91
|
-
def
|
92
|
-
|
30
|
+
def state
|
31
|
+
return @default_state if @default_state
|
32
|
+
@default_state_defined = true
|
93
33
|
%x{
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
34
|
+
var native_state = {state: {}};
|
35
|
+
native_state.setState = function(new_state, callback) {
|
36
|
+
for (var key in new_state) {
|
37
|
+
this.state[key] = new_state[key];
|
38
|
+
}
|
39
|
+
if (callback) { callback.call(); }
|
40
|
+
}
|
98
41
|
}
|
42
|
+
@default_state = `Opal.Preact.State.$new(native_state)`
|
99
43
|
end
|
100
|
-
alias m_ref method_ref
|
101
44
|
|
102
|
-
def
|
103
|
-
|
104
|
-
`Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1].push(el)`
|
105
|
-
# `console.log("render_preact_element pushed", Opal.Preact.render_buffer, Opal.Preact.render_buffer.toString())`
|
106
|
-
nil
|
45
|
+
def render(&block)
|
46
|
+
`base.render_block = #{block}`
|
107
47
|
end
|
108
|
-
alias rpe render_preact_element
|
109
48
|
|
110
|
-
def
|
111
|
-
|
49
|
+
def should_component_update?(&block)
|
50
|
+
`base.should_component_update_block = block`
|
112
51
|
end
|
52
|
+
end
|
53
|
+
end
|
113
54
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
55
|
+
def display_name
|
56
|
+
@native.JS[:displayName]
|
57
|
+
end
|
118
58
|
|
119
|
-
|
120
|
-
|
121
|
-
|
59
|
+
def force_update(&block)
|
60
|
+
if block_given?
|
61
|
+
# this maybe needs instance_exec too
|
62
|
+
@native.JS.forceUpdate(`function() { block.$call(); }`)
|
63
|
+
else
|
64
|
+
@native.JS.forceUpdate
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_preact_element(arg, &block)
|
69
|
+
if block_given?
|
70
|
+
# execute block, fetch last element from buffer
|
71
|
+
%x{
|
72
|
+
let last_buffer_length = Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1].length;
|
73
|
+
let last_buffer_element = Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1][last_buffer_length - 1];
|
74
|
+
block.$call();
|
75
|
+
// console.log("get_preact_element popping", Opal.Preact.render_buffer, Opal.Preact.render_buffer.toString())
|
76
|
+
let new_element = Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1].pop();
|
77
|
+
if (last_buffer_element === new_element) { #{Isomorfeus.raise_error(message: "Block did not create any Preact element!")} }
|
78
|
+
return new_element;
|
79
|
+
}
|
80
|
+
else
|
81
|
+
# element was rendered before being passed as arg
|
82
|
+
# fetch last element from buffer
|
83
|
+
# `console.log("get_preact_element popping", Opal.Preact.render_buffer, Opal.Preact.render_buffer.toString())`
|
84
|
+
`Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1].pop()`
|
122
85
|
end
|
123
86
|
end
|
87
|
+
alias gpe get_preact_element
|
88
|
+
|
89
|
+
def method_ref(method_symbol, *args)
|
90
|
+
method_key = "#{method_symbol}#{args}"
|
91
|
+
%x{
|
92
|
+
if (#@native.method_refs && #@native.method_refs[#{method_key}]) { return #@native.method_refs[#{method_key}]; }
|
93
|
+
if (!#@native.method_refs) { #@native.method_refs = {}; }
|
94
|
+
#@native.method_refs[#{method_key}] = { m: #{method(method_symbol)}, a: args };
|
95
|
+
return #@native.method_refs[#{method_key}];
|
96
|
+
}
|
97
|
+
end
|
98
|
+
alias m_ref method_ref
|
99
|
+
|
100
|
+
def render_preact_element(el)
|
101
|
+
# push el to buffer
|
102
|
+
`Opal.Preact.render_buffer[Opal.Preact.render_buffer.length - 1].push(el)`
|
103
|
+
# `console.log("render_preact_element pushed", Opal.Preact.render_buffer, Opal.Preact.render_buffer.toString())`
|
104
|
+
nil
|
105
|
+
end
|
106
|
+
alias rpe render_preact_element
|
107
|
+
|
108
|
+
def ref(name)
|
109
|
+
`#@native[name]`
|
110
|
+
end
|
111
|
+
|
112
|
+
def ruby_ref(name)
|
113
|
+
return `#@native[name]` if `(typeof #@native[name] === 'function')`
|
114
|
+
`Opal.Preact.Ref.$new(#@native[name])`
|
115
|
+
end
|
116
|
+
|
117
|
+
def set_state(updater, &callback)
|
118
|
+
@state.set_state(updater, &callback)
|
119
|
+
end
|
124
120
|
end
|
@@ -1,9 +1,7 @@
|
|
1
|
-
module Preact
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
base.include(::Preact::Component::Mixin)
|
6
|
-
end
|
1
|
+
module Preact::Component
|
2
|
+
class Base
|
3
|
+
def self.inherited(base)
|
4
|
+
base.include(::Preact::Component::Mixin)
|
7
5
|
end
|
8
6
|
end
|
9
|
-
end
|
7
|
+
end
|
@@ -1,101 +1,110 @@
|
|
1
|
-
module Preact
|
2
|
-
|
3
|
-
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
module Preact::Component::Callbacks
|
2
|
+
def self.included(base)
|
3
|
+
base.instance_exec do
|
4
|
+
def component_did_catch(&block)
|
5
|
+
# TODO convert error
|
6
|
+
%x{
|
7
|
+
var fun = function(error) {
|
8
|
+
Opal.Preact.register_active_component(this);
|
9
|
+
try {
|
10
|
+
#{`this.__ruby_instance`.instance_exec(`error`, &block)};
|
11
|
+
} catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
|
12
|
+
Opal.Preact.unregister_active_component(this);
|
13
|
+
}
|
14
|
+
if (self.lucid_preact_component) { self.lucid_preact_component.prototype.componentDidCatch = fun; }
|
15
|
+
else { self.preact_component.prototype.componentDidCatch = fun; }
|
16
|
+
Opal.Preact.using_did_catch = true;
|
17
|
+
}
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
def component_did_mount(&block)
|
21
|
+
%x{
|
22
|
+
let fun = function() {
|
23
|
+
Opal.Preact.register_active_component(this);
|
24
|
+
try {
|
25
|
+
#{`this.__ruby_instance`.instance_exec(&block)};
|
26
|
+
} catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
|
27
|
+
Opal.Preact.unregister_active_component(this);
|
28
|
+
}
|
29
|
+
if (self.lucid_preact_component) {
|
30
|
+
if (self.lucid_preact_component.prototype.componentDidMount) {
|
31
|
+
let fun_one = self.lucid_preact_component.prototype.componentDidMount;
|
32
|
+
let fun_two = fun;
|
33
|
+
fun = function() {
|
34
|
+
fun_one();
|
35
|
+
fun_two();
|
25
36
|
}
|
26
|
-
if (self.lucid_preact_component) {
|
27
|
-
if (self.lucid_preact_component.prototype.componentDidMount) {
|
28
|
-
let fun_one = self.lucid_preact_component.prototype.componentDidMount;
|
29
|
-
let fun_two = fun;
|
30
|
-
fun = function() {
|
31
|
-
fun_one();
|
32
|
-
fun_two();
|
33
|
-
}
|
34
|
-
}
|
35
|
-
self.lucid_preact_component.prototype.componentDidMount = fun;
|
36
|
-
} else { self.preact_component.prototype.componentDidMount = fun; }
|
37
37
|
}
|
38
|
-
|
38
|
+
self.lucid_preact_component.prototype.componentDidMount = fun;
|
39
|
+
} else { self.preact_component.prototype.componentDidMount = fun; }
|
40
|
+
}
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
43
|
+
def component_did_update(&block)
|
44
|
+
%x{
|
45
|
+
var fun = function(prev_props, prev_state, snapshot) {
|
46
|
+
Opal.Preact.register_active_component(this);
|
47
|
+
try {
|
48
|
+
#{`this.__ruby_instance`.instance_exec(`Opal.Preact.Props.$new({props: prev_props})`,
|
49
|
+
`Opal.Preact.State.$new({state: prev_state})`,
|
50
|
+
`snapshot`, &block)};
|
51
|
+
} catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
|
52
|
+
Opal.Preact.unregister_active_component(this);
|
53
|
+
}
|
54
|
+
if (self.lucid_preact_component) { self.lucid_preact_component.prototype.componentDidUpdate = fun; }
|
55
|
+
else { self.preact_component.prototype.componentDidUpdate = fun; }
|
56
|
+
}
|
57
|
+
end
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
def component_will_unmount(&block)
|
60
|
+
%x{
|
61
|
+
var fun = function() {
|
62
|
+
if (typeof this.unsubscriber === "function") { this.unsubscriber(); };
|
63
|
+
Opal.Preact.register_active_component(this);
|
64
|
+
try {
|
65
|
+
#{`this.__ruby_instance`.instance_exec(&block)};
|
66
|
+
} catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
|
67
|
+
Opal.Preact.unregister_active_component(this);
|
68
|
+
}
|
69
|
+
if (self.lucid_preact_component) { self.lucid_preact_component.prototype.componentWillUnmount = fun; }
|
70
|
+
else { self.preact_component.prototype.componentWillUnmount = fun; }
|
71
|
+
}
|
72
|
+
end
|
66
73
|
|
67
74
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
75
|
+
def get_derived_state_from_props(&block)
|
76
|
+
%x{
|
77
|
+
var fun = function(props, state) {
|
78
|
+
Opal.Preact.register_active_component(this);
|
79
|
+
try {
|
80
|
+
var result = #{`this.__ruby_instance`.instance_exec(`Opal.Preact.Props.$new({props: props})`,
|
81
|
+
`Opal.Preact.State.$new({state: state})`, &block)};
|
82
|
+
} catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
|
83
|
+
Opal.Preact.unregister_active_component(this);
|
84
|
+
if (typeof result.$to_n === 'function') { result = result.$to_n() }
|
85
|
+
if (result === nil) { return null; }
|
86
|
+
return result;
|
87
|
+
}
|
88
|
+
if (self.lucid_preact_component) { self.lucid_preact_component.prototype.getDerivedStateFromProps = fun; }
|
89
|
+
else { self.preact_component.prototype.getDerivedStateFromProps = fun; }
|
90
|
+
}
|
91
|
+
end
|
83
92
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
93
|
+
def get_snapshot_before_update(&block)
|
94
|
+
%x{
|
95
|
+
var fun = function(prev_props, prev_state) {
|
96
|
+
Opal.Preact.register_active_component(this);
|
97
|
+
try {
|
98
|
+
var result = #{`this.__ruby_instance`.instance_exec(`Opal.Preact.Props.$new({props: prev_props})`,
|
99
|
+
`Opal.Preact.State.$new({state: prev_state})`, &block)};
|
100
|
+
} catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
|
101
|
+
Opal.Preact.unregister_active_component(this);
|
102
|
+
if (result === nil) { return null; }
|
103
|
+
return result;
|
104
|
+
}
|
105
|
+
if (self.lucid_preact_component) { self.lucid_preact_component.prototype.getSnapshotBeforeUpdate = fun; }
|
106
|
+
else { self.preact_component.prototype.getSnapshotBeforeUpdate = fun; }
|
107
|
+
}
|
99
108
|
end
|
100
109
|
end
|
101
110
|
end
|
@@ -1,11 +1,7 @@
|
|
1
|
-
module Preact
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
@props = `Opal.Preact.Props.$new(#@native)`
|
7
|
-
@state = `Opal.Preact.State.$new(#@native)`
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module Preact::Component::Initializer
|
2
|
+
def initialize(native_component)
|
3
|
+
@native = native_component
|
4
|
+
@props = `Opal.Preact.Props.$new(#@native)`
|
5
|
+
@state = `Opal.Preact.State.$new(#@native)`
|
10
6
|
end
|
11
7
|
end
|
@@ -1,15 +1,11 @@
|
|
1
|
-
module Preact
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
base.include(::Preact::Component::Callbacks)
|
11
|
-
base.include(::Preact::Component::Initializer)
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module Preact::Component::Mixin
|
2
|
+
def self.included(base)
|
3
|
+
base.include(::Native::Wrapper)
|
4
|
+
base.extend(::Preact::Component::NativeComponentConstructor)
|
5
|
+
base.extend(::LucidPropDeclaration::Mixin)
|
6
|
+
base.include(::Preact::Elements)
|
7
|
+
base.include(::Preact::Component::Api)
|
8
|
+
base.include(::Preact::Component::Callbacks)
|
9
|
+
base.include(::Preact::Component::Initializer)
|
14
10
|
end
|
15
11
|
end
|