live 0.13.0 → 0.13.1
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
- checksums.yaml.gz.sig +0 -0
- data/lib/live/element.rb +2 -2
- data/lib/live/page.rb +20 -14
- data/lib/live/resolver.rb +1 -1
- data/lib/live/version.rb +1 -1
- data/lib/live/view.rb +3 -3
- data/lib/live.rb +3 -3
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf47630cac82b5611f454d7c61b1db67d8802c91eabc819d44d2e1a82ffd1d96
|
4
|
+
data.tar.gz: ce5bcd2dd5a5bc0c98357eb963aaa38ff83c4e312da85c0f3b4e79ca546e6d72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd5eaca0a5038361c60d13de5bc8b5e8e5ce66f0e828c74c0c199d6a8d9706bee31fbeff1365155b41b59241c2be4f405f6d1186c44b928510d1d94ad7e42000
|
7
|
+
data.tar.gz: 0f0956b2f4a4d79af54ee01e965585d370633eac1ad23ded24c817e43f0b7b8dd681a5187607fe2fdf4fa52be385f4c20ec25a09c55ceee5c00fe846c8a4cde1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/live/element.rb
CHANGED
data/lib/live/page.rb
CHANGED
@@ -3,14 +3,16 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "element"
|
7
|
+
require_relative "resolver"
|
8
8
|
|
9
|
-
require
|
10
|
-
require
|
9
|
+
require "async"
|
10
|
+
require "async/queue"
|
11
11
|
|
12
|
-
require
|
13
|
-
require
|
12
|
+
require "protocol/websocket"
|
13
|
+
require "protocol/websocket/message"
|
14
|
+
|
15
|
+
require "console/event/failure"
|
14
16
|
|
15
17
|
module Live
|
16
18
|
# Represents a connected client page with bound dynamic content areas.
|
@@ -74,30 +76,34 @@ module Live
|
|
74
76
|
|
75
77
|
def close
|
76
78
|
@elements.each do |id, element|
|
77
|
-
|
79
|
+
begin
|
80
|
+
element.close
|
81
|
+
rescue => error
|
82
|
+
Console::Event::Failure.for(error).emit(self)
|
83
|
+
end
|
78
84
|
end
|
79
85
|
end
|
80
86
|
|
81
87
|
# Process a single incoming message from the network.
|
82
88
|
def process_message(message)
|
83
89
|
case message[0]
|
84
|
-
when
|
90
|
+
when "bind"
|
85
91
|
# Bind a client-side element to a server-side element.
|
86
92
|
if element = self.resolve(message[1], message[2])
|
87
93
|
self.bind(element)
|
88
94
|
else
|
89
95
|
Console.warn(self, "Could not resolve element:", message)
|
90
|
-
@updates.enqueue([
|
96
|
+
@updates.enqueue(["error", message[1], "Could not resolve element!"])
|
91
97
|
end
|
92
|
-
when
|
98
|
+
when "unbind"
|
93
99
|
# Unbind a client-side element from a server-side element.
|
94
100
|
if element = @elements.delete(message[1])
|
95
101
|
element.close unless @attached.key?(message[1])
|
96
102
|
else
|
97
103
|
Console.warn(self, "Could not unbind element:", message)
|
98
|
-
@updates.enqueue([
|
104
|
+
@updates.enqueue(["error", message[1], "Could not unbind element!"])
|
99
105
|
end
|
100
|
-
when
|
106
|
+
when "event"
|
101
107
|
# Handle an event from the client.
|
102
108
|
self.handle(message[1], message[2])
|
103
109
|
else
|
@@ -111,14 +117,14 @@ module Live
|
|
111
117
|
Sync do |task|
|
112
118
|
queue_task = task.async do
|
113
119
|
while update = @updates.dequeue
|
114
|
-
Console.debug(self, "Sending update:", update)
|
115
120
|
::Protocol::WebSocket::TextMessage.generate(update).send(connection)
|
121
|
+
|
122
|
+
# Flush the output if there are no more updates:
|
116
123
|
connection.flush if @updates.empty?
|
117
124
|
end
|
118
125
|
end
|
119
126
|
|
120
127
|
while message = connection.read
|
121
|
-
Console.debug(self, "Reading message:", message)
|
122
128
|
process_message(message.parse)
|
123
129
|
end
|
124
130
|
ensure
|
data/lib/live/resolver.rb
CHANGED
data/lib/live/version.rb
CHANGED
data/lib/live/view.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require
|
6
|
+
require_relative "element"
|
7
|
+
require "xrb/builder"
|
8
8
|
|
9
9
|
module Live
|
10
10
|
# Represents a single division of content on the page an provides helpers for rendering the content.
|
@@ -12,7 +12,7 @@ module Live
|
|
12
12
|
# @returns [Object] The generated HTML.
|
13
13
|
def to_html
|
14
14
|
XRB::Builder.fragment do |builder|
|
15
|
-
builder.inline_tag :div, id: @id, class:
|
15
|
+
builder.inline_tag :div, id: @id, class: "live", data: @data do
|
16
16
|
render(builder)
|
17
17
|
end
|
18
18
|
end
|
data/lib/live.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: live
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -39,7 +39,7 @@ cert_chain:
|
|
39
39
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
40
40
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
41
41
|
-----END CERTIFICATE-----
|
42
|
-
date: 2024-
|
42
|
+
date: 2024-09-23 00:00:00.000000000 Z
|
43
43
|
dependencies:
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: async-websocket
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
107
|
+
rubygems_version: 3.4.19
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Live HTML tags updated via a WebSocket.
|
metadata.gz.sig
CHANGED
Binary file
|