bitwrench 2.0.24 → 2.0.30
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 +17 -9
- 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 +661 -174
- package/dist/bitwrench-lean.cjs.min.js +7 -7
- package/dist/bitwrench-lean.cjs.min.js.gz +0 -0
- package/dist/bitwrench-lean.es5.js +690 -178
- package/dist/bitwrench-lean.es5.min.js +5 -5
- package/dist/bitwrench-lean.es5.min.js.gz +0 -0
- package/dist/bitwrench-lean.esm.js +661 -174
- package/dist/bitwrench-lean.esm.min.js +6 -6
- package/dist/bitwrench-lean.esm.min.js.gz +0 -0
- package/dist/bitwrench-lean.umd.js +661 -174
- package/dist/bitwrench-lean.umd.min.js +7 -7
- 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 +659 -172
- package/dist/bitwrench.cjs.min.js +6 -6
- package/dist/bitwrench.cjs.min.js.gz +0 -0
- package/dist/bitwrench.css +6 -6
- package/dist/bitwrench.d.ts +666 -0
- package/dist/bitwrench.es5.js +687 -175
- package/dist/bitwrench.es5.min.js +6 -6
- package/dist/bitwrench.es5.min.js.gz +0 -0
- package/dist/bitwrench.esm.js +659 -172
- package/dist/bitwrench.esm.min.js +5 -5
- package/dist/bitwrench.esm.min.js.gz +0 -0
- package/dist/bitwrench.min.css +1 -1
- package/dist/bitwrench.umd.js +659 -172
- package/dist/bitwrench.umd.min.js +6 -6
- package/dist/bitwrench.umd.min.js.gz +0 -0
- package/dist/builds.json +96 -96
- package/dist/bwserve.cjs.js +140 -7
- package/dist/bwserve.esm.js +141 -8
- package/dist/sri.json +46 -46
- package/docs/README.md +5 -3
- package/docs/bitwrench-for-wasm.md +851 -0
- package/docs/bitwrench-mcp.md +1 -1
- package/docs/bitwrench-taco-schema-discussion.md +694 -0
- package/docs/bitwrench_api.md +134 -24
- package/docs/bitwrench_typescript_usage.md +441 -0
- package/docs/component-cheatsheet.md +1 -1
- package/docs/framework-translation-table.md +1 -1
- package/docs/llm-bitwrench-guide.md +34 -6
- package/docs/routing.md +1 -1
- package/docs/state-management.md +27 -3
- package/docs/thinking-in-bitwrench.md +6 -5
- package/docs/tutorial-bwserve.md +1 -1
- package/docs/tutorial-website.md +1 -1
- package/package.json +16 -10
- package/readme.html +29 -14
- package/src/bitwrench-styles.js +17 -17
- package/src/bitwrench.d.ts +666 -0
- package/src/bitwrench.js +638 -150
- package/src/bwserve/bwclient.js +3 -3
- package/src/bwserve/client.js +26 -0
- package/src/bwserve/index.js +110 -3
- package/src/cli/attach.js +7 -5
- package/src/cli/serve.js +53 -9
- package/src/mcp/live.js +3 -1
- package/src/mcp/server.js +7 -7
- package/src/version.js +3 -3
package/docs/bitwrench_api.md
CHANGED
|
@@ -4,27 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
| Field | Value |
|
|
6
6
|
|-------|-------|
|
|
7
|
-
| Version | 2.0.
|
|
8
|
-
| Generated | 2026-
|
|
9
|
-
| Total APIs |
|
|
10
|
-
| Categories |
|
|
11
|
-
| bitwrench.js |
|
|
7
|
+
| Version | 2.0.30 |
|
|
8
|
+
| Generated | 2026-04-12 |
|
|
9
|
+
| Total APIs | 105 |
|
|
10
|
+
| Categories | 14 |
|
|
11
|
+
| bitwrench.js | 4100 lines |
|
|
12
12
|
| bitwrench-bccl.js | 3793 lines |
|
|
13
13
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
16
16
|
- [Core](#core) (5)
|
|
17
17
|
- [DOM Generation](#dom-generation) (10)
|
|
18
|
+
- [DOM Selection](#dom-selection) (1)
|
|
18
19
|
- [Identifiers](#identifiers) (4)
|
|
19
20
|
- [State Management](#state-management) (3)
|
|
20
21
|
- [Events (DOM)](#events-dom-) (2)
|
|
21
|
-
- [Pub/Sub](#pub-sub) (
|
|
22
|
+
- [Pub/Sub](#pub-sub) (4)
|
|
22
23
|
- [CSS & Styling](#css-styling) (10)
|
|
23
24
|
- [Component Builders](#component-builders) (50)
|
|
24
25
|
- [Browser Utilities](#browser-utilities) (4)
|
|
25
26
|
- [Utilities](#utilities) (1)
|
|
26
27
|
- [Function Registry](#function-registry) (5)
|
|
27
|
-
- [Component](#component) (
|
|
28
|
+
- [Component](#component) (5)
|
|
29
|
+
- [Data Utilities](#data-utilities) (1)
|
|
28
30
|
|
|
29
31
|
---
|
|
30
32
|
|
|
@@ -293,6 +295,28 @@ Get all registered component handles as a Map.
|
|
|
293
295
|
|
|
294
296
|
---
|
|
295
297
|
|
|
298
|
+
## DOM Selection
|
|
299
|
+
|
|
300
|
+
### `bw.el(target, apply)`
|
|
301
|
+
|
|
302
|
+
Look up a single DOM element by ID, CSS selector, UUID, or element ref. Optionally apply content or a function to the resolved element. Resolution order for string targets: 1. Check `bw._nodeMap[id]` cache (O(1), stale entries auto-pruned) 2. `document.getElementById(id)` 3. `document.querySelector(id)` for selectors starting with # or . 4. Class-based lookup for `bw_uuid_*` tokens With one argument, returns the element (or null). With two arguments, applies the second argument to the element and returns the element: - string/number: sets `el.textContent` - function: calls `apply(el)`, returns el - TACO object: clears children, mounts TACO via `bw.createDOM()` - array: clears children, appends each item (string -> text node, TACO -> element)
|
|
303
|
+
|
|
304
|
+
**Parameters:**
|
|
305
|
+
|
|
306
|
+
| Name | Type | Description |
|
|
307
|
+
|------|------|-------------|
|
|
308
|
+
| `target` | `string|Element` | - Element ref, ID, CSS selector, or bw_uuid_* class |
|
|
309
|
+
| `apply` | `string|number|Function|Object|Array` | - Content or function to apply |
|
|
310
|
+
|
|
311
|
+
**Returns:** `Element|null` — DOM element, or null if not found
|
|
312
|
+
|
|
313
|
+
**Example:**
|
|
314
|
+
```javascript
|
|
315
|
+
bw.el('#title') // lookup bw.el('#title', 'Hello') // set text content bw.el('#app', { t: 'h1', c: 'Hi' }) // mount TACO bw.el('.card', function(el) { // apply function el.style.opacity = '0.5'; })
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
296
320
|
## Identifiers
|
|
297
321
|
|
|
298
322
|
### `bw.uuid(prefix)`
|
|
@@ -488,32 +512,32 @@ Publish to a topic, calling all subscribers in registration order. Application-s
|
|
|
488
512
|
| `topic` | `string` | - Topic name (plain string, no prefix) |
|
|
489
513
|
| `detail` | `*` | - Data to pass to subscribers |
|
|
490
514
|
|
|
491
|
-
**Returns:** `number` — of successfully called subscribers
|
|
515
|
+
**Returns:** `number` — of successfully called subscribers (including wildcard matches)
|
|
492
516
|
|
|
493
517
|
**Example:**
|
|
494
518
|
```javascript
|
|
495
|
-
bw.pub('score:updated', { player: 'X', score: 10 });
|
|
519
|
+
bw.pub('score:updated', { player: 'X', score: 10 }); // Wildcard subscribers matching 'score:*' will also fire
|
|
496
520
|
```
|
|
497
521
|
|
|
498
522
|
---
|
|
499
523
|
|
|
500
524
|
### `bw.sub(topic, handler, el)`
|
|
501
525
|
|
|
502
|
-
Subscribe to a topic. Returns an unsub() function. Optional third argument ties the subscription to a DOM element's lifecycle
|
|
526
|
+
Subscribe to a topic. Returns an unsub() function. Supports wildcard patterns: a topic ending in `*` matches any published topic that starts with the prefix before the `*`. For example, `'agui:*'` matches `'agui:ready'`, `'agui:error'`, etc. The handler receives `(detail, topic)` so it can distinguish which topic fired. Optional third argument ties the subscription to a DOM element's lifecycle -- when `bw.cleanup()` is called on that element, the subscription is automatically removed, preventing memory leaks.
|
|
503
527
|
|
|
504
528
|
**Parameters:**
|
|
505
529
|
|
|
506
530
|
| Name | Type | Description |
|
|
507
531
|
|------|------|-------------|
|
|
508
|
-
| `topic` | `string` | - Topic name |
|
|
509
|
-
| `handler` | `Function` | - Called with (detail) on each publish |
|
|
532
|
+
| `topic` | `string` | - Topic name, or wildcard pattern ending in '*' |
|
|
533
|
+
| `handler` | `Function` | - Called with (detail, topic) on each publish |
|
|
510
534
|
| `el` | `Element` | - Optional DOM element to tie lifecycle to |
|
|
511
535
|
|
|
512
536
|
**Returns:** `Function` — to unsubscribe
|
|
513
537
|
|
|
514
538
|
**Example:**
|
|
515
539
|
```javascript
|
|
516
|
-
var unsub = bw.sub('score:updated', function(detail) { console.log(detail.player, 'scored', detail.score); }); // Later: unsub() to stop listening
|
|
540
|
+
var unsub = bw.sub('score:updated', function(detail) { console.log(detail.player, 'scored', detail.score); }); // Later: unsub() to stop listening // Wildcard: listen to all 'agui:' topics bw.sub('agui:*', function(detail, topic) { console.log('Got', topic, detail); });
|
|
517
541
|
```
|
|
518
542
|
|
|
519
543
|
---
|
|
@@ -533,6 +557,27 @@ Unsubscribe a handler by reference from a topic. Removes ALL instances of the gi
|
|
|
533
557
|
|
|
534
558
|
---
|
|
535
559
|
|
|
560
|
+
### `bw.once(topic, handler, el)`
|
|
561
|
+
|
|
562
|
+
Subscribe to a topic for a single event only. The subscription is automatically removed after the first publish. Equivalent to manually calling unsub() inside a bw.sub() handler, but avoids the common bug of forgetting to unsubscribe.
|
|
563
|
+
|
|
564
|
+
**Parameters:**
|
|
565
|
+
|
|
566
|
+
| Name | Type | Description |
|
|
567
|
+
|------|------|-------------|
|
|
568
|
+
| `topic` | `string` | - Topic name |
|
|
569
|
+
| `handler` | `Function` | - Called once with (detail) on the next publish |
|
|
570
|
+
| `el` | `Element` | - Optional DOM element to tie lifecycle to |
|
|
571
|
+
|
|
572
|
+
**Returns:** `Function` — to cancel the subscription before it fires
|
|
573
|
+
|
|
574
|
+
**Example:**
|
|
575
|
+
```javascript
|
|
576
|
+
bw.once('data:loaded', function(detail) { console.log('Received:', detail); // No need to unsubscribe -- already done automatically }); // Cancel before it fires: var cancel = bw.once('timeout', handler); cancel(); // handler will never be called
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
536
581
|
## CSS & Styling
|
|
537
582
|
|
|
538
583
|
### `bw.css(rules, options = {})`
|
|
@@ -672,7 +717,7 @@ Generate and apply styles in one call. Convenience wrapper. Equivalent to: `bw.a
|
|
|
672
717
|
| `config` | `Object` | - Style configuration (same as `makeStyles`) |
|
|
673
718
|
| `scope` | `string` | - Scope selector (same as `applyStyles`) |
|
|
674
719
|
|
|
675
|
-
**Returns:** `
|
|
720
|
+
**Returns:** `Object` — styles object (same as `makeStyles` return value: `{css, alternateCss, palette, alternatePalette, rules, alternateRules, isLightPrimary}`)
|
|
676
721
|
|
|
677
722
|
**Example:**
|
|
678
723
|
```javascript
|
|
@@ -694,21 +739,21 @@ bw.loadReset(); // inject once, safe to call multiple times
|
|
|
694
739
|
|
|
695
740
|
---
|
|
696
741
|
|
|
697
|
-
### `bw.
|
|
742
|
+
### `bw.toggleThemeMode(scope)`
|
|
698
743
|
|
|
699
|
-
Toggle between primary and alternate palettes. Adds/removes the `bw_theme_alt` class on the scoping element. Without a scope, toggles on `<html>` (global). With a scope, toggles on
|
|
744
|
+
Toggle between primary and alternate theme palettes. Adds/removes the `bw_theme_alt` class on the scoping element(s). Without a scope, toggles on `<html>` (global). With a scope, toggles on ALL matching elements.
|
|
700
745
|
|
|
701
746
|
**Parameters:**
|
|
702
747
|
|
|
703
748
|
| Name | Type | Description |
|
|
704
749
|
|------|------|-------------|
|
|
705
|
-
| `scope` | `string` | -
|
|
750
|
+
| `scope` | `string|Element` | - Selector or element. Omit for global. |
|
|
706
751
|
|
|
707
|
-
**Returns:** `string` — mode after toggle: 'primary' or 'alternate'
|
|
752
|
+
**Returns:** `string` — mode after toggle: 'primary' or 'alternate' (based on first element)
|
|
708
753
|
|
|
709
754
|
**Example:**
|
|
710
755
|
```javascript
|
|
711
|
-
bw.
|
|
756
|
+
bw.toggleThemeMode(); // global toggle on <html> bw.toggleThemeMode('#my-dashboard'); // scoped toggle bw.toggleThemeMode('.panel'); // toggle on ALL .panel elements
|
|
712
757
|
```
|
|
713
758
|
|
|
714
759
|
---
|
|
@@ -2212,21 +2257,86 @@ bw.message('my_carousel', 'goToSlide', 2); // Or from SSE handler: es.onmessage
|
|
|
2212
2257
|
|
|
2213
2258
|
---
|
|
2214
2259
|
|
|
2215
|
-
### `bw.
|
|
2260
|
+
### `bw.formData(target)`
|
|
2261
|
+
|
|
2262
|
+
Collect form data from all input, select, and textarea elements within a container. Each element's `name` attribute (or `id` if no name) becomes a key in the returned object. This provides a lightweight alternative to the browser FormData API that returns a plain object suitable for JSON serialization or bw.pub(). Handles all standard HTML form controls: - text/number/email/etc inputs: string value - checkboxes: boolean (true/false) - radio buttons: string value of the checked radio (unchecked groups omitted) - multi-select: array of selected option values - textarea: string value Elements without both `name` and `id` attributes are silently skipped.
|
|
2263
|
+
|
|
2264
|
+
**Parameters:**
|
|
2265
|
+
|
|
2266
|
+
| Name | Type | Description |
|
|
2267
|
+
|------|------|-------------|
|
|
2268
|
+
| `target` | `string|Element` | - CSS selector, UUID string, or DOM element |
|
|
2269
|
+
|
|
2270
|
+
**Returns:** `Object` — object mapping field names to values
|
|
2271
|
+
|
|
2272
|
+
**Example:**
|
|
2273
|
+
```javascript
|
|
2274
|
+
// Given a form with name="email" input and name="agree" checkbox: var data = bw.formData('#signup-form'); // => { email: 'user@example.com', agree: true } // Collect and publish in one step: bw.pub('form:submit', bw.formData('#my-form')); // Works with any container, not just <form>: bw.pub('settings:changed', bw.formData('.settings-panel'));
|
|
2275
|
+
```
|
|
2276
|
+
|
|
2277
|
+
---
|
|
2278
|
+
|
|
2279
|
+
### `bw.inspect(target, depth)`
|
|
2280
|
+
|
|
2281
|
+
Inspect a DOM element and its subtree, returning a plain-object representation with bitwrench metadata at each node. Useful for debugging, devtools, MCP/AG-UI tool discovery, and automated testing. Each node in the returned tree includes: - `tag` -- lowercase tag name (or '#text' for text nodes) - `id` -- element id (if set) - `uuid` -- bitwrench UUID class (if lifecycle-managed) - `type` -- component type from o.type (if set, e.g. 'card', 'tabs') - `classes` -- first 5 CSS classes (string, space-separated) - `handles` -- array of el.bw method names (if any) - `state` -- copy of _bw_state (if any) - `hasRender` -- true if _bw_render is set - `hasSubs` -- true if element has pub/sub subscriptions - `refs` -- copy of _bw_refs keys (if any) - `children` -- array of child node trees (up to depth limit, max 50 per level)
|
|
2282
|
+
|
|
2283
|
+
**Parameters:**
|
|
2284
|
+
|
|
2285
|
+
| Name | Type | Description |
|
|
2286
|
+
|------|------|-------------|
|
|
2287
|
+
| `target` | `string|Element` | - CSS selector, UUID, or DOM element |
|
|
2288
|
+
| `depth` | `number` | - Maximum recursion depth (0 = target only, no children) |
|
|
2289
|
+
|
|
2290
|
+
**Returns:** `Object|null` — object tree, or null if element not found
|
|
2291
|
+
|
|
2292
|
+
**Example:**
|
|
2293
|
+
```javascript
|
|
2294
|
+
// Get full tree from #app, 3 levels deep (default): var info = bw.inspect('#app'); // Shallow inspection (just the element, no children): var info = bw.inspect('#my-carousel', 0); console.log(info.handles); // ['next', 'prev', 'goToSlide'] console.log(info.type); // 'carousel' // Deep inspection for debugging: console.log(JSON.stringify(bw.inspect('#app', 5), null, 2));
|
|
2295
|
+
```
|
|
2296
|
+
|
|
2297
|
+
---
|
|
2298
|
+
|
|
2299
|
+
### `bw.catalog(type)`
|
|
2300
|
+
|
|
2301
|
+
Query the BCCL component registry. Returns metadata about registered component types -- their names and factory function names. Useful for tooling, introspection, documentation generators, and auto-complete systems (including MCP/AG-UI tool discovery). With no arguments, returns an array of all registered component types. With a type name, returns metadata for that single type (or null if the type is not registered).
|
|
2302
|
+
|
|
2303
|
+
**Parameters:**
|
|
2304
|
+
|
|
2305
|
+
| Name | Type | Description |
|
|
2306
|
+
|------|------|-------------|
|
|
2307
|
+
| `type` | `string` | - Optional component type name to look up |
|
|
2308
|
+
|
|
2309
|
+
**Returns:** `Array<Object>|Object|null` — of {type, factory} objects, a single {type, factory} object, or null if the type is not found
|
|
2310
|
+
|
|
2311
|
+
**Example:**
|
|
2312
|
+
```javascript
|
|
2313
|
+
// List all available component types: bw.catalog(); // => [{ type: 'card', factory: 'makeCard' }, // { type: 'button', factory: 'makeButton' }, ...] // Look up a specific type: bw.catalog('accordion'); // => { type: 'accordion', factory: 'makeAccordion' } // Check if a type exists: if (bw.catalog('chart')) { ... } // Get just the type names: bw.catalog().map(function(c) { return c.type; }); // => ['card', 'button', 'container', 'row', ...]
|
|
2314
|
+
```
|
|
2315
|
+
|
|
2316
|
+
---
|
|
2317
|
+
|
|
2318
|
+
## Data Utilities
|
|
2319
|
+
|
|
2320
|
+
### `bw.jsonPatch(obj, ops)`
|
|
2216
2321
|
|
|
2217
|
-
|
|
2322
|
+
Apply RFC 6902 JSON Patch operations to a plain object. Supported operations: add, remove, replace, move, copy, test. Paths use JSON Pointer (RFC 6901) notation: `/foo/bar/0`. Mutates the target object in place and returns it.
|
|
2218
2323
|
|
|
2219
2324
|
**Parameters:**
|
|
2220
2325
|
|
|
2221
2326
|
| Name | Type | Description |
|
|
2222
2327
|
|------|------|-------------|
|
|
2223
|
-
| `
|
|
2328
|
+
| `obj` | `Object` | - Target object to patch |
|
|
2329
|
+
| `ops` | `Array<Object>` | - Array of patch operations |
|
|
2330
|
+
| `ops[].op` | `string` | - Operation: 'add', 'remove', 'replace', 'move', 'copy', 'test' |
|
|
2331
|
+
| `ops[].path` | `string` | - JSON Pointer path (e.g. '/a/b/0') |
|
|
2332
|
+
| `ops[].value` | `*` | - Value for add/replace/test |
|
|
2333
|
+
| `ops[].from` | `string` | - Source path for move/copy |
|
|
2224
2334
|
|
|
2225
|
-
**Returns:** `
|
|
2335
|
+
**Returns:** `Object` — patched object (same reference)
|
|
2226
2336
|
|
|
2227
2337
|
**Example:**
|
|
2228
2338
|
```javascript
|
|
2229
|
-
bw.
|
|
2339
|
+
var obj = { a: 1, b: { c: 2 } }; bw.jsonPatch(obj, [ { op: 'replace', path: '/a', value: 10 }, { op: 'add', path: '/b/d', value: 3 }, { op: 'remove', path: '/b/c' } ]); // obj => { a: 10, b: { d: 3 } }
|
|
2230
2340
|
```
|
|
2231
2341
|
|
|
2232
2342
|
---
|