sinatra-inertia 0.1.1 → 0.1.3
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 +22 -0
- data/lib/sinatra/inertia/async_sources.rb +2 -2
- 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: 3e51ad95f421e2dc7d2eadc72b2c17b06377e2a72748a591e09d48106500786e
|
|
4
|
+
data.tar.gz: 3f110beacd7e7eb6778440a800e6f31768d0cb44ff75546607a94ee22c50e066
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ab6eda91b4f83b63d90d3cd56281edb83222e99692396748544497dd5c4637aedaf8f557bf7777b3f03c743ab15c1ec483d50f8b88e415d15aef071aade9a47
|
|
7
|
+
data.tar.gz: 4d1b984e23f72254fad4e1a6da82498cb35ca8f26f5270c5ab1ddaa4149118926a1c9a00ce5c7c061318e9d9da7693d412b50c4952432ba9d909a82394376914
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.3 — 2026-04-29
|
|
4
|
+
|
|
5
|
+
- `lib/sinatra/inertia/async_sources.rb` registers under
|
|
6
|
+
`HomuraRuntime::AsyncRegistry` (was `CloudflareWorkers::AsyncRegistry`)
|
|
7
|
+
to follow the homura-runtime 0.3.0 module rename. Pure-Sinatra MRI
|
|
8
|
+
consumers are unaffected (the registration block is gated on
|
|
9
|
+
`defined?(::HomuraRuntime)`). Pin homura-runtime ≥ 0.3.0 if you
|
|
10
|
+
want sinatra-inertia 0.1.3's auto-await registration to fire.
|
|
11
|
+
|
|
12
|
+
## 0.1.2 — 2026-04-29
|
|
13
|
+
|
|
14
|
+
- Fix: under Opal/Workers, the Inertia visit JSON body shipped with
|
|
15
|
+
`Content-Type: text/html` and missing `X-Inertia: true` /
|
|
16
|
+
`Vary: X-Inertia` headers. `Response#to_h` is an async function
|
|
17
|
+
(it `await`s any Proc-returned JS Promise), so the rest of the
|
|
18
|
+
`inertia` helper ran after a JS-level suspend; Sinatra finalised
|
|
19
|
+
the response with default headers before the awaited continuation
|
|
20
|
+
set them. We now set the protocol headers *before* touching
|
|
21
|
+
`to_h`, so the response's content type and Inertia headers are in
|
|
22
|
+
place regardless of how the runtime schedules the resumption.
|
|
23
|
+
Pure-MRI behaviour is unchanged.
|
|
24
|
+
|
|
3
25
|
## 0.1.1 — 2026-04-29
|
|
4
26
|
|
|
5
27
|
- Add `spec.metadata['homura.auto_await'] = 'true'` so that when this
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
# Loaded only when the homura runtime is present (MRI / pure-Sinatra
|
|
11
11
|
# environments don't need this; their `to_h` is fully synchronous).
|
|
12
12
|
|
|
13
|
-
if defined?(::
|
|
14
|
-
::
|
|
13
|
+
if defined?(::HomuraRuntime) && defined?(::HomuraRuntime::AsyncRegistry)
|
|
14
|
+
::HomuraRuntime::AsyncRegistry.register_async_source do
|
|
15
15
|
async_method 'Sinatra::Inertia::Response', :to_h
|
|
16
16
|
async_method 'Sinatra::Inertia::Response', :to_json
|
|
17
17
|
end
|
|
@@ -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)
|