bitwrench 2.0.22 → 2.0.23

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 (88) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +4 -3
  3. package/bin/bwmcp.js +3 -0
  4. package/dist/bitwrench-bccl.cjs.js +1 -1
  5. package/dist/bitwrench-bccl.cjs.min.js +1 -1
  6. package/dist/bitwrench-bccl.cjs.min.js.gz +0 -0
  7. package/dist/bitwrench-bccl.esm.js +1 -1
  8. package/dist/bitwrench-bccl.esm.min.js +1 -1
  9. package/dist/bitwrench-bccl.esm.min.js.gz +0 -0
  10. package/dist/bitwrench-bccl.umd.js +1 -1
  11. package/dist/bitwrench-bccl.umd.min.js +1 -1
  12. package/dist/bitwrench-bccl.umd.min.js.gz +0 -0
  13. package/dist/bitwrench-code-edit.cjs.js +1 -1
  14. package/dist/bitwrench-code-edit.cjs.min.js +1 -1
  15. package/dist/bitwrench-code-edit.es5.js +1 -1
  16. package/dist/bitwrench-code-edit.es5.min.js +1 -1
  17. package/dist/bitwrench-code-edit.esm.js +1 -1
  18. package/dist/bitwrench-code-edit.esm.min.js +1 -1
  19. package/dist/bitwrench-code-edit.umd.js +1 -1
  20. package/dist/bitwrench-code-edit.umd.min.js +1 -1
  21. package/dist/bitwrench-code-edit.umd.min.js.gz +0 -0
  22. package/dist/bitwrench-debug.js +1 -1
  23. package/dist/bitwrench-debug.min.js +1 -1
  24. package/dist/bitwrench-lean.cjs.js +3 -3
  25. package/dist/bitwrench-lean.cjs.min.js +2 -2
  26. package/dist/bitwrench-lean.cjs.min.js.gz +0 -0
  27. package/dist/bitwrench-lean.es5.js +3 -3
  28. package/dist/bitwrench-lean.es5.min.js +2 -2
  29. package/dist/bitwrench-lean.es5.min.js.gz +0 -0
  30. package/dist/bitwrench-lean.esm.js +3 -3
  31. package/dist/bitwrench-lean.esm.min.js +2 -2
  32. package/dist/bitwrench-lean.esm.min.js.gz +0 -0
  33. package/dist/bitwrench-lean.umd.js +3 -3
  34. package/dist/bitwrench-lean.umd.min.js +2 -2
  35. package/dist/bitwrench-lean.umd.min.js.gz +0 -0
  36. package/dist/bitwrench-util-css.cjs.js +1 -1
  37. package/dist/bitwrench-util-css.cjs.min.js +1 -1
  38. package/dist/bitwrench-util-css.es5.js +1 -1
  39. package/dist/bitwrench-util-css.es5.min.js +1 -1
  40. package/dist/bitwrench-util-css.esm.js +1 -1
  41. package/dist/bitwrench-util-css.esm.min.js +1 -1
  42. package/dist/bitwrench-util-css.umd.js +1 -1
  43. package/dist/bitwrench-util-css.umd.min.js +1 -1
  44. package/dist/bitwrench-util-css.umd.min.js.gz +0 -0
  45. package/dist/bitwrench.cjs.js +3 -3
  46. package/dist/bitwrench.cjs.min.js +2 -2
  47. package/dist/bitwrench.cjs.min.js.gz +0 -0
  48. package/dist/bitwrench.css +1 -1
  49. package/dist/bitwrench.es5.js +3 -3
  50. package/dist/bitwrench.es5.min.js +2 -2
  51. package/dist/bitwrench.es5.min.js.gz +0 -0
  52. package/dist/bitwrench.esm.js +3 -3
  53. package/dist/bitwrench.esm.min.js +2 -2
  54. package/dist/bitwrench.esm.min.js.gz +0 -0
  55. package/dist/bitwrench.umd.js +3 -3
  56. package/dist/bitwrench.umd.min.js +2 -2
  57. package/dist/bitwrench.umd.min.js.gz +0 -0
  58. package/dist/builds.json +57 -57
  59. package/dist/bwserve.cjs.js +2 -2
  60. package/dist/bwserve.esm.js +2 -2
  61. package/dist/sri.json +45 -45
  62. package/docs/README.md +76 -0
  63. package/docs/app-patterns.md +264 -0
  64. package/docs/bitwrench-mcp.md +426 -0
  65. package/docs/bitwrench_api.md +2232 -0
  66. package/docs/bw-attach.md +399 -0
  67. package/docs/bwserve.md +841 -0
  68. package/docs/cli.md +307 -0
  69. package/docs/component-cheatsheet.md +144 -0
  70. package/docs/component-library.md +1099 -0
  71. package/docs/framework-translation-table.md +33 -0
  72. package/docs/llm-bitwrench-guide.md +672 -0
  73. package/docs/routing.md +562 -0
  74. package/docs/state-management.md +767 -0
  75. package/docs/taco-format.md +373 -0
  76. package/docs/theming.md +309 -0
  77. package/docs/thinking-in-bitwrench.md +1457 -0
  78. package/docs/tutorial-bwserve.md +297 -0
  79. package/docs/tutorial-embedded.md +314 -0
  80. package/docs/tutorial-website.md +255 -0
  81. package/package.json +11 -3
  82. package/readme.html +5 -4
  83. package/src/mcp/knowledge.js +231 -0
  84. package/src/mcp/live.js +226 -0
  85. package/src/mcp/server.js +216 -0
  86. package/src/mcp/tools.js +369 -0
  87. package/src/mcp/transport.js +55 -0
  88. package/src/version.js +3 -3
