isomorfeus-react 16.9.1 → 16.9.2
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/react_view_helper.rb +52 -45
- data/lib/react/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: 36a1941b8bebb3eef585602735dc05d182dfe09b6ad1f5ba774ddb10790556bb
|
4
|
+
data.tar.gz: 549f3f98cc52b1f47aed4b6e7b0152d924a0827c868165ee5ada3099b4e7037d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a13a3fbcb9b37b09104e8397cf9e13e4e70f0d8fcd3cbc3e879369fb213880d0d3505ede782263702ab0d543197663d6b9000ddd27334a726bdf1695d248fc94
|
7
|
+
data.tar.gz: 06e9d53a8ac9d70125ac519835ad128ca3e47b54bef2eb4a5320116b92b294841403fe2c34f966321318c38588dfefea1822f3259f6294414304245459577faa
|
@@ -4,6 +4,7 @@ module Isomorfeus
|
|
4
4
|
thread_id_asset = "#{Thread.current.object_id}#{asset}"
|
5
5
|
render_result = "<div data-iso-env=\"#{Isomorfeus.env}\" data-iso-root=\"#{component_name}\" data-iso-props='#{Oj.dump(props, mode: :strict)}'"
|
6
6
|
if Isomorfeus.server_side_rendering
|
7
|
+
|
7
8
|
# initialize speednode context
|
8
9
|
unless Isomorfeus.ssr_contexts.key?(thread_id_asset)
|
9
10
|
asset_file_name = OpalWebpackLoader::Manifest.lookup_path_for(asset)
|
@@ -12,60 +13,66 @@ module Isomorfeus
|
|
12
13
|
end
|
13
14
|
|
14
15
|
# build javascript for rendering first pass
|
15
|
-
javascript = "global.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
ws_scheme = props[:location_scheme] == 'https:' ? 'wss:' : 'ws:'
|
23
|
-
javascript << <<~JAVASCRIPT
|
24
|
-
global.Opal.Isomorfeus.TopLevel["$transport_ws_url="]('#{ws_scheme}#{props[:location_host]}#{Isomorfeus.api_websocket_path}');
|
25
|
-
if (typeof global.Opal.Isomorfeus.Transport !== 'undefined') { global.Opal.Isomorfeus.Transport.$connect(); }
|
26
|
-
JAVASCRIPT
|
27
|
-
end
|
16
|
+
javascript = "global.FirstPassFinished = false;\n"
|
17
|
+
javascript << "global.Opal.Isomorfeus['$force_init!']();\n"
|
18
|
+
javascript << "global.Opal.Isomorfeus.TopLevel['$ssr_route_path=']('#{props[:location]}');\n"
|
19
|
+
|
20
|
+
# if location_host and scheme are given and if Transport is loaded, connect and then render, otherwise do not render
|
21
|
+
ws_scheme = props[:location_scheme] == 'https:' ? 'wss:' : 'ws:'
|
22
|
+
api_ws_path = Isomorfeus.respond_to?(:api_websocket_path) ? Isomorfeus.api_websocket_path : ''
|
28
23
|
javascript << <<~JAVASCRIPT
|
29
|
-
var
|
30
|
-
var
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}
|
24
|
+
var location_host = '#{props[:location_host]}';
|
25
|
+
var ws_scheme = '#{ws_scheme}';
|
26
|
+
var api_ws_path = '#{api_ws_path}';
|
27
|
+
if (typeof global.Opal.Isomorfeus.Transport !== 'undefined' && location_host !== '' && api_ws_path !== '') {
|
28
|
+
global.Opal.Isomorfeus.TopLevel["$transport_ws_url="](ws_scheme + location_host + api_ws_path);
|
29
|
+
global.Opal.send(global.Opal.Isomorfeus.Transport.$promise_connect(), 'then', [], ($$1 = function(){
|
30
|
+
try {
|
31
|
+
global.Opal.Isomorfeus.TopLevel.$render_component_to_string('#{component_name}', #{Oj.dump(props, mode: :strict)});
|
32
|
+
global.FirstPassFinished = 'transport';
|
33
|
+
} catch (e) { global.FirstPassFinished = 'transport'; }
|
34
|
+
}, $$1.$$s = this, $$1.$$arity = 0, $$1))
|
35
|
+
} else { global.FirstPassFinished = true };
|
42
36
|
JAVASCRIPT
|
37
|
+
|
43
38
|
# execute first render pass
|
44
|
-
|
39
|
+
Isomorfeus.ssr_contexts[thread_id_asset].exec(javascript)
|
45
40
|
|
46
|
-
|
47
|
-
|
41
|
+
# wait for first pass to finish
|
42
|
+
first_pass_finished = Isomorfeus.ssr_contexts[thread_id_asset].exec('return global.FirstPassFinished')
|
43
|
+
unless first_pass_finished
|
48
44
|
start_time = Time.now
|
49
|
-
while
|
45
|
+
while !first_pass_finished
|
50
46
|
break if (Time.now - start_time) > 10
|
51
47
|
sleep 0.01
|
52
|
-
|
48
|
+
first_pass_finished = Isomorfeus.ssr_contexts[thread_id_asset].exec('return global.FirstPassFinished')
|
53
49
|
end
|
54
|
-
# build javascript for second render pass
|
55
|
-
javascript = <<~JAVASCRIPT
|
56
|
-
var rendered_tree = global.Opal.Isomorfeus.TopLevel.$render_component_to_string('#{component_name}', #{Oj.dump(props, mode: :strict)})
|
57
|
-
var application_state = global.Opal.Isomorfeus.store.native.getState();
|
58
|
-
var transport_busy = false;
|
59
|
-
if (typeof global.Opal.Isomorfeus.Transport !== 'undefined') {
|
60
|
-
transport_busy = global.Opal.Isomorfeus.Transport['$busy?']();
|
61
|
-
global.Opal.Isomorfeus.Transport.$disconnect();
|
62
|
-
}
|
63
|
-
return [rendered_tree, application_state, transport_busy];
|
64
|
-
JAVASCRIPT
|
65
|
-
# execute second render pass
|
66
|
-
rendered_tree, application_state, _transport_busy = Isomorfeus.ssr_contexts[thread_id_asset].exec(javascript)
|
67
50
|
end
|
68
51
|
|
52
|
+
# wait for transport requests to finish
|
53
|
+
if first_pass_finished == 'transport'
|
54
|
+
transport_busy = Isomorfeus.ssr_contexts[thread_id_asset].exec('return global.Opal.Isomorfeus.Transport["$busy?"]()')
|
55
|
+
if transport_busy
|
56
|
+
start_time = Time.now
|
57
|
+
while transport_busy
|
58
|
+
break if (Time.now - start_time) > 10
|
59
|
+
sleep 0.01
|
60
|
+
transport_busy = Isomorfeus.ssr_contexts[thread_id_asset].exec('return global.Opal.Isomorfeus.Transport["$busy?"]()')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# build javascript for second render pass
|
66
|
+
javascript = <<~JAVASCRIPT
|
67
|
+
var rendered_tree = global.Opal.Isomorfeus.TopLevel.$render_component_to_string('#{component_name}', #{Oj.dump(props, mode: :strict)})
|
68
|
+
var application_state = global.Opal.Isomorfeus.store.native.getState();
|
69
|
+
if (typeof global.Opal.Isomorfeus.Transport !== 'undefined') { global.Opal.Isomorfeus.Transport.$disconnect(); }
|
70
|
+
return [rendered_tree, application_state];
|
71
|
+
JAVASCRIPT
|
72
|
+
|
73
|
+
# execute second render pass
|
74
|
+
rendered_tree, application_state = Isomorfeus.ssr_contexts[thread_id_asset].exec(javascript)
|
75
|
+
|
69
76
|
# build result
|
70
77
|
render_result << " data-iso-state='#{Oj.dump(application_state, mode: :strict)}'>"
|
71
78
|
render_result << rendered_tree
|
@@ -76,4 +83,4 @@ module Isomorfeus
|
|
76
83
|
render_result
|
77
84
|
end
|
78
85
|
end
|
79
|
-
end
|
86
|
+
end
|
data/lib/react/version.rb
CHANGED
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.9.
|
4
|
+
version: 16.9.2
|
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-08-
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|