nodality 1.3.25 → 1.4.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.
- package/dist/animator.cjs.js +1 -1
- package/dist/animator.cjs.js.LICENSE.txt +1 -1
- package/dist/animator.esm.js +1 -1
- package/dist/animator.esm.js.LICENSE.txt +1 -1
- package/dist/audionew.cjs.js +1 -1
- package/dist/audionew.cjs.js.LICENSE.txt +1 -1
- package/dist/audionew.esm.js +1 -1
- package/dist/audionew.esm.js.LICENSE.txt +1 -1
- package/dist/base.cjs.js +1 -1
- package/dist/base.cjs.js.LICENSE.txt +1 -1
- package/dist/base.esm.js +1 -1
- package/dist/base.esm.js.LICENSE.txt +1 -1
- package/dist/beta-desktop-bar.cjs.js +1 -1
- package/dist/beta-desktop-bar.cjs.js.LICENSE.txt +1 -1
- package/dist/beta-desktop-bar.esm.js +1 -1
- package/dist/beta-desktop-bar.esm.js.LICENSE.txt +1 -1
- package/dist/beta-mobile-bar.cjs.js +1 -1
- package/dist/beta-mobile-bar.cjs.js.LICENSE.txt +1 -1
- package/dist/beta-mobile-bar.esm.js +1 -1
- package/dist/beta-mobile-bar.esm.js.LICENSE.txt +1 -1
- package/dist/bundle.umd.js +1 -1
- package/dist/bundle.umd.js.LICENSE.txt +20 -1
- package/dist/button.cjs.js +1 -1
- package/dist/button.cjs.js.LICENSE.txt +1 -1
- package/dist/button.esm.js +1 -1
- package/dist/button.esm.js.LICENSE.txt +1 -1
- package/dist/card-getter.cjs.js.LICENSE.txt +1 -1
- package/dist/card-getter.esm.js.LICENSE.txt +1 -1
- package/dist/center.cjs.js +1 -1
- package/dist/center.cjs.js.LICENSE.txt +1 -1
- package/dist/center.esm.js +1 -1
- package/dist/center.esm.js.LICENSE.txt +1 -1
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.cjs.js.LICENSE.txt +1 -1
- package/dist/checkbox.esm.js +1 -1
- package/dist/checkbox.esm.js.LICENSE.txt +1 -1
- package/dist/code.cjs.js +1 -1
- package/dist/code.cjs.js.LICENSE.txt +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/code.esm.js.LICENSE.txt +1 -1
- package/dist/container.cjs.js +1 -1
- package/dist/container.cjs.js.LICENSE.txt +1 -1
- package/dist/container.esm.js +1 -1
- package/dist/container.esm.js.LICENSE.txt +1 -1
- package/dist/data-list.cjs.js +1 -1
- package/dist/data-list.cjs.js.LICENSE.txt +1 -1
- package/dist/data-list.esm.js.LICENSE.txt +1 -1
- package/dist/designer.cjs.js +1 -1
- package/dist/designer.cjs.js.LICENSE.txt +20 -1
- package/dist/designer.esm.js +1 -1
- package/dist/designer.esm.js.LICENSE.txt +20 -1
- package/dist/element-mapper.cjs.js +1 -1
- package/dist/element-mapper.cjs.js.LICENSE.txt +1 -1
- package/dist/element-mapper.esm.js +1 -1
- package/dist/element-mapper.esm.js.LICENSE.txt +1 -1
- package/dist/finalresult.esm.js +1 -1
- package/dist/finalresult.esm.js.LICENSE.txt +20 -1
- package/dist/flex-card.cjs.js +1 -1
- package/dist/flex-card.cjs.js.LICENSE.txt +1 -1
- package/dist/flex-card.esm.js +1 -1
- package/dist/flex-card.esm.js.LICENSE.txt +1 -1
- package/dist/flex-grid.cjs.js +1 -1
- package/dist/flex-grid.cjs.js.LICENSE.txt +1 -1
- package/dist/flex-grid.esm.js +1 -1
- package/dist/flex-grid.esm.js.LICENSE.txt +1 -1
- package/dist/flex-row.cjs.js +1 -1
- package/dist/flex-row.cjs.js.LICENSE.txt +1 -1
- package/dist/flex-row.esm.js +1 -1
- package/dist/flex-row.esm.js.LICENSE.txt +1 -1
- package/dist/floating-input.cjs.js +1 -1
- package/dist/floating-input.cjs.js.LICENSE.txt +1 -1
- package/dist/floating-input.esm.js +1 -1
- package/dist/floating-input.esm.js.LICENSE.txt +1 -1
- package/dist/free.cjs.js +1 -1
- package/dist/free.cjs.js.LICENSE.txt +1 -1
- package/dist/free.esm.js +1 -1
- package/dist/free.esm.js.LICENSE.txt +1 -1
- package/dist/horizontal-scroller.cjs.js.LICENSE.txt +1 -1
- package/dist/horizontal-scroller.esm.js.LICENSE.txt +1 -1
- package/dist/image-picker.cjs.js +1 -1
- package/dist/image-picker.cjs.js.LICENSE.txt +1 -1
- package/dist/image-picker.esm.js +1 -1
- package/dist/image-picker.esm.js.LICENSE.txt +1 -1
- package/dist/image.cjs.js +1 -1
- package/dist/image.cjs.js.LICENSE.txt +1 -1
- package/dist/image.esm.js +1 -1
- package/dist/image.esm.js.LICENSE.txt +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.LICENSE.txt +20 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.LICENSE.txt +20 -1
- package/dist/keyframe-animation.cjs.js.LICENSE.txt +1 -1
- package/dist/keyframe-animation.esm.js.LICENSE.txt +1 -1
- package/dist/link-getter.cjs.js +1 -1
- package/dist/link-getter.cjs.js.LICENSE.txt +1 -1
- package/dist/link-getter.esm.js +1 -1
- package/dist/link-getter.esm.js.LICENSE.txt +1 -1
- package/dist/link.cjs.js +1 -1
- package/dist/link.cjs.js.LICENSE.txt +1 -1
- package/dist/link.esm.js +1 -1
- package/dist/link.esm.js.LICENSE.txt +1 -1
- package/dist/meta-adder.cjs.js +1 -1
- package/dist/meta-adder.cjs.js.LICENSE.txt +1 -1
- package/dist/meta-adder.esm.js +1 -1
- package/dist/meta-adder.esm.js.LICENSE.txt +1 -1
- package/dist/modal-2025.cjs.js +1 -1
- package/dist/modal-2025.cjs.js.LICENSE.txt +1 -1
- package/dist/modal-2025.esm.js +1 -1
- package/dist/modal-2025.esm.js.LICENSE.txt +1 -1
- package/dist/multiswitcher.cjs.js +1 -1
- package/dist/multiswitcher.cjs.js.LICENSE.txt +1 -1
- package/dist/multiswitcher.esm.js +1 -1
- package/dist/multiswitcher.esm.js.LICENSE.txt +1 -1
- package/dist/new-nav-bar.cjs.js +1 -1
- package/dist/new-nav-bar.cjs.js.LICENSE.txt +1 -1
- package/dist/new-nav-bar.esm.js +1 -1
- package/dist/new-nav-bar.esm.js.LICENSE.txt +1 -1
- package/dist/picker.cjs.js +1 -1
- package/dist/picker.cjs.js.LICENSE.txt +1 -1
- package/dist/picker.esm.js +1 -1
- package/dist/picker.esm.js.LICENSE.txt +1 -1
- package/dist/progress.cjs.js +1 -1
- package/dist/progress.cjs.js.LICENSE.txt +1 -1
- package/dist/progress.esm.js +1 -1
- package/dist/progress.esm.js.LICENSE.txt +1 -1
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.cjs.js.LICENSE.txt +1 -1
- package/dist/radio.esm.js.LICENSE.txt +1 -1
- package/dist/range.cjs.js +1 -1
- package/dist/range.cjs.js.LICENSE.txt +1 -1
- package/dist/range.esm.js.LICENSE.txt +1 -1
- package/dist/scroll-video.cjs.js.LICENSE.txt +1 -1
- package/dist/scroll-video.esm.js.LICENSE.txt +1 -1
- package/dist/side-bar.cjs.js +1 -1
- package/dist/side-bar.cjs.js.LICENSE.txt +1 -1
- package/dist/side-bar.esm.js +1 -1
- package/dist/side-bar.esm.js.LICENSE.txt +1 -1
- package/dist/side-nav-bar.cjs.js +1 -1
- package/dist/side-nav-bar.cjs.js.LICENSE.txt +1 -1
- package/dist/side-nav-bar.esm.js +1 -1
- package/dist/side-nav-bar.esm.js.LICENSE.txt +1 -1
- package/dist/simple-bar.cjs.js +1 -1
- package/dist/simple-bar.cjs.js.LICENSE.txt +1 -1
- package/dist/simple-bar.esm.js +1 -1
- package/dist/simple-bar.esm.js.LICENSE.txt +1 -1
- package/dist/slider-2025.cjs.js +1 -1
- package/dist/slider-2025.cjs.js.LICENSE.txt +1 -1
- package/dist/slider-2025.esm.js +1 -1
- package/dist/slider-2025.esm.js.LICENSE.txt +1 -1
- package/dist/spacer.cjs.js +1 -1
- package/dist/spacer.cjs.js.LICENSE.txt +1 -1
- package/dist/spacer.esm.js +1 -1
- package/dist/spacer.esm.js.LICENSE.txt +1 -1
- package/dist/stack.cjs.js +1 -1
- package/dist/stack.cjs.js.LICENSE.txt +1 -1
- package/dist/stack.esm.js +1 -1
- package/dist/stack.esm.js.LICENSE.txt +1 -1
- package/dist/stacker.cjs.js.LICENSE.txt +1 -1
- package/dist/stacker.esm.js.LICENSE.txt +1 -1
- package/dist/table.cjs.js +1 -1
- package/dist/table.cjs.js.LICENSE.txt +1 -1
- package/dist/table.esm.js +1 -1
- package/dist/table.esm.js.LICENSE.txt +1 -1
- package/dist/text-field.cjs.js +1 -1
- package/dist/text-field.cjs.js.LICENSE.txt +1 -1
- package/dist/text-field.esm.js +1 -1
- package/dist/text-field.esm.js.LICENSE.txt +1 -1
- package/dist/text.cjs.js +1 -1
- package/dist/text.cjs.js.LICENSE.txt +1 -1
- package/dist/text.esm.js +1 -1
- package/dist/text.esm.js.LICENSE.txt +1 -1
- package/dist/theme.cjs.js.LICENSE.txt +1 -1
- package/dist/theme.esm.js.LICENSE.txt +1 -1
- package/dist/transform-anim.cjs.js.LICENSE.txt +1 -1
- package/dist/transform-anim.esm.js.LICENSE.txt +1 -1
- package/dist/ulist.cjs.js +1 -1
- package/dist/ulist.cjs.js.LICENSE.txt +1 -1
- package/dist/ulist.esm.js +1 -1
- package/dist/ulist.esm.js.LICENSE.txt +1 -1
- package/dist/video.cjs.js +1 -1
- package/dist/video.cjs.js.LICENSE.txt +1 -1
- package/dist/video.esm.js +1 -1
- package/dist/video.esm.js.LICENSE.txt +1 -1
- package/dist/wrap.cjs.js +1 -1
- package/dist/wrap.cjs.js.LICENSE.txt +1 -1
- package/dist/wrap.esm.js +1 -1
- package/dist/wrap.esm.js.LICENSE.txt +1 -1
- package/dist/zoom-card.cjs.js +1 -1
- package/dist/zoom-card.cjs.js.LICENSE.txt +1 -1
- package/dist/zoom-card.esm.js +1 -1
- package/dist/zoom-card.esm.js.LICENSE.txt +1 -1
- package/layout/animator.js +13 -4
- package/layout/audio.js +1 -1
- package/layout/audionew.js +1 -1
- package/layout/base.js +1 -1
- package/layout/beta-desktop-bar.js +1 -1
- package/layout/beta-mobile-bar.js +1 -1
- package/layout/button.js +1 -1
- package/layout/center.js +1 -1
- package/layout/checkbox.js +1 -1
- package/layout/circle.js +1 -1
- package/layout/code.js +1 -1
- package/layout/container.js +1 -1
- package/layout/dropdown-2025.js +1 -1
- package/layout/flex-card.js +1 -1
- package/layout/flex-grid.js +1 -1
- package/layout/flex-row.js +1 -1
- package/layout/form-components/custom.js +1 -1
- package/layout/form-components/data-list.js +1 -1
- package/layout/form-components/floating-input.js +1 -1
- package/layout/form-components/form-all.js +1 -1
- package/layout/form-components/form.js +1 -1
- package/layout/form-components/image-picker.js +1 -1
- package/layout/form-components/picker.js +1 -1
- package/layout/form-components/radio.js +1 -1
- package/layout/form-components/radiogroup.js +1 -1
- package/layout/form-components/range.js +1 -1
- package/layout/free.js +1 -1
- package/layout/grid-overlay.js +1 -1
- package/layout/grid-switcher.js +1 -1
- package/layout/grid.js +1 -1
- package/layout/horizontal-scroller.js +1 -1
- package/layout/image.js +1 -1
- package/layout/index.js +1 -1
- package/layout/link.js +1 -1
- package/layout/list.js +1 -1
- package/layout/meta-adder.js +1 -1
- package/layout/modal-2025.js +1 -1
- package/layout/morph.js +1 -1
- package/layout/multiswitcher.js +1 -1
- package/layout/nav-bar.js +1 -1
- package/layout/nav-factor/custom-div.js +1 -1
- package/layout/new-nav-bar.js +1 -1
- package/layout/polygon.js +1 -1
- package/layout/prerender-site.js +1 -1
- package/layout/prerender.js +1 -1
- package/layout/progress.js +1 -1
- package/layout/row.js +1 -1
- package/layout/scroll-video.js +1 -1
- package/layout/shop.js +1 -1
- package/layout/side-bar.js +1 -1
- package/layout/side-nav-bar.js +1 -1
- package/layout/simple-bar.js +1 -1
- package/layout/slider-2025.js +1 -1
- package/layout/spacer.js +1 -1
- package/layout/stack.js +1 -1
- package/layout/svg.js +1 -1
- package/layout/switcher.js +1 -1
- package/layout/table.js +1 -1
- package/layout/text-field.js +1 -1
- package/layout/text.js +1 -1
- package/layout/ulist.js +1 -1
- package/layout/video.js +1 -1
- package/layout/wrap.js +1 -1
- package/layout/zoom-card.js +1 -1
- package/lib/agent-surface.js +1 -1
- package/lib/card-getter.js +1 -1
- package/lib/check-page.js +1 -1
- package/lib/codegen.js +1 -1
- package/lib/data.js +1 -1
- package/lib/designer.js +14 -1
- package/lib/element-mapper.js +1 -1
- package/lib/element-params.generated.js +1 -1
- package/lib/grid-geometry.js +1 -1
- package/lib/keyframe-animation.js +1 -1
- package/lib/known-inert.js +1 -1
- package/lib/link-getter.js +1 -1
- package/lib/morph-node.js +39 -7
- package/lib/normalize-spec.js +1 -1
- package/lib/parse-html.js +1 -1
- package/lib/raster-inspect.js +1 -1
- package/lib/raster-ops.js +255 -34
- package/lib/raster-presets.js +32 -1
- package/lib/react.js +11 -2
- package/lib/resolve-refs.js +1 -1
- package/lib/responsive.js +647 -0
- package/lib/scroll-video.js +1 -1
- package/lib/seo.js +1 -1
- package/lib/stacker.js +1 -1
- package/lib/suggest.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/transform-anim.js +1 -1
- package/lib/transition.js +1 -1
- package/lib/validate-nodes.js +27 -2
- package/lib/view-transition.js +287 -0
- package/lib/webmcp-adapter.js +1 -1
- package/package.json +5 -3
- package/skills/nodality/SKILL.md +9 -0
package/lib/transform-anim.js
CHANGED
package/lib/transition.js
CHANGED
package/lib/validate-nodes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* nodality v1.
|
|
2
|
+
* nodality v1.4.0
|
|
3
3
|
* (c) 2026 Filip Vabrousek
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -195,11 +195,14 @@ const BARE_DESIGN_OPS = [
|
|
|
195
195
|
* over-reporting costs more than under-reporting.
|
|
196
196
|
*/
|
|
197
197
|
const DESIGN_OP_NAMES = [
|
|
198
|
-
"animation", "background", "blast", "card-style", "filter", "gradient",
|
|
198
|
+
"animation", "arrange", "background", "blast", "card-style", "filter", "gradient",
|
|
199
199
|
"layout", "link-style", "margin", "navStyle", "shadow", "slayout",
|
|
200
200
|
"span", "transform",
|
|
201
201
|
];
|
|
202
202
|
|
|
203
|
+
/** What an `arrange` node can switch its target to inside its range. */
|
|
204
|
+
const ARRANGE_MODES = ["row", "column", "expand", "collapse"];
|
|
205
|
+
|
|
203
206
|
/**
|
|
204
207
|
* Every top-level key a design node reads.
|
|
205
208
|
*
|
|
@@ -770,6 +773,28 @@ export function validateNodes(nodes, elements, defs) {
|
|
|
770
773
|
["a CSS gradient, e.g. \"linear-gradient(#1d6fe0, #7fd1ff)\"",
|
|
771
774
|
"or direction: \"radial\" to take the built-in one"]);
|
|
772
775
|
}
|
|
776
|
+
|
|
777
|
+
// An `arrange` node does nothing without a target and a range, and
|
|
778
|
+
// a mode outside the two it knows would be dropped in silence.
|
|
779
|
+
if (!bare && name === "arrange") {
|
|
780
|
+
const mode = node.op.mode;
|
|
781
|
+
if (mode !== undefined && !ARRANGE_MODES.includes(mode)) {
|
|
782
|
+
push("BAD_FIELD", `${path}.op.mode`, mode,
|
|
783
|
+
suggest(String(mode), ARRANGE_MODES), ARRANGE_MODES);
|
|
784
|
+
}
|
|
785
|
+
const r = node.range;
|
|
786
|
+
const num = (x) => (typeof x === "number" ? x : parseInt(x, 10));
|
|
787
|
+
const rangeOk = Array.isArray(r) && r.length === 2 &&
|
|
788
|
+
r.every((x) => Number.isFinite(num(x))) && num(r[0]) >= 0 && num(r[0]) <= num(r[1]);
|
|
789
|
+
if (!rangeOk) {
|
|
790
|
+
push("BAD_FIELD", `${path}.range`, r, [],
|
|
791
|
+
["[lo, hi] viewport widths in CSS px, 0 <= lo <= hi"]);
|
|
792
|
+
}
|
|
793
|
+
if (!Array.isArray(node.target) || node.target.length === 0) {
|
|
794
|
+
push("MISSING_FIELD", `${path}.target`, node.target, [],
|
|
795
|
+
["the id of the row, cards or nav it switches"]);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
773
798
|
return;
|
|
774
799
|
}
|
|
775
800
|
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* nodality v1.4.0
|
|
3
|
+
* (c) 2026 Filip Vabrousek
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*!
|
|
8
|
+
* view-transition.js — shader transitions for single-page route changes,
|
|
9
|
+
* with the View Transitions API's calling convention.
|
|
10
|
+
*
|
|
11
|
+
* A router that already does
|
|
12
|
+
*
|
|
13
|
+
* document.startViewTransition(() => render(route));
|
|
14
|
+
*
|
|
15
|
+
* swaps one call and keeps everything else, including its CSS:
|
|
16
|
+
*
|
|
17
|
+
* import { nodalityTransition } from "nodality/view-transition";
|
|
18
|
+
* nodalityTransition(() => render(route), { effect: "t-fluid" });
|
|
19
|
+
*
|
|
20
|
+
* Elements are paired by `view-transition-name`, exactly as the platform
|
|
21
|
+
* pairs them, and each pair is morphed by a raster transition: the old
|
|
22
|
+
* element is frozen before the update, the new one after it, and the
|
|
23
|
+
* pipeline interpolates between their rects while the effect chain runs
|
|
24
|
+
* over both stills.
|
|
25
|
+
*
|
|
26
|
+
* WHY NOT ON TOP OF THE PLATFORM'S TRANSITION. The browser renders a view
|
|
27
|
+
* transition as `::view-transition-old/new` snapshots in its own top
|
|
28
|
+
* layer. CSS can move, fade and filter those, but no shader can draw them
|
|
29
|
+
* and nothing on the page can paint above them while the transition runs.
|
|
30
|
+
* So this does the platform's job itself — freeze, update, pair, animate —
|
|
31
|
+
* and hands the platform back the cases where there is nothing to add:
|
|
32
|
+
* reduced motion (no effect is allowed), and no WebGL (no effect is
|
|
33
|
+
* possible). There the native transition runs if the browser has one.
|
|
34
|
+
*
|
|
35
|
+
* Unlike the native transition, only NAMED elements animate. Everything
|
|
36
|
+
* else changes at once; the native one also cross-fades the page root.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
import { applyRasterPipeline } from "./raster-ops.js";
|
|
40
|
+
import { preset } from "./raster-presets.js";
|
|
41
|
+
import { progressTimeline, prefersReducedMotion } from "./transition.js";
|
|
42
|
+
import { captureStill } from "./morph-node.js";
|
|
43
|
+
|
|
44
|
+
const nextFrame = () => new Promise((r) => requestAnimationFrame(() => r()));
|
|
45
|
+
|
|
46
|
+
/** The name an element transitions under, or null. */
|
|
47
|
+
function nameOf(el) {
|
|
48
|
+
const own = el.style && el.style.viewTransitionName;
|
|
49
|
+
if (own && own !== "none") return own;
|
|
50
|
+
const attr = el.getAttribute && el.getAttribute("data-view-transition-name");
|
|
51
|
+
if (attr) return attr;
|
|
52
|
+
const cs = getComputedStyle(el);
|
|
53
|
+
const css = cs.viewTransitionName || cs.getPropertyValue("view-transition-name");
|
|
54
|
+
return css && css !== "none" && css !== "auto" ? css.trim() : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Every named, visible element under `root`, by name. A duplicate name
|
|
59
|
+
* is an error in the platform API (the transition is skipped); here the
|
|
60
|
+
* first one wins and the rest are reported, so a page still advances.
|
|
61
|
+
*/
|
|
62
|
+
function collect(root) {
|
|
63
|
+
const found = new Map();
|
|
64
|
+
for (const el of root.querySelectorAll("*")) {
|
|
65
|
+
const name = nameOf(el);
|
|
66
|
+
if (!name) continue;
|
|
67
|
+
const r = el.getBoundingClientRect();
|
|
68
|
+
if (!r.width || !r.height) continue;
|
|
69
|
+
if (found.has(name)) {
|
|
70
|
+
console.warn(`[nodality] view transition: two elements are named "${name}" — ` +
|
|
71
|
+
"only the first animates.");
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
found.set(name, el);
|
|
75
|
+
}
|
|
76
|
+
return found;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A box in viewport coordinates, the space the overlay is drawn in. */
|
|
80
|
+
const boxOf = (el) => {
|
|
81
|
+
const r = el.getBoundingClientRect();
|
|
82
|
+
return { x: r.x, y: r.y, w: r.width, h: r.height };
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
function webglAvailable() {
|
|
86
|
+
try {
|
|
87
|
+
const c = document.createElement("canvas");
|
|
88
|
+
return !!(c.getContext("webgl2") || c.getContext("webgl"));
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const chainFor = (effect) => {
|
|
95
|
+
if (!effect) return [];
|
|
96
|
+
if (Array.isArray(effect)) return effect;
|
|
97
|
+
try { return preset(effect) || []; } catch (e) { return []; }
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** New images have no box until they decode, and the rect must be final. */
|
|
101
|
+
async function settleImages(els) {
|
|
102
|
+
const imgs = els.flatMap((el) => [...el.querySelectorAll("img")]);
|
|
103
|
+
await Promise.all(imgs.map((im) => (im.complete && im.naturalWidth) ? null
|
|
104
|
+
: (typeof im.decode === "function" ? im.decode().catch(() => {}) : null)));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Run `update` as a shader transition.
|
|
109
|
+
*
|
|
110
|
+
* @param {() => (void|Promise<void>)} update renders the next route
|
|
111
|
+
* @param {object} [opts]
|
|
112
|
+
* @param {string|object[]} [opts.effect="t-fluid"] preset name or node array
|
|
113
|
+
* @param {number} [opts.duration=800] ms
|
|
114
|
+
* @param {string} [opts.fade="opaque"] how the two stills combine; see the
|
|
115
|
+
* pipeline's `fade` ("opaque", "dissolve", "morph")
|
|
116
|
+
* @param {number[]} [opts.crossfade=[0.05, 0.45]] the slice of progress in
|
|
117
|
+
* which the old content hands over to the new; the shapes still travel
|
|
118
|
+
* the whole duration
|
|
119
|
+
* @param {Element} [opts.root=document.body] where named elements are looked for
|
|
120
|
+
* @returns {{ updateCallbackDone: Promise<void>, ready: Promise<void>,
|
|
121
|
+
* finished: Promise<void>, skipTransition(): void }}
|
|
122
|
+
* the same shape as the platform's ViewTransition
|
|
123
|
+
*/
|
|
124
|
+
function nodalityTransition(update, opts = {}) {
|
|
125
|
+
const root = opts.root || document.body;
|
|
126
|
+
|
|
127
|
+
// Nothing to add: let the platform do it, or just update.
|
|
128
|
+
if (prefersReducedMotion() || !webglAvailable()) {
|
|
129
|
+
if (typeof document.startViewTransition === "function") {
|
|
130
|
+
return document.startViewTransition(update);
|
|
131
|
+
}
|
|
132
|
+
const done = Promise.resolve().then(update);
|
|
133
|
+
return { updateCallbackDone: done, ready: done, finished: done, skipTransition() {} };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let skip = null;
|
|
137
|
+
let skipped = false;
|
|
138
|
+
const hidden = [];
|
|
139
|
+
let resolveUpdate, resolveReady;
|
|
140
|
+
const updateCallbackDone = new Promise((r) => { resolveUpdate = r; });
|
|
141
|
+
const ready = new Promise((r) => { resolveReady = r; });
|
|
142
|
+
|
|
143
|
+
const finished = (async () => {
|
|
144
|
+
// 1. Freeze the old side. Captures are async, so the update waits
|
|
145
|
+
// for them; that is the same order the platform uses.
|
|
146
|
+
const before = collect(root);
|
|
147
|
+
const olds = new Map();
|
|
148
|
+
// The old element's partner is not known yet, so it is rasterised
|
|
149
|
+
// as if it may grow to fill the viewport: the stills are vector
|
|
150
|
+
// until this point, and a small name drawn into a full-screen box
|
|
151
|
+
// from a 1x capture is the pixelation this avoids.
|
|
152
|
+
const reach = (rect) => Math.min(4, Math.max(1,
|
|
153
|
+
window.innerWidth / Math.max(rect.w, 1)));
|
|
154
|
+
await Promise.all([...before].map(async ([name, el]) => {
|
|
155
|
+
const rect = boxOf(el);
|
|
156
|
+
try {
|
|
157
|
+
olds.set(name, { rect, image: await captureStill(el, rect.w, rect.h, reach(rect)) });
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.warn(`[nodality] view transition: could not capture "${name}".`, e);
|
|
160
|
+
}
|
|
161
|
+
}));
|
|
162
|
+
|
|
163
|
+
// The overlay holds the old stills while the DOM changes under it,
|
|
164
|
+
// so there is no frame where the old element has gone and the
|
|
165
|
+
// transition has not yet begun.
|
|
166
|
+
const overlay = document.createElement("div");
|
|
167
|
+
overlay.setAttribute("data-nodality-view-transition", "");
|
|
168
|
+
overlay.setAttribute("aria-hidden", "true");
|
|
169
|
+
overlay.style.cssText = "position:fixed;inset:0;pointer-events:none;z-index:2147483000;";
|
|
170
|
+
const stills = new Map();
|
|
171
|
+
for (const [name, o] of olds) {
|
|
172
|
+
const img = o.image;
|
|
173
|
+
img.style.cssText = `position:absolute;left:${o.rect.x}px;top:${o.rect.y}px;` +
|
|
174
|
+
`width:${o.rect.w}px;height:${o.rect.h}px;`;
|
|
175
|
+
overlay.appendChild(img);
|
|
176
|
+
stills.set(name, img);
|
|
177
|
+
}
|
|
178
|
+
document.body.appendChild(overlay);
|
|
179
|
+
|
|
180
|
+
// 2. Update.
|
|
181
|
+
try {
|
|
182
|
+
await update();
|
|
183
|
+
} finally {
|
|
184
|
+
resolveUpdate();
|
|
185
|
+
}
|
|
186
|
+
await nextFrame();
|
|
187
|
+
|
|
188
|
+
// 3. Pair by name and freeze the new side.
|
|
189
|
+
const after = collect(root);
|
|
190
|
+
const pairs = [];
|
|
191
|
+
for (const [name, el] of after) {
|
|
192
|
+
if (olds.has(name)) pairs.push({ name, el, old: olds.get(name) });
|
|
193
|
+
}
|
|
194
|
+
await settleImages(pairs.map((p) => p.el));
|
|
195
|
+
// Hidden while the transition owns the pixels; it still lays out,
|
|
196
|
+
// so it measures and captures.
|
|
197
|
+
for (const p of pairs) {
|
|
198
|
+
p.el.style.visibility = "hidden";
|
|
199
|
+
hidden.push(p.el);
|
|
200
|
+
}
|
|
201
|
+
await Promise.all(pairs.map(async (p) => {
|
|
202
|
+
p.rect = boxOf(p.el);
|
|
203
|
+
p.image = await captureStill(p.el, p.rect.w, p.rect.h);
|
|
204
|
+
}));
|
|
205
|
+
|
|
206
|
+
// An old element with no partner fades out; a new one with no
|
|
207
|
+
// partner is simply there, as with the native transition's
|
|
208
|
+
// unpaired groups.
|
|
209
|
+
for (const [name, img] of stills) {
|
|
210
|
+
if (pairs.some((p) => p.name === name)) continue;
|
|
211
|
+
img.style.transition = `opacity ${Math.round((opts.duration || 800) / 2)}ms ease-out`;
|
|
212
|
+
requestAnimationFrame(() => { img.style.opacity = "0"; });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 4. One pipeline per pair, all on one timeline.
|
|
216
|
+
const pipes = [];
|
|
217
|
+
for (const p of pairs) {
|
|
218
|
+
const host = document.createElement("div");
|
|
219
|
+
host.style.cssText = "position:absolute;inset:0;";
|
|
220
|
+
overlay.appendChild(host);
|
|
221
|
+
const pipe = applyRasterPipeline(host, chainFor(opts.effect || "t-fluid"), {
|
|
222
|
+
transition: {
|
|
223
|
+
oldImage: p.old.image, newImage: p.image,
|
|
224
|
+
oldRect: p.old.rect, oldTo: p.rect,
|
|
225
|
+
newRect: p.rect, newFrom: p.old.rect,
|
|
226
|
+
fade: opts.fade || "opaque",
|
|
227
|
+
// Each capture at its own aspect ratio, and the old
|
|
228
|
+
// content handed over early — see buildFragmentShader.
|
|
229
|
+
fit: "width",
|
|
230
|
+
crossfade: opts.crossfade || [0.05, 0.45],
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
if (pipe) pipes.push(pipe);
|
|
234
|
+
}
|
|
235
|
+
const group = {
|
|
236
|
+
progress: 0,
|
|
237
|
+
setProgress(t) {
|
|
238
|
+
for (const pipe of pipes) pipe.setProgress(t);
|
|
239
|
+
group.progress = Math.min(1, Math.max(0, t));
|
|
240
|
+
return group.progress;
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
group.setProgress(0);
|
|
244
|
+
await nextFrame();
|
|
245
|
+
// The pipelines are presenting the old side now; the stills under
|
|
246
|
+
// them can go.
|
|
247
|
+
for (const p of pairs) {
|
|
248
|
+
const img = stills.get(p.name);
|
|
249
|
+
if (img) img.remove();
|
|
250
|
+
}
|
|
251
|
+
resolveReady();
|
|
252
|
+
|
|
253
|
+
const tl = progressTimeline(group, { duration: opts.duration || 800 });
|
|
254
|
+
skip = () => tl.set(1);
|
|
255
|
+
if (skipped) skip();
|
|
256
|
+
await tl.to(1);
|
|
257
|
+
|
|
258
|
+
// 5. Hand the screen back to the real elements.
|
|
259
|
+
for (const p of pairs) p.el.style.visibility = "";
|
|
260
|
+
await nextFrame();
|
|
261
|
+
tl.destroy();
|
|
262
|
+
for (const pipe of pipes) pipe.destroy();
|
|
263
|
+
overlay.remove();
|
|
264
|
+
})();
|
|
265
|
+
|
|
266
|
+
// A failure mid-transition must not leave the page frozen under an
|
|
267
|
+
// overlay or with its new elements hidden.
|
|
268
|
+
finished.catch((e) => {
|
|
269
|
+
console.warn("[nodality] view transition failed:", e);
|
|
270
|
+
document.querySelectorAll("[data-nodality-view-transition]").forEach((o) => o.remove());
|
|
271
|
+
for (const el of hidden) el.style.visibility = "";
|
|
272
|
+
resolveUpdate();
|
|
273
|
+
resolveReady();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
updateCallbackDone,
|
|
278
|
+
ready,
|
|
279
|
+
finished: finished.catch(() => {}),
|
|
280
|
+
skipTransition() {
|
|
281
|
+
skipped = true;
|
|
282
|
+
if (skip) skip();
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export { nodalityTransition };
|
package/lib/webmcp-adapter.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodality",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A lightweight library for declarative UI elements.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
"./inspect": "./lib/raster-inspect.js",
|
|
40
40
|
"./examples/*": "./examples/*.js",
|
|
41
41
|
"./transition": "./lib/transition.js",
|
|
42
|
+
"./view-transition": "./lib/view-transition.js",
|
|
43
|
+
"./responsive": "./lib/responsive.js",
|
|
42
44
|
"./designer": "./lib/designer.js",
|
|
43
45
|
"./react": {
|
|
44
46
|
"types": "./lib/react.d.ts",
|
|
@@ -96,8 +98,8 @@
|
|
|
96
98
|
"babel-loader": "^10.0.0",
|
|
97
99
|
"jsdom": "^29.1.1",
|
|
98
100
|
"playwright": "^1.54.1",
|
|
99
|
-
"react": "
|
|
100
|
-
"react-dom": "
|
|
101
|
+
"react": "19.2.4",
|
|
102
|
+
"react-dom": "19.2.4",
|
|
101
103
|
"serve": "^14.2.6",
|
|
102
104
|
"webpack-cli": "^6.0.1"
|
|
103
105
|
},
|
package/skills/nodality/SKILL.md
CHANGED
|
@@ -185,6 +185,15 @@ Rules that are not obvious from the schema:
|
|
|
185
185
|
- **`agent-surface` is opt-in and allow-listed.** No form is exposed
|
|
186
186
|
unless named in `forms`. Do not add it unless the user asks for an
|
|
187
187
|
agent-operable page.
|
|
188
|
+
- **`arrange` switches a group's arrangement inside a width range.**
|
|
189
|
+
`{ op: { name: "arrange", mode: "column" }, target: ["hero"], range: [0, 640] }`
|
|
190
|
+
stacks a `row` or `cards` grid at 0–640 px, and `mode: "row"` keeps it
|
|
191
|
+
side by side; on a `nav`, `mode: "collapse"` shows the menu button up to
|
|
192
|
+
the range's end and `mode: "expand"` the full bar. Ranges are inclusive
|
|
193
|
+
CSS px. Do not guess them: `nodality/responsive`'s `respond()` measures
|
|
194
|
+
the page in a browser and emits one node per interval, covering every
|
|
195
|
+
width, switching exactly where a group stops fitting (experimental). Of
|
|
196
|
+
two overlapping ranges on one element, the first declared wins.
|
|
188
197
|
|
|
189
198
|
A complete navigation graph is one node:
|
|
190
199
|
|