achilles 1.1.2 → 1.1.4
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
- data/CHANGELOG.md +17 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +3 -5
- data/Rakefile +1 -0
- data/app/javascript/achilles/application/dom-mutation-observer/observer.js +13 -3
- data/app/javascript/achilles/components/components_class_mapper.js +1 -1
- data/app/javascript/achilles/components/components_registry.js +21 -8
- data/docs/releases/v1.1.3.md +14 -0
- data/docs/releases/v1.1.4.md +16 -0
- data/docs/upgrading.md +2 -0
- data/lib/achilles/version.rb +1 -1
- metadata +4 -4
- data/docs/core-js-gaps.md +0 -26
- data/docs/v1-roadmap.md +0 -68
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e59beb8e8ab33df4ada94377c9fc2b6dd6ae961c92c763cc8c512aa0c5fa5d8
|
|
4
|
+
data.tar.gz: 4b11194cec10e35dc71b6a421f12bf3ad4fcfb686d379c4fb4945f20bb64ba3e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5987a86094329766c89ef1288865da37e5ea856a11dd84fc3e73b3f4087388fcd35675968643674b019ab8ae04039902397ac427e082c177f9f4204adc7340ee
|
|
7
|
+
data.tar.gz: 0b0d801e5a7f4ce5263804a13164ae33ee5ca999eac205471bed8e8a3eb649378c6323e5c920d8b77ee4bc0200e9881e5749b4fa454489aa4b1fdf2d9559bdf1
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to Achilles will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 1.1.4
|
|
6
|
+
|
|
7
|
+
### Performance
|
|
8
|
+
|
|
9
|
+
- Speed up component registration by querying each component's ID directly in
|
|
10
|
+
the browser while preserving duplicate-ID detection.
|
|
11
|
+
- Skip component discovery for text-only DOM updates and reconcile changes
|
|
12
|
+
to component markers and IDs.
|
|
13
|
+
- Limit Turbo Frame teardown lookups to registered components in the
|
|
14
|
+
outgoing frame.
|
|
15
|
+
|
|
16
|
+
## 1.1.3
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Resolve component class names and IDs only among registered entries.
|
|
21
|
+
|
|
5
22
|
## 1.1.2
|
|
6
23
|
|
|
7
24
|
### Fixed
|
data/CONTRIBUTING.md
CHANGED
data/README.md
CHANGED
|
@@ -8,10 +8,8 @@ Achilles scans the page for elements with `data-component-class`, instantiates
|
|
|
8
8
|
the matching JavaScript class, and calls `setup` and `teardown` as Turbo renders
|
|
9
9
|
new pages or new component markup is inserted.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
and then read the [1.1.1](docs/releases/v1.1.1.md) and
|
|
14
|
-
[1.1.2](docs/releases/v1.1.2.md) release notes.
|
|
11
|
+
If you are upgrading an existing app, see the [upgrade index](docs/upgrading.md)
|
|
12
|
+
for version-specific notes.
|
|
15
13
|
|
|
16
14
|
## Why Achilles?
|
|
17
15
|
|
|
@@ -281,7 +279,7 @@ If no timezone is present, Achilles falls back to `Etc/UTC`.
|
|
|
281
279
|
Applications upgrading to `1.1.0` should read the
|
|
282
280
|
[1.1.0 upgrade guide](docs/upgrading-to-1.1.0.md). The complete upgrade index
|
|
283
281
|
lives in [docs/upgrading.md](docs/upgrading.md), and the current release note is
|
|
284
|
-
available at [docs/releases/v1.1.
|
|
282
|
+
available at [docs/releases/v1.1.3.md](docs/releases/v1.1.3.md).
|
|
285
283
|
|
|
286
284
|
## Upgrading From 0.1.3
|
|
287
285
|
|
data/Rakefile
CHANGED
|
@@ -9,7 +9,12 @@ class Observer {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
config() {
|
|
12
|
-
return {
|
|
12
|
+
return {
|
|
13
|
+
attributes: true,
|
|
14
|
+
attributeFilter: ["id", "data-component-class"],
|
|
15
|
+
childList: true,
|
|
16
|
+
subtree: true,
|
|
17
|
+
};
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
start() {
|
|
@@ -22,8 +27,13 @@ class Observer {
|
|
|
22
27
|
this._callbackScheduled = false;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
domChangedCallback(mutationsList
|
|
26
|
-
if (this._callbackScheduled) {
|
|
30
|
+
domChangedCallback(mutationsList) {
|
|
31
|
+
if (this._callbackScheduled || !mutationsList.some((mutation) => {
|
|
32
|
+
// Replacing text cannot add or remove component roots.
|
|
33
|
+
return mutation.type !== "childList" ||
|
|
34
|
+
Array.from(mutation.addedNodes).some((node) => node.nodeType !== Node.TEXT_NODE) ||
|
|
35
|
+
Array.from(mutation.removedNodes).some((node) => node.nodeType !== Node.TEXT_NODE);
|
|
36
|
+
})) {
|
|
27
37
|
return;
|
|
28
38
|
}
|
|
29
39
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Single Responsibility: Contains the list of all view components so it can be instantiated
|
|
2
2
|
class ComponentsClassMapper {
|
|
3
|
-
_componentsClassMapper =
|
|
3
|
+
_componentsClassMapper = Object.create(null);
|
|
4
4
|
|
|
5
5
|
addComponentClass(key, klass) {
|
|
6
6
|
this._componentsClassMapper[key] = klass;
|
|
@@ -2,11 +2,19 @@ import { AppConstants } from "achilles/application/app_constants";
|
|
|
2
2
|
|
|
3
3
|
// Contains all the registered components in a page at the current moment
|
|
4
4
|
class ComponentsRegistry {
|
|
5
|
-
_registeredComponents =
|
|
5
|
+
_registeredComponents = Object.create(null);
|
|
6
6
|
strictLifecycleErrors = false;
|
|
7
7
|
|
|
8
8
|
matchingElementsForId(id) {
|
|
9
|
-
|
|
9
|
+
if(typeof id !== 'string')
|
|
10
|
+
return [];
|
|
11
|
+
|
|
12
|
+
const css = globalThis.window?.CSS;
|
|
13
|
+
// CSS selectors cannot preserve null characters or unpaired surrogates.
|
|
14
|
+
const selector = id !== '' && !/[\0\uD800-\uDFFF]/u.test(id) && typeof css?.escape === 'function'
|
|
15
|
+
? `#${css.escape(id)}`
|
|
16
|
+
: '[id]';
|
|
17
|
+
return [...document.querySelectorAll(selector)].filter((elem) => elem.id === id);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
elementForId(id) {
|
|
@@ -134,20 +142,25 @@ class ComponentsRegistry {
|
|
|
134
142
|
if(!rootElement || typeof rootElement.contains !== 'function')
|
|
135
143
|
return;
|
|
136
144
|
|
|
145
|
+
const candidateIds = typeof rootElement.querySelectorAll === 'function'
|
|
146
|
+
? new Set([rootElement.id, ...Array.from(rootElement.querySelectorAll('[id]'), (element) => element.id)])
|
|
147
|
+
: null;
|
|
148
|
+
|
|
137
149
|
Object.values(this._registeredComponents)
|
|
138
150
|
.filter((component) => {
|
|
139
151
|
if(component.id === AppConstants.PageComponentId)
|
|
140
152
|
return false;
|
|
153
|
+
if(candidateIds && !candidateIds.has(component.id))
|
|
154
|
+
return false;
|
|
141
155
|
|
|
142
156
|
let element = this.elementForId(component.id);
|
|
143
157
|
return element && rootElement.contains(element);
|
|
144
158
|
})
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.teardownAndDeregister(component.id);
|
|
159
|
+
.map(({ id }) => ({ id, depth: this.elementDepth(id) }))
|
|
160
|
+
.sort((first, second) => second.depth - first.depth)
|
|
161
|
+
.forEach(({ id }) => {
|
|
162
|
+
if(this.getRegisteredComponent(id))
|
|
163
|
+
this.teardownAndDeregister(id);
|
|
151
164
|
});
|
|
152
165
|
}
|
|
153
166
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Achilles 1.1.3
|
|
2
|
+
|
|
3
|
+
Achilles now looks up component class names and IDs only among registered
|
|
4
|
+
entries. This fixes lookups when a class name or ID matches a built-in
|
|
5
|
+
JavaScript object property.
|
|
6
|
+
|
|
7
|
+
## Upgrading
|
|
8
|
+
|
|
9
|
+
Update the Achilles gem to `1.1.3` and keep your existing component markup and
|
|
10
|
+
registration code. If you are upgrading from a version earlier than `1.1.0`,
|
|
11
|
+
start with the [1.1.0 upgrade guide](../upgrading-to-1.1.0.md).
|
|
12
|
+
|
|
13
|
+
- [Changelog](../../CHANGELOG.md)
|
|
14
|
+
- [Upgrade index](../upgrading.md)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Achilles 1.1.4
|
|
2
|
+
|
|
3
|
+
Achilles now looks up each component ID directly when registering it. Duplicate
|
|
4
|
+
IDs still prevent registration. Text-only DOM changes no longer trigger a
|
|
5
|
+
component scan. On Turbo Frame replacement, Achilles finds the outgoing
|
|
6
|
+
components inside the frame and tears down children before their parents.
|
|
7
|
+
|
|
8
|
+
## Upgrading
|
|
9
|
+
|
|
10
|
+
Update to `1.1.4` using the existing component markup and registration code.
|
|
11
|
+
Verify Turbo Frame replacement, browser history restoration, and dynamic
|
|
12
|
+
component insertion in your application. If you are upgrading from a version
|
|
13
|
+
earlier than `1.1.0`, start with the [1.1.0 upgrade guide](../upgrading-to-1.1.0.md).
|
|
14
|
+
|
|
15
|
+
- [Changelog](../../CHANGELOG.md)
|
|
16
|
+
- [Upgrade index](../upgrading.md)
|
data/docs/upgrading.md
CHANGED
|
@@ -12,6 +12,8 @@ setup, component markup, lifecycle behavior, or public APIs.
|
|
|
12
12
|
|
|
13
13
|
## Release Notes
|
|
14
14
|
|
|
15
|
+
- [Achilles 1.1.4](releases/v1.1.4.md)
|
|
16
|
+
- [Achilles 1.1.3](releases/v1.1.3.md)
|
|
15
17
|
- [Achilles 1.1.2](releases/v1.1.2.md)
|
|
16
18
|
- [Achilles 1.1.1](releases/v1.1.1.md)
|
|
17
19
|
- [Achilles 1.1.0](releases/v1.1.0.md)
|
data/lib/achilles/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: achilles
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jey Geethan
|
|
@@ -87,15 +87,15 @@ files:
|
|
|
87
87
|
- app/views/layouts/achilles/application.html.erb
|
|
88
88
|
- config/importmap.rb
|
|
89
89
|
- config/routes.rb
|
|
90
|
-
- docs/core-js-gaps.md
|
|
91
90
|
- docs/migrating-from-0.1.3-to-v1.md
|
|
92
91
|
- docs/release-checklist.md
|
|
93
92
|
- docs/releases/v1.1.0.md
|
|
94
93
|
- docs/releases/v1.1.1.md
|
|
95
94
|
- docs/releases/v1.1.2.md
|
|
95
|
+
- docs/releases/v1.1.3.md
|
|
96
|
+
- docs/releases/v1.1.4.md
|
|
96
97
|
- docs/upgrading-to-1.1.0.md
|
|
97
98
|
- docs/upgrading.md
|
|
98
|
-
- docs/v1-roadmap.md
|
|
99
99
|
- lib/achilles.rb
|
|
100
100
|
- lib/achilles/engine.rb
|
|
101
101
|
- lib/achilles/version.rb
|
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
121
121
|
- !ruby/object:Gem::Version
|
|
122
122
|
version: '0'
|
|
123
123
|
requirements: []
|
|
124
|
-
rubygems_version:
|
|
124
|
+
rubygems_version: 3.6.9
|
|
125
125
|
specification_version: 4
|
|
126
126
|
summary: JavaScript component lifecycle for Rails and Turbo apps
|
|
127
127
|
test_files: []
|
data/docs/core-js-gaps.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Core JavaScript Gaps
|
|
2
|
-
|
|
3
|
-
This is the current improvement backlog for Achilles core JavaScript. API
|
|
4
|
-
reference docs should wait until the structure settles.
|
|
5
|
-
|
|
6
|
-
## Completed
|
|
7
|
-
|
|
8
|
-
- Added an explicit `Application#start` and `Application#stop` lifecycle.
|
|
9
|
-
- Made Turbo event listeners removable.
|
|
10
|
-
- Validated that component roots have non-empty ids before registration.
|
|
11
|
-
- Changed teardown order so child components tear down before parent components.
|
|
12
|
-
- Deleted deregistered registry entries instead of leaving `null` tombstones.
|
|
13
|
-
- Batched mutation observer setup work with a microtask debounce.
|
|
14
|
-
- Replaced one-way lifecycle flags with a `mounted` state while keeping
|
|
15
|
-
`setupExecuted` and `teardownExecuted` as compatibility aliases.
|
|
16
|
-
- Added tests for missing ids, duplicate starts, listener cleanup,
|
|
17
|
-
child-before-parent teardown, dynamic insertion batching, deregistration, and
|
|
18
|
-
remounting a reused component instance.
|
|
19
|
-
- Chose a DOM ancestry model for nested components under the single synthetic
|
|
20
|
-
`Page` root.
|
|
21
|
-
- Split JavaScript tests by parser, registry, application, Turbo hooks, and
|
|
22
|
-
component base responsibility.
|
|
23
|
-
- Added package/file-list regression coverage for the gemspec.
|
|
24
|
-
- Added opt-in strict lifecycle error handling for tests and development.
|
|
25
|
-
|
|
26
|
-
## Remaining Priority Gaps
|
data/docs/v1-roadmap.md
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# Achilles v1 Roadmap
|
|
2
|
-
|
|
3
|
-
This document tracks the work needed before publishing Achilles `1.0.0`.
|
|
4
|
-
The goal is a stable open source release that is safe to evaluate in real Rails
|
|
5
|
-
applications, even if it intentionally removes legacy behavior from the `0.x`
|
|
6
|
-
line.
|
|
7
|
-
|
|
8
|
-
## Product Direction
|
|
9
|
-
|
|
10
|
-
Achilles is a small JavaScript lifecycle layer for Rails + Turbo applications.
|
|
11
|
-
It gives teams explicit component classes mapped to DOM nodes without requiring
|
|
12
|
-
Stimulus controller conventions or a JavaScript build step.
|
|
13
|
-
|
|
14
|
-
## v1 Public API
|
|
15
|
-
|
|
16
|
-
The v1 API should be small and documented:
|
|
17
|
-
|
|
18
|
-
- `Application`
|
|
19
|
-
- `ComponentBase`
|
|
20
|
-
- `ComponentsClassMapper`
|
|
21
|
-
- DOM discovery through `data-component-class`
|
|
22
|
-
- component root lookup through `rootElement()`
|
|
23
|
-
- `rootNode()` as an alias for `rootElement()`
|
|
24
|
-
- CSS selector lookup through `rootElementSelector()`
|
|
25
|
-
- lifecycle hooks: `setup()` and `teardown()`
|
|
26
|
-
- Turbo integration through `turbo:load` and `turbo:before-render`
|
|
27
|
-
|
|
28
|
-
## Planned Breaking Changes
|
|
29
|
-
|
|
30
|
-
- Make `rootElement()` return the component's DOM element.
|
|
31
|
-
- Keep `rootNode()` as an alias for `rootElement()`.
|
|
32
|
-
- Remove the jQuery return behavior from `rootElement()`.
|
|
33
|
-
- Keep Achilles internals independent from jQuery.
|
|
34
|
-
- Require every component root to have a unique `id`.
|
|
35
|
-
- Treat setup and teardown as idempotent lifecycle operations managed by
|
|
36
|
-
Achilles.
|
|
37
|
-
|
|
38
|
-
## Release Gates
|
|
39
|
-
|
|
40
|
-
Do not publish `1.0.0` until these are true:
|
|
41
|
-
|
|
42
|
-
- Rails test suite passes.
|
|
43
|
-
- JavaScript lifecycle tests cover parser, registry, Turbo hooks, root lookup,
|
|
44
|
-
setup idempotence, teardown idempotence, missing elements, and dynamic DOM
|
|
45
|
-
insertion.
|
|
46
|
-
- Dummy app asset precompile passes.
|
|
47
|
-
- README includes install, usage, lifecycle, dynamic DOM, migration, and API
|
|
48
|
-
reference sections.
|
|
49
|
-
- `CHANGELOG.md` documents all breaking changes from `0.1.3`.
|
|
50
|
-
- CI runs tests on supported Ruby and Rails versions.
|
|
51
|
-
- At least one real application has tested the release candidate.
|
|
52
|
-
|
|
53
|
-
## Release Plan
|
|
54
|
-
|
|
55
|
-
1. Publish a compatibility release in the `0.x` line with dependency and
|
|
56
|
-
lifecycle fixes.
|
|
57
|
-
2. Create a `v1.0.0.rc1` prerelease after the v1 API and tests are complete.
|
|
58
|
-
3. Test `v1.0.0.rc1` in existing applications.
|
|
59
|
-
4. Publish `1.0.0` only after the migration guide and real-app testing are done.
|
|
60
|
-
|
|
61
|
-
Follow the [release checklist](release-checklist.md) when building and testing
|
|
62
|
-
release candidates.
|
|
63
|
-
|
|
64
|
-
## Current Recommendation
|
|
65
|
-
|
|
66
|
-
Do not push `v1.0.0` yet. The project is ready for a compatibility release, but
|
|
67
|
-
`1.0.0` should wait for the final v1 API cleanup and real-application testing
|
|
68
|
-
through a release candidate.
|