From fcc367879fbb6d3c081876bcdada8958fca4a8cb Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 8 Sep 2026 21:09:47 +1200 Subject: [PATCH 1/3] Adopt bake-node for browser test packages Assisted-By: devx/7ef83274-928f-499d-b668-48449b1ff60e --- .github/workflows/test-packages.yaml | 31 + .gitignore | 1 + gems.rb | 2 + releases.md | 6 + .../live/.website/_components/.bake-node.json | 25 + .../@socketry/live/Live.js | 0 .../morphdom}/morphdom-esm.js | 0 test/live/.website/index.html | 9 +- .../.website/node_modules/.package-lock.json | 22 - .../node_modules/@socketry/live/package.json | 36 - .../node_modules/@socketry/live/readme.md | 174 ---- .../node_modules/morphdom/CHANGELOG.md | 253 ------ .../.website/node_modules/morphdom/LICENSE | 21 - .../.website/node_modules/morphdom/README.md | 265 ------ .../morphdom/dist/morphdom-factory.js | 710 ---------------- .../morphdom/dist/morphdom-umd.js | 782 ------------------ .../morphdom/dist/morphdom-umd.min.js | 1 - .../node_modules/morphdom/dist/morphdom.js | 776 ----------------- .../morphdom/docs/old-benchmark.md | 204 ----- .../node_modules/morphdom/docs/virtual-dom.md | 38 - .../.website/node_modules/morphdom/factory.js | 1 - .../.website/node_modules/morphdom/index.d.ts | 21 - .../node_modules/morphdom/package.json | 63 -- .../node_modules/morphdom/src/index.js | 6 - .../node_modules/morphdom/src/morphAttrs.js | 63 -- .../node_modules/morphdom/src/morphdom.js | 482 ----------- .../morphdom/src/specialElHandlers.js | 115 --- .../node_modules/morphdom/src/util.js | 113 --- test/live/.website/package-lock.json | 3 +- test/live/.website/package.json | 23 + test/live/website.rb | 14 +- 31 files changed, 105 insertions(+), 4155 deletions(-) create mode 100644 .github/workflows/test-packages.yaml create mode 100644 test/live/.website/_components/.bake-node.json rename test/live/.website/{node_modules => _components}/@socketry/live/Live.js (100%) rename test/live/.website/{node_modules/morphdom/dist => _components/morphdom}/morphdom-esm.js (100%) delete mode 100644 test/live/.website/node_modules/.package-lock.json delete mode 100644 test/live/.website/node_modules/@socketry/live/package.json delete mode 100644 test/live/.website/node_modules/@socketry/live/readme.md delete mode 100644 test/live/.website/node_modules/morphdom/CHANGELOG.md delete mode 100644 test/live/.website/node_modules/morphdom/LICENSE delete mode 100644 test/live/.website/node_modules/morphdom/README.md delete mode 100644 test/live/.website/node_modules/morphdom/dist/morphdom-factory.js delete mode 100644 test/live/.website/node_modules/morphdom/dist/morphdom-umd.js delete mode 100644 test/live/.website/node_modules/morphdom/dist/morphdom-umd.min.js delete mode 100644 test/live/.website/node_modules/morphdom/dist/morphdom.js delete mode 100644 test/live/.website/node_modules/morphdom/docs/old-benchmark.md delete mode 100644 test/live/.website/node_modules/morphdom/docs/virtual-dom.md delete mode 100644 test/live/.website/node_modules/morphdom/factory.js delete mode 100644 test/live/.website/node_modules/morphdom/index.d.ts delete mode 100644 test/live/.website/node_modules/morphdom/package.json delete mode 100644 test/live/.website/node_modules/morphdom/src/index.js delete mode 100644 test/live/.website/node_modules/morphdom/src/morphAttrs.js delete mode 100644 test/live/.website/node_modules/morphdom/src/morphdom.js delete mode 100644 test/live/.website/node_modules/morphdom/src/specialElHandlers.js delete mode 100644 test/live/.website/node_modules/morphdom/src/util.js diff --git a/.github/workflows/test-packages.yaml b/.github/workflows/test-packages.yaml new file mode 100644 index 0000000..fa113da --- /dev/null +++ b/.github/workflows/test-packages.yaml @@ -0,0 +1,31 @@ +name: Test Packages + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + test: + name: Test Packages + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v7 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby + bundler-cache: true + + - uses: actions/setup-node@v7 + with: + node-version: 24 + cache: npm + cache-dependency-path: test/live/.website/package-lock.json + + - name: Install dependencies + run: bundle exec bake node:install root=test/live/.website frozen=true + + - name: Check static packages + run: bundle exec bake node:packages:check root=test/live/.website diff --git a/.gitignore b/.gitignore index ee82a6f..bd4a7bf 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /gems.locked /.covered.db /external +/test/live/.website/node_modules diff --git a/gems.rb b/gems.rb index b2f4aa6..3b1ceaf 100644 --- a/gems.rb +++ b/gems.rb @@ -18,6 +18,8 @@ end group :test do + gem "bake-node" + gem "sus" gem "covered" diff --git a/releases.md b/releases.md index cec820c..eab5dd3 100644 --- a/releases.md +++ b/releases.md @@ -1,5 +1,11 @@ # Releases +## Unreleased + +### JavaScript Test Packages + +Live now uses Bake Node to install and project the JavaScript packages used by its browser integration tests. The generated static package manifest supplies the test page import map, while `node_modules` is treated as a disposable package-manager projection. + ## v0.19.0 ### Explicit Element Construction diff --git a/test/live/.website/_components/.bake-node.json b/test/live/.website/_components/.bake-node.json new file mode 100644 index 0000000..058539b --- /dev/null +++ b/test/live/.website/_components/.bake-node.json @@ -0,0 +1,25 @@ +{ + "format": 1, + "base": "/_components/", + "imports": { + "live": "/_components/@socketry/live/Live.js", + "morphdom": "/_components/morphdom/morphdom-esm.js" + }, + "packages": { + "@socketry/live": { + "version": "0.16.0", + "source": ".", + "files": { + "Live.js": "74d31c1af27eddaaf1c2cbd7d0c2b7e51e9f123800c130ce468ee0a998160f3d" + } + }, + "morphdom": { + "version": "2.7.7", + "source": "dist", + "files": { + "morphdom-esm.js": "48e804579b52b7e0f6a6331e6436d5d1c2e21c24f815528d8a91bc350984ec3a" + } + } + }, + "digest": "26730554c6c7938b737947014a44d59ee78feb7c2939acf53726caeb58685b4a" +} diff --git a/test/live/.website/node_modules/@socketry/live/Live.js b/test/live/.website/_components/@socketry/live/Live.js similarity index 100% rename from test/live/.website/node_modules/@socketry/live/Live.js rename to test/live/.website/_components/@socketry/live/Live.js diff --git a/test/live/.website/node_modules/morphdom/dist/morphdom-esm.js b/test/live/.website/_components/morphdom/morphdom-esm.js similarity index 100% rename from test/live/.website/node_modules/morphdom/dist/morphdom-esm.js rename to test/live/.website/_components/morphdom/morphdom-esm.js diff --git a/test/live/.website/index.html b/test/live/.website/index.html index 0543885..61a2c2a 100644 --- a/test/live/.website/index.html +++ b/test/live/.website/index.html @@ -3,12 +3,7 @@ Live Test @@ -21,4 +16,4 @@ Live.start(); - \ No newline at end of file + diff --git a/test/live/.website/node_modules/.package-lock.json b/test/live/.website/node_modules/.package-lock.json deleted file mode 100644 index 0fed5b4..0000000 --- a/test/live/.website/node_modules/.package-lock.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": ".website", - "lockfileVersion": 3, - "requires": true, - "packages": { - "node_modules/@socketry/live": { - "version": "0.16.0", - "resolved": "https://registry.npmjs.org/@socketry/live/-/live-0.16.0.tgz", - "integrity": "sha512-bf+RkpvwJnN5N/sQkZeIZcdWdzdEmy4hZvbrIyUXlw6v6VVCZfbN8FLMzGcTcNU3m0HX4b77wtC0o8U/36FbXA==", - "license": "MIT", - "dependencies": { - "morphdom": "^2.7" - } - }, - "node_modules/morphdom": { - "version": "2.7.7", - "resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.7.7.tgz", - "integrity": "sha512-04GmsiBcalrSCNmzfo+UjU8tt3PhZJKzcOy+r1FlGA7/zri8wre3I1WkYN9PT3sIeIKfW9bpyElA+VzOg2E24g==", - "license": "MIT" - } - } -} diff --git a/test/live/.website/node_modules/@socketry/live/package.json b/test/live/.website/node_modules/@socketry/live/package.json deleted file mode 100644 index 1a00e8f..0000000 --- a/test/live/.website/node_modules/@socketry/live/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "@socketry/live", - "type": "module", - "version": "0.16.0", - "description": "Live HTML tags for Ruby.", - "main": "Live.js", - "files": [ - "Live.js" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/socketry/live-js.git" - }, - "scripts": { - "test": "node --test" - }, - "devDependencies": { - "jsdom": "^24.0", - "ws": "^8.17" - }, - "dependencies": { - "morphdom": "^2.7" - }, - "keywords": [ - "live", - "dynamic", - "html", - "ruby" - ], - "author": "Samuel Williams (http://www.codeotaku.com/)", - "license": "MIT", - "bugs": { - "url": "https://github.com/socketry/live-js/issues" - }, - "homepage": "https://github.com/socketry/live-js#readme" -} diff --git a/test/live/.website/node_modules/@socketry/live/readme.md b/test/live/.website/node_modules/@socketry/live/readme.md deleted file mode 100644 index eeaf887..0000000 --- a/test/live/.website/node_modules/@socketry/live/readme.md +++ /dev/null @@ -1,174 +0,0 @@ -# Live.js - -A JavaScript client library for building interactive web applications with Ruby Live framework. - -[![Development Status](https://github.com/socketry/live-js/workflows/Test/badge.svg)](https://github.com/socketry/live-js/actions?workflow=Test) - -## Features - -- **Real-time Communication**: WebSocket-based client-server communication. -- **DOM Manipulation**: Efficient updating, replacing, and modifying HTML elements. -- **Event Forwarding**: Forward client events to server for processing. -- **Controller Loading**: Declarative JavaScript controller loading with `data-live-controller`. -- **Automatic Cleanup**: Proper lifecycle management and memory cleanup. -- **Live Elements**: Automatic binding and unbinding of live elements. - -## Usage - -### Installation - -```bash -npm install @socketry/live -``` - -### Basic Setup - -```javascript -import { Live } from '@socketry/live'; - -// Start the live connection -const live = Live.start({ - path: 'live', // WebSocket endpoint - base: window.location.href -}); -``` - -### Controller Loading - -Live.js supports declarative controller loading using the `data-live-controller` attribute: - -```html -
- -
-``` - -```javascript -// game_controller.mjs -export default function(element) { - console.log('Controller loaded for:', element); - - // Setup your controller logic - element.addEventListener('click', handleClick); - - // Return a controller object with cleanup - return { - dispose() { - element.removeEventListener('click', handleClick); - } - }; -} -``` - -## API Reference - -### Live Class - -#### Static Methods - -- `Live.start(options)` - Create and start a new Live instance - - `options.window` - Window object (defaults to globalThis) - - `options.path` - WebSocket path (defaults to 'live') - - `options.base` - Base URL (defaults to window.location.href) - -#### Instance Methods - -##### Connection Management -- `connect()` - Establish WebSocket connection -- `disconnect()` - Close WebSocket connection - -##### DOM Manipulation -- `update(id, html, options)` - Update element content -- `replace(selector, html, options)` - Replace elements -- `prepend(selector, html, options)` - Prepend content -- `append(selector, html, options)` - Append content -- `remove(selector, options)` - Remove elements - -##### Event Handling -- `forward(id, event)` - Forward event to server -- `forwardEvent(id, event, detail, preventDefault)` - Forward DOM event -- `forwardFormEvent(id, event, detail, preventDefault)` - Forward form event - -##### Script Execution -- `script(id, code, options)` - Execute JavaScript code -- `loadController(id, path, options)` - Load JavaScript controller - -##### Event Dispatching -- `dispatchEvent(selector, type, options)` - Dispatch custom events - -### Options Parameter - -Most methods accept an `options` parameter with: -- `options.reply` - If truthy, server will reply with `{reply: options.reply}` - -### Controller Pattern - -Controllers are JavaScript modules that manage view-specific behavior: - -```javascript -// Simple controller -export default function(element) { - // Setup code - return { - dispose() { - // Cleanup code - } - }; -} - -// With options -export default function(element, options) { - const config = options.config || {}; - // Use config... -} -``` - -## Live Elements - -Elements with the `live` CSS class are automatically managed: - -```html -
- Content that can be updated -
-``` - -## Event Examples - -### Basic Event Forwarding - -```javascript -// Forward click events -element.addEventListener('click', (event) => { - live.forwardEvent('my-element', event, { button: 'clicked' }); -}); - -// Forward form submissions -form.addEventListener('submit', (event) => { - live.forwardFormEvent('my-form', event, { action: 'submit' }); -}); -``` - -## Contributing - -We welcome contributions to this project. - -1. Fork it. -2. Create your feature branch (`git checkout -b my-new-feature`). -3. Commit your changes (`git commit -am 'Add some feature'`). -4. Push to the branch (`git push origin my-new-feature`). -5. Create new Pull Request. - -### Developer Certificate of Origin - -In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed. - -### Community Guidelines - -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. - -## See Also - - - [lively](https://github.com/socketry/lively) — Ruby framework for building interactive web applications. - - [live](https://github.com/socketry/live) — Provides client-server communication using websockets. - - [live-audio-js](https://github.com/socketry/live-audio-js) — Web Audio API-based game audio synthesis library. diff --git a/test/live/.website/node_modules/morphdom/CHANGELOG.md b/test/live/.website/node_modules/morphdom/CHANGELOG.md deleted file mode 100644 index 713bda0..0000000 --- a/test/live/.website/node_modules/morphdom/CHANGELOG.md +++ /dev/null @@ -1,253 +0,0 @@ -Changelog -========= - -# 2.x - -## 2.7.7 -- Fix stale build - -## 2.7.6 -- Fix typescript type definition -- handle empty optgroups - -## 2.7.5 -- Fix issue where empty optgroup in select prevents proper diffing - -## 2.7.4 -- Fix incorrect index references when returning a cloned tree from onBeforeElUpdated - -## 2.7.3 -- Allow returning a new fromEl tree from onBeforeElUpdated to be used morph for that branch - -## 2.7.2 -- Fix morphing duplicate ids of incompatible tags - -## 2.7.1 -- Pass toEl as second argument to `skipFromChildren` callback - -## 2.7.0 - -- Add new `addChild` and `skipFromChildren` callbacks to allow customization of how new children are -added to a parent as well as preserving the from tree when indexing changes for diffing. - -## 2.5.12 - -- Fix merge attrs with multiple properties [PR #175](https://github.com/patrick-steele-idem/morphdom/pull/175) - -## 2.5.11 - -- Multiple forms duplication [PR #174](https://github.com/patrick-steele-idem/morphdom/pull/174) - -## 2.5.10 - -- Pr/167 - Allow document fragment patching [PR #168](https://github.com/patrick-steele-idem/morphdom/pull/168) - -## 2.5.9 - -- Faster attrs merge [PR #165](https://github.com/patrick-steele-idem/morphdom/pull/165) - -## 2.5.8 - -- Minor improvements [PR #164](https://github.com/patrick-steele-idem/morphdom/pull/164) - -## 2.5.7 - -- Chore: Alternate refactor to #155 - Move isSameNode check [PR #156](https://github.com/patrick-steele-idem/morphdom/pull/156) -- Use attribute name with the prefix in XMLNS namespace [PR #133](https://github.com/patrick-steele-idem/morphdom/pull/133) - -## 2.5.6 - -- fixed the string with space trouble [PR #161](https://github.com/patrick-steele-idem/morphdom/pull/161) - -## 2.5.5 - -- Template support for creating element from string [PR #159](https://github.com/patrick-steele-idem/morphdom/pull/159) - -## 2.5.4 - -- Enhancement: Fix id key removal from tree when the element with key is inside a document fragment node (ex: shadow dom) [PR #119](https://github.com/patrick-steele-idem/morphdom/pull/119) -- Minor: small refactor to morphEl to own function [PR #149](small refactor to morphEl to own function) -- selectNode for range b/c documentElement not avail in Safari [commit](https://github.com/patrick-steele-idem/morphdom/commit/6afd2976ab4fac4d8e1575975531644ecc62bc1d) -- clarify getNodeKey docs [PR #151](https://github.com/patrick-steele-idem/morphdom/pull/151) - -## 2.5.3 - -- Minor: update deps [PR #145](https://github.com/patrick-steele-idem/morphdom/pull/145) -- Minor: Minor comments and very very minor refactors [PR #143](https://github.com/patrick-steele-idem/morphdom/pull/143) - -## 2.5.2 - -- New dist for 2.5.1. My bad! - -## 2.5.1 - -- Bugfix: Fix bug where wrong select option would get selected. [PR #117](https://github.com/patrick-steele-idem/morphdom/pull/117) - -## 2.5.0 - -- Enhancement: Publish es6 format as morphdom-esm.js [PR #141](https://github.com/patrick-steele-idem/morphdom/pull/141) -- Enhancement: Start removing old browser support code paths [PR #140](https://github.com/patrick-steele-idem/morphdom/pull/140) - -## 2.4.0 - -- Enhancement: Rollup 1.0 [PR #139](https://github.com/patrick-steele-idem/morphdom/pull/139) -- Enhancement: Add Typescript declaration file [PR #138](https://github.com/patrick-steele-idem/morphdom/pull/138) - -## 2.3.x - -### 2.3.1 - -- Bug: Fixed losing cursor position in Edge ([PR #100](https://github.com/patrick-steele-idem/morphdom/pull/100) by [@zastavnitskiy](https://github.com/zastavnitskiy)) - -### 2.3.0 - -- Changes to improve code maintainability. Single file is now split out into multiple modules and [rollup](https://github.com/rollup/rollup) is used to build the distribution files. - -## 2.2.x - -### 2.2.2 - -- Changes to ensure that `selectedIndex` is updated correctly in all browsers ([PR #94](https://github.com/patrick-steele-idem/morphdom/pull/94) by [@aknuds1](https://github.com/aknuds1)) - -### 2.2.1 - -- IE-specific bug: fix `