isomorfeus-preact 10.6.22 → 10.6.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/isomorfeus/preact_view_helper.rb +28 -5
- data/lib/preact/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8b133ab120af42dff909afe3fd478174cd0ff2414a73b8d1281cfdde3e5d333
|
4
|
+
data.tar.gz: 681651aa16c14f38d2e0fa45a5fff880a4513bc5bff3f59acb88fadf0fc3279d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e881c1b2d966629ff7ce355387ebaa43f05d9e89f73a513e09f0da1721143ec4370141f7c1679c50363794be974632f13ff92a1377883094459329ad9873f9e1
|
7
|
+
data.tar.gz: 6857773386b43ddb122e7045d2cfc07fa06375b59597e7e51d6860ba26e841ececee6b7ae44b8713c3a72eff35678071b7d03c4bae38fee73d7475b90b3a2e25
|
@@ -41,6 +41,8 @@ module Isomorfeus
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
start_time = Time.now if Isomorfeus.development?
|
45
|
+
pass = 1
|
44
46
|
# if location_host and scheme are given and if Transport is loaded, connect and then render,
|
45
47
|
# otherwise do not render because only one pass is required
|
46
48
|
ws_scheme = props[:location_scheme] == 'https:' ? 'wss:' : 'ws:'
|
@@ -88,6 +90,7 @@ module Isomorfeus
|
|
88
90
|
end
|
89
91
|
# wait for first pass to finish
|
90
92
|
unless first_pass_skipped
|
93
|
+
pass += 1
|
91
94
|
first_pass_finished, exception = Isomorfeus.ssr_contexts[thread_id_asset].exec('return [global.FirstPassFinished, global.Exception ? { message: global.Exception.message, stack: global.Exception.stack } : false ]')
|
92
95
|
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
93
96
|
unless first_pass_finished
|
@@ -104,7 +107,7 @@ module Isomorfeus
|
|
104
107
|
if transport_busy
|
105
108
|
start_time = Time.now
|
106
109
|
while transport_busy
|
107
|
-
break if (Time.now - start_time) >
|
110
|
+
break if (Time.now - start_time) > 5
|
108
111
|
sleep 0.01
|
109
112
|
transport_busy = Isomorfeus.ssr_contexts[thread_id_asset].exec('return global.Opal.Isomorfeus.Transport["$busy?"]()')
|
110
113
|
end
|
@@ -127,12 +130,31 @@ module Isomorfeus
|
|
127
130
|
global.Exception = e;
|
128
131
|
}
|
129
132
|
let application_state = global.Opal.Isomorfeus.store.native.getState();
|
130
|
-
|
133
|
+
let transport_busy = false;
|
134
|
+
if (typeof global.Opal.Isomorfeus.Transport !== 'undefined' && global.Opal.Isomorfeus.Transport["$busy?"]()) { transport_busy = true; }
|
131
135
|
if (typeof global.NanoCSSInstance !== 'undefined') { ssr_styles = global.NanoCSSInstance.raw }
|
132
|
-
return [rendered_tree, application_state, ssr_styles, global.Opal.Isomorfeus['$ssr_response_status'](), global.Exception ? { message: global.Exception.message, stack: global.Exception.stack } : false];
|
136
|
+
return [rendered_tree, application_state, ssr_styles, global.Opal.Isomorfeus['$ssr_response_status'](), transport_busy, global.Exception ? { message: global.Exception.message, stack: global.Exception.stack } : false];
|
137
|
+
JAVASCRIPT
|
138
|
+
# execute further render passes
|
139
|
+
rendered_tree, application_state, @ssr_styles, @ssr_response_status, transport_busy, exception = Isomorfeus.ssr_contexts[thread_id_asset].exec(javascript)
|
140
|
+
break_while = false
|
141
|
+
start_time = Time.now
|
142
|
+
while transport_busy
|
143
|
+
break if (Time.now - start_time) > 5
|
144
|
+
while transport_busy
|
145
|
+
break if (Time.now - start_time) > 4
|
146
|
+
sleep 0.01
|
147
|
+
transport_busy = Isomorfeus.ssr_contexts[thread_id_asset].exec('return global.Opal.Isomorfeus.Transport["$busy?"]()')
|
148
|
+
end
|
149
|
+
# execute third render pass
|
150
|
+
pass += 1
|
151
|
+
rendered_tree, application_state, @ssr_styles, @ssr_response_status, transport_busy, exception = Isomorfeus.ssr_contexts[thread_id_asset].exec(javascript)
|
152
|
+
break if break_while || pass > 5
|
153
|
+
end
|
154
|
+
javascript = <<~JAVASCRIPT
|
155
|
+
if (typeof global.Opal.Isomorfeus.Transport !== 'undefined') { global.Opal.Isomorfeus.Transport.$disconnect(); }
|
133
156
|
JAVASCRIPT
|
134
|
-
|
135
|
-
rendered_tree, application_state, @ssr_styles, @ssr_response_status, exception = Isomorfeus.ssr_contexts[thread_id_asset].exec(javascript)
|
157
|
+
Isomorfeus.ssr_contexts[thread_id_asset].exec(javascript)
|
136
158
|
Isomorfeus.raise_error(message: exception['message'], stack: exception['stack']) if exception
|
137
159
|
render_result << " data-iso-hydrated='true'" if rendered_tree
|
138
160
|
if Isomorfeus.respond_to?(:current_user) && Isomorfeus.current_user && !Isomorfeus.current_user.anonymous?
|
@@ -150,6 +172,7 @@ module Isomorfeus
|
|
150
172
|
if Isomorfeus.server_side_rendering
|
151
173
|
render_result = "<script type='application/javascript'>\nServerSideRenderingStateJSON = #{Oj.dump(application_state, mode: :strict)}\n</script>\n" << render_result
|
152
174
|
end
|
175
|
+
STDERR.puts "PreactViewHelper Server Side Rendering rendered #{pass} passes and took ~#{Time.now - start_time}s" if Isomorfeus.development?
|
153
176
|
render_result
|
154
177
|
end
|
155
178
|
|
data/lib/preact/version.rb
CHANGED
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.
|
4
|
+
version: 10.6.23
|
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-01-
|
11
|
+
date: 2022-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|