nodality 1.5.2 → 1.5.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.
- package/README.md +2 -22
- package/bin/mcp-server.mjs +3 -1
- package/dist/animator.cjs.js.LICENSE.txt +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.LICENSE.txt +1 -1
- package/dist/base.esm.js.LICENSE.txt +1 -1
- package/dist/beta-desktop-bar.cjs.js.LICENSE.txt +1 -1
- package/dist/beta-desktop-bar.esm.js.LICENSE.txt +1 -1
- package/dist/beta-mobile-bar.cjs.js.LICENSE.txt +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 +28 -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.LICENSE.txt +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.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 +28 -1
- package/dist/designer.esm.js +1 -1
- package/dist/designer.esm.js.LICENSE.txt +28 -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 +28 -1
- package/dist/flex-card.cjs.js.LICENSE.txt +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.LICENSE.txt +1 -1
- package/dist/floating-input.esm.js.LICENSE.txt +1 -1
- package/dist/free.cjs.js.LICENSE.txt +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.LICENSE.txt +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 +28 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.LICENSE.txt +28 -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.LICENSE.txt +1 -1
- package/dist/meta-adder.esm.js.LICENSE.txt +1 -1
- package/dist/modal-2025.cjs.js.LICENSE.txt +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.LICENSE.txt +1 -1
- package/dist/new-nav-bar.esm.js.LICENSE.txt +1 -1
- package/dist/picker.cjs.js.LICENSE.txt +1 -1
- package/dist/picker.esm.js.LICENSE.txt +1 -1
- package/dist/progress.cjs.js.LICENSE.txt +1 -1
- package/dist/progress.esm.js.LICENSE.txt +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.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.LICENSE.txt +1 -1
- package/dist/side-bar.esm.js.LICENSE.txt +1 -1
- package/dist/side-nav-bar.cjs.js.LICENSE.txt +1 -1
- package/dist/side-nav-bar.esm.js.LICENSE.txt +1 -1
- package/dist/simple-bar.cjs.js.LICENSE.txt +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.LICENSE.txt +1 -1
- package/dist/spacer.esm.js.LICENSE.txt +1 -1
- package/dist/stack.cjs.js.LICENSE.txt +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.LICENSE.txt +1 -1
- package/dist/table.esm.js.LICENSE.txt +1 -1
- package/dist/text-field.cjs.js.LICENSE.txt +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.LICENSE.txt +1 -1
- package/dist/wrap.esm.js.LICENSE.txt +1 -1
- package/dist/zoom-card.cjs.js.LICENSE.txt +1 -1
- package/dist/zoom-card.esm.js.LICENSE.txt +1 -1
- package/layout/animator.js +1 -1
- package/layout/audio.js +1 -1
- package/layout/audionew.js +3 -2
- 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 +9 -7
- package/layout/center.js +1 -1
- package/layout/checkbox.js +3 -2
- package/layout/circle.js +1 -1
- package/layout/code.js +5 -11
- package/layout/container.js +14 -14
- package/layout/dropdown-2025.js +3 -2
- package/layout/flex-card.js +1 -1
- package/layout/flex-grid.js +4 -3
- package/layout/flex-row.js +3 -9
- 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 +18 -17
- package/layout/index.js +1 -1
- package/layout/link.js +12 -12
- 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 +3 -2
- 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 +3 -2
- package/layout/table.js +1 -1
- package/layout/text-field.js +1 -1
- package/layout/text.js +21 -13
- package/layout/ulist.js +3 -2
- package/layout/video.js +3 -3
- 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 +11 -2
- package/lib/data.js +1 -1
- package/lib/designer.js +5 -4
- package/lib/element-mapper.js +3 -2
- 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 +1 -1
- package/lib/normalize-spec.js +1 -1
- package/lib/op-semantics.js +178 -0
- package/lib/parse-html.js +60 -6
- package/lib/raster-inspect.js +1 -1
- package/lib/raster-ops.js +1 -1
- package/lib/raster-presets.js +1 -1
- package/lib/react.js +1 -1
- package/lib/resolve-refs.js +1 -1
- package/lib/responsive.js +41 -1
- 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 +13 -2
- package/lib/view-transition.js +1 -1
- package/lib/webmcp-adapter.js +1 -1
- package/package.json +1 -1
- package/skills/nodality/SKILL.md +3 -5
- package/skills/nodality/references/editing.md +8 -6
- package/skills/nodality-edit-page/SKILL.md +3 -1
package/layout/text.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* nodality v1.5.
|
|
2
|
+
* nodality v1.5.4
|
|
3
3
|
* (c) 2026 Filip Vabrousek
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {Animator} from "./animator.js";
|
|
8
8
|
|
|
9
|
-
import { toObjectSource } from "../lib/codegen.js";
|
|
9
|
+
import { toObjectSource, jsString } from "../lib/codegen.js";
|
|
10
10
|
import { keyPattern } from "../lib/codegen.js";
|
|
11
11
|
// 13:28 07/04/2020 - BEGIN NOTHING GONNA STOP US NOW Lets go!
|
|
12
12
|
|
|
@@ -23,7 +23,7 @@ class Text extends Animator {
|
|
|
23
23
|
this.elCSS = [];
|
|
24
24
|
this.html = [];
|
|
25
25
|
this.react = [];
|
|
26
|
-
this.code.push(`new Text(
|
|
26
|
+
this.code.push(`new Text(${jsString(this.text)})`);
|
|
27
27
|
//console.log("15/12/25 cool");
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -41,7 +41,7 @@ class Text extends Animator {
|
|
|
41
41
|
|
|
42
42
|
const objString = toObjectSource(cleanedObj, 4);
|
|
43
43
|
|
|
44
|
-
return [`new Text(
|
|
44
|
+
return [`new Text(${jsString(this.text)}).set(${objString})`];
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
|
|
@@ -120,26 +120,34 @@ class Text extends Animator {
|
|
|
120
120
|
return /(\*\*.*\*\*|\*.*\*|`[^`]+`|\[.*?\]\(.*?\)|^# )/m.test(str);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
// Minimal Markdown parser
|
|
123
|
+
// Minimal Markdown parser. The text is escaped first and only the
|
|
124
|
+
// tags below are added back, so text can never inject markup; a link keeps
|
|
125
|
+
// its href only for http(s), mailto, tel or a relative URL.
|
|
124
126
|
parseMarkdown(mdString) {
|
|
125
|
-
let html = mdString
|
|
127
|
+
let html = String(mdString)
|
|
128
|
+
.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
|
|
129
|
+
.replace(/"/g, """).replace(/'/g, "'");
|
|
126
130
|
|
|
127
131
|
// Headers: # H1, ## H2, ### H3
|
|
128
132
|
html = html.replace(/^### (.*$)/gim, "<h3>$1</h3>");
|
|
129
133
|
html = html.replace(/^## (.*$)/gim, "<h2>$1</h2>");
|
|
130
134
|
html = html.replace(/^# (.*$)/gim, "<h1>$1</h1>");
|
|
131
135
|
|
|
132
|
-
// Bold
|
|
133
|
-
html = html.replace(/\*\*(
|
|
134
|
-
|
|
135
|
-
// Italic: *text*
|
|
136
|
-
html = html.replace(/\*(.*?)\*/g, "<em>$1</em>");
|
|
136
|
+
// Bold and italic only when the asterisks hug text, so "2 * 3 * 4" stays.
|
|
137
|
+
html = html.replace(/\*\*(?=\S)(.+?)(?<=\S)\*\*/g, "<strong>$1</strong>");
|
|
138
|
+
html = html.replace(/\*(?=\S)([^*\n]+?)(?<=\S)\*/g, "<em>$1</em>");
|
|
137
139
|
|
|
138
140
|
// Inline code: `code`
|
|
139
141
|
html = html.replace(/`([^`]+)`/g, "<code>$1</code>");
|
|
140
142
|
|
|
141
|
-
// Links: [text](url)
|
|
142
|
-
|
|
143
|
+
// Links: [text](url). Browsers drop tabs and newlines inside a URL, so the
|
|
144
|
+
// scheme is checked after removing them ("java\tscript:" is javascript:).
|
|
145
|
+
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (m, label, url) => {
|
|
146
|
+
const bare = url.replace(/[\u0000-\u0020]/g, "");
|
|
147
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(bare);
|
|
148
|
+
const safe = !scheme || /^(https?|mailto|tel)$/i.test(scheme[1]);
|
|
149
|
+
return safe ? `<a href="${bare}">${label}</a>` : label;
|
|
150
|
+
});
|
|
143
151
|
|
|
144
152
|
// Line breaks
|
|
145
153
|
html = html.replace(/\n/g, "<br>");
|
package/layout/ulist.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* nodality v1.5.
|
|
2
|
+
* nodality v1.5.4
|
|
3
3
|
* (c) 2026 Filip Vabrousek
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {Animator} from "./animator.js";
|
|
8
8
|
|
|
9
|
+
import { jsString } from "../lib/codegen.js";
|
|
9
10
|
class UList extends Animator {
|
|
10
11
|
constructor() {
|
|
11
12
|
super();
|
|
@@ -195,7 +196,7 @@ toCode(indent = 0) {
|
|
|
195
196
|
code += `\n${pad} .setItems([\n` +
|
|
196
197
|
this.items.map(c =>
|
|
197
198
|
typeof c === "string"
|
|
198
|
-
? `${" ".repeat(indent + 4)}
|
|
199
|
+
? `${" ".repeat(indent + 4)}${jsString(c)}`
|
|
199
200
|
: c.toCode(indent + 4)
|
|
200
201
|
).join(",\n") +
|
|
201
202
|
`\n${pad} ])`;
|
package/layout/video.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* nodality v1.5.
|
|
2
|
+
* nodality v1.5.4
|
|
3
3
|
* (c) 2026 Filip Vabrousek
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Animator } from "./animator.js";
|
|
8
|
-
import { toObjectSource } from "../lib/codegen.js";
|
|
8
|
+
import { toObjectSource, jsString } from "../lib/codegen.js";
|
|
9
9
|
|
|
10
10
|
// Video — a <video> element as data.
|
|
11
11
|
//
|
|
@@ -231,7 +231,7 @@ class Video extends Animator {
|
|
|
231
231
|
const cleaned = Object.fromEntries(
|
|
232
232
|
Object.entries(this.options || {}).filter(([, v]) => v != null)
|
|
233
233
|
);
|
|
234
|
-
return [`new Video(
|
|
234
|
+
return [`new Video(${jsString(this.url)}).set(${toObjectSource(cleaned, 4)})`];
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
render(el) {
|
package/layout/wrap.js
CHANGED
package/layout/zoom-card.js
CHANGED
package/lib/agent-surface.js
CHANGED
package/lib/card-getter.js
CHANGED
package/lib/check-page.js
CHANGED
package/lib/codegen.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* nodality v1.5.
|
|
2
|
+
* nodality v1.5.4
|
|
3
3
|
* (c) 2026 Filip Vabrousek
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* unquoteKeys(jsonString) // already have the JSON? just fix the keys
|
|
28
28
|
* IDENT_KEY // the pattern, for call sites that chain
|
|
29
29
|
* // further replaces onto the same string
|
|
30
|
+
* jsString(value) // a value as a quoted, escaped JS string
|
|
30
31
|
*/
|
|
31
32
|
|
|
32
33
|
// A quoted JSON key whose bare form is a valid JS identifier. Anything
|
|
@@ -59,4 +60,12 @@ function toObjectSource(value, indent = 4) {
|
|
|
59
60
|
return unquoteKeys(JSON.stringify(value, null, indent));
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
/**
|
|
64
|
+
* A value as a JavaScript string literal. Every value pasted into generated
|
|
65
|
+
* source goes through this, so page text can never close the string it sits in.
|
|
66
|
+
*/
|
|
67
|
+
function jsString(value) {
|
|
68
|
+
return JSON.stringify(String(value));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { toObjectSource, unquoteKeys, keyPattern, jsString };
|
package/lib/data.js
CHANGED
package/lib/designer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* nodality v1.5.
|
|
2
|
+
* nodality v1.5.4
|
|
3
3
|
* (c) 2026 Filip Vabrousek
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -81,6 +81,7 @@ import { Shop } from "../layout/shop.js";
|
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
|
|
84
|
+
import { jsString } from "./codegen.js";
|
|
84
85
|
// Audio, progress, TextField, import navFactor
|
|
85
86
|
class Des {
|
|
86
87
|
constructor() {
|
|
@@ -1446,7 +1447,7 @@ new Slider(texts, null, { tintColor: "#e74c3c", inactiveColor: "#ccc" })
|
|
|
1446
1447
|
let codea = document.createElement("code");
|
|
1447
1448
|
|
|
1448
1449
|
|
|
1449
|
-
const prepare = this.code.map(c => `${c}.render(
|
|
1450
|
+
const prepare = this.code.map(c => `${c}.render(${jsString(target)}); \n \n`);
|
|
1450
1451
|
this.code = prepare;
|
|
1451
1452
|
|
|
1452
1453
|
codea.textContent = this.code;//.replaceAll(",.", ".").replaceAll(",, new", "new").replaceAll(/\[\s*\n*,\s*\n*/g, "["); // replace with your code
|
|
@@ -1498,7 +1499,7 @@ new Slider(texts, null, { tintColor: "#e74c3c", inactiveColor: "#ccc" })
|
|
|
1498
1499
|
// when run from the CLI — no rendering side effects.
|
|
1499
1500
|
if (typeof globalThis !== "undefined" && globalThis.NODALITY_EMIT === true) {
|
|
1500
1501
|
// Populate this.code without triggering DOM work.
|
|
1501
|
-
const prepare = this.code.map((c) => `${c}.render(
|
|
1502
|
+
const prepare = this.code.map((c) => `${c}.render(${jsString((obj && obj.mount) || "#mount")})`);
|
|
1502
1503
|
globalThis.__NODALITY_EMITTED__ = prepare;
|
|
1503
1504
|
return this;
|
|
1504
1505
|
}
|
|
@@ -1619,7 +1620,7 @@ const components = {
|
|
|
1619
1620
|
if ((obj && obj.annotate) || (dev && dev.annotate)) {
|
|
1620
1621
|
annotateRoundTrip(
|
|
1621
1622
|
document.querySelector((obj && obj.mount) || "#mount"),
|
|
1622
|
-
this._elements);
|
|
1623
|
+
this._elements, this.protoOptions);
|
|
1623
1624
|
}
|
|
1624
1625
|
} catch (e) {
|
|
1625
1626
|
console.warn("[nodality] round-trip annotation skipped:", e);
|
package/lib/element-mapper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* nodality v1.5.
|
|
2
|
+
* nodality v1.5.4
|
|
3
3
|
* (c) 2026 Filip Vabrousek
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -74,6 +74,7 @@ import { GridOverlay } from "../layout/grid-overlay.js";
|
|
|
74
74
|
import { Shop } from "../layout/shop.js";
|
|
75
75
|
|
|
76
76
|
|
|
77
|
+
import { jsString } from "./codegen.js";
|
|
77
78
|
// The closed set of `type:` values mapType understands, in the order it
|
|
78
79
|
// tests them. Kept beside the dispatch so a new branch without a new entry
|
|
79
80
|
// is visible in review — the vocabulary and the router should not drift.
|
|
@@ -557,7 +558,7 @@ animation: {
|
|
|
557
558
|
justifyContent: "center",
|
|
558
559
|
alignItems: "center",
|
|
559
560
|
position: "absolute",
|
|
560
|
-
id:
|
|
561
|
+
id: ${jsString(obj.el.id ? String(obj.el.id) : "#first")},
|
|
561
562
|
scale: 0.3,
|
|
562
563
|
${ft?.animation ? animation : ""}${
|
|
563
564
|
// Wrapper routes its options through commonMethods(), so a raster
|
package/lib/grid-geometry.js
CHANGED
package/lib/known-inert.js
CHANGED
package/lib/link-getter.js
CHANGED
package/lib/morph-node.js
CHANGED
package/lib/normalize-spec.js
CHANGED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* nodality v1.5.4
|
|
3
|
+
* (c) 2026 Filip Vabrousek
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*!
|
|
8
|
+
* op-semantics.js: how the nodes of each op combine, declared as data.
|
|
9
|
+
*
|
|
10
|
+
* Read from the renderer, not designed. Each entry records what the code does
|
|
11
|
+
* today; __tests__/unit/op-semantics.test.mjs checks the lookups behind it.
|
|
12
|
+
* The validator uses it to report nodes that can never apply, and
|
|
13
|
+
* describeOps() hands it to agents.
|
|
14
|
+
*
|
|
15
|
+
* combine
|
|
16
|
+
* first the first node with this op that reaches an element applies;
|
|
17
|
+
* later ones are ignored (ElementMapper.filtero, Array.find)
|
|
18
|
+
* sequence every node applies, in array order. link-style: later values
|
|
19
|
+
* overwrite earlier ones. Raster ops: chained within their stage,
|
|
20
|
+
* and stages always run field, warp, cell, displace, color, so
|
|
21
|
+
* order only matters between ops of one stage.
|
|
22
|
+
* inert accepted by the validator, read by no renderer code
|
|
23
|
+
*
|
|
24
|
+
* scope (what "reaches" means)
|
|
25
|
+
* element per target element; a node without `target` reaches every one
|
|
26
|
+
* range per element and overlapping viewport range (arrange)
|
|
27
|
+
* page one decision per page; `target` is not consulted
|
|
28
|
+
*
|
|
29
|
+
* slot ops that share one decision (layout and slayout)
|
|
30
|
+
*
|
|
31
|
+
* Pure module: no DOM at import.
|
|
32
|
+
*/
|
|
33
|
+
import { RASTER_OP_NAMES } from "./raster-ops.js";
|
|
34
|
+
|
|
35
|
+
const MAX_WIDTH = 99999;
|
|
36
|
+
|
|
37
|
+
const DESIGN_SEMANTICS = {
|
|
38
|
+
animation: { combine: "first", scope: "element" },
|
|
39
|
+
arrange: { combine: "first", scope: "range" },
|
|
40
|
+
background: { combine: "first", scope: "element" },
|
|
41
|
+
blast: { combine: "first", scope: "element" },
|
|
42
|
+
"card-style": { combine: "first", scope: "page" },
|
|
43
|
+
filter: { combine: "first", scope: "element" },
|
|
44
|
+
gradient: { combine: "first", scope: "element" },
|
|
45
|
+
layout: { combine: "first", scope: "page", slot: "layout" },
|
|
46
|
+
slayout: { combine: "first", scope: "page", slot: "layout" },
|
|
47
|
+
// LinkStyler.style applies every matching node in order and only
|
|
48
|
+
// compares an element against target[0].
|
|
49
|
+
"link-style": { combine: "sequence", scope: "element", firstTargetOnly: true },
|
|
50
|
+
margin: { combine: "first", scope: "element" },
|
|
51
|
+
navStyle: { combine: "inert", scope: "element" },
|
|
52
|
+
shadow: { combine: "first", scope: "element" },
|
|
53
|
+
span: { combine: "first", scope: "element" },
|
|
54
|
+
transform: { combine: "first", scope: "element" },
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const OP_SEMANTICS = Object.freeze({
|
|
58
|
+
...DESIGN_SEMANTICS,
|
|
59
|
+
...Object.fromEntries(RASTER_OP_NAMES.map((name) =>
|
|
60
|
+
[name, { combine: "sequence", scope: "element", byStage: true }])),
|
|
61
|
+
morph: { combine: "sequence", scope: "page" },
|
|
62
|
+
"agent-surface": { combine: "first", scope: "page" },
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/** The op name a node carries, whichever form it is written in. */
|
|
66
|
+
export function opName(node) {
|
|
67
|
+
if (!node || typeof node !== "object") return null;
|
|
68
|
+
if (typeof node.op === "string") return node.op;
|
|
69
|
+
if (node.op && typeof node.op === "object" && typeof node.op.name === "string") return node.op.name;
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const bare = (id) => String(id).replace(/^#/, "");
|
|
74
|
+
|
|
75
|
+
function rangeOf(node) {
|
|
76
|
+
const r = Array.isArray(node.range) && node.range.length === 2 ? node.range : [0, MAX_WIDTH];
|
|
77
|
+
const lo = Number(r[0]);
|
|
78
|
+
const hi = Number(r[1]);
|
|
79
|
+
return [Number.isFinite(lo) ? lo : 0, Number.isFinite(hi) ? hi : MAX_WIDTH];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Nodes that lose to an earlier node under the declared rules, and nodes of
|
|
84
|
+
* inert ops. Each finding: { index, code, by, lost, detail }.
|
|
85
|
+
* SHADOWED_NODE `lost` lists the targets (or "page") the node loses on;
|
|
86
|
+
* `by` the indices of the nodes that win there; `whole` is
|
|
87
|
+
* true when the node applies nowhere.
|
|
88
|
+
* INERT_OP no renderer code reads this op.
|
|
89
|
+
*/
|
|
90
|
+
export function shadowedNodes(nodes) {
|
|
91
|
+
const out = [];
|
|
92
|
+
if (!Array.isArray(nodes)) return out;
|
|
93
|
+
const seenPage = new Map(); // slot -> first index
|
|
94
|
+
const seenAll = new Map(); // slot -> first untargeted index
|
|
95
|
+
const seenEl = new Map(); // `${slot}|${id}` -> first index
|
|
96
|
+
const seenRange = new Map(); // `${slot}|${id}` -> [{ index, lo, hi }]
|
|
97
|
+
|
|
98
|
+
nodes.forEach((node, index) => {
|
|
99
|
+
const name = opName(node);
|
|
100
|
+
const sem = name && OP_SEMANTICS[name];
|
|
101
|
+
if (!sem) return;
|
|
102
|
+
if (sem.combine === "inert") {
|
|
103
|
+
out.push({ index, code: "INERT_OP", by: [], lost: [], whole: true,
|
|
104
|
+
detail: `No renderer code reads "${name}"; this node does nothing.` });
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (sem.combine !== "first") return;
|
|
108
|
+
const slot = sem.slot || name;
|
|
109
|
+
|
|
110
|
+
if (sem.scope === "page") {
|
|
111
|
+
if (seenPage.has(slot)) {
|
|
112
|
+
const by = seenPage.get(slot);
|
|
113
|
+
out.push({ index, code: "SHADOWED_NODE", by: [by], lost: ["page"], whole: true,
|
|
114
|
+
detail: `Node ${by} already decides "${slot}" for the page; this node does nothing.` });
|
|
115
|
+
} else {
|
|
116
|
+
seenPage.set(slot, index);
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const targets = Array.isArray(node.target) && node.target.length ? node.target.map(bare) : null;
|
|
122
|
+
|
|
123
|
+
if (sem.scope === "range") {
|
|
124
|
+
if (!targets) return;
|
|
125
|
+
const [lo, hi] = rangeOf(node);
|
|
126
|
+
const lost = [];
|
|
127
|
+
const by = new Set();
|
|
128
|
+
for (const id of targets) {
|
|
129
|
+
const key = `${slot}|${id}`;
|
|
130
|
+
const earlier = seenRange.get(key) || [];
|
|
131
|
+
const hits = earlier.filter((e) => e.lo <= hi && lo <= e.hi);
|
|
132
|
+
if (hits.length) {
|
|
133
|
+
lost.push(id);
|
|
134
|
+
hits.forEach((h) => by.add(h.index));
|
|
135
|
+
}
|
|
136
|
+
seenRange.set(key, [...earlier, { index, lo, hi }]);
|
|
137
|
+
}
|
|
138
|
+
if (lost.length) {
|
|
139
|
+
out.push({ index, code: "SHADOWED_NODE", by: [...by], lost, whole: false,
|
|
140
|
+
detail: `On ${lost.join(", ")}, an earlier "${slot}" node covers part of [${lo}, ${hi}]; there the earlier node wins.` });
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// scope "element"
|
|
146
|
+
if (seenAll.has(slot)) {
|
|
147
|
+
const by = seenAll.get(slot);
|
|
148
|
+
out.push({ index, code: "SHADOWED_NODE", by: [by], lost: targets || ["all"], whole: true,
|
|
149
|
+
detail: `Node ${by} has no target, so it reaches every element first; this node does nothing.` });
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (!targets) {
|
|
153
|
+
const earlier = [...seenEl.entries()].filter(([k]) => k.startsWith(`${slot}|`));
|
|
154
|
+
if (earlier.length) {
|
|
155
|
+
out.push({ index, code: "SHADOWED_NODE", by: [...new Set(earlier.map(([, i]) => i))],
|
|
156
|
+
lost: earlier.map(([k]) => k.slice(slot.length + 1)), whole: false,
|
|
157
|
+
detail: `On ${earlier.map(([k]) => k.slice(slot.length + 1)).join(", ")}, an earlier "${slot}" node wins; this node applies to every other element.` });
|
|
158
|
+
}
|
|
159
|
+
seenAll.set(slot, index);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const lost = [];
|
|
163
|
+
const by = new Set();
|
|
164
|
+
for (const id of targets) {
|
|
165
|
+
const key = `${slot}|${id}`;
|
|
166
|
+
if (seenEl.has(key)) { lost.push(id); by.add(seenEl.get(key)); }
|
|
167
|
+
else seenEl.set(key, index);
|
|
168
|
+
}
|
|
169
|
+
if (lost.length) {
|
|
170
|
+
const whole = lost.length === targets.length;
|
|
171
|
+
out.push({ index, code: "SHADOWED_NODE", by: [...by], lost, whole,
|
|
172
|
+
detail: whole
|
|
173
|
+
? `An earlier "${slot}" node already applies to ${lost.join(", ")}; this node does nothing.`
|
|
174
|
+
: `On ${lost.join(", ")}, an earlier "${slot}" node wins; this node still applies to the rest.` });
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return out;
|
|
178
|
+
}
|
package/lib/parse-html.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* nodality v1.5.
|
|
2
|
+
* nodality v1.5.4
|
|
3
3
|
* (c) 2026 Filip Vabrousek
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -54,13 +54,23 @@ const HEADINGS = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
|
54
54
|
/** The attribute a page uses to carry its own descriptors. */
|
|
55
55
|
export const SPEC_ATTR = "data-nod";
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* The attribute marking the JSON script that carries the page's nodes. One
|
|
59
|
+
* script after the annotated children, so the 1:1 children-to-elements
|
|
60
|
+
* mapping is untouched; application/json is neither run nor displayed.
|
|
61
|
+
*/
|
|
62
|
+
export const NODES_ATTR = "data-nod-nodes";
|
|
63
|
+
|
|
64
|
+
const isNodesScript = (n) => n && n.tagName && n.tagName.toLowerCase() === "script"
|
|
65
|
+
&& n.hasAttribute && n.hasAttribute(NODES_ATTR);
|
|
66
|
+
|
|
57
67
|
/**
|
|
58
68
|
* Write each descriptor onto the child it produced. Returns how many were
|
|
59
69
|
* written, which is what the caller needs to know if the two ever diverge.
|
|
60
70
|
*/
|
|
61
|
-
export function annotateRoundTrip(host, elements) {
|
|
71
|
+
export function annotateRoundTrip(host, elements, nodes) {
|
|
62
72
|
if (!host || !Array.isArray(elements)) return 0;
|
|
63
|
-
const kids = Array.from(host.children || []);
|
|
73
|
+
const kids = Array.from(host.children || []).filter((k) => !isNodesScript(k));
|
|
64
74
|
let written = 0;
|
|
65
75
|
for (let i = 0; i < kids.length && i < elements.length; i++) {
|
|
66
76
|
try {
|
|
@@ -68,9 +78,31 @@ export function annotateRoundTrip(host, elements) {
|
|
|
68
78
|
written++;
|
|
69
79
|
} catch (e) { /* a node that refuses attributes is skipped, not fatal */ }
|
|
70
80
|
}
|
|
81
|
+
// The nodes, when the page has any. "<" is escaped so no value can end
|
|
82
|
+
// the script element early.
|
|
83
|
+
for (const k of Array.from(host.children || [])) if (isNodesScript(k)) k.remove();
|
|
84
|
+
if (Array.isArray(nodes) && nodes.length && host.ownerDocument) {
|
|
85
|
+
try {
|
|
86
|
+
const script = host.ownerDocument.createElement("script");
|
|
87
|
+
script.setAttribute("type", "application/json");
|
|
88
|
+
script.setAttribute(NODES_ATTR, "");
|
|
89
|
+
script.textContent = JSON.stringify(nodes).replace(/</g, "\\u003c");
|
|
90
|
+
host.appendChild(script);
|
|
91
|
+
} catch (e) { /* nodes that do not serialise are skipped, not fatal */ }
|
|
92
|
+
}
|
|
71
93
|
return written;
|
|
72
94
|
}
|
|
73
95
|
|
|
96
|
+
/** The nodes a page carries, or null when it carries none or they are corrupt. */
|
|
97
|
+
function readNodes(box) {
|
|
98
|
+
const script = Array.from(box.children).find(isNodesScript);
|
|
99
|
+
if (!script) return null;
|
|
100
|
+
try {
|
|
101
|
+
const nodes = JSON.parse(script.textContent);
|
|
102
|
+
return Array.isArray(nodes) ? nodes : null;
|
|
103
|
+
} catch (e) { return null; }
|
|
104
|
+
}
|
|
105
|
+
|
|
74
106
|
/**
|
|
75
107
|
* Recover what the tag alone determines. Deliberately narrow: returning a
|
|
76
108
|
* confident guess for a composite would be worse than returning nothing,
|
|
@@ -112,7 +144,24 @@ export function parseHTML(html, doc) {
|
|
|
112
144
|
if (!d) throw new Error("[nodality] parseHTML needs a document");
|
|
113
145
|
const box = d.createElement("div");
|
|
114
146
|
box.innerHTML = String(html == null ? "" : html);
|
|
115
|
-
return Array.from(box.children).map(parseNode).filter(Boolean);
|
|
147
|
+
return Array.from(box.children).filter((k) => !isNodesScript(k)).map(parseNode).filter(Boolean);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* parse(html) -> { elements, nodes }. Nodes come back only from a page
|
|
152
|
+
* rendered with `annotate: true`; `nodesExact` says whether they did.
|
|
153
|
+
*/
|
|
154
|
+
export function parseSpec(html, doc) {
|
|
155
|
+
const d = doc || (typeof document !== "undefined" ? document : null);
|
|
156
|
+
if (!d) throw new Error("[nodality] parseSpec needs a document");
|
|
157
|
+
const box = d.createElement("div");
|
|
158
|
+
box.innerHTML = String(html == null ? "" : html);
|
|
159
|
+
const nodes = readNodes(box);
|
|
160
|
+
return {
|
|
161
|
+
elements: Array.from(box.children).filter((k) => !isNodesScript(k)).map(parseNode).filter(Boolean),
|
|
162
|
+
nodes: nodes || [],
|
|
163
|
+
nodesExact: nodes !== null,
|
|
164
|
+
};
|
|
116
165
|
}
|
|
117
166
|
|
|
118
167
|
/**
|
|
@@ -124,7 +173,8 @@ export function parseReport(html, doc) {
|
|
|
124
173
|
if (!d) throw new Error("[nodality] parseReport needs a document");
|
|
125
174
|
const box = d.createElement("div");
|
|
126
175
|
box.innerHTML = String(html == null ? "" : html);
|
|
127
|
-
const
|
|
176
|
+
const nodes = readNodes(box);
|
|
177
|
+
const kids = Array.from(box.children).filter((k) => !isNodesScript(k));
|
|
128
178
|
const spec = [], unrecovered = [];
|
|
129
179
|
kids.forEach((node, i) => {
|
|
130
180
|
const one = parseNode(node);
|
|
@@ -138,13 +188,17 @@ export function parseReport(html, doc) {
|
|
|
138
188
|
// already become a page. This is also the first place Stage 3 and Stage 5
|
|
139
189
|
// compose — the validator that makes a spec repairable is the one that
|
|
140
190
|
// makes a parsed spec safe.
|
|
141
|
-
|
|
191
|
+
// The carried nodes are untrusted for the same reason, and are checked
|
|
192
|
+
// against the recovered elements.
|
|
193
|
+
const check = validateNodes(nodes || [], spec);
|
|
142
194
|
|
|
143
195
|
return {
|
|
144
196
|
ok: unrecovered.length === 0 && check.ok,
|
|
145
197
|
exact: kids.every((n) => n.getAttribute && n.getAttribute(SPEC_ATTR)),
|
|
146
198
|
total: kids.length,
|
|
147
199
|
spec,
|
|
200
|
+
nodes: nodes || [],
|
|
201
|
+
nodesExact: nodes !== null,
|
|
148
202
|
unrecovered,
|
|
149
203
|
errors: check.errors,
|
|
150
204
|
};
|
package/lib/raster-inspect.js
CHANGED
package/lib/raster-ops.js
CHANGED
package/lib/raster-presets.js
CHANGED
package/lib/react.js
CHANGED
package/lib/resolve-refs.js
CHANGED