live 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/live/element.rb +7 -7
- data/lib/live/page.rb +17 -6
- data/lib/live/version.rb +1 -1
- data/lib/live.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 01e0a2e5881cd9cb589f93184b159a022a884a3b6549d6da54764ebe05bd8b81
|
4
|
+
data.tar.gz: 3cc1bd067307955f663cd9318bf60ec80dce9a4759df0935d3b00176c0183c85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b74fd0f4365c5eb0fcf8ed1b8064ad5efd39ebcd56a12b4cb9e144a6dce0a503eb14f054fb16332b20abe905c364b36486b594ab9f4992fb645d41fff860be21
|
7
|
+
data.tar.gz: 80a79b3466c52e0cc0989416c547c06e39d9059a910489a16c713ab046a83480b10c645e33420fc31fa262894c02d9bcef01a7c9e3fe17e86f571524bc1eb519
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/live/element.rb
CHANGED
@@ -30,18 +30,18 @@ module Live
|
|
30
30
|
attr :data
|
31
31
|
|
32
32
|
# Generate a JavaScript string which forwards the specified event to the server.
|
33
|
-
# @parameter
|
34
|
-
def forward_event(
|
35
|
-
if
|
36
|
-
"live.forwardEvent(#{JSON.dump(@id)}, event, #{JSON.dump(
|
33
|
+
# @parameter detail [Hash] The detail associated with the forwarded event.
|
34
|
+
def forward_event(detail = nil)
|
35
|
+
if detail
|
36
|
+
"live.forwardEvent(#{JSON.dump(@id)}, event, #{JSON.dump(detail)})"
|
37
37
|
else
|
38
38
|
"live.forwardEvent(#{JSON.dump(@id)}, event)"
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def forward_form_event(
|
43
|
-
if
|
44
|
-
"live.forwardFormEvent(#{JSON.dump(@id)}, event, #{JSON.dump(
|
42
|
+
def forward_form_event(detail = nil)
|
43
|
+
if detail
|
44
|
+
"live.forwardFormEvent(#{JSON.dump(@id)}, event, #{JSON.dump(detail)})"
|
45
45
|
else
|
46
46
|
"live.forwardFormEvent(#{JSON.dump(@id)}, event)"
|
47
47
|
end
|
data/lib/live/page.rb
CHANGED
@@ -43,14 +43,13 @@ module Live
|
|
43
43
|
# Handle an event from the client. If the element could not be found, it is silently ignored.
|
44
44
|
# @parameter id [String] The unique identifier of the element which forwarded the event.
|
45
45
|
# @parameter event [String] The type of the event.
|
46
|
-
# @parameter details [Hash] The associated details if any.
|
47
46
|
# @returns [Object] The result of the element handler, if the element was found.
|
48
47
|
# @returns [Nil] If the element could not be found.
|
49
48
|
def handle(id, event)
|
50
49
|
if element = @elements[id]
|
51
50
|
return element.handle(event)
|
52
51
|
else
|
53
|
-
Console.warn(self, "Could not handle event:", event
|
52
|
+
Console.warn(self, "Could not handle event:", id:, event:)
|
54
53
|
end
|
55
54
|
|
56
55
|
return nil
|
@@ -64,14 +63,26 @@ module Live
|
|
64
63
|
|
65
64
|
# Process a single incoming message from the network.
|
66
65
|
def process_message(message)
|
67
|
-
|
68
|
-
|
66
|
+
case message[0]
|
67
|
+
when 'bind'
|
68
|
+
# Bind a client-side element to a server-side element.
|
69
|
+
if element = self.resolve(message[1], message[2])
|
69
70
|
self.bind(element)
|
70
71
|
else
|
71
72
|
Console.warn(self, "Could not resolve element:", message)
|
73
|
+
# @updates.enqueue(['error', message[1], "Could not resolve element!"])
|
72
74
|
end
|
73
|
-
|
74
|
-
|
75
|
+
when 'unbind'
|
76
|
+
# Unbind a client-side element from a server-side element.
|
77
|
+
if element = @elements.delete(message[1])
|
78
|
+
element.close
|
79
|
+
else
|
80
|
+
Console.warn(self, "Could not unbind element:", message)
|
81
|
+
@updates.enqueue(['error', message[1], "Could not unbind element!"])
|
82
|
+
end
|
83
|
+
when 'event'
|
84
|
+
# Handle an event from the client.
|
85
|
+
self.handle(message[1], message[2])
|
75
86
|
else
|
76
87
|
Console.warn(self, "Unhandled message:", message)
|
77
88
|
end
|
data/lib/live/version.rb
CHANGED
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.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
39
39
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
40
40
|
-----END CERTIFICATE-----
|
41
|
-
date: 2024-05-
|
41
|
+
date: 2024-05-05 00:00:00.000000000 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: async-websocket
|
metadata.gz.sig
CHANGED
Binary file
|