isomorfeus-preact 22.9.0.rc2 → 22.9.0.rc3

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: 1941d58313b84f914e1a02af158c082f7db2ff2dc807326937b2278ada18fe26
4
- data.tar.gz: c8201b7ee9f43842e5a08cafe1342444d351effc2e14607c8d40b809fee1db7d
3
+ metadata.gz: d21e147a89cb2cf3634e110df0fe606184d6b87d4069bdd1c20a6b8242cf11d7
4
+ data.tar.gz: e6bc52cb3de1d9058c5a7c260c103f1d09552fefa8508424cf04d4a9721a2227
5
5
  SHA512:
6
- metadata.gz: eaa0e1d7b8a55ddf4a2df7f1c84b042b5abe5d4be8eb88425fe58accebdea661d877dc7ad4c39d66419ade311951658b99670ba71d271bc5dd00f4f86a90250c
7
- data.tar.gz: dc7ec144d1c841d1a95a23b45458bbda2f0ae1ca12e6f516a40024a526be72a5e7b50a18aa0c700808caea085c8399ae1d87e8e1f0c4536fa8ba065830f0ea93
6
+ metadata.gz: fcfd20cd641399287821454d0d09c600ed51a660dd0efc949a5d585166c3c9a29794a4fb7e88271fb03d48aabb33109144e7c6912526b7bf49f302e5aa6b63a6
7
+ data.tar.gz: a4f55aae16d757584903b3114b77092b8509d759887596681c5935e178f2d1fa2bda97c1ecb8b719adde179bc3a3bebf27916381dce51e85f4b26a0837a10ce1
@@ -41,7 +41,6 @@ module Isomorfeus
41
41
  else # RUBY_ENGINE
42
42
  class << self
43
43
  attr_reader :component_cache_init_block
44
- attr_accessor :server_side_rendering
45
44
  attr_accessor :ssr_hot_asset_url
46
45
 
47
46
  def ssr_response_status
@@ -1,11 +1,6 @@
1
1
  module Isomorfeus
2
2
  class PreactSSR
3
- def self.mount_component(component_name, props, session_id, location, locale = nil)
4
- rendered_tree = new(component_name, props, session_id, location, locale).render
5
- [rendered_tree, Isomorfeus.store.get_state, NanoCSS.instance.renderer[:raw]]
6
- end
7
-
8
- def initialize(component_name, props, session_id, location, locale = nil)
3
+ def initialize(component_name, props, session_id, location, locale)
9
4
  @session_id = session_id
10
5
  @component_name = component_name
11
6
  @props = props
@@ -13,12 +8,14 @@ module Isomorfeus
13
8
  @locale = locale
14
9
  end
15
10
 
16
- def render
11
+ def render(skip_ssr)
17
12
  Isomorfeus.browser_location = Browser::Location.new(@location)
18
13
  Isomorfeus.current_locale = @locale
19
14
  NanoCSS.instance = NanoCSS.new(given_renderer: NanoCSS.global_instance.renderer.deep_dup)
20
15
  Isomorfeus.init_store
21
16
  Isomorfeus.store.clear!
17
+ Isomorfeus.store.dispatch(type: 'I18N_MERGE', data: { locale: @locale, domain: Isomorfeus.i18n_domain })
18
+ return '' if skip_ssr
22
19
  c = Isomorfeus.current_user
23
20
  if c.respond_to?(:reload)
24
21
  Thread.current[:isomorfeus_user] = LocalSystem.new
@@ -28,7 +25,13 @@ module Isomorfeus
28
25
  Thread.current[:isomorfeus_user] = c
29
26
  end
30
27
  end
31
- Isomorfeus::TopLevel.render_component_to_string(@component_name, @props)
28
+ render_component_to_string(@component_name, @props)
29
+ end
30
+
31
+ def render_component_to_string(component_name, props)
32
+ component = component_name.is_a?(String) ? self.class.const_get(component_name) : component_name
33
+ ::Preact._vnode_id = 0
34
+ ::Preact.render_to_string(::Preact.create_element(component, props))
32
35
  end
33
36
  end
34
37
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Preact
3
- VERSION = '22.9.0.rc2'
3
+ VERSION = '22.9.0.rc3'
4
4
  end
5
5
  end
@@ -4,46 +4,38 @@ module Preact
4
4
  base.include Isomorfeus::AssetManager::ViewHelper
5
5
  end
6
6
 
7
- def cached_mount_component(component_name, props = {}, skip_ssr: false, use_ssr: false, refresh: false)
7
+ def cached_mount_component(component_name, props = {}, skip_ssr: false, refresh: false)
8
8
  key = "#{Isomorfeus.current_user}#{component_name}#{props}"
9
9
  if !Isomorfeus.development? && !refresh
10
10
  render_result, @_ssr_styles, status = component_cache.fetch(key)
11
11
  Isomorfeus.ssr_response_status = status
12
12
  return render_result if render_result
13
13
  end
14
- render_result = mount_component(component_name, props, asset_key, skip_ssr: skip_ssr, use_ssr: use_ssr)
14
+ render_result = mount_component(component_name, props, asset_key, skip_ssr: skip_ssr)
15
15
  status = ssr_response_status
16
16
  component_cache.store(key, render_result, ssr_styles, status) if status >= 200 && status < 300
17
17
  render_result
18
18
  end
