nodality 1.3.26 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/dist/animator.cjs.js +1 -1
  2. package/dist/animator.cjs.js.LICENSE.txt +1 -1
  3. package/dist/animator.esm.js +1 -1
  4. package/dist/animator.esm.js.LICENSE.txt +1 -1
  5. package/dist/audionew.cjs.js +1 -1
  6. package/dist/audionew.cjs.js.LICENSE.txt +1 -1
  7. package/dist/audionew.esm.js +1 -1
  8. package/dist/audionew.esm.js.LICENSE.txt +1 -1
  9. package/dist/base.cjs.js +1 -1
  10. package/dist/base.cjs.js.LICENSE.txt +1 -1
  11. package/dist/base.esm.js +1 -1
  12. package/dist/base.esm.js.LICENSE.txt +1 -1
  13. package/dist/beta-desktop-bar.cjs.js +1 -1
  14. package/dist/beta-desktop-bar.cjs.js.LICENSE.txt +1 -1
  15. package/dist/beta-desktop-bar.esm.js +1 -1
  16. package/dist/beta-desktop-bar.esm.js.LICENSE.txt +1 -1
  17. package/dist/beta-mobile-bar.cjs.js +1 -1
  18. package/dist/beta-mobile-bar.cjs.js.LICENSE.txt +1 -1
  19. package/dist/beta-mobile-bar.esm.js +1 -1
  20. package/dist/beta-mobile-bar.esm.js.LICENSE.txt +1 -1
  21. package/dist/bundle.umd.js +1 -1
  22. package/dist/bundle.umd.js.LICENSE.txt +20 -1
  23. package/dist/button.cjs.js +1 -1
  24. package/dist/button.cjs.js.LICENSE.txt +1 -1
  25. package/dist/button.esm.js +1 -1
  26. package/dist/button.esm.js.LICENSE.txt +1 -1
  27. package/dist/card-getter.cjs.js.LICENSE.txt +1 -1
  28. package/dist/card-getter.esm.js.LICENSE.txt +1 -1
  29. package/dist/center.cjs.js +1 -1
  30. package/dist/center.cjs.js.LICENSE.txt +1 -1
  31. package/dist/center.esm.js +1 -1
  32. package/dist/center.esm.js.LICENSE.txt +1 -1
  33. package/dist/checkbox.cjs.js +1 -1
  34. package/dist/checkbox.cjs.js.LICENSE.txt +1 -1
  35. package/dist/checkbox.esm.js +1 -1
  36. package/dist/checkbox.esm.js.LICENSE.txt +1 -1
  37. package/dist/code.cjs.js +1 -1
  38. package/dist/code.cjs.js.LICENSE.txt +1 -1
  39. package/dist/code.esm.js +1 -1
  40. package/dist/code.esm.js.LICENSE.txt +1 -1
  41. package/dist/container.cjs.js +1 -1
  42. package/dist/container.cjs.js.LICENSE.txt +1 -1
  43. package/dist/container.esm.js +1 -1
  44. package/dist/container.esm.js.LICENSE.txt +1 -1
  45. package/dist/data-list.cjs.js +1 -1
  46. package/dist/data-list.cjs.js.LICENSE.txt +1 -1
  47. package/dist/data-list.esm.js.LICENSE.txt +1 -1
  48. package/dist/designer.cjs.js +1 -1
  49. package/dist/designer.cjs.js.LICENSE.txt +20 -1
  50. package/dist/designer.esm.js +1 -1
  51. package/dist/designer.esm.js.LICENSE.txt +20 -1
  52. package/dist/element-mapper.cjs.js +1 -1
  53. package/dist/element-mapper.cjs.js.LICENSE.txt +1 -1
  54. package/dist/element-mapper.esm.js +1 -1
  55. package/dist/element-mapper.esm.js.LICENSE.txt +1 -1
  56. package/dist/finalresult.esm.js +1 -1
  57. package/dist/finalresult.esm.js.LICENSE.txt +20 -1
  58. package/dist/flex-card.cjs.js +1 -1
  59. package/dist/flex-card.cjs.js.LICENSE.txt +1 -1
  60. package/dist/flex-card.esm.js +1 -1
  61. package/dist/flex-card.esm.js.LICENSE.txt +1 -1
  62. package/dist/flex-grid.cjs.js +1 -1
  63. package/dist/flex-grid.cjs.js.LICENSE.txt +1 -1
  64. package/dist/flex-grid.esm.js +1 -1
  65. package/dist/flex-grid.esm.js.LICENSE.txt +1 -1
  66. package/dist/flex-row.cjs.js +1 -1
  67. package/dist/flex-row.cjs.js.LICENSE.txt +1 -1
  68. package/dist/flex-row.esm.js +1 -1
  69. package/dist/flex-row.esm.js.LICENSE.txt +1 -1
  70. package/dist/floating-input.cjs.js +1 -1
  71. package/dist/floating-input.cjs.js.LICENSE.txt +1 -1
  72. package/dist/floating-input.esm.js +1 -1
  73. package/dist/floating-input.esm.js.LICENSE.txt +1 -1
  74. package/dist/free.cjs.js +1 -1
  75. package/dist/free.cjs.js.LICENSE.txt +1 -1
  76. package/dist/free.esm.js +1 -1
  77. package/dist/free.esm.js.LICENSE.txt +1 -1
  78. package/dist/horizontal-scroller.cjs.js.LICENSE.txt +1 -1
  79. package/dist/horizontal-scroller.esm.js.LICENSE.txt +1 -1
  80. package/dist/image-picker.cjs.js +1 -1
  81. package/dist/image-picker.cjs.js.LICENSE.txt +1 -1
  82. package/dist/image-picker.esm.js +1 -1
  83. package/dist/image-picker.esm.js.LICENSE.txt +1 -1
  84. package/dist/image.cjs.js +1 -1
  85. package/dist/image.cjs.js.LICENSE.txt +1 -1
  86. package/dist/image.esm.js +1 -1
  87. package/dist/image.esm.js.LICENSE.txt +1 -1
  88. package/dist/index.cjs.js +1 -1
  89. package/dist/index.cjs.js.LICENSE.txt +20 -1
  90. package/dist/index.d.ts +1 -1
  91. package/dist/index.esm.js +1 -1
  92. package/dist/index.esm.js.LICENSE.txt +20 -1
  93. package/dist/keyframe-animation.cjs.js.LICENSE.txt +1 -1
  94. package/dist/keyframe-animation.esm.js.LICENSE.txt +1 -1
  95. package/dist/link-getter.cjs.js +1 -1
  96. package/dist/link-getter.cjs.js.LICENSE.txt +1 -1
  97. package/dist/link-getter.esm.js +1 -1
  98. package/dist/link-getter.esm.js.LICENSE.txt +1 -1
  99. package/dist/link.cjs.js +1 -1
  100. package/dist/link.cjs.js.LICENSE.txt +1 -1
  101. package/dist/link.esm.js +1 -1
  102. package/dist/link.esm.js.LICENSE.txt +1 -1
  103. package/dist/meta-adder.cjs.js +1 -1
  104. package/dist/meta-adder.cjs.js.LICENSE.txt +1 -1
  105. package/dist/meta-adder.esm.js +1 -1
  106. package/dist/meta-adder.esm.js.LICENSE.txt +1 -1
  107. package/dist/modal-2025.cjs.js +1 -1
  108. package/dist/modal-2025.cjs.js.LICENSE.txt +1 -1
  109. package/dist/modal-2025.esm.js +1 -1
  110. package/dist/modal-2025.esm.js.LICENSE.txt +1 -1
  111. package/dist/multiswitcher.cjs.js +1 -1
  112. package/dist/multiswitcher.cjs.js.LICENSE.txt +1 -1
  113. package/dist/multiswitcher.esm.js +1 -1
  114. package/dist/multiswitcher.esm.js.LICENSE.txt +1 -1
  115. package/dist/new-nav-bar.cjs.js +1 -1
  116. package/dist/new-nav-bar.cjs.js.LICENSE.txt +1 -1
  117. package/dist/new-nav-bar.esm.js +1 -1
  118. package/dist/new-nav-bar.esm.js.LICENSE.txt +1 -1
  119. package/dist/picker.cjs.js +1 -1
  120. package/dist/picker.cjs.js.LICENSE.txt +1 -1
  121. package/dist/picker.esm.js +1 -1
  122. package/dist/picker.esm.js.LICENSE.txt +1 -1
  123. package/dist/progress.cjs.js +1 -1
  124. package/dist/progress.cjs.js.LICENSE.txt +1 -1
  125. package/dist/progress.esm.js +1 -1
  126. package/dist/progress.esm.js.LICENSE.txt +1 -1
  127. package/dist/radio.cjs.js +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 +1 -1
  131. package/dist/range.cjs.js.LICENSE.txt +1 -1
  132. package/dist/range.esm.js.LICENSE.txt +1 -1
  133. package/dist/scroll-video.cjs.js.LICENSE.txt +1 -1
  134. package/dist/scroll-video.esm.js.LICENSE.txt +1 -1
  135. package/dist/side-bar.cjs.js +1 -1
  136. package/dist/side-bar.cjs.js.LICENSE.txt +1 -1
  137. package/dist/side-bar.esm.js +1 -1
  138. package/dist/side-bar.esm.js.LICENSE.txt +1 -1
  139. package/dist/side-nav-bar.cjs.js +1 -1
  140. package/dist/side-nav-bar.cjs.js.LICENSE.txt +1 -1
  141. package/dist/side-nav-bar.esm.js +1 -1
  142. package/dist/side-nav-bar.esm.js.LICENSE.txt +1 -1
  143. package/dist/simple-bar.cjs.js +1 -1
  144. package/dist/simple-bar.cjs.js.LICENSE.txt +1 -1
  145. package/dist/simple-bar.esm.js +1 -1
  146. package/dist/simple-bar.esm.js.LICENSE.txt +1 -1
  147. package/dist/slider-2025.cjs.js +1 -1
  148. package/dist/slider-2025.cjs.js.LICENSE.txt +1 -1
  149. package/dist/slider-2025.esm.js +1 -1
  150. package/dist/slider-2025.esm.js.LICENSE.txt +1 -1
  151. package/dist/spacer.cjs.js +1 -1
  152. package/dist/spacer.cjs.js.LICENSE.txt +1 -1
  153. package/dist/spacer.esm.js +1 -1
  154. package/dist/spacer.esm.js.LICENSE.txt +1 -1
  155. package/dist/stack.cjs.js +1 -1
  156. package/dist/stack.cjs.js.LICENSE.txt +1 -1
  157. package/dist/stack.esm.js +1 -1
  158. package/dist/stack.esm.js.LICENSE.txt +1 -1
  159. package/dist/stacker.cjs.js.LICENSE.txt +1 -1
  160. package/dist/stacker.esm.js.LICENSE.txt +1 -1
  161. package/dist/table.cjs.js +1 -1
  162. package/dist/table.cjs.js.LICENSE.txt +1 -1
  163. package/dist/table.esm.js +1 -1
  164. package/dist/table.esm.js.LICENSE.txt +1 -1
  165. package/dist/text-field.cjs.js +1 -1
  166. package/dist/text-field.cjs.js.LICENSE.txt +1 -1
  167. package/dist/text-field.esm.js +1 -1
  168. package/dist/text-field.esm.js.LICENSE.txt +1 -1
  169. package/dist/text.cjs.js +1 -1
  170. package/dist/text.cjs.js.LICENSE.txt +1 -1
  171. package/dist/text.esm.js +1 -1
  172. package/dist/text.esm.js.LICENSE.txt +1 -1
  173. package/dist/theme.cjs.js.LICENSE.txt +1 -1
  174. package/dist/theme.esm.js.LICENSE.txt +1 -1
  175. package/dist/transform-anim.cjs.js.LICENSE.txt +1 -1
  176. package/dist/transform-anim.esm.js.LICENSE.txt +1 -1
  177. package/dist/ulist.cjs.js +1 -1
  178. package/dist/ulist.cjs.js.LICENSE.txt +1 -1
  179. package/dist/ulist.esm.js +1 -1
  180. package/dist/ulist.esm.js.LICENSE.txt +1 -1
  181. package/dist/video.cjs.js +1 -1
  182. package/dist/video.cjs.js.LICENSE.txt +1 -1
  183. package/dist/video.esm.js +1 -1
  184. package/dist/video.esm.js.LICENSE.txt +1 -1
  185. package/dist/wrap.cjs.js +1 -1
  186. package/dist/wrap.cjs.js.LICENSE.txt +1 -1
  187. package/dist/wrap.esm.js +1 -1
  188. package/dist/wrap.esm.js.LICENSE.txt +1 -1
  189. package/dist/zoom-card.cjs.js +1 -1
  190. package/dist/zoom-card.cjs.js.LICENSE.txt +1 -1
  191. package/dist/zoom-card.esm.js +1 -1
  192. package/dist/zoom-card.esm.js.LICENSE.txt +1 -1
  193. package/layout/animator.js +13 -4
  194. package/layout/audio.js +1 -1
  195. package/layout/audionew.js +1 -1
  196. package/layout/base.js +1 -1
  197. package/layout/beta-desktop-bar.js +1 -1
  198. package/layout/beta-mobile-bar.js +1 -1
  199. package/layout/button.js +1 -1
  200. package/layout/center.js +1 -1
  201. package/layout/checkbox.js +1 -1
  202. package/layout/circle.js +1 -1
  203. package/layout/code.js +1 -1
  204. package/layout/container.js +1 -1
  205. package/layout/dropdown-2025.js +1 -1
  206. package/layout/flex-card.js +1 -1
  207. package/layout/flex-grid.js +1 -1
  208. package/layout/flex-row.js +1 -1
  209. package/layout/form-components/custom.js +1 -1
  210. package/layout/form-components/data-list.js +1 -1
  211. package/layout/form-components/floating-input.js +1 -1
  212. package/layout/form-components/form-all.js +1 -1
  213. package/layout/form-components/form.js +1 -1
  214. package/layout/form-components/image-picker.js +1 -1
  215. package/layout/form-components/picker.js +1 -1
  216. package/layout/form-components/radio.js +1 -1
  217. package/layout/form-components/radiogroup.js +1 -1
  218. package/layout/form-components/range.js +1 -1
  219. package/layout/free.js +1 -1
  220. package/layout/grid-overlay.js +1 -1
  221. package/layout/grid-switcher.js +1 -1
  222. package/layout/grid.js +1 -1
  223. package/layout/horizontal-scroller.js +1 -1
  224. package/layout/image.js +1 -1
  225. package/layout/index.js +1 -1
  226. package/layout/link.js +1 -1
  227. package/layout/list.js +1 -1
  228. package/layout/meta-adder.js +1 -1
  229. package/layout/modal-2025.js +1 -1
  230. package/layout/morph.js +1 -1
  231. package/layout/multiswitcher.js +1 -1
  232. package/layout/nav-bar.js +1 -1
  233. package/layout/nav-factor/custom-div.js +1 -1
  234. package/layout/new-nav-bar.js +1 -1
  235. package/layout/polygon.js +1 -1
  236. package/layout/prerender-site.js +1 -1
  237. package/layout/prerender.js +1 -1
  238. package/layout/progress.js +1 -1
  239. package/layout/row.js +1 -1
  240. package/layout/scroll-video.js +1 -1
  241. package/layout/shop.js +1 -1
  242. package/layout/side-bar.js +1 -1
  243. package/layout/side-nav-bar.js +1 -1
  244. package/layout/simple-bar.js +1 -1
  245. package/layout/slider-2025.js +1 -1
  246. package/layout/spacer.js +1 -1
  247. package/layout/stack.js +1 -1
  248. package/layout/svg.js +1 -1
  249. package/layout/switcher.js +1 -1
  250. package/layout/table.js +1 -1
  251. package/layout/text-field.js +1 -1
  252. package/layout/text.js +1 -1
  253. package/layout/ulist.js +1 -1
  254. package/layout/video.js +1 -1
  255. package/layout/wrap.js +1 -1
  256. package/layout/zoom-card.js +1 -1
  257. package/lib/agent-surface.js +1 -1
  258. package/lib/card-getter.js +1 -1
  259. package/lib/check-page.js +1 -1
  260. package/lib/codegen.js +1 -1
  261. package/lib/data.js +1 -1
  262. package/lib/designer.js +14 -1
  263. package/lib/element-mapper.js +1 -1
  264. package/lib/element-params.generated.js +1 -1
  265. package/lib/grid-geometry.js +1 -1
  266. package/lib/keyframe-animation.js +1 -1
  267. package/lib/known-inert.js +1 -1
  268. package/lib/link-getter.js +1 -1
  269. package/lib/morph-node.js +39 -7
  270. package/lib/normalize-spec.js +1 -1
  271. package/lib/parse-html.js +1 -1
  272. package/lib/raster-inspect.js +1 -1
  273. package/lib/raster-ops.js +255 -34
  274. package/lib/raster-presets.js +32 -1
  275. package/lib/react.js +1 -1
  276. package/lib/resolve-refs.js +1 -1
  277. package/lib/responsive.js +647 -0
  278. package/lib/scroll-video.js +1 -1
  279. package/lib/seo.js +1 -1
  280. package/lib/stacker.js +1 -1
  281. package/lib/suggest.js +1 -1
  282. package/lib/theme.js +1 -1
  283. package/lib/transform-anim.js +1 -1
  284. package/lib/transition.js +1 -1
  285. package/lib/validate-nodes.js +27 -2
  286. package/lib/view-transition.js +287 -0
  287. package/lib/webmcp-adapter.js +1 -1
  288. package/package.json +3 -1
  289. package/skills/nodality/SKILL.md +9 -0
