nodality 1.4.3 → 1.5.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.
Files changed (306) hide show
  1. package/README.md +34 -5
  2. package/bin/dev-server.mjs +200 -0
  3. package/bin/install-skill.mjs +77 -20
  4. package/bin/mcp-server.mjs +98 -0
  5. package/bin/nodality.mjs +29 -4
  6. package/dist/animator.cjs.js +1 -1
  7. package/dist/animator.cjs.js.LICENSE.txt +1 -1
  8. package/dist/animator.esm.js +1 -1
  9. package/dist/animator.esm.js.LICENSE.txt +1 -1
  10. package/dist/audionew.cjs.js +1 -1
  11. package/dist/audionew.cjs.js.LICENSE.txt +1 -1
  12. package/dist/audionew.esm.js +1 -1
  13. package/dist/audionew.esm.js.LICENSE.txt +1 -1
  14. package/dist/base.cjs.js +1 -1
  15. package/dist/base.cjs.js.LICENSE.txt +1 -1
  16. package/dist/base.esm.js +1 -1
  17. package/dist/base.esm.js.LICENSE.txt +1 -1
  18. package/dist/beta-desktop-bar.cjs.js +1 -1
  19. package/dist/beta-desktop-bar.cjs.js.LICENSE.txt +1 -1
  20. package/dist/beta-desktop-bar.esm.js +1 -1
  21. package/dist/beta-desktop-bar.esm.js.LICENSE.txt +1 -1
  22. package/dist/beta-mobile-bar.cjs.js +1 -1
  23. package/dist/beta-mobile-bar.cjs.js.LICENSE.txt +1 -1
  24. package/dist/beta-mobile-bar.esm.js +1 -1
  25. package/dist/beta-mobile-bar.esm.js.LICENSE.txt +1 -1
  26. package/dist/bundle.umd.js +1 -1
  27. package/dist/bundle.umd.js.LICENSE.txt +28 -62
  28. package/dist/button.cjs.js +1 -1
  29. package/dist/button.cjs.js.LICENSE.txt +1 -1
  30. package/dist/button.esm.js +1 -1
  31. package/dist/button.esm.js.LICENSE.txt +1 -1
  32. package/dist/card-getter.cjs.js.LICENSE.txt +1 -1
  33. package/dist/card-getter.esm.js.LICENSE.txt +1 -1
  34. package/dist/center.cjs.js +1 -1
  35. package/dist/center.cjs.js.LICENSE.txt +1 -1
  36. package/dist/center.esm.js +1 -1
  37. package/dist/center.esm.js.LICENSE.txt +1 -1
  38. package/dist/checkbox.cjs.js +1 -1
  39. package/dist/checkbox.cjs.js.LICENSE.txt +1 -1
  40. package/dist/checkbox.esm.js +1 -1
  41. package/dist/checkbox.esm.js.LICENSE.txt +1 -1
  42. package/dist/code.cjs.js +1 -1
  43. package/dist/code.cjs.js.LICENSE.txt +1 -1
  44. package/dist/code.esm.js +1 -1
  45. package/dist/code.esm.js.LICENSE.txt +1 -1
  46. package/dist/container.cjs.js +1 -1
  47. package/dist/container.cjs.js.LICENSE.txt +1 -1
  48. package/dist/container.esm.js +1 -1
  49. package/dist/container.esm.js.LICENSE.txt +1 -1
  50. package/dist/data-list.cjs.js.LICENSE.txt +1 -1
  51. package/dist/data-list.esm.js.LICENSE.txt +1 -1
  52. package/dist/designer.cjs.js +1 -1
  53. package/dist/designer.cjs.js.LICENSE.txt +28 -26
  54. package/dist/designer.esm.js +1 -1
  55. package/dist/designer.esm.js.LICENSE.txt +28 -26
  56. package/dist/element-mapper.cjs.js +1 -1
  57. package/dist/element-mapper.cjs.js.LICENSE.txt +1 -1
  58. package/dist/element-mapper.esm.js +1 -1
  59. package/dist/element-mapper.esm.js.LICENSE.txt +1 -1
  60. package/dist/finalresult.esm.js +1 -2
  61. package/dist/finalresult.esm.js.LICENSE.txt +28 -26
  62. package/dist/flex-card.cjs.js +1 -1
  63. package/dist/flex-card.cjs.js.LICENSE.txt +1 -1
  64. package/dist/flex-card.esm.js +1 -1
  65. package/dist/flex-card.esm.js.LICENSE.txt +1 -1
  66. package/dist/flex-grid.cjs.js +1 -1
  67. package/dist/flex-grid.cjs.js.LICENSE.txt +1 -1
  68. package/dist/flex-grid.esm.js +1 -1
  69. package/dist/flex-grid.esm.js.LICENSE.txt +1 -1
  70. package/dist/flex-row.cjs.js +1 -1
  71. package/dist/flex-row.cjs.js.LICENSE.txt +1 -1
  72. package/dist/flex-row.esm.js +1 -1
  73. package/dist/flex-row.esm.js.LICENSE.txt +1 -1
  74. package/dist/floating-input.cjs.js +1 -1
  75. package/dist/floating-input.cjs.js.LICENSE.txt +1 -1
  76. package/dist/floating-input.esm.js +1 -1
  77. package/dist/floating-input.esm.js.LICENSE.txt +1 -1
  78. package/dist/free.cjs.js +1 -1
  79. package/dist/free.cjs.js.LICENSE.txt +1 -1
  80. package/dist/free.esm.js +1 -1
  81. package/dist/free.esm.js.LICENSE.txt +1 -1
  82. package/dist/horizontal-scroller.cjs.js.LICENSE.txt +1 -1
  83. package/dist/horizontal-scroller.esm.js.LICENSE.txt +1 -1
  84. package/dist/image-picker.cjs.js +1 -1
  85. package/dist/image-picker.cjs.js.LICENSE.txt +1 -1
  86. package/dist/image-picker.esm.js +1 -1
  87. package/dist/image-picker.esm.js.LICENSE.txt +1 -1
  88. package/dist/image.cjs.js +1 -1
  89. package/dist/image.cjs.js.LICENSE.txt +1 -1
  90. package/dist/image.esm.js +1 -1
  91. package/dist/image.esm.js.LICENSE.txt +1 -1
  92. package/dist/index.cjs.js +1 -1
  93. package/dist/index.cjs.js.LICENSE.txt +28 -26
  94. package/dist/index.d.ts +3 -2
  95. package/dist/index.esm.js +1 -2
  96. package/dist/index.esm.js.LICENSE.txt +28 -26
  97. package/dist/keyframe-animation.cjs.js.LICENSE.txt +1 -1
  98. package/dist/keyframe-animation.esm.js.LICENSE.txt +1 -1
  99. package/dist/link-getter.cjs.js +1 -1
  100. package/dist/link-getter.cjs.js.LICENSE.txt +1 -1
  101. package/dist/link-getter.esm.js +1 -1
  102. package/dist/link-getter.esm.js.LICENSE.txt +1 -1
  103. package/dist/link.cjs.js +1 -1
  104. package/dist/link.cjs.js.LICENSE.txt +1 -1
  105. package/dist/link.esm.js +1 -1
  106. package/dist/link.esm.js.LICENSE.txt +1 -1
  107. package/dist/meta-adder.cjs.js +1 -1
  108. package/dist/meta-adder.cjs.js.LICENSE.txt +1 -1
  109. package/dist/meta-adder.esm.js +1 -1
  110. package/dist/meta-adder.esm.js.LICENSE.txt +1 -1
  111. package/dist/modal-2025.cjs.js +1 -1
  112. package/dist/modal-2025.cjs.js.LICENSE.txt +1 -1
  113. package/dist/modal-2025.esm.js +1 -1
  114. package/dist/modal-2025.esm.js.LICENSE.txt +1 -1
  115. package/dist/multiswitcher.cjs.js +1 -1
  116. package/dist/multiswitcher.cjs.js.LICENSE.txt +1 -1
  117. package/dist/multiswitcher.esm.js +1 -1
  118. package/dist/multiswitcher.esm.js.LICENSE.txt +1 -1
  119. package/dist/new-nav-bar.cjs.js +1 -1
  120. package/dist/new-nav-bar.cjs.js.LICENSE.txt +1 -1
  121. package/dist/new-nav-bar.esm.js +1 -1
  122. package/dist/new-nav-bar.esm.js.LICENSE.txt +1 -1
  123. package/dist/picker.cjs.js +1 -1
  124. package/dist/picker.cjs.js.LICENSE.txt +1 -1
  125. package/dist/picker.esm.js +1 -1
  126. package/dist/picker.esm.js.LICENSE.txt +1 -1
  127. package/dist/progress.cjs.js +1 -1
  128. package/dist/progress.cjs.js.LICENSE.txt +1 -1
  129. package/dist/progress.esm.js +1 -1
  130. package/dist/progress.esm.js.LICENSE.txt +1 -1
  131. package/dist/radio.cjs.js.LICENSE.txt +1 -1
  132. package/dist/radio.esm.js.LICENSE.txt +1 -1
  133. package/dist/range.cjs.js.LICENSE.txt +1 -1
  134. package/dist/range.esm.js.LICENSE.txt +1 -1
  135. package/dist/scroll-video.cjs.js.LICENSE.txt +1 -1
  136. package/dist/scroll-video.esm.js.LICENSE.txt +1 -1
  137. package/dist/side-bar.cjs.js +1 -1
  138. package/dist/side-bar.cjs.js.LICENSE.txt +1 -1
  139. package/dist/side-bar.esm.js +1 -1
  140. package/dist/side-bar.esm.js.LICENSE.txt +1 -1
  141. package/dist/side-nav-bar.cjs.js +1 -1
  142. package/dist/side-nav-bar.cjs.js.LICENSE.txt +1 -1
  143. package/dist/side-nav-bar.esm.js +1 -1
  144. package/dist/side-nav-bar.esm.js.LICENSE.txt +1 -1
  145. package/dist/simple-bar.cjs.js +1 -1
  146. package/dist/simple-bar.cjs.js.LICENSE.txt +1 -1
  147. package/dist/simple-bar.esm.js +1 -1
  148. package/dist/simple-bar.esm.js.LICENSE.txt +1 -1
  149. package/dist/slider-2025.cjs.js +1 -1
  150. package/dist/slider-2025.cjs.js.LICENSE.txt +1 -1
  151. package/dist/slider-2025.esm.js +1 -1
  152. package/dist/slider-2025.esm.js.LICENSE.txt +1 -1
  153. package/dist/spacer.cjs.js +1 -1
  154. package/dist/spacer.cjs.js.LICENSE.txt +1 -1
  155. package/dist/spacer.esm.js +1 -1
  156. package/dist/spacer.esm.js.LICENSE.txt +1 -1
  157. package/dist/stack.cjs.js +1 -1
  158. package/dist/stack.cjs.js.LICENSE.txt +1 -1
  159. package/dist/stack.esm.js +1 -1
  160. package/dist/stack.esm.js.LICENSE.txt +1 -1
  161. package/dist/stacker.cjs.js.LICENSE.txt +1 -1
  162. package/dist/stacker.esm.js.LICENSE.txt +1 -1
  163. package/dist/table.cjs.js +1 -1
  164. package/dist/table.cjs.js.LICENSE.txt +1 -1
  165. package/dist/table.esm.js +1 -1
  166. package/dist/table.esm.js.LICENSE.txt +1 -1
  167. package/dist/text-field.cjs.js +1 -1
  168. package/dist/text-field.cjs.js.LICENSE.txt +1 -1
  169. package/dist/text-field.esm.js +1 -1
  170. package/dist/text-field.esm.js.LICENSE.txt +1 -1
  171. package/dist/text.cjs.js +1 -1
  172. package/dist/text.cjs.js.LICENSE.txt +1 -1
  173. package/dist/text.esm.js +1 -1
  174. package/dist/text.esm.js.LICENSE.txt +1 -1
  175. package/dist/theme.cjs.js.LICENSE.txt +1 -1
  176. package/dist/theme.esm.js.LICENSE.txt +1 -1
  177. package/dist/transform-anim.cjs.js.LICENSE.txt +1 -1
  178. package/dist/transform-anim.esm.js.LICENSE.txt +1 -1
  179. package/dist/ulist.cjs.js +1 -1
  180. package/dist/ulist.cjs.js.LICENSE.txt +1 -1
  181. package/dist/ulist.esm.js +1 -1
  182. package/dist/ulist.esm.js.LICENSE.txt +1 -1
  183. package/dist/video.cjs.js +1 -1
  184. package/dist/video.cjs.js.LICENSE.txt +1 -1
  185. package/dist/video.esm.js +1 -1
  186. package/dist/video.esm.js.LICENSE.txt +1 -1
  187. package/dist/wrap.cjs.js +1 -1
  188. package/dist/wrap.cjs.js.LICENSE.txt +1 -1
  189. package/dist/wrap.esm.js +1 -1
  190. package/dist/wrap.esm.js.LICENSE.txt +1 -1
  191. package/dist/zoom-card.cjs.js +1 -1
  192. package/dist/zoom-card.cjs.js.LICENSE.txt +1 -1
  193. package/dist/zoom-card.esm.js +1 -1
  194. package/dist/zoom-card.esm.js.LICENSE.txt +1 -1
  195. package/layout/animator.js +49 -6
  196. package/layout/audio.js +1 -1
  197. package/layout/audionew.js +1 -1
  198. package/layout/base.js +1 -1
  199. package/layout/beta-desktop-bar.js +1 -1
  200. package/layout/beta-mobile-bar.js +1 -1
  201. package/layout/button.js +3 -3
  202. package/layout/center.js +1 -1
  203. package/layout/checkbox.js +1 -1
  204. package/layout/circle.js +1 -1
  205. package/layout/code.js +1 -1
  206. package/layout/container.js +4 -4
  207. package/layout/dropdown-2025.js +6 -5
  208. package/layout/flex-card.js +1 -1
  209. package/layout/flex-grid.js +3 -3
  210. package/layout/flex-row.js +3 -3
  211. package/layout/form-components/custom.js +1 -1
  212. package/layout/form-components/data-list.js +1 -1
  213. package/layout/form-components/floating-input.js +1 -1
  214. package/layout/form-components/form-all.js +1 -1
  215. package/layout/form-components/form.js +1 -1
  216. package/layout/form-components/image-picker.js +2 -2
  217. package/layout/form-components/picker.js +2 -2
  218. package/layout/form-components/radio.js +1 -1
  219. package/layout/form-components/radiogroup.js +1 -1
  220. package/layout/form-components/range.js +1 -1
  221. package/layout/free.js +1 -1
  222. package/layout/grid-overlay.js +1 -1
  223. package/layout/grid-switcher.js +3 -3
  224. package/layout/grid.js +2 -2
  225. package/layout/horizontal-scroller.js +1 -1
  226. package/layout/image.js +6 -3
  227. package/layout/index.js +1 -1
  228. package/layout/link.js +3 -3
  229. package/layout/list.js +1 -1
  230. package/layout/meta-adder.js +1 -1
  231. package/layout/modal-2025.js +1 -1
  232. package/layout/morph.js +1 -1
  233. package/layout/multiswitcher.js +12 -7
  234. package/layout/nav-bar.js +2 -2
  235. package/layout/nav-factor/custom-div.js +1 -1
  236. package/layout/new-nav-bar.js +2 -2
  237. package/layout/polygon.js +1 -1
  238. package/layout/prerender-site.js +1 -1
  239. package/layout/prerender.js +1 -1
  240. package/layout/progress.js +2 -2
  241. package/layout/row.js +3 -3
  242. package/layout/scroll-video.js +1 -1
  243. package/layout/shop.js +1 -1
  244. package/layout/side-bar.js +1 -1
  245. package/layout/side-nav-bar.js +1 -1
  246. package/layout/simple-bar.js +1 -1
  247. package/layout/slider-2025.js +1 -1
  248. package/layout/spacer.js +1 -1
  249. package/layout/stack.js +1 -1
  250. package/layout/svg.js +1 -1
  251. package/layout/switcher.js +2 -2
  252. package/layout/table.js +1 -1
  253. package/layout/text-field.js +2 -2
  254. package/layout/text.js +8 -8
  255. package/layout/ulist.js +1 -1
  256. package/layout/video.js +1 -1
  257. package/layout/wrap.js +1 -1
  258. package/layout/zoom-card.js +1 -1
  259. package/lib/agent-surface.js +1 -1
  260. package/lib/card-getter.js +1 -1
  261. package/lib/check-page.js +6 -2
  262. package/lib/codegen.js +1 -1
  263. package/lib/data.js +1 -1
  264. package/lib/designer.js +114 -8
  265. package/lib/dev-inspector.js +295 -0
  266. package/lib/dev-state.js +257 -0
  267. package/lib/element-mapper.js +186 -13
  268. package/lib/element-params.generated.js +4 -4
  269. package/lib/grid-geometry.js +1 -1
  270. package/lib/keyframe-animation.js +1 -1
  271. package/lib/known-inert.js +1 -1
  272. package/lib/link-getter.js +1 -1
  273. package/lib/morph-node.js +1 -1
  274. package/lib/normalize-spec.js +1 -1
  275. package/lib/parse-html.js +1 -1
  276. package/lib/raster-inspect.js +1 -1
  277. package/lib/raster-ops.js +9 -1
  278. package/lib/raster-presets.js +1 -1
  279. package/lib/react.js +1 -1
  280. package/lib/resolve-refs.js +1 -1
  281. package/lib/responsive.js +1 -1
  282. package/lib/scroll-video.js +1 -1
  283. package/lib/seo.js +1 -1
  284. package/lib/stacker.js +1 -1
  285. package/lib/suggest.js +1 -1
  286. package/lib/theme.js +1 -1
  287. package/lib/transform-anim.js +1 -1
  288. package/lib/transition.js +1 -1
  289. package/lib/validate-nodes.js +1 -1
  290. package/lib/view-transition.js +1 -1
  291. package/lib/webmcp-adapter.js +1 -1
  292. package/package.json +1 -1
  293. package/schema.json +1720 -4197
  294. package/scripts/generate-schema.mjs +9 -2
  295. package/skills/nodality/SKILL.md +22 -238
  296. package/skills/nodality/references/content-and-composites.md +66 -0
  297. package/skills/nodality/references/editing.md +38 -0
  298. package/skills/nodality/references/imperative.md +27 -0
  299. package/skills/nodality/references/multi-page.md +40 -0
  300. package/skills/nodality/references/node-families.md +58 -0
  301. package/skills/nodality/references/prerender.md +13 -0
  302. package/skills/nodality/references/verifying.md +27 -0
  303. package/skills/nodality-apply-comments/SKILL.md +52 -0
  304. package/skills/nodality-current/SKILL.md +69 -0
  305. package/skills/nodality-edit-page/SKILL.md +42 -0
  306. package/skills/nodality-new-page/SKILL.md +55 -0
