lively 0.23.0 → 0.24.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02c1d603877c33f60d054f04e6d9ef68d5385b23d3f165b23520e2ea47eefa80
4
- data.tar.gz: 6a48a1a8753f2a35adb4da6abb5527a7f95c2462903499f4a4b2ae968f0e0ebb
3
+ metadata.gz: 38b69265a34b5238872eb7b99d919dd4134b87beae41b567bc6623ad37780df2
4
+ data.tar.gz: ae5ff6d1ad55757801ca32f3f36437048a72e000317110db8473514ed85b3bf0
5
5
  SHA512:
6
- metadata.gz: 63c191f0001969c89b0b8b7f0fcf6de08757b202a7d53423d6d2ddd91aa05eea34f8b66f4e2e7c9363546b6c1064afa35878904722bd19f9d82436c58f6f5c62
7
- data.tar.gz: efd50bf88258523e7a95dbec278ec95a448ded6849ab77209cf6fc1158805dc0b0f06ed3228b0b616806ff8af2bc27124171eb56ff10d6f277d4143c78b8989a
6
+ metadata.gz: 0c7df91edb0e4f0db3a48dee5d7c7fb778dfaa2332ccb00ee036f24fd4d0d67db5706a629fbb8701667157c09e1df6503e316b3813742410b12e9f348d685fd8
7
+ data.tar.gz: eb0ecb1ec543d765c7ce561b026c430b3f08a22fbb7597b8b0d38f3a0f15ce8ee0cb847778e0352f975db46824be2db8d1bac54e0f0a8a2976cbf71cf6410f80
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,135 @@
1
+ # Client JavaScript Packages
2
+
3
+ This guide explains how to organize, test, and deploy client-side JavaScript packages in a Lively application.
4
+
5
+ ## Package Boundaries
6
+
7
+ Small application entry points can live directly in `public/`. As client behavior grows, keeping reusable modules, their dependencies, and their tests in a workspace package gives that code an explicit boundary independent of the Ruby application.
8
+
9
+ Lively uses `web-packages` to maintain three distinct layers:
10
+
11
+ ~~~ text
12
+ components/ # Authored JavaScript packages and their tests.
13
+ node_modules/ # Package-manager installation.
14
+ public/_components/ # Generated browser-facing projection.
15
+ public/application.js # Application entry point.
16
+ ~~~
17
+
18
+ Only files in `components/` and `public/application.js` are authored directly. Treat `node_modules/` and `public/_components/` as generated output.
19
+
20
+ ## Create a Package
21
+
22
+ For example, an application can place its presentation behavior in an internal package:
23
+
24
+ ~~~ text
25
+ components/
26
+ presentation/
27
+ package.json
28
+ Presentation.js
29
+ test/
30
+ Presentation.js
31
+ ~~~
32
+
33
+ Define the package entry point and test command in `components/presentation/package.json`:
34
+
35
+ ~~~ json
36
+ {
37
+ "name": "@example/presentation",
38
+ "private": true,
39
+ "type": "module",
40
+ "exports": "./Presentation.js",
41
+ "scripts": {
42
+ "test": "node --test test/*.js"
43
+ }
44
+ }
45
+ ~~~
46
+
47
+ The package can use any browser-ready JavaScript modules. `web-packages` projects those modules for static delivery; it does not require a bundling or transpilation step.
48
+
49
+ ## Configure the Workspace
50
+
51
+ Register internal packages as workspaces in the application's root `package.json`, then select the files and browser import names that should be deployed:
52
+
53
+ ~~~ json
54
+ {
55
+ "private": true,
56
+ "workspaces": [
57
+ "components/*"
58
+ ],
59
+ "scripts": {
60
+ "test": "npm test --workspaces --if-present"
61
+ },
62
+ "web-packages": {
63
+ "packages": {
64
+ "@example/presentation": {
65
+ "include": [
66
+ "Presentation.js"
67
+ ],
68
+ "imports": {
69
+ "@example/presentation": "Presentation.js"
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+ ~~~
76
+
77
+ Install dependencies and generate the browser-facing projection:
78
+
79
+ ~~~ bash
80
+ $ bundle exec bake web:packages:install
81
+ $ bundle exec bake web:packages:update
82
+ ~~~
83
+
84
+ The package is now available at `/_components/@example/presentation/Presentation.js`.
85
+
86
+ ## Add the Package to a Page
87
+
88
+ Lively pages expose JavaScript packages through an import map. A custom page can extend the default imports and load an application entry point:
89
+
90
+ ~~~ ruby
91
+ class ApplicationPage < Lively::Page
92
+ IMPORTS = Lively::Pages::Index::IMPORTS.merge(
93
+ "@example/presentation" => "/_components/@example/presentation/Presentation.js"
94
+ ).freeze
95
+
96
+ def initialize(body:)
97
+ super(
98
+ title: "Presentation",
99
+ body: body,
100
+ imports: IMPORTS,
101
+ modules: ["/application.js"]
102
+ )
103
+ end
104
+ end
105
+ ~~~
106
+
107
+ The application entry point can then use the package by name:
108
+
109
+ ~~~ javascript
110
+ import {Presentation} from '@example/presentation';
111
+
112
+ const presentation = new Presentation(document);
113
+ presentation.start();
114
+ ~~~
115
+
116
+ Keep application startup and page-specific integration in `public/application.js`. Put reusable behavior in the package so it can be tested without starting the Ruby application.
117
+
118
+ ## Test and Verify Packages
119
+
120
+ Run the workspace tests directly with the package manager:
121
+
122
+ ~~~ bash
123
+ $ npm test
124
+ ~~~
125
+
126
+ When generated packages are committed or deployed with the application, verify that they match the lock file and package configuration:
127
+
128
+ ~~~ bash
129
+ $ bundle exec bake web:packages:install frozen=true
130
+ $ bundle exec bake web:packages:check
131
+ ~~~
132
+
133
+ The first command checks that dependency installation is reproducible. The second checks both the generated manifest and the contents of `public/_components`.
134
+
135
+ For details about package selection, import maps, and alternative package managers, see the [Web Packages documentation](https://socketry.github.io/web-packages/).
data/context/index.yaml CHANGED
@@ -3,6 +3,8 @@
3
3
  ---
4
4
  description: A simple client-server SPA framework.
5
5
  metadata:
6
+ bug_tracker_uri: https://github.com/socketry/lively/issues
7
+ changelog_uri: https://github.com/socketry/lively/blob/main/releases.md
6
8
  documentation_uri: https://socketry.github.io/lively/
7
9
  source_code_uri: https://github.com/socketry/lively.git
8
10
  files:
@@ -10,6 +12,10 @@ files:
10
12
  title: Getting Started
11
13
  description: This guide will help you get started with Lively, a framework for building
12
14
  real-time applications in Ruby.
15
+ - path: client-javascript-packages.md
16
+ title: Client JavaScript Packages
17
+ description: This guide explains how to organize, test, and deploy client-side JavaScript
18
+ packages in a Lively application.
13
19
  - path: worms-tutorial.md
14
20
  title: Building a Worms Game with Lively
15
21
  description: This tutorial will guide you through creating a Worms-style game using
data/lib/lively/assets.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2025, by Samuel Williams.
4
+ # Copyright, 2021-2026, by Samuel Williams.
5
5
 
6
6
  require "uri"
7
7
  require "protocol/http/middleware"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2026, by Samuel Williams.
4
+ # Copyright, 2026, by Samuel Williams.
5
5
 
6
6
  require_relative "middleware"
7
7
  require "falcon/environment/server"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2026, by Samuel Williams.
4
+ # Copyright, 2026, by Samuel Williams.
5
5
 
6
6
  require_relative "../application"
7
7
  require_relative "../assets"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024-2025, by Samuel Williams.
4
+ # Copyright, 2024-2026, by Samuel Williams.
5
5
 
6
6
  # @namespace
7
7
  module Lively
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Lively
8
- VERSION = "0.23.0"
8
+ VERSION = "0.24.0"
9
9
  end
data/lib/lively.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2024, by Samuel Williams.
4
+ # Copyright, 2021-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "lively/version"
7
7
 
@@ -0,0 +1,38 @@
1
+ {
2
+ "format": 1,
3
+ "base": "/_components/",
4
+ "imports": {
5
+ "live": "/_components/@socketry/live/Live.js",
6
+ "live-audio": "/_components/@socketry/live-audio/Live/Audio.js",
7
+ "morphdom": "/_components/morphdom/morphdom-esm.js"
8
+ },
9
+ "packages": {
10
+ "@socketry/live": {
11
+ "version": "0.17.0",
12
+ "source": ".",
13
+ "files": {
14
+ "Live.js": "c036db246f9530240788b499c197d65356e81c9022bf927e260a267b7729f256"
15
+ }
16
+ },
17
+ "@socketry/live-audio": {
18
+ "version": "0.5.1",
19
+ "source": ".",
20
+ "files": {
21
+ "Live/Audio.js": "786d04e3fef1ae228bbf9784c013c63f6a77fad3ec97e38de4627b7b6fae5fc6",
22
+ "Live/Audio/Controller.js": "808e70ce652227cf2db50f7a4a86c328026d8bd2d2971ed4b9cbab47c139b587",
23
+ "Live/Audio/Library.js": "5c42c2f88c80241f03e791627934ce4f4a07094d1e36b1a5e01a56c5ac657498",
24
+ "Live/Audio/Output.js": "7d38b7a8fea6c3225ff854c8fcc671e783fbe95bcfb7edaae37886d430cd52e0",
25
+ "Live/Audio/Sound.js": "5b43b81409bee5dc4a4ee78bf70fcfcf84014e8f1c6237fa4978760be4ff4b83",
26
+ "Live/Audio/Visualizer.js": "9d0fd06fb3d9dca70e3e1a29445ec34dc1818d0132f50b358450c44953a60a22"
27
+ }
28
+ },
29
+ "morphdom": {
30
+ "version": "2.7.8",
31
+ "source": "dist",
32
+ "files": {
33
+ "morphdom-esm.js": "b5ecceffde9493a3e5f6d1ca80277f580a1146ca3b3e0091cb3c398d6b2754b3"
34
+ }
35
+ }
36
+ },
37
+ "digest": "fdddf14f8aab179ed60bceeb4767c45132426324d05eb94301936397ca78e402"
38
+ }
@@ -266,6 +266,11 @@ var specialElHandlers = {
266
266
  if (nodeName === 'OPTGROUP') {
267
267
  optgroup = curChild;
268
268
  curChild = optgroup.firstChild;
269
+ // handle empty optgroups
270
+ if (!curChild) {
271
+ curChild = optgroup.nextSibling;
272
+ optgroup = null;
273
+ }
269
274
  } else {
270
275
  if (nodeName === 'OPTION') {
271
276
  if (curChild.hasAttribute('selected')) {
@@ -308,10 +313,19 @@ function morphdomFactory(morphAttrs) {
308
313
  }
309
314
 
310
315
  if (typeof toNode === 'string') {
311
- if (fromNode.nodeName === '#document' || fromNode.nodeName === 'HTML' || fromNode.nodeName === 'BODY') {
316
+ if (fromNode.nodeName === '#document' || fromNode.nodeName === 'HTML') {
312
317
  var toNodeHtml = toNode;
313
318
  toNode = doc.createElement('html');
314
319
  toNode.innerHTML = toNodeHtml;
320
+ } else if (fromNode.nodeName === 'BODY') {
321
+ var toNodeBody = toNode;
322
+ toNode = doc.createElement('html');
323
+ toNode.innerHTML = toNodeBody;
324
+ // Extract the body element from the created HTML structure
325
+ var bodyElement = toNode.querySelector('body');
326
+ if (bodyElement) {
327
+ toNode = bodyElement;
328
+ }
315
329
  } else {
316
330
  toNode = toElement(toNode);
317
331
  }
@@ -491,8 +505,16 @@ function morphdomFactory(morphAttrs) {
491
505
 
492
506
  if (!childrenOnly) {
493
507
  // optional
494
- if (onBeforeElUpdated(fromEl, toEl) === false) {
508
+ var beforeUpdateResult = onBeforeElUpdated(fromEl, toEl);
509
+ if (beforeUpdateResult === false) {
495
510
  return;
511
+ } else if (beforeUpdateResult instanceof HTMLElement) {
512
+ fromEl = beforeUpdateResult;
513
+ // reindex the new fromEl in case it's not in the same
514
+ // tree as the original fromEl
515
+ // (Phoenix LiveView sometimes returns a cloned tree,
516
+ // but keyed lookups would still point to the original tree)
517
+ indexTree(fromEl);
496
518
  }
497
519
 
498
520
  // update attributes on original DOM element first
data/readme.md CHANGED
@@ -10,6 +10,8 @@ Please see the [project documentation](https://socketry.github.io/lively/) for m
10
10
 
11
11
  - [Getting Started](https://socketry.github.io/lively/guides/getting-started/index) - This guide will help you get started with Lively, a framework for building real-time applications in Ruby.
12
12
 
13
+ - [Client JavaScript Packages](https://socketry.github.io/lively/guides/client-javascript-packages/index) - This guide explains how to organize, test, and deploy client-side JavaScript packages in a Lively application.
14
+
13
15
  - [Building a Worms Game with Lively](https://socketry.github.io/lively/guides/worms-tutorial/index) - This tutorial will guide you through creating a Worms-style game using Lively, a Ruby framework for building real-time applications.
14
16
 
15
17
  - [Building a Flappy Bird Game with Live Views](https://socketry.github.io/lively/guides/flappy-bird-tutorial/index) - This tutorial will guide you through creating a complete Flappy Bird-style game using Live Views, a Ruby framework for building real-time interactive applications.
@@ -20,6 +22,10 @@ Please see the [project documentation](https://socketry.github.io/lively/) for m
20
22
 
21
23
  Please see the [project releases](https://socketry.github.io/lively/releases/index) for all releases.
22
24
 
25
+ ### v0.24.0
26
+
27
+ - [Web Packages](https://socketry.github.io/lively/releases/index#web-packages)
28
+
23
29
  ### v0.18.0
24
30
 
25
31
  - Add support for HTTY.
@@ -57,10 +63,6 @@ Please see the [project releases](https://socketry.github.io/lively/releases/ind
57
63
 
58
64
  - Fixed guide rendering and test suite.
59
65
 
60
- ### v0.13.1
61
-
62
- - Tidied up gem dependencies.
63
-
64
66
  ## See Also
65
67
 
66
68
  - [live](https://github.com/socketry/live) — Provides client-server communication using websockets.
@@ -70,26 +72,26 @@ Please see the [project releases](https://socketry.github.io/lively/releases/ind
70
72
 
71
73
  We welcome contributions to this project.
72
74
 
73
- 1. Fork it.
75
+ 1. Fork the repository.
74
76
  2. Create your feature branch (`git checkout -b my-new-feature`).
75
- 3. Commit your changes (`git commit -am 'Add some feature'`).
77
+ 3. Commit your changes (`git commit -am 'Add some feature.'`).
76
78
  4. Push to the branch (`git push origin my-new-feature`).
77
- 5. Create new Pull Request.
79
+ 5. Create a new pull request.
78
80
 
79
81
  ### Running Tests
80
82
 
81
83
  To run the test suite:
82
84
 
83
- ``` shell
84
- bundle exec sus
85
+ ``` bash
86
+ $ bundle exec sus
85
87
  ```
86
88
 
87
89
  ### Making Releases
88
90
 
89
91
  To make a new release:
90
92
 
91
- ``` shell
92
- bundle exec bake gem:release:patch # or minor or major
93
+ ``` bash
94
+ $ bundle exec bake gem:release:patch # or minor or major
93
95
  ```
94
96
 
95
97
  ### Developer Certificate of Origin
data/releases.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Releases
2
2
 
3
+ ## v0.24.0
4
+
5
+ ### Web Packages
6
+
7
+ Lively now uses `web-packages` v0.2 after the project was renamed from `bake-node`. Client package configuration now uses the `web-packages` key, package projections are managed through the `web:packages` Bake namespace, and the unchanged projection manifest is now stored as `.manifest.json`.
8
+
3
9
  ## v0.18.0
4
10
 
5
11
  - Add support for HTTY.
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.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.19'
139
+ - !ruby/object:Gem::Dependency
140
+ name: web-packages
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.2'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.2'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: xrb
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -156,6 +170,7 @@ extensions: []
156
170
  extra_rdoc_files: []
157
171
  files:
158
172
  - bin/lively
173
+ - context/client-javascript-packages.md
159
174
  - context/flappy-bird-tutorial.md
160
175
  - context/game-audio-tutorial.md
161
176
  - context/getting-started.md
@@ -176,22 +191,15 @@ files:
176
191
  - lib/lively/router.rb
177
192
  - lib/lively/version.rb
178
193
  - license.md
194
+ - public/_components/.manifest.json
179
195
  - public/_components/@socketry/live-audio/Live/Audio.js
180
196
  - public/_components/@socketry/live-audio/Live/Audio/Controller.js
181
197
  - public/_components/@socketry/live-audio/Live/Audio/Library.js
182
198
  - public/_components/@socketry/live-audio/Live/Audio/Output.js
183
199
  - public/_components/@socketry/live-audio/Live/Audio/Sound.js
184
200
  - public/_components/@socketry/live-audio/Live/Audio/Visualizer.js
185
- - public/_components/@socketry/live-audio/package.json
186
- - public/_components/@socketry/live-audio/readme.md
187
201
  - public/_components/@socketry/live/Live.js
188
- - public/_components/@socketry/live/package.json
189
- - public/_components/@socketry/live/readme.md
190
202
  - public/_components/morphdom/morphdom-esm.js
191
- - public/_components/morphdom/morphdom-factory.js
192
- - public/_components/morphdom/morphdom-umd.js
193
- - public/_components/morphdom/morphdom-umd.min.js
194
- - public/_components/morphdom/morphdom.js
195
203
  - public/_static/Falcon.png
196
204
  - public/_static/icon.png
197
205
  - public/_static/index.css
@@ -203,6 +211,8 @@ homepage: https://github.com/socketry/lively
203
211
  licenses:
204
212
  - MIT
205
213
  metadata:
214
+ bug_tracker_uri: https://github.com/socketry/lively/issues
215
+ changelog_uri: https://github.com/socketry/lively/blob/main/releases.md
206
216
  documentation_uri: https://socketry.github.io/lively/
207
217
  source_code_uri: https://github.com/socketry/lively.git
208
218
  rdoc_options: []
metadata.gz.sig CHANGED
Binary file
@@ -1,39 +0,0 @@
1
- {
2
- "name": "@socketry/live",
3
- "type": "module",
4
- "version": "0.17.0",
5
- "description": "Live HTML tags for Ruby.",
6
- "main": "Live.js",
7
- "exports": {
8
- ".": "./Live.js"
9
- },
10
- "files": [
11
- "Live.js"
12
- ],
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/socketry/live-js.git"
16
- },
17
- "scripts": {
18
- "test": "node --test"
19
- },
20
- "devDependencies": {
21
- "jsdom": "^24.0",
22
- "ws": "^8.17"
23
- },
24
- "dependencies": {
25
- "morphdom": "^2.7"
26
- },
27
- "keywords": [
28
- "live",
29
- "dynamic",
30
- "html",
31
- "ruby"
32
- ],
33
- "author": "Samuel Williams <samuel.williams@oriontransfer.co.nz> (http://www.codeotaku.com/)",
34
- "license": "MIT",
35
- "bugs": {
36
- "url": "https://github.com/socketry/live-js/issues"
37
- },
38
- "homepage": "https://github.com/socketry/live-js#readme"
39
- }