package/lib/raster-ops.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.26
2
+ * nodality v1.4.0
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -29,10 +29,14 @@
29
29
  // October 2026, long after embedding shipped.)
30
30
  // live (the DEFAULT where it applies; opt OUT with `live: false` on any
31
31
  // node) — the emerging HTML-in-Canvas API (WICG, Chrome origin trial):
32
- // the mount subtree moves inside the effect <canvas layoutsubtree> and
33
- // is uploaded per frame with gl.texElementImage2D(), staying
34
- // interactive and live. Falls back to snapshot when the API is absent,
35
- // and again if no paint event arrives within 1500ms.
32
+ // the mount subtree moves inside the effect canvas and is uploaded per
33
+ // frame, staying interactive and live. Two generations of the API are
34
+ // spoken (see htmlInCanvasGeneration): Chrome 155+ opts in with
35
+ // <canvas content="drawable"> and uploads with gl.texElementSubImage2D()
36
+ // into storage allocated here; the trial before it opted in with
37
+ // <canvas layoutsubtree> and uploaded with gl.texElementImage2D().
38
+ // Falls back to snapshot when the API is absent, and again if no paint
39
+ // event arrives within 1500ms.
36
40
  //
37
41
  // "Where it applies" = any chain that is not PURE overlay. A
38
42
  // pure-overlay chain (blobs alone) restructures nothing, so there is
