svelte-on-rails 22.5.4 → 22.5.6

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: 1a6a1c4758093d4ee7080494a52d0a3709728dc830b7f0c261841363100ea593
4
- data.tar.gz: 18d316a0a47d9c780d3169acd3edc525f4a097864302182b1398173ffd26aba7
3
+ metadata.gz: ab6d571ef0c95edbc34868a44322a5fd65ce530ec4bf9d25abae20bb3f07cb6d
4
+ data.tar.gz: 875903772b806d6be74e66057cfb75c14d12e127a7024ab240be4d8e9b52f8c6
5
5
  SHA512:
6
- metadata.gz: af06be9fb96620f83701d90eb2745dc551329f25b1fceedf55e02f42150361f4d491b0ae5fb1279639761449a08dbab73861711c6776178d294bc84343f012c9
7
- data.tar.gz: c8c362043c2872cb7b4bf8b89de643daca6accfca5d5d7937ed726f3f49dea6babe3b5501c43a9c497be5eb843b4195832b0cf1a97e3e856d9e836605a3feda6
6
+ metadata.gz: 0bf76f5cc03cd13af95609c0a3e5d1ae7c5d6e9b899cad7f0fea2da9636a12cd8e015bf6e8f7fb5475d55a82f33ad3362123ee57c81e30b9cbecfb2f669586e5
7
+ data.tar.gz: 585f3cefa671842756b103dbafded674e47c217db31954044e42731dbe1648a293210b0b156ef8de842a74c24891a929c871121fd3d3da9e1d4b06d9032b0312
@@ -43,7 +43,7 @@ module SvelteOnRails
43
43
  # DEFAULTS
44
44
 
45
45
  rd = @configs[:redis_cache_store] && @configs[:redis_cache_store][:namespace]
46
- @redis_namespace ||= "#{rd || app_name}:svelte-on-rails:#{Rails.env rescue 'no-env'}"
46
+ @redis_namespace ||= "#{rd || app_name}:svelte-on-rails:#{Rails.env rescue 'no-env'}:"
47
47
  @configs[:skip_ssr_header] ||= 'X-Turbo-Request-ID'
48
48
  if defined? Redis
49
49
  @redis_instance = Redis.new(url: redis_cache_store[:url])
@@ -344,10 +344,11 @@ module SvelteOnRails
344
344
  fingerprint = (@conf.watch_changes? ? @conf.fingerprint(component_paths[:path], debug?, component_paths[:name]) : '')
345
345
 
346
346
  cache_key_raw = @options.to_s +
347
- @cached_props.to_s + fingerprint + @options[:cache_key].to_s +
348
- (@cached_props.key?(:_uncached) ? "" : @html_options.to_s)
347
+ @cached_props.to_s +
348
+ fingerprint +
349
+ @html_options.to_s
349
350
 
350
- "#{@conf.redis_namespace}:#{@component_name.gsub('/','-')}:#{Digest::XXH64.hexdigest(cache_key_raw)}"
351
+ "#{@conf.redis_namespace}#{@component_name.gsub('/','-')}:#{Digest::XXH64.hexdigest(cache_key_raw)}"
351
352
  end
352
353
  end
353
354
 
@@ -45,9 +45,9 @@ module SvelteOnRails
45
45
  support.render_cached(self) do
46
46
  rnd = support.render_svelte(@current_template)
47
47
  if rnd[:success]
48
+ support.log_completed("returned from cache, with uncached props#{', (Fallback!)' if rnd[:fallback]}")
48
49
  concat(rnd[:head].html_safe)
49
50
  concat(rnd[:html].html_safe)
50
- support.log_completed("returned from cache, with uncached props#{', (Fallback!)' if rnd[:fallback]}")
51
51
  elsif config.configs[:ssr_error_tag]
52
52
  sor_error_tag(support, wrapper_html, component_props, 'server-side-svelte-render-error', 'SVELTE RENDER FAILED')
53
53
  else
@@ -13,7 +13,7 @@ namespace :svelte_on_rails do
13
13
  end
14
14
 
15
15
  if Rails.env.production? && ENV["FORCE"] != "1"
16
- print "You are about to delete all keys matching «#{namespace}:*» in PRODUCTION. Continue? (y/N) "
16
+ print "You are about to delete all keys matching «#{namespace} in PRODUCTION. Continue? (y/N) "
17
17
  answer = STDIN.gets.to_s.strip.downcase
18
18
  unless %w[y yes].include?(answer)
19
19
  puts "Aborted."
@@ -21,7 +21,7 @@ namespace :svelte_on_rails do
21
21
  end
22
22
  end
23
23
 
24
- pattern = "#{namespace}:*"
24
+ pattern = "#{namespace}*"
25
25
  cursor = "0"
26
26
  total_deleted = 0
27
27
  batches = 0
@@ -51,16 +51,72 @@ namespace :svelte_on_rails do
51
51
 
52
52
  desc "Show all svelte-on-rails Redis keys with their memory footprint (scoped to redis_namespace). Env: LIMIT=n, SORT=size|key, PATTERN=extra-glob"
53
53
  task show: :environment do
54
+
55
+ _entries = entries
56
+
57
+ _entries.sort_by! { |e| -e[:bytes] }
58
+
59
+ key_w = [_entries.map { |e| e[:key].length }.max, 3].max
60
+ size_w = [_entries.map { |e| human_bytes(e[:bytes]).length }.max, 4].max
61
+ ttl_w = [_entries.map { |e| ttl_str(e[:ttl]).length }.max, 3].max
62
+ type_w = [_entries.map { |e| e[:type].to_s.length }.max, 4].max
63
+
64
+ header = format("%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s", "KEY", "SIZE", "TTL", "TYPE")
65
+ puts header
66
+ puts "-" * header.length
67
+
68
+ _entries.each do |e|
69
+ puts format(
70
+ "%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s",
71
+ e[:key], human_bytes(e[:bytes]), ttl_str(e[:ttl]), e[:type]
72
+ )
73
+ end
74
+
75
+ total_bytes = _entries.sum { |e| e[:bytes] }
76
+ puts "-" * header.length
77
+ puts "Total: #{_entries.size} key(s), #{human_bytes(total_bytes)} in RAM"
78
+ end
79
+
80
+ desc "Show contents of cached keys"
81
+ task show_contents: :environment do
82
+
83
+ entries.each do |e|
84
+ puts '='*120
85
+ puts "#{e[:key]} (#{human_bytes(e[:bytes])})"
86
+ puts '-'*120
87
+ puts SvelteOnRails::Configuration.instance.redis_instance.get(e[:key])
88
+ end
89
+
90
+ end
91
+
92
+ desc "Show only the svelte part (wrapping div stripped away) of cached keys"
93
+ task show_svelte: :environment do
94
+
95
+ entries.each do |e|
96
+
97
+ ht = SvelteOnRails::Configuration.instance.redis_instance.get(e[:key])
98
+ nok = Nokogiri::HTML(ht)
99
+
100
+ puts '='*120
101
+ puts "#{e[:key]} (#{human_bytes(e[:bytes])})"
102
+ puts '-'*120
103
+ puts nok.at_css('.svelte-component')&.inner_html
104
+ end
105
+
106
+ end
107
+
108
+
109
+ def entries
54
110
  conf = SvelteOnRails::Configuration.instance
55
111
  redis = conf.redis_instance
56
112
  namespace = conf.redis_namespace
57
113
 
58
114
  unless redis
59
115
  warn "svelte_on_rails:show_cache — no redis_instance configured, nothing to show."
60
- next
116
+ return []
61
117
  end
62
118
 
63
- pattern = "#{namespace}:*"
119
+ pattern = "#{namespace}*"
64
120
 
65
121
  puts "Scanning Redis for keys matching «#{pattern}» ..."
66
122
 
@@ -96,30 +152,9 @@ namespace :svelte_on_rails do
96
152
 
97
153
  if entries.empty?
98
154
  puts "No keys found under «#{pattern}»."
99
- next
100
- end
101
-
102
- entries.sort_by! { |e| -e[:bytes] }
103
-
104
- key_w = [entries.map { |e| e[:key].length }.max, 3].max
105
- size_w = [entries.map { |e| human_bytes(e[:bytes]).length }.max, 4].max
106
- ttl_w = [entries.map { |e| ttl_str(e[:ttl]).length }.max, 3].max
107
- type_w = [entries.map { |e| e[:type].to_s.length }.max, 4].max
108
-
109
- header = format("%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s", "KEY", "SIZE", "TTL", "TYPE")
110
- puts header
111
- puts "-" * header.length
112
-
113
- entries.each do |e|
114
- puts format(
115
- "%-#{key_w}s %#{size_w}s %#{ttl_w}s %-#{type_w}s",
116
- e[:key], human_bytes(e[:bytes]), ttl_str(e[:ttl]), e[:type]
117
- )
155
+ return []
118
156
  end
119
-
120
- total_bytes = entries.sum { |e| e[:bytes] }
121
- puts "-" * header.length
122
- puts "Total: #{entries.size} key(s), #{human_bytes(total_bytes)} in RAM"
157
+ entries
123
158
  end
124
159
  end
125
160
  end
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: 22.5.4
4
+ version: 22.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair