@lipsjs/lips 0.1.1 → 0.2.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.
- package/README.md +119 -85
- package/dist/lips.js +3836 -0
- package/dist/lips.js.map +28 -0
- package/dist/lips.min.js +9 -2
- package/dist/lips.min.js.map +22 -43
- package/dist/precompile.min.js +20 -0
- package/dist/precompile.min.js.map +13 -0
- package/dist/runtime.min.js +4 -0
- package/dist/runtime.min.js.map +19 -0
- package/dist/types/events.d.ts +1 -1
- package/dist/types/ir/compiler.d.ts +153 -0
- package/dist/types/ir/expression.d.ts +120 -0
- package/dist/types/ir/facade.d.ts +94 -0
- package/dist/types/ir/index.d.ts +15 -0
- package/dist/types/ir/parser.d.ts +124 -0
- package/dist/types/ir/router.d.ts +47 -0
- package/dist/types/ir/runtime.d.ts +95 -0
- package/dist/types/ir/signal.d.ts +26 -0
- package/dist/types/ir/swap.d.ts +23 -0
- package/dist/types/lips.d.ts +16 -37
- package/dist/types/precompile.d.ts +60 -0
- package/dist/types/runtime.d.ts +16 -0
- package/dist/types/stylesheet.d.ts +24 -40
- package/dist/types/types.d.ts +49 -185
- package/package.json +29 -10
- package/dist/test.component.min.js +0 -3
- package/dist/test.component.min.js.map +0 -50
- package/dist/test.stress.min.js +0 -476
- package/dist/test.stress.min.js.map +0 -50
- package/dist/types/component.d.ts +0 -107
- package/dist/types/constants.d.ts +0 -23
- package/dist/types/dws.d.ts +0 -14
- package/dist/types/iuc/index.d.ts +0 -25
- package/dist/types/iuc/tick.d.ts +0 -38
- package/dist/types/iuc.d.ts +0 -25
- package/dist/types/metrics.d.ts +0 -50
- package/dist/types/preprocess.d.ts +0 -2
- package/dist/types/signal.d.ts +0 -30
- package/dist/types/syntax/async.d.ts +0 -16
- package/dist/types/syntax/for.d.ts +0 -25
- package/dist/types/syntax/if.d.ts +0 -14
- package/dist/types/syntax/router.d.ts +0 -40
- package/dist/types/syntax/switch.d.ts +0 -16
- package/dist/types/tick.d.ts +0 -38
- package/dist/types/tps.d.ts +0 -11
- package/dist/types/uqs.d.ts +0 -37
- package/dist/types/utils.d.ts +0 -25
package/README.md
CHANGED
|
@@ -1,51 +1,53 @@
|
|
|
1
|
-
# Lips
|
|
1
|
+
# Lips — Fast, Lightweight Reactive UI Framework
|
|
2
2
|
|
|
3
|
-
Lips is a
|
|
3
|
+
Lips is a runtime, fine-grained reactive UI framework with an HTML-native template
|
|
4
|
+
syntax. Import it and build — **no build step required** — or precompile your templates
|
|
5
|
+
ahead of time for CSP-safe, parse-free startup.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Under the hood a template compiles to a small **IR** (intermediate representation): the
|
|
8
|
+
DOM is cloned from static skeletons and each binding is its own effect over per-key
|
|
9
|
+
signals, so a state change updates only what actually read it — no virtual DOM, no diffing.
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
11
|
+
```
|
|
12
|
+
template string ──parse──▶ AST ──compile──▶ IR ──render──▶ DOM
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## ✨ Highlights
|
|
16
|
+
|
|
17
|
+
- **Zero build step** — import and go; templates render at runtime
|
|
18
|
+
- **Fine-grained reactivity** — per-key signals; updates are O(bindings that changed)
|
|
19
|
+
- **HTML-native syntax** — element-shaped control flow (`<if>`, `<for>`, `<switch>`, `<async>`), not an attribute DSL
|
|
20
|
+
- **Tiny** — ~21 KB gzip full, ~12 KB gzip precompiled-only, one dependency
|
|
21
|
+
- **Serializable components** — a template is a plain object; the compiled IR is JSON
|
|
22
|
+
- **Precompile + CSP mode** — build templates to IR; run with no `eval`/`Function` under a strict CSP
|
|
23
|
+
- **Hot-swap** — `instance.swap(newIR)` re-renders only what changed, preserving state
|
|
24
|
+
- **Batteries included** — router, i18n, macros, scoped styles, slots, component events
|
|
25
|
+
- **TypeScript** — full type definitions
|
|
16
26
|
|
|
17
|
-
## 🚀 Quick
|
|
27
|
+
## 🚀 Quick start
|
|
18
28
|
|
|
19
29
|
```html
|
|
20
30
|
<!DOCTYPE html>
|
|
21
31
|
<html>
|
|
22
|
-
<head>
|
|
23
|
-
<title>My Lips App</title>
|
|
24
|
-
</head>
|
|
25
32
|
<body>
|
|
26
33
|
<div id="app"></div>
|
|
27
|
-
|
|
34
|
+
|
|
28
35
|
<script type="module">
|
|
29
|
-
// Import from CDN directly in the module script
|
|
30
36
|
import Lips from 'https://cdn.jsdelivr.net/npm/@lipsjs/lips'
|
|
31
37
|
|
|
32
|
-
const lips = new Lips()
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const counter = {
|
|
38
|
+
const lips = new Lips()
|
|
39
|
+
|
|
40
|
+
lips.root({
|
|
36
41
|
state: { count: 0 },
|
|
37
42
|
handler: {
|
|
38
|
-
increment()
|
|
43
|
+
increment(){ this.state.count++ }
|
|
39
44
|
},
|
|
40
45
|
default: `
|
|
41
46
|
<div>
|
|
42
47
|
<h2>Count: {state.count}</h2>
|
|
43
48
|
<button on-click(increment)>Increment</button>
|
|
44
|
-
</div
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
lips.root(counter, '#app');
|
|
49
|
+
</div>`
|
|
50
|
+
}, '#app')
|
|
49
51
|
</script>
|
|
50
52
|
</body>
|
|
51
53
|
</html>
|
|
@@ -53,91 +55,123 @@ Lips is a modern, runtime-based UI framework that brings fine-grained reactivity
|
|
|
53
55
|
|
|
54
56
|
## 📦 Installation
|
|
55
57
|
|
|
56
|
-
### Via NPM
|
|
57
|
-
|
|
58
58
|
```bash
|
|
59
59
|
npm install @lipsjs/lips
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
```js
|
|
63
|
+
import Lips from '@lipsjs/lips'
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Entry points
|
|
67
|
+
|
|
68
|
+
| Import | Contents | gzip |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `@lipsjs/lips` | full: runtime + parser/compiler + styles + router | ~21 KB |
|
|
71
|
+
| `@lipsjs/lips/runtime` | precompiled-only: no parser/compiler (CSP-friendly) | ~12 KB |
|
|
72
|
+
| `@lipsjs/lips/precompile` | build-time helpers + Vite/Rollup plugin | — |
|
|
73
|
+
| `@lipsjs/lips/dev` | unminified full build | — |
|
|
74
|
+
|
|
75
|
+
## 🧩 Template syntax
|
|
63
76
|
|
|
64
77
|
```html
|
|
65
|
-
|
|
78
|
+
<!-- interpolation & attributes -->
|
|
79
|
+
<p title=state.title>Hello {state.name}!</p>
|
|
80
|
+
|
|
81
|
+
<!-- events: named handler (+args) or inline arrow -->
|
|
82
|
+
<button on-click(select, item.id)>pick</button>
|
|
83
|
+
<button on-click(() => state.count++)>+</button>
|
|
84
|
+
|
|
85
|
+
<!-- conditionals -->
|
|
86
|
+
<if(state.ready)>…</if>
|
|
87
|
+
<else-if(state.loading)>…</else-if>
|
|
88
|
+
<else>…</else>
|
|
89
|
+
|
|
90
|
+
<!-- keyed lists: node identity & child state survive reorders -->
|
|
91
|
+
<for [item, i] in=state.items by="id">
|
|
92
|
+
<li>{i}: {item.label}</li>
|
|
93
|
+
</for>
|
|
94
|
+
|
|
95
|
+
<!-- switch, async, scoped vars, dynamic tags -->
|
|
96
|
+
<switch(state.tab)><case is="a">…</case><default>…</default></switch>
|
|
97
|
+
<async await(context.load())><loading>…</loading><then [data]>…</then><catch [e]>…</catch></async>
|
|
98
|
+
<let doubled={ state.n * 2 }/>
|
|
99
|
+
<{state.page} params=state.params/>
|
|
66
100
|
```
|
|
67
101
|
|
|
68
|
-
|
|
102
|
+
Components compose with **slots** (`<{input.renderer}/>`) and **events**
|
|
103
|
+
(`this.emit('picked', …)` → parent `on-picked(...)`). Full lifecycle:
|
|
104
|
+
`onCreate · onInput · onMount · onRender · onUpdate · onAttach · onDetach · onContext ·
|
|
105
|
+
onError · onDestroy`.
|
|
69
106
|
|
|
70
|
-
|
|
107
|
+
## ⚡ Precompile & CSP
|
|
71
108
|
|
|
72
|
-
|
|
109
|
+
Compile templates to IR at build time — no runtime parsing, and with
|
|
110
|
+
`mode: 'interpreted'` no `eval`/`Function`, so the app runs under `script-src` without
|
|
111
|
+
`unsafe-eval`.
|
|
73
112
|
|
|
74
|
-
|
|
113
|
+
```js
|
|
114
|
+
import { precompile } from '@lipsjs/lips/precompile'
|
|
115
|
+
const card = precompile({ state: {/*…*/}, default: `<div>…</div>` }).template // { ir, state, … }
|
|
116
|
+
```
|
|
75
117
|
|
|
76
|
-
|
|
118
|
+
Or let the bundler do it (Vite/Rollup) for `.lips` single-file components:
|
|
77
119
|
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
120
|
+
```js
|
|
121
|
+
// vite.config.js
|
|
122
|
+
import { lipsPlugin } from '@lipsjs/lips/precompile'
|
|
123
|
+
export default { plugins: [ lipsPlugin() ] }
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
import Card from './card.lips' // already-compiled IR
|
|
128
|
+
lips.register('card', Card)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 🔥 Hot-swap
|
|
132
|
+
|
|
133
|
+
Re-render a live component against a revised template, keeping component state:
|
|
82
134
|
|
|
83
|
-
|
|
84
|
-
|
|
135
|
+
```js
|
|
136
|
+
const app = lips.render('editor', template).appendTo('#app')
|
|
137
|
+
const { changes } = app.swap(newIR) // patches only what differs
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 📖 Documentation
|
|
141
|
+
|
|
142
|
+
[Full Lips documentation](https://lips-js.github.io)
|
|
85
143
|
|
|
86
|
-
|
|
87
|
-
# If not: curl -fsSL https://bun.sh/install | bash
|
|
144
|
+
## 🏗️ Building from source
|
|
88
145
|
|
|
89
|
-
|
|
90
|
-
bun run dev
|
|
146
|
+
Developed with [Bun](https://bun.sh).
|
|
91
147
|
|
|
92
|
-
|
|
93
|
-
|
|
148
|
+
```bash
|
|
149
|
+
git clone https://github.com/fabrice8/lips.git
|
|
150
|
+
cd lips
|
|
151
|
+
bun install
|
|
94
152
|
|
|
95
|
-
#
|
|
96
|
-
bun run build
|
|
153
|
+
bun run dev # watch build
|
|
154
|
+
bun run build # production bundles
|
|
155
|
+
bun run test # test suite
|
|
156
|
+
bun run size # size-budget check
|
|
97
157
|
```
|
|
98
158
|
|
|
99
159
|
## 🤝 Contributing
|
|
100
160
|
|
|
101
|
-
Contributions
|
|
102
|
-
|
|
103
|
-
1. **Fork the repository**
|
|
104
|
-
2. **Create a feature branch**:
|
|
105
|
-
```bash
|
|
106
|
-
git checkout -b feature/amazing-feature
|
|
107
|
-
```
|
|
108
|
-
3. **Commit your changes**:
|
|
109
|
-
```bash
|
|
110
|
-
git commit -m 'Add some amazing feature'
|
|
111
|
-
```
|
|
112
|
-
4. **Push to the branch**:
|
|
113
|
-
```bash
|
|
114
|
-
git push origin feature/amazing-feature
|
|
115
|
-
```
|
|
116
|
-
5. **Open a Pull Request**
|
|
117
|
-
|
|
118
|
-
Please ensure your code follows the existing style and includes appropriate tests.
|
|
119
|
-
|
|
120
|
-
### Development Guidelines
|
|
121
|
-
|
|
122
|
-
- Ensure you have [Bun](https://bun.sh) installed for development
|
|
123
|
-
- Follow the TypeScript coding style
|
|
124
|
-
- Add unit tests for new features
|
|
125
|
-
- Maintain the zero-build philosophy for runtime usage
|
|
126
|
-
- Update documentation for any new features or changes
|
|
161
|
+
Contributions welcome — fork, branch, and open a PR. Please keep the runtime dependency
|
|
162
|
+
footprint small, add tests for new behavior, and run `bun run test` before submitting.
|
|
127
163
|
|
|
128
164
|
## 📄 License
|
|
129
165
|
|
|
130
|
-
|
|
166
|
+
MIT — see [LICENSE](LICENSE).
|
|
131
167
|
|
|
132
168
|
## 🙏 Acknowledgements
|
|
133
169
|
|
|
134
|
-
- [Bun](https://bun.sh)
|
|
135
|
-
- [
|
|
136
|
-
- [
|
|
137
|
-
- [
|
|
138
|
-
- [SolidJS](https://github.com/solidjs/solid) for the signal based reactivity concept.
|
|
139
|
-
- All contributors who have helped make Lips better
|
|
170
|
+
- [Bun](https://bun.sh) — runtime & bundler
|
|
171
|
+
- [Stylis](https://github.com/thysultan/stylis) — CSS preprocessor
|
|
172
|
+
- [MarkoJS](https://github.com/marko-js/marko) — inspiring template syntax
|
|
173
|
+
- [SolidJS](https://github.com/solidjs/solid) — signal-based fine-grained reactivity
|
|
140
174
|
|
|
141
175
|
---
|
|
142
176
|
|
|
143
|
-
Lips
|
|
177
|
+
Lips — reactive UI without the complexity. Created with ❤️ by [Fabrice K.E.M](https://github.com/fabrice8)
|