@@ -698,6 +702,101 @@ ${NB.map(([x, y]) => probe(x, y)).join("")}
698
702
  }),
699
703
  },
700
704
 
705
+ // Particle scatter. The image breaks into one particle per cell; each
706
+ // shrinks to a dot, is carried off on its own heading and comes back.
707
+ // Built for transitions — `t-particles` keyframes it to be absent at
708
+ // both ends — where the gaps between particles are transparent, so the
709
+ // two captures read as one cloud of dots changing shape while the
710
+ // morph's boxes carry it from the old rect to the new.
711
+ //
712
+ // { op: "particles", size: 5, amount: [0, 1, 0] } // in a transition
713
+ //
714
+ // A gather, not a scatter. The pipeline only runs per-pixel programs,
715
+ // so each output pixel searches the cells a particle could have come
716
+ // from and keeps the topmost one that covers it. That search is what
717
+ // bounds the travel — a particle moves at most reach - 1 cells — and
718
+ // why `reach` is compiled in: a GLSL loop bound must be a constant,
719
+ // and it is also the cost, (2·reach + 1)² cells per pixel.
720
+ particles: {
721
+ doc: {
722
+ summary: "Breaks the image into one particle per cell, which shrinks to a dot "
723
+ + "and scatters on its own heading. Built for transitions (t-particles), "
724
+ + "where the gaps are transparent; elsewhere they show the image unmoved.",
725
+ params: {
726
+ size: { default: 6, unit: "px", summary: "particle size: one particle per cell this big" },
727
+ amount: { default: 1, unit: "ratio", summary: "0 is the intact image, 1 fully scattered" },
728
+ reach: {
729
+ default: 4, unit: "count", structural: true,
730
+ summary: "travel limit: a particle moves at most reach - 1 cells. Compiled in, "
731
+ + "and the cost: each pixel searches (2·reach + 1)² cells.",
732
+ },
733
+ seed: { default: 0, unit: "count", summary: "picks a different scatter of the same character" },
734
+ },
735
+ },
736
+ structural: ["reach"],
737
+ stage: "displace",
738
+ decl: (p) => `
739
+ uniform float ${p}size;
740
+ uniform float ${p}amount;
741
+ uniform float ${p}seed;
742
+ // Polynomial hash, as in flow: trig hashes band on Apple
743
+ // silicon and differ between GPU vendors.
744
+ float ${p}h(vec2 v) {
745
+ vec3 q = fract(vec3(v.xyx) * 0.1031 + ${p}seed * 0.1);
746
+ q += dot(q, q.yzx + 33.33);
747
+ return fract((q.x + q.y) * q.z);
748
+ }`,
749
+ code: (p, node) => {
750
+ const R = Math.max(1, Math.min(6, Math.round(node.reach != null ? node.reach : 4)));
751
+ return `
752
+ {
753
+ float sz = max(${p}size, 1.0);
754
+ float a = clamp(${p}amount, 0.0, 1.0);
755
+ if (a > 0.0) {
756
+ vec2 x = sampleP;
757
+ vec2 q = floor(x / sz);
758
+ // Square and full-size at rest, so at a = 0 the cells tile
759
+ // the image exactly; round and at 45% in full flight.
760
+ float h = sz * 0.5 * (1.0 - 0.55 * a);
761
+ float travel = ${R - 1}.0 * sz * a;
762
+ float best = -1.0;
763
+ vec2 hit = vec2(-1.0e5);
764
+ for (int j = -${R}; j <= ${R}; j++) {
765
+ for (int i = -${R}; i <= ${R}; i++) {
766
+ vec2 c = q + vec2(float(i), float(j));
767
+ vec2 dir = vec2(${p}h(c), ${p}h(c + vec2(57.3, 11.9))) * 2.0 - 1.0;
768
+ // How far this one goes, and how high it stacks.
769
+ float k = ${p}h(c + vec2(31.7, 83.1));
770
+ vec2 home = (c + 0.5) * sz;
771
+ vec2 d = x - (home + dir * travel * (0.35 + 0.65 * k));
772
+ float dist = mix(max(abs(d.x), abs(d.y)), length(d), a);
773
+ if (dist <= h && k > best) {
774
+ best = k;
775
+ // The particle carries its own cell, shrunk.
776
+ hit = home + d * (0.5 * sz / h);
777
+ }
778
+ }
779
+ }
780
+ #ifdef NOD_TRANSITION
781
+ // A gap lands outside both boxes, which is transparent.
782
+ sampleP = hit;
783
+ #else
784
+ // No backdrop outside a transition: a gap would clamp to an
785
+ // edge texel, so it shows the image unmoved instead.
786
+ if (best >= 0.0) sampleP = hit;
787
+ #endif
788
+ }
789
+ }`;
790
+ },
791
+ uniforms: (node, dpr) => ({
792
+ // A length, so dpr-scaled.
793
+ size: ["1f", (node.size != null ? node.size : 6) * dpr],
794
+ amount: ["1f", node.amount != null ? node.amount : 1],
795
+ // Selects a scatter; not a length.
796
+ seed: ["1f", node.seed != null ? node.seed : 0],
797
+ }),
798
+ },
799
+
701
800
  // ── Field producers ──────────────────────────────────────────────
