isomorfeus-preact 10.6.54 → 10.6.57

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a15d9cadd4a78dd05440af2a93cc177a35d493e74e6ebd8e41910f3935791b9b
4
- data.tar.gz: 784cee9416986e08bb1109e5b68538a11e47442fd1fc2e0f5f4afd72486d5337
3
+ metadata.gz: c5031b455f87fd1d741f943fe39a1f839980f46751fc9b895c722f343a3800e1
4
+ data.tar.gz: 0dcfb17fa803756400b1c745d15c993cfa2a4661df4c2e5247a25f6d3392df85
5
5
  SHA512:
6
- metadata.gz: 3d879ecbaa46a298165dafe83a4569916ee0f9baa2df35b34496339e64af2a1e4a17dad47e5481c5d3772688cdb50fc5685571888ba8055e926e9a929fccd697
7
- data.tar.gz: ea345e3bb4f1313213c46fdd9c0f7733db3d9d89bfbc42d33d7b93a56b6a144bee6d0b3281233eb949e60ab75aba02d74b85bd12af95494053533a7f4a80dc07
6
+ metadata.gz: 5afe1ad79cc07dab287a5b4ea66b7770a9073a6d7026b817b27bd017d06c305616fb8f82d0f7c71e1de7b42d55f79f76653de76c7fab1bfb00c5a533a1f72fea
7
+ data.tar.gz: fd00f32642afdc4737b9ae27cb5e586ad70b3421c2dfd11219551394ec6c54be97a44d82a3b2c0163622e941180afb593c9e3d95f10b0aef25ab60a56e680c35
@@ -9,6 +9,6 @@ module LucidApp::Mixin
9
9
  base.include(::LucidComponent::Api)
10
10
  base.include(::LucidApp::Api)
11
11
  base.include(::LucidComponent::Initializer)
12
- base.include(::LucidI18n::Mixin) if `("lucid_i18n/mixin" in Opal.modules)`
12
+ base.include(::LucidI18n::Mixin) if `(Opal.modules.hasOwnProperty("lucid_i18n/mixin"))`
13
13
  end
14
14
  end
@@ -27,7 +27,7 @@ module LucidComponent::Api
27
27
  if @_preload_promise && @_preload_promise.resolved?
28
28
  instance_exec(&`base.render_block`)
29
29
  else
30
- instance_exec(&block)
30
+ instance_exec(@_preload_promise, &block)
31
31
  end
32
32
  end
33
33
  `base.while_loading_block = wl_block`
@@ -8,6 +8,6 @@ module LucidComponent::Mixin
8
8
  base.include(::Preact::Component::Callbacks)
9
9
  base.include(::LucidComponent::Api)
10
10
  base.include(::LucidComponent::Initializer)
11
- base.include(::LucidI18n::Mixin) if `("lucid_i18n/mixin" in Opal.modules)`
11
+ base.include(::LucidI18n::Mixin) if `(Opal.modules.hasOwnProperty("lucid_i18n/mixin"))`
12
12
  end
13
13
  end
@@ -5,6 +5,6 @@ module LucidFunc::Mixin
5
5
  base.extend(::LucidFunc::NativeComponentConstructor)
6
6
  base.include(::Preact::Elements)
7
7
  base.include(::LucidComponent::Api)
8
- base.include(::LucidI18n::Mixin) if `("lucid_i18n/mixin" in Opal.modules)`
8
+ base.include(::LucidI18n::Mixin) if `(Opal.modules.hasOwnProperty("lucid_i18n/mixin"))`
9
9
  end
10
10
  end
@@ -1,4 +1,12 @@
1
1
  module Preact::FunctionComponent::Api
2
+ def self.included(base)
3
+ base.instance_exec do
4
+ def to_js
5
+ self.JS[:preact_component]
6
+ end
7
+ end
8
+ end
9
+
2
10
  def props
3
11
  @native_props
4
12
  end
