upkeep-rails 0.2.4-x86_64-linux-gnu → 0.2.5-x86_64-linux-gnu

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: e80237db7311d234e7af7393ecdcaff8b2131759aadfc85165ca3487063fd527
4
- data.tar.gz: 8ae13e3a3f231954ab181c58453b685182212a021bc4ceec676b7c98d31762b3
3
+ metadata.gz: 828ee508a8bffaea1d061057621788c05b28375c72b4e6f0e5eddcae41bab13e
4
+ data.tar.gz: a9da18d5ab2c950d61ad77d56b4b137d72eb48be5c9664581d8413b87cc8d337
5
5
  SHA512:
6
- metadata.gz: 6d28d048fe9e6c95745347ea89525fc3b3f140195f0c3d073e28640d961bf745ab7fddd1ffacfd7367fa82ee375783fec8ea666174732a83a9e12fb965442d82
7
- data.tar.gz: 4408218499b208688620e6decf412a4767d1582f04a7a898afbfb2ad4281d637ab09b132b2e1137beff099b682870093a8f4f32b6ae63ccd6f665e611781417a
6
+ metadata.gz: e01080f38b260266eb73bc6725a893a6e5de2fe2e8e5788ac557831179a2238a6fc4cd393f7b7fb9a34c6ca28daecb41e2fda4f63bba489c89d3cc9eb72f2032
7
+ data.tar.gz: d0306f0eaf0a870fde1c599cb822d624a6b5fed96ca78bd3040400ea3fb8ccc6392a0e75fd3df4b1926116dd56ddb92819c2069518fc6e918b5c5ea66810e276
data/README.md CHANGED
@@ -47,7 +47,7 @@ bin/rails db:migrate
47
47
 
48
48
  This creates the subscription tables, writes an initializer, mounts ActionCable if needed, and imports the browser client.
49
49
 
50
- Requirements: Ruby 3.2+, Rails 7.1+, Turbo 2.0+.
50
+ Requirements: Ruby 3.2+, Rails 7.1+, `turbo-rails` 2.x, and Turbo JavaScript 8.x.
51
51
 
52
52
  Releases are precompiled for `x86_64-linux-gnu`, `aarch64-linux-gnu`,
53
53
  `x86_64-darwin`, `arm64-darwin`, and `x64-mingw-ucrt`. Installing Upkeep does
@@ -64,7 +64,7 @@ bin/rails generate upkeep:install
64
64
  bin/rails db:migrate
