live 0.18.2 → 0.19.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
- checksums.yaml.gz.sig +0 -0
- data/lib/live/element.rb +17 -7
- data/lib/live/resolver.rb +23 -2
- data/lib/live/version.rb +1 -1
- data/readme.md +2 -12
- data/releases.md +11 -0
- 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: 826ca30c017f31b254c40ed89d01bf3989aef0ed660935beef1e3e4cb90c53c1
|
|
4
|
+
data.tar.gz: 0eccc9cbf069665e895323d50e78321106a065d7d62a3e15c0a67c17a34385c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61317101fe18021fea96f836ef083ee437fcf718fc78055609fad3bf369421da3821ac8fcfde1fd80eb5fabcc05d844d64bd5de967372a7a5898bfb6e0017404
|
|
7
|
+
data.tar.gz: e35a93dbb23f40ba34a5adbbfb6c1c61de1e199fbdc028fd9013fab288ed9099afc06e2594e3167242f678a80f7f9a4f1b9f0db4762ea5ffe8587369a8455a4a
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/live/element.rb
CHANGED
|
@@ -20,26 +20,36 @@ module Live
|
|
|
20
20
|
#
|
|
21
21
|
# @parameter id [String] The unique identifier within the page.
|
|
22
22
|
# @parameter data [Hash] The data associated with the element, typically stored as `data-` attributes.
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
# @parameter options [Hash] Additional options passed to the element constructor.
|
|
24
|
+
def self.root(id = self.unique_id, data: {}, **options)
|
|
25
|
+
self.new(id, data, **options)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
# Mount an element within a parent element.
|
|
28
|
-
|
|
29
|
+
# @parameter parent [Element] The parent element.
|
|
30
|
+
# @parameter id [String] The unique identifier within the parent element.
|
|
31
|
+
# @parameter data [Hash] The data associated with the element, typically stored as `data-` attributes.
|
|
32
|
+
# @parameter options [Hash] Additional options passed to the element constructor.
|
|
33
|
+
def self.child(parent, id = self.unique_id, data: {}, **options)
|
|
29
34
|
full_id = parent.id + ":" + id
|
|
30
35
|
|
|
31
|
-
self.new(full_id, data)
|
|
36
|
+
self.new(full_id, data, **options)
|
|
32
37
|
end
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
# Mount an element within a parent element.
|
|
40
|
+
# @parameter parent [Element] The parent element.
|
|
41
|
+
# @parameter id [String] The unique identifier within the parent element.
|
|
42
|
+
# @parameter data [Hash] The data associated with the element, typically stored as `data-` attributes.
|
|
43
|
+
# @parameter options [Hash] Additional options passed to the element constructor.
|
|
44
|
+
def self.mount(parent, id, data: {}, **options)
|
|
45
|
+
self.child(parent, id, data:, **options)
|
|
36
46
|
end
|
|
37
47
|
|
|
38
48
|
# Initialize the element with the specified id and data.
|
|
39
49
|
#
|
|
40
50
|
# @parameter id [String] The unique identifier within the page.
|
|
41
51
|
# @parameter data [Hash] The data associated with the element, typically stored as `data-` attributes.
|
|
42
|
-
def initialize(id
|
|
52
|
+
def initialize(id, data)
|
|
43
53
|
data[:class] ||= self.class.name
|
|
44
54
|
|
|
45
55
|
@id = id
|
data/lib/live/resolver.rb
CHANGED
|
@@ -37,14 +37,35 @@ module Live
|
|
|
37
37
|
return self
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
# Construct an allowed root element from its class.
|
|
41
|
+
# @parameter view_class [Class] The view class to construct.
|
|
42
|
+
# @parameter id [String] The unique identifier for the view.
|
|
43
|
+
# @parameter data [Hash] The data associated with the view.
|
|
44
|
+
# @parameter options [Hash] Additional options passed to the view constructor.
|
|
45
|
+
# @returns [Element] A new view instance.
|
|
46
|
+
# @raises [ArgumentError] If the view class is not allowed.
|
|
47
|
+
def root(view_class, id = view_class.unique_id, data: {}, **options)
|
|
48
|
+
unless @allowed[view_class.name].equal?(view_class)
|
|
49
|
+
raise ArgumentError, "View class is not allowed: #{view_class.to_s.dump}!"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
return make(view_class, id, data, **options)
|
|
53
|
+
end
|
|
54
|
+
|
|
40
55
|
# Resolve a tag.
|
|
41
56
|
# @parameter id [String] The unique identifier for the tag.
|
|
42
57
|
# @parameter data [Hash] The data associated with the tag. Should include the `:class` key.
|
|
43
58
|
# @returns [Element] The element instance if it was allowed.
|
|
44
59
|
def call(id, data)
|
|
45
|
-
if
|
|
46
|
-
return
|
|
60
|
+
if view_class = @allowed[data[:class]]
|
|
61
|
+
return make(view_class, id, data)
|
|
47
62
|
end
|
|
48
63
|
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def make(view_class, id, data, **options)
|
|
68
|
+
view_class.new(id, data, **options)
|
|
69
|
+
end
|
|
49
70
|
end
|
|
50
71
|
end
|
data/lib/live/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -40,19 +40,9 @@ bundle exec sus
|
|
|
40
40
|
|
|
41
41
|
Please see the [project releases](https://socketry.github.io/live/releases/index) for all releases.
|
|
42
42
|
|
|
43
|
-
### v0.
|
|
44
|
-
|
|
45
|
-
- **Breaking Change**: Live now uses Web Components for managing life-cycle events instead of observers. You will need to use `live-js` v0.16.0 or later with this version of `live`, which emits `<live-view>` elements (instead of `<div>` elements).
|
|
46
|
-
- Using older versions of `live-js` with this version of `live` may result in unexpected behavior or errors.
|
|
47
|
-
- Using older versions of `live` with `live-js` v0.16.0 or later may also result in unexpected behavior or errors.
|
|
48
|
-
- Updating both `live` and `live-js` to their latest versions is recommended to ensure compatibility, and requires no changes to application code.
|
|
43
|
+
### v0.19.0
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- **Breaking Change**: Live now uses Web Components for managing life-cycle events instead of observers. You will need to use `live-js` v0.16.0 or later with this version of `live`, which emits `<live-view>` elements (instead of `<div>` elements).
|
|
53
|
-
- Using older versions of `live-js` with this version of `live` may result in unexpected behavior or errors.
|
|
54
|
-
- Using older versions of `live` with `live-js` v0.16.0 or later may also result in unexpected behavior or errors.
|
|
55
|
-
- Updating both `live` and `live-js` to their latest versions is recommended to ensure compatibility, and requires no changes to application code.
|
|
45
|
+
- [Explicit Element Construction](https://socketry.github.io/live/releases/index#explicit-element-construction)
|
|
56
46
|
|
|
57
47
|
### v0.18.0
|
|
58
48
|
|
data/releases.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.19.0
|
|
4
|
+
|
|
5
|
+
### Explicit Element Construction
|
|
6
|
+
|
|
7
|
+
Element construction now separates serialized element data from Ruby constructor options and makes the intended construction path explicit.
|
|
8
|
+
|
|
9
|
+
- `Live::Element#initialize` now requires both `id` and `data`. Replace `MyView.new` with `MyView.root`, and replace `MyView.new("custom-id")` with `MyView.root("custom-id")`. Internal callers using `new` directly must pass the data hash explicitly, even when empty.
|
|
10
|
+
- `Live::Element.root`, `.child`, and `.mount` now accept serialized attributes through `data:`. Other keyword arguments are forwarded to `initialize`. For example, change `MyView.root(mode: "presenter")` to `MyView.root(data: {mode: "presenter"})`; constructor dependencies such as `controller:` can remain ordinary keyword arguments.
|
|
11
|
+
- Calls passing a positional data hash to `.mount` must use the `data:` keyword. Change `ChildView.mount(parent, "child", {mode: "compact"})` to `ChildView.mount(parent, "child", data: {mode: "compact"})`.
|
|
12
|
+
- `Live::Resolver#root(view_class, id = view_class.unique_id, data: {}, **options)` constructs an allowed root using the same internal path as browser-resolved elements. Custom resolvers that inject dependencies can override the private `make(view_class, id, data, **options)` method instead of overriding `call`.
|
|
13
|
+
|
|
3
14
|
## v0.18.0
|
|
4
15
|
|
|
5
16
|
- **Breaking Change**: Live now uses Web Components for managing life-cycle events instead of observers. You will need to use `live-js` v0.16.0 or later with this version of `live`, which emits `<live-view>` elements (instead of `<div>` elements).
|
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.19.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
115
115
|
- !ruby/object:Gem::Version
|
|
116
116
|
version: '0'
|
|
117
117
|
requirements: []
|
|
118
|
-
rubygems_version: 4.0.
|
|
118
|
+
rubygems_version: 4.0.10
|
|
119
119
|
specification_version: 4
|
|
120
120
|
summary: Live HTML tags updated via a WebSocket.
|
|
121
121
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|