isomorfeus-react 16.12.23 → 16.12.24

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: 0b0036481e21b2135112831ebf7aee76c904bcd48b3974f1011ca602131f8cc8
4
- data.tar.gz: fa116a1c8b7d2a24f81e4c112141c23350e6d0eb2bafe028e1e6f2e7f1edcca4
3
+ metadata.gz: 5860bb2392aa87bc2224fcd09490cf803c2463420a0dc7b81eeb2eb2281a9125
4
+ data.tar.gz: b9ce782e12c36506a6ae46740fe466049d9c34492185ffd5fd913a69fde7d367
5
5
  SHA512:
6
- metadata.gz: efe98461b8ec364858ab1b96a09c5b1fc0425089dedf7de79739ff8794a5324c3af31f6adafb412dbe0302b01ac2d1c6f829ea5a6456453c79cb938f49492056
7
- data.tar.gz: 8de49d95da87fd8e9038378e3f10497ac6cab5d02840ee1a14aa8d97ee97bef7530a56add6df06b4001f6287d464a49027ee4922037aa4b03f299670eee247f8
6
+ metadata.gz: 30e21a8dd53fc01f0bb573c355efa588e8a7b0acdf74b5cfe35dd2a82280064543fc734907ee0c8ad5102d7c68a96c39475b25974123238c920ca00163fef18c
7
+ data.tar.gz: 3daf8ba10d97f38b831da9a34526ae3b47ff3508457cdfc631c3ee01d3105aa0865eb32685e6faf6ab9af2b9f2e4199f41a31f180162b052fad008cb08971ada
@@ -43,7 +43,7 @@ module Isomorfeus
43
43
  begin
44
44
  asset = Net::HTTP.get(URI(asset_path))
45
45
  rescue Exception => e
46
- Isomorfeus.raise_error(message: "Server Side Rendering: Failed loading asset #{asset_path} from webpack dev server. Error: #{e.message}")
46
+ Isomorfeus.raise_error(message: "Server Side Rendering: Failed loading asset #{asset_path} from webpack dev server. Error: #{e.message}", stack: e.backtrace )
47
47
  end
48
48
  if asset.strip.start_with?('<')
49
49
  Isomorfeus.raise_error(message: "Server Side Rendering: Failed loading asset #{asset_path} from webpack dev server, asset is not javascript. Did the webpack build succeed?")
@@ -51,7 +51,7 @@ module Isomorfeus
51
51
  begin
52
52
  Isomorfeus.ssr_contexts[thread_id_asset] = ExecJS.permissive_compile(asset)
53
53
  rescue Exception => e
54
- Isomorfeus.raise_error(message: "Server Side Rendering: Failed creating context for #{asset_path}. Error: #{e.message}")
54
+ Isomorfeus.raise_error(message: "Server Side Rendering: Failed creating context for #{asset_path}. Error: #{e.message}", stack: e.backtrace)
55
55
  end
56
56
  else
57
57
  # initialize speednode context
@@ -201,6 +201,9 @@ module Isomorfeus
201
201
  end
202
202
  render_result << (rendered_tree ? rendered_tree : "SSR didn't work")
203
203
  else
204
+ if Isomorfeus.respond_to?(:current_user) && Isomorfeus.current_user && !Isomorfeus.current_user.anonymous?
205
+ render_result << " data-iso-usid=#{Oj.dump(Isomorfeus.current_user.to_sid, mode: :strict)}"
206
+ end
204
207
  render_result << " data-iso-nloc='#{props[:locale]}'>" unless static
205
208
  end
206
209
  render_result << '</div>'
@@ -4,8 +4,8 @@ module LucidApp
4
4
  base.instance_exec do
5
5
  def theme(theme_hash = nil, &block)
6
6
  if block_given?
7
+ result = block.call(React::Component::Styles.new(`base.jss_theme`))
7
8
  %x{
8
- let result = block.$call(Opal.Hash.$new(base.jss_theme));
9
9
  if (typeof result.$to_n === 'function') { base.jss_theme = result.$to_n(); }
10
10
  else { base.jss_theme = result; }
11
11
  return result;
@@ -19,6 +19,10 @@ module React
19
19
  @classes ||= React::Component::Styles.new(@native, 'classes')
20
20
  end
21
21
 
22
+ def children
23
+ @native.JS[:props].JS[:children]
24
+ end
25
+
22
26
  def theme
23
27
  @theme ||= React::Component::Styles.new(@native, 'theme')
24
28
  end
@@ -1,29 +1,70 @@
1
1
  module React
2
2
  module Component
3
3
  class Styles
4
+
4
5
  def initialize(native, props_prop = false)
5
6
  @native = native
6
7
  @props_prop = props_prop
7
8
  end
8
9
 
10
+ def [](prop)
11
+ method_missing(prop)
12
+ end
13
+
14
+ def []=(prop, val)
15
+ method_missing(prop, val)
16
+ end
17
+
18
+ %x{
19
+ function isObject(obj) { return (obj && typeof obj === 'object'); }
20
+
21
+ function mergeDeep(one, two) {
22
+ return [one, two].reduce(function(pre, obj) {
23
+ Object.keys(obj).forEach(function(key){
24
+ let pVal = pre[key];
25
+ let oVal = obj[key];
26
+ if (Array.isArray(pVal) && Array.isArray(oVal)) {
27
+ pre[key] = pVal.concat.apply(this, oVal);
28
+ } else if (isObject(pVal) && isObject(oVal)) {
29
+ pre[key] = mergeDeep(pVal, oVal);
30
+ } else {
31
+ pre[key] = oVal;
32
+ }
33
+ });
34
+ return pre;
35
+ }, {});
36
+ }
37
+ }
38
+
39
+ def deep_merge(a_hash)
40
+ native_hash = a_hash.to_n
41
+ React::Component::Styles.new(`mergeDeep(#@native, native_hash)`)
42
+ end
43
+
44
+ def deep_merge!(a_hash)
45
+ native_hash = a_hash.to_n
46
+ `#@native = mergeDeep(#@native, native_hash)`
47
+ self
48
+ end
49
+
9
50
  def method_missing(prop, *args, &block)
10
51
  %x{
11
52
  let value;
12
53
  if (#@props_prop) {
13
54
  if (!#@native.props[#@props_prop] || typeof #@native.props[#@props_prop][prop] === 'undefined') {
14
- console.warn("Style/Theme key " + prop + " returning nil!");
55
+ console.warn("Style/Theme key '" + prop + "' returning nil!");
15
56
  return #{nil};
16
57
  }
17
58
  value = #@native.props[#@props_prop][prop];
18
59
  } else {
19
60
  if (!#@native || typeof #@native[prop] === 'undefined') {
20
- console.warn("Style/Theme key " + prop + " returning nil!");
61
+ console.warn("Style/Theme key '" + prop + "' returning nil!");
21
62
  return #{nil};
22
63
  }
23
64
  value = #@native[prop];
24
65
  }
25
66
  if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value)) { return value; }
26
- if (typeof value === 'function') { return #{Proc.new { `value()` }} }
67
+ if (typeof value === 'function') { return value.apply(#@native, args); }
27
68
  return Opal.React.Component.Styles.$new(value);
28
69
  }
29
70
  end
data/lib/react/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module React
2
- VERSION = '16.12.23'
2
+ VERSION = '16.12.24'
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.12.23
4
+ version: 16.12.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-22 00:00:00.000000000 Z
11
+ date: 2020-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby