Module: Isomorfeus
- Defined in:
- lib/isomorfeus/top_level.rb,
lib/isomorfeus/preact/config.rb,
lib/isomorfeus/top_level_ssr.rb,
lib/isomorfeus/preact/imports.rb,
lib/isomorfeus/props/validator.rb,
lib/isomorfeus/preact_view_helper.rb,
lib/isomorfeus/props/validate_hash_proxy.rb,
lib/isomorfeus/preact/redis_component_cache.rb,
lib/isomorfeus/preact/memcached_component_cache.rb,
lib/isomorfeus/preact/thread_local_component_cache.rb
Defined Under Namespace
Modules: Preact, PreactViewHelper, Props
Classes: TopLevel
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.component_cache_init_block ⇒ Object
Returns the value of attribute component_cache_init_block.
113
114
115
|
# File 'lib/isomorfeus/preact/config.rb', line 113
def component_cache_init_block
@component_cache_init_block
end
|
.current_user_sid ⇒ Object
Returns the value of attribute current_user_sid.
4
5
6
|
# File 'lib/isomorfeus/preact/config.rb', line 4
def current_user_sid
@current_user_sid
end
|
Returns the value of attribute env.
9
10
11
|
# File 'lib/isomorfeus/preact/config.rb', line 9
def env
@env
end
|
.initial_state_fetched ⇒ Object
Returns the value of attribute initial_state_fetched.
5
6
7
|
# File 'lib/isomorfeus/preact/config.rb', line 5
def initial_state_fetched
@initial_state_fetched
end
|
.initialized ⇒ Object
Returns the value of attribute initialized.
8
9
10
|
# File 'lib/isomorfeus/preact/config.rb', line 8
def initialized
@initialized
end
|
.server_side_rendering ⇒ Object
Returns the value of attribute server_side_rendering.
114
115
116
|
# File 'lib/isomorfeus/preact/config.rb', line 114
def server_side_rendering
@server_side_rendering
end
|
.ssr_hot_asset_url ⇒ Object
Returns the value of attribute ssr_hot_asset_url.
115
116
117
|
# File 'lib/isomorfeus/preact/config.rb', line 115
def ssr_hot_asset_url
@ssr_hot_asset_url
end
|
.ssr_response_status ⇒ Object
Returns the value of attribute ssr_response_status.
7
8
9
|
# File 'lib/isomorfeus/preact/config.rb', line 7
def ssr_response_status
@ssr_response_status
end
|
.top_component ⇒ Object
Returns the value of attribute top_component.
6
7
8
|
# File 'lib/isomorfeus/preact/config.rb', line 6
def top_component
@top_component
end
|
Returns the value of attribute zeitwerk.
10
11
12
|
# File 'lib/isomorfeus/preact/config.rb', line 10
def zeitwerk
@zeitwerk
end
|
.zeitwerk_lock ⇒ Object
Returns the value of attribute zeitwerk_lock.
117
118
119
|
# File 'lib/isomorfeus/preact/config.rb', line 117
def zeitwerk_lock
@zeitwerk_lock
end
|
Class Method Details
.add_client_init_after_store_class_name(init_class_name) ⇒ Object
32
33
34
|
# File 'lib/isomorfeus/preact/config.rb', line 32
def add_client_init_after_store_class_name(init_class_name)
client_init_after_store_class_names << init_class_name
end
|
.add_client_init_class_name(init_class_name) ⇒ Object
28
29
30
|
# File 'lib/isomorfeus/preact/config.rb', line 28
def add_client_init_class_name(init_class_name)
client_init_class_names << init_class_name
end
|
.add_client_option(key, value = nil) ⇒ Object
36
37
38
39
|
# File 'lib/isomorfeus/preact/config.rb', line 36
def add_client_option(key, value = nil)
self.class.attr_accessor(key)
self.send("#{key}=", value)
end
|
.cached_component_class(class_name) ⇒ Object
47
48
49
50
|
# File 'lib/isomorfeus/preact/config.rb', line 47
def cached_component_class(class_name)
return cached_component_classes[class_name] if cached_component_classes.key?(class_name)
cached_component_classes[class_name] = "::#{class_name}".constantize
end
|
.cached_component_classes ⇒ Object
42
43
44
|
# File 'lib/isomorfeus/preact/config.rb', line 42
def cached_component_classes
@cached_component_classes ||= {}
end
|
.component_cache_init(&block) ⇒ Object
119
120
121
|
# File 'lib/isomorfeus/preact/config.rb', line 119
def component_cache_init(&block)
@component_cache_init_block = block
end
|
.configuration(&block) ⇒ Object
123
124
125
|
# File 'lib/isomorfeus/preact/config.rb', line 123
def configuration(&block)
block.call(self)
end
|
.development? ⇒ Boolean
72
73
74
|
# File 'lib/isomorfeus/preact/config.rb', line 72
def development?
@development
end
|
.execute_init_after_store_classes ⇒ Object
58
59
60
61
62
|
# File 'lib/isomorfeus/preact/config.rb', line 58
def execute_init_after_store_classes
client_init_after_store_class_names.each do |constant|
constant.constantize.send(:init)
end
end
|
.execute_init_classes ⇒ Object
52
53
54
55
56
|
# File 'lib/isomorfeus/preact/config.rb', line 52
def execute_init_classes
client_init_class_names.each do |constant|
constant.constantize.send(:init)
end
end
|
.force_render ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/isomorfeus/preact/config.rb', line 89
def force_render
begin
if Isomorfeus.top_component
Preact.find_dom_node(Isomorfeus.top_component) if on_browser? || on_desktop? if `typeof Opal.global.deepForceUpdate === 'undefined'`
Isomorfeus.top_component.JS.forceUpdate()
else
`Opal.global.deepForceUpdate(#{Isomorfeus.top_component})`
end
end
rescue Exception => e
`console.error("force_render failed'! Error: " + #{e.message} + "! Reloading page.")`
`location.reload()` if on_browser?
end
nil
end
|
12
13
14
15
16
17
|
# File 'lib/isomorfeus/preact/config.rb', line 12
def init
return if initialized
@initialized = true
Isomorfeus.init_store
execute_init_classes
end
|
.load_configuration(directory) ⇒ Object
135
136
137
138
139
|
# File 'lib/isomorfeus/preact/config.rb', line 135
def load_configuration(directory)
Dir.glob(File.join(directory, '*.rb')).sort.each do |file|
require File.expand_path(file)
end
end
|
.production? ⇒ Boolean
76
77
78
|
# File 'lib/isomorfeus/preact/config.rb', line 76
def production?
@production
end
|
.raise_error(error: nil, error_class: nil, message: nil, stack: nil) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
# File 'lib/isomorfeus/preact/config.rb', line 144
def raise_error(error: nil, error_class: nil, message: nil, stack: nil)
error_class = error.class unless error == nil
error_class = RuntimeError unless error_class
execution_environment = if on_browser? then 'on Browser'
elsif on_ssr? then 'in Server Side Rendering'
elsif on_server? then 'on Server'
elsif on_mobile? then 'on Mobile'
elsif on_database? then 'on Database'
else
'on Client'
end
if error
message = error.message
stack = error.backtrace
else
error = error_class.new("Isomorfeus in #{env} #{execution_environment}:\n#{message}")
error.set_backtrace(stack) if stack
end
ecn = error_class ? error_class.name : ''
m = message ? message : ''
s = stack ? stack : ''
if RUBY_ENGINE == 'opal'
`console.error(ecn, m, s)` if Isomorfeus.development?
else
STDERR.puts "#{ecn}: #{m}\n #{s.is_a?(Array) ? s.join("\n") : s}"
end
raise error
end
|
.ssr_contexts ⇒ Object
127
128
129
|
# File 'lib/isomorfeus/preact/config.rb', line 127
def ssr_contexts
@ssr_contexts ||= {}
end
|
.test? ⇒ Boolean
80
81
82
|
# File 'lib/isomorfeus/preact/config.rb', line 80
def test?
@test
end
|
131
132
133
|
# File 'lib/isomorfeus/preact/config.rb', line 131
def version
Isomorfeus::VERSION
end
|