nuclo 0.2.17 → 0.2.18

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 (2) hide show
  1. package/README.md +24 -7
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # nuclo
2
2
 
3
- **A lightweight, imperative DOM framework with explicit updates.**
3
+ **A lightweight DOM framework with reactive UI bindings, mutable state, and explicit updates.**
4
4
 
5
- Build interactive UIs with plain functions, mutable JavaScript objects, and explicit `update()` calls. Nuclo is imperative: nothing re-renders until you call `update()`. No virtual DOM, no proxies, and no hidden state tracking.
5
+ Create elements with plain functions, and pass a function anywhere a value depends on state — that registers a reactive binding Nuclo can reevaluate later. Mutate regular JavaScript values directly, then call `update()` when you want Nuclo to synchronize the DOM. No virtual DOM, no proxies, and no automatic state tracking.
6
+
7
+ Nuclo's workflow has three parts:
8
+
9
+ 1. **Create the UI with builder functions** — text, attributes, conditions, and lists can be passed a function whenever they depend on state; this registers a reactive binding.
10
+ 2. **Mutate regular JavaScript state** — no signals, no proxies, no wrapped values. `count++` is just `count++`. Mutating state does not, by itself, touch the DOM.
11
+ 3. **Call `update()`** — this explicitly triggers synchronization: Nuclo reevaluates the bindings registered in step 1 and patches the real DOM wherever a result changed.
6
12
 
7
13
  ```ts
8
14
  import 'nuclo';
@@ -22,12 +28,13 @@ render(counter, document.body);
22
28
 
23
29
  ## Why nuclo?
24
30
 
25
- - **Explicit and Predictable** – You control when updates happen with a simple `update()` call
26
- - **Direct DOM Manipulation** – Work directly with the DOM, no virtual layer in between
27
- - **Tiny Footprint** – ~10 KB gzipped, zero dependencies
31
+ - **Reactive UI Bindings** – Pass a function for any text, attribute, condition, or list that depends on state; Nuclo can reevaluate it later
32
+ - **Explicit and Predictable** – Reevaluation doesn't happen on mutation — you trigger it yourself with a simple `update()` call
33
+ - **Real DOM, No Virtual Layer** – Nuclo creates and updates real DOM nodes directly; there's no virtual DOM to diff
34
+ - **Tiny Footprint** – ~13 KB gzipped, zero dependencies
28
35
  - **Global Tag Builders** – Natural API with global functions for all HTML and SVG elements
29
36
  - **TypeScript-First** – Full type definitions for all 175 HTML and SVG builders
30
- - **Targeted DOM Updates** – `update()` re-runs dynamic bindings and only touches DOM where values changed
37
+ - **Targeted DOM Updates** – `update()` re-runs registered bindings and only touches DOM where values changed
31
38
  - **Atomic Styling** – Built-in `css()` / `createCss()` with TypeScript autocomplete, theming, and SSR CSS collection
32
39
  - **Server-Side Rendering** – `renderToString()` + `hydrate()` with a lightweight DOM polyfill
33
40
 
@@ -303,6 +310,16 @@ render(app, document.body);
303
310
 
304
311
  ## Core Concepts
305
312
 
313
+ **The mental model:**
314
+
315
+ 1. Create the UI with builder functions — `h1(...)`, `when()`, `list()`.
316
+ 2. Use functions for values that depend on state — `h1(() => \`Count: ${count}\`)`. This registers a reactive binding.
317
+ 3. Mutate regular JavaScript state — `count++`.
318
+ 4. Call `update()`.
319
+ 5. Nuclo reevaluates registered bindings and applies the changes to the existing DOM.
320
+
321
+ State mutation and the `update()` call are plain JavaScript: you write `count++` and call `update()` yourself. Nuclo does not watch your variables — nothing reevaluates until `update()` runs. This is explicitly triggered reactivity, not automatic reactivity: the binding from step 2 stays reactive (it can be reevaluated), but only `update()` starts that reevaluation.
322
+
306
323
  ### 1. **Explicit Updates**
307
324
 
308
325
  nuclo doesn't auto-detect changes. You call `update()` when ready:
@@ -344,7 +361,7 @@ user.name = 'Alice'; // triggers update
344
361
 
345
362
  ### 2. **Dynamic Functions**
346
363
 
347
- Zero-arg functions become dynamic bindings that re-run when you call `update()`:
364
+ Zero-arg functions become reactive bindings: Nuclo keeps them registered and can reevaluate them, but only when you call `update()` — mutating the state they read does nothing on its own:
348
365
 
349
366
  ```ts
350
367
  let count = 0;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "nuclo",
3
3
  "private": false,
4
- "version": "0.2.17",
5
- "description": "Lightweight reactive DOM library with global tag builders, SSR, hydration, and atomic CSS — no virtual DOM, no compiler.",
4
+ "version": "0.2.18",
5
+ "description": "Lightweight DOM library with reactive UI bindings, mutable state, and explicit updates — global tag builders, SSR, hydration, and atomic CSS, no virtual DOM, no compiler.",
6
6
  "license": "MIT",
7
7
  "author": "Danilo Celestino de Castro (https://github.com/dan2dev)",
8
8
  "keywords": [