702
801
  // These draw nothing. They write a scalar field that LATER ops read
703
802
  // via `masked:`, which is the whole of the node-to-node data flow:
@@ -2031,9 +2130,43 @@ function registerRasterOp(name, def) {
2031
2130
  return def;
2032
2131
  }
2033
2132
 
2133
+ // Which generation of the HTML-in-Canvas WebGL upload `target` (a context
2134
+ // or a context prototype) speaks:
2135
+ // "sub-image" — Chrome 155+: texElementSubImage2D() into texture storage
2136
+ // the caller allocates; the canvas opts in with
2137
+ // content="drawable" and the uploaded element carries
2138
+ // `drawable`.
2139
+ // "image" — the origin trial before that: texElementImage2D(), which
2140
+ // allocates by itself; the canvas opts in with layoutsubtree.
2141
+ // null — neither.
2142
+ // Chrome 156 exposes BOTH methods, so the newer one is checked first.
2143
+ // Testing for the old name alone kept working only because Chrome left it
2144
+ // in place after the rename; the day it goes, that test reads "no API" and
2145
+ // every live pipeline quietly becomes a snapshot.
2146
+ function htmlInCanvasGeneration(target) {
2147
+ if (!target) return null;
2148
+ if ("texElementSubImage2D" in target) return "sub-image";
2149
+ if ("texElementImage2D" in target) return "image";
2150
+ return null;
2151
+ }
2152
+
2153
+ // The canvas opt-in for each generation. It must be present before the
2154
+ // context is created, so the browser prepares the canvas for laid-out
2155
+ // children.
2156
+ function setLiveOptIn(canvas, generation) {
2157
+ if (generation === "sub-image") canvas.setAttribute("content", "drawable");
2158
+ else canvas.setAttribute("layoutsubtree", "");
2159
+ }
2160
+
2161
+ function clearLiveOptIn(canvas) {
2162
+ canvas.removeAttribute("content");
2163
+ canvas.removeAttribute("layoutsubtree");
2164
+ canvas.removeAttribute("data-nodality-raster-api");
2165
+ }
2166
+
2034
2167
  function isHTMLInCanvasAvailable() {
2035
2168
  if (typeof WebGLRenderingContext === "undefined") return false;
2036
- return "texElementImage2D" in WebGLRenderingContext.prototype;
2169
+ return htmlInCanvasGeneration(WebGLRenderingContext.prototype) !== null;
2037
2170
  }