package/lib/designer.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.4.3
2
+ * nodality v1.5.0
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -94,6 +94,13 @@ class Des {
94
94
  this.options = [];
95
95
  this.code = [];
96
96
  this.ready2Render = [];
97
+ // Per element, in order: the instance the mapper built (when it
98
+ // returned one) and the code string(s) it emitted. The render core
99
+ // mounts the instance; code is run only where there is none.
100
+ this._built = [];
101
+ // Every component built for this page (see Animator._owner), so
102
+ // destroy() can release them all, nested ones included.
103
+ this._owned = [];
97
104
  this.stor = {
98
105
  text:
99
106
  {
@@ -442,6 +449,47 @@ new Text("row.").set({
442
449
  }
443
450
 
444
451
  add(arr) {
452
+ // Under `nodality dev`, components the mapper builds here are
453
+ // addressed by id, not by the source line of this call.
454
+ const devFlag = typeof globalThis !== "undefined" && globalThis.__NODALITY_DEV__ && typeof globalThis.__NODALITY_DEV__ === "object"
455
+ ? globalThis.__NODALITY_DEV__ : null;
456
+ if (devFlag) devFlag.inDes = true;
457
+ const prevOwner = Animator._owner;
458
+ Animator._owner = this._owned;
459
+ try {
460
+ return this._add(arr);
461
+ } finally {
462
+ Animator._owner = prevOwner;
463
+ if (devFlag) devFlag.inDes = false;
464
+ }
465
+ }
466
+
467
+ /**
468
+ * Release everything this page attached: every component built for it
469
+ * (Theme subscriptions, tracked listeners, raster pipelines and their
470
+ * WebGL contexts, its node), the morph controllers, the agent surface,
471
+ * the code panel and the dev registration. Call it before rendering the
472
+ * same mount again. Safe to call twice.
473
+ */
474
+ destroy() {
475
+ for (const c of this._owned.splice(0).reverse()) {
476
+ try { if (c && typeof c.destroy === "function") c.destroy(); } catch (e) { /* keep releasing the rest */ }
477
+ }
478
+ for (const m of [].concat(this._morphs || [])) {
479
+ try { if (m && typeof m.destroy === "function") m.destroy(); } catch (e) { /* already gone */ }
480
+ }
481
+ this._morphs = null;
482
+ try { if (this._agentSurface && typeof this._agentSurface.destroy === "function") this._agentSurface.destroy(); } catch (e) { /* already gone */ }
483
+ this._agentSurface = null;
484
+ for (const n of [this._codeEl, this._preEl]) if (n && n.parentNode) n.parentNode.removeChild(n);
485
+ const dev = typeof globalThis !== "undefined" && globalThis.__NODALITY_DEV__;
486
+ if (dev && Array.isArray(dev.pages)) dev.pages = dev.pages.filter((p) => !this._devEntry || p !== this._devEntry);
487
+ this._built = [];
488
+ this.ready2Render = [];
489
+ return this;
490
+ }
491
+
492
+ _add(arr) {
445
493
 
446
494
  // Kept for phase T: a morph node resolves `from`/`to` ids against
447
495
  // the rendered children BY POSITION, so it needs the descriptor
@@ -527,6 +575,8 @@ customOptions.forEach(item => {
527
575
  for (var i = 0; i < arr.length; i++) {
528
576
  let el = arr[i];
529
577
  let ela = null;
578
+ const built0 = this.ready2Render.length;
579
+ const code0 = this.code.length;
530
580
 
531
581
  let ops = ["blast", "gradient", "shadow", "filter", "animation", "transform", "span"];
532
582
  let replacementObjects = [
@@ -1248,7 +1298,14 @@ new Slider(texts, null, { tintColor: "#e74c3c", inactiveColor: "#ccc" })
1248
1298
  storage: this.stor
1249
1299
  });
1250
1300
 
1251
- this.code.push(ela);
1301
+ // An instance carrying its source since the render core: the
1302
+ // source goes to the code panel, the instance is mounted.
1303
+ if (ela && typeof ela === "object" && typeof ela.toCode === "function") {
1304
+ this.code.push([].concat(ela.toCode()).join(""));
1305
+ this.ready2Render.push(ela);
1306
+ } else {
1307
+ this.code.push(ela);
1308
+ }
1252
1309
  } else if (el.type === "wrap") { // add blast and background here
1253
1310
  /*
1254
1311
  const ft = customOptions.filter(l => l.op === "gradient")[0];
@@ -1351,8 +1408,18 @@ new Slider(texts, null, { tintColor: "#e74c3c", inactiveColor: "#ccc" })
1351
1408
  }
1352
1409
  //.join("") is important :)
1353
1410
  this.ready2Render.push(ela);
1354
- ela = eval(ela).render();
1411
+ // Every mapper returns an instance; nothing here is evaluated.
1412
+ ela = ela.render();
1355
1413
  } // 20:20:26
1414
+ {
1415
+ const last = this.ready2Render.length > built0 ? this.ready2Render[this.ready2Render.length - 1] : null;
1416
+ // table and row: the mapper returns an instance, but these
1417
+ // branches never listed it in ready2Render.
1418
+ const unlisted = !last && ela && typeof ela === "object" && typeof ela.render === "function"
1419
+ && typeof ela.toCode === "function" && ["table", "row"].includes(el.type) ? ela : null;
1420
+ const instance = last && typeof last === "object" && typeof last.render === "function" ? last : unlisted;
1421
+ this._built.push({ instance, codeCount: this.code.length - code0 });
1422
+ }
1356
1423
  } // LARGE FOR I = 0 CYCLE END
1357
1424
 
1358
1425
  return this;
@@ -1479,10 +1546,29 @@ const components = {
1479
1546
  ...libs,
1480
1547
  };
1481
1548
 
1482
- for (var i = 0; i < this.code.length; i++) {
1483
- let sub = this.code[i];
1484
- new Function(...Object.keys(components), sub)(...Object.values(components));
1485
- // eval(`${sub}`);
1549
+ // Under `nodality dev`, components built from the pair are addressed
1550
+ // by id; the flag stops them recording this line as their source.
1551
+ const devFlag = typeof globalThis !== "undefined" && globalThis.__NODALITY_DEV__ && typeof globalThis.__NODALITY_DEV__ === "object"
1552
+ ? globalThis.__NODALITY_DEV__ : null;
1553
+ if (devFlag) devFlag.inDes = true;
1554
+ // Only the legacy demo types (slider, hslider, grid, modal,
1555
+ // responsive — not in the vocabulary, rejected by the validator) still
1556
+ // emit source with no instance. Their source is fixed text with no
1557
+ // page data in it; nothing from E or N is ever executed.
1558
+ const runCode = (sub) => new Function(...Object.keys(components), sub)(...Object.values(components));
1559
+ const prevOwner = Animator._owner;
1560
+ Animator._owner = this._owned;
1561
+ try {
1562
+ // Render core: mount the component the mapper built in add().
1563
+ const target = (obj && obj.mount) || "#mount";
1564
+ let c = 0;
1565
+ for (const b of this._built) {
1566
+ if (b.instance) { b.instance.render(target); c += b.codeCount; }
1567
+ else for (let k = 0; k < b.codeCount; k++, c++) runCode(this.code[c]);
1568
+ }
1569
+ } finally {
1570
+ Animator._owner = prevOwner;
1571
+ if (devFlag) devFlag.inDes = false;
1486
1572
  }
1487
1573
 
1488
1574
  // Morph nodes run LAST, and they run here rather than in the
@@ -1525,8 +1611,12 @@ const components = {
1525
1611
  // Opt-in, and it must stay that way. This writes attributes into the
1526
1612
  // output, and every page that exists renders byte for byte as it
1527
1613
  // always did precisely because nobody asked for them.
1614
+ // `nodality dev` defines __NODALITY_DEV__ before any page script runs;
1615
+ // nothing else does, so a built or deployed page never enters here.
1616
+ const dev = typeof globalThis !== "undefined" && globalThis.__NODALITY_DEV__
1617
+ && Array.isArray(globalThis.__NODALITY_DEV__.pages) ? globalThis.__NODALITY_DEV__ : null;
1528
1618
  try {
1529
- if (obj && obj.annotate) {
1619
+ if ((obj && obj.annotate) || (dev && dev.annotate)) {
1530
1620
  annotateRoundTrip(
1531
1621
  document.querySelector((obj && obj.mount) || "#mount"),
1532
1622
  this._elements);
@@ -1534,6 +1624,22 @@ const components = {
1534
1624
  } catch (e) {
1535
1625
  console.warn("[nodality] round-trip annotation skipped:", e);
1536
1626
  }
1627
+
1628
+ // The dev inspector needs the pair itself, not just the DOM: which
1629
+ // nodes target the picked element, and which width ranges are in
1630
+ // force for it, are facts of N that the rendered page does not show.
1631
+ if (dev) {
1632
+ try {
1633
+ const entry = { mount: (obj && obj.mount) || "#mount", elements: this._elements, nodes: this.protoOptions };
1634
+ this._devEntry = entry;
1635
+ dev.pages.push(entry);
1636
+ if (typeof window !== "undefined" && typeof window.dispatchEvent === "function" && typeof CustomEvent === "function") {
1637
+ window.dispatchEvent(new CustomEvent("nodality:rendered", { detail: entry }));
1638
+ }
1639
+ } catch (e) {
1640
+ console.warn("[nodality] dev registration skipped:", e);
1641
+ }
1642
+ }
1537
1643
  }
1538
1644
  }
1539
1645
 
@@ -0,0 +1,295 @@
1
+ /*!
2
+ * nodality v1.5.0
3
+ * (c) 2026 Filip Vabrousek
4
+ * License: MIT
5
+ */
6
+
7
+ /*!
8
+ * dev-inspector.js — the in-page half of `nodality dev`.
9
+ *
10
+ * Served by the dev server only; never imported, never bundled, never in a
11
+ * built page. It lets a person point at what they mean and leaves the
12
+ * meaning in two files an agent reads (see lib/dev-state.js):
13
+ *
14
+ * S select: click an element → .nodality/current.json
15
+ * C comment: click an element, or drag across several, and type a
16
+ * note → .nodality/comments.json
17
+ * Esc off: the page behaves as a page again (the starting state)
18
+ *
19
+ * It finds elements by their `id`, which every Nodality element renders, and
20
+ * reads the (E, N) pair the Designer registers in __NODALITY_DEV__.pages to
21
+ * report which nodes target the pick and which width ranges are in force.
22
+ * Everything it draws lives in one shadow root, so page styles cannot reach
23
+ * it and it never edits the page's own nodes.
24
+ */
25
+ (function () {
26
+ if (typeof window === "undefined" || window.__NODALITY_INSPECTOR__) return;
27
+ window.__NODALITY_INSPECTOR__ = true;
28
+ const DEV = (window.__NODALITY_DEV__ = window.__NODALITY_DEV__ || { pages: [], annotate: true });
29
+ const API = "/__nodality";
30
+ const PAGE = location.pathname;
31
+
32
+ // ── the pair: id → spec, node indexes, ranges ──────────────────────
33
+ let index = new Map();
34
+ const bare = (s) => (typeof s === "string" ? s.replace(/^#/, "") : null);
35
+ function names(v, out) {
36
+ if (typeof v === "string") out.push(bare(v));
37
+ else if (Array.isArray(v)) v.forEach((x) => names(x, out));
38
+ else if (v && typeof v === "object") Object.values(v).forEach((x) => names(x, out));
39
+ return out;
40
+ }
41
+ function walk(list, visit) {
42
+ for (const el of Array.isArray(list) ? list : []) {
43
+ if (Array.isArray(el)) { walk(el, visit); continue; }
44
+ if (!el || typeof el !== "object") continue;
45
+ if (typeof el.id === "string") visit(el);
46
+ walk(el.children, visit);
47
+ if (Array.isArray(el.items)) walk(el.items, visit);
48
+ }
49
+ }
50
+ function rebuild() {
51
+ index = new Map();
52
+ for (const pg of DEV.pages) {
53
+ walk(pg.elements, (el) => { if (!index.has(el.id)) index.set(el.id, { spec: el, nodes: [], ranges: [] }); });
54
+ (pg.nodes || []).forEach((n, i) => {
55
+ if (!n || typeof n !== "object") return;
56
+ const hit = names([n.target, n.from, n.to], []);
57
+ if (Array.isArray(n.chain)) n.chain.forEach((e) => names([e && e.from, e && e.to], hit));
58
+ for (const id of new Set(hit)) {
59
+ const rec = index.get(id);
60
+ if (!rec) continue;
61
+ rec.nodes.push(i);
62
+ if (Array.isArray(n.range)) rec.ranges.push({ node: i, range: n.range });
63
+ }
64
+ });
65
+ }
66
+ }
67
+ window.addEventListener("nodality:rendered", () => { rebuild(); drawPins(); });
68
+
69
+ // ── shadow UI ──────────────────────────────────────────────────────
70
+ const host = document.createElement("div");
71
+ host.setAttribute("data-nodality", "dev-inspector");
72
+ host.style.cssText = "position:fixed;inset:0;pointer-events:none;z-index:2147483647";
73
+ const root = host.attachShadow({ mode: "open" });
74
+ root.innerHTML = `<style>
75
+ :host{all:initial}
76
+ *{box-sizing:border-box;font:12px/1.4 -apple-system,system-ui,sans-serif}
77
+ .box{position:fixed;border:1.5px solid #378ADD;border-radius:3px;display:none;pointer-events:none}
78
+ .box.sel{border:2px solid #185FA5;background:rgba(55,138,221,.08)}
79
+ .lab{position:absolute;top:-20px;left:-2px;background:#185FA5;color:#fff;padding:1px 6px;border-radius:3px;white-space:nowrap;font:11px ui-monospace,Menlo,monospace}
80
+ .drag{position:fixed;border:1.5px dashed #BA7517;background:rgba(239,159,39,.08);display:none}
81
+ .pin{position:fixed;width:18px;height:18px;border-radius:50%;background:#FAC775;color:#633806;border:1px solid #BA7517;display:flex;align-items:center;justify-content:center;font-size:11px;pointer-events:auto;cursor:default}
82
+ .bar{position:fixed;right:12px;bottom:12px;background:#fff;color:#2C2C2A;border:1px solid #D3D1C7;border-radius:10px;padding:6px;display:flex;flex-direction:column;gap:6px;pointer-events:auto;min-width:220px}
83
+ .row{display:flex;gap:6px;align-items:center}
84
+ button{border:1px solid #D3D1C7;background:#fff;color:#2C2C2A;border-radius:6px;padding:3px 8px;cursor:pointer}
85
+ button.on{background:#E6F1FB;color:#0C447C;border-color:#378ADD}
86
+ .st{color:#5F5E5A;margin-left:auto;font-size:11px}
87
+ input{flex:1;border:1px solid #B4B2A9;border-radius:6px;padding:4px 6px;min-width:0}
88
+ .err{color:#A32D2D;font-size:11px}
89
+ .note{display:none}
90
+ </style>
91
+ <div class="box" id="hover"><span class="lab"></span></div>
92
+ <div class="box sel" id="sel"><span class="lab"></span></div>
93
+ <div class="drag" id="drag"></div>
94
+ <div id="pins"></div>
95
+ <div class="bar">
96
+ <div class="row"><button id="bS">Select (S)</button><button id="bC">Comment (C)</button><span class="st" id="st"></span></div>
97
+ <div class="row note" id="noteRow"><input id="note" maxlength="2000" placeholder="what should change here?"><button id="add">Add</button></div>
98
+ <div class="err" id="err"></div>
99
+ </div>`;
100
+ const $ = (id) => root.getElementById(id);
101
+ const mount = () => { if (!host.isConnected) document.body.appendChild(host); };
102
+ if (document.body) mount(); else document.addEventListener("DOMContentLoaded", mount);
103
+
104
+ let mode = "off";
105
+ let pending = null; // { target: [ids], rect } awaiting a note
106
+ function setMode(m) {
107
+ mode = mode === m ? "off" : m;
108
+ $("bS").classList.toggle("on", mode === "select");
109
+ $("bC").classList.toggle("on", mode === "comment");
110
+ if (mode !== "comment") { pending = null; $("noteRow").style.display = "none"; }
111
+ $("hover").style.display = "none";
112
+ status();
113
+ }
114
+ function status(msg) {
115
+ $("st").textContent = msg || `${mode === "off" ? "off" : mode} · ${innerWidth}px`;
116
+ }
117
+ $("bS").onclick = () => setMode("select");
118
+ $("bC").onclick = () => setMode("comment");
119
+ status();
120
+
121
+ // ── finding what was pointed at ─────────────────────────────────────
122
+ const ours = (e) => e.composedPath && e.composedPath().includes(host);
123
+ // An element is addressable by an id from the pair (or any id, on a page
124
+ // with no pair), or — on a page written with the imperative layer — by the
125
+ // line that created it (data-nod-src, set in dev by the component base).
126
+ const idOk = (n) => n.id && n !== host && (index.size === 0 || index.has(n.id));
127
+ const srcOf = (n) => (n.getAttribute && n.getAttribute("data-nod-src")) || null;
128
+ function known(node) {
129
+ for (let n = node; n && n !== document.documentElement; n = n.parentElement) {
130
+ if (idOk(n) || srcOf(n)) return n;
131
+ }
132
+ return null;
133
+ }
134
+ function label(node) {
135
+ const rec = idOk(node) ? index.get(node.id) : null;
136
+ const kind = (rec && rec.spec.type) || node.tagName.toLowerCase();
137
+ if (idOk(node)) return `#${node.id} · ${kind}`;
138
+ return `${srcOf(node).replace(/:\d+$/, "")} · ${kind}`;
139
+ }
140
+ function place(box, node) {
141
+ const r = node.getBoundingClientRect();
142
+ Object.assign(box.style, { display: "block", left: r.left - 3 + "px", top: r.top - 3 + "px", width: r.width + 6 + "px", height: r.height + 6 + "px" });
143
+ box.querySelector(".lab").textContent = label(node);
144
+ }
145
+ function describe(nodes) {
146
+ const first = nodes[0];
147
+ const rec = (idOk(first) && index.get(first.id)) || { spec: {}, nodes: [], ranges: [] };
148
+ const w = innerWidth;
149
+ return {
150
+ ids: nodes.filter(idOk).map((n) => n.id),
151
+ src: srcOf(first),
152
+ type: rec.spec.type || null,
153
+ tag: first.tagName.toLowerCase(),
154
+ text: (first.textContent || "").replace(/\s+/g, " ").trim().slice(0, 120),
155
+ nodesTargeting: rec.nodes,
156
+ activeRanges: rec.ranges.filter(({ range: [a, b] }) => w >= (a ?? 0) && w <= (b ?? Infinity)),
157
+ };
158
+ }
159
+ const post = (path, body) => fetch(API + path, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) })
160
+ .then((r) => r.json()).catch(() => ({ ok: false }));
161
+ const viewport = () => ({ width: innerWidth, height: innerHeight });
162
+
163
+ // ── select ─────────────────────────────────────────────────────────
164
+ let selected = null;
165
+ function select(node) {
166
+ selected = node;
167
+ place($("sel"), node);
168
+ post("/current", { page: PAGE, viewport: viewport(), selection: describe([node]) })
169
+ .then((r) => status(r.ok ? `picked ${label(node).split(" · ")[0]}` : "could not save the pick"));
170
+ }
171
+
172
+ // ── comment: click one element, or drag across several ─────────────
173
+ let drag = null;
174
+ let skipClick = false; // the click a finished drag also fires
175
+ function askNote(target, rect, src) {
176
+ pending = { target, rect, src: src || null };
177
+ $("noteRow").style.display = "flex";
178
+ $("err").textContent = "";
179
+ $("note").value = "";
180
+ $("note").focus();
181
+ status(`note on ${target.length ? target.map((t) => "#" + t).join(", ") : String(src).replace(/:\d+$/, "")}`);
182
+ }
183
+ function addNote() {
184
+ const note = $("note").value.trim();
185
+ if (!note) { $("err").textContent = "Write a note first."; return; }
186
+ post("/comments", { page: PAGE, viewport: viewport(), target: pending.target, rect: pending.rect, src: pending.src, note })
187
+ .then((r) => {
188
+ if (!r.ok) { $("err").textContent = "The note was not saved."; return; }
189
+ pending = null;
190
+ $("noteRow").style.display = "none";
191
+ status("note saved");
192
+ loadPins();
193
+ });
194
+ }
195
+ $("add").onclick = addNote;
196
+ $("note").addEventListener("keydown", (e) => { if (e.key === "Enter") addNote(); e.stopPropagation(); });
197
+ $("note").addEventListener("input", () => { $("err").textContent = ""; });
198
+
199
+ // ── pins ───────────────────────────────────────────────────────────
200
+ let pins = [];
201
+ function loadPins() {
202
+ fetch(`${API}/comments?page=${encodeURIComponent(PAGE)}`).then((r) => r.json())
203
+ .then((list) => { pins = (Array.isArray(list) ? list : []).filter((c) => c.status === "open"); drawPins(); })
204
+ .catch(() => {});
205
+ }
206
+ function drawPins() {
207
+ const box = $("pins");
208
+ box.textContent = "";
209
+ pins.forEach((c, i) => {
210
+ const node = c.target.length ? document.getElementById(c.target[0])
211
+ : c.source ? [...document.querySelectorAll("[data-nod-src]")].find((n) => srcOf(n).startsWith(`${c.source.file}:${c.source.line}:`)) : null;
212
+ if (!node) return;
213
+ const r = node.getBoundingClientRect();
214
+ const p = document.createElement("div");
215
+ p.className = "pin";
216
+ p.textContent = String(i + 1);
217
+ p.title = c.note;
218
+ p.style.left = r.right - 9 + "px";
219
+ p.style.top = r.top - 9 + "px";
220
+ box.appendChild(p);
221
+ });
222
+ }
223
+ let raf = 0;
224
+ const redraw = () => {
225
+ cancelAnimationFrame(raf);
226
+ raf = requestAnimationFrame(() => { drawPins(); if (selected && selected.isConnected) place($("sel"), selected); status(); });
227
+ };
228
+ addEventListener("scroll", redraw, true);
229
+ addEventListener("resize", redraw);
230
+
231
+ // ── events: capture phase, so the page never sees an inspector click ──
232
+ document.addEventListener("mousemove", (e) => {
233
+ if (mode === "off" || ours(e)) return;
234
+ if (drag) {
235
+ const x = Math.min(drag.x, e.clientX), y = Math.min(drag.y, e.clientY);
236
+ const w = Math.abs(e.clientX - drag.x), h = Math.abs(e.clientY - drag.y);
237
+ if (w + h > 6) { drag.moved = true; Object.assign($("drag").style, { display: "block", left: x + "px", top: y + "px", width: w + "px", height: h + "px" }); }
238
+ return;
239
+ }
240
+ const node = known(e.target);
241
+ if (node) place($("hover"), node); else $("hover").style.display = "none";
242
+ }, true);
243
+ document.addEventListener("mousedown", (e) => {
244
+ if (mode !== "comment" || ours(e)) return;
245
+ e.preventDefault();
246
+ drag = { x: e.clientX, y: e.clientY, moved: false };
247
+ }, true);
248
+ document.addEventListener("mouseup", (e) => {
249
+ if (!drag) return;
250
+ const d = drag; drag = null;
251
+ $("drag").style.display = "none";
252
+ if (!d.moved) return;
253
+ skipClick = true;
254
+ const box = { l: Math.min(d.x, e.clientX), t: Math.min(d.y, e.clientY), r: Math.max(d.x, e.clientX), b: Math.max(d.y, e.clientY) };
255
+ const inside = [...document.querySelectorAll("[id], [data-nod-src]")].filter((n) => {
256
+ if (n === host || !(idOk(n) || srcOf(n))) return false;
257
+ const r = n.getBoundingClientRect();
258
+ return r.width > 0 && r.left >= box.l && r.right <= box.r && r.top >= box.t && r.bottom <= box.b;
259
+ });
260
+ const outer = inside.filter((n) => !inside.some((m) => m !== n && m.contains(n)));
261
+ if (!outer.length) { status("nothing addressable inside that area"); return; }
262
+ askNote(outer.filter(idOk).map((n) => n.id), { x: box.l + scrollX, y: box.t + scrollY, w: box.r - box.l, h: box.b - box.t }, srcOf(outer[0]));
263
+ }, true);
264
+ document.addEventListener("click", (e) => {
265
+ if (mode === "off" || ours(e)) return;
266
+ e.preventDefault();
267
+ e.stopPropagation();
268
+ if (skipClick) { skipClick = false; return; }
269
+ const node = known(e.target);
270
+ if (!node) { status("nothing addressable here: no id, no source line"); return; }
271
+ if (mode === "select") select(node);
272
+ else askNote(idOk(node) ? [node.id] : [], null, srcOf(node));
273
+ }, true);
274
+ document.addEventListener("keydown", (e) => {
275
+ if (ours(e)) return;
276
+ const t = e.target;
277
+ if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;
278
+ if (e.metaKey || e.ctrlKey || e.altKey) return;
279
+ if (e.key === "s" || e.key === "S") setMode("select");
280
+ else if (e.key === "c" || e.key === "C") setMode("comment");
281
+ else if (e.key === "Escape" && mode !== "off") setMode(mode);
282
+ }, true);
283
+
284
+ // ── reload when the site changes; report the page on arrival ───────
285
+ try {
286
+ const es = new EventSource(`${API}/events`);
287
+ es.addEventListener("reload", () => location.reload());
288
+ } catch { /* no live reload; everything else still works */ }
289
+ rebuild();
290
+ addEventListener("load", () => {
291
+ rebuild();
292
+ loadPins();
293
+ post("/current", { page: PAGE, viewport: viewport(), selection: null });
294
+ });
295
+ })();