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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ea6749866c7f8dc1f8a29c24c617d359e9b92c9c2d62557b32d475a4bbccdc8
4
- data.tar.gz: 81b36d010aab7e8691a78f25a6b98acc69dab5eb1d238ab7c342afab81d170e5
3
+ metadata.gz: c6b58bda075eda9a5f99024e0903349bded01f4e383f241c08108c73f012b124
4
+ data.tar.gz: d252c973002ce1bcc9359869a77c0800c2a6b94c813563019432a1490180cbd7
5
5
  SHA512:
6
- metadata.gz: 89a88fb47bb30c0b7119ea47b05734d5bdbed9dbe82413099316a29251ccdbabb55092760cf0473d6629326c89a4b50b585a2c023f62c48b771712a6c43395a4
7
- data.tar.gz: ac545bd664f6ac91a9245c447954d01821d70af98443c5764efc4d5c84c063b83d592049a857ac85f65bd24c3f8f200964b20a7e784644e1d67346b3a5728968
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(@props_json).to_s(36)
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: #{support.cache_key} (ttl was: #{ttl} seconds, now set to: #{support.redis_expiration_seconds} seconds)")
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svelte-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair