svelte-on-rails 22.1.0 → 22.2.0
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.rb +1 -1
- data/lib/svelte_on_rails/configuration.rb +1 -1
- data/lib/svelte_on_rails/installer/utils.rb +2 -2
- data/lib/svelte_on_rails/lib/utils.rb +25 -11
- data/lib/svelte_on_rails/lib/view_helper_support.rb +14 -13
- data/lib/svelte_on_rails/railtie.rb +1 -1
- data/lib/svelte_on_rails/{ssr_server.rb → ssr_client.rb} +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a32126c57f42015b2fae36849a77266d174dfc6234a5958c924b490e4c1efc47
|
|
4
|
+
data.tar.gz: b264887e056b7d3aeb763923d1f20eccdab81000bc1c7dae63b7c909397157c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec6ad182cd5a2f06c654017f2ddbc81fe07b07498339262b0ec145d7fbaa815d12abef5a681930080d8edaee57e536f036399e5df011c8e3d3413ecea9b0a5f7
|
|
7
|
+
data.tar.gz: e67beb89b3a4ed77bdb3d7cc39f54596769c1b9cd25d12b7db7341cf860176d0b9a633b6fba4e4703a2a48d42509a1b18a977345b0a91214cefe556c760766b2
|
data/lib/svelte-on-rails.rb
CHANGED
|
@@ -3,7 +3,7 @@ require "svelte_on_rails/view_helpers"
|
|
|
3
3
|
require "svelte_on_rails/turbo_stream"
|
|
4
4
|
require "svelte_on_rails/action_cable"
|
|
5
5
|
require "svelte_on_rails/active_record_extensions"
|
|
6
|
-
require "svelte_on_rails/
|
|
6
|
+
require "svelte_on_rails/ssr_client"
|
|
7
7
|
|
|
8
8
|
require "svelte_on_rails/railtie" if defined?(Rails)
|
|
9
9
|
|
|
@@ -179,7 +179,7 @@ module SvelteOnRails
|
|
|
179
179
|
|
|
180
180
|
def redis_cache_store_configs
|
|
181
181
|
if defined?(Rails.application) && Rails.application.config.cache_store.is_a?(Array) && Rails.application.config.cache_store.first == :redis_cache_store
|
|
182
|
-
{
|
|
182
|
+
{ redis_cache_store: Rails.application.config.cache_store.second.stringify_keys }
|
|
183
183
|
else
|
|
184
184
|
{}
|
|
185
185
|
end
|
|
@@ -274,7 +274,7 @@ module SvelteOnRails
|
|
|
274
274
|
def self.template_paths(templates, app_root: nil)
|
|
275
275
|
paths = []
|
|
276
276
|
app_root = app_root_path(app_root)
|
|
277
|
-
ssr_server_configured = SvelteOnRails::
|
|
277
|
+
ssr_server_configured = SvelteOnRails::SsrClient.instance.configured?
|
|
278
278
|
|
|
279
279
|
templates.each do |t|
|
|
280
280
|
templates_folder = File.expand_path("../../../templates", __dir__)
|
|
@@ -285,7 +285,7 @@ module SvelteOnRails
|
|
|
285
285
|
files.each do |f|
|
|
286
286
|
|
|
287
287
|
unless ssr_server_configured
|
|
288
|
-
next if File.basename(f) == File.basename(SvelteOnRails::
|
|
288
|
+
next if File.basename(f) == File.basename(SvelteOnRails::SsrClient.ssr_server_bin_path)
|
|
289
289
|
end
|
|
290
290
|
|
|
291
291
|
paths.push(
|
|
@@ -24,24 +24,38 @@ module SvelteOnRails
|
|
|
24
24
|
|
|
25
25
|
# Defining methods to log errors and warnings using Rails logger
|
|
26
26
|
def self.puts_error(text)
|
|
27
|
-
|
|
28
|
-
caller_info = caller[1] =~ /`([^']*)'/ ? $1 : "unknown"
|
|
29
|
-
Rails.logger.error(" => [SOR] #{caller_info} ERROR")
|
|
30
|
-
text.split("\n").each do |line|
|
|
31
|
-
Rails.logger.error(" => #{line}")
|
|
32
|
-
end
|
|
27
|
+
log_with_severity(:error, text, "ERROR", "\e[31m") # red
|
|
33
28
|
end
|
|
34
29
|
|
|
35
30
|
# Defining method to log warnings using Rails logger
|
|
36
31
|
def self.puts_warning(text)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
log_with_severity(:warn, text, "WARNING", "\e[33m")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Internal: emits a tagged, colored block via Rails.logger.
|
|
36
|
+
# ANSI colors are always included; modern terminals + the Rails
|
|
37
|
+
# dev logger render them. In production the logger strips them
|
|
38
|
+
# or they pass through harmlessly to aggregators.
|
|
39
|
+
def self.log_with_severity(level, text, label, color_code)
|
|
40
|
+
|
|
41
|
+
clear = "\e[0m"
|
|
42
|
+
bold = "\e[1m"
|
|
43
|
+
|
|
44
|
+
header = "#{color_code}#{bold}[SOR] #{label}#{clear}"
|
|
45
|
+
Rails.logger.public_send(level, header)
|
|
46
|
+
text.to_s.split("\n").each do |line|
|
|
47
|
+
Rails.logger.public_send(level, "#{color_code} => #{line}#{clear}")
|
|
42
48
|
end
|
|
43
49
|
end
|
|
44
50
|
|
|
51
|
+
def self.color_supported?
|
|
52
|
+
return false if Rails.env.production?
|
|
53
|
+
# Rails dev logger writes to STDOUT; check that it's a TTY.
|
|
54
|
+
$stdout.tty?
|
|
55
|
+
rescue
|
|
56
|
+
false
|
|
57
|
+
end
|
|
58
|
+
|
|
45
59
|
def self.component_paths_uncached(component, current_controller_path)
|
|
46
60
|
|
|
47
61
|
file_basename = File.basename(component, ".svelte")
|
|
@@ -47,19 +47,20 @@ module SvelteOnRails
|
|
|
47
47
|
[Svelte on Rails] Source file not found: «#{p[:path]}»
|
|
48
48
|
TEXT
|
|
49
49
|
end
|
|
50
|
-
if p[:path]
|
|
51
|
-
if !p[:file_basename].match?(/^[A-Z][A-Za-z0-9]
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
if p[:path].start_with?('app/views/')
|
|
51
|
+
if !p[:file_basename].match?(/^[A-Z][A-Za-z0-9]*$/) && !p[:file_basename].match?(/^_[a-z0-9][a-z0-9_]*$/)
|
|
52
|
+
@utils.puts_warning <<~TEXT
|
|
53
|
+
Invalid filename: «#{p[:file_basename]}»
|
|
54
|
+
Component names should be CamelCased, or under_scored and prefixed by an underscore (e.g. «_my_partial»).
|
|
55
|
+
See: https://svelte-on-rails.dev/naming.html
|
|
56
|
+
TEXT
|
|
57
57
|
end
|
|
58
|
-
elsif !p[:file_basename].match?(/^[A-Z][A-Za-z0-9]
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
elsif !p[:file_basename].match?(/^[A-Z][A-Za-z0-9]*$/)
|
|
59
|
+
@utils.puts_warning <<~TEXT
|
|
60
|
+
Invalid filename: «#{p[:file_basename]}»
|
|
61
|
+
Component names should be CamelCased.
|
|
62
|
+
See: https://svelte-on-rails.dev/naming.html
|
|
63
|
+
TEXT
|
|
63
64
|
end
|
|
64
65
|
full_path = Rails.root.join(p[:path])
|
|
65
66
|
dir, wanted = full_path.dirname.to_s, full_path.basename.to_s
|
|
@@ -232,7 +233,7 @@ module SvelteOnRails
|
|
|
232
233
|
def render_with_ssr_server(caller_loc)
|
|
233
234
|
return {} unless @conf.configs[:ssr_server]
|
|
234
235
|
|
|
235
|
-
result = SvelteOnRails::
|
|
236
|
+
result = SvelteOnRails::SsrClient.instance.render(
|
|
236
237
|
component_paths,
|
|
237
238
|
cached_props,
|
|
238
239
|
debug?,
|
|
@@ -21,7 +21,7 @@ module SvelteOnRails
|
|
|
21
21
|
SvelteOnRails::Lib::Utils.ssr_server_log("Skipping svelte-on-rails SSR-Server because of top level task: #{Rake.application.top_level_tasks.join(', ')}")
|
|
22
22
|
$stdout.flush
|
|
23
23
|
elsif SvelteOnRails::Configuration.instance.configs[:ssr]
|
|
24
|
-
SvelteOnRails::
|
|
24
|
+
SvelteOnRails::SsrClient.instance
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
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.
|
|
4
|
+
version: 22.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christian Sedlmair
|
|
@@ -97,7 +97,7 @@ files:
|
|
|
97
97
|
- lib/svelte_on_rails/lib/view_helper_support.rb
|
|
98
98
|
- lib/svelte_on_rails/lib/watch_asset_changes.rb
|
|
99
99
|
- lib/svelte_on_rails/railtie.rb
|
|
100
|
-
- lib/svelte_on_rails/
|
|
100
|
+
- lib/svelte_on_rails/ssr_client.rb
|
|
101
101
|
- lib/svelte_on_rails/turbo_stream.rb
|
|
102
102
|
- lib/svelte_on_rails/view_helpers.rb
|
|
103
103
|
- lib/tasks/svelte_on_rails_tasks.rake
|