turbo-rails 2.0.10 → 2.0.12
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/assets/javascripts/turbo.js +500 -445
- data/app/assets/javascripts/turbo.min.js +7 -7
- data/app/assets/javascripts/turbo.min.js.map +1 -1
- data/app/channels/turbo/streams/broadcasts.rb +4 -2
- data/app/controllers/turbo/frames/frame_request.rb +1 -0
- data/app/controllers/turbo/native/navigation.rb +11 -8
- data/app/helpers/turbo/streams/action_helper.rb +7 -2
- data/app/models/concerns/turbo/broadcastable.rb +1 -1
- data/app/models/turbo/streams/tag_builder.rb +2 -2
- data/lib/turbo/engine.rb +1 -1
- data/lib/turbo/system_test_helper.rb +4 -4
- data/lib/turbo/version.rb +1 -1
- metadata +3 -3
@@ -38,8 +38,10 @@ module Turbo::Streams::Broadcasts
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def broadcast_action_to(*streamables, action:, target: nil, targets: nil, attributes: {}, **rendering)
|
41
|
-
|
42
|
-
|
41
|
+
attributes.deep_symbolize_keys! if RUBY_VERSION < "3"
|
42
|
+
|
43
|
+
broadcast_stream_to(*streamables, content: turbo_stream_action_tag(
|
44
|
+
action, target: target, targets: targets, template: render_broadcast_action(rendering), **attributes)
|
43
45
|
)
|
44
46
|
end
|
45
47
|
|
@@ -23,6 +23,7 @@ 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? }
|
26
27
|
|
27
28
|
helper_method :turbo_frame_request?, :turbo_frame_request_id
|
28
29
|
end
|
@@ -1,20 +1,23 @@
|
|
1
1
|
# Turbo is built to work with native navigation principles and present those alongside what's required for the web. When you
|
2
|
-
# have
|
3
|
-
# requests with three dedicated responses: <tt>recede</tt>, <tt>resume</tt>, <tt>refresh</tt>.
|
2
|
+
# have Hotwire Native clients running (see the Hotwire Native iOS and Hotwire Native Android projects for details),
|
3
|
+
# you can respond to native requests with three dedicated responses: <tt>recede</tt>, <tt>resume</tt>, <tt>refresh</tt>.
|
4
4
|
#
|
5
|
-
#
|
5
|
+
# Hotwire Native Android and Hotwire Native iOS handle these actions automatically.
|
6
6
|
module Turbo::Native::Navigation
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
helper_method :turbo_native_app?
|
10
|
+
helper_method :hotwire_native_app?, :turbo_native_app?
|
11
11
|
end
|
12
12
|
|
13
|
-
#
|
14
|
-
|
15
|
-
|
13
|
+
# Hotwire Native applications are identified by having the string "Hotwire Native" as part of their user agent.
|
14
|
+
# Legacy Turbo Native applications use the "Turbo Native" string.
|
15
|
+
def hotwire_native_app?
|
16
|
+
request.user_agent.to_s.match?(/(Turbo|Hotwire) Native/)
|
16
17
|
end
|
17
|
-
|
18
|
+
|
19
|
+
alias_method :turbo_native_app?, :hotwire_native_app?
|
20
|
+
|
18
21
|
# Tell the Turbo Native app to dismiss a modal (if presented) or pop a screen off of the navigation stack. Otherwise redirect to the given URL if Turbo Native is not present.
|
19
22
|
def recede_or_redirect_to(url, **options)
|
20
23
|
turbo_native_action_or_redirect url, :recede, :to, options
|
@@ -22,7 +22,12 @@ 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,
|
25
|
+
def turbo_stream_action_tag(action, attributes = {})
|
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)
|
26
31
|
template = action.to_sym.in?(%i[ remove refresh ]) ? "" : tag.template(template.to_s.html_safe)
|
27
32
|
|
28
33
|
if target = convert_to_turbo_stream_dom_id(target)
|
@@ -39,7 +44,7 @@ module Turbo::Streams::ActionHelper
|
|
39
44
|
# turbo_stream_refresh_tag
|
40
45
|
# # => <turbo-stream action="refresh"></turbo-stream>
|
41
46
|
def turbo_stream_refresh_tag(request_id: Turbo.current_request_id, **attributes)
|
42
|
-
turbo_stream_action_tag(:refresh,
|
47
|
+
turbo_stream_action_tag(:refresh, attributes.with_defaults({ "request-id": request_id }.compact))
|
43
48
|
end
|
44
49
|
|
45
50
|
private
|
@@ -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
|
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
|
@@ -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(**options)
|
244
|
+
turbo_stream_refresh_tag(**options)
|
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.
|
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}(*args, &block) # def visit(*args, &block)
|
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(*args, &block)
|
55
|
+
assert_selector(:turbo_cable_stream_source, *args, &block)
|
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(*args, &block)
|
79
|
+
assert_no_selector(:turbo_cable_stream_source, *args, &block)
|
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.12
|
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:
|
13
|
+
date: 2025-03-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
rubygems_version: 3.5.
|
113
|
+
rubygems_version: 3.5.22
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: The speed of a single-page web application without having to write any JavaScript.
|