nodality 1.5.3 → 1.5.5

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.
Files changed (292) hide show
  1. package/README.md +7 -4
  2. package/bin/mcp-server.mjs +23 -1
  3. package/dist/animator.cjs.js +1 -1
  4. package/dist/animator.cjs.js.LICENSE.txt +1 -1
  5. package/dist/animator.esm.js +1 -1
  6. package/dist/animator.esm.js.LICENSE.txt +1 -1
  7. package/dist/audionew.cjs.js +1 -1
  8. package/dist/audionew.cjs.js.LICENSE.txt +1 -1
  9. package/dist/audionew.esm.js +1 -1
  10. package/dist/audionew.esm.js.LICENSE.txt +1 -1
  11. package/dist/base.cjs.js +1 -1
  12. package/dist/base.cjs.js.LICENSE.txt +1 -1
  13. package/dist/base.esm.js +1 -1
  14. package/dist/base.esm.js.LICENSE.txt +1 -1
  15. package/dist/beta-desktop-bar.cjs.js +1 -1
  16. package/dist/beta-desktop-bar.cjs.js.LICENSE.txt +1 -1
  17. package/dist/beta-desktop-bar.esm.js +1 -1
  18. package/dist/beta-desktop-bar.esm.js.LICENSE.txt +1 -1
  19. package/dist/beta-mobile-bar.cjs.js +1 -1
  20. package/dist/beta-mobile-bar.cjs.js.LICENSE.txt +1 -1
  21. package/dist/beta-mobile-bar.esm.js +1 -1
  22. package/dist/beta-mobile-bar.esm.js.LICENSE.txt +1 -1
  23. package/dist/bundle.umd.js +1 -1
  24. package/dist/bundle.umd.js.LICENSE.txt +1 -1
  25. package/dist/button.cjs.js +1 -1
  26. package/dist/button.cjs.js.LICENSE.txt +1 -1
  27. package/dist/button.esm.js +1 -1
  28. package/dist/button.esm.js.LICENSE.txt +1 -1
  29. package/dist/card-getter.cjs.js.LICENSE.txt +1 -1
  30. package/dist/card-getter.esm.js.LICENSE.txt +1 -1
  31. package/dist/center.cjs.js +1 -1
  32. package/dist/center.cjs.js.LICENSE.txt +1 -1
  33. package/dist/center.esm.js +1 -1
  34. package/dist/center.esm.js.LICENSE.txt +1 -1
  35. package/dist/checkbox.cjs.js +1 -1
  36. package/dist/checkbox.cjs.js.LICENSE.txt +1 -1
  37. package/dist/checkbox.esm.js +1 -1
  38. package/dist/checkbox.esm.js.LICENSE.txt +1 -1
  39. package/dist/code.cjs.js +1 -1
  40. package/dist/code.cjs.js.LICENSE.txt +1 -1
  41. package/dist/code.esm.js +1 -1
  42. package/dist/code.esm.js.LICENSE.txt +1 -1
  43. package/dist/container.cjs.js +1 -1
  44. package/dist/container.cjs.js.LICENSE.txt +1 -1
  45. package/dist/container.esm.js +1 -1
  46. package/dist/container.esm.js.LICENSE.txt +1 -1
  47. package/dist/data-list.cjs.js.LICENSE.txt +1 -1
  48. package/dist/data-list.esm.js.LICENSE.txt +1 -1
  49. package/dist/designer.cjs.js +1 -1
  50. package/dist/designer.cjs.js.LICENSE.txt +1 -1
  51. package/dist/designer.esm.js +1 -1
  52. package/dist/designer.esm.js.LICENSE.txt +1 -1
  53. package/dist/element-mapper.cjs.js +1 -1
  54. package/dist/element-mapper.cjs.js.LICENSE.txt +1 -1
  55. package/dist/element-mapper.esm.js +1 -1
  56. package/dist/element-mapper.esm.js.LICENSE.txt +1 -1
  57. package/dist/finalresult.esm.js +1 -1
  58. package/dist/finalresult.esm.js.LICENSE.txt +1 -1
  59. package/dist/flex-card.cjs.js +1 -1
  60. package/dist/flex-card.cjs.js.LICENSE.txt +1 -1
  61. package/dist/flex-card.esm.js +1 -1
  62. package/dist/flex-card.esm.js.LICENSE.txt +1 -1
  63. package/dist/flex-grid.cjs.js +1 -1
  64. package/dist/flex-grid.cjs.js.LICENSE.txt +1 -1
  65. package/dist/flex-grid.esm.js +1 -1
  66. package/dist/flex-grid.esm.js.LICENSE.txt +1 -1
  67. package/dist/flex-row.cjs.js +1 -1
  68. package/dist/flex-row.cjs.js.LICENSE.txt +1 -1
  69. package/dist/flex-row.esm.js +1 -1
  70. package/dist/flex-row.esm.js.LICENSE.txt +1 -1
  71. package/dist/floating-input.cjs.js +1 -1
  72. package/dist/floating-input.cjs.js.LICENSE.txt +1 -1
  73. package/dist/floating-input.esm.js +1 -1
  74. package/dist/floating-input.esm.js.LICENSE.txt +1 -1
  75. package/dist/free.cjs.js +1 -1
  76. package/dist/free.cjs.js.LICENSE.txt +1 -1
  77. package/dist/free.esm.js +1 -1
  78. package/dist/free.esm.js.LICENSE.txt +1 -1
  79. package/dist/horizontal-scroller.cjs.js.LICENSE.txt +1 -1
  80. package/dist/horizontal-scroller.esm.js.LICENSE.txt +1 -1
  81. package/dist/image-picker.cjs.js +1 -1
  82. package/dist/image-picker.cjs.js.LICENSE.txt +1 -1
  83. package/dist/image-picker.esm.js +1 -1
  84. package/dist/image-picker.esm.js.LICENSE.txt +1 -1
  85. package/dist/image.cjs.js +1 -1
  86. package/dist/image.cjs.js.LICENSE.txt +1 -1
  87. package/dist/image.esm.js +1 -1
  88. package/dist/image.esm.js.LICENSE.txt +1 -1
  89. package/dist/index.cjs.js +1 -1
  90. package/dist/index.cjs.js.LICENSE.txt +1 -1
  91. package/dist/index.d.ts +3 -2
  92. package/dist/index.esm.js +1 -1
  93. package/dist/index.esm.js.LICENSE.txt +1 -1
  94. package/dist/keyframe-animation.cjs.js.LICENSE.txt +1 -1
  95. package/dist/keyframe-animation.esm.js.LICENSE.txt +1 -1
  96. package/dist/link-getter.cjs.js +1 -1
  97. package/dist/link-getter.cjs.js.LICENSE.txt +1 -1
  98. package/dist/link-getter.esm.js +1 -1
  99. package/dist/link-getter.esm.js.LICENSE.txt +1 -1
  100. package/dist/link.cjs.js +1 -1
  101. package/dist/link.cjs.js.LICENSE.txt +1 -1
  102. package/dist/link.esm.js +1 -1
  103. package/dist/link.esm.js.LICENSE.txt +1 -1
  104. package/dist/meta-adder.cjs.js +1 -1
  105. package/dist/meta-adder.cjs.js.LICENSE.txt +1 -1
  106. package/dist/meta-adder.esm.js +1 -1
  107. package/dist/meta-adder.esm.js.LICENSE.txt +1 -1
  108. package/dist/modal-2025.cjs.js +1 -1
  109. package/dist/modal-2025.cjs.js.LICENSE.txt +1 -1
  110. package/dist/modal-2025.esm.js +1 -1
  111. package/dist/modal-2025.esm.js.LICENSE.txt +1 -1
  112. package/dist/multiswitcher.cjs.js +1 -1
  113. package/dist/multiswitcher.cjs.js.LICENSE.txt +1 -1
  114. package/dist/multiswitcher.esm.js +1 -1
  115. package/dist/multiswitcher.esm.js.LICENSE.txt +1 -1
  116. package/dist/new-nav-bar.cjs.js +1 -1
  117. package/dist/new-nav-bar.cjs.js.LICENSE.txt +1 -1
  118. package/dist/new-nav-bar.esm.js +1 -1
  119. package/dist/new-nav-bar.esm.js.LICENSE.txt +1 -1
  120. package/dist/picker.cjs.js +1 -1
  121. package/dist/picker.cjs.js.LICENSE.txt +1 -1
  122. package/dist/picker.esm.js +1 -1
  123. package/dist/picker.esm.js.LICENSE.txt +1 -1
  124. package/dist/progress.cjs.js +1 -1
  125. package/dist/progress.cjs.js.LICENSE.txt +1 -1
  126. package/dist/progress.esm.js +1 -1
  127. package/dist/progress.esm.js.LICENSE.txt +1 -1
  128. package/dist/radio.cjs.js.LICENSE.txt +1 -1
  129. package/dist/radio.esm.js.LICENSE.txt +1 -1
  130. package/dist/range.cjs.js.LICENSE.txt +1 -1
  131. package/dist/range.esm.js.LICENSE.txt +1 -1
  132. package/dist/scroll-video.cjs.js.LICENSE.txt +1 -1
  133. package/dist/scroll-video.esm.js.LICENSE.txt +1 -1
  134. package/dist/side-bar.cjs.js +1 -1
  135. package/dist/side-bar.cjs.js.LICENSE.txt +1 -1
  136. package/dist/side-bar.esm.js +1 -1
  137. package/dist/side-bar.esm.js.LICENSE.txt +1 -1
  138. package/dist/side-nav-bar.cjs.js +1 -1
  139. package/dist/side-nav-bar.cjs.js.LICENSE.txt +1 -1
  140. package/dist/side-nav-bar.esm.js +1 -1
  141. package/dist/side-nav-bar.esm.js.LICENSE.txt +1 -1
  142. package/dist/simple-bar.cjs.js +1 -1
  143. package/dist/simple-bar.cjs.js.LICENSE.txt +1 -1
  144. package/dist/simple-bar.esm.js +1 -1
  145. package/dist/simple-bar.esm.js.LICENSE.txt +1 -1
  146. package/dist/slider-2025.cjs.js +1 -1
  147. package/dist/slider-2025.cjs.js.LICENSE.txt +1 -1
  148. package/dist/slider-2025.esm.js +1 -1
  149. package/dist/slider-2025.esm.js.LICENSE.txt +1 -1
  150. package/dist/spacer.cjs.js +1 -1
  151. package/dist/spacer.cjs.js.LICENSE.txt +1 -1
  152. package/dist/spacer.esm.js +1 -1
  153. package/dist/spacer.esm.js.LICENSE.txt +1 -1
  154. package/dist/stack.cjs.js +1 -1
  155. package/dist/stack.cjs.js.LICENSE.txt +1 -1
  156. package/dist/stack.esm.js +1 -1
  157. package/dist/stack.esm.js.LICENSE.txt +1 -1
  158. package/dist/stacker.cjs.js.LICENSE.txt +1 -1
  159. package/dist/stacker.esm.js.LICENSE.txt +1 -1
  160. package/dist/table.cjs.js +1 -1
  161. package/dist/table.cjs.js.LICENSE.txt +1 -1
  162. package/dist/table.esm.js +1 -1
  163. package/dist/table.esm.js.LICENSE.txt +1 -1
  164. package/dist/text-field.cjs.js +1 -1
  165. package/dist/text-field.cjs.js.LICENSE.txt +1 -1
  166. package/dist/text-field.esm.js +1 -1
  167. package/dist/text-field.esm.js.LICENSE.txt +1 -1
  168. package/dist/text.cjs.js +1 -1
  169. package/dist/text.cjs.js.LICENSE.txt +1 -1
  170. package/dist/text.esm.js +1 -1
  171. package/dist/text.esm.js.LICENSE.txt +1 -1
  172. package/dist/theme.cjs.js.LICENSE.txt +1 -1
  173. package/dist/theme.esm.js.LICENSE.txt +1 -1
  174. package/dist/transform-anim.cjs.js.LICENSE.txt +1 -1
  175. package/dist/transform-anim.esm.js.LICENSE.txt +1 -1
  176. package/dist/ulist.cjs.js +1 -1
  177. package/dist/ulist.cjs.js.LICENSE.txt +1 -1
  178. package/dist/ulist.esm.js +1 -1
  179. package/dist/ulist.esm.js.LICENSE.txt +1 -1
  180. package/dist/video.cjs.js +1 -1
  181. package/dist/video.cjs.js.LICENSE.txt +1 -1
  182. package/dist/video.esm.js +1 -1
  183. package/dist/video.esm.js.LICENSE.txt +1 -1
  184. package/dist/wrap.cjs.js +1 -1
  185. package/dist/wrap.cjs.js.LICENSE.txt +1 -1
  186. package/dist/wrap.esm.js +1 -1
  187. package/dist/wrap.esm.js.LICENSE.txt +1 -1
  188. package/dist/zoom-card.cjs.js +1 -1
  189. package/dist/zoom-card.cjs.js.LICENSE.txt +1 -1
  190. package/dist/zoom-card.esm.js +1 -1
  191. package/dist/zoom-card.esm.js.LICENSE.txt +1 -1
  192. package/layout/animator.js +6 -2
  193. package/layout/audio.js +1 -1
  194. package/layout/audionew.js +1 -1
  195. package/layout/base.js +1 -1
  196. package/layout/beta-desktop-bar.js +1 -1
  197. package/layout/beta-mobile-bar.js +1 -1
  198. package/layout/button.js +1 -1
  199. package/layout/center.js +1 -1
  200. package/layout/checkbox.js +1 -1
  201. package/layout/circle.js +3 -3
  202. package/layout/code.js +2 -2
  203. package/layout/container.js +2 -2
  204. package/layout/dropdown-2025.js +1 -1
  205. package/layout/flex-card.js +2 -2
  206. package/layout/flex-grid.js +2 -2
  207. package/layout/flex-row.js +2 -2
  208. package/layout/form-components/custom.js +1 -1
  209. package/layout/form-components/data-list.js +1 -1
  210. package/layout/form-components/floating-input.js +1 -1
  211. package/layout/form-components/form-all.js +1 -1
  212. package/layout/form-components/form.js +1 -1
  213. package/layout/form-components/image-picker.js +1 -1
  214. package/layout/form-components/picker.js +1 -1
  215. package/layout/form-components/radio.js +1 -1
  216. package/layout/form-components/radiogroup.js +1 -1
  217. package/layout/form-components/range.js +1 -1
  218. package/layout/free.js +1 -1
  219. package/layout/grid-overlay.js +1 -1
  220. package/layout/grid-switcher.js +1 -1
  221. package/layout/grid.js +1 -1
  222. package/layout/horizontal-scroller.js +1 -1
  223. package/layout/image.js +1 -1
  224. package/layout/index.js +1 -1
  225. package/layout/link.js +2 -2
  226. package/layout/list.js +1 -1
  227. package/layout/meta-adder.js +1 -1
  228. package/layout/modal-2025.js +1 -1
  229. package/layout/morph.js +1 -1
  230. package/layout/multiswitcher.js +1 -1
  231. package/layout/nav-bar.js +1 -1
  232. package/layout/nav-factor/custom-div.js +1 -1
  233. package/layout/new-nav-bar.js +1 -1
  234. package/layout/polygon.js +3 -3
  235. package/layout/prerender-site.js +1 -1
  236. package/layout/prerender.js +1 -1
  237. package/layout/progress.js +1 -1
  238. package/layout/row.js +1 -1
  239. package/layout/scroll-video.js +1 -1
  240. package/layout/shop.js +1 -1
  241. package/layout/side-bar.js +1 -1
  242. package/layout/side-nav-bar.js +1 -1
  243. package/layout/simple-bar.js +1 -1
  244. package/layout/slider-2025.js +1 -1
  245. package/layout/spacer.js +1 -1
  246. package/layout/stack.js +2 -2
  247. package/layout/svg.js +1 -1
  248. package/layout/switcher.js +1 -1
  249. package/layout/table.js +2 -2
  250. package/layout/text-field.js +1 -1
  251. package/layout/text.js +2 -2
  252. package/layout/ulist.js +19 -2
  253. package/layout/video.js +1 -1
  254. package/layout/wrap.js +1 -1
  255. package/layout/zoom-card.js +1 -1
  256. package/lib/agent-surface.js +2 -2
  257. package/lib/card-getter.js +1 -1
  258. package/lib/check-page.js +1 -1
  259. package/lib/codegen.js +1 -1
  260. package/lib/data.js +1 -1
  261. package/lib/designer.js +2 -2
  262. package/lib/element-mapper.js +8 -6
  263. package/lib/element-params.generated.js +1 -1
  264. package/lib/grid-geometry.js +1 -1
  265. package/lib/keyframe-animation.js +1 -1
  266. package/lib/known-inert.js +1 -1
  267. package/lib/lines.js +262 -0
  268. package/lib/link-getter.js +3 -3
  269. package/lib/morph-node.js +1 -1
  270. package/lib/normalize-spec.js +1 -1
  271. package/lib/op-semantics.js +91 -2
  272. package/lib/parse-html.js +60 -6
  273. package/lib/raster-inspect.js +1 -1
  274. package/lib/raster-ops.js +1 -1
  275. package/lib/raster-presets.js +1 -1
  276. package/lib/react.js +1 -1
  277. package/lib/resolve-refs.js +1 -1
  278. package/lib/responsive.js +1 -1
  279. package/lib/scroll-video.js +1 -1
  280. package/lib/seo.js +1 -1
  281. package/lib/stacker.js +1 -1
  282. package/lib/suggest.js +1 -1
  283. package/lib/theme.js +1 -1
  284. package/lib/transform-anim.js +1 -1
  285. package/lib/transition.js +1 -1
  286. package/lib/validate-nodes.js +21 -1
  287. package/lib/view-transition.js +1 -1
  288. package/lib/webmcp-adapter.js +21 -6
  289. package/package.json +2 -1
  290. package/skills/nodality/SKILL.md +4 -0
  291. package/skills/nodality/references/editing.md +8 -6
  292. package/skills/nodality-edit-page/SKILL.md +3 -1
