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: 8ed527ca97f2174b17323b76802d7a1a9f9466386ecb6070f2ecb3783fa6607e
4
- data.tar.gz: 9985fb1aa1871d56c2c8794c387d93879448cc2ab1d7ae8e418d2d8eae18a332
3
+ metadata.gz: cf52bbd2cf9e26d50d411c7856c8a44d29dc665061f77cf33f7bcbbae312b396
4
+ data.tar.gz: 3837c7cf9ed721257308bf489b3a0d10abbaad31ecf55a93d6dc082dc02d56de
5
5
  SHA512:
6
- metadata.gz: f5d14910a3fbfc8be8d777bcf76f52e9fd68202f823fc46ef08c1cc9f4b1871d087c99828d721272fac9ed15edb533d99ed137ddb2b1759354310dfca61b253a
7
- data.tar.gz: 8b91ee0067227d07eef255a3d6bcea28724ca30cd18623cb07c5b4bccf19265086e2b605953237554934a7d437d7282e0a561094fad85ffd524cf2a180e7e283
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: true,
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
  },
@@ -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, :log_level, :override_turbo_broadcastable, :suppress_broadcasts
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 = "warn"
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:log-level", content: log_level || config.log_level),
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Hotsock
4
4
  module Turbo
5
- VERSION = "0.4.1"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotsock-turbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Miller