turbo-rails 2.0.12 → 2.0.14
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/README.md +1 -1
- data/app/channels/turbo/streams/broadcasts.rb +3 -3
- data/app/controllers/turbo/frames/frame_request.rb +0 -1
- data/app/helpers/turbo/streams/action_helper.rb +2 -7
- data/app/models/concerns/turbo/broadcastable.rb +3 -3
- data/app/models/turbo/streams/tag_builder.rb +4 -2
- data/app/views/layouts/turbo_rails/frame.html.erb +1 -0
- data/lib/turbo/engine.rb +1 -1
- data/lib/turbo/system_test_helper.rb +4 -4
- data/lib/turbo/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e17d560cb33067c997c6cde1542866e726ab04635888c8f03e5c1617eb715939
|
4
|
+
data.tar.gz: adc7f9fb8409841348540ac39f68b1c0dd964d2ad2fa3bd98b14bdb83c92df95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d840efa50eb5ffad82cd4aaf6965a8c1e764072df5a884138162fc2a72eef6fef2ad00f16bcc8867d765c8c6eae5edeb1f983baef251ce81fc342930495deea
|
7
|
+
data.tar.gz: d66318b79505d8439adbae704a387740026d87f09d9b126d10db03d6d518d741c6b08de3bbadd568e9226cc245fbf213b999cfe5467ea16f8fb7b183b88e341a
|
data/README.md
CHANGED
@@ -182,7 +182,7 @@ import "@hotwired/turbo-rails"
|
|
182
182
|
|
183
183
|
You can watch [the video introduction to Hotwire](https://hotwired.dev/#screencast), which focuses extensively on demonstrating Turbo in a Rails demo. Then you should familiarize yourself with [Turbo handbook](https://turbo.hotwired.dev/handbook/introduction) to understand Drive, Frames, and Streams in-depth. Finally, dive into the code documentation by starting with [`Turbo::FramesHelper`](https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/frames_helper.rb), [`Turbo::StreamsHelper`](https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/streams_helper.rb), [`Turbo::Streams::TagBuilder`](https://github.com/hotwired/turbo-rails/blob/main/app/models/turbo/streams/tag_builder.rb), and [`Turbo::Broadcastable`](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb).
|
184
184
|
|
185
|
-
Note that in development, the default Action Cable adapter is the single-process `async` adapter. This means that turbo updates are only broadcast within that same process. So you can't start `bin/rails console` and trigger Turbo broadcasts and expect them to show up in a browser connected to a server running in a separate `bin/dev` or `bin/rails server` process. Instead, you should use the web-console when needing to
|
185
|
+
Note that in development, the default Action Cable adapter is the single-process `async` adapter. This means that turbo updates are only broadcast within that same process. So you can't start `bin/rails console` and trigger Turbo broadcasts and expect them to show up in a browser connected to a server running in a separate `bin/dev` or `bin/rails server` process. Instead, you should use the web-console when needing to manually trigger Turbo broadcasts inside the same process. Add "console" to any action or "<%= console %>" in any view to make the web console appear.
|
186
186
|
|
187
187
|
### RubyDoc Documentation
|
188
188
|
|
@@ -38,8 +38,6 @@ module Turbo::Streams::Broadcasts
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def broadcast_action_to(*streamables, action:, target: nil, targets: nil, attributes: {}, **rendering)
|
41
|
-
attributes.deep_symbolize_keys! if RUBY_VERSION < "3"
|
42
|
-
|
43
41
|
broadcast_stream_to(*streamables, content: turbo_stream_action_tag(
|
44
42
|
action, target: target, targets: targets, template: render_broadcast_action(rendering), **attributes)
|
45
43
|
)
|
@@ -70,8 +68,10 @@ module Turbo::Streams::Broadcasts
|
|
70
68
|
end
|
71
69
|
|
72
70
|
def broadcast_refresh_later_to(*streamables, request_id: Turbo.current_request_id, **opts)
|
71
|
+
stream_name = stream_name_from(streamables)
|
72
|
+
|
73
73
|
refresh_debouncer_for(*streamables, request_id: request_id).debounce do
|
74
|
-
Turbo::Streams::BroadcastStreamJob.perform_later
|
74
|
+
Turbo::Streams::BroadcastStreamJob.perform_later stream_name, content: turbo_stream_refresh_tag(request_id: request_id, **opts).to_str # Sidekiq requires job arguments to be valid JSON types, such as String
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -23,7 +23,6 @@ module Turbo::Frames::FrameRequest
|
|
23
23
|
included do
|
24
24
|
layout -> { "turbo_rails/frame" if turbo_frame_request? }
|
25
25
|
etag { :frame if turbo_frame_request? }
|
26
|
-
before_action { flash.keep if turbo_frame_request? }
|
27
26
|
|
28
27
|
helper_method :turbo_frame_request?, :turbo_frame_request_id
|
29
28
|
end
|
@@ -22,12 +22,7 @@ module Turbo::Streams::ActionHelper
|
|
22
22
|
# message = Message.find(1)
|
23
23
|
# turbo_stream_action_tag "remove", target: [message, :special]
|
24
24
|
# # => <turbo-stream action="remove" target="special_message_1"></turbo-stream>
|
25
|
-
def turbo_stream_action_tag(action,
|
26
|
-
attributes.deep_symbolize_keys! if RUBY_VERSION < "3"
|
27
|
-
|
28
|
-
target = attributes.delete(:target)
|
29
|
-
targets = attributes.delete(:targets)
|
30
|
-
template = attributes.delete(:template)
|
25
|
+
def turbo_stream_action_tag(action, target: nil, targets: nil, template: nil, **attributes)
|
31
26
|
template = action.to_sym.in?(%i[ remove refresh ]) ? "" : tag.template(template.to_s.html_safe)
|
32
27
|
|
33
28
|
if target = convert_to_turbo_stream_dom_id(target)
|
@@ -44,7 +39,7 @@ module Turbo::Streams::ActionHelper
|
|
44
39
|
# turbo_stream_refresh_tag
|
45
40
|
# # => <turbo-stream action="refresh"></turbo-stream>
|
46
41
|
def turbo_stream_refresh_tag(request_id: Turbo.current_request_id, **attributes)
|
47
|
-
turbo_stream_action_tag(:refresh,
|
42
|
+
turbo_stream_action_tag(:refresh, "request-id": request_id.presence, **attributes)
|
48
43
|
end
|
49
44
|
|
50
45
|
private
|
@@ -286,7 +286,7 @@ module Turbo::Broadcastable
|
|
286
286
|
#
|
287
287
|
# # sends <turbo-stream action="update" method="morph" target="clearance_5"><template><div id="clearance_5">Other partial</div></template></turbo-stream>
|
288
288
|
# # to the stream named "identity:2:clearances"
|
289
|
-
#
|
289
|
+
# clearance.broadcast_update_to examiner.identity, :clearances, attributes: { method: :morph }, partial: "clearances/other_partial", locals: { a: 1 }
|
290
290
|
def broadcast_update_to(*streamables, **rendering)
|
291
291
|
Turbo::StreamsChannel.broadcast_update_to(*streamables, **extract_options_and_add_target(rendering, target: self)) unless suppressed_turbo_broadcasts?
|
292
292
|
end
|
@@ -508,7 +508,7 @@ module Turbo::Broadcastable
|
|
508
508
|
self.class.broadcast_target_default
|
509
509
|
end
|
510
510
|
|
511
|
-
def extract_options_and_add_target(rendering, target: broadcast_target_default)
|
511
|
+
def extract_options_and_add_target(rendering = {}, target: broadcast_target_default)
|
512
512
|
broadcast_rendering_with_defaults(rendering).tap do |options|
|
513
513
|
options[:target] = target if !options.key?(:target) && !options.key?(:targets)
|
514
514
|
end
|
@@ -518,7 +518,7 @@ module Turbo::Broadcastable
|
|
518
518
|
options.tap do |o|
|
519
519
|
# Add the current instance into the locals with the element name (which is the un-namespaced name)
|
520
520
|
# as the key. This parallels how the ActionView::ObjectRenderer would create a local variable.
|
521
|
-
o[:locals] = (o[:locals] || {}).reverse_merge
|
521
|
+
o[:locals] = (o[:locals] || {}).reverse_merge(model_name.element.to_sym => self).compact
|
522
522
|
|
523
523
|
if o[:html] || o[:partial]
|
524
524
|
return o
|
@@ -240,8 +240,8 @@ class Turbo::Streams::TagBuilder
|
|
240
240
|
#
|
241
241
|
# turbo_stream.refresh request_id: "abc123"
|
242
242
|
# # => <turbo-stream action="refresh" request-id="abc123"></turbo-stream>
|
243
|
-
def refresh(
|
244
|
-
turbo_stream_refresh_tag(
|
243
|
+
def refresh(...)
|
244
|
+
turbo_stream_refresh_tag(...)
|
245
245
|
end
|
246
246
|
|
247
247
|
# Send an action of the type <tt>name</tt> to <tt>target</tt>. Options described in the concrete methods.
|
@@ -267,6 +267,8 @@ class Turbo::Streams::TagBuilder
|
|
267
267
|
content.render_in(@view_context, &block)
|
268
268
|
when content
|
269
269
|
allow_inferred_rendering ? (render_record(content) || content) : content
|
270
|
+
when block_given? && (rendering.key?(:partial) || rendering.key?(:layout))
|
271
|
+
@view_context.render(formats: [ :html ], layout: rendering[:partial], **rendering, &block)
|
270
272
|
when block_given?
|
271
273
|
@view_context.capture(&block)
|
272
274
|
when rendering.any?
|
data/lib/turbo/engine.rb
CHANGED
@@ -164,7 +164,7 @@ module Turbo
|
|
164
164
|
ActiveSupport.on_load(:action_dispatch_system_test_case) do
|
165
165
|
app.config.turbo.test_connect_after_actions.map do |method|
|
166
166
|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
167
|
-
def #{method}(
|
167
|
+
def #{method}(...) # def visit(...)
|
168
168
|
super.tap { connect_turbo_cable_stream_sources } # super.tap { connect_turbo_cable_stream_sources }
|
169
169
|
end # end
|
170
170
|
RUBY
|
@@ -51,8 +51,8 @@ module Turbo::SystemTestHelper
|
|
51
51
|
#
|
52
52
|
# In addition to the filters listed above, accepts any valid Capybara global
|
53
53
|
# filter option.
|
54
|
-
def assert_turbo_cable_stream_source(
|
55
|
-
assert_selector(:turbo_cable_stream_source,
|
54
|
+
def assert_turbo_cable_stream_source(...)
|
55
|
+
assert_selector(:turbo_cable_stream_source, ...)
|
56
56
|
end
|
57
57
|
|
58
58
|
# Asserts that a `<turbo-cable-stream-source>` element is absent from the
|
@@ -75,8 +75,8 @@ module Turbo::SystemTestHelper
|
|
75
75
|
#
|
76
76
|
# In addition to the filters listed above, accepts any valid Capybara global
|
77
77
|
# filter option.
|
78
|
-
def assert_no_turbo_cable_stream_source(
|
79
|
-
assert_no_selector(:turbo_cable_stream_source,
|
78
|
+
def assert_no_turbo_cable_stream_source(...)
|
79
|
+
assert_no_selector(:turbo_cable_stream_source, ...)
|
80
80
|
end
|
81
81
|
|
82
82
|
Capybara.add_selector :turbo_cable_stream_source do
|
data/lib/turbo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2025-
|
13
|
+
date: 2025-06-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 7.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: 7.1.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: railties
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 7.1.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 7.1.0
|
43
43
|
description:
|
44
44
|
email: david@loudthinking.com
|
45
45
|
executables: []
|
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: '3.1'
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - ">="
|