lively 0.16.2 → 0.17.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/lively/application.rb +47 -33
- data/lib/lively/resolver.rb +34 -0
- data/lib/lively/version.rb +2 -2
- data/readme.md +57 -13
- data/releases.md +116 -0
- data.tar.gz.sig +0 -0
- metadata +2 -1
- 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: d41e94774f23353b426f53e23eb343783826c244d9bbad793759e5eea9fcd534
|
|
4
|
+
data.tar.gz: c2c5b21df4f25117d12e8c8af2e8c17113489346087cdd80a2d5b6b0dbd920d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0445eecaf41965ab7aea620f3d2886da5b2e76a5850678fcb30b60e0410aafe6d5f7d4180348564f43833b07476f2bacac00dc447a38229528ff8884ad67374e
|
|
7
|
+
data.tar.gz: f75a5afa75d4d98ad71c4a014c00ffec9b62368d1995eafe67265c05ee72e0cfd43afcc9a43374dda74b2261753348c0b34adfe672bc9d09f3566899f661e69f
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/lively/application.rb
CHANGED
|
@@ -7,6 +7,7 @@ require "live"
|
|
|
7
7
|
require "protocol/http/middleware"
|
|
8
8
|
require "async/websocket/adapters/http"
|
|
9
9
|
|
|
10
|
+
require_relative "resolver"
|
|
10
11
|
require_relative "pages/index"
|
|
11
12
|
require_relative "hello_world"
|
|
12
13
|
|
|
@@ -18,49 +19,65 @@ module Lively
|
|
|
18
19
|
# standard HTTP requests for the initial page load and WebSocket connections
|
|
19
20
|
# for live updates. It integrates with the Live framework to provide real-time
|
|
20
21
|
# interactive web applications.
|
|
22
|
+
#
|
|
23
|
+
# Use {.[]} to create a simple application class for a single view, optionally
|
|
24
|
+
# with shared state. For more complex applications, subclass and override
|
|
25
|
+
# {#allowed_views}, {#state}, and {#body}.
|
|
21
26
|
class Application < Protocol::HTTP::Middleware
|
|
22
|
-
|
|
27
|
+
VIEWS = [HelloWorld].freeze
|
|
28
|
+
STATE = {}.freeze
|
|
29
|
+
|
|
30
|
+
# Create a new application class configured for a specific Live view tag,
|
|
31
|
+
# optionally with shared state that is passed to all views.
|
|
32
|
+
#
|
|
23
33
|
# @parameter tag [Class] The Live view class to use as the application body.
|
|
34
|
+
# @parameter state [Hash] Shared state to pass to all views as keyword arguments.
|
|
24
35
|
# @returns [Class] A new application class configured for the specified tag.
|
|
25
|
-
def self.[](
|
|
36
|
+
def self.[](*tags, **state)
|
|
26
37
|
klass = Class.new(self)
|
|
27
38
|
|
|
28
|
-
klass.
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
klass.define_method(:body) do
|
|
33
|
-
tag.new
|
|
34
|
-
end
|
|
39
|
+
klass.const_set(:VIEWS, tags)
|
|
40
|
+
klass.const_set(:STATE, state)
|
|
35
41
|
|
|
36
42
|
return klass
|
|
37
43
|
end
|
|
38
44
|
|
|
39
|
-
# Get the default resolver for this application.
|
|
40
|
-
# @returns [Live::Resolver] A resolver configured to allow HelloWorld components.
|
|
41
|
-
def self.resolver
|
|
42
|
-
Live::Resolver.allow(HelloWorld)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
45
|
# Initialize a new Lively application.
|
|
46
46
|
# @parameter delegate [Protocol::HTTP::Middleware] The next middleware in the chain.
|
|
47
|
-
|
|
48
|
-
def initialize(delegate, resolver: self.class.resolver)
|
|
47
|
+
def initialize(delegate)
|
|
49
48
|
super(delegate)
|
|
50
|
-
|
|
51
|
-
@resolver = resolver
|
|
52
49
|
end
|
|
53
50
|
|
|
54
|
-
# @attribute [Live::Resolver] The resolver for live components.
|
|
55
|
-
attr :resolver
|
|
56
|
-
|
|
57
51
|
# @attribute [Protocol::HTTP::Middleware] The delegate middleware for request handling.
|
|
58
52
|
attr :delegate
|
|
59
53
|
|
|
54
|
+
# The shared state for this application, passed to all views via the resolver.
|
|
55
|
+
# Override this in subclasses to provide custom state.
|
|
56
|
+
# @returns [Hash] Key-value pairs passed as keyword arguments to view constructors.
|
|
57
|
+
def state
|
|
58
|
+
self.class::STATE
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# The view classes that this application allows.
|
|
62
|
+
# Override this in subclasses to specify which views can be resolved.
|
|
63
|
+
# @returns [Array(Class)] The allowed view classes.
|
|
64
|
+
def allowed_views
|
|
65
|
+
self.class::VIEWS
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# The resolver for live components.
|
|
69
|
+
# Built from {#allowed_views} and {#state}.
|
|
70
|
+
# @returns [Lively::Resolver] The resolver instance.
|
|
71
|
+
def resolver
|
|
72
|
+
@resolver ||= Resolver.new(self.state).tap do |resolver|
|
|
73
|
+
resolver.allow(*self.allowed_views)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
60
77
|
# Handle a WebSocket connection for live updates.
|
|
61
78
|
# @parameter connection [Async::WebSocket::Connection] The WebSocket connection.
|
|
62
79
|
def live(connection)
|
|
63
|
-
Live::Page.new(
|
|
80
|
+
Live::Page.new(self.resolver).run(connection)
|
|
64
81
|
end
|
|
65
82
|
|
|
66
83
|
# Get the title for this application.
|
|
@@ -70,25 +87,22 @@ module Lively
|
|
|
70
87
|
end
|
|
71
88
|
|
|
72
89
|
# Create the body content for this application.
|
|
73
|
-
# @
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
HelloWorld.new(...)
|
|
90
|
+
# @returns [Live::View] A new view instance.
|
|
91
|
+
def body
|
|
92
|
+
self.allowed_views.first.new(**self.state)
|
|
77
93
|
end
|
|
78
94
|
|
|
79
95
|
# Create the index page for this application.
|
|
80
|
-
# @parameter **options [Hash] Additional options to pass to the index constructor.
|
|
81
96
|
# @returns [Pages::Index] A new index page instance.
|
|
82
|
-
def index
|
|
83
|
-
Pages::Index.new(title: self.title, body: self.body
|
|
97
|
+
def index
|
|
98
|
+
Pages::Index.new(title: self.title, body: self.body)
|
|
84
99
|
end
|
|
85
100
|
|
|
86
101
|
# Handle a standard HTTP request.
|
|
87
102
|
# @parameter request [Protocol::HTTP::Request] The incoming HTTP request.
|
|
88
|
-
# @parameter **options [Hash] Additional options.
|
|
89
103
|
# @returns [Protocol::HTTP::Response] The HTTP response with the rendered page.
|
|
90
|
-
def handle(request
|
|
91
|
-
return Protocol::HTTP::Response[200, [], [self.index
|
|
104
|
+
def handle(request)
|
|
105
|
+
return Protocol::HTTP::Response[200, [], [self.index.call]]
|
|
92
106
|
end
|
|
93
107
|
|
|
94
108
|
# Process an incoming HTTP request.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2026, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require "live/resolver"
|
|
7
|
+
|
|
8
|
+
module Lively
|
|
9
|
+
# Extends {Live::Resolver} to pass shared application state to views on construction.
|
|
10
|
+
#
|
|
11
|
+
# When the browser reconnects via WebSocket, the resolver creates new view
|
|
12
|
+
# instances with the shared state (e.g. a controller) so all clients stay in sync.
|
|
13
|
+
class Resolver < Live::Resolver
|
|
14
|
+
# Initialize a new resolver with shared state.
|
|
15
|
+
# @parameter state [Hash] Key-value pairs to pass to view constructors as keyword arguments.
|
|
16
|
+
def initialize(state = nil)
|
|
17
|
+
super()
|
|
18
|
+
@state = state
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @attribute [Hash] The shared state passed to view constructors.
|
|
22
|
+
attr :state
|
|
23
|
+
|
|
24
|
+
# Resolve a client-side element to a server-side instance with shared state.
|
|
25
|
+
# @parameter id [String] The unique element identifier.
|
|
26
|
+
# @parameter data [Hash] The element data attributes.
|
|
27
|
+
# @returns [Live::Element | Nil] The resolved element, or `nil`.
|
|
28
|
+
def call(id, data)
|
|
29
|
+
if klass = @allowed[data[:class]]
|
|
30
|
+
return klass.new(id, data, **@state)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/lively/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -16,6 +16,59 @@ Please see the [project documentation](https://socketry.github.io/lively/) for m
|
|
|
16
16
|
|
|
17
17
|
- [Game Audio Tutorial](https://socketry.github.io/lively/guides/game-audio-tutorial/index) - This guide shows you how to add audio to your Live.js games and applications using the `live-audio` library. You'll learn how to play sound effects, background music, and create dynamic audio experiences.
|
|
18
18
|
|
|
19
|
+
## Releases
|
|
20
|
+
|
|
21
|
+
Please see the [project releases](https://socketry.github.io/lively/releases/index) for all releases.
|
|
22
|
+
|
|
23
|
+
### v0.17.0
|
|
24
|
+
|
|
25
|
+
- Expose shared application state via `Application[..., controller: Controller.new]`.
|
|
26
|
+
|
|
27
|
+
### v0.16.2
|
|
28
|
+
|
|
29
|
+
- Modernize internals and update dependencies.
|
|
30
|
+
|
|
31
|
+
### v0.16.1
|
|
32
|
+
|
|
33
|
+
- Updated game audio tutorial content.
|
|
34
|
+
|
|
35
|
+
### v0.16.0
|
|
36
|
+
|
|
37
|
+
- Updated `live-audio` component dependencies.
|
|
38
|
+
|
|
39
|
+
### v0.15.1
|
|
40
|
+
|
|
41
|
+
- Fixed handling of spaces in asset names.
|
|
42
|
+
|
|
43
|
+
### v0.15.0
|
|
44
|
+
|
|
45
|
+
- Added platformer-style game example.
|
|
46
|
+
- Improved game audio tutorial.
|
|
47
|
+
|
|
48
|
+
### v0.14.1
|
|
49
|
+
|
|
50
|
+
- Added `bake` tasks for release management.
|
|
51
|
+
|
|
52
|
+
### v0.14.0
|
|
53
|
+
|
|
54
|
+
- Fixed guide rendering and test suite.
|
|
55
|
+
|
|
56
|
+
### v0.13.1
|
|
57
|
+
|
|
58
|
+
- Tidied up gem dependencies.
|
|
59
|
+
|
|
60
|
+
### v0.13.0
|
|
61
|
+
|
|
62
|
+
- Added `live-audio` support for background and positional audio in applications.
|
|
63
|
+
- Added game audio example demonstrating audio playback.
|
|
64
|
+
- Fixed serving non-existent asset paths gracefully.
|
|
65
|
+
- Achieved 100% test and documentation coverage.
|
|
66
|
+
|
|
67
|
+
## See Also
|
|
68
|
+
|
|
69
|
+
- [live](https://github.com/socketry/live) — Provides client-server communication using websockets.
|
|
70
|
+
- [mayu](https://github.com/mayu-live/framework) — A live streaming server-side component-based VirtualDOM rendering framework.
|
|
71
|
+
|
|
19
72
|
## Contributing
|
|
20
73
|
|
|
21
74
|
We welcome contributions to this project.
|
|
@@ -36,9 +89,11 @@ bundle exec sus
|
|
|
36
89
|
|
|
37
90
|
### Making Releases
|
|
38
91
|
|
|
39
|
-
|
|
92
|
+
To make a new release:
|
|
40
93
|
|
|
41
|
-
|
|
94
|
+
``` shell
|
|
95
|
+
bundle exec bake gem:release:patch # or minor or major
|
|
96
|
+
```
|
|
42
97
|
|
|
43
98
|
### Developer Certificate of Origin
|
|
44
99
|
|
|
@@ -47,14 +102,3 @@ In order to protect users of this project, we require all contributors to comply
|
|
|
47
102
|
### Community Guidelines
|
|
48
103
|
|
|
49
104
|
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
|
50
|
-
|
|
51
|
-
## Releases
|
|
52
|
-
|
|
53
|
-
Please see the [project releases](https://socketry.github.io/lively/releases/index) for all releases.
|
|
54
|
-
|
|
55
|
-
### v0.14.1
|
|
56
|
-
|
|
57
|
-
## See Also
|
|
58
|
-
|
|
59
|
-
- [live](https://github.com/socketry/live) — Provides client-server communication using websockets.
|
|
60
|
-
- [mayu](https://github.com/mayu-live/framework) — A live streaming server-side component-based VirtualDOM rendering framework.
|
data/releases.md
CHANGED
|
@@ -1,3 +1,119 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.17.0
|
|
4
|
+
|
|
5
|
+
- Expose shared application state via `Application[..., controller: Controller.new]`.
|
|
6
|
+
|
|
7
|
+
## v0.16.2
|
|
8
|
+
|
|
9
|
+
- Modernize internals and update dependencies.
|
|
10
|
+
|
|
11
|
+
## v0.16.1
|
|
12
|
+
|
|
13
|
+
- Updated game audio tutorial content.
|
|
14
|
+
|
|
15
|
+
## v0.16.0
|
|
16
|
+
|
|
17
|
+
- Updated `live-audio` component dependencies.
|
|
18
|
+
|
|
19
|
+
## v0.15.1
|
|
20
|
+
|
|
21
|
+
- Fixed handling of spaces in asset names.
|
|
22
|
+
|
|
23
|
+
## v0.15.0
|
|
24
|
+
|
|
25
|
+
- Added platformer-style game example.
|
|
26
|
+
- Improved game audio tutorial.
|
|
27
|
+
|
|
3
28
|
## v0.14.1
|
|
29
|
+
|
|
30
|
+
- Added `bake` tasks for release management.
|
|
31
|
+
|
|
32
|
+
## v0.14.0
|
|
33
|
+
|
|
34
|
+
- Fixed guide rendering and test suite.
|
|
35
|
+
|
|
36
|
+
## v0.13.1
|
|
37
|
+
|
|
38
|
+
- Tidied up gem dependencies.
|
|
39
|
+
|
|
40
|
+
## v0.13.0
|
|
41
|
+
|
|
42
|
+
- Added `live-audio` support for background and positional audio in applications.
|
|
43
|
+
- Added game audio example demonstrating audio playback.
|
|
44
|
+
- Fixed serving non-existent asset paths gracefully.
|
|
45
|
+
- Achieved 100% test and documentation coverage.
|
|
46
|
+
|
|
47
|
+
## v0.12.0
|
|
48
|
+
|
|
49
|
+
- Added bundled guides for getting started and tutorials.
|
|
50
|
+
- Added Pacman example application.
|
|
51
|
+
- Improved multiplayer support in flappy bird via `falcon.rb` binding.
|
|
52
|
+
- Fixed chatbot example.
|
|
53
|
+
|
|
54
|
+
## v0.11.0
|
|
55
|
+
|
|
56
|
+
- Added `.wav` audio file support.
|
|
57
|
+
- Added worms multiplayer presentation example.
|
|
58
|
+
- Added tool-assisted AI integration example.
|
|
59
|
+
- Dropped support for Ruby v3.1.
|
|
60
|
+
|
|
61
|
+
## v0.10.1
|
|
62
|
+
|
|
63
|
+
- Fixed missing `require` statements.
|
|
64
|
+
|
|
65
|
+
## v0.10.0
|
|
66
|
+
|
|
67
|
+
- Added touch input support for mobile devices.
|
|
68
|
+
- Added multiplayer support to the flappy bird example.
|
|
69
|
+
- Default asset root is now the local `public/` directory.
|
|
70
|
+
|
|
71
|
+
## v0.9.0
|
|
72
|
+
|
|
73
|
+
- Added `.mp3` audio file support.
|
|
74
|
+
- Added sound effects to the math quest example.
|
|
75
|
+
|
|
76
|
+
## v0.8.0
|
|
77
|
+
|
|
78
|
+
- Server now binds to `localhost` by default for security.
|
|
79
|
+
- Disabled asset caching during development.
|
|
80
|
+
- Added worms example application.
|
|
81
|
+
|
|
82
|
+
## v0.7.0
|
|
83
|
+
|
|
84
|
+
- Added hello-world example application.
|
|
85
|
+
- Updated `@socketry/live` to v0.14.0.
|
|
86
|
+
- Renamed `example/` directory to `examples/`.
|
|
87
|
+
|
|
88
|
+
## v0.6.0
|
|
89
|
+
|
|
90
|
+
- Added `lively` command-line executable.
|
|
91
|
+
- Added several example applications (chatbot, flappy bird, game of life, waves).
|
|
92
|
+
|
|
93
|
+
## v0.5.0
|
|
94
|
+
|
|
95
|
+
- Updated bundled `Live.js` client library.
|
|
96
|
+
|
|
97
|
+
## v0.4.0
|
|
98
|
+
|
|
99
|
+
- Updated dependencies and `live.js`.
|
|
100
|
+
|
|
101
|
+
## v0.3.0
|
|
102
|
+
|
|
103
|
+
- Modernized gem structure.
|
|
104
|
+
- Fixed service environment configuration issues.
|
|
105
|
+
|
|
106
|
+
## v0.2.1
|
|
107
|
+
|
|
108
|
+
- Updated dependencies.
|
|
109
|
+
- Switched to `bake-gem` for release management.
|
|
110
|
+
|
|
111
|
+
## v0.2.0
|
|
112
|
+
|
|
113
|
+
- Public assets are now included in the released gem.
|
|
114
|
+
- Moved example app to a separate repository.
|
|
115
|
+
- Improved event handling and UI styling.
|
|
116
|
+
|
|
117
|
+
## v0.1.0
|
|
118
|
+
|
|
119
|
+
- Initial proof of concept implementation.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lively
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.17.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -126,6 +126,7 @@ files:
|
|
|
126
126
|
- lib/lively/hello_world.rb
|
|
127
127
|
- lib/lively/pages/index.rb
|
|
128
128
|
- lib/lively/pages/index.xrb
|
|
129
|
+
- lib/lively/resolver.rb
|
|
129
130
|
- lib/lively/version.rb
|
|
130
131
|
- license.md
|
|
131
132
|
- public/_components/@socketry/live-audio/Live/Audio.js
|
metadata.gz.sig
CHANGED
|
Binary file
|