65
65
  ```
66
66
 
67
- The installer creates the subscription tables, writes an initializer, and imports the browser client. Requirements are Ruby 3.2+, Rails 7.1+, and Turbo 2.0+.
67
+ The installer creates the subscription tables, writes an initializer, and imports the browser client. Requirements are Ruby 3.2+, Rails 7.1+, `turbo-rails` 2.x, and Turbo JavaScript 8.x.
68
68
 
69
69
  ### Declaring identities: the one new concept
70
70
 
data/docs/how-it-works.md CHANGED
@@ -152,13 +152,13 @@ Page-level fallbacks use Turbo Stream `refresh method="morph"
152
152
  scroll="preserve"` instead of replacing `<html>` or writing a new document from
153
153
  JavaScript.
154
154
 
155
- When a change was committed while handling a browser request, the refresh tag
156
- also carries that request's Turbo id as `request-id` (from
157
- `Turbo.current_request_id` or the `X-Turbo-Request-Id` header). Turbo's client
158
- ignores refreshes for its own recent requests, so a write performed during a
159
- page view view tracking, for example cannot refresh the viewer who caused
160
- it into a self-refresh loop. Writes from jobs or the console carry no request
161
- id and refresh everyone.
155
+ When a change was committed while handling a GET or HEAD request, the refresh
156
+ tag also carries that request's Turbo id as `request-id` (from
157
+ `Turbo.current_request_id` or the `X-Turbo-Request-Id` header). Turbo 8's client
158
+ ignores refreshes for its own recent requests, so view tracking cannot refresh
159
+ the viewer who caused it into a self-refresh loop. Mutations omit the request id
160
+ so the originating tab still refreshes when its response does not render every
161
+ affected region. Writes from jobs or the console also refresh everyone.
162
162
 
163
163
  ## Deoptimization
164
164
 
@@ -117,20 +117,11 @@ function renderStreamMessage(data) {
117
117
  }
118
118
  }
119
119
 
120
- function installRefreshAction() {
120
+ function assertTurboCompatibility() {
121
121
  const turbo = window.Turbo
122
- if (!turbo?.StreamActions || turbo.StreamActions.refresh) return
122
+ if (!turbo || turbo.StreamActions?.refresh) return
123
123
 
124
- turbo.StreamActions.refresh = function () {
125
- const preserveScroll = this.getAttribute("scroll") === "preserve"
126
- const scrollPosition = preserveScroll ? [window.scrollX, window.scrollY] : null
127
-
128
- if (scrollPosition) {
129
- document.addEventListener("turbo:load", () => window.scrollTo(...scrollPosition), { once: true })
130
- }
131
-
132
- turbo.visit(window.location.href, { action: "replace", shouldCacheSnapshot: false })
133
- }
124
+ throw new Error("Upkeep requires Turbo 8 or newer")
134
125
  }
135
126
 
136
127
  class UpkeepSubscriptionSourceElement extends HTMLElement {
@@ -288,7 +279,7 @@ document.addEventListener("turbo:before-visit", resetFrameFetches)
288
279
  document.addEventListener("turbo:load", connectUpkeepSubscriptions)
289
280
 
290
281
  export function connectUpkeepSubscriptions() {
291
- installRefreshAction()
282
+ assertTurboCompatibility()
292
283
  ensureSourceElement()
293
284
  document.querySelectorAll(SOURCE_SELECTOR).forEach((source) => {
294
285
  source.connectStreamSource?.()
@@ -26,7 +26,7 @@ module Upkeep
26
26
  def upkeep_reactive_request?
27
27
  return true if Upkeep::Rails.configuration.request_activation == :all
28
28
 
29
- self.class.upkeep_reactive_actions.include?(action_name)
29
+ self.class.upkeep_reactive_actions.include?(action_name) || upkeep_reactive_continuation_request?
30
30
  end
31
31
 
32
32
  module_function
@@ -129,11 +129,11 @@ module Upkeep
129
129
  result
130
130
  end
131
131
 
132
- # Changes committed while handling this request carry the originating Turbo
133
- # request id, so the client that caused them ignores its own refresh delivery
134
- # (Turbo's recentRequests debounce). Breaks self-refresh loops from writes
135
- # during GETs, e.g. view tracking.
132
+ # GET writes can otherwise self-refresh in a loop. Mutation deliveries must
133
+ # still reach the originating tab when the response omits an affected region.
136
134
  def upkeep_stamp_change_request_id(changes)
135
+ return changes unless request.get? || request.head?
136
+
137
137
  request_id = upkeep_turbo_request_id
138
138
  return changes unless request_id
139
139
 
@@ -173,6 +173,12 @@ module Upkeep
173
173
  upkeep_reactive_request? && request.format.html? && (request.get? || request.head?)
174
174
  end
175
175
 
176
+ def upkeep_reactive_continuation_request?
177
+ request.headers["Turbo-Frame"].present? &&
178
+ request.headers[ClientSubscription::ID_HEADER].present? &&
179
+ request.headers[ClientSubscription::TOKEN_HEADER].present?
180
+ end
181
+
176
182
  def request_capture_profile?
177
183
  ActiveSupport::Notifications.notifier.listening?(Upkeep::Rails::REQUEST_CAPTURE)
178
184
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Upkeep
4
- VERSION = "0.2.4"
4
+ VERSION = "0.2.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upkeep-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: x86_64-linux-gnu
6
6
  authors:
7
7
  - Felipe dos Anjos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-03 00:00:00.000000000 Z
11
+ date: 2026-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -302,7 +302,7 @@ licenses:
302
302
  - MIT
303
303
  metadata:
304
304
  homepage_uri: https://github.com/fc-anjos/upkeep-rails
305
- source_code_uri: https://github.com/fc-anjos/upkeep-rails/tree/v0.2.4
305
+ source_code_uri: https://github.com/fc-anjos/upkeep-rails/tree/v0.2.5
306
306
  bug_tracker_uri: https://github.com/fc-anjos/upkeep-rails/issues
307
307
  rubygems_mfa_required: 'true'
308
308
  post_install_message: