hotsock-turbo 0.4.1 → 0.5.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf52bbd2cf9e26d50d411c7856c8a44d29dc665061f77cf33f7bcbbae312b396
|
|
4
|
+
data.tar.gz: 3837c7cf9ed721257308bf489b3a0d10abbaad31ecf55a93d6dc082dc02d56de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 80ff73b6944ee96e9742adf861cdaecce891d5872f040ba8706ef2e569bfac5f9d5c2e7d82ba6d3bffeff7fa873c328017ba2a442c8a25e1c55b61df874419f8
|
|
7
|
+
data.tar.gz: f8d9ee1d2420547bd6617bd7f42a565ba69c6e8f2b4fd4bd7b50dbc840ab8a45ed43f33222dee060e52895817948163aaa6bb8c7c64d940159e7eeead93604bb
|
|
@@ -22,7 +22,9 @@ function createHotsockClient() {
|
|
|
22
22
|
const data = await response.json()
|
|
23
23
|
return data.token
|
|
24
24
|
},
|
|
25
|
-
lazyConnection:
|
|
25
|
+
lazyConnection:
|
|
26
|
+
document.querySelector('meta[name="hotsock:lazy-connection"]')
|
|
27
|
+
?.content === "true",
|
|
26
28
|
logLevel: document.querySelector('meta[name="hotsock:log-level"]')
|
|
27
29
|
?.content,
|
|
28
30
|
},
|
data/lib/hotsock/turbo/config.rb
CHANGED
|
@@ -3,16 +3,26 @@
|
|
|
3
3
|
module Hotsock
|
|
4
4
|
module Turbo
|
|
5
5
|
class Config
|
|
6
|
-
attr_accessor :parent_controller, :connect_token_path, :wss_url, :
|
|
6
|
+
attr_accessor :parent_controller, :connect_token_path, :wss_url, :lazy_connection, :override_turbo_broadcastable, :suppress_broadcasts
|
|
7
|
+
attr_writer :log_level
|
|
7
8
|
|
|
8
9
|
def initialize
|
|
9
10
|
@parent_controller = "ApplicationController"
|
|
10
11
|
@connect_token_path = nil
|
|
11
12
|
@wss_url = nil
|
|
12
|
-
@log_level =
|
|
13
|
+
@log_level = :default
|
|
14
|
+
@lazy_connection = false
|
|
13
15
|
@override_turbo_broadcastable = false
|
|
14
16
|
@suppress_broadcasts = false
|
|
15
17
|
end
|
|
18
|
+
|
|
19
|
+
def log_level
|
|
20
|
+
if @log_level == :default
|
|
21
|
+
defined?(Rails) && Rails.env.development? ? "debug" : "warn"
|
|
22
|
+
else
|
|
23
|
+
@log_level
|
|
24
|
+
end
|
|
25
|
+
end
|
|
16
26
|
end
|
|
17
27
|
end
|
|
18
28
|
end
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
module Hotsock
|
|
4
4
|
module Turbo
|
|
5
5
|
module StreamsHelper
|
|
6
|
-
def hotsock_turbo_meta_tags(connect_token_path: nil, wss_url: nil, log_level: nil)
|
|
6
|
+
def hotsock_turbo_meta_tags(connect_token_path: nil, wss_url: nil, log_level: nil, lazy_connection: nil)
|
|
7
7
|
config = Hotsock::Turbo.config
|
|
8
|
+
lazy = lazy_connection.nil? ? config.lazy_connection : lazy_connection
|
|
9
|
+
effective_log_level = log_level || config.log_level
|
|
8
10
|
tags = [
|
|
9
11
|
tag(:meta, name: "hotsock:connect-token-path", content: connect_token_path || config.connect_token_path),
|
|
10
|
-
tag(:meta, name: "hotsock:
|
|
12
|
+
(tag(:meta, name: "hotsock:lazy-connection", content: "true") if lazy),
|
|
13
|
+
(tag(:meta, name: "hotsock:log-level", content: effective_log_level) if effective_log_level),
|
|
11
14
|
tag(:meta, name: "hotsock:wss-url", content: wss_url || config.wss_url)
|
|
12
|
-
]
|
|
15
|
+
].compact
|
|
13
16
|
safe_join(tags, "\n")
|
|
14
17
|
end
|
|
15
18
|
|