2038
2171
 
2039
2172
  // ── Shader assembly ──────────────────────────────────────────────────
@@ -2250,6 +2383,23 @@ function buildFragmentShader(recs, flat, probe, transition) {
2250
2383
  // "opaque" (default) keeps the union solid; "dissolve" is a true
2251
2384
  // cross-dissolve. See nodBlend.
2252
2385
  const fade = (transition && transition.fade) || "opaque";
2386
+ // Optional transition shaping, both compiled in (they are fixed for
2387
+ // the life of a transition):
2388
+ // fit: "width" each capture keeps its own aspect ratio — drawn
2389
+ // at its box's width, top-aligned, clipped to the
2390
+ // box — instead of being stretched to fill it. A
2391
+ // small element growing into a large one otherwise
2392
+ // smears its text across the whole new shape. Same
2393
+ // sizing the platform gives ::view-transition-old/new.
2394
+ // crossfade: [a,b] the old-to-new handover happens inside that slice
2395
+ // of t, while the boxes still travel the whole way.
2396
+ // The container-transform pattern: the old content
2397
+ // goes early, before it has been blown up.
2398
+ const glf = (v) => { const x = Number(v); return (Number.isFinite(x) ? x : 0).toFixed(5); };
2399
+ const aspectOf = (r) => (r && r.w > 0 && r.h > 0 ? r.h / r.w : 0);
2400
+ const fitWidth = !!(transition && transition.fit === "width");
2401
+ const xf = transition && Array.isArray(transition.crossfade) &&
2402
+ transition.crossfade.length === 2 ? transition.crossfade : null;
2253
2403
  let decls = "";
2254
2404
 
2255
2405
  // Every field any node writes or reads, declared up front at 1.0 so
@@ -2384,9 +2534,13 @@ ${b.color}
2384
2534
  gl_FragColor = vec4(hi.x, lo.x, hi.y, lo.y) / 255.0;
2385
2535
  }`;
2386
2536
 
2537
+ // NOD_TRANSITION lets an op's GLSL tell the two modes apart. Only a
2538
+ // transition has a backdrop: a sample outside both captures' boxes is
2539
+ // transparent there, while the single-image path clamps it to the
2540
+ // nearest edge texel.
2387
2541
  return `
2388
2542
  precision highp float;
2389
- uniform sampler2D u_tex;
2543
+ ${transition ? "#define NOD_TRANSITION 1\n" : ""}uniform sampler2D u_tex;
2390
2544
  uniform vec2 u_res;