19
19
 
20
- def mount_component(component_name, props = {}, skip_ssr: false, use_ssr: false)
20
+ def mount_component(component_name, props = {}, skip_ssr: false)
21
21
  ssr_start_time = Time.now if Isomorfeus.development?
22
22
  @ssr_styles = nil
23
+ locale = props.delete(:locale)
23
24
  render_result = "<div data-iso-env=\"#{Isomorfeus.env}\" data-iso-root=\"#{component_name}\" data-iso-props='#{Oj.dump(props, mode: :strict)}'"
24
- if !skip_ssr && (Isomorfeus.server_side_rendering || use_ssr)
25
- location_host = props[:location_host] ? props[:location_host] : 'localhost'
26
- location = "#{props[:location_scheme] || 'http:'}//#{location_host}#{props[:location]}"
25
+ location_host = props[:location_host] ? props[:location_host] : 'localhost'
26
+ location = "#{props[:location_scheme] || 'http:'}//#{location_host}#{props[:location]}"
27
27
 
28
- rendered_tree, application_state, @_ssr_styles = Isomorfeus::PreactSSR.mount_component(component_name, props, Thread.current[:isomorfeus_session_id], location, props[:locale])
28
+ rendered_tree, application_state, @_ssr_styles = Isomorfeus::TopLevel.mount_component(component_name, props, Thread.current[:isomorfeus_session_id], location, locale, skip_ssr)
29
29
 
30
- render_result << " data-iso-hydrated='true'" if rendered_tree
31
- if Isomorfeus.respond_to?(:current_user) && Isomorfeus.current_user && !Isomorfeus.current_user.anonymous?
32
- render_result << " data-iso-usids=#{Oj.dump(Isomorfeus.current_user.sid.to_s, mode: :strict)}"
33
- end
34
- render_result << " data-iso-nloc='#{props[:locale]}'>"
35
- render_result << (rendered_tree ? rendered_tree : "SSR didn't work")
36
- else
37
- if Isomorfeus.respond_to?(:current_user) && Isomorfeus.current_user && !Isomorfeus.current_user.anonymous?
38
- render_result << " data-iso-usids=#{Oj.dump(Isomorfeus.current_user.sid.to_s, mode: :strict)}"
39
- end
40
- render_result << " data-iso-nloc='#{props[:locale]}'>"
30
+ render_result << " data-iso-hydrated='true'" unless skip_ssr
31
+ if Isomorfeus.respond_to?(:current_user) && Isomorfeus.current_user && !Isomorfeus.current_user.anonymous?
32
+ render_result << " data-iso-usids=#{Oj.dump(Isomorfeus.current_user.sid.to_s, mode: :strict)}"
41
33
  end
34
+ render_result << '>'
35
+ render_result << (rendered_tree ? rendered_tree : "SSR didn't work")
42
36
  render_result << '</div>'
43
- if Isomorfeus.server_side_rendering && !skip_ssr
44
- render_result = "<script type='application/javascript'>\nServerSideRenderingStateJSON = #{Oj.dump(application_state, mode: :strict)}\n</script>\n" << render_result
45
- puts "Preact::ViewHelper Server Side Rendering took ~#{((Time.now - ssr_start_time)*1000).to_i}ms" if Isomorfeus.development?
46
- end
37
+ render_result = "<script type='application/javascript'>\nServerSideRenderingStateJSON = #{Oj.dump(application_state, mode: :strict)}\n</script>\n" << render_result
38
+ puts "Preact::ViewHelper Server Side Rendering took ~#{((Time.now - ssr_start_time)*1000).to_i}ms" if Isomorfeus.development?
47
39
  render_result
48
40
  end
49
41
 
@@ -117,10 +117,9 @@ module Isomorfeus
117
117
  Isomorfeus.top_component = top
118
118
  end
119
119
  else
120
- def render_component_to_string(component_name, props)
121
- component = component_name.is_a?(String) ? const_get(component_name) : component_name
122
- ::Preact._vnode_id = 0
123
- ::Preact.render_to_string(::Preact.create_element(component, props))
120
+ def mount_component(component, props, session_id, location, locale, skip_ssr = false)
121
+ rendered_tree = Isomorfeus::PreactSSR.new(component, props, session_id, location, locale).render(skip_ssr)
122
+ [rendered_tree, Isomorfeus.store.get_state, NanoCSS.instance.renderer[:raw]]
124
123
  end
125
124
  end
126
125
  end
@@ -81,7 +81,6 @@ else
81
81
  Isomorfeus.ssr_hot_asset_url = 'http://localhost:3036/assets/'
82
82
  end
83
83
 
84
- Isomorfeus.server_side_rendering = true
85
84
  NanoCSS.instance = NanoCSS.new(nil)
86
85
 
87
86
  # cache
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-preact
3
3
  version: !ruby/object:Gem::Version
4
- version: 22.9.0.rc2
4
+ version: 22.9.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 22.9.0.rc2
61
+ version: 22.9.0.rc3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 22.9.0.rc2
68
+ version: 22.9.0.rc3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: isomorfeus-redux
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 22.9.0.rc2
75
+ version: 22.9.0.rc3
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 22.9.0.rc2
82
+ version: 22.9.0.rc3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: isomorfeus-puppetmaster
85
85
  requirement: !ruby/object:Gem::Requirement