@rip-lang/ui 0.3.13 → 0.3.14

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 +66 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -45,6 +45,72 @@ export Home = component
45
45
 
46
46
  Run `bun index.rip`, open `http://localhost:3000`.
47
47
 
48
+ ## The Two Keywords
49
+
50
+ Rip UI adds two keywords to the language: `component` and `render`. Each
51
+ serves a distinct role, and together they form a complete reactive UI model.
52
+
53
+ ### `component` — the model
54
+
55
+ Raw Rip Lang has no concept of a self-contained, reusable UI unit. The
56
+ `component` keyword adds everything needed to manage interactive state:
57
+
58
+ - **Reactive state** (`:=`) — assignments create signals that trigger
59
+ updates automatically. `count := 0` is not a plain variable; changing
60
+ it updates the DOM.
61
+ - **Computed values** (`~=`) — derived values that recalculate when their
62
+ dependencies change. `remaining ~= todos.filter((t) -> not t.done).length`
63
+ - **Effects** (`~>`) — side effects that run whenever reactive dependencies
64
+ change. `~> @app.data.count = count`
65
+ - **Props** (`@` prefix, `=!` for readonly) — a public API for parent
66
+ components to pass data in, with signal passthrough for shared reactivity.
67
+ - **Lifecycle hooks** — `beforeMount`, `mounted`, `updated`, `beforeUnmount`,
68
+ `unmounted` for running code at specific points in a component's life.
69
+ - **Context API** — `setContext` and `getContext` for ancestor-to-descendant
70
+ data sharing without prop drilling.
71
+ - **Mount/unmount mechanics** — attaching to the DOM, cascading teardown
72
+ to children, and keep-alive caching across navigation.
73
+ - **Encapsulation** — each component is a class with its own scope, state,
74
+ and methods. No global variable collisions, no leaking internals.
75
+
76
+ A component without a render block can still hold state, run effects, and
77
+ participate in the component tree — it just has no visual output.
78
+
79
+ ### `render` — the view
80
+
81
+ The `render` keyword provides a declarative template DSL for describing DOM
82
+ structure. It has its own lexer pass and syntax rules distinct from regular
83
+ Rip code:
84
+
85
+ - **Element creation** — tag names become DOM nodes: `div`, `h1`, `button`
86
+ - **CSS-selector shortcuts** — `div.card.active`, `#main`, `.card` (implicit `div`)
87
+ - **Dynamic classes** — `div.('card', active && 'active')` with CLSX semantics
88
+ - **Event handlers** — `@click: handler` compiles to `addEventListener`
89
+ - **Two-way binding** — `value <=> username` wires reactive read and write
90
+ - **Conditionals and loops** — `if`/`else` and `for item in items` with
91
+ anchor-based DOM insertion and keyed reconciliation
92
+ - **Children/slots** — `@children` receives child nodes, `#content` marks
93
+ layout insertion points
94
+ - **Component instantiation** — PascalCase names like `Card title: "Hello"`
95
+ resolve to components automatically, no imports needed
96
+
97
+ Render compiles to two methods: `_create()` builds the DOM tree once, and
98
+ `_setup()` wires reactive effects for fine-grained updates. There is no
99
+ virtual DOM — each reactive binding creates a direct DOM effect that updates
100
+ the specific text node or attribute that depends on it.
101
+
102
+ A render block can only exist inside a component. It needs the component's
103
+ signals, computed values, and lifecycle to have something to render and
104
+ react to.
105
+
106
+ ### Together
107
+
108
+ `component` provides the **model** — state, reactivity, lifecycle, identity.
109
+ `render` provides the **view** — a concise way to describe what the DOM
110
+ should look like and how it stays in sync with that state. One defines
111
+ behavior, the other defines structure. Neither is useful without the other
112
+ in practice, but they are separate concerns with separate syntax.
113
+
48
114
  ## Component Composition
49
115
 
50
116
  Page components in `pages/` map to routes via file-based routing. Shared
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/ui",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "description": "Zero-build reactive web framework — rip.js + ui.rip + launch(url)",
5
5
  "type": "module",
6
6
  "main": "ui.rip",
@@ -39,7 +39,7 @@
39
39
  "README.md"
40
40
  ],
41
41
  "peerDependencies": {
42
- "@rip-lang/api": ">=1.1.6"
42
+ "@rip-lang/api": ">=1.1.10"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@rip-lang/api": {