package/lib/lines.js ADDED
@@ -0,0 +1,262 @@
1
+ /*!
2
+ * nodality v1.5.5
3
+ * (c) 2026 Filip Vabrousek
4
+ * License: MIT
5
+ */
6
+
7
+ /*!
8
+ * lines.js: a compact line syntax for the (elements, nodes) pair.
9
+ *
10
+ * One statement per line, so a model's output streams, an error points at a
11
+ * line, and an edit replaces a line. It is parsed, never evaluated: page text
12
+ * stays data. print() and parse() round-trip any pair, so the JSON form stays
13
+ * the stored and validated one.
14
+ *
15
+ * h1 #hero "Ship it" color=#1d6fe0 an element: type, #id, "text", key=value
16
+ * row #features children are indented two spaces
17
+ * h2 "Plain data in"
18
+ * + shadow() hero a node: {op:{name:"shadow"}, target:["hero"]}
19
+ * + gradient(gradient="linear-gradient(90deg, #000, #fff)") hero
20
+ * + dither hero levels=6 size=2 {op:"dither", target:["hero"], levels:6, size:2}
21
+ * + arrange(mode=column) features @0-424
22
+ * { "$ref": "card" } any element as raw JSON
23
+ * + { "op": "morph", "chain": [] } any node as raw JSON
24
+ * // a comment
25
+ *
26
+ * Values are bare when unambiguous (3px, #fff, column, 6, true) and JSON
27
+ * otherwise ("two words", [1,2], {"a":1}). A bare number or true/false/null
28
+ * means the number or literal; the string "6" prints as "6".
29
+ *
30
+ * Pure module: no DOM at import.
31
+ */
32
+
33
+ const BARE = /^[A-Za-z0-9#._%/:+-]+$/;
34
+ const NUM = /^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/;
35
+ const KEY = /^[A-Za-z_$][\w$-]*$/;
36
+ const ID = /^[A-Za-z0-9_-]+$/;
37
+ const OP = /^[A-Za-z][\w-]*$/;
38
+
39
+ // ── printing ─────────────────────────────────────────────────────────
40
+
41
+ function value(v) {
42
+ if (typeof v === "string" && v.length && BARE.test(v) && !NUM.test(v)
43
+ && !["true", "false", "null"].includes(v) && !v.startsWith("@") && !v.startsWith("+")) return v;
44
+ return JSON.stringify(v);
45
+ }
46
+
47
+ const key = (k) => (KEY.test(k) ? k : JSON.stringify(k));
48
+ const pairs = (obj, skip) => Object.keys(obj)
49
+ .filter((k) => !skip.includes(k) && obj[k] !== undefined)
50
+ .map((k) => `${key(k)}=${value(obj[k])}`);
51
+
52
+ function printElement(el, depth, out) {
53
+ const pad = " ".repeat(depth);
54
+ if (!el || typeof el !== "object" || Array.isArray(el) || typeof el.type !== "string" || !OP.test(el.type)) {
55
+ out.push(pad + JSON.stringify(el));
56
+ return;
57
+ }
58
+ const parts = [el.type];
59
+ const skip = ["type"];
60
+ if (typeof el.id === "string" && ID.test(el.id)) { parts.push(`#${el.id}`); skip.push("id"); }
61
+ if (typeof el.text === "string") { parts.push(JSON.stringify(el.text)); skip.push("text"); }
62
+ const kids = Array.isArray(el.children) && el.children.length
63
+ && el.children.every((c) => c && typeof c === "object" && !Array.isArray(c));
64
+ if (kids) skip.push("children");
65
+ parts.push(...pairs(el, skip));
66
+ out.push(pad + parts.join(" "));
67
+ if (kids) for (const c of el.children) printElement(c, depth + 1, out);
68
+ }
69
+
70
+ function printNode(node, out) {
71
+ if (!node || typeof node !== "object" || Array.isArray(node)) { out.push("+ " + JSON.stringify(node)); return; }
72
+ const op = node.op;
73
+ let head;
74
+ if (typeof op === "string" && OP.test(op)) head = op;
75
+ else if (op && typeof op === "object" && !Array.isArray(op) && typeof op.name === "string" && OP.test(op.name)) {
76
+ head = `${op.name}(${pairs(op, ["name"]).join(", ")})`;
77
+ } else { out.push("+ " + JSON.stringify(node)); return; }
78
+ const parts = [head];
79
+ const skip = ["op"];
80
+ if (Array.isArray(node.target) && node.target.length
81
+ && node.target.every((t) => typeof t === "string" && BARE.test(t) && !NUM.test(t) && !t.startsWith("@"))) {
82
+ parts.push(...node.target);
83
+ skip.push("target");
84
+ }
85
+ const r = node.range;
86
+ if (Array.isArray(r) && r.length === 2 && Number.isInteger(r[0]) && Number.isInteger(r[1]) && r[0] >= 0 && r[1] >= 0) {
87
+ parts.push(`@${r[0]}-${r[1]}`);
88
+ skip.push("range");
89
+ }
90
+ parts.push(...pairs(node, skip));
91
+ out.push("+ " + parts.join(" "));
92
+ }
93
+
94
+ /** The pair as lines. */
95
+ export function printLines({ elements = [], nodes = [] } = {}) {
96
+ const out = [];
97
+ for (const el of elements) printElement(el, 0, out);
98
+ for (const n of nodes) printNode(n, out);
99
+ return out.join("\n") + (out.length ? "\n" : "");
100
+ }
101
+
102
+ // ── parsing ──────────────────────────────────────────────────────────
103
+
104
+ /** Length of a JSON string literal starting at i (s[i] === '"'), or -1. */
105
+ function stringEnd(s, i) {
106
+ for (let j = i + 1; j < s.length; j++) {
107
+ if (s[j] === "\\") { j++; continue; }
108
+ if (s[j] === '"') return j + 1;
109
+ }
110
+ return -1;
111
+ }
112
+
113
+ /** End index of a balanced [..], {..} or (..) starting at i. */
114
+ function balancedEnd(s, i) {
115
+ const open = s[i];
116
+ const close = { "[": "]", "{": "}", "(": ")" }[open];
117
+ let depth = 0;
118
+ for (let j = i; j < s.length; j++) {
119
+ const c = s[j];
120
+ if (c === '"') { const e = stringEnd(s, j); if (e < 0) return -1; j = e - 1; continue; }
121
+ if (c === "[" || c === "{" || c === "(") depth++;
122
+ else if (c === "]" || c === "}" || c === ")") { depth--; if (depth === 0) return c === close ? j + 1 : -1; }
123
+ }
124
+ return -1;
125
+ }
126
+
127
+ /** Split a line into raw tokens: strings, bracketed groups and words, keeping key=value together. */
128
+ function tokens(s) {
129
+ const out = [];
130
+ let i = 0;
131
+ while (i < s.length) {
132
+ if (/\s|,/.test(s[i])) { i++; continue; }
133
+ let j = i;
134
+ while (j < s.length && !/\s|,/.test(s[j])) {
135
+ if (s[j] === '"') { const e = stringEnd(s, j); if (e < 0) throw new Error("unterminated string"); j = e; continue; }
136
+ if (s[j] === "[" || s[j] === "{" || s[j] === "(") {
137
+ const e = balancedEnd(s, j);
138
+ if (e < 0) throw new Error(`unbalanced ${s[j]}`);
139
+ j = e;
140
+ continue;
141
+ }
142
+ j++;
143
+ }
144
+ out.push(s.slice(i, j));
145
+ i = j;
146
+ }
147
+ return out;
148
+ }
149
+
150
+ function parseValue(raw) {
151
+ if (raw === "") throw new Error("empty value");
152
+ if (raw[0] === '"' || raw[0] === "[" || raw[0] === "{") return JSON.parse(raw);
153
+ if (NUM.test(raw)) return Number(raw);
154
+ if (raw === "true") return true;
155
+ if (raw === "false") return false;
156
+ if (raw === "null") return null;
157
+ return raw;
158
+ }
159
+
160
+ /** "k=v" -> [k, v], or null when the token is not a pair. */
161
+ function pair(tok) {
162
+ let k, rest;
163
+ if (tok[0] === '"') {
164
+ const e = stringEnd(tok, 0);
165
+ if (e < 0 || tok[e] !== "=") return null;
166
+ k = JSON.parse(tok.slice(0, e));
167
+ rest = tok.slice(e + 1);
168
+ } else {
169
+ const m = /^([A-Za-z_$][\w$-]*)=(.*)$/s.exec(tok);
170
+ if (!m) return null;
171
+ k = m[1];
172
+ rest = m[2];
173
+ }
174
+ return [k, parseValue(rest)];
175
+ }
176
+
177
+ function parseNodeLine(body) {
178
+ if (body[0] === "{") return JSON.parse(body);
179
+ const toks = tokens(body);
180
+ if (!toks.length) throw new Error("empty node");
181
+ const m = /^([A-Za-z][\w-]*)(\(.*\))?$/s.exec(toks[0]);
182
+ if (!m) throw new Error(`not an op: ${toks[0]}`);
183
+ const node = {};
184
+ if (m[2] !== undefined) {
185
+ const op = { name: m[1] };
186
+ for (const t of tokens(m[2].slice(1, -1))) {
187
+ const p = pair(t);
188
+ if (!p) throw new Error(`op parameter is not key=value: ${t}`);
189
+ op[p[0]] = p[1];
190
+ }
191
+ node.op = op;
192
+ } else node.op = m[1];
193
+ const target = [];
194
+ for (const t of toks.slice(1)) {
195
+ const p = pair(t);
196
+ if (p) { node[p[0]] = p[1]; continue; }
197
+ const r = /^@(\d+)-(\d+)$/.exec(t);
198
+ if (r) { node.range = [Number(r[1]), Number(r[2])]; continue; }
199
+ if (t[0] === '"') { target.push(JSON.parse(t)); continue; }
200
+ target.push(t);
201
+ }
202
+ if (target.length) {
203
+ // Keep `target` right after `op`, as written.
204
+ const { op, ...rest } = node;
205
+ return { op, target, ...rest };
206
+ }
207
+ return node;
208
+ }
209
+
210
+ function parseElementLine(body) {
211
+ if (body[0] === "{") return JSON.parse(body);
212
+ const toks = tokens(body);
213
+ if (!OP.test(toks[0] || "")) throw new Error(`not an element type: ${toks[0]}`);
214
+ const el = { type: toks[0] };
215
+ for (const t of toks.slice(1)) {
216
+ const p = pair(t);
217
+ if (p) { el[p[0]] = p[1]; continue; }
218
+ if (t[0] === "#" && ID.test(t.slice(1)) && el.id === undefined) { el.id = t.slice(1); continue; }
219
+ if (t[0] === '"' && el.text === undefined) { el.text = JSON.parse(t); continue; }
220
+ throw new Error(`unexpected ${t}`);
221
+ }
222
+ return el;
223
+ }
224
+
225
+ /**
226
+ * Lines -> { elements, nodes, errors }. A line that cannot be read is
227
+ * reported with its number and skipped; the rest still parses, so a stream
228
+ * cut mid-line loses only that line.
229
+ */
230
+ export function parseLines(text) {
231
+ const elements = [];
232
+ const nodes = [];
233
+ const errors = [];
234
+ const stack = []; // [{ depth, el }]
235
+ String(text == null ? "" : text).split("\n").forEach((raw, i) => {
236
+ const line = i + 1;
237
+ if (!raw.trim() || raw.trim().startsWith("//")) return;
238
+ const indent = raw.length - raw.trimStart().length;
239
+ const body = raw.trim();
240
+ try {
241
+ if (body.startsWith("+")) {
242
+ nodes.push(parseNodeLine(body.slice(1).trim()));
243
+ return;
244
+ }
245
+ if (indent % 2) throw new Error("indent by two spaces");
246
+ const depth = indent / 2;
247
+ const el = parseElementLine(body);
248
+ while (stack.length && stack[stack.length - 1].depth >= depth) stack.pop();
249
+ if (depth === 0) elements.push(el);
250
+ else {
251
+ const parent = stack[stack.length - 1];
252
+ if (!parent || parent.depth !== depth - 1) throw new Error("indented with no parent one level up");
253
+ if (!Array.isArray(parent.el.children)) parent.el.children = [];
254
+ parent.el.children.push(el);
255
+ }
256
+ stack.push({ depth, el });
257
+ } catch (e) {
258
+ errors.push({ line, message: e.message, text: raw });
259
+ }
260
+ });
261
+ return { elements, nodes, errors };
262
+ }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -64,13 +64,13 @@ class LinkStyler {
64
64
  }
65
65
  }
