bitwrench 2.0.15 → 2.0.17

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 (53) hide show
  1. package/README.md +57 -21
  2. package/dist/bitwrench-bccl.cjs.js +3750 -0
  3. package/dist/bitwrench-bccl.cjs.min.js +40 -0
  4. package/dist/bitwrench-bccl.esm.js +3745 -0
  5. package/dist/bitwrench-bccl.esm.min.js +40 -0
  6. package/dist/bitwrench-bccl.umd.js +3756 -0
  7. package/dist/bitwrench-bccl.umd.min.js +40 -0
  8. package/dist/bitwrench-code-edit.cjs.js +57 -7
  9. package/dist/bitwrench-code-edit.cjs.min.js +9 -2
  10. package/dist/bitwrench-code-edit.es5.js +74 -11
  11. package/dist/bitwrench-code-edit.es5.min.js +9 -2
  12. package/dist/bitwrench-code-edit.esm.js +57 -7
  13. package/dist/bitwrench-code-edit.esm.min.js +9 -2
  14. package/dist/bitwrench-code-edit.umd.js +57 -7
  15. package/dist/bitwrench-code-edit.umd.min.js +9 -2
  16. package/dist/bitwrench-lean.cjs.js +905 -157
  17. package/dist/bitwrench-lean.cjs.min.js +7 -7
  18. package/dist/bitwrench-lean.es5.js +931 -157
  19. package/dist/bitwrench-lean.es5.min.js +5 -5
  20. package/dist/bitwrench-lean.esm.js +904 -157
  21. package/dist/bitwrench-lean.esm.min.js +7 -7
  22. package/dist/bitwrench-lean.umd.js +905 -157
  23. package/dist/bitwrench-lean.umd.min.js +7 -7
  24. package/dist/bitwrench.cjs.js +910 -158
  25. package/dist/bitwrench.cjs.min.js +8 -8
  26. package/dist/bitwrench.css +60 -17
  27. package/dist/bitwrench.es5.js +939 -158
  28. package/dist/bitwrench.es5.min.js +6 -6
  29. package/dist/bitwrench.esm.js +909 -158
  30. package/dist/bitwrench.esm.min.js +8 -8
  31. package/dist/bitwrench.min.css +1 -1
  32. package/dist/bitwrench.umd.js +910 -158
  33. package/dist/bitwrench.umd.min.js +8 -8
  34. package/dist/builds.json +168 -80
  35. package/dist/bwserve.cjs.js +660 -0
  36. package/dist/bwserve.esm.js +652 -0
  37. package/dist/sri.json +36 -28
  38. package/package.json +20 -3
  39. package/readme.html +62 -23
  40. package/src/bitwrench-bccl-entry.js +72 -0
  41. package/src/bitwrench-bccl.js +5 -1
  42. package/src/bitwrench-code-edit.js +56 -6
  43. package/src/bitwrench-color-utils.js +5 -6
  44. package/src/bitwrench-styles.js +20 -8
  45. package/src/bitwrench.js +876 -140
  46. package/src/bwserve/client.js +182 -0
  47. package/src/bwserve/index.js +363 -0
  48. package/src/bwserve/shell.js +106 -0
  49. package/src/cli/index.js +36 -15
  50. package/src/cli/layout-default.js +47 -32
  51. package/src/cli/serve.js +325 -0
  52. package/src/version.js +3 -3
  53. /package/bin/{bitwrench.js → bwcli.js} +0 -0
package/README.md CHANGED
@@ -54,7 +54,8 @@ Or include directly in a page:
54
54
  - **Built-in reactivity** — `bw.update()` re-renders components when state changes, `bw.patch()` updates individual elements by ID, `bw.pub()`/`bw.sub()` provides decoupled messaging between any part of the application
55
55
  - **CSS and theme generation** — `bw.css()` generates stylesheets from objects, `bw.generateTheme()` derives a complete visual theme (buttons, alerts, badges, cards, forms, tables, dark mode) from 2-3 seed colors
56
56
  - **45+ ready-made components** — cards, buttons, sortable tables, form inputs, modals, dropdowns, accordions, tooltips, popovers, toasts, timelines, steppers, file uploads, stat cards — each a single function call that returns a composable object
57
- - **Static site CLI** — the `bitwrench` command converts Markdown, HTML, and JSON files into styled, self-contained pages with theme support
57
+ - **Server-driven UI (bwserve)** — push TACO rendering commands from Node.js to the browser over SSE; same protocol works from C (ESP32), Python, Rust, or any language via the `bwcli serve` pipe server
58
+ - **Static site CLI** — the `bwcli` command converts Markdown, HTML, and JSON files into styled, self-contained pages with theme support
58
59
  - **Utilities** — color interpolation, random data generation, lorem ipsum, cookies, URL params, file I/O for both browser and Node.js
59
60
 
60
61
  ## Getting Started
@@ -88,28 +89,31 @@ Or include directly in a page:
88
89
 
89
90
  ## Adding State
90
91
 
91
- The `o` key adds state and a render function to any element. When state changes, call `bw.update()` to re-render:
92
+ Wrap any TACO in `bw.component()` to get a reactive component with `.get()`, `.set()`, and template bindings:
92
93
 
93
94
  ```javascript
94
- bw.DOM('#counter', {
95
- t: 'div',
95
+ var counter = bw.component({
96
+ t: 'div', c: [
97
+ { t: 'span', c: 'Count: ${count}' },
98
+ { t: 'button', c: '+1', a: {
99
+ onclick: function() { counter.set('count', counter.get('count') + 1); }
100
+ }}
101
+ ],
96
102
  o: {
97
103
  state: { count: 0 },
98
- render: function(el) {
99
- var s = el._bw_state;
100
- bw.DOM(el, {
101
- t: 'div', c: [
102
- { t: 'span', c: 'Count: ' + s.count },
103
- { t: 'button', a: {
104
- onclick: function() { s.count++; bw.update(el); }
105
- }, c: '+1' }
106
- ]
107
- });
104
+ methods: {
105
+ reset: function(comp) { comp.set('count', 0); }
108
106
  }
109
107
  }
110
108
  });
109
+
110
+ bw.DOM('#app', counter);
111
+ counter.set('count', 42); // DOM updates automatically
112
+ counter.reset(); // methods from o.methods are callable on the handle
111
113
  ```
112
114
 
115
+ For low-level control, you can also use `o.render` + `bw.update()` directly — see the [State Management guide](docs/state-management.md).
116
+
113
117
  For communication between components, use pub/sub:
114
118
 
115
119
  ```javascript
@@ -139,13 +143,19 @@ bw.toggleTheme(); // switch between primary and alternate palettes
139
143
  |---|---|
140
144
  | `bw.html(obj)` | Convert an object to an HTML string |
141
145
  | `bw.DOM(selector, obj)` | Mount an object to a DOM element |
146
+ | `bw.component(taco)` | Wrap a TACO in a ComponentHandle with `.get()/.set()` reactive API |
142
147
  | `bw.css(rules)` | Generate CSS from a JS object |
143
148
  | `bw.loadDefaultStyles()` | Inject the built-in stylesheet |
144
149
  | `bw.generateTheme(name, config)` | Generate a scoped theme from seed colors |
145
150
  | `bw.patch(id, content)` | Update a specific element by UUID |
146
151
  | `bw.update(el)` | Re-render via the element's `o.render` function |
152
+ | `bw.message(target, action, data)` | Send a message to a component by tag name |
147
153
  | `bw.pub(topic, detail)` | Publish a message to subscribers |
148
154
  | `bw.sub(topic, handler)` | Subscribe to a topic; returns an unsub function |
155
+ | `bw.inspect(target)` | Debug a component in the browser console |
156
+ | `bw.clientConnect(url, opts)` | Connect to a bwserve SSE endpoint |
157
+ | `bw.clientApply(msg)` | Apply a bwserve protocol message to the DOM |
158
+ | `bw.clientParse(str)` | Parse strict or r-prefix relaxed JSON |
149
159
 
150
160
  See the full [API Reference](https://deftio.github.io/bitwrench/pages/08-api-reference.html) for all functions.
151
161
 
@@ -155,17 +165,26 @@ Convert Markdown, HTML, or JSON files to styled standalone pages:
155
165
 
156
166
  ```bash
157
167
  # Convert Markdown to a self-contained HTML page
158
- bitwrench README.md -o index.html --standalone
168
+ bwcli README.md -o index.html --standalone
159
169
 
160
170
  # Apply a theme preset
161
- bitwrench doc.md -o doc.html --standalone --theme ocean
171
+ bwcli doc.md -o doc.html --standalone --theme ocean
162
172
 
