isomorfeus-preact 10.6.29 → 10.6.30

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: 568b183142ceacc12014377fb018c981eb829354bbedefde4fbaa6afe8e3ffff
4
- data.tar.gz: c63fd0c3260e2a2050550b4ae41511c7843dff4a6114e014ede3808f2713d950
3
+ metadata.gz: 261bf828fca3276232e1cc9a57f32cb6bd45ddd0fa2d386c42dc799813a5f110
4
+ data.tar.gz: a18cdda3bbb233fd376f90c0cabda7637cd110a34697e2a2d7710e78249775db
5
5
  SHA512:
6
- metadata.gz: abbe6bfcd288626c53f2434a3334cf2b4af9fee57771632ac48ed10679c67b45ce027e4eb2a5c282398f250eaae9a8724dacd9bc1ef07fe1cb309f1376d2f45f
7
- data.tar.gz: 1acb14bef1c93928f8727c8841ef9c413ddea9e56a678e155ca04e40c1d3ade6edacfa89bb04c7770bfc61d2d9fe6d1f50a9b833db1f618bb70d695087684df0
6
+ metadata.gz: a76b3e58d5d4fd34409126b93487eb8f257509f6c9ff4697248c60333d51c416b1232bc78c4e72d694fbbab5b2392405cdda5aa40310f500e0a53e8d7e61e76b
7
+ data.tar.gz: ea99ad3ec25838e3c6c94d971e529fe92b7ba7597e685578fcd097a62a852e095faae7f10d18d7822d5880510350ac1997578818d4cde8ae9a45bd2ec9a8f971
@@ -37,7 +37,9 @@ module LucidApp
37
37
  this[ref] = function(element) {
38
38
  element = oper.native_element_or_component_to_ruby(element);
39
39
  oper.register_active_component(this);
40
- #{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
40
+ try {
41
+ #{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
42
+ } catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
41
43
  oper.unregister_active_component(this);
42
44
  }
43
45
  this[ref] = this[ref].bind(this);
@@ -47,7 +49,7 @@ module LucidApp
47
49
  }
48
50
  if (base.preload_block) {
49
51
  oper.register_active_component(this);
50
- this.state.preloaded = this.__ruby_instance.$execute_preload_block();
52
+ this.state.preloaded = this.__ruby_instance.$execute_preload_block(); // caught in execute_preload_block itself
51
53
  oper.unregister_active_component(this);
52
54
  }
53
55
  this.listener = this.listener.bind(this);
@@ -61,9 +63,14 @@ module LucidApp
61
63
  oper.render_buffer.push([]);
62
64
  oper.register_active_component(this);
63
65
  let block_result;
