isomorfeus-react 16.13.0 → 16.13.1

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: 947da878f70ba5a12ed18872ce80759e8d8653a7690527a906bd91f10edc1333
4
- data.tar.gz: 7ed9f57c7eb15dcf6b6b5d7d1650e4e55041702cc948cdec4c14321db995f50e
3
+ metadata.gz: 1c28956343a2d33bfd6e86a406a1479b403a609f482dc283df7e60dfee2b52fb
4
+ data.tar.gz: 6909f97fa27587d1635256763cf19d7fede19704f2027876b486043c48d291b4
5
5
  SHA512:
6
- metadata.gz: 260fdc8fc33d3346b7c8f0faf037a9061fda2832aa2713fa12cc0981f9efcbf6084b1768fe5518eb925b5504e667cad95c4b5a0da0cd38bb105783abcf4b4a0d
7
- data.tar.gz: 72e8199ae9fe16615f1f6140715ffdda6d9db023e2f54dfb8476d05da9b62849590f6925a02940d5e968a11a307198642ae9af04011f8e9633cb8af647e3b0ff
6
+ metadata.gz: ad4419cf10814eaf6c2c85dd36450f83ff321a38f47672342faa6a6b136110fcea7710aaae32fa10ea09c4794e226346bbde0a18a7d93ae9e59b2191fdeef2e6
7
+ data.tar.gz: 9ecdaa132dd659a414a9a6f1826b847476686ee3432c1b7827bdfb7a03755f9e9e67c1607a54675ebcf6f4b094c5508d8ad5f219c37a72b8a9567a93566892f6
@@ -100,10 +100,12 @@ else
100
100
  Isomorfeus.server_side_rendering = true
101
101
 
102
102
  # cache
103
- require 'isomorfeus/thread_local_cache'
103
+ require 'isomorfeus/thread_local_component_cache'
104
104
  require 'isomorfeus/react_view_helper'
105
105
 
106
- Isomorfeus.component_cache_class = Isomorfeus::ThreadLocalCache
106
+ Isomorfeus.component_cache do
107
+ Isomorfeus::ThreadLocalComponentCache.new
108
+ end
107
109
 
108
110
  Opal.append_path(__dir__.untaint)
109
111
 
@@ -109,13 +109,17 @@ module Isomorfeus
109
109
  self.add_client_option(:client_init_after_store_class_names, [])
110
110
  else
111
111
  class << self
112
- attr_accessor :component_cache_class
112
+ attr_reader :component_cache
113
113
  attr_accessor :server_side_rendering
114
114
  attr_accessor :ssr_hot_asset_url
115
115
  attr_reader :env
116
116
  attr_accessor :zeitwerk
117
117
  attr_accessor :zeitwerk_lock
118
118
 
119
+ def component_cache(&block)
120
+ @component_cache = block
121
+ end
122
+
119
123
  def configuration(&block)
120
124
  block.call(self)
121
125
  end
@@ -146,6 +150,12 @@ module Isomorfeus
146
150
  def version
147
151
  Isomorfeus::VERSION
148
152
  end
153
+
154
+ def load_configuration
155
+ Dir.glob("config/*.rf").sort.each do |file|
156
+ require_relative file
157
+ end
158
+ end
149
159
  end
150
160
  end
151
161
 
@@ -155,9 +165,24 @@ module Isomorfeus
155
165
  execution_environment = if on_browser? then 'on Browser'
156
166
  elsif on_ssr? then 'in Server Side Rendering'
157
167
  elsif on_server? then 'on Server'
168
+ elsif on_mobile? then 'on Mobile'
169
+ elsif on_database? then 'on Database'
170
+ else
171
+ 'on Client'
158
172
  end
159
173
  error = error_class.new("Isomorfeus in #{env} #{execution_environment}:\n#{message}")
160
174
  error.set_backtrace(stack) if stack
175
+
176
+ if Isomorfeus.development?
177
+ if RUBY_ENGINE == 'opal'
178
+ ecn = error_class ? error_class.name : ''
179
+ m = message ? message : ''
180
+ s = stack ? stack : ''
181
+ `console.error(ecn, m, s)`
182
+ else
183
+ STDERR.puts "#{ecn}: #{m}\n #{s}"
184
+ end
185
+ end
161
186
  raise error
162
187
  end
163
188
  end
@@ -1,26 +1,22 @@
1
1
  module Isomorfeus
2
2
  module ReactViewHelper