163
173
  # Custom colors
164
- bitwrench doc.md -o doc.html --standalone --theme "#336699,#cc6633"
174
+ bwcli doc.md -o doc.html --standalone --theme "#336699,#cc6633"
165
175
  ```
166
176
 
167
177
  Flags: `--output/-o`, `--standalone/-s`, `--cdn`, `--theme/-t`, `--css/-c`, `--title`, `--favicon/-f`, `--highlight`, `--verbose/-v`
168
178
 
179
+ ### Pipe Server
180
+
181
+ `bwcli serve` turns any language into a bwserve backend — send JSON protocol messages via HTTP POST or stdin, and connected browsers update in real time:
182
+
183
+ ```bash
184
+ bwcli serve --port 8080 --input-port 9000
185
+ curl -X POST http://localhost:9000 -d '{"type":"patch","target":"temp","content":"23.5 C"}'
186
+ ```
187
+
169
188
  ## Build Formats
170
189
 
171
190
  | Format | File | Use case |
@@ -179,21 +198,38 @@ All formats include source maps. A separate CSS file (`bitwrench.css`) is also a
179
198
 
180
199
  ## Documentation
181
200
 
182
- - [Interactive docs and demos](https://deftio.github.io/bitwrench/pages/) — full tutorial site with live examples
201
+ **Guides** (in `docs/`):
202
+
203
+ - [TACO Format](docs/taco-format.md) — the `{t, a, c, o}` object format
204
+ - [State Management](docs/state-management.md) — three-level component model, ComponentHandle, reactive state
205
+ - [Component Library](docs/component-library.md) — all 50+ `make*()` functions with signatures and examples
206
+ - [Theming](docs/theming.md) — palette-driven theme generation, presets, design tokens
207
+ - [CLI](docs/cli.md) — the `bwcli` command for file conversion and pipe server
208
+ - [bwserve](docs/bwserve.md) — server-driven UI protocol (SSE, actions, embedded devices)
209
+ - [LLM Guide](docs/llm-bitwrench-guide.md) — compact single-file reference for AI-assisted development
210
+
211
+ **Tutorials:**
212
+
213
+ - [Build a Website](docs/tutorial-website.md) — multi-section landing page from TACO objects
214
+ - [bwserve Dashboard](docs/tutorial-bwserve.md) — Streamlit-style server-push dashboard
215
+ - [ESP32 IoT Dashboard](docs/tutorial-embedded.md) — embedded sensor dashboard with C macros
216
+
217
+ **Interactive demos** (live site):
218
+
183
219
  - [Quick Start](https://deftio.github.io/bitwrench/pages/00-quick-start.html) — first steps with `bw.DOM()`
184
220
  - [Components](https://deftio.github.io/bitwrench/pages/01-components.html) — buttons, cards, alerts, badges, navbars
185
221
  - [Styling & Theming](https://deftio.github.io/bitwrench/pages/03-styling.html) — CSS generation and theming strategies
186
- - [State & Interactivity](https://deftio.github.io/bitwrench/pages/05-state.html) — `bw.patch()`, `bw.update()`, pub/sub
222
+ - [State & Interactivity](https://deftio.github.io/bitwrench/pages/05-state.html) — state patterns and ComponentHandle
187
223
  - [Tic Tac Toe Tutorial](https://deftio.github.io/bitwrench/pages/06-tic-tac-toe-tutorial.html) — step-by-step game with state management
188
224
  - [Framework Comparison](https://deftio.github.io/bitwrench/pages/07-framework-comparison.html) — bitwrench vs React, Vue, Svelte
189
- - [Themes](https://deftio.github.io/bitwrench/pages/10-themes.html) — interactive theme generator with presets, dark mode, and CSS export
225
+ - [Themes](https://deftio.github.io/bitwrench/pages/10-themes.html) — interactive theme generator with presets and CSS export
190
226
 
191
227
  ## Development
192
228
 
193
229
  ```bash
194
230
  npm install # install dev dependencies
195
231
  npm run build # build all dist formats (UMD, ESM, CJS, ES5)
196
- npm test # run unit tests (558 tests)
232
+ npm test # run unit tests (1000+ tests)
197
233
  npm run test:cli # run CLI tests (49 tests)
198
234
  npm run test:e2e # run Playwright browser tests
199
235
  npm run lint # run ESLint