66
66
 
67
- let split = bst[j].op.ops.split("-");
67
+ let split = String(bst[j].op.ops || "").split("-");
68
68
 
69
69
  // re["color"] = //bst.op.style.color;
70
70
 
71
71
  // alert(allow);
72
72
 
73
- /* let split = bst[j].op.ops.split("-");
73
+ /* let split = String(bst[j].op.ops || "").split("-");
74
74
 
75
75
  if(allow && split.includes("round")){
76
76
  re["borderObj"] = {width: 3, radius: "0.7rem", color: bst[j].op.style.color};
package/lib/morph-node.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * Pure module: no DOM at import.
32
32
  */
33
- import { RASTER_OP_NAMES } from "./raster-ops.js";
33
+ import { RASTER_OP_NAMES, REGISTRY } from "./raster-ops.js";
34
34
 
35
35
  const MAX_WIDTH = 99999;
36
36
 
@@ -176,3 +176,92 @@ export function shadowedNodes(nodes) {
176
176
  });
177
177
  return out;
178
178
  }
179
+
180
+ /**
181
+ * What applies to one element, at every viewport width, and why.
182
+ *
183
+ * Static: computed from the nodes alone, no browser. For each op that
184
+ * reaches the element it names the node that decides it and the nodes that
185
+ * lose. `arrange` is the one op that reads `range`, so it is answered per
186
+ * width interval; every other op decides the same at every width.
187
+ *
188
+ * { element, ops: [
189
+ * { op, combine: "first", node, shadowed: [i...] },
190
+ * { op: "arrange", combine: "first", intervals: [{ range, node, shadowed }] },
191
+ * { op, combine: "sequence", stage, nodes: [i...] }, // in apply order
192
+ * ],
193
+ * page: [{ op, node, shadowed }], // page-wide ops (layout, card-style...)
194
+ * inert: [i...] }
195
+ */
196
+ export function explainElement(nodes, elementId) {
197
+ const id = bare(elementId);
198
+ const list = Array.isArray(nodes) ? nodes : [];
199
+ const reaches = (node, sem) => {
200
+ if (sem.scope === "page") return true;
201
+ const t = Array.isArray(node.target) && node.target.length ? node.target.map(bare) : null;
202
+ if (!t) return sem.scope !== "range";
203
+ return sem.firstTargetOnly ? t[0] === id : t.includes(id);
204
+ };
205
+ const firsts = new Map(); // slot -> { op, node, shadowed }
206
+ const pageWide = new Map();
207
+ const arranges = []; // { index, lo, hi }
208
+ const sequences = new Map(); // op|stage -> { op, stage, nodes }
209
+ const inert = [];
210
+
211
+ list.forEach((node, index) => {
212
+ const name = opName(node);
213
+ const sem = name && OP_SEMANTICS[name];
214
+ if (!sem || !reaches(node, sem)) return;
215
+ if (sem.combine === "inert") { inert.push(index); return; }
216
+ if (sem.combine === "sequence") {
217
+ const stages = sem.byStage
218
+ ? [].concat((REGISTRY[name] && REGISTRY[name].stage) || "color")
219
+ : [null];
220
+ for (const stage of stages) {
221
+ const key = sem.byStage ? `stage:${stage}` : name;
222
+ if (!sequences.has(key)) sequences.set(key, { op: sem.byStage ? null : name, stage, nodes: [] });
223
+ sequences.get(key).nodes.push(index);
224
+ }
225
+ return;
226
+ }
227
+ if (sem.scope === "range") {
228
+ const [lo, hi] = rangeOf(node);
229
+ arranges.push({ index, lo, hi });
230
+ return;
231
+ }
232
+ const slot = sem.slot || name;
233
+ const map = sem.scope === "page" ? pageWide : firsts;
234
+ if (!map.has(slot)) map.set(slot, { op: slot, combine: "first", node: index, shadowed: [] });
235
+ else map.get(slot).shadowed.push(index);
236
+ });
237
+
238
+ const ops = [...firsts.values()];
239
+ if (arranges.length) {
240
+ // Cut the width axis at every range end; each piece's winner is the
241
+ // first declared node covering it.
242
+ const cuts = new Set([0, MAX_WIDTH + 1]);
243
+ for (const a of arranges) { cuts.add(a.lo); cuts.add(a.hi + 1); }
244
+ const pts = [...cuts].filter((x) => x >= 0 && x <= MAX_WIDTH + 1).sort((a, b) => a - b);
245
+ const intervals = [];
246
+ for (let i = 0; i + 1 < pts.length; i++) {
247
+ const lo = pts[i], hi = pts[i + 1] - 1;
248
+ const cover = arranges.filter((a) => a.lo <= lo && hi <= a.hi);
249
+ if (!cover.length) continue;
250
+ const last = intervals[intervals.length - 1];
251
+ const node = cover[0].index;
252
+ const shadowed = cover.slice(1).map((c) => c.index);
253
+ if (last && last.node === node && last.range[1] + 1 === lo
254
+ && JSON.stringify(last.shadowed) === JSON.stringify(shadowed)) last.range[1] = hi;
255
+ else intervals.push({ range: [lo, hi], node, shadowed });
256
+ }
257
+ ops.push({ op: "arrange", combine: "first", intervals });
258
+ }
259
+ const order = ["field", "warp", "cell", "displace", "color", null];
260
+ const seq = [...sequences.values()].sort((a, b) => order.indexOf(a.stage) - order.indexOf(b.stage));
261
+ for (const s of seq) {
262
+ ops.push(s.stage
263
+ ? { op: "raster", combine: "sequence", stage: s.stage, nodes: s.nodes }
264
+ : { op: s.op, combine: "sequence", nodes: s.nodes });
265
+ }
266
+ return { element: id, ops, page: [...pageWide.values()], inert };
267
+ }
package/lib/parse-html.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
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 kids = Array.from(box.children);
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
- const check = validateNodes([], spec);
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
  };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/raster-ops.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/responsive.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/seo.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/stacker.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/suggest.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/theme.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/transition.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.5.3
