svelte-on-rails 4.0.0 → 4.0.1
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/svelte_on_rails/lib/view_helper_support.rb +33 -34
- data/lib/svelte_on_rails/view_helpers.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: c6b58bda075eda9a5f99024e0903349bded01f4e383f241c08108c73f012b124
|
4
|
+
data.tar.gz: d252c973002ce1bcc9359869a77c0800c2a6b94c813563019432a1490180cbd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4299f254dbe525ad6a4725c75f5db2254883776a3479e137adfbefa4dbca4bd39421963458e73eb476c355c820a164e6ee28df1de9ae45443896f6bcc2c89ec1
|
7
|
+
data.tar.gz: fcbf455e8ab2b244b3dad582f01d822ed6d76f5bafdadc2fd6bc75eec08eaaa4aec456f9ea69afc9abc0b691f4628eab1049748a29a8b549ebeb07340f61c8ab
|
@@ -10,6 +10,7 @@ module SvelteOnRails
|
|
10
10
|
@start_time = Time.now
|
11
11
|
@filename = (file.match(/\.svelte$/) ? file[0..-8] : file)
|
12
12
|
@conf = SvelteOnRails::Configuration.instance
|
13
|
+
@all_arguments = props
|
13
14
|
@helper_options, @html_options, @props, @props_json = split_props(
|
14
15
|
props,
|
15
16
|
%i[class id style],
|
@@ -46,36 +47,7 @@ module SvelteOnRails
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def redis_expiration_seconds
|
49
|
-
(conf.redis_cache_store[:expires_in] || 1.hour).to_i
|
50
|
-
end
|
51
|
-
|
52
|
-
def split_props(props, html_options, helper_options)
|
53
|
-
prp = {}
|
54
|
-
hlp_opts = {}
|
55
|
-
ht_opts = {
|
56
|
-
data: {
|
57
|
-
svelte_component: "/#{conf.components_folder + filename}",
|
58
|
-
controller: 'svelte-on-rails',
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
props.each do |k, v|
|
63
|
-
_k = k.to_sym
|
64
|
-
if helper_options.include?(_k)
|
65
|
-
hlp_opts[_k] = v
|
66
|
-
elsif html_options.include?(_k)
|
67
|
-
ht_opts[_k] = v
|
68
|
-
else
|
69
|
-
prp[_k] = v
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
ht_opts[:class] = "#{ht_opts[:class]} svelte-component".strip
|
74
|
-
prp_js = prp.to_json
|
75
|
-
ht_opts[:data][:props] = prp_js
|
76
|
-
ht_opts[:data][:svelte_status] = 'do-not-hydrate-me' if hlp_opts[:hydrate] == false
|
77
|
-
|
78
|
-
[hlp_opts, ht_opts, prp, prp_js]
|
50
|
+
(conf.redis_cache_store[:expires_in] || @helper_options[:expires_in] || 1.hour).to_i
|
79
51
|
end
|
80
52
|
|
81
53
|
def elapsed_milliseconds
|
@@ -155,8 +127,6 @@ module SvelteOnRails
|
|
155
127
|
_ssr == :auto ? request.headers[conf.non_ssr_request_header].blank? : _ssr
|
156
128
|
end
|
157
129
|
|
158
|
-
private
|
159
|
-
|
160
130
|
def generate_cache_key
|
161
131
|
|
162
132
|
mtime_file = @conf.ssr_dist_folder.join('last_mtime')
|
@@ -172,7 +142,7 @@ module SvelteOnRails
|
|
172
142
|
"#{filename.split('/').last}.svelte",
|
173
143
|
Zlib.crc32(filename).to_s(36),
|
174
144
|
key2
|
175
|
-
].join('-')
|
145
|
+
].compact.join('-')
|
176
146
|
|
177
147
|
@cache_key_primary = [
|
178
148
|
conf.redis_cache_store[:namespace] ? conf.redis_cache_store[:namespace] : "svelte-on-rails:#{Rails.env}",
|
@@ -181,13 +151,42 @@ module SvelteOnRails
|
|
181
151
|
|
182
152
|
last_part = [
|
183
153
|
(@conf.watch_changes? ? Zlib.crc32(mtime).to_s(36) : nil),
|
184
|
-
Zlib.crc32(@
|
154
|
+
Zlib.crc32(@all_arguments.to_json).to_s(36)
|
185
155
|
].compact.join('-')
|
186
156
|
|
187
157
|
@cache_key = [@cache_key_primary, last_part].join(':')
|
188
158
|
|
189
159
|
end
|
190
160
|
|
161
|
+
def split_props(props, html_options, helper_options)
|
162
|
+
prp = {}
|
163
|
+
hlp_opts = {}
|
164
|
+
ht_opts = {
|
165
|
+
data: {
|
166
|
+
svelte_component: "/#{conf.components_folder + filename}",
|
167
|
+
controller: 'svelte-on-rails',
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
props.each do |k, v|
|
172
|
+
_k = k.to_sym
|
173
|
+
if helper_options.include?(_k)
|
174
|
+
hlp_opts[_k] = v
|
175
|
+
elsif html_options.include?(_k)
|
176
|
+
ht_opts[_k] = v
|
177
|
+
else
|
178
|
+
prp[_k] = v
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
ht_opts[:class] = "#{ht_opts[:class]} svelte-component".strip
|
183
|
+
prp_js = prp.to_json
|
184
|
+
ht_opts[:data][:props] = prp_js
|
185
|
+
ht_opts[:data][:svelte_status] = 'do-not-hydrate-me' if hlp_opts[:hydrate] == false
|
186
|
+
|
187
|
+
[hlp_opts, ht_opts, prp, prp_js]
|
188
|
+
end
|
189
|
+
|
191
190
|
end
|
192
191
|
end
|
193
192
|
end
|
@@ -31,7 +31,7 @@ module SvelteOnRails
|
|
31
31
|
# TTL
|
32
32
|
if support.debug?
|
33
33
|
ttl = redis.ttl(support.cache_key)
|
34
|
-
support.debug_log("Cache key:
|
34
|
+
support.debug_log("Cache key: «#{support.cache_key}» (ttl was: #{ttl} seconds, now set to: #{support.redis_expiration_seconds} seconds)")
|
35
35
|
end
|
36
36
|
redis.expire(support.cache_key, support.redis_expiration_seconds)
|
37
37
|
|