sinatra-inertia 0.1.1 → 0.1.2
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/CHANGELOG.md +13 -0
- data/lib/sinatra/inertia/helpers.rb +14 -6
- data/lib/sinatra/inertia/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 52d1f4d245c4bc1d97964a1b6b92a8dc091cde035738df4b8fc1b8bcf8017b8f
|
|
4
|
+
data.tar.gz: 7237b568ccdb58addccffbcb20a51da0ade11d49ab2fa4dc35acc9c698444c1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 868d4070d399099ff8e31643d90aa8488dcd34dacf1e2e580c579547d0d599e4a3c117cf91e23e70cff58684be566ed4cd6c42857aae19f7c21bc0d3109a0c33
|
|
7
|
+
data.tar.gz: ff829335676a68745d9a2c450d24f53ac08798b089e547619a416e63e9695ca2f4038d5c5b8b2646acefa3a82d8ef9c94ce4a6241eb13ad9dbd2196998acf61f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.2 — 2026-04-29
|
|
4
|
+
|
|
5
|
+
- Fix: under Opal/Workers, the Inertia visit JSON body shipped with
|
|
6
|
+
`Content-Type: text/html` and missing `X-Inertia: true` /
|
|
7
|
+
`Vary: X-Inertia` headers. `Response#to_h` is an async function
|
|
8
|
+
(it `await`s any Proc-returned JS Promise), so the rest of the
|
|
9
|
+
`inertia` helper ran after a JS-level suspend; Sinatra finalised
|
|
10
|
+
the response with default headers before the awaited continuation
|
|
11
|
+
set them. We now set the protocol headers *before* touching
|
|
12
|
+
`to_h`, so the response's content type and Inertia headers are in
|
|
13
|
+
place regardless of how the runtime schedules the resumption.
|
|
14
|
+
Pure-MRI behaviour is unchanged.
|
|
15
|
+
|
|
3
16
|
## 0.1.1 — 2026-04-29
|
|
4
17
|
|
|
5
18
|
- Add `spec.metadata['homura.auto_await'] = 'true'` so that when this
|
|
@@ -31,6 +31,19 @@ module Sinatra
|
|
|
31
31
|
end
|
|
32
32
|
clear = @inertia_clear_history == true
|
|
33
33
|
|
|
34
|
+
# Set the protocol response headers BEFORE we touch any async
|
|
35
|
+
# `to_h` resolution. Under Opal, `Response#to_h` is an `async`
|
|
36
|
+
# function (it `await`s any Proc-returned JS Promise), so the
|
|
37
|
+
# rest of this method runs after a JS-level suspend. Setting
|
|
38
|
+
# `content_type` / `X-Inertia` before the suspend guarantees
|
|
39
|
+
# Sinatra's dispatch sees them when it finalises the response,
|
|
40
|
+
# regardless of how the underlying runtime schedules the
|
|
41
|
+
# awaited continuation.
|
|
42
|
+
if inertia_request?
|
|
43
|
+
content_type 'application/json; charset=utf-8'
|
|
44
|
+
headers 'X-Inertia' => 'true', 'Vary' => 'X-Inertia'
|
|
45
|
+
end
|
|
46
|
+
|
|
34
47
|
# Read errors *before* sweeping so the response carries them, then
|
|
35
48
|
# sweep immediately so the next request sees a clean slate. The
|
|
36
49
|
# sweep must happen before any further session writes that the
|
|
@@ -52,12 +65,7 @@ module Sinatra
|
|
|
52
65
|
page_hash = response_obj.to_h
|
|
53
66
|
page_json = page_hash.to_json
|
|
54
67
|
|
|
55
|
-
if inertia_request?
|
|
56
|
-
content_type 'application/json; charset=utf-8'
|
|
57
|
-
headers['X-Inertia'] = 'true'
|
|
58
|
-
headers['Vary'] = 'X-Inertia'
|
|
59
|
-
return page_json
|
|
60
|
-
end
|
|
68
|
+
return page_json if inertia_request?
|
|
61
69
|
|
|
62
70
|
@page = page_hash
|
|
63
71
|
@page_json = ::Rack::Utils.escape_html(page_json)
|