nodality 1.3.24 → 1.3.26

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 (200) hide show
  1. package/dist/animator.cjs.js.LICENSE.txt +1 -1
  2. package/dist/animator.esm.js.LICENSE.txt +1 -1
  3. package/dist/audionew.cjs.js.LICENSE.txt +1 -1
  4. package/dist/audionew.esm.js.LICENSE.txt +1 -1
  5. package/dist/base.cjs.js.LICENSE.txt +1 -1
  6. package/dist/base.esm.js.LICENSE.txt +1 -1
  7. package/dist/beta-desktop-bar.cjs.js.LICENSE.txt +1 -1
  8. package/dist/beta-desktop-bar.esm.js.LICENSE.txt +1 -1
  9. package/dist/beta-mobile-bar.cjs.js.LICENSE.txt +1 -1
  10. package/dist/beta-mobile-bar.esm.js.LICENSE.txt +1 -1
  11. package/dist/bundle.umd.js.LICENSE.txt +1 -1
  12. package/dist/button.cjs.js.LICENSE.txt +1 -1
  13. package/dist/button.esm.js.LICENSE.txt +1 -1
  14. package/dist/card-getter.cjs.js.LICENSE.txt +1 -1
  15. package/dist/card-getter.esm.js.LICENSE.txt +1 -1
  16. package/dist/center.cjs.js.LICENSE.txt +1 -1
  17. package/dist/center.esm.js.LICENSE.txt +1 -1
  18. package/dist/checkbox.cjs.js.LICENSE.txt +1 -1
  19. package/dist/checkbox.esm.js.LICENSE.txt +1 -1
  20. package/dist/code.cjs.js.LICENSE.txt +1 -1
  21. package/dist/code.esm.js.LICENSE.txt +1 -1
  22. package/dist/container.cjs.js.LICENSE.txt +1 -1
  23. package/dist/container.esm.js.LICENSE.txt +1 -1
  24. package/dist/data-list.cjs.js.LICENSE.txt +1 -1
  25. package/dist/data-list.esm.js.LICENSE.txt +1 -1
  26. package/dist/designer.cjs.js.LICENSE.txt +1 -1
  27. package/dist/designer.esm.js.LICENSE.txt +1 -1
  28. package/dist/element-mapper.cjs.js.LICENSE.txt +1 -1
  29. package/dist/element-mapper.esm.js.LICENSE.txt +1 -1
  30. package/dist/finalresult.esm.js.LICENSE.txt +1 -1
  31. package/dist/flex-card.cjs.js.LICENSE.txt +1 -1
  32. package/dist/flex-card.esm.js.LICENSE.txt +1 -1
  33. package/dist/flex-grid.cjs.js.LICENSE.txt +1 -1
  34. package/dist/flex-grid.esm.js.LICENSE.txt +1 -1
  35. package/dist/flex-row.cjs.js.LICENSE.txt +1 -1
  36. package/dist/flex-row.esm.js.LICENSE.txt +1 -1
  37. package/dist/floating-input.cjs.js.LICENSE.txt +1 -1
  38. package/dist/floating-input.esm.js.LICENSE.txt +1 -1
  39. package/dist/free.cjs.js.LICENSE.txt +1 -1
  40. package/dist/free.esm.js.LICENSE.txt +1 -1
  41. package/dist/horizontal-scroller.cjs.js.LICENSE.txt +1 -1
  42. package/dist/horizontal-scroller.esm.js.LICENSE.txt +1 -1
  43. package/dist/image-picker.cjs.js.LICENSE.txt +1 -1
  44. package/dist/image-picker.esm.js.LICENSE.txt +1 -1
  45. package/dist/image.cjs.js.LICENSE.txt +1 -1
  46. package/dist/image.esm.js.LICENSE.txt +1 -1
  47. package/dist/index.cjs.js.LICENSE.txt +1 -1
  48. package/dist/index.d.ts +1 -1
  49. package/dist/index.esm.js.LICENSE.txt +1 -1
  50. package/dist/keyframe-animation.cjs.js.LICENSE.txt +1 -1
  51. package/dist/keyframe-animation.esm.js.LICENSE.txt +1 -1
  52. package/dist/link-getter.cjs.js.LICENSE.txt +1 -1
  53. package/dist/link-getter.esm.js.LICENSE.txt +1 -1
  54. package/dist/link.cjs.js.LICENSE.txt +1 -1
  55. package/dist/link.esm.js.LICENSE.txt +1 -1
  56. package/dist/meta-adder.cjs.js.LICENSE.txt +1 -1
  57. package/dist/meta-adder.esm.js.LICENSE.txt +1 -1
  58. package/dist/modal-2025.cjs.js.LICENSE.txt +1 -1
  59. package/dist/modal-2025.esm.js.LICENSE.txt +1 -1
  60. package/dist/multiswitcher.cjs.js.LICENSE.txt +1 -1
  61. package/dist/multiswitcher.esm.js.LICENSE.txt +1 -1
  62. package/dist/new-nav-bar.cjs.js.LICENSE.txt +1 -1
  63. package/dist/new-nav-bar.esm.js.LICENSE.txt +1 -1
  64. package/dist/picker.cjs.js.LICENSE.txt +1 -1
  65. package/dist/picker.esm.js.LICENSE.txt +1 -1
  66. package/dist/progress.cjs.js.LICENSE.txt +1 -1
  67. package/dist/progress.esm.js.LICENSE.txt +1 -1
  68. package/dist/radio.cjs.js.LICENSE.txt +1 -1
  69. package/dist/radio.esm.js.LICENSE.txt +1 -1
  70. package/dist/range.cjs.js.LICENSE.txt +1 -1
  71. package/dist/range.esm.js.LICENSE.txt +1 -1
  72. package/dist/scroll-video.cjs.js.LICENSE.txt +1 -1
  73. package/dist/scroll-video.esm.js.LICENSE.txt +1 -1
  74. package/dist/side-bar.cjs.js.LICENSE.txt +1 -1
  75. package/dist/side-bar.esm.js.LICENSE.txt +1 -1
  76. package/dist/side-nav-bar.cjs.js.LICENSE.txt +1 -1
  77. package/dist/side-nav-bar.esm.js.LICENSE.txt +1 -1
  78. package/dist/simple-bar.cjs.js.LICENSE.txt +1 -1
  79. package/dist/simple-bar.esm.js.LICENSE.txt +1 -1
  80. package/dist/slider-2025.cjs.js.LICENSE.txt +1 -1
  81. package/dist/slider-2025.esm.js.LICENSE.txt +1 -1
  82. package/dist/spacer.cjs.js.LICENSE.txt +1 -1
  83. package/dist/spacer.esm.js.LICENSE.txt +1 -1
  84. package/dist/stack.cjs.js.LICENSE.txt +1 -1
  85. package/dist/stack.esm.js.LICENSE.txt +1 -1
  86. package/dist/stacker.cjs.js.LICENSE.txt +1 -1
  87. package/dist/stacker.esm.js.LICENSE.txt +1 -1
  88. package/dist/table.cjs.js.LICENSE.txt +1 -1
  89. package/dist/table.esm.js.LICENSE.txt +1 -1
  90. package/dist/text-field.cjs.js.LICENSE.txt +1 -1
  91. package/dist/text-field.esm.js.LICENSE.txt +1 -1
  92. package/dist/text.cjs.js.LICENSE.txt +1 -1
  93. package/dist/text.esm.js.LICENSE.txt +1 -1
  94. package/dist/theme.cjs.js.LICENSE.txt +1 -1
  95. package/dist/theme.esm.js.LICENSE.txt +1 -1
  96. package/dist/transform-anim.cjs.js.LICENSE.txt +1 -1
  97. package/dist/transform-anim.esm.js.LICENSE.txt +1 -1
  98. package/dist/ulist.cjs.js.LICENSE.txt +1 -1
  99. package/dist/ulist.esm.js.LICENSE.txt +1 -1
  100. package/dist/video.cjs.js.LICENSE.txt +1 -1
  101. package/dist/video.esm.js.LICENSE.txt +1 -1
  102. package/dist/wrap.cjs.js.LICENSE.txt +1 -1
  103. package/dist/wrap.esm.js.LICENSE.txt +1 -1
  104. package/dist/zoom-card.cjs.js.LICENSE.txt +1 -1
  105. package/dist/zoom-card.esm.js.LICENSE.txt +1 -1
  106. package/layout/animator.js +1 -1
  107. package/layout/audio.js +1 -1
  108. package/layout/audionew.js +1 -1
  109. package/layout/base.js +1 -1
  110. package/layout/beta-desktop-bar.js +1 -1
  111. package/layout/beta-mobile-bar.js +1 -1
  112. package/layout/button.js +1 -1
  113. package/layout/center.js +1 -1
  114. package/layout/checkbox.js +1 -1
  115. package/layout/circle.js +1 -1
  116. package/layout/code.js +1 -1
  117. package/layout/container.js +1 -1
  118. package/layout/dropdown-2025.js +1 -1
  119. package/layout/flex-card.js +1 -1
  120. package/layout/flex-grid.js +1 -1
  121. package/layout/flex-row.js +1 -1
  122. package/layout/form-components/custom.js +1 -1
  123. package/layout/form-components/data-list.js +1 -1
  124. package/layout/form-components/floating-input.js +1 -1
  125. package/layout/form-components/form-all.js +1 -1
  126. package/layout/form-components/form.js +1 -1
  127. package/layout/form-components/image-picker.js +1 -1
  128. package/layout/form-components/picker.js +1 -1
  129. package/layout/form-components/radio.js +1 -1
  130. package/layout/form-components/radiogroup.js +1 -1
  131. package/layout/form-components/range.js +1 -1
  132. package/layout/free.js +1 -1
  133. package/layout/grid-overlay.js +1 -1
  134. package/layout/grid-switcher.js +1 -1
  135. package/layout/grid.js +1 -1
  136. package/layout/horizontal-scroller.js +1 -1
  137. package/layout/image.js +1 -1
  138. package/layout/index.js +1 -1
  139. package/layout/link.js +1 -1
  140. package/layout/list.js +1 -1
  141. package/layout/meta-adder.js +1 -1
  142. package/layout/modal-2025.js +1 -1
  143. package/layout/morph.js +1 -1
  144. package/layout/multiswitcher.js +1 -1
  145. package/layout/nav-bar.js +1 -1
  146. package/layout/nav-factor/custom-div.js +1 -1
  147. package/layout/new-nav-bar.js +1 -1
  148. package/layout/polygon.js +1 -1
  149. package/layout/prerender-site.js +1 -1
  150. package/layout/prerender.js +1 -1
  151. package/layout/progress.js +1 -1
  152. package/layout/row.js +1 -1
  153. package/layout/scroll-video.js +1 -1
  154. package/layout/shop.js +1 -1
  155. package/layout/side-bar.js +1 -1
  156. package/layout/side-nav-bar.js +1 -1
  157. package/layout/simple-bar.js +1 -1
  158. package/layout/slider-2025.js +1 -1
  159. package/layout/spacer.js +1 -1
  160. package/layout/stack.js +1 -1
  161. package/layout/svg.js +1 -1
  162. package/layout/switcher.js +1 -1
  163. package/layout/table.js +1 -1
  164. package/layout/text-field.js +1 -1
  165. package/layout/text.js +1 -1
  166. package/layout/ulist.js +1 -1
  167. package/layout/video.js +1 -1
  168. package/layout/wrap.js +1 -1
  169. package/layout/zoom-card.js +1 -1
  170. package/lib/agent-surface.js +1 -1
  171. package/lib/card-getter.js +1 -1
  172. package/lib/check-page.js +1 -1
  173. package/lib/codegen.js +1 -1
  174. package/lib/data.js +1 -1
  175. package/lib/designer.js +1 -1
  176. package/lib/element-mapper.js +1 -1
  177. package/lib/element-params.generated.js +1 -1
  178. package/lib/grid-geometry.js +1 -1
  179. package/lib/keyframe-animation.js +1 -1
  180. package/lib/known-inert.js +1 -1
  181. package/lib/link-getter.js +1 -1
  182. package/lib/morph-node.js +1 -1
  183. package/lib/normalize-spec.js +1 -1
  184. package/lib/parse-html.js +1 -1
  185. package/lib/raster-inspect.js +1 -1
  186. package/lib/raster-ops.js +1 -1
  187. package/lib/raster-presets.js +1 -1
  188. package/lib/react.d.ts +30 -0
  189. package/lib/react.js +173 -0
  190. package/lib/resolve-refs.js +1 -1
  191. package/lib/scroll-video.js +1 -1
  192. package/lib/seo.js +1 -1
  193. package/lib/stacker.js +1 -1
  194. package/lib/suggest.js +1 -1
  195. package/lib/theme.js +1 -1
  196. package/lib/transform-anim.js +1 -1
  197. package/lib/transition.js +1 -1
  198. package/lib/validate-nodes.js +1 -1
  199. package/lib/webmcp-adapter.js +1 -1
  200. package/package.json +18 -3
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/layout/spacer.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/layout/stack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/layout/svg.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/layout/table.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/layout/text.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/layout/ulist.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/layout/video.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/layout/wrap.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/check-page.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/codegen.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/data.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/designer.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/morph-node.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/parse-html.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
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.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/lib/react.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ // Types for nodality/react. Hand-written: scripts/generate-types.mjs covers
2
+ // the main bundle (dist/index.d.ts), not the lib/ subpaths.
3
+
4
+ import type { CSSProperties, ReactElement } from "react";
5
+
6
+ /** Anything with Nodality's render(): every component class, e.g. Wrapper or Text. */
7
+ export interface NodalityRenderable {
8
+ render(): Node;
9
+ }
10
+
11
+ export interface NodalityProps {
12
+ /** Regime 1 — the specification's elements (E). */
13
+ elements?: Array<Record<string, unknown>>;
14
+ /** Regime 1 — its nodes (N). */
15
+ nodes?: Array<Record<string, unknown>>;
16
+ /** Regime 1 — definitions, passed to Des.defs(). */
17
+ defs?: Record<string, unknown>;
18
+ /**
19
+ * Regime 2 — a factory returning a Nodality component. A factory rather than
20
+ * an instance so it is not rebuilt on every parent render; client-side only.
21
+ */
22
+ view?: () => NodalityRenderable;
23
+ /** When to rebuild `view` — same meaning as useEffect's dependency array. */
24
+ deps?: ReadonlyArray<unknown>;
25
+ className?: string;
26
+ style?: CSSProperties;
27
+ }
28
+
29
+ export declare function Nodality(props: NodalityProps): ReactElement;
30
+ export default Nodality;
package/lib/react.js ADDED
@@ -0,0 +1,173 @@
1
+ /*!
2
+ * nodality v1.3.26
3
+ * (c) 2026 Filip Vabrousek
4
+ * License: MIT
5
+ */
6
+
7
+ "use client";
8
+
9
+ /*!
10
+ * nodality/react — host a Nodality render inside a React tree.
11
+ *
12
+ * import Nodality from "nodality/react";
13
+ *
14
+ * <Nodality elements={E} nodes={N} /> // a specification
15
+ * <Nodality view={() => new Wrapper()...} deps={[x]} /> // component code you own
16
+ *
17
+ * Both of the library's regimes are first-class. The pair is what a
18
+ * generator emits and what the compiler consumes; the component classes are
19
+ * what the compiler EMITS, and what a developer takes ownership of
20
+ * afterwards. A React binding that supported only one of them would be
21
+ * describing half the library.
22
+ *
23
+ * They differ in exactly one respect: only the specification survives the
24
+ * build boundary. A specification is data, so a prerenderer can find it in
25
+ * the page (the <script data-nodality-for> this emits) and render it to HTML
26
+ * at build time. A `view` is a closure over your module graph — it cannot be
27
+ * serialised into the document, so it renders on the client only.
28
+ *
29
+ * Moved here from create-nodality-react's template (src/Nodality.jsx) so
30
+ * every React app imports one maintained copy. The markup it emits is
31
+ * unchanged, so that template's prerender.mjs keeps working.
32
+ *
33
+ * Plain JavaScript rather than JSX: bundlers do not compile JSX inside
34
+ * node_modules. "use client" marks it as a client component for the Next.js
35
+ * App Router; other bundlers ignore it. `Des` comes from "nodality" itself
36
+ * rather than ../layout, so an app that also imports "nodality" loads ONE
37
+ * copy of the library — two copies would mean two Theme singletons and two
38
+ * element registries.
39
+ *
40
+ * React 18 or later (useId). React is an optional peer dependency: nothing
41
+ * else in nodality needs it.
42
+ */
43
+
44
+ import { createElement, Fragment, useEffect, useId, useMemo, useRef } from "react";
45
+ import { Des } from "nodality";
46
+
47
+ // One object for every render, on purpose. React 19.0–19.2 re-apply
48
+ // dangerouslySetInnerHTML whenever the prop OBJECT differs from the last
49
+ // render's, not its __html string, so a literal `{ __html: "" }` (a new
50
+ // object each time) set innerHTML = "" on every parent re-render and wiped
51
+ // the built view — typing into a field whose value the parent kept in state
52
+ // emptied the whole host, and with `deps` unchanged nothing rebuilt it.
53
+ // React 18 and 19.3+ compare the string, so they never showed it.
54
+ const EMPTY_HTML = Object.freeze({ __html: "" });
55
+
56
+ /**
57
+ * @param {object} props
58
+ * @param {Array<object>} [props.elements] Regime 1: the specification's elements (E).
59
+ * @param {Array<object>} [props.nodes] Regime 1: its nodes (N).
60
+ * @param {object} [props.defs] Regime 1: definitions, passed to Des.defs().
61
+ * @param {() => {render(): Node}} [props.view]
62
+ * Regime 2: a factory returning a Nodality component. A factory rather
63
+ * than an instance so it is not rebuilt on every parent render.
64
+ * @param {Array<unknown>} [props.deps] When to rebuild `view` — same meaning as useEffect's.
65
+ * @param {string} [props.className]
66
+ * @param {object} [props.style]
67
+ */
68
+ export function Nodality({
69
+ elements,
70
+ nodes = [],
71
+ defs,
72
+ view,
73
+ deps = [],
74
+ className,
75
+ style,
76
+ }) {
77
+ const host = useRef(null);
78
+
79
+ // Des mounts by CSS selector, and React's useId contains ':' — invalid in a
80
+ // selector. Strip it. useId is stable across server and client, so the id
81
+ // still matches whatever a prerenderer wrote into the document.
82
+ const domId = "nod-" + useId().replace(/:/g, "");
83
+
84
+ // Key the effect on the SPECIFICATION by value, not on prop identity. A
85
+ // parent re-render creates fresh object literals every time; depending on
86
+ // those rebuilt the whole subtree on every keystroke, losing focus, scroll
87
+ // position and animation state.
88
+ const spec = useMemo(
89
+ () => (elements ? JSON.stringify({ elements, nodes, defs }) : null),
90
+ [elements, nodes, defs],
91
+ );
92
+
93
+ // Same problem, different shape: an inline `view={() => …}` is a new
94
+ // function every render. Hold the latest in a ref and rebuild only when the
95
+ // caller's own `deps` say to. Serialised rather than spread, because a
96
+ // dependency array that changes length between renders is a React error.
97
+ const viewRef = useRef(view);
98
+ viewRef.current = view;
99
+ const depsKey = useMemo(() => {
100
+ try { return JSON.stringify(deps); } catch { return String(deps); }
101
+ }, [deps]);
102
+
103
+ useEffect(() => {
104
+ const el = host.current;
105
+ if (!el) return;
106
+
107
+ // Prerendered markup is static: it exists for crawlers and for first
108
+ // paint. The builder still has to run to attach behaviour, so replace it
109
+ // rather than adopt it.
110
+ el.innerHTML = "";
111
+
112
+ if (viewRef.current) {
113
+ // render() with no argument returns a detached node rather than
114
+ // mounting, so nothing escapes this host.
115
+ el.appendChild(viewRef.current().render());
116
+ } else if (elements) {
117
+ const d = new Des();
118
+ if (defs) d.defs(defs);
119
+ d.nodes(nodes)
120
+ .add(elements)
121
+ .set({ mount: "#" + domId, code: false, elements: false, layout: false });
122
+
123
+ // Des.set() appends a <pre> and a <textarea id="elements"> to
124
+ // document.body — the on-page code panel. `code: false` only hides them,
125
+ // so without this every mount leaks two nodes and every instance after
126
+ // the first duplicates id="elements". Reaching for the instance's own
127
+ // handles removes exactly what this render created, rather than querying
128
+ // the page for the first match.
129
+ d._preEl?.remove();
130
+ d._codeEl?.remove();
131
+ }
132
+
133
+ return () => {
134
+ el.innerHTML = "";
135
+ };
136
+ // `spec` and `depsKey` cover the inputs by value; that is the point.
137
+ // eslint-disable-next-line react-hooks/exhaustive-deps
138
+ }, [spec, depsKey, domId]);
139
+
140
+ return createElement(
141
+ Fragment,
142
+ null,
143
+ // A prerenderer writes HTML into this div AFTER React has rendered it, so
144
+ // React's virtual tree says "empty" while the DOM says otherwise.
145
+ // suppressHydrationWarning is not enough — it covers attributes and text,
146
+ // not extra element children, and hydration fails with React #418/#423
147
+ // and silently re-renders the whole root on the client. An empty
148
+ // dangerouslySetInnerHTML is the documented escape for externally-managed
149
+ // DOM: React stops reconciling this subtree entirely, which is exactly
150
+ // the contract wanted. It also means the built output survives every
151
+ // subsequent React render, since the prop value never changes.
152
+ createElement("div", {
153
+ id: domId,
154
+ ref: host,
155
+ className,
156
+ style,
157
+ suppressHydrationWarning: true,
158
+ dangerouslySetInnerHTML: EMPTY_HTML,
159
+ }),
160
+ // A specification travels with the page so a prerenderer can find it
161
+ // without knowing anything about the app's component tree. A `view` has
162
+ // nothing to emit here — code does not cross the build boundary. '<' is
163
+ // escaped so a string containing </script> cannot close it.
164
+ spec &&
165
+ createElement("script", {
166
+ type: "application/json",
167
+ "data-nodality-for": domId,
168
+ dangerouslySetInnerHTML: { __html: spec.replace(/</g, "\\u003c") },
169
+ }),
170
+ );
171
+ }
172
+
173
+ export default Nodality;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
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.3.24
2
+ * nodality v1.3.26
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.3.24
2
+ * nodality v1.3.26
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.3.24
2
+ * nodality v1.3.26
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.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
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.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * nodality v1.3.24
2
+ * nodality v1.3.26
3
3
  * (c) 2026 Filip Vabrousek
4
4
  * License: MIT
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodality",
3
- "version": "1.3.24",
3
+ "version": "1.3.26",
4
4
  "description": "A lightweight library for declarative UI elements.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -39,7 +39,12 @@
39
39
  "./inspect": "./lib/raster-inspect.js",
40
40
  "./examples/*": "./examples/*.js",
41
41
  "./transition": "./lib/transition.js",
42
- "./designer": "./lib/designer.js"
42
+ "./designer": "./lib/designer.js",
43
+ "./react": {
44
+ "types": "./lib/react.d.ts",
45
+ "import": "./lib/react.js",
46
+ "default": "./lib/react.js"
47
+ }
43
48
  },
44
49
  "publishConfig": {
45
50
  "access": "public",
@@ -91,8 +96,18 @@
91
96
  "babel-loader": "^10.0.0",
92
97
  "jsdom": "^29.1.1",
93
98
  "playwright": "^1.54.1",
99
+ "react": "19.2.4",
100
+ "react-dom": "19.2.4",
94
101
  "serve": "^14.2.6",
95
102
  "webpack-cli": "^6.0.1"
96
103
  },
97
- "types": "dist/index.d.ts"
104
+ "types": "dist/index.d.ts",
105
+ "peerDependencies": {
106
+ "react": ">=18"
107
+ },
108
+ "peerDependenciesMeta": {
109
+ "react": {
110
+ "optional": true
111
+ }
112
+ }
98
113
  }