3
- def cached_mount_component(component_name, props = {}, asset = 'application_ssr.js', static = false)
3
+ def cached_mount_component(component_name, props = {}, asset = 'web_ssr.js', static = false)
4
4
  key = "#{component_name}#{props}#{asset}"
5
- if Isomorfeus.production? && component_cache.key?(key)
6
- render_result = component_cache[key][:render_result]
7
- @ssr_response_status = component_cache[key][:ssr_response_status]
8
- @sst_styles = component_cache[key][:ssr_styles]
9
- else
10
- render_result = mount_component(component_name, props, asset, static)
11
- status = ssr_response_status
12
- if status >= 200 && status < 300
13
- component_cache[key] = { render_result: render_result, ssr_response_status: status, ssr_styles: ssr_styles }
14
- end
5
+ if Isomorfeus.production?
6
+ render_result, @ssr_response_status, @ssr_styles = component_cache.fetch(key)
7
+ return render_result if render_result
15
8
  end
9
+ render_result = mount_component(component_name, props, asset, static)
10
+ status = ssr_response_status
11
+ component_cache.set(key, render_result, status, ssr_styles) if status >= 200 && status < 300
16
12
  render_result
17
13
  end
18
14
 
19
- def cached_mount_static_component(component_name, props = {}, asset = 'application_ssr.js')
15
+ def cached_mount_static_component(component_name, props = {}, asset = 'web_ssr.js')
20
16
  cached_mount_component(component_name, props, asset, true)
21
17
  end
22
18
 
23
- def mount_component(component_name, props = {}, asset = 'application_ssr.js', static = false)
19
+ def mount_component(component_name, props = {}, asset = 'web_ssr.js', static = false)
24
20
  @ssr_response_status = nil
25
21
  @ssr_styles = nil
26
22
  thread_id_asset = "#{Thread.current.object_id}#{asset}"
@@ -214,7 +210,7 @@ module Isomorfeus
214
210
  render_result
215
211
  end
216
212
 
217
- def mount_static_component(component_name, props = {}, asset = 'application_ssr.js')
213
+ def mount_static_component(component_name, props = {}, asset = 'web_ssr.js')
218
214
  mount_component(component_name, props, asset, true)
219
215
  end
220
216
 
@@ -229,7 +225,7 @@ module Isomorfeus
229
225
  private
230
226
 
231
227
  def component_cache
232
- @_component_cache ||= Isomorfeus.component_cache_class.new
228
+ @_component_cache ||= Isomorfeus.component_cache.call
233
229
  end
234
230
  end
235
231
  end
@@ -0,0 +1,15 @@
1
+ module Isomorfeus
2
+ class ThreadLocalComponentCache
3
+ def initialize
4
+ Thread.current[:local_cache] = {} unless Thread.current.key?(:local_cache)
5
+ end
6
+
7
+ def fetch(key)
8
+ Thread.current[:local_cache][key]
9
+ end
10
+
11
+ def store(key, rendered_tree, response_status, styles)
12
+ Thread.current[:local_cache][key] = [rendered_tree, response_status, styles]
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module React
2
- VERSION = '16.13.0'
2
+ VERSION = '16.13.1'
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.13.0
4
+ version: 16.13.1
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-27 00:00:00.000000000 Z
11
+ date: 2020-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.9.10
89
+ version: 0.9.11
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: 0.9.10
96
+ version: 0.9.11
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: isomorfeus-redux
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -200,7 +200,7 @@ files:
200
200
  - lib/isomorfeus/props/validator.rb
201
201
  - lib/isomorfeus/react_config.rb
202
202
  - lib/isomorfeus/react_view_helper.rb
203
- - lib/isomorfeus/thread_local_cache.rb
203
+ - lib/isomorfeus/thread_local_component_cache.rb
204
204
  - lib/isomorfeus/top_level.rb
205
205
  - lib/isomorfeus/top_level_ssr.rb
206
206
  - lib/isomorfeus/vivify_module.rb
@@ -1,21 +0,0 @@
1
- module Isomorfeus
2
- class ThreadLocalCache
3
- def initialize
4
- Thread.current[:local_cache] = {} unless Thread.current.key?(:local_cache)
5
- end
6
-
7
- def [](key)
8
- Thread.current[:local_cache][key]
9
- end
10
- alias fetch []
11
-
12
- def []=(key, value)
13
- Thread.current[:local_cache][key] = value
14
- end
15
- alias store []=
16
-
17
- def key?(key)
18
- Thread.current[:local_cache].key?(key)
19
- end
20
- end
21
- end