bitwrench 2.0.14 → 2.0.16
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 +57 -21
- package/dist/bitwrench-bccl.cjs.js +3746 -0
- package/dist/bitwrench-bccl.cjs.min.js +40 -0
- package/dist/bitwrench-bccl.esm.js +3741 -0
- package/dist/bitwrench-bccl.esm.min.js +40 -0
- package/dist/bitwrench-bccl.umd.js +3752 -0
- package/dist/bitwrench-bccl.umd.min.js +40 -0
- package/dist/bitwrench-code-edit.cjs.js +99 -49
- package/dist/bitwrench-code-edit.cjs.min.js +23 -0
- package/dist/bitwrench-code-edit.es5.js +79 -16
- package/dist/bitwrench-code-edit.es5.min.js +9 -2
- package/dist/bitwrench-code-edit.esm.js +99 -49
- package/dist/bitwrench-code-edit.esm.min.js +9 -2
- package/dist/bitwrench-code-edit.umd.js +99 -49
- package/dist/bitwrench-code-edit.umd.min.js +9 -2
- package/dist/bitwrench-lean.cjs.js +4923 -3248
- package/dist/bitwrench-lean.cjs.min.js +35 -6
- package/dist/bitwrench-lean.es5.js +6325 -4580
- package/dist/bitwrench-lean.es5.min.js +32 -3
- package/dist/bitwrench-lean.esm.js +4923 -3248
- package/dist/bitwrench-lean.esm.min.js +35 -6
- package/dist/bitwrench-lean.umd.js +4923 -3248
- package/dist/bitwrench-lean.umd.min.js +35 -6
- package/dist/bitwrench.cjs.js +5082 -3667
- package/dist/bitwrench.cjs.min.js +38 -8
- package/dist/bitwrench.css +2289 -6034
- package/dist/bitwrench.es5.js +6862 -5346
- package/dist/bitwrench.es5.min.js +34 -5
- package/dist/bitwrench.esm.js +5082 -3667
- package/dist/bitwrench.esm.min.js +38 -8
- package/dist/bitwrench.min.css +1 -0
- package/dist/bitwrench.umd.js +5082 -3667
- package/dist/bitwrench.umd.min.js +38 -8
- package/dist/builds.json +184 -74
- package/dist/bwserve.cjs.js +646 -0
- package/dist/bwserve.esm.js +638 -0
- package/dist/sri.json +36 -26
- package/package.json +23 -6
- package/readme.html +71 -32
- package/src/bitwrench-bccl-entry.js +72 -0
- package/src/{bitwrench-components-v2.js → bitwrench-bccl.js} +396 -647
- package/src/bitwrench-code-edit.js +98 -48
- package/src/bitwrench-color-utils.js +24 -18
- package/src/bitwrench-components-stub.js +4 -1
- package/src/bitwrench-file-ops.js +180 -0
- package/src/bitwrench-lean.js +2 -2
- package/src/bitwrench-styles.js +1287 -4029
- package/src/bitwrench-utils.js +458 -0
- package/src/bitwrench.js +2070 -1292
- package/src/bwserve/client.js +182 -0
- package/src/bwserve/index.js +352 -0
- package/src/bwserve/shell.js +103 -0
- package/src/cli/index.js +36 -15
- package/src/cli/layout-default.js +18 -18
- package/src/cli/serve.js +325 -0
- package/src/generate-css.js +73 -53
- package/src/version.js +3 -3
- package/src/bitwrench-component-base.js +0 -736
- package/src/bitwrench-components-inline.js +0 -374
- package/src/bitwrench-components.js +0 -610
- /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
|
-
- **
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
99
|
-
|
|
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
|
-
|
|
168
|
+
bwcli README.md -o index.html --standalone
|
|
159
169
|
|
|
160
170
|
# Apply a theme preset
|
|
161
|
-
|
|
171
|
+
bwcli doc.md -o doc.html --standalone --theme ocean
|
|
162
172
|
|
|
163
173
|
# Custom colors
|
|
164
|
-
|
|
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
|
-
|
|
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) —
|
|
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
|
|
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 (
|
|
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
|