64
- if (base.while_loading_block && !state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
65
- else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
66
- if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
66
+ try {
67
+ if (base.while_loading_block && !state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
68
+ else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
69
+ if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
70
+ } catch (e) {
71
+ if (oper.using_did_catch) { throw e; }
72
+ else { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
73
+ }
67
74
  oper.unregister_active_component(this);
68
75
  let children = oper.render_buffer.pop();
69
76
  return Opal.global.Preact.createElement(Opal.global.LucidApplicationContext.Provider, { value: { iso_store: this.state.isomorfeus_store_state, iso_theme: base.css_theme }}, children);
@@ -78,6 +85,11 @@ module LucidApp
78
85
  componentWillUnmount() {
79
86
  if (typeof this.unsubscriber === "function") { this.unsubscriber(); }
80
87
  }
88
+ shouldComponentUpdate(next_props, next_state) {
89
+ if (!Opal.Preact.props_are_equal(this.props, next_props)) { return true; }
90
+ if (Opal.Preact.state_is_not_equal(this.state, next_state)) { return true; }
91
+ return false;
92
+ }
81
93
  validateProp(props, propName, componentName) {
82
94
  try { base.$validate_prop(propName, props[propName]) }
83
95
  catch (e) { return new Error(componentName + ": Error: prop validation failed: " + e.message); }
@@ -33,7 +33,9 @@ module LucidComponent
33
33
  this[ref] = function(element) {
34
34
  element = oper.native_element_or_component_to_ruby(element);
35
35
  oper.register_active_component(this);
36
- #{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
36
+ try {
37
+ #{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
38
+ } catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
37
39
  oper.unregister_active_component(this);
38
40
  }
39
41
  this[ref] = this[ref].bind(this);
@@ -43,7 +45,7 @@ module LucidComponent
43
45
  }
44
46
  if (base.preload_block) {
45
47
  oper.register_active_component(this);
46
- this.state.preloaded = this.__ruby_instance.$execute_preload_block();
48
+ this.state.preloaded = this.__ruby_instance.$execute_preload_block(); // caught in execute_preload_block itself
47
49
  oper.unregister_active_component(this);
48
50
  }
49
51
  }
@@ -55,9 +57,14 @@ module LucidComponent
55
57
  oper.render_buffer.push([]);
56
58
  oper.register_active_component(this);
57
59
  let block_result;
58
- if (base.while_loading_block && !state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
59
- else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
60
- if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
60
+ try {
61
+ if (base.while_loading_block && !state.preloaded) { block_result = #{`this.__ruby_instance`.instance_exec(&`base.while_loading_block`)}; }
62
+ else { block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)}; }
63
+ if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
64
+ } catch (e) {
65
+ if (oper.using_did_catch) { throw e; }
66
+ else { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
67
+ }
61
68
  oper.unregister_active_component(this);
62
69
  let result = oper.render_buffer.pop();
63
70
  return (result.length === 1) ? result[0] : result;
@@ -24,8 +24,13 @@ module LucidFunc
24
24
  const __ruby_instance = __ruby_state.instance;
25
25
  __ruby_instance.props = Object.assign({}, props, context);
26
26
  oper.register_active_component(__ruby_instance);
27
- let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
28
- if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
27
+ try {
28
+ let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
29
+ if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
30
+ } catch (e) {
31
+ if (oper.using_did_catch) { throw e; }
32
+ else { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
33
+ }
29
34
  oper.unregister_active_component(__ruby_instance);
30
35
  // console.log("function popping", oper.render_buffer, oper.render_buffer.toString());
31
36
  let result = oper.render_buffer.pop();
@@ -17,8 +17,13 @@ module Preact
17
17
  const __ruby_instance = __ruby_state.instance;
18
18
  __ruby_instance.props = props;
19
19
  oper.register_active_component(__ruby_instance);
20
- let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
21
- if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
20
+ try {
21
+ let block_result = #{`__ruby_instance`.instance_exec(&`base.render_block`)};
22
+ if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
23
+ } catch (e) {
24
+ if (oper.using_did_catch) { throw e; }
25
+ else { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
26
+ }
22
27
  oper.unregister_active_component(__ruby_instance);
23
28
  let result = oper.render_buffer.pop();
24
29
  return (result.length === 1) ? result[0] : result;
@@ -8,11 +8,14 @@ module Preact
8
8
  %x{
9
9
  var fun = function(error) {
10
10
  Opal.Preact.register_active_component(this);
11
- #{`this.__ruby_instance`.instance_exec(`error`, &block)};
11
+ try {
12
+ #{`this.__ruby_instance`.instance_exec(`error`, &block)};
13
+ } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
12
14
  Opal.Preact.unregister_active_component(this);
13
15
  }
14
16
  if (self.lucid_preact_component) { self.lucid_preact_component.prototype.componentDidCatch = fun; }
15
17
  else { self.preact_component.prototype.componentDidCatch = fun; }
18
+ Opal.Preact.using_did_catch = true;
16
19
  }
17
20
  end
18
21
 
@@ -20,7 +23,9 @@ module Preact
20
23
  %x{
21
24
  let fun = function() {
22
25
  Opal.Preact.register_active_component(this);
23
- #{`this.__ruby_instance`.instance_exec(&block)};
26
+ try {
27
+ #{`this.__ruby_instance`.instance_exec(&block)};
28
+ } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
24
29
  Opal.Preact.unregister_active_component(this);
25
30
  }
26
31
  if (self.lucid_preact_component) {
@@ -41,9 +46,11 @@ module Preact
41
46
  %x{
42
47
  var fun = function(prev_props, prev_state, snapshot) {
43
48
  Opal.Preact.register_active_component(this);
44
- #{`this.__ruby_instance`.instance_exec(`Opal.Preact.Props.$new({props: prev_props})`,
45
- `Opal.Preact.State.$new({state: prev_state})`,
46
- `snapshot`, &block)};
49
+ try {
50
+ #{`this.__ruby_instance`.instance_exec(`Opal.Preact.Props.$new({props: prev_props})`,
51
+ `Opal.Preact.State.$new({state: prev_state})`,
52
+ `snapshot`, &block)};
53
+ } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
47
54
  Opal.Preact.unregister_active_component(this);
48
55
  }
49
56
  if (self.lucid_preact_component) { self.lucid_preact_component.prototype.componentDidUpdate = fun; }
@@ -56,7 +63,9 @@ module Preact
56
63
  var fun = function() {
57
64
  if (typeof this.unsubscriber === "function") { this.unsubscriber(); };
58
65
  Opal.Preact.register_active_component(this);
59
- #{`this.__ruby_instance`.instance_exec(&block)};
66
+ try {
67
+ #{`this.__ruby_instance`.instance_exec(&block)};
68
+ } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
60
69
  Opal.Preact.unregister_active_component(this);
61
70
  }
62
71
  if (self.lucid_preact_component) { self.lucid_preact_component.prototype.componentWillUnmount = fun; }
@@ -69,8 +78,10 @@ module Preact
69
78
  %x{
70
79
  var fun = function(props, state) {
71
80
  Opal.Preact.register_active_component(this);
72
- var result = #{`this.__ruby_instance`.instance_exec(`Opal.Preact.Props.$new({props: props})`,
73
- `Opal.Preact.State.$new({state: state})`, &block)};
81
+ try {
82
+ var result = #{`this.__ruby_instance`.instance_exec(`Opal.Preact.Props.$new({props: props})`,
83
+ `Opal.Preact.State.$new({state: state})`, &block)};
84
+ } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
74
85
  Opal.Preact.unregister_active_component(this);
75
86
  if (typeof result.$to_n === 'function') { result = result.$to_n() }
76
87
  if (result === nil) { return null; }
@@ -85,8 +96,10 @@ module Preact
85
96
  %x{
86
97
  var fun = function(prev_props, prev_state) {
87
98
  Opal.Preact.register_active_component(this);
88
- var result = #{`this.__ruby_instance`.instance_exec(`Opal.Preact.Props.$new({props: prev_props})`,
89
- `Opal.Preact.State.$new({state: prev_state})`, &block)};
99
+ try {
100
+ var result = #{`this.__ruby_instance`.instance_exec(`Opal.Preact.Props.$new({props: prev_props})`,
101
+ `Opal.Preact.State.$new({state: prev_state})`, &block)};
102
+ } catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
90
103
  Opal.Preact.unregister_active_component(this);