package/docs/cli.md ADDED
@@ -0,0 +1,307 @@
1
+ # CLI
2
+
3
+ The `bwcli` command converts files to styled HTML pages. It supports Markdown, HTML, and JSON input, and can produce self-contained offline pages or pages that load bitwrench from a CDN.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g bitwrench
9
+ ```
10
+
11
+ Or use `npx` without installing:
12
+
13
+ ```bash
14
+ npx bwcli README.md
15
+ ```
16
+
17
+ ## Basic usage
18
+
19
+ ```bash
20
+ # Convert a Markdown file to HTML
21
+ bwcli README.md
22
+
23
+ # Specify output file
24
+ bwcli README.md -o index.html
25
+
26
+ # Apply a theme
27
+ bwcli README.md -o index.html --theme ocean
28
+
29
+ # Create a self-contained offline page
30
+ bwcli README.md -o index.html --standalone
31
+
32
+ # Add syntax highlighting
33
+ bwcli README.md -o index.html --highlight
34
+ ```
35
+
36
+ ## Input formats
37
+
38
+ The CLI detects the input format by file extension:
39
+
40
+ | Extension | Handling |
41
+ |-----------|----------|
42
+ | `.md`, `.markdown` | Parsed with [Quikdown](https://github.com/deftio/quikdown) (bundled zero-dep Markdown parser). Title extracted from first `# heading`. |
43
+ | `.html`, `.htm` | If it is a full HTML document (has `<html>` or `<!DOCTYPE>`), the `<title>` and `<body>` content are extracted. Otherwise, the file is used as-is as body content. |
44
+ | `.json` | If the JSON has a `t` property, it is treated as a TACO object and rendered with `bw.html()`. Otherwise, it is pretty-printed as a code block. |
45
+
46
+ ## Output
47
+
48
+ By default, the output file has the same name as the input with a `.html` extension:
49
+
50
+ ```bash
51
+ bwcli docs/guide.md # → docs/guide.html
52
+ bwcli data.json # → data.html
53
+ ```
54
+
55
+ Override with `-o`:
56
+
57
+ ```bash
58
+ bwcli docs/guide.md -o site/index.html
59
+ ```
60
+
61
+ ## Bitwrench injection modes
62
+
63
+ By default, the CLI produces plain HTML without bitwrench. Three flags control how bitwrench is included in the output:
64
+
65
+ | Flag | Mode | What happens |
66
+ |------|------|-------------|
67
+ | `--standalone` / `-s` | Inline | The entire bitwrench UMD bundle is embedded in a `<script>` tag. Page works offline with no external dependencies. |
68
+ | `--cdn` | CDN | A `<script>` tag loads bitwrench from jsDelivr with an SRI hash for integrity. Requires internet access. |
69
+ | `--no-bw` | None | No bitwrench is included. Plain HTML output. This is the default. |
70
+
71
+ When bitwrench is included (`--standalone` or `--cdn`), a small script runs after the page loads to call `bw.loadStyles()`, applying bitwrench's default component styles.
72
+
73
+ ## Themes
74
+
75
+ Apply a built-in theme preset:
76
+
77
+ ```bash
78
+ bwcli README.md --theme ocean
79
+ bwcli README.md --theme sunset
80
+ bwcli README.md --theme forest
81
+ bwcli README.md --theme slate
82
+ ```
83
+
84
+ Or specify custom colors as a comma-separated pair of hex values (primary and secondary):
85
+
86
+ ```bash
87
+ bwcli README.md --theme "#336699,#cc6633"
88
+ ```
89
+
90
+ Available presets: `teal`, `ocean`, `sunset`, `forest`, `slate`, `rose`, `indigo`, `amber`, `emerald`, `nord`, `coral`, `midnight`.
91
+
92
+ Themes require bitwrench to be included (`--standalone` or `--cdn`). If neither is specified, the theme flag is ignored.
93
+
94
+ ## Additional CSS
95
+
96
+ Include an external CSS file:
97
+
98
+ ```bash
99
+ bwcli README.md -c styles.css -o index.html
100
+ ```
101
+
102
+ The CSS file's contents are embedded in a `<style>` tag in the output. This works with or without bitwrench injection.
103
+
104
+ ## Favicon
105
+
106
+ Add a favicon to the page:
107
+
108
+ ```bash
109
+ bwcli README.md -f favicon.ico -o index.html
110
+ bwcli README.md -f https://example.com/icon.png -o index.html
111
+ ```
112
+
113
+ The value is used directly as the `href` attribute of a `<link rel="icon">` tag.
114
+
115
+ ## Syntax highlighting
116
+
117
+ Include highlight.js for code block syntax highlighting:
118
+
119
+ ```bash
120
+ bwcli README.md --highlight -o index.html
121
+ ```
122
+
123
+ This adds the highlight.js CDN stylesheet and script to the output page. Code blocks in the Markdown source get automatic syntax highlighting based on the language specified in the fenced code block.
124
+
125
+ ## Page title
126
+
127
+ The CLI auto-detects the page title from the content:
128
+
129
+ - **Markdown**: First `# heading` in the file
130
+ - **HTML**: `<title>` element content
131
+ - **JSON**: The filename
132
+
133
+ Override with `--title`:
134
+
135
+ ```bash
136
+ bwcli README.md --title "My Project Documentation" -o index.html
137
+ ```
138
+
139
+ ## All flags
140
+
141
+ ```
142
+ bwcli <file> [options]
143
+
144
+ Options:
145
+ -o, --output <file> Output file path
146
+ -c, --css <file> Include external CSS file
147
+ -t, --theme <name> Theme preset or hex colors ("primary,secondary")
148
+ -s, --standalone Embed bitwrench inline (works offline)
149
+ --cdn Link bitwrench via CDN (jsDelivr)
150
+ --no-bw Don't inject bitwrench (default)
151
+ --title <text> Page title (default: auto-detect)
152
+ -f, --favicon <path> Favicon path or URL
153
+ --highlight Include highlight.js for syntax highlighting
154
+ -v, --verbose Verbose output
155
+ -h, --help Print help
156
+ --version Print version
157
+ ```
158
+
159
+ ## The `bwcli serve` subcommand — Pipe Server
160
+
161
+ `bwcli serve` is a pipe server that turns **any language** into a bwserve backend. It opens two ports:
162
+
163
+ - **Web port** (default `:8080`) — browsers connect here via SSE
164
+ - **Input port** (default `:9000`) — your app sends protocol messages here via HTTP POST
165
+
166
+ Alternatively, use `--stdin` to pipe newline-delimited JSON from stdin.
167
+
168
+ ### Usage
169
+
170
+ ```bash
171
+ # Start the pipe server with default ports
172
+ bwcli serve
173
+
174
+ # Custom ports
175
+ bwcli serve --port 8080 --input-port 9000
176
+
177
+ # Open browser automatically
178
+ bwcli serve --open
179
+
180
+ # Stdin mode: pipe messages from any command
181
+ python sensor.py | bwcli serve --stdin --port 8080
182
+
183
+ # Verbose logging (shows all messages)
184
+ bwcli serve -v
185
+ ```
186
+
187
+ ### Sending protocol messages
188
+
189
+ Your app sends bwserve protocol messages (JSON) to the input port. All connected browsers update in real time.
190
+
191
+ ```bash
192
+ # Patch a value:
193
+ curl -X POST http://localhost:9000 \
194
+ -H "Content-Type: application/json" \
195
+ -d '{"type":"patch","target":"temp","content":"23.5 C"}'
196
+
197
+ # Batch update:
198
+ curl -X POST http://localhost:9000 \
199
+ -d '{"type":"batch","ops":[
200
+ {"type":"patch","target":"temp","content":"23.5"},
201
+ {"type":"patch","target":"humidity","content":"67%"}
202
+ ]}'
203
+
204
+ # r-prefix relaxed JSON is also accepted (for C/embedded):
205
+ curl -X POST http://localhost:9000 -d "r{'type':'patch','target':'temp','content':'23.5'}"
206
+ ```
207
+
208
+ ### Options
209
+
210
+ ```
211
+ bwcli serve [options]
212
+
213
+ Options:
214
+ -p, --port <number> Web port for browsers (default: 8080)
215
+ --input-port <number> Input port for protocol messages (default: 9000)
216
+ --stdin Read messages from stdin instead of input port
217
+ -t, --theme <name> Theme preset or hex colors
218
+ --open Open browser on start
219
+ -v, --verbose Verbose output (shows all messages)
220
+ -h, --help Print help
221
+ ```
222
+
223
+ ### How it works
224
+
225
+ 1. Browser opens `http://localhost:8080` and gets an auto-generated page shell
226
+ 2. Shell loads bitwrench, opens SSE connection to `/bw/events/:clientId`
227
+ 3. Your app POSTs protocol messages to `http://localhost:9000`
228
+ 4. `bwcli serve` broadcasts each message to all connected browsers via SSE
229
+ 5. Browser's `bw.apply()` updates the DOM
230
+
231
+ Both strict JSON and r-prefix relaxed JSON are accepted on the input port. See [bwserve](bwserve.md) for the full protocol reference.
232
+
233
+ ## The `bwcli attach` subcommand — Remote Debugging REPL
234
+
235
+ `bwcli attach` provides a built-in terminal-based debugger for any bitwrench page. It starts a bwserve instance and waits for a browser to connect via a drop-in `<script>` tag. Once connected, you get an interactive REPL for evaluating JS, inspecting the DOM, taking screenshots, and listening to events.
236
+
237
+ ### Usage
238
+
239
+ ```bash
240
+ # Start on default port (7902)
241
+ bwcli attach
242
+
243
+ # Custom port
244
+ bwcli attach --port 3000
245
+
246
+ # Enable screenshot support
247
+ bwcli attach --allow-screenshot
248
+
249
+ # Verbose mode (shows protocol messages)
250
+ bwcli attach -v
251
+ ```
252
+
253
+ ### Connecting a page
254
+
255
+ Add this to any HTML page, or paste it into the browser's devtools console:
256
+
257
+ ```html
258
+ <script src="http://localhost:7902/bw/attach.js"></script>
259
+ ```
260
+
261
+ The drop-in script automatically loads bitwrench if it's not already on the page, then connects via SSE.
262
+
263
+ ### REPL commands
264
+
265
+ Once connected, you get a `bw>` prompt:
266
+
267
+ ```
268
+ bw> document.title # Evaluate JS expression
269
+ bw> /tree #app 2 # Show DOM tree
270
+ bw> /screenshot body page.png # Capture screenshot (requires --allow-screenshot)
271
+ bw> /mount #app card {"title":"Hi"} # Mount BCCL component
272
+ bw> /render #app {"t":"h1","c":"Hi"} # Render TACO
273
+ bw> /patch counter 42 # Update element text
274
+ bw> /listen button click # Watch DOM events
275
+ bw> /unlisten button click # Stop watching
276
+ bw> /exec alert('hello') # Execute JS (fire-and-forget)
277
+ bw> /clients # List connected clients
278
+ bw> /help # Command reference
279
+ bw> /quit # Exit
280
+ ```
281
+
282
+ ### Options
283
+
284
+ ```
285
+ bwcli attach [options]
286
+
287
+ Options:
288
+ -p, --port <number> Server port (default: 7902)
289
+ --allow-screenshot Enable /screenshot command
290
+ -v, --verbose Verbose output
291
+ -h, --help Print help
292
+ ```
293
+
294
+ For the complete guide, see [bwcli attach documentation](bw-attach.md).
295
+
296
+ ## Page layout
297
+
298
+ The CLI wraps content in a responsive layout:
299
+
300
+ - Centered container (max-width 48rem)
301
+ - System font stack (San Francisco, Segoe UI, Roboto, Helvetica, Arial)
302
+ - Comfortable typography (1rem base, 1.6 line-height)
303
+ - Styled code blocks with horizontal scroll
304
+ - Responsive tables with alternating row colors
305
+ - Mobile-friendly (adjusts at 600px breakpoint)
306
+
307
+ This layout is designed to produce readable documents without any additional styling. Add `--theme` and `--standalone` (or `--cdn`) for bitwrench-styled components on top of this base.
@@ -0,0 +1,144 @@
1
+ # Component Cheat Sheet
2
+
3
+ > **Before you write custom TACO for a common UI pattern, check this list.**
4
+ > Bitwrench ships 50+ ready-made `make*()` factories. Each returns a Level 0 TACO object.
5
+
6
+ ## Full Component Table
7
+
8
+ | Component | Key Props | Capabilities | Handles / Slots |
9
+ |-----------|-----------|-------------|----------------|
10
+ | **Tables & Data** | | | |
11
+ | makeTable | data, columns, sortable, pageSize, onRowClick | Click-to-sort (on by default), pagination, row selection, custom column renderers | -- |
12
+ | makeTableFromArray | data (2D array), headerRow, sortable | Convert CSV/spreadsheet data to sortable table | -- |
13
+ | makeDataTable | title, data, columns, responsive | Title heading + responsive scroll wrapper around makeTable | -- |
14
+ | makeBarChart | data, labelKey, valueKey, title, color, formatValue | Pure-CSS vertical bar chart, no external library | -- |
15
+ | **Interactive** | | | |
16
+ | makeCarousel | items, autoPlay, interval, showControls | Auto-play, pause-on-hover, keyboard nav, dot indicators | goToSlide(i), next(), prev(), play(), pause(), getActiveIndex() |
17
+ | makeTabs | tabs [{label,content}], activeIndex | Arrow/Home/End keys, full WAI-ARIA, click switching | setActiveTab(i), getActiveTab() |
18
+ | makeAccordion | items [{title,content}], multiOpen | Smooth animations, ARIA, multi-open option | toggle(i), openAll(), closeAll() |
19
+ | makeModal | title, content, footer, size, onClose | ESC dismiss, backdrop click close, size variants | open(), close() |
20
+ | makeToast | title, content, variant, delay, position | Auto-dismiss (5s default), 6 position options | dismiss() |
21
+ | makeDropdown | trigger, items, align, variant | Outside-click-to-close, divider support | -- |
22
+ | makePopover | trigger, title, content, placement | Click-outside-to-close, 4 placements | -- |
23
+ | makeTooltip | content, text, placement | Show on hover/focus, role=tooltip, 4 placements | -- |
24
+ | **Content** | | | |
25
+ | makeCard | title, content, footer, image, variant, shadow | All props accept TACO (not just strings), image positions, shadow variants, hoverable | slots: setTitle/getTitle, setContent/getContent, setFooter/getFooter |
26
+ | makeStatCard | value, label, change, variant, prefix, suffix | Dashboard KPI with change indicator (green/red arrows) | slots: setValue/getValue, setLabel/getLabel |
27
+ | makeAlert | title, content, variant, dismissible | Dismissible close button, 8 color variants | -- |
28
+ | makeBadge | text, variant, pill, size | Pill shape option, sm/lg sizes | -- |
29
+ | makeProgress | value, max, variant, striped, animated | Striped + animated variants, ARIA | setValue(n), getValue() |
30
+ | makeHero | title, subtitle, actions, variant, size, backgroundImage | Background image with overlay, centered/left layouts | -- |
31
+ | makeSection | title, subtitle, content, variant, spacing | Semantic section wrapper with spacing control | -- |
32
+ | makeFeatureGrid | features [{icon,title,desc}], columns, centered | Responsive icon+title+desc grid | -- |
33
+ | makeCTA | title, description, actions, variant | Call-to-action block with action buttons | -- |
34
+ | makeCodeDemo | title, description, code, result | Code + live output in tabbed view, copy button | -- |
35
+ | makeMediaObject | src, alt, title, content, reverse, imageSize | Image + text side-by-side, reversible | -- |
36
+ | makeTimeline | items [{title,content,date,variant}] | Vertical timeline with colored markers | -- |
37
+ | makeStepper | steps [{label,desc}], currentStep | Step progress indicator with completed/active/pending states | -- |
38
+ | makeListGroup | items, flush, interactive | Interactive click items, flush variant for cards | -- |
39
+ | makeAvatar | src, alt, initials, size, variant | Initials fallback when no image, 4 sizes | -- |
40
+ | makeSkeleton | variant, width, height, count | Pulse animation placeholder (text/circle/rect) | -- |
41
+ | makeSpinner | variant, size, type | Border/grow animation types, 3 sizes | -- |
42
+ | **Navigation** | | | |
43
+ | makeNav | items [{text,href,active}], pills, vertical | Pill/vertical variants, disabled items | -- |
44
+ | makeNavbar | brand, brandHref, items, dark | Dark variant, brand link | -- |
45
+ | makeBreadcrumb | items [{text,href}] | aria-label, aria-current on active item | -- |
46
+ | makePagination | pages, currentPage, onPageChange, size | Page change callbacks, sm/lg sizes | -- |
47
+ | **Forms** | | | |
48
+ | makeForm | children, onsubmit | Form wrapper with default preventDefault | -- |
49
+ | makeFormGroup | label, input, help, validation, feedback, required | Required indicator (*), validation feedback (valid/invalid) | -- |
50
+ | makeInput | type, placeholder, value, disabled, oninput | All HTML5 types, bw_form_control styling | -- |
51
+ | makeTextarea | placeholder, value, rows, disabled | Multi-line input, bw_form_control styling | -- |
52
+ | makeSelect | options [{value,text}], value, disabled | Dropdown select, bw_form_control styling | -- |
53
+ | makeCheckbox | label, checked, id, name, disabled | Label-for-id linking, bw_form_check styling | -- |
54
+ | makeRadio | label, name, value, checked, id | Label-for-id linking, radio group support | -- |
55
+ | makeSwitch | label, checked, id, name, disabled | Toggle switch with label linking | -- |
56
+ | makeSearchInput | placeholder, onSearch, onInput | Enter to search, clear button appears on input | -- |
57
+ | makeChipInput | chips, placeholder, onAdd, onRemove | Enter to add, click X to remove, backspace last | addChip(v), removeChip(v), getChips(), clear() |
58
+ | makeFileUpload | accept, multiple, onFiles, text | Drag-and-drop zone, styled file input | -- |
59
+ | makeRange | min, max, step, value, label, showValue | Live value display next to slider | -- |
60
+ | **Buttons** | | | |
61
+ | makeButton | text, variant, size, disabled, onclick, type | 8 variants + outline-* variants, sm/lg sizes | -- |
62
+ | makeButtonGroup | children, size, vertical | Shared border-radius, vertical/horizontal layout | -- |
63
+ | **Layout** | | | |
64
+ | makeContainer | fluid, children | Centered max-width or full-width fluid | -- |
65
+ | makeRow | children, gap | Flexbox row with gap (1-5) | -- |
66
+ | makeCol | size, offset, content | Responsive: size as number or {xs,sm,md,lg,xl} | -- |
67
+ | makeStack | children, direction, gap | Vertical/horizontal flex stack | -- |
68
+
69
+ ## How to Use Handles
70
+
71
+ Components with handles expose imperative methods via `el.bw`. Use `bw.mount()` instead of `bw.DOM()` to get the element reference:
72
+
73
+ ```javascript
74
+ // Mount and get element reference
75
+ var el = bw.mount('#target', bw.makeCarousel({ items: slides, autoPlay: true }));
76
+
77
+ // Call handle methods directly
78
+ el.bw.goToSlide(2);
79
+ el.bw.pause();
80
+ var idx = el.bw.getActiveIndex(); // => 2
81
+
82
+ // Works with any component that has handles
83
+ var modal = bw.mount('#modal', bw.makeModal({ title: 'Confirm', content: 'Sure?' }));
84
+ modal.bw.open(); // show the modal
85
+ modal.bw.close(); // hide it
86
+ ```
87
+
88
+ When you don't have the element reference, use `bw.message()`:
89
+
90
+ ```javascript
91
+ bw.message('#my-carousel', 'goToSlide', 2);
92
+ bw.message('.bw_uuid_abc123', 'next');
93
+ ```
94
+
95
+ See [State Management -- Level 1.5](state-management.md#level-15-component-handles) for the full handle/slots guide.
96
+
97
+ ## How to Use Slots
98
+
99
+ Slot-based components auto-generate `el.bw.setName()` / `el.bw.getName()` pairs for content areas:
100
+
101
+ ```javascript
102
+ var card = bw.mount('#info', bw.makeCard({ title: 'Stats', content: '0' }));
103
+ card.bw.setTitle('Revenue'); // update just the title
104
+ card.bw.setContent({ t: 'b', c: '$42k' }); // accepts TACO objects
105
+ card.bw.getTitle(); // => 'Revenue'
106
+ ```
107
+
108
+ Slot setters update only the targeted child -- input focus, scroll, and animation state in siblings are preserved.
109
+
110
+ Build your own with `o.slots`:
111
+
112
+ ```javascript
113
+ {
114
+ t: 'div', c: [
115
+ { t: 'h3', a: { class: 'title' }, c: 'Default' },
116
+ { t: 'div', a: { class: 'body' }, c: 'Content' }
117
+ ],
118
+ o: {
119
+ slots: { title: '.title', body: '.body' }
120
+ // => el.bw.setTitle(), el.bw.getTitle(), el.bw.setBody(), el.bw.getBody()
121
+ }
122
+ }
123
+ ```
124
+
125
+ ## Factory Dispatcher
126
+
127
+ Use `bw.make(type, props)` for data-driven component creation:
128
+
129
+ ```javascript
130
+ bw.make('card', { title: 'Hello' }); // same as bw.makeCard({ title: 'Hello' })
131
+
132
+ // Data-driven layout
133
+ var layout = [
134
+ { type: 'card', props: { title: 'Stats' } },
135
+ { type: 'alert', props: { content: 'Warning!', variant: 'warning' } }
136
+ ];
137
+ bw.DOM('#app', { t: 'div', c: layout.map(function(item) {
138
+ return bw.make(item.type, item.props);
139
+ })});
140
+ ```
141
+
142
+ ---
143
+
144
+ *See [Component Library](component-library.md) for full signatures and examples. See [LLM Guide](llm-bitwrench-guide.md) for the compact API reference.*