2
+ * nodality v1.5.5
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -195,6 +195,14 @@ const BARE_DESIGN_OPS = [
195
195
  * node that works, and `preview` refuses to render an invalid pair, so
196
196
  * over-reporting costs more than under-reporting.
197
197
  */
198
+ /** Element fields the renderer cannot do without, per type. */
199
+ const REQUIRED_FIELDS = {
200
+ video: [["url", "the video's URL"]],
201
+ audio: [["url", "the audio file's URL"]],
202
+ multiswitcher: [["breakpoints", "a non-empty array of { at, view }"]],
203
+ simple: [["react", "a non-empty array of { at, template }"]],
204
+ };
205
+
198
206
  export const DESIGN_OP_NAMES = [
199
207
  "animation", "arrange", "background", "blast", "card-style", "filter", "gradient",
200
208
  "layout", "link-style", "margin", "navStyle", "shadow", "slayout",
@@ -498,6 +506,18 @@ export function validateNodes(nodes, elements, defs) {
498
506
  push("UNKNOWN_ELEMENT_TYPE", `${p}.type`, el.type,
499
507
  suggest(el.type, ELEMENT_TYPES), ELEMENT_TYPES);
500
508
  }
509
+ // Fields without which the renderer refuses the element.
510
+ // Validating clean and then throwing at render time is the
511
+ // failure the conformance test exists to rule out.
512
+ const need = REQUIRED_FIELDS[el.type];
513
+ if (need) {
514
+ for (const [field, what] of need) {
515
+ const v = el[field];
516
+ if (v == null || v === "" || (Array.isArray(v) && !v.length)) {
517
+ push("MISSING_FIELD", `${p}.${field}`, v, [], [what]);
518
+ }
519
+ }
520
+ }
501
521
  // Content declared in the slot this type does not read.
502
522
  // `{type:"table", children:[...]}` validated clean and then
503
523
  // rendered its placeholders — the exact silent no-op Stage 1