hotsock-turbo 0.3.0 → 0.4.0
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/app/assets/javascripts/hotsock-turbo.js +12 -9
- data/lib/hotsock/turbo/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: b67599699f411cccd916179d8160bd4275620bfb291c192387a15911c7a5c953
|
|
4
|
+
data.tar.gz: cfaec3f98b3c30eb7d2b9b5c2f67a5e29c2fc7d7e112730f718f106f912b7c3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a7940056a3bc984e7ffd12efa3d44d1d5145e407b3fef4ff8379fd1169b741a3661c81fa334648710992ddcd1bcf166c2a76529afff568695b806a6cbb6dab6
|
|
7
|
+
data.tar.gz: b4c9f15c8662985b588e7f92950fb5bd00caffa3ba24d8d3487576b47c3685d8aee772e750455bf0400c956140179f23b25ab10579544c04f47f8f13397f7e58
|
|
@@ -8,11 +8,11 @@ function createHotsockClient() {
|
|
|
8
8
|
{
|
|
9
9
|
connectTokenFn: async () => {
|
|
10
10
|
const connectTokenPath = document.querySelector(
|
|
11
|
-
'meta[name="hotsock:connect-token-path"]'
|
|
12
|
-
)
|
|
11
|
+
'meta[name="hotsock:connect-token-path"]',
|
|
12
|
+
)?.content
|
|
13
13
|
const csrfToken = document.querySelector(
|
|
14
|
-
'meta[name="csrf-token"]'
|
|
15
|
-
)
|
|
14
|
+
'meta[name="csrf-token"]',
|
|
15
|
+
)?.content
|
|
16
16
|
const response = await fetch(connectTokenPath, {
|
|
17
17
|
method: "POST",
|
|
18
18
|
headers: {
|
|
@@ -25,12 +25,15 @@ function createHotsockClient() {
|
|
|
25
25
|
lazyConnection: true,
|
|
26
26
|
logLevel: document.querySelector('meta[name="hotsock:log-level"]')
|
|
27
27
|
?.content,
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
29
|
)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
let hotsockClient = window.Hotsock
|
|
33
|
+
if (!hotsockClient && document.querySelector('meta[name="hotsock:wss-url"]')) {
|
|
34
|
+
hotsockClient = createHotsockClient()
|
|
35
|
+
window.Hotsock = hotsockClient
|
|
36
|
+
}
|
|
34
37
|
|
|
35
38
|
const subscriptions = new Map() // channel -> { binding, elements: Set, unsubscribeTimer }
|
|
36
39
|
const lastMessageIds = new Map() // channel -> lastMessageId (ULID)
|
|
@@ -101,7 +104,7 @@ class HotsockTurboStreamSourceElement extends HTMLElement {
|
|
|
101
104
|
console.error("Failed to render Turbo Stream message:", error)
|
|
102
105
|
}
|
|
103
106
|
},
|
|
104
|
-
{ channel, subscribeTokenFn: () => token }
|
|
107
|
+
{ channel, subscribeTokenFn: () => token },
|
|
105
108
|
)
|
|
106
109
|
|
|
107
110
|
sub = { binding, elements: new Set([this]), unsubscribeTimer: null }
|
|
@@ -154,7 +157,7 @@ class HotsockTurboStreamSourceElement extends HTMLElement {
|
|
|
154
157
|
if (customElements.get("hotsock-turbo-stream-source") === undefined) {
|
|
155
158
|
customElements.define(
|
|
156
159
|
"hotsock-turbo-stream-source",
|
|
157
|
-
HotsockTurboStreamSourceElement
|
|
160
|
+
HotsockTurboStreamSourceElement,
|
|
158
161
|
)
|
|
159
162
|
}
|
|
160
163
|
|