@@ -112,7 +120,15 @@ module Preact::FunctionComponent::Api
112
120
  %x{
113
121
  if (#{self}.method_refs?.[#{method_key}]) { return #{self}.method_refs[#{method_key}]; }
114
122
  if (!#{self}.method_refs) { #{self}.method_refs = {}; }
115
- #{self}.method_refs[#{method_key}] = { m: #{method(method_symbol)}, a: args };
123
+ #{self}.method_refs[#{method_key}] = { m: null, a: args };
124
+ let r = #{self}.method_refs[#{method_key}];
125
+ let dev = #{Isomorfeus.development?};
126
+ r.preact_event_handler_function = function(event, info) {
127
+ let ruby_event = Opal.Preact.native_to_ruby_event(event);
128
+ if (!r.m || dev) { r.m = #{method(method_symbol)} };
129
+ if (r.a.length > 0) { r.m.$call.apply(r.m, [ruby_event, info].concat(r.a)); }
130
+ else { r.m.$call(ruby_event, info); }
131
+ };
116
132
  return #{self}.method_refs[#{method_key}];
117
133
  }
118
134
  end
@@ -49,6 +49,10 @@ module Preact::Component::Api
49
49
  def should_component_update?(&block)
50
50
  `base.should_component_update_block = block`
51
51
  end
52
+
53
+ def to_js
54
+ self.JS[:preact_component]
55
+ end
52
56
  end
53
57
  end
54
58
 
@@ -96,7 +100,15 @@ module Preact::Component::Api
96
100
  %x{
97
101
  if (#@native.method_refs?.[#{method_key}]) { return #@native.method_refs[#{method_key}]; }
98
102
  if (!#@native.method_refs) { #@native.method_refs = {}; }
99
- #@native.method_refs[#{method_key}] = { m: #{method(method_symbol)}, a: args };
103
+ #@native.method_refs[#{method_key}] = { m: null, a: args };
104
+ let r = #@native.method_refs[#{method_key}];
105
+ let dev = #{Isomorfeus.development?};
106
+ r.preact_event_handler_function = function(event, info) {
107
+ let ruby_event = Opal.Preact.native_to_ruby_event(event);
108
+ if (!r.m || dev) { r.m = #{method(method_symbol)} };
109
+ if (r.a.length > 0) { r.m.$call.apply(r.m, [ruby_event, info].concat(r.a)); }
110
+ else { r.m.$call(ruby_event, info); }
111
+ };
100
112
  return #@native.method_refs[#{method_key}];
101
113
  }
102
114
  end
@@ -1,3 +1,3 @@
1
1
  module Preact
2
- VERSION = '10.6.54'
2
+ VERSION = '10.6.57'
3
3
  end
data/lib/preact.rb CHANGED
@@ -130,14 +130,7 @@ module Preact
130
130
  let ruby_event = self.native_to_ruby_event(event);
131
131
  #{`active_c.__ruby_instance`.instance_exec(`ruby_event`, `info`, &`value`)};
132
132
  }
133
- } else if (type === "object" && typeof value.m === "object" && typeof value.m.$call === "function" ) {
134
- if (!value.preact_event_handler_function) {
135
- value.preact_event_handler_function = function(event, info) {
136
- let ruby_event = self.native_to_ruby_event(event);
137
- if (value.a.length > 0) { value.m.$call.apply(value.m, [ruby_event, info].concat(value.a)); }
138
- else { value.m.$call(ruby_event, info); }
139
- };
140
- }
133
+ } else if (typeof value.preact_event_handler_function === "function") {
141
134
  result[self.lower_camelize(key)] = value.preact_event_handler_function;
142
135
  } else if (type === "string" ) {
143
136
  let active_component = self.active_component();
@@ -154,12 +147,6 @@ module Preact
154
147
  else { method_ref = active_component.__ruby_instance.$method_ref(value); } // create ref for native
155
148
  }
156
149
  if (method_ref) {
157
- if (!method_ref.preact_event_handler_function) {
158
- method_ref.preact_event_handler_function = function(event, info) {
159
- let ruby_event = self.native_to_ruby_event(event);
160
- method_ref.m.$call(ruby_event, info)
161
- };
162
- }
163
150
  result[self.lower_camelize(key)] = method_ref.preact_event_handler_function;
164
151
  } else {
165
152
  let component_name;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-preact
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.6.54
4
+ version: 10.6.57
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-25 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby