isomorfeus-react 16.10.8 → 16.10.9

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: f4e282b6791c9a739cde5039e051d9edc78d54fb39a8b6cd1e8c90f4d8f9007d
4
- data.tar.gz: b8358d33d9cbb221829053bae6f84f33941a5007db32ea8dfef7e3d11cc0cd84
3
+ metadata.gz: a4f48aa681e4ef082360632f0cc00170e2fef45dcb74cae9abcbedbec13cb60b
4
+ data.tar.gz: c778e71574479ec8111c52c571f01df750c84b03d114820fff4a4b1aee350465
5
5
  SHA512:
6
- metadata.gz: eb43c54e03a5cba4a31f8ab3cff891b49e84a578e0e17956a48745196df6129b00e1d6e56d4bc9d65c86dab6d6df6def5d99e634eddef0bcdf9d31b69f13720f
7
- data.tar.gz: 717d220b8d9bdf184a0632f979ecc84ef7e2ae3d211a7c1d9e28b78ea7610b7e4d4b05dce8978cd2e010ee59001271857be3186b12f8c805b8f36b9584039d12
6
+ metadata.gz: c244ba0c1a51df15754fbc00aa1e7e6afc0c9d3880004816fbabc0f52870431937cbd40b2302e683820094fca342225cdcb596c4cf0adfe333db3e929c2a4053
7
+ data.tar.gz: fdaaf7afd00c1885c4ff5d1bb623b2c22146a76ab8dc077c0ead3276f5bdc36c6548b01d28560db476406f92e1b3f8caf76a87b09e91656e4856bde4f90f4173
data/README.md CHANGED
@@ -5,9 +5,19 @@ Develop React components for Opal Ruby along with very easy to use and advanced
5
5
  ## Community and Support
6
6
  At the [Isomorfeus Framework Project](http://isomorfeus.com)
7
7
 
8
- ## Versioning
8
+ ## Versioning and Compatibility
9
9
  isomorfeus-react version follows the React version which features and API it implements.
10
- Isomorfeus-react 16.8.x implements features and the API of React 16.8 and should be used with React 16.8
10
+
11
+ ### React
12
+ Isomorfeus-react 16.10.x implements features and the API of React 16.8 and should be used with React 16.10
13
+
14
+ ### Preact
15
+ isomorfeus-react works with preact version 10.0.x.
16
+
17
+ ### Nerv
18
+ isomorfeus-react works in general with nervjs 1.4.x. with some issues:
19
+ - Server Side Rendering does currently not work at all.
20
+ - Some specs with respect to callbacks (component_will_unmount) and styles fail.
11
21
 
12
22
  ## Documentation
13
23
 
@@ -1,11 +1,11 @@
1
1
  if RUBY_ENGINE == 'opal'
2
- require 'opal'
3
- require 'opal-autoloader'
4
- require 'native'
5
- require 'promise'
6
- require 'active_support/core_ext/string'
7
- require 'react/active_support_support'
2
+ # require 'opal'
3
+ # require 'native'
4
+ # require 'promise'
5
+ # rely on i-redux to have included above reqiorements
8
6
  require 'isomorfeus-redux'
7
+ require 'active_support/core_ext/string'
8
+ require 'opal-autoloader'
9
9
 
10
10
  if Isomorfeus.on_browser?
11
11
  require 'browser/event'
@@ -83,23 +83,35 @@ module Isomorfeus
83
83
  return (o !== null && typeof o[x] !== "undefined" && o[x] !== null) ? o[x] : null;
84
84
  }, global.Opal.global)
85
85
  if (!component) { component = global.Opal.Isomorfeus.$cached_component_class('#{component_name}'); }