2391
2545
  uniform vec2 u_mouse;
2392
2546
  uniform float u_time;
@@ -2475,9 +2629,15 @@ vec2 nodBoxUV(vec4 box, vec2 p) {
2475
2629
  float nodInBox(vec2 uv) {
2476
2630
  return step(0.0, uv.x) * step(uv.x, 1.0) * step(0.0, uv.y) * step(uv.y, 1.0);
2477
2631
  }
2478
- vec4 nodSampleAt(vec2 p) {
2479
- vec2 uo = nodBoxUV(u_boxOld, p);
2480
- vec2 un = nodBoxUV(u_boxNew, p);
2632
+ ${fitWidth ? `// fit: "width" — the capture's own height at this box width.
2633
+ vec2 nodFitUV(vec4 box, vec2 p, float aspect) {
2634
+ return vec2((p.x - box.x) / max(box.z, 1.0),
2635
+ 1.0 - (p.y - box.y) / max(box.z * aspect, 1.0));
2636
+ }
2637
+ ` : ""}vec4 nodSampleAt(vec2 p) {
2638
+ ${fitWidth ? ` vec2 uo = nodFitUV(u_boxOld, p, ${glf(aspectOf(transition.oldRect))});
2639
+ vec2 un = nodFitUV(u_boxNew, p, ${glf(aspectOf(transition.newRect))});` : ` vec2 uo = nodBoxUV(u_boxOld, p);
2640
+ vec2 un = nodBoxUV(u_boxNew, p);`}
2481
2641
  vec4 o = texture2D(u_old, clamp(uo, 0.001, 0.999));
2482
2642
  // With newImage the new side is a capture of the ELEMENT, so both
2483
2643
  // sides can travel between their own rects and converge into one
@@ -2489,7 +2649,11 @@ vec4 nodSampleAt(vec2 p) {
2489
2649
  clamp(un, 0.001, 0.999));
2490
2650
  o.a *= nodInBox(uo);
2491
2651
  n.a *= nodInBox(un);
2492
- ${oldSideCode}${newSideCode}
2652
+ ${fitWidth ? ` // Clipped to the travelling box as well, so a tall capture in a
2653
+ // short box shows its top rather than spilling below it.
2654
+ o.a *= nodInBox(nodBoxUV(u_boxOld, p));
2655
+ n.a *= nodInBox(nodBoxUV(u_boxNew, p));
2656
+ ` : ""}${oldSideCode}${newSideCode}
2493
2657
  // The threshold each pixel flips at. Mostly a COHERENT ramp down the
2494
2658
  // box with a little grain on top — pure white noise chooses correctly
2495
2659
  // (never two legible images at once) but reads as television static
@@ -2498,7 +2662,7 @@ ${oldSideCode}${newSideCode}
2498
2662
  float grain = fract(sin(dot(floor(p / 3.0), vec2(12.9898, 78.233))) * 43758.5453);
2499
2663
  float ramp = clamp(un.y, 0.0, 1.0);
2500
2664
  float d = ramp * 0.82 + grain * 0.18;
2501
- return nodBlend(o, n, u_t, d);
2665
+ return nodBlend(o, n, ${xf ? `smoothstep(${glf(xf[0])}, ${glf(xf[1])}, u_t)` : "u_t"}, d);
2502
2666
  }` : ""}
2503
2667
  void main() {
2504
2668
  vec2 fc = ${fragCoord};
@@ -3301,7 +3465,7 @@ function applyRasterPipeline(el, rasterNodes, opts) {
3301
3465
  const pureOverlay = rasterNodes.length > 0 && !transition &&
3302
3466
  rasterNodes.every((n) => (REGISTRY[n.op] || {}).overlay);
3303
3467
  // Live-first (HTML-in-Canvas). The live backend captures content that
3304
- // lives INSIDE the canvas (texElementImage2D over the restructured
3468
+ // lives INSIDE the canvas (the live upload over the restructured
3305
3469
  // subtree) — the same model canvasUI's bubble uses: content in the
3306
3470
  // canvas, the lens drawn over that live capture. So live is viable
3307
3471
  // whenever the host is hidden and its content moves into the canvas,
@@ -3333,33 +3497,36 @@ function applyRasterPipeline(el, rasterNodes, opts) {
3333
3497
  const forceLive = !!(transition && transition.live === true);
3334
3498
  const wantLive = !pureOverlay && (!transition || forceLive) &&
3335
3499
  !rasterNodes.some((n) => n.live === false);
3336
- const apiAvailable =
3337
- (typeof WebGL2RenderingContext !== "undefined" &&
3338
- "texElementImage2D" in WebGL2RenderingContext.prototype) ||
3339
- (typeof WebGLRenderingContext !== "undefined" &&
3340
- "texElementImage2D" in WebGLRenderingContext.prototype);
3341
- let live = wantLive && apiAvailable;
3500
+ const apiGeneration =
3501
+ htmlInCanvasGeneration(typeof WebGL2RenderingContext !== "undefined" &&
3502
+ WebGL2RenderingContext.prototype) ||
3503
+ htmlInCanvasGeneration(typeof WebGLRenderingContext !== "undefined" &&
3504
+ WebGLRenderingContext.prototype);
3505
+ let live = wantLive && apiGeneration !== null;
3342
3506
  if (wantLive && !live) {
3343
3507
  console.info("[nodality] HTML-in-Canvas API not available - raster ops fall back to snapshot capture.");
3344
3508
  }
3345
3509
 
3346
3510
  const canvas = document.createElement("canvas");
3347
- // layoutsubtree must be present before context creation so the
3348
- // browser prepares the canvas for laid-out children (origin trial).
3349
- if (live) canvas.setAttribute("layoutsubtree", "");
3511
+ if (live) setLiveOptIn(canvas, apiGeneration);
3350
3512
  const ctxOpts = { alpha: true, premultipliedAlpha: false };
3351
3513
  // WebGL2-first everywhere: NPOT mipmaps (offset-scaled blur for the
3352
- // glassy ops) and texElementImage2D both need it; WebGL1 remains as
3353
- // a sharp-rendering fallback (mip blur simply disables).
3514
+ // glassy ops) and the live upload's sized RGBA8 format both need it;
3515
+ // WebGL1 remains as a sharp-rendering fallback (mip blur simply
3516
+ // disables).
3354
3517
  const gl = canvas.getContext("webgl2", ctxOpts) ||
3355
3518
  canvas.getContext("webgl", ctxOpts);
3356
3519
  if (!gl) return null;
3357
3520
  const isGL2 = (typeof WebGL2RenderingContext !== "undefined") &&
3358
3521
  (gl instanceof WebGL2RenderingContext);
3359
3522
  const needMips = isGL2 && rasterNodes.some((n) => (REGISTRY[n.op] || {}).mips);
3360
- if (live && !("texElementImage2D" in gl)) {
3361
- console.info("[nodality] texElementImage2D missing on the created context - snapshot fallback.");
3362
- canvas.removeAttribute("layoutsubtree");
3523
+ // The generation that counts is the one on the context actually
3524
+ // created. It has to match the opt-in already set from the prototype.
3525
+ const liveGeneration = live ? htmlInCanvasGeneration(gl) : null;
3526
+ if (live && liveGeneration !== apiGeneration) {
3527
+ console.info("[nodality] HTML-in-Canvas upload missing on the created context (" +
3528
+ liveGeneration + " vs " + apiGeneration + ") - snapshot fallback.");
3529
+ clearLiveOptIn(canvas);
3363
3530
  live = false;
3364
3531
  }
3365
3532
 
@@ -3371,7 +3538,11 @@ function applyRasterPipeline(el, rasterNodes, opts) {
3371
3538
  canvas.width = Math.round(rect.width * dpr);
3372
3539
  canvas.height = Math.round(rect.height * dpr);
3373
3540
  canvas.setAttribute("data-nodality-raster", live ? "live" : "snapshot");
3374
- console.info("[nodality] raster backend:", live ? "html-in-canvas (live)" : "snapshot");
3541
+ // Which upload generation a live canvas runs on, so a test or an
3542
+ // inspector can tell the two apart; Chrome 156 can run either.
3543
+ if (live) canvas.setAttribute("data-nodality-raster-api", liveGeneration);
3544
+ console.info("[nodality] raster backend:",
3545
+ live ? "html-in-canvas (live, " + liveGeneration + ")" : "snapshot");
3375
3546
 
3376
3547
  // In live mode the canvas fills the host's CONTENT box, not its border
3377
3548
  // box (it is a child of the host). Filled in below when live attaches.
@@ -3379,15 +3550,15 @@ function applyRasterPipeline(el, rasterNodes, opts) {
3379
3550
  let sourceEl = el; // element uploaded as the texture in live mode
3380
3551
  if (live) {
3381
3552
  // HTML-in-Canvas: the subtree becomes canvas children (wrapped in
3382
- // a single div we can pass to texElementImage2D) so it keeps
3553
+ // a single div we can pass to the live upload) so it keeps
3383
3554
  // layout, interactivity and its accessibility-tree presence while
3384
3555
  // the canvas paints it (WICG proposal; Chrome origin trial behind
3385
- // chrome://flags/#canvas-draw-element). layoutsubtree was already
3386
- // set before context creation above.
3556
+ // chrome://flags/#canvas-draw-element). The canvas opt-in was
3557
+ // already set before context creation above.
3387
3558
  const wrap = document.createElement("div");
3388
3559
  // The wrapper MUST fill the canvas box. Left to itself it
3389
3560
  // shrink-wraps its content — a headline wraps to the text width,
3390
- // not the element width — and texElementImage2D then captures
3561
+ // not the element width — and the live upload then captures
3391
3562
  // that narrower box while the shader maps the texture across the
3392
3563
  // whole canvas. Everything comes out stretched horizontally by
3393
3564
  // canvasWidth/contentWidth, so the drawn glyphs no longer sit
@@ -3446,6 +3617,8 @@ function applyRasterPipeline(el, rasterNodes, opts) {
3446
3617
  wrap.style.justifyContent = hostCS.justifyContent;
3447
3618
  wrap.style.gap = hostCS.gap;
3448
3619
  }
3620
+ // Chrome 155+ draws only canvas descendants marked `drawable`.
3621
+ if (liveGeneration === "sub-image") wrap.setAttribute("drawable", "");
3449
3622
  while (el.firstChild) wrap.appendChild(el.firstChild);
3450
3623
  canvas.appendChild(wrap);
3451
3624
  sourceEl = wrap;
@@ -4043,6 +4216,39 @@ function applyRasterPipeline(el, rasterNodes, opts) {
4043
4216
  // renders or redraws. Uploading outside of it yields an empty
4044
4217
  // (fully transparent) texture — which looks like a blank box.
4045
4218
  //
4219
+ // Chrome 155+ (`sub-image`) no longer allocates the destination: the
4220
+ // texture's storage has to exist before texElementSubImage2D writes
4221
+ // into it, sized to the element's image as captureElementImage()
4222
+ // reports it. That size follows the canvas box, so it is measured
4223
+ // again only when the backing store changes rather than on every
4224
+ // paint.
4225
+ //
4226
+ // updateElementGeometry() is deliberately NOT called. In this
4227
+ // generation it is what makes canvas descendants hit-testable, and the
4228
+ // pipeline already hit-tests the hosted subtree itself (see
4229
+ // hostedElementAt), retargeting each event to where the shader drew
4230
+ // the content. With native hit testing switched on as well, a
4231
+ // displaced click would reach the element under the cursor natively
4232
+ // AND the one under the drawn pixel through the retarget.
4233
+ let storageFor = "";
4234
+ const allocateSubImageStorage = () => {
4235
+ const key = canvas.width + "x" + canvas.height;
4236
+ if (key === storageFor) return;
4237
+ let w = canvas.width, h = canvas.height;
4238
+ if (typeof canvas.captureElementImage === "function") {
4239
+ const image = canvas.captureElementImage(sourceEl);
4240
+ try {
4241
+ w = Math.ceil(image.width);
4242
+ h = Math.ceil(image.height);
4243
+ } finally {
4244
+ if (image && typeof image.close === "function") image.close();
4245
+ }
4246
+ }
4247
+ gl.texImage2D(gl.TEXTURE_2D, 0, isGL2 ? (gl.RGBA8 || 0x8058) : gl.RGBA,
4248
+ Math.max(1, w), Math.max(1, h), 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
4249
+ storageFor = key;
4250
+ };
4251
+
4046
4252
  // The trial's texElementImage2D signature has drifted across Chrome
4047
4253
  // builds (the element parameter has moved as the arg list shrank),
4048
4254
  // so the working call form is discovered at runtime — guided by the
@@ -4051,6 +4257,21 @@ function applyRasterPipeline(el, rasterNodes, opts) {
4051
4257
  const onPaint = () => {
4052
4258
  if (destroyed || mode !== "live") return;
4053
4259
  gl.bindTexture(gl.TEXTURE_2D, tex);
4260
+ if (liveGeneration === "sub-image") {
4261
+ try {
4262
+ allocateSubImageStorage();
4263
+ gl.texElementSubImage2D(gl.TEXTURE_2D, 0, 0, 0, sourceEl);
4264
+ } catch (e) {
4265
+ // Measured again next time, in case storage was the problem.
4266
+ storageFor = "";
4267
+ fallbackToSnapshot("texElementSubImage2D failed: " +
4268
+ (e && e.name ? e.name : "?") + ": " + (e && e.message ? e.message : e));
4269
+ return;
4270
+ }
4271
+ finishUpload();
4272
+ textureReady = true;
4273
+ return;
4274
+ }
4054
4275
  // Confirmed signature in Chrome 148+ (origin trial):
4055
4276
  // texElementImage2D(target, internalformat, element)
4056
4277
  // where internalformat must be a *sized* WebGL2 format
@@ -4104,7 +4325,7 @@ function applyRasterPipeline(el, rasterNodes, opts) {
4104
4325
  canvas.removeEventListener("paint", onPaint);
4105
4326
  while (sourceEl.firstChild) el.appendChild(sourceEl.firstChild);
4106
4327
  if (sourceEl.parentNode === canvas) canvas.removeChild(sourceEl);
4107
- canvas.removeAttribute("layoutsubtree");
4328
+ clearLiveOptIn(canvas);
4108
4329
  canvas.style.cssText =
4109
4330
  "position:absolute;top:0;left:0;" +
4110
4331
  `width:${rect.width}px;height:${rect.height}px;` +
@@ -5000,7 +5221,7 @@ function applyRasterPipeline(el, rasterNodes, opts) {
5000
5221
 
5001
5222
  export {
5002
5223
  applyRasterPipeline, registerRasterOp, RASTER_OP_NAMES,
5003
- isHTMLInCanvasAvailable, DRIVER_NAMES, DRIVER_DOCS,
5224
+ isHTMLInCanvasAvailable, htmlInCanvasGeneration, DRIVER_NAMES, DRIVER_DOCS,
5004
5225
  // Phase H3. The registry is already effectively public — registerRasterOp
5005
5226
  // mutates it — and a dev tool needs to read an op's stage and params to
5006
5227
  // show them. `isStructuralChange` is exported so the inspector can label
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.26
2
+ * nodality v1.4.0
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -93,6 +93,37 @@ const PRESETS = {
93
93
  ],
94
94
  },
95
95
 
96
+ // Particles travel a few cells at most (the op gathers rather than
97
+ // scatters). The long journey from the old rect to the new one is the
98
+ // morph's geometry; what this adds is the shape coming apart into
99
+ // dots on the way and re-forming as the other one.
100
+ // A current through the morph: both stills are carried along a
101
+ // divergence-free flow that rises and settles, so the shape seems to
102
+ // pour into its new box. flow needs no solver and no float targets, so
103
+ // it runs wherever the transition runs. `speed` keeps the field moving
104
+ // during the morph; at both ends strength is 0 and it does nothing.
105
+ "t-fluid": {
106
+ summary: "Liquid morph: the old state is carried on a current and pours " +
107
+ "into the new one, calm at both ends.",
108
+ nodes: [
109
+ { op: "flow", strength: [0, 46, 0], scale: 130, speed: 0.8, ease: "in-out" },
110
+ { op: "aberration", amount: [0, 4, 0], window: [0.2, 0.8] },
111
+ ],
112
+ },
113
+
114
+ //
115
+ // Held at full scatter through the middle third: a single [0, 1, 0]
116
+ // peak is over in an instant at ordinary morph durations, and on pale
117
+ // content the dots barely register. reach 5 lets a 9px particle travel
118
+ // 36px, at (2·5 + 1)² = 121 cells searched per pixel.
119
+ "t-particles": {
120
+ summary: "Particle morph: the old state breaks into dots that scatter and " +
121
+ "re-form as the new one, with see-through gaps in between.",
122
+ nodes: [
123
+ { op: "particles", size: 9, amount: [0, 1, 1, 0], reach: 5, ease: "in-out" },
124
+ ],
125
+ },
126
+
96
127
  // ── fluid ────────────────────────────────────────────────────────
97
128
  // The two `stir` numbers are the PROVEN values from
98
129
  // designerTest/raster-spot.html, not fresh guesses: radius 0.055 is
package/lib/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.26
2
+ * nodality v1.4.0
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.26
2
+ * nodality v1.4.0
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */