isomorfeus-preact 10.6.45 → 10.6.46
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/config.rb +1 -15
- data/lib/isomorfeus/preact_view_helper.rb +3 -7
- data/lib/isomorfeus/ssr.rb +4 -10
- data/lib/isomorfeus/top_level_ssr.rb +10 -1
- data/lib/preact/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6aa16242ab93d05f360dd9c8b3455dd2e4b4084835116cd8973356edde20d4c
|
4
|
+
data.tar.gz: b230de356c9524d886f9cbfed54edc39c5531d7531b205301358c19acb800809
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0c8247ff444a7f045eb80e6a6d575f957869f87b559df2dba16520ebfe92e2a46d15aee505e9dd908fd4ce061139ff8285a9a9cef7afb6cb75f43d2fd728f50
|
7
|
+
data.tar.gz: acd073c0cb7c199228efa51ed17c1b11612f20670a4cea63b2c382bce7bf1dfef37d43180332de482907b6778fb15cf2d347a5f4a5aa15cdb94e90b02d913635
|
@@ -17,10 +17,7 @@ module Isomorfeus
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def force_init!
|
20
|
-
|
21
|
-
Isomorfeus.initial_state_fetched = true
|
22
|
-
Redux::Store.preloaded_state = Isomorfeus.store.get_state
|
23
|
-
end
|
20
|
+
@initialized = true
|
24
21
|
Isomorfeus.force_init_store!
|
25
22
|
execute_init_classes
|
26
23
|
end
|
@@ -38,17 +35,6 @@ module Isomorfeus
|
|
38
35
|
self.send("#{key}=", value)
|
39
36
|
end
|
40
37
|
|
41
|
-
# only used for SSR
|
42
|
-
def cached_component_classes
|
43
|
-
@cached_component_classes ||= {}
|
44
|
-
end
|
45
|
-
|
46
|
-
# only used for SSR
|
47
|
-
def cached_component_class(class_name)
|
48
|
-
return cached_component_classes[class_name] if cached_component_classes.key?(class_name)
|
49
|
-
cached_component_classes[class_name] = "::#{class_name}".constantize
|
50
|
-
end
|
51
|
-
|
52
38
|
def execute_init_classes
|
53
39
|
client_init_class_names.each do |constant|
|
54
40
|
constant.constantize.send(:init)
|
@@ -58,7 +58,7 @@ module Isomorfeus
|
|
58
58
|
# execute first render pass
|
59
59
|
begin
|
60
60
|
pass += 1
|
61
|
-
has_transport,
|
61
|
+
has_transport, need_further_pass, exception = ctx.exec(javascript)
|
62
62
|
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
63
63
|
rescue Exception => e
|
64
64
|
Isomorfeus.raise_error(error: e)
|
@@ -95,14 +95,10 @@ module Isomorfeus
|
|
95
95
|
Isomorfeus.raise_error(message: "Server Side Rendering: #{exception['message']}", stack: exception['stack']) if exception
|
96
96
|
else
|
97
97
|
start_time = Time.now
|
98
|
-
script_key = if has_transport
|
98
|
+
script_key = if has_transport
|
99
99
|
:still_busy
|
100
|
-
elsif has_transport
|
101
|
-
:transport_busy
|
102
|
-
elsif has_store
|
103
|
-
:store_busy
|
104
100
|
else
|
105
|
-
|
101
|
+
:store_busy
|
106
102
|
end
|
107
103
|
while need_further_pass
|
108
104
|
# execute further render passes
|
data/lib/isomorfeus/ssr.rb
CHANGED
@@ -11,7 +11,6 @@ module Isomorfeus
|
|
11
11
|
global.Exception = false;
|
12
12
|
global.IsomorfeusSessionId = session_id;
|
13
13
|
global.HasTransport = (typeof global.Opal.Isomorfeus.Transport !== 'undefined') && (api_ws_path !== '');
|
14
|
-
global.HasStore = typeof global.Opal.Isomorfeus.store !== 'undefined';
|
15
14
|
global.Opal.Isomorfeus['$env='](env);
|
16
15
|
if (typeof global.Opal.Isomorfeus["$current_locale="] === 'function') { global.Opal.Isomorfeus["$current_locale="](locale); }
|
17
16
|
global.Opal.Isomorfeus['$force_init!']();
|
@@ -22,8 +21,7 @@ module Isomorfeus
|
|
22
21
|
global.Opal.send(global.Opal.Isomorfeus.Transport.$promise_connect(global.IsomorfeusSessionId), 'then', [], ($$1 = function(){
|
23
22
|
try {
|
24
23
|
global.RenderedTree = global.Opal.Isomorfeus.TopLevel.$render_component_to_string(component_name, props);
|
25
|
-
|
26
|
-
global.NeedFurtherPass = (nfp == nil) ? false : nfp;
|
24
|
+
global.NeedFurtherPass = self.still_busy();
|
27
25
|
global.FirstPassFinished = true;
|
28
26
|
} catch (e) {
|
29
27
|
global.Exception = e;
|
@@ -33,16 +31,13 @@ module Isomorfeus
|
|
33
31
|
} else {
|
34
32
|
try {
|
35
33
|
global.RenderedTree = global.Opal.Isomorfeus.TopLevel.$render_component_to_string(component_name, props);
|
36
|
-
|
37
|
-
let nfp = global.Opal.Isomorfeus.store['$recently_dispatched?']();
|
38
|
-
global.NeedFurtherPass = (nfp == nil) ? false : nfp;
|
39
|
-
}
|
34
|
+
global.NeedFurtherPass = self.store_busy();
|
40
35
|
} catch (e) {
|
41
36
|
global.Exception = e;
|
42
37
|
global.NeedFurtherPass = false;
|
43
38
|
}
|
44
39
|
};
|
45
|
-
return [global.HasTransport, global.
|
40
|
+
return [global.HasTransport, global.NeedFurtherPass, global.Exception ? { message: global.Exception.message, stack: global.Exception.stack } : false];
|
46
41
|
}
|
47
42
|
|
48
43
|
self.first_pass_result = function() {
|
@@ -66,8 +61,7 @@ module Isomorfeus
|
|
66
61
|
}
|
67
62
|
let application_state = global.Opal.Isomorfeus.store.native.getState();
|
68
63
|
if (typeof global.NanoCSSInstance !== 'undefined') { ssr_styles = global.NanoCSSInstance.raw }
|
69
|
-
|
70
|
-
global.NeedFurtherPass = (nfp == nil) ? false : nfp;
|
64
|
+
global.NeedFurtherPass = ((global.HasTransport && global.Opal.Isomorfeus.Transport["$busy?"]()) || self.store_busy());
|
71
65
|
return [rendered_tree, application_state, ssr_styles, global.Opal.Isomorfeus['$ssr_response_status'](), global.NeedFurtherPass, global.Exception ? { message: global.Exception.message, stack: global.Exception.stack } : false];
|
72
66
|
}
|
73
67
|
|
@@ -21,9 +21,18 @@ module Isomorfeus
|
|
21
21
|
component = component_name;
|
22
22
|
}
|
23
23
|
}
|
24
|
-
component =
|
24
|
+
component = cached_component_class(component_name) unless component
|
25
25
|
Preact.render_to_string(Preact.create_element(component, `Opal.Hash.$new(props)`))
|
26
26
|
end
|
27
|
+
|
28
|
+
def cached_component_classes
|
29
|
+
@cached_component_classes ||= {}
|
30
|
+
end
|
31
|
+
|
32
|
+
def cached_component_class(class_name)
|
33
|
+
return cached_component_classes[class_name] if cached_component_classes.key?(class_name)
|
34
|
+
cached_component_classes[class_name] = "::#{class_name}".constantize
|
35
|
+
end
|
27
36
|
end
|
28
37
|
end
|
29
38
|
end
|
data/lib/preact/version.rb
CHANGED