86
- let sheets = new global.Opal.global.MuiStyles.ServerStyleSheets();
87
- let app = global.Opal.React.$create_element(component, global.Opal.Hash.$new(#{Oj.dump(props, mode: :strict)}));
88
- rendered_tree = global.Opal.global.ReactDOMServer.renderToString(sheets.collect(app));
89
- ssr_styles = sheets.toString();
86
+ try {
87
+ let sheets = new global.Opal.global.MuiStyles.ServerStyleSheets();
88
+ let app = global.Opal.React.$create_element(component, global.Opal.Hash.$new(#{Oj.dump(props, mode: :strict)}));
89
+ rendered_tree = global.Opal.global.ReactDOMServer.renderToString(sheets.collect(app));
90
+ ssr_styles = sheets.toString();
91
+ } catch (e) {
92
+ rendered_tree = e.message + "\\n" + e.stack;
93
+ }
90
94
  } else if (typeof global.Opal.global.ReactJSS !== 'undefined' && typeof global.Opal.global.ReactJSS.SheetsRegistry !== 'undefined') {
91
95
  component = '#{component_name}'.split(".").reduce(function(o, x) {
92
96
  return (o !== null && typeof o[x] !== "undefined" && o[x] !== null) ? o[x] : null;
93
97
  }, global.Opal.global)
94
98
  if (!component) { component = global.Opal.Isomorfeus.$cached_component_class('#{component_name}'); }
95
- let sheets = new global.Opal.global.ReactJSS.SheetsRegistry();
96
- let generate_id = global.Opal.global.ReactJSS.createGenerateId();
97
- let app = global.Opal.React.$create_element(component, global.Opal.Hash.$new(#{Oj.dump(props, mode: :strict)}));
98
- let element = global.Opal.global.React.createElement(global.Opal.global.ReactJSS.JssProvider, { registry: sheets, generateId: generate_id }, app);
99
- rendered_tree = global.Opal.global.ReactDOMServer.renderToString(element);
100
- ssr_styles = sheets.toString();
99
+ try {
100
+ let sheets = new global.Opal.global.ReactJSS.SheetsRegistry();
101
+ let generate_id = global.Opal.global.ReactJSS.createGenerateId();
102
+ let app = global.Opal.React.$create_element(component, global.Opal.Hash.$new(#{Oj.dump(props, mode: :strict)}));
103
+ let element = global.Opal.global.React.createElement(global.Opal.global.ReactJSS.JssProvider, { registry: sheets, generateId: generate_id }, app);
104
+ rendered_tree = global.Opal.global.ReactDOMServer.renderToString(element);
105
+ ssr_styles = sheets.toString();
106
+ } catch (e) {
107
+ rendered_tree = e.message + "\\n" + e.stack;
108
+ }
101
109
  } else {
102
- rendered_tree = global.Opal.Isomorfeus.TopLevel.$render_component_to_string('#{component_name}', #{Oj.dump(props, mode: :strict)});
110
+ try {
111
+ rendered_tree = global.Opal.Isomorfeus.TopLevel.$render_component_to_string('#{component_name}', #{Oj.dump(props, mode: :strict)});
112
+ } catch (e) {
113
+ rendered_tree = e.message + "\\n" + e.stack;
114
+ }
103
115
  }
104
116
  let application_state = global.Opal.Isomorfeus.store.native.getState();
105
117
  if (typeof global.Opal.Isomorfeus.Transport !== 'undefined') { global.Opal.Isomorfeus.Transport.$disconnect(); }
@@ -111,7 +123,7 @@ module Isomorfeus
111
123
 
112
124
  # build result
113
125
  render_result << " data-iso-nloc='#{props[:locale]}' data-iso-state='#{Oj.dump(application_state, mode: :strict)}'>"
114
- render_result << rendered_tree
126
+ render_result << (rendered_tree ? rendered_tree : "SSR didn't work")
115
127
  else
116
128
  render_result << " data-iso-nloc='#{props[:locale]}'>"
117
129
  end
@@ -53,6 +53,10 @@ module LucidApp
53
53
  static get displayName() {
54
54
  return #{component_name};
55
55
  }
56
+ static set displayName(new_name) {
57
+ // dont do anything here except returning the set value
58
+ return new_name;
59
+ }
56
60
  render() {
57
61
  this.context = this.state.isomorfeus_store_state;
58
62
  Opal.React.render_buffer.push([]);
@@ -1,7 +1,7 @@
1
1
  module LucidComponent
2
2
  class AppStoreProxy
3
3
  def initialize(component_instance)
4
- @native_component_instance = component_instance.to_n
4
+ @native = component_instance.to_n
5
5
  @component_instance = component_instance
6
6
  end
7
7
 
@@ -12,9 +12,9 @@ module LucidComponent
12
12
  Isomorfeus.store.dispatch(action)
13
13
  else
14
14
  # check if we have a component local state value
15
- if `this.native_component_instance.context`
16
- if `this.native_component_instance.context.application_state && this.native_component_instance.context.application_state.hasOwnProperty(key)`
17
- return @native_component_instance.JS['context'].JS[:application_state].JS[key]
15
+ if `this.native.props.store`
16
+ if `this.native.props.store.application_state && this.native.props.store.application_state.hasOwnProperty(key)`
17
+ return @native.JS[:props].JS[:store].JS[:application_state].JS[key]
18
18
  end
19
19
  else
20
20
  a_state = Isomorfeus.store.get_state
@@ -1,7 +1,7 @@
1
1
  module LucidComponent
2
2
  class ClassStoreProxy
3
3
  def initialize(component_instance)
4
- @native_component_instance = component_instance.to_n
4
+ @native = component_instance.to_n
5
5
  @component_instance = component_instance
6
6
  @component_name = component_instance.class.to_s
7
7
  end
@@ -14,10 +14,11 @@ module LucidComponent
14
14
  else
15
15
  # get class state
16
16
  # check if we have a component local state value
17
- if `this.native_component_instance.context`
18
- if @native_component_instance.JS['context'].JS[:component_class_state].JS[@component_name] &&
19
- @native_component_instance.JS['context'].JS[:component_class_state].JS[@component_name].JS.hasOwnProperty(key)
20
- return @native_component_instance.JS['context'].JS[:component_class_state].JS[@component_name].JS[key]
17
+ if @native.JS[:props].JS[:store]
18
+ if @native.JS[:props].JS[:store].JS[:component_class_state] &&
19
+ @native.JS[:props].JS[:store].JS[:component_class_state].JS[@component_name] &&
20
+ @native.JS[:props].JS[:store].JS[:component_class_state].JS[@component_name].JS.hasOwnProperty(key)
21
+ return @native.JS[:props].JS[:store].JS[:component_class_state].JS[@component_name].JS[key]
21
22
  end
22
23
  else
23
24
  a_state = Isomorfeus.store.get_state
@@ -1,7 +1,7 @@
1
1
  module LucidComponent
2
2
  class InstanceStoreProxy
3
3
  def initialize(component_instance)
4
- @native_component_instance = component_instance.to_n
4
+ @native = component_instance.to_n
5
5
  @component_instance = component_instance
6
6
  @component_object_id = component_instance.object_id.to_s
7
7
  end
@@ -16,11 +16,12 @@ module LucidComponent
16
16
  else
17
17
  # get instance state
18
18
 
19
- if `this.native_component_instance.context`
20
- if @native_component_instance.JS[:context].JS[:component_state].JS[@component_object_id] &&
21
- @native_component_instance.JS[:context].JS[:component_state].JS[@component_object_id].JS.hasOwnProperty(key)
19
+ if @native.JS[:props].JS[:store]
20
+ if @native.JS[:props].JS[:store].JS[:component_state] &&
21
+ @native.JS[:props].JS[:store].JS[:component_state].JS[@component_object_id] &&
22
+ @native.JS[:props].JS[:store].JS[:component_state].JS[@component_object_id].JS.hasOwnProperty(key)
22
23
  # check if we have a component local state value
23
- return @native_component_instance.JS[:context].JS[:component_state].JS[@component_object_id].JS[key]
24
+ return @native.JS[:props].JS[:store].JS[:component_state].JS[@component_object_id].JS[key]
24
25
  end
25
26
  else
26
27
  a_state = Isomorfeus.store.get_state
@@ -41,6 +41,10 @@ module LucidComponent
41
41
  static get displayName() {
42
42
  return #{component_name};
43
43
  }
44
+ static set displayName(new_name) {
45
+ // dont do anything here except returning the set value
46
+ return new_name;
47
+ }
44
48
  render() {
45
49
  Opal.React.render_buffer.push([]);
46
50
  // console.log("lucid component pushed", Opal.React.render_buffer, Opal.React.render_buffer.toString());
@@ -54,7 +58,7 @@ module LucidComponent
54
58
  return Opal.React.render_buffer.pop();
55
59
  }
56
60
  data_access() {
57
- return this.context;
61
+ return this.props.store;
58
62
  }
59
63
  shouldComponentUpdate(next_props, next_state) {
60
64
  let counter = 0;
@@ -90,12 +94,14 @@ module LucidComponent
90
94
  return null;
91
95
  }
92
96
  }
93
- base.lucid_react_component.contextType = Opal.global.LucidApplicationContext;
94
97
  base.jss_styles = null;
95
98
  base.jss_styles_used = null;
96
99
  base.use_styles = null;
100
+ base.store_updates = true;
97
101
  base.react_component = function(props) {
98
102
  let classes = null;
103
+ let store;
104
+ if (base.store_updates) { store = Opal.global.React.useContext(Opal.global.LucidApplicationContext); }
99
105
  let theme = Opal.global.ReactJSS.useTheme();
100
106
  if (base.jss_styles) {
101
107
  if (!base.use_styles || (Opal.Isomorfeus.development && !Object.is(base.jss_styles, base.jss_styles_used))) {
@@ -106,8 +112,11 @@ module LucidComponent
106
112
  }
107
113
  classes = base.use_styles();
108
114
  }
109
- let class_theme_props = Object.assign({}, props, { classes: classes, theme: theme });
110
- return Opal.global.React.createElement(base.lucid_react_component, class_theme_props);
115
+ let new_props = Object.assign({}, props)
116
+ new_props.classes = classes;
117
+ new_props.theme = theme;
118
+ new_props.store = store;
119
+ return Opal.global.React.createElement(base.lucid_react_component, new_props);
111
120
  }
112
121
  }
113
122
  end
@@ -33,8 +33,11 @@ module LucidComponent
33
33
  @default_instance_store ||= ::LucidComponent::ComponentInstanceStoreDefaults.new(state, self.to_s)
34
34
  end
35
35
 
36
- def store_updates_off
37
- `delete base.lucid_react_component['contextType']`
36
+ def store_updates(switch)
37
+ case switch
38
+ when :on then `base.store_updates = true`
39
+ when :off then `base.store_updates = false`
40
+ end
38
41
  end
39
42
  end
40
43
  end
@@ -54,6 +54,10 @@ module LucidMaterial
54
54
  static get displayName() {
55
55
  return #{component_name};
56
56
  }
57
+ static set displayName(new_name) {
58
+ // dont do anything here except returning the set value
59
+ return new_name;
60
+ }
57
61
  render() {
58
62
  this.context = this.state.isomorfeus_store_state;
59
63
  Opal.React.render_buffer.push([]);
@@ -42,6 +42,10 @@ module LucidMaterial
42
42
  static get displayName() {
43
43
  return #{component_name};
44
44
  }
45
+ static set displayName(new_name) {
46
+ // dont do anything here except returning the set value
47
+ return new_name;
48
+ }
45
49
  render() {
46
50
  Opal.React.render_buffer.push([]);
47
51
  // console.log("material component pushed", Opal.React.render_buffer, Opal.React.render_buffer.toString());
@@ -55,7 +59,7 @@ module LucidMaterial
55
59
  return Opal.React.render_buffer.pop();
56
60
  }
57
61
  data_access() {
58
- return this.context;
62
+ return this.props.store;
59
63
  }
60
64
  shouldComponentUpdate(next_props, next_state) {
61
65
  let counter = 0;
@@ -91,12 +95,14 @@ module LucidMaterial
91
95
  return null;
92
96
  }
93
97
  };
94
- base.lucid_react_component.contextType = Opal.global.LucidApplicationContext;
95
98
  base.jss_styles = null;
96
99
  base.jss_styles_used = null;
97
100
  base.use_styles = null;
101
+ base.store_updates = true;
98
102
  base.react_component = function(props) {
99
103
  let classes = null;
104
+ let store;
105
+ if (base.store_updates) { store = Opal.global.React.useContext(Opal.global.LucidApplicationContext); }
100
106
  let theme = Opal.global.MuiStyles.useTheme();
101
107
  if (base.jss_styles) {
102
108
  if (!base.use_styles || (Opal.Isomorfeus.development && !Object.is(base.jss_styles, base.jss_styles_used))) {
@@ -107,8 +113,11 @@ module LucidMaterial
107
113
  }
108
114
  classes = base.use_styles();
109
115
  }
110
- let themed_classes_props = Object.assign({}, props, { classes: classes, theme: theme });
111
- return Opal.global.React.createElement(base.lucid_react_component, themed_classes_props);
116
+ let new_props = Object.assign({}, props)
117
+ new_props.classes = classes;
118
+ new_props.theme = theme;
119
+ new_props.store = store;
120
+ return Opal.global.React.createElement(base.lucid_react_component, new_props);
112
121
  }
113
122
  }
114
123
  end
data/lib/react.rb CHANGED
@@ -136,12 +136,12 @@ module React
136
136
  if (block !== nil) {
137
137
  Opal.React.render_buffer.push([]);
138
138
  // console.log("create_element pushed", Opal.React.render_buffer, Opal.React.render_buffer.toString());
139
- let block_result = block.$call()
139
+ let block_result = block.$call();
140
140
  if (block_result && (block_result.constructor === String || block_result.constructor === Number)) {
141
141
  Opal.React.render_buffer[Opal.React.render_buffer.length - 1].push(block_result);
142
142
  }
143
143
  // console.log("create_element popping", Opal.React.render_buffer, Opal.React.render_buffer.toString());
144
- children = Opal.React.render_buffer.pop()
144
+ children = Opal.React.render_buffer.pop();
145
145
  if (children.length == 1) { children = children[0]; }
146
146
  else if (children.length == 0) { children = null; }
147
147
  } else if (children === nil) { children = null; }
@@ -37,6 +37,10 @@ module React
37
37
  static get displayName() {
38
38
  return #{component_name};
39
39
  }
40
+ static set displayName(new_name) {
41
+ // dont do anything here except returning the set value
42
+ return new_name;
43
+ }
40
44
  render() {
41
45
  Opal.React.render_buffer.push([]);
42
46
  // console.log("react component pushed", Opal.React.render_buffer, Opal.React.render_buffer.toString());
data/lib/react/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module React
2
- VERSION = '16.10.8'
2
+ VERSION = '16.10.9'
3
3
  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.10.8
4
+ version: 16.10.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-11 00:00:00.000000000 Z
11
+ date: 2019-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 4.0.14
89
+ version: 4.0.15
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: 4.0.14
96
+ version: 4.0.15
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: isomorfeus-speednode
99
99
  requirement: !ruby/object:Gem::Requirement