91
104
  if (result === nil) { return null; }
92
105
  return result;
@@ -24,7 +24,9 @@ module Preact
24
24
  const oper = Opal.Preact;
25
25
  element = oper.native_element_or_component_to_ruby(element);
26
26
  oper.register_active_component(this);
27
- #{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
27
+ try {
28
+ #{`this.__ruby_instance`.instance_exec(`element`, &`defined_refs[r]`)}
29
+ } catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
28
30
  oper.unregister_active_component(this);
29
31
  }
30
32
  this[ref] = this[ref].bind(this);
@@ -40,8 +42,13 @@ module Preact
40
42
  const oper = Opal.Preact;
41
43
  oper.render_buffer.push([]);
42
44
  oper.register_active_component(this);
43
- let block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)};
44
- if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
45
+ try {
46
+ let block_result = #{`this.__ruby_instance`.instance_exec(&`base.render_block`)};
47
+ if (block_result && block_result !== nil) { oper.render_block_result(block_result); }
48
+ } catch (e) {
49
+ if (oper.using_did_catch) { throw e; }
50
+ else { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
51
+ }
45
52
  oper.unregister_active_component(this);
46
53
  let result = oper.render_buffer.pop();
47
54
  return (result.length === 1) ? result[0] : result;
@@ -50,8 +57,12 @@ module Preact
50
57
  const oper = Opal.Preact;
51
58
  if (base.should_component_update_block) {
52
59
  oper.register_active_component(this);
53
- return #{!!`this.__ruby_instance`.instance_exec(`oper.Props.$new({props: next_props})`, `oper.State.$new({state: next_state })`, &`base.should_component_update_block`)};
60
+ let result;
61
+ try {
62
+ result = #{!!`this.__ruby_instance`.instance_exec(`oper.Props.$new({props: next_props})`, `oper.State.$new({state: next_state })`, &`base.should_component_update_block`)};
63
+ } catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
54
64
  oper.unregister_active_component(this);
65
+ return result;
55
66
  }
56
67
  if (!oper.props_are_equal(this.props, next_props)) { return true; }
57
68
  if (oper.state_is_not_equal(this.state, next_state)) { return true; }
@@ -5,7 +5,7 @@ module Preact
5
5
  def initialize(native)
6
6
  @native = native
7
7
  end
8
-
8
+
9
9
  def is_wrapped_context
10
10
  true
11
11
  end
@@ -22,8 +22,10 @@ module Preact
22
22
  if (block !== nil) {
23
23
  operabu.push([]);
24
24
  // console.log("consumer pushed", operabu, operabu.toString());
25
- let block_result = block.$call(value);
26
- if (block_result && block_result !== nil) { Opal.Preact.render_block_result(block_result); }
25
+ try {
26
+ let block_result = block.$call(value);
27
+ if (block_result && block_result !== nil) { Opal.Preact.render_block_result(block_result); }
28
+ } catch (e) { console.error(e.message === nil ? 'error at' : e.message, e.stack); }
27
29
  // console.log("consumer popping", operabu, operabu.toString());
28
30
  children = operabu.pop();
29
31
  if (children.length === 1) { children = children[0]; }
@@ -1,3 +1,3 @@
1
1
  module Preact
2
- VERSION = '10.6.29'
2
+ VERSION = '10.6.30'
3
3
  end
data/lib/preact.rb CHANGED
@@ -80,6 +80,8 @@ module Preact
80
80
  } else { operain(component, null, null, block); }
81
81
  };
82
82
 
83
+ self.using_did_catch = false;
84
+
83
85
  self.active_components = [];
84
86
 
85
87
  self.active_component = function() {
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.29
4
+ version: 10.6.30
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-05 00:00:00.000000000 Z
11
+ date: 2022-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby