bitwrench 2.0.22 → 2.0.24
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/LICENSE.txt +1 -1
- package/README.md +4 -3
- package/bin/bwmcp.js +3 -0
- package/dist/bitwrench-bccl.cjs.js +1 -1
- package/dist/bitwrench-bccl.cjs.min.js +1 -1
- package/dist/bitwrench-bccl.cjs.min.js.gz +0 -0
- package/dist/bitwrench-bccl.esm.js +1 -1
- package/dist/bitwrench-bccl.esm.min.js +1 -1
- package/dist/bitwrench-bccl.esm.min.js.gz +0 -0
- package/dist/bitwrench-bccl.umd.js +1 -1
- package/dist/bitwrench-bccl.umd.min.js +1 -1
- package/dist/bitwrench-bccl.umd.min.js.gz +0 -0
- package/dist/bitwrench-code-edit.cjs.js +1 -1
- package/dist/bitwrench-code-edit.cjs.min.js +1 -1
- package/dist/bitwrench-code-edit.es5.js +1 -1
- package/dist/bitwrench-code-edit.es5.min.js +1 -1
- package/dist/bitwrench-code-edit.esm.js +1 -1
- package/dist/bitwrench-code-edit.esm.min.js +1 -1
- package/dist/bitwrench-code-edit.umd.js +1 -1
- package/dist/bitwrench-code-edit.umd.min.js +1 -1
- package/dist/bitwrench-code-edit.umd.min.js.gz +0 -0
- package/dist/bitwrench-debug.js +1 -1
- package/dist/bitwrench-debug.min.js +1 -1
- package/dist/bitwrench-lean.cjs.js +3 -3
- package/dist/bitwrench-lean.cjs.min.js +2 -2
- package/dist/bitwrench-lean.cjs.min.js.gz +0 -0
- package/dist/bitwrench-lean.es5.js +3 -3
- package/dist/bitwrench-lean.es5.min.js +2 -2
- package/dist/bitwrench-lean.es5.min.js.gz +0 -0
- package/dist/bitwrench-lean.esm.js +3 -3
- package/dist/bitwrench-lean.esm.min.js +2 -2
- package/dist/bitwrench-lean.esm.min.js.gz +0 -0
- package/dist/bitwrench-lean.umd.js +3 -3
- package/dist/bitwrench-lean.umd.min.js +2 -2
- package/dist/bitwrench-lean.umd.min.js.gz +0 -0
- package/dist/bitwrench-util-css.cjs.js +1 -1
- package/dist/bitwrench-util-css.cjs.min.js +1 -1
- package/dist/bitwrench-util-css.es5.js +1 -1
- package/dist/bitwrench-util-css.es5.min.js +1 -1
- package/dist/bitwrench-util-css.esm.js +1 -1
- package/dist/bitwrench-util-css.esm.min.js +1 -1
- package/dist/bitwrench-util-css.umd.js +1 -1
- package/dist/bitwrench-util-css.umd.min.js +1 -1
- package/dist/bitwrench-util-css.umd.min.js.gz +0 -0
- package/dist/bitwrench.cjs.js +3 -3
- package/dist/bitwrench.cjs.min.js +2 -2
- package/dist/bitwrench.cjs.min.js.gz +0 -0
- package/dist/bitwrench.css +1 -1
- package/dist/bitwrench.es5.js +3 -3
- package/dist/bitwrench.es5.min.js +2 -2
- package/dist/bitwrench.es5.min.js.gz +0 -0
- package/dist/bitwrench.esm.js +3 -3
- package/dist/bitwrench.esm.min.js +2 -2
- package/dist/bitwrench.esm.min.js.gz +0 -0
- package/dist/bitwrench.umd.js +3 -3
- package/dist/bitwrench.umd.min.js +2 -2
- package/dist/bitwrench.umd.min.js.gz +0 -0
- package/dist/builds.json +65 -65
- package/dist/bwserve.cjs.js +2 -2
- package/dist/bwserve.esm.js +2 -2
- package/dist/sri.json +45 -45
- package/docs/README.md +76 -0
- package/docs/app-patterns.md +264 -0
- package/docs/bitwrench-mcp.md +426 -0
- package/docs/bitwrench_api.md +2232 -0
- package/docs/bw-attach.md +399 -0
- package/docs/bwserve.md +841 -0
- package/docs/cli.md +307 -0
- package/docs/component-cheatsheet.md +144 -0
- package/docs/component-library.md +1099 -0
- package/docs/framework-translation-table.md +33 -0
- package/docs/llm-bitwrench-guide.md +672 -0
- package/docs/routing.md +562 -0
- package/docs/state-management.md +767 -0
- package/docs/taco-format.md +373 -0
- package/docs/theming.md +309 -0
- package/docs/thinking-in-bitwrench.md +1457 -0
- package/docs/tutorial-bwserve.md +297 -0
- package/docs/tutorial-embedded.md +314 -0
- package/docs/tutorial-website.md +255 -0
- package/package.json +11 -3
- package/readme.html +5 -4
- package/src/mcp/knowledge.js +231 -0
- package/src/mcp/live.js +226 -0
- package/src/mcp/server.js +216 -0
- package/src/mcp/tools.js +369 -0
- package/src/mcp/transport.js +55 -0
- package/src/version.js +3 -3
package/docs/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Bitwrench Documentation
|
|
2
|
+
|
|
3
|
+
These guides cover how to build UIs with bitwrench.
|
|
4
|
+
|
|
5
|
+
## What to Read
|
|
6
|
+
|
|
7
|
+
| Question | Guide |
|
|
8
|
+
|----------|-------|
|
|
9
|
+
| What components does bitwrench have? | [Component Cheat Sheet](component-cheatsheet.md) |
|
|
10
|
+
| How do I build a page? | [Building a Website tutorial](tutorial-website.md) |
|
|
11
|
+
| How does TACO work? | [TACO Format](taco-format.md) or [Thinking in Bitwrench](thinking-in-bitwrench.md) |
|
|
12
|
+
| How do I add interactivity? | [State Management](state-management.md) |
|
|
13
|
+
| How do I theme my app? | [Theming](theming.md) |
|
|
14
|
+
| I'm an LLM generating bitwrench code | [LLM Guide](llm-bitwrench-guide.md) |
|
|
15
|
+
| How do I use bwmcp with an AI agent? | [bwmcp MCP Server](bitwrench-mcp.md) |
|
|
16
|
+
| Full API with signatures? | [API Reference](bitwrench_api.md) |
|
|
17
|
+
|
|
18
|
+
## Start Here
|
|
19
|
+
|
|
20
|
+
- **[Thinking in Bitwrench](thinking-in-bitwrench.md)** -- The complete guide to building with bitwrench. Covers TACO basics, styling (`bw.css`, `bw.s`, `bw.responsive`), composition, the three-level component model, events (and why `onclick` goes in `a:`, not `o.mounted`), bwserve, and common patterns. **Read this first.**
|
|
21
|
+
- **[LLM Guide](llm-bitwrench-guide.md)** -- Compact single-file reference for AI-assisted development. All APIs, patterns, and rules in one document. Also useful as a quick-reference cheat sheet for humans.
|
|
22
|
+
|
|
23
|
+
## Guides
|
|
24
|
+
|
|
25
|
+
| Guide | Description |
|
|
26
|
+
|-------|-------------|
|
|
27
|
+
| [Thinking in Bitwrench](thinking-in-bitwrench.md) | Design philosophy: why TACO exists, component model vs. DOM templates |
|
|
28
|
+
| [TACO Format](taco-format.md) | The `{t, a, c, o}` object format that bitwrench uses for everything |
|
|
29
|
+
| [State Management](state-management.md) | Three-level component model, reactive state, cross-component communication |
|
|
30
|
+
| [Component Cheat Sheet](component-cheatsheet.md) | Scannable table of all 50+ components with capabilities and handles |
|
|
31
|
+
| [Component Library](component-library.md) | All 50+ `make*()` functions with full signatures and examples |
|
|
32
|
+
| [Routing](routing.md) | Client-side router: hash/history mode, route params, guards, pub/sub |
|
|
33
|
+
| [Theming](theming.md) | Palette-driven theme generation, presets, design tokens |
|
|
34
|
+
| [CLI](cli.md) | The `bwcli` command: file conversion, themes, standalone pages |
|
|
35
|
+
| [bwserve](bwserve.md) | Server-driven UI: SSE protocol, pipe server, embedded devices, relaxed JSON |
|
|
36
|
+
| [bwcli attach](bw-attach.md) | Remote debugging REPL: terminal-based inspector for any bitwrench page |
|
|
37
|
+
| [App Patterns](app-patterns.md) | Canonical project layouts: dashboard, SPA, bwserve, embedded, static site |
|
|
38
|
+
| [LLM Guide](llm-bitwrench-guide.md) | Compact single-file reference for AI-assisted development |
|
|
39
|
+
| [bwmcp MCP Server](bitwrench-mcp.md) | MCP server for AI agents: tool catalog, live rendering, screenshots |
|
|
40
|
+
|
|
41
|
+
## Tutorials
|
|
42
|
+
|
|
43
|
+
| Tutorial | Description |
|
|
44
|
+
|----------|-------------|
|
|
45
|
+
| [Building a Website](tutorial-website.md) | Build a complete landing page from scratch |
|
|
46
|
+
| [Server App with bwserve](tutorial-bwserve.md) | Build a Streamlit-style server-driven dashboard |
|
|
47
|
+
| [ESP32 Embedded](tutorial-embedded.md) | ESP32 IoT dashboard with C/C++ macros |
|
|
48
|
+
|
|
49
|
+
## Interactive Docs
|
|
50
|
+
|
|
51
|
+
The [live documentation site](https://deftio.github.io/bitwrench/pages/) has interactive examples:
|
|
52
|
+
|
|
53
|
+
- [Quick Start](https://deftio.github.io/bitwrench/pages/00-quick-start.html)
|
|
54
|
+
- [Components](https://deftio.github.io/bitwrench/pages/01-components.html)
|
|
55
|
+
- [Tables & Forms](https://deftio.github.io/bitwrench/pages/02-tables-forms.html)
|
|
56
|
+
- [Styling](https://deftio.github.io/bitwrench/pages/03-styling.html)
|
|
57
|
+
- [Dashboard](https://deftio.github.io/bitwrench/pages/04-dashboard.html)
|
|
58
|
+
- [State & Interactivity](https://deftio.github.io/bitwrench/pages/05-state.html)
|
|
59
|
+
- [Framework Comparison](https://deftio.github.io/bitwrench/pages/07-framework-comparison.html)
|
|
60
|
+
- [Themes](https://deftio.github.io/bitwrench/pages/10-themes.html)
|
|
61
|
+
- [Debugging](https://deftio.github.io/bitwrench/pages/11-debugging.html)
|
|
62
|
+
- [bwserve Protocol](https://deftio.github.io/bitwrench/pages/12-bwserve-protocol.html)
|
|
63
|
+
- [bwserve Sandbox](https://deftio.github.io/bitwrench/pages/bwserve-sandbox.html)
|
|
64
|
+
|
|
65
|
+
## Key Concepts
|
|
66
|
+
|
|
67
|
+
Bitwrench describes UI as plain JavaScript objects. There is no JSX, no templates, no virtual DOM, and no compile step required. A button is a JavaScript object. A page layout is a JavaScript object. You compose them with arrays and functions — standard language features.
|
|
68
|
+
|
|
69
|
+
The library provides four things:
|
|
70
|
+
|
|
71
|
+
1. **A rendering engine** that turns objects into HTML or DOM
|
|
72
|
+
2. **A component library** of 50+ ready-made UI elements
|
|
73
|
+
3. **A reactivity system** that updates the DOM when state changes
|
|
74
|
+
4. **A client-side router** that maps URLs to views with guards and pub/sub
|
|
75
|
+
|
|
76
|
+
Everything else -- styling, theming, event handling, server communication -- builds on these pieces.
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# App Patterns
|
|
2
|
+
|
|
3
|
+
Five canonical layouts for bitwrench apps. Each section shows when to use it, directory structure, a code skeleton, and state flow.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Pattern 1: Single-Page Dashboard
|
|
8
|
+
|
|
9
|
+
One page, multiple widgets, shared data. Stat cards, tables, and charts react to the same store. Good for monitoring dashboards and admin panels.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
my-dashboard/
|
|
13
|
+
index.html <- loads bitwrench, includes app.js
|
|
14
|
+
app.js <- store, widgets, render functions
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
// app.js
|
|
19
|
+
bw.loadStyles({ primary: '#1e40af', secondary: '#059669' });
|
|
20
|
+
|
|
21
|
+
// Store: plain object + scoped pub/sub
|
|
22
|
+
var store = { users: 128, revenue: 48200, orders: [] };
|
|
23
|
+
|
|
24
|
+
function updateStore(key, value) {
|
|
25
|
+
store[key] = value;
|
|
26
|
+
bw.pub('store:' + key, value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Widgets -- each subscribes to its own data slice
|
|
30
|
+
function renderStats() {
|
|
31
|
+
bw.DOM('#stats', { t: 'div', c: [
|
|
32
|
+
bw.makeStatCard({ label: 'Users', value: store.users }),
|
|
33
|
+
bw.makeStatCard({ label: 'Revenue', value: '$' + store.revenue })
|
|
34
|
+
]});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function renderTable() {
|
|
38
|
+
bw.DOM('#orders', bw.makeTable({ data: store.orders, sortable: true }));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Layout
|
|
42
|
+
bw.DOM('#app', { t: 'div', c: [
|
|
43
|
+
bw.makeNavbar({ brand: 'Dashboard' }),
|
|
44
|
+
{ t: 'div', a: { id: 'stats' } },
|
|
45
|
+
{ t: 'div', a: { id: 'orders' } }
|
|
46
|
+
]});
|
|
47
|
+
|
|
48
|
+
// Wire up
|
|
49
|
+
bw.sub('store:users', renderStats);
|
|
50
|
+
bw.sub('store:revenue', renderStats);
|
|
51
|
+
bw.sub('store:orders', renderTable);
|
|
52
|
+
renderStats();
|
|
53
|
+
renderTable();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**State flow:** `store` is a plain object. `updateStore()` sets values and publishes scoped topics (`store:users`, `store:orders`). Each widget subscribes only to its own topics and re-renders itself. Widgets never read each other -- they read from the shared store. See [state-management.md](state-management.md).
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Pattern 2: Multi-Page SPA
|
|
61
|
+
|
|
62
|
+
Client-side navigation between views with a persistent nav/footer and shared state. URL changes without full page reloads.
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
my-spa/
|
|
66
|
+
index.html
|
|
67
|
+
app.js <- router, nav, footer
|
|
68
|
+
views/
|
|
69
|
+
home.js, users.js, settings.js
|
|
70
|
+
store.js <- shared state
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
// store.js
|
|
75
|
+
var store = { user: { name: 'Alice' }, items: [] };
|
|
76
|
+
function updateStore(key, value) {
|
|
77
|
+
store[key] = value;
|
|
78
|
+
bw.pub('store:' + key, value);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// views/home.js
|
|
82
|
+
function homeView() {
|
|
83
|
+
return { t: 'div', c: [
|
|
84
|
+
bw.makeHero({ title: 'Welcome, ' + store.user.name }),
|
|
85
|
+
bw.makeCard({ title: 'Recent', content: store.items.length + ' items' })
|
|
86
|
+
]};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// views/users.js
|
|
90
|
+
function usersView(params) {
|
|
91
|
+
if (params.id) return bw.makeCard({ title: 'User ' + params.id });
|
|
92
|
+
return bw.makeTable({ data: store.items, sortable: true });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// app.js
|
|
96
|
+
bw.loadStyles({ primary: '#2563eb', secondary: '#7c3aed' });
|
|
97
|
+
|
|
98
|
+
bw.DOM('#app', { t: 'div', c: [
|
|
99
|
+
bw.makeNavbar({ brand: 'My App', items: [
|
|
100
|
+
{ text: 'Home', href: '#/' },
|
|
101
|
+
{ text: 'Users', href: '#/users' },
|
|
102
|
+
{ text: 'Settings', href: '#/settings' }
|
|
103
|
+
]}),
|
|
104
|
+
{ t: 'div', a: { id: 'view' } },
|
|
105
|
+
{ t: 'footer', a: { style: 'padding:1rem; text-align:center' }, c: '(c) 2026' }
|
|
106
|
+
]});
|
|
107
|
+
|
|
108
|
+
bw.router({
|
|
109
|
+
target: '#view',
|
|
110
|
+
routes: {
|
|
111
|
+
'/': function() { return homeView(); },
|
|
112
|
+
'/users': function() { return usersView({}); },
|
|
113
|
+
'/users/:id': function(params) { return usersView(params); },
|
|
114
|
+
'/settings': function() { return settingsView(); },
|
|
115
|
+
'*': function() { return { t: 'h1', c: '404 Not Found' }; }
|
|
116
|
+
},
|
|
117
|
+
after: function(to) { bw.pub('nav:changed', { path: to }); }
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**State flow:** `bw.router()` listens for hash changes. Each route handler returns a TACO mounted into `#view`. Nav and footer stay in the DOM -- only `#view` swaps. Views subscribe via `bw.sub('store:key', fn, el)` -- the `el` param auto-unsubscribes when the view unmounts. See [routing.md](routing.md), [state-management.md](state-management.md#shared-state-across-views).
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Pattern 3: bwserve Server-Driven App
|
|
126
|
+
|
|
127
|
+
Server owns all state and pushes UI over SSE. The client is thin -- it renders whatever the server sends. Good for internal tools, LLM-driven UIs, and apps with no client-side logic. No client files needed -- bwserve auto-generates the HTML shell.
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
my-bwserve-app/
|
|
131
|
+
server.js <- Node.js server (the only file)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
// server.js
|
|
136
|
+
import bwserve from 'bitwrench/bwserve';
|
|
137
|
+
|
|
138
|
+
var app = bwserve.create({ port: 7902 });
|
|
139
|
+
var count = 0;
|
|
140
|
+
|
|
141
|
+
app.page('/', function(client) {
|
|
142
|
+
client.render('#app', {
|
|
143
|
+
t: 'div', c: [
|
|
144
|
+
{ t: 'h1', c: 'Server Counter' },
|
|
145
|
+
{ t: 'span', a: { id: 'val' }, c: '0' },
|
|
146
|
+
{ t: 'button', a: { 'data-bw-action': 'inc' }, c: '+1' }
|
|
147
|
+
]
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
client.on('inc', function() {
|
|
151
|
+
count++;
|
|
152
|
+
client.patch('val', String(count));
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
app.listen();
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**State flow:** Browser requests `/` => server returns HTML shell. Shell opens SSE => server sends TACO via `client.render()`. User clicks `data-bw-action` => browser POSTs to server. Server calls `client.patch()` => browser updates. All state stays on the server. See [bwserve.md](bwserve.md).
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Pattern 4: Embedded / IoT Dashboard
|
|
164
|
+
|
|
165
|
+
A microcontroller (ESP32, Raspberry Pi) serves a static HTML page and pushes sensor data as JSON. Minimal footprint, works on constrained hardware.
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
firmware/
|
|
169
|
+
main.ino <- serves HTML + sensor data
|
|
170
|
+
data/
|
|
171
|
+
index.html <- dashboard page
|
|
172
|
+
bitwrench.umd.min.js
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
// Inside data/index.html <script> block
|
|
177
|
+
bw.loadStyles({ primary: '#0d9488' });
|
|
178
|
+
|
|
179
|
+
// Static layout -- rendered once
|
|
180
|
+
bw.DOM('#app', { t: 'div', c: [
|
|
181
|
+
{ t: 'h1', c: 'Sensor Dashboard' },
|
|
182
|
+
{ t: 'div', a: { id: 'readings' } },
|
|
183
|
+
bw.makeButton({ text: 'LED On', onclick: function() {
|
|
184
|
+
fetch('/api/command', {
|
|
185
|
+
method: 'POST',
|
|
186
|
+
headers: { 'Content-Type': 'application/json' },
|
|
187
|
+
body: JSON.stringify({ cmd: 'led', val: 'on' })
|
|
188
|
+
});
|
|
189
|
+
}})
|
|
190
|
+
]});
|
|
191
|
+
|
|
192
|
+
// Poll the device -- re-render readings section each cycle
|
|
193
|
+
setInterval(function() {
|
|
194
|
+
fetch('/api/sensors').then(function(r) { return r.json(); })
|
|
195
|
+
.then(function(data) {
|
|
196
|
+
bw.DOM('#readings', { t: 'div', c: [
|
|
197
|
+
bw.makeStatCard({ label: 'Temperature', value: data.temp + ' C' }),
|
|
198
|
+
bw.makeStatCard({ label: 'Humidity', value: data.humidity + ' %' })
|
|
199
|
+
]});
|
|
200
|
+
});
|
|
201
|
+
}, 2000);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**State flow:** Device serves files from flash (SPIFFS/LittleFS). Page renders a static layout, then a `setInterval` polls `/api/sensors`. On each response, `bw.DOM()` re-renders the readings. For SSE push instead of polling, use `new EventSource('/events')` and call `bw.patch()` on each message. See [tutorial-embedded.md](tutorial-embedded.md).
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Pattern 5: Static Site (bwcli)
|
|
209
|
+
|
|
210
|
+
Convert Markdown or HTML to styled pages at build time. No runtime JavaScript required. Good for docs, blogs, and project pages.
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
my-docs/
|
|
214
|
+
content/
|
|
215
|
+
index.md, guide.md, api.md
|
|
216
|
+
styles.css <- optional custom CSS
|
|
217
|
+
build.sh
|
|
218
|
+
dist/ <- generated output
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
#!/bin/bash
|
|
223
|
+
# build.sh
|
|
224
|
+
for f in content/*.md; do
|
|
225
|
+
name=$(basename "$f" .md)
|
|
226
|
+
bwcli "$f" \
|
|
227
|
+
--standalone \
|
|
228
|
+
--theme ocean \
|
|
229
|
+
--highlight \
|
|
230
|
+
-c styles.css \
|
|
231
|
+
-o "dist/${name}.html"
|
|
232
|
+
done
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Each output is self-contained with bitwrench embedded inline. No CDN, no toolchain beyond `bwcli`.
|
|
236
|
+
|
|
237
|
+
**State flow:** There is none at runtime. `bwcli` reads Markdown, converts to HTML, applies a theme, and writes a static file. For pages that need interactivity, add `--standalone` and include a `<script>` block using bitwrench at runtime. See [cli.md](cli.md).
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Choosing a Pattern
|
|
242
|
+
|
|
243
|
+
| Use case | Pattern | Key API |
|
|
244
|
+
|----------|---------|---------|
|
|
245
|
+
| Monitoring dashboard, admin panel | Single-Page Dashboard | `bw.pub/sub`, `bw.DOM()`, `makeStatCard` |
|
|
246
|
+
| Multi-view app with URL navigation | Multi-Page SPA | `bw.router()`, `bw.navigate()` |
|
|
247
|
+
| Server owns all logic (internal tool, LLM UI) | bwserve Server-Driven | `client.render()`, `client.patch()` |
|
|
248
|
+
| Microcontroller or constrained device | Embedded / IoT | `bw.DOM()`, `fetch()` polling or SSE |
|
|
249
|
+
| Documentation, blog, project pages | Static Site (bwcli) | `bwcli`, `--theme`, `--standalone` |
|
|
250
|
+
| Prototype or quick one-off | Single-Page Dashboard | One HTML file, no build step |
|
|
251
|
+
|
|
252
|
+
Patterns compose: a bwserve app can include a client-side router, an embedded dashboard can use pub/sub, and a static site can include runtime bitwrench for interactive sections.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Related
|
|
257
|
+
|
|
258
|
+
- [State Management](state-management.md) -- levels 0-2, pub/sub, shared state
|
|
259
|
+
- [Routing](routing.md) -- `bw.router()` full API
|
|
260
|
+
- [Component Library](component-library.md) -- all `make*()` factories
|
|
261
|
+
- [bwserve](bwserve.md) -- server-driven UI protocol
|
|
262
|
+
- [Tutorial: Embedded](tutorial-embedded.md) -- ESP32 walkthrough
|
|
263
|
+
- [CLI](cli.md) -- `bwcli` command reference
|
|
264
|
+
- [Thinking in Bitwrench](thinking-in-bitwrench.md) -- design philosophy
|