isomorfeus-preact 10.6.50 → 10.6.51
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/browser/history.rb +1 -0
- data/lib/isomorfeus/preact/imports.rb +3 -2
- data/lib/isomorfeus/preact/ssr/history.rb +23 -0
- data/lib/isomorfeus/preact/ssr/render_core.rb +103 -0
- data/lib/isomorfeus/{top_level_ssr.rb → preact/ssr/top_level.rb} +0 -0
- data/lib/isomorfeus/preact_view_helper.rb +19 -76
- data/lib/isomorfeus_preact/lucid_app/native_component_constructor.rb +1 -0
- data/lib/isomorfeus_preact/lucid_component/api.rb +7 -4
- data/lib/preact/component/callbacks.rb +7 -14
- data/lib/preact/version.rb +1 -1
- metadata +5 -4
- data/lib/isomorfeus/ssr.rb +0 -107
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dffa4d4b7dbec570b2548b38a5a842fca2def84c6601138157240035a49c767f
|
4
|
+
data.tar.gz: f469ef96052690c6c34c5538904907450883b841a176d7d2db908fa89af53f78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b8f47cace24c504437d92ec69862edfde48f9fa85696dad8c7f893de1d9fa92776f2fae775f51e8f4889b92fcb1902ce0b5d4e7f321f614c7be840eb56e4419
|
7
|
+
data.tar.gz: ad68c421f1f11598b9dc3b731a271969367f9460985c1e006f0659cf1c8d4d9b9a9f8cbcfb711f1f4f2e6593e3d7a5d23badb9c42d965dffcc7684815c651b66
|
data/lib/browser/history.rb
CHANGED
@@ -15,8 +15,9 @@ module Isomorfeus
|
|
15
15
|
if Dir.exist?(Isomorfeus.app_root)
|
16
16
|
if File.exist?(File.join(Isomorfeus.app_root, 'isomorfeus_loader.rb'))
|
17
17
|
Isomorfeus.add_common_ruby_import('isomorfeus_loader')
|
18
|
-
Isomorfeus.add_ssr_ruby_import('isomorfeus/
|
19
|
-
Isomorfeus.add_ssr_ruby_import('isomorfeus/ssr')
|
18
|
+
Isomorfeus.add_ssr_ruby_import('isomorfeus/preact/ssr/top_level')
|
19
|
+
Isomorfeus.add_ssr_ruby_import('isomorfeus/preact/ssr/render_core')
|
20
|
+
Isomorfeus.add_ssr_ruby_import('isomorfeus/preact/ssr/history')
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Browser
|
2
|
+
class History
|
3
|
+
def back; end
|
4
|
+
def forward; end
|
5
|
+
def go(a); end
|
6
|
+
|
7
|
+
def length
|
8
|
+
0
|
9
|
+
end
|
10
|
+
alias :size :length
|
11
|
+
|
12
|
+
def push_state(state, title = '', url = nil); end
|
13
|
+
def replace_state(state, title = '', url = nil); end
|
14
|
+
def scroll_restoration; end
|
15
|
+
def scroll_restoration=(s); end
|
16
|
+
|
17
|
+
def state
|
18
|
+
{}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Isomorfeus.browser_history = Browser::History.new
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module SSR
|
3
|
+
%x{
|
4
|
+
self.first_pass = function(component_name, props) {
|
5
|
+
if (global.HasTransport) {
|
6
|
+
let $$1;
|
7
|
+
global.Opal.send(global.Opal.Isomorfeus.Transport.$promise_connect(global.IsomorfeusSessionId), 'then', [], ($$1 = function(){
|
8
|
+
self.async_render_pass(component_name, props);
|
9
|
+
}, $$1.$$s = this, $$1.$$arity = 0, $$1))
|
10
|
+
} else {
|
11
|
+
self.async_render_pass(component_name, props);
|
12
|
+
};
|
13
|
+
}
|
14
|
+
|
15
|
+
self.async_render_pass = function(component_name, props) {
|
16
|
+
if (global.RenderPass < global.MaxPasses) {
|
17
|
+
self.render_pass(component_name, props);
|
18
|
+
if (global.Exception) {
|
19
|
+
self.finish_render();
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
setTimeout(self.check_and_render, 1, component_name, props);
|
23
|
+
} else { self.finish_render(); }
|
24
|
+
}
|
25
|
+
|
26
|
+
self.render_pass = function(component_name, props) {
|
27
|
+
const oper = global.Opal.Preact;
|
28
|
+
oper.render_buffer = [];
|
29
|
+
oper.active_components = [];
|
30
|
+
oper.active_redux_components = [];
|
31
|
+
global.NeedAnotherPass = false;
|
32
|
+
try {
|
33
|
+
global.RenderPass++;
|
34
|
+
global.RenderedTree = global.Opal.Isomorfeus.TopLevel.$render_component_to_string(component_name, props);
|
35
|
+
} catch (e) {
|
36
|
+
global.RenderedTree = 'exception';
|
37
|
+
global.Exception = e;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
self.check_and_render = function(component_name, props) {
|
42
|
+
if (self.still_busy()) {
|
43
|
+
global.NeedAnotherPass = true;
|
44
|
+
setTimeout(self.check_and_render, 1, component_name, props);
|
45
|
+
} else if (global.NeedAnotherPass) {
|
46
|
+
global.NeedAnotherPass = false;
|
47
|
+
self.async_render_pass(component_name, props);
|
48
|
+
} else { self.finish_render(); }
|
49
|
+
}
|
50
|
+
|
51
|
+
self.finish_render = function() {
|
52
|
+
global.Rendering = false;
|
53
|
+
if (global.HasTransport) { self.$disconnect_transport(); }
|
54
|
+
}
|
55
|
+
|
56
|
+
self.still_busy = function() {
|
57
|
+
if (global.Opal.Isomorfeus?.Transport?.["$busy?"]?.()) { return true; }
|
58
|
+
let nfp = global.Opal.Isomorfeus.store["$recently_dispatched?"]();
|
59
|
+
return (nfp == global.Opal.nil) ? false : nfp;
|
60
|
+
}
|
61
|
+
|
62
|
+
self.get_exception = function() {
|
63
|
+
if (global.Exception) { return { message: global.Exception.message, stack: global.Exception.stack }; }
|
64
|
+
else { return null; }
|
65
|
+
}
|
66
|
+
|
67
|
+
self.get_result = function() {
|
68
|
+
const opi = global.Opal.Isomorfeus;
|
69
|
+
let application_state = opi.store.native.getState();
|
70
|
+
let ssr_styles = global?.NanoCSSInstance?.raw;
|
71
|
+
return [global.RenderedTree, application_state, ssr_styles, opi['$ssr_response_status'](), global.RenderPass, self.get_exception()];
|
72
|
+
}
|
73
|
+
|
74
|
+
self.mount_component = function(session_id, env, locale, location, transport_ws_url, component_name, props, max_passes) {
|
75
|
+
const opi = global.Opal.Isomorfeus;
|
76
|
+
global.RenderPass = 0;
|
77
|
+
global.Rendering = true;
|
78
|
+
global.MaxPasses = max_passes;
|
79
|
+
global.IsomorfeusSessionId = session_id;
|
80
|
+
global.RenderedTree = null;
|
81
|
+
global.Exception = false;
|
82
|
+
global.HasTransport = (typeof opi.Transport !== 'undefined');
|
83
|
+
if (global.HasTransport) { opi.TopLevel["$transport_ws_url="](transport_ws_url); }
|
84
|
+
opi['$env='](env);
|
85
|
+
if (typeof opi["$current_locale="] === 'function') { opi["$current_locale="](locale); }
|
86
|
+
opi['$force_init!']();
|
87
|
+
opi['$ssr_response_status='](200);
|
88
|
+
opi.TopLevel['$ssr_route_path='](location);
|
89
|
+
|
90
|
+
self.first_pass(component_name, props);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
def self.disconnect_transport
|
95
|
+
Isomorfeus::Transport::RequestAgent.agents.each do |agent_id, agent|
|
96
|
+
agent.promise.reject() unless agent.promise.realized?
|
97
|
+
Isomorfeus::Transport::RequestAgent.del!(agent_id)
|
98
|
+
end
|
99
|
+
Isomorfeus::Transport.instance_variable_set(:@requests_in_progress, { requests: {}, agent_ids: {} })
|
100
|
+
Isomorfeus::Transport.disconnect
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
File without changes
|
@@ -23,21 +23,14 @@ module Isomorfeus
|
|
23
23
|
render_result = "<div data-iso-env=\"#{Isomorfeus.env}\" data-iso-root=\"#{component_name}\" data-iso-props='#{Oj.dump(props, mode: :strict)}'"
|
24
24
|
if !skip_ssr && (Isomorfeus.server_side_rendering || use_ssr)
|
25
25
|
thread_id_asset = "#{Thread.current.object_id}#{asset_key}"
|
26
|
-
|
27
|
-
|
26
|
+
begin
|
27
|
+
if Isomorfeus.development?
|
28
28
|
init_speednode_context(asset_key, thread_id_asset)
|
29
|
-
|
30
|
-
if e.message.include?('@hash[:js][:js][:raw]') # asset bundling did not yet finish
|
31
|
-
sleep 2
|
32
|
-
return mount_component(component_name, props, asset_key, skip_ssr: skip_ssr, use_ssr: use_ssr, max_passes: max_passes)
|
33
|
-
else
|
34
|
-
Isomorfeus.raise_error(message: "Server Side Rendering: Failed creating context for #{asset_key}. Error: #{e.message}", stack: e.backtrace)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
else
|
38
|
-
unless Isomorfeus.ssr_contexts.key?(thread_id_asset)
|
29
|
+
elsif !Isomorfeus.ssr_contexts.key?(thread_id_asset)
|
39
30
|
init_speednode_context(asset_key, thread_id_asset)
|
40
31
|
end
|
32
|
+
rescue Exception => e
|
33
|
+
Isomorfeus.raise_error(message: "Server Side Rendering: Failed creating context for #{asset_key}. Error: #{e.message}", stack: e.backtrace)
|
41
34
|
end
|
42
35
|
|
43
36
|
ctx = Isomorfeus.ssr_contexts[thread_id_asset]
|
@@ -51,76 +44,28 @@ module Isomorfeus
|
|
51
44
|
# build javascript for rendering first pass
|
52
45
|
# it will initialize buffers to guard against leaks, maybe caused by previous exceptions
|
53
46
|
javascript = <<~JAVASCRIPT
|
54
|
-
return Opal.Isomorfeus.SSR.
|
47
|
+
return Opal.Isomorfeus.SSR.mount_component('#{Thread.current[:isomorfeus_session_id]}', '#{Isomorfeus.env}', '#{props[:locale]}', '#{props[:location]}', '#{transport_ws_url}', '#{component_name}', #{Oj.dump(props, mode: :strict)}, #{max_passes})
|
55
48
|
JAVASCRIPT
|
56
49
|
|
57
|
-
finished = false
|
58
|
-
# execute first render pass
|
59
50
|
begin
|
60
|
-
|
61
|
-
has_transport, need_further_pass, exception = ctx.exec(javascript)
|
62
|
-
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
51
|
+
ctx.exec(javascript)
|
63
52
|
rescue Exception => e
|
64
53
|
Isomorfeus.raise_error(error: e)
|
65
54
|
end
|
66
55
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
first_pass_finished, need_further_pass, exception = ctx.eval_script(key: :first_pass_check)
|
71
|
-
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
72
|
-
unless first_pass_finished
|
73
|
-
start_time = Time.now
|
74
|
-
while !first_pass_finished
|
75
|
-
# break if (Time.now - start_time) > 10
|
76
|
-
sleep 0.005
|
77
|
-
first_pass_finished, need_further_pass, exception = ctx.eval_script(key: :first_pass_check)
|
78
|
-
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# wait for transport to settle
|
83
|
-
still_busy = ctx.eval_script(key: :still_busy)
|
84
|
-
if still_busy
|
85
|
-
start_time = Time.now
|
86
|
-
while still_busy
|
87
|
-
break if (Time.now - start_time) > 5
|
88
|
-
sleep 0.005
|
89
|
-
still_busy = ctx.eval_script(key: :still_busy)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
if !need_further_pass
|
95
|
-
rendered_tree, application_state, @ssr_styles, @ssr_response_status, exception = ctx.eval_script(key: :first_pass_result)
|
96
|
-
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
97
|
-
else
|
56
|
+
sleep 0.001 # give other threads that would respond to a request from node/SSR a chance to run
|
57
|
+
rendering = ctx.eval_script(key: :rendering)
|
58
|
+
if rendering
|
98
59
|
start_time = Time.now
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
# execute further render passes
|
104
|
-
pass += 1
|
105
|
-
rendered_tree, application_state, @ssr_styles, @ssr_response_status, need_further_pass, exception = ctx.exec(javascript)
|
106
|
-
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
107
|
-
if need_further_pass
|
108
|
-
sleep 0.001 # give other threads a chance
|
109
|
-
# break if (Time.now - start_time) > 5
|
110
|
-
still_busy = ctx.eval_script(key: :still_busy)
|
111
|
-
while still_busy
|
112
|
-
# break if (Time.now - start_time) > 5
|
113
|
-
sleep 0.005
|
114
|
-
still_busy = ctx.eval_script(key: :still_busy)
|
115
|
-
end
|
116
|
-
break if pass >= max_passes
|
117
|
-
else
|
118
|
-
break
|
119
|
-
end
|
60
|
+
while rendering
|
61
|
+
break if (Time.now - start_time) > 10
|
62
|
+
sleep 0.005
|
63
|
+
rendering = ctx.eval_script(key: :rendering)
|
120
64
|
end
|
121
65
|
end
|
122
66
|
|
123
|
-
ctx.eval_script(key: :
|
67
|
+
rendered_tree, application_state, @ssr_styles, @ssr_response_status, passes, exception = ctx.eval_script(key: :get_result)
|
68
|
+
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
124
69
|
|
125
70
|
render_result << " data-iso-hydrated='true'" if rendered_tree
|
126
71
|
if Isomorfeus.respond_to?(:current_user) && Isomorfeus.current_user && !Isomorfeus.current_user.anonymous?
|
@@ -137,7 +82,7 @@ module Isomorfeus
|
|
137
82
|
render_result << '</div>'
|
138
83
|
if Isomorfeus.server_side_rendering && !skip_ssr
|
139
84
|
render_result = "<script type='application/javascript'>\nServerSideRenderingStateJSON = #{Oj.dump(application_state, mode: :strict)}\n</script>\n" << render_result
|
140
|
-
puts "PreactViewHelper Server Side Rendering rendered #{
|
85
|
+
puts "PreactViewHelper Server Side Rendering rendered #{passes} passes and took ~#{((Time.now - ssr_start_time)*1000).to_i}ms" if Isomorfeus.development?
|
141
86
|
end
|
142
87
|
render_result
|
143
88
|
end
|
@@ -172,10 +117,8 @@ module Isomorfeus
|
|
172
117
|
asset_manager.transition(asset_key, asset)
|
173
118
|
Isomorfeus.ssr_contexts[thread_id_asset] = ExecJS.permissive_compile(asset.bundle)
|
174
119
|
ctx = Isomorfeus.ssr_contexts[thread_id_asset]
|
175
|
-
ctx.add_script(key: :
|
176
|
-
ctx.add_script(key: :
|
177
|
-
ctx.add_script(key: :still_busy, source: 'Opal.Isomorfeus.SSR.still_busy()')
|
178
|
-
ctx.add_script(key: :transport_disconnect, source: 'global.Opal.Isomorfeus.SSR.$disconnect_transport()')
|
120
|
+
ctx.add_script(key: :get_result, source: 'Opal.Isomorfeus.SSR.get_result()')
|
121
|
+
ctx.add_script(key: :rendering, source: 'global.Rendering')
|
179
122
|
end
|
180
123
|
end
|
181
124
|
|
@@ -8,6 +8,7 @@ module LucidApp::NativeComponentConstructor
|
|
8
8
|
base.css_styles = null;
|
9
9
|
base.css_theme = null;
|
10
10
|
base.preload_block = null;
|
11
|
+
base.preload_did_mount_proc = null;
|
11
12
|
base.while_loading_block = null;
|
12
13
|
|
13
14
|
base.preact_component = class extends Opal.global.Preact.Component {
|
@@ -11,12 +11,15 @@ module LucidComponent::Api
|
|
11
11
|
|
12
12
|
# preloading
|
13
13
|
def preload(&block)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
@_preload_promise.then { self.state.preloaded = true } if @_preload_promise
|
14
|
+
pdm_proc = proc do
|
15
|
+
if !self.state.preloaded && @_preload_promise
|
16
|
+
@_preload_promise.then { self.state.preloaded = true }
|
18
17
|
end
|
19
18
|
end
|
19
|
+
%x{
|
20
|
+
base.preload_block = block;
|
21
|
+
base.preload_did_mount_proc = pdm_proc;
|
22
|
+
}
|
20
23
|
end
|
21
24
|
|
22
25
|
def while_loading(option = nil, &block)
|
@@ -23,23 +23,16 @@ module Preact::Component::Callbacks
|
|
23
23
|
let fun = function() {
|
24
24
|
const oper = Opal.Preact;
|
25
25
|
oper.register_active_component(this);
|
26
|
-
try {
|
27
|
-
|
28
|
-
|
26
|
+
try { #{`this.__ruby_instance`.instance_exec(&block)}; }
|
27
|
+
catch (e) { console.error(e.message === Opal.nil ? 'error at' : e.message, e.stack); }
|
28
|
+
if (self.preload_did_mount_proc) { #{`this.__ruby_instance`.instance_exec { self.class.JS[:preload_did_mount_proc].call } } }
|
29
29
|
oper.unregister_active_component(this);
|
30
30
|
}
|
31
31
|
if (self.lucid_preact_component) {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
fun = function() {
|
37
|
-
this.componentDidMountOne();
|
38
|
-
this.componentDidMountTwo();
|
39
|
-
}
|
40
|
-
}
|
41
|
-
proto.componentDidMount = fun;
|
42
|
-
} else { self.preact_component.prototype.componentDidMount = fun; }
|
32
|
+
self.lucid_preact_component.prototype.componentDidMount = fun;
|
33
|
+
} else {
|
34
|
+
self.preact_component.prototype.componentDidMount = fun;
|
35
|
+
}
|
43
36
|
}
|
44
37
|
end
|
45
38
|
|
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.51
|
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-
|
11
|
+
date: 2022-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -229,13 +229,14 @@ files:
|
|
229
229
|
- lib/isomorfeus/preact/imports.rb
|
230
230
|
- lib/isomorfeus/preact/memcached_component_cache.rb
|
231
231
|
- lib/isomorfeus/preact/redis_component_cache.rb
|
232
|
+
- lib/isomorfeus/preact/ssr/history.rb
|
233
|
+
- lib/isomorfeus/preact/ssr/render_core.rb
|
234
|
+
- lib/isomorfeus/preact/ssr/top_level.rb
|
232
235
|
- lib/isomorfeus/preact/thread_local_component_cache.rb
|
233
236
|
- lib/isomorfeus/preact_view_helper.rb
|
234
237
|
- lib/isomorfeus/props/validate_hash_proxy.rb
|
235
238
|
- lib/isomorfeus/props/validator.rb
|
236
|
-
- lib/isomorfeus/ssr.rb
|
237
239
|
- lib/isomorfeus/top_level.rb
|
238
|
-
- lib/isomorfeus/top_level_ssr.rb
|
239
240
|
- lib/isomorfeus_preact/lucid_app/api.rb
|
240
241
|
- lib/isomorfeus_preact/lucid_app/base.rb
|
241
242
|
- lib/isomorfeus_preact/lucid_app/mixin.rb
|
data/lib/isomorfeus/ssr.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
module Isomorfeus
|
2
|
-
module SSR
|
3
|
-
%x{
|
4
|
-
self.first_pass = function(session_id, env, locale, location, transport_ws_url, component_name, props) {
|
5
|
-
const oper = global.Opal.Preact;
|
6
|
-
const opi = global.Opal.Isomorfeus;
|
7
|
-
oper.render_buffer = [];
|
8
|
-
oper.active_components = [];
|
9
|
-
oper.active_redux_components = [];
|
10
|
-
global.FirstPassFinished = false;
|
11
|
-
global.NeedFurtherPass = false;
|
12
|
-
global.RenderedTree = '';
|
13
|
-
global.Exception = false;
|
14
|
-
global.IsomorfeusSessionId = session_id;
|
15
|
-
global.HasTransport = (typeof opi.Transport !== 'undefined');
|
16
|
-
opi['$env='](env);
|
17
|
-
if (typeof opi["$current_locale="] === 'function') { opi["$current_locale="](locale); }
|
18
|
-
opi['$force_init!']();
|
19
|
-
opi['$ssr_response_status='](200);
|
20
|
-
opi.TopLevel['$ssr_route_path='](location);
|
21
|
-
if (global.HasTransport) {
|
22
|
-
opi.TopLevel["$transport_ws_url="](transport_ws_url);
|
23
|
-
let $$1;
|
24
|
-
global.Opal.send(opi.Transport.$promise_connect(global.IsomorfeusSessionId), 'then', [], ($$1 = function(){
|
25
|
-
try {
|
26
|
-
global.RenderedTree = opi.TopLevel.$render_component_to_string(component_name, props);
|
27
|
-
global.NeedFurtherPass = self.still_busy();
|
28
|
-
global.FirstPassFinished = true;
|
29
|
-
} catch (e) {
|
30
|
-
global.Exception = e;
|
31
|
-
global.FirstPassFinished = true;
|
32
|
-
global.NeedFurtherPass = false;
|
33
|
-
}
|
34
|
-
}, $$1.$$s = this, $$1.$$arity = 0, $$1))
|
35
|
-
global.NeedFurtherPass = true;
|
36
|
-
} else {
|
37
|
-
try {
|
38
|
-
global.RenderedTree = opi.TopLevel.$render_component_to_string(component_name, props);
|
39
|
-
global.NeedFurtherPass = self.store_busy();
|
40
|
-
} catch (e) {
|
41
|
-
global.Exception = e;
|
42
|
-
global.FirstPassFinished = true;
|
43
|
-
global.NeedFurtherPass = false;
|
44
|
-
}
|
45
|
-
};
|
46
|
-
return [global.HasTransport, global.NeedFurtherPass, self.get_exception()];
|
47
|
-
}
|
48
|
-
|
49
|
-
self.first_pass_check = function() {
|
50
|
-
return [global.FirstPassFinished, global.NeedFurtherPass, self.get_exception()];
|
51
|
-
}
|
52
|
-
|
53
|
-
self.first_pass_result = function() {
|
54
|
-
const opi = global.Opal.Isomorfeus;
|
55
|
-
let application_state = opi.store.native.getState();
|
56
|
-
let ssr_styles = global?.NanoCSSInstance?.raw;
|
57
|
-
return [global.RenderedTree, application_state, ssr_styles, opi['$ssr_response_status'](), self.get_exception()];
|
58
|
-
}
|
59
|
-
|
60
|
-
self.further_pass = function(component_name, props) {
|
61
|
-
const oper = global.Opal.Preact;
|
62
|
-
const opi = global.Opal.Isomorfeus;
|
63
|
-
oper.render_buffer = [];
|
64
|
-
oper.active_components = [];
|
65
|
-
oper.active_redux_components = [];
|
66
|
-
global.NeedFurtherPass = false;
|
67
|
-
global.Exception = false;
|
68
|
-
let application_state = null;
|
69
|
-
let rendered_tree = null;
|
70
|
-
let ssr_styles = null;
|
71
|
-
try {
|
72
|
-
rendered_tree = opi.TopLevel.$render_component_to_string(component_name, props);
|
73
|
-
application_state = opi.store.native.getState();
|
74
|
-
ssr_styles = global?.NanoCSSInstance?.raw;
|
75
|
-
global.NeedFurtherPass = self.still_busy();
|
76
|
-
} catch (e) {
|
77
|
-
global.Exception = e;
|
78
|
-
}
|
79
|
-
return [rendered_tree, application_state, ssr_styles, opi['$ssr_response_status'](), global.NeedFurtherPass, self.get_exception()];
|
80
|
-
}
|
81
|
-
|
82
|
-
self.get_exception = function() {
|
83
|
-
if (global.Exception) { return { message: global.Exception.message, stack: global.Exception.stack }; }
|
84
|
-
return false;
|
85
|
-
}
|
86
|
-
|
87
|
-
self.still_busy = function(){
|
88
|
-
if (global.Opal.Isomorfeus?.Transport?.["$busy?"]?.()) { return true; }
|
89
|
-
return self.store_busy();
|
90
|
-
}
|
91
|
-
|
92
|
-
self.store_busy = function() {
|
93
|
-
let nfp = global.Opal.Isomorfeus.store["$recently_dispatched?"]();
|
94
|
-
return (nfp == global.Opal.nil) ? false : nfp;
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
def self.disconnect_transport
|
99
|
-
Isomorfeus::Transport::RequestAgent.agents.each do |agent_id, agent|
|
100
|
-
agent.promise.reject() unless agent.promise.realized?
|
101
|
-
Isomorfeus::Transport::RequestAgent.del!(agent_id)
|
102
|
-
end
|
103
|
-
Isomorfeus::Transport.instance_variable_set(:@requests_in_progress, { requests: {}, agent_ids: {} })
|
104
|
-
Isomorfeus::Transport.disconnect
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|