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
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
// bitwrench TypeScript type definitions
|
|
2
|
+
// https://github.com/deftio/bitwrench
|
|
3
|
+
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// TACO format types
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
/** Raw HTML marker returned by bw.raw() */
|
|
9
|
+
export interface BwRaw {
|
|
10
|
+
__bw_raw: true;
|
|
11
|
+
v: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** TACO content: text, nested TACO, array of mixed, raw HTML, or null */
|
|
15
|
+
export type TacoContent =
|
|
16
|
+
| string
|
|
17
|
+
| number
|
|
18
|
+
| Taco
|
|
19
|
+
| TacoContent[]
|
|
20
|
+
| BwRaw
|
|
21
|
+
| null
|
|
22
|
+
| undefined;
|
|
23
|
+
|
|
24
|
+
/** TACO attributes object */
|
|
25
|
+
export interface TacoAttributes {
|
|
26
|
+
id?: string;
|
|
27
|
+
class?: string | string[];
|
|
28
|
+
style?: string | Record<string, string | number>;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
readonly?: boolean;
|
|
31
|
+
checked?: boolean;
|
|
32
|
+
selected?: boolean;
|
|
33
|
+
value?: string | number;
|
|
34
|
+
type?: string;
|
|
35
|
+
href?: string;
|
|
36
|
+
src?: string;
|
|
37
|
+
alt?: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
for?: string;
|
|
42
|
+
target?: string;
|
|
43
|
+
rel?: string;
|
|
44
|
+
role?: string;
|
|
45
|
+
tabindex?: number | string;
|
|
46
|
+
/** Event handlers: function or string */
|
|
47
|
+
onclick?: ((e: Event) => void) | string;
|
|
48
|
+
onchange?: ((e: Event) => void) | string;
|
|
49
|
+
oninput?: ((e: Event) => void) | string;
|
|
50
|
+
onsubmit?: ((e: Event) => void) | string;
|
|
51
|
+
onkeydown?: ((e: Event) => void) | string;
|
|
52
|
+
onkeyup?: ((e: Event) => void) | string;
|
|
53
|
+
onmouseover?: ((e: Event) => void) | string;
|
|
54
|
+
onmouseout?: ((e: Event) => void) | string;
|
|
55
|
+
onfocus?: ((e: Event) => void) | string;
|
|
56
|
+
onblur?: ((e: Event) => void) | string;
|
|
57
|
+
/** Any other HTML attribute */
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** TACO options object -- lifecycle, state, component handles */
|
|
62
|
+
export interface TacoOptions {
|
|
63
|
+
/** Component state, stored on el._bw_state */
|
|
64
|
+
state?: Record<string, any>;
|
|
65
|
+
/** Called after element created and in DOM */
|
|
66
|
+
mounted?: (el: HTMLElement, state?: Record<string, any>) => void;
|
|
67
|
+
/** Called on bw.cleanup() */
|
|
68
|
+
unmount?: (el: HTMLElement, state?: Record<string, any>) => void;
|
|
69
|
+
/** Called by bw.update(); stored on el._bw_render */
|
|
70
|
+
render?: (el: HTMLElement, state?: Record<string, any>) => void;
|
|
71
|
+
/** Methods attached to el.bw namespace */
|
|
72
|
+
handle?: Record<string, (el: HTMLElement, ...args: any[]) => any>;
|
|
73
|
+
/** Slot selectors: auto-generates el.bw.setName()/getName() */
|
|
74
|
+
slots?: Record<string, string>;
|
|
75
|
+
/** Component type identifier (used internally by BCCL) */
|
|
76
|
+
type?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* TACO object -- Tag, Attributes, Content, Options.
|
|
81
|
+
* The core UI primitive in bitwrench.
|
|
82
|
+
*/
|
|
83
|
+
export interface Taco {
|
|
84
|
+
/** HTML tag name */
|
|
85
|
+
t: string;
|
|
86
|
+
/** HTML attributes, event handlers, classes, styles */
|
|
87
|
+
a?: TacoAttributes;
|
|
88
|
+
/** Content: text, nested TACO, array, raw HTML */
|
|
89
|
+
c?: TacoContent;
|
|
90
|
+
/** Options: lifecycle hooks, state, component handles */
|
|
91
|
+
o?: TacoOptions;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// Styles / theming types
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
/** Color shade object generated by bw.deriveShades() */
|
|
99
|
+
export interface ColorShades {
|
|
100
|
+
base: string;
|
|
101
|
+
hover: string;
|
|
102
|
+
active: string;
|
|
103
|
+
light: string;
|
|
104
|
+
darkText: string;
|
|
105
|
+
border: string;
|
|
106
|
+
focus: string;
|
|
107
|
+
textOn: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Full palette generated by bw.derivePalette() or bw.makeStyles() */
|
|
111
|
+
export interface Palette {
|
|
112
|
+
primary: ColorShades;
|
|
113
|
+
secondary: ColorShades;
|
|
114
|
+
tertiary: ColorShades;
|
|
115
|
+
success: ColorShades;
|
|
116
|
+
danger: ColorShades;
|
|
117
|
+
warning: ColorShades;
|
|
118
|
+
info: ColorShades;
|
|
119
|
+
light: ColorShades;
|
|
120
|
+
dark: ColorShades;
|
|
121
|
+
/** Plain string, not a ColorShades object */
|
|
122
|
+
background: string;
|
|
123
|
+
/** Plain string, not a ColorShades object */
|
|
124
|
+
surface: string;
|
|
125
|
+
/** Plain string, not a ColorShades object */
|
|
126
|
+
surfaceAlt: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Seed color config for bw.makeStyles() and bw.loadStyles() */
|
|
130
|
+
export interface StyleConfig {
|
|
131
|
+
primary?: string;
|
|
132
|
+
secondary?: string;
|
|
133
|
+
tertiary?: string;
|
|
134
|
+
success?: string;
|
|
135
|
+
danger?: string;
|
|
136
|
+
warning?: string;
|
|
137
|
+
info?: string;
|
|
138
|
+
light?: string;
|
|
139
|
+
dark?: string;
|
|
140
|
+
background?: string;
|
|
141
|
+
surface?: string;
|
|
142
|
+
surfaceAlt?: string;
|
|
143
|
+
palette?: Partial<Palette>;
|
|
144
|
+
spacing?: string;
|
|
145
|
+
radius?: string;
|
|
146
|
+
typeRatio?: string;
|
|
147
|
+
elevation?: string;
|
|
148
|
+
motion?: string;
|
|
149
|
+
compact?: boolean;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Result of bw.makeStyles() */
|
|
153
|
+
export interface StylesResult {
|
|
154
|
+
css: string;
|
|
155
|
+
alternateCss: string;
|
|
156
|
+
palette: Palette;
|
|
157
|
+
alternatePalette: Palette;
|
|
158
|
+
rules: Record<string, any>;
|
|
159
|
+
alternateRules: Record<string, any>;
|
|
160
|
+
isLightPrimary: boolean;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// Component config types (BCCL make*() factories)
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
|
|
167
|
+
export type Variant =
|
|
168
|
+
| 'primary' | 'secondary' | 'tertiary'
|
|
169
|
+
| 'success' | 'danger' | 'warning' | 'info'
|
|
170
|
+
| 'light' | 'dark';
|
|
171
|
+
|
|
172
|
+
export interface CardConfig {
|
|
173
|
+
title?: string | Taco;
|
|
174
|
+
content?: string | Taco | TacoContent[];
|
|
175
|
+
footer?: string | Taco;
|
|
176
|
+
image?: string;
|
|
177
|
+
variant?: Variant;
|
|
178
|
+
shadow?: boolean | string;
|
|
179
|
+
clickable?: boolean;
|
|
180
|
+
style?: Record<string, string | number>;
|
|
181
|
+
class?: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface ButtonConfig {
|
|
185
|
+
text?: string | Taco;
|
|
186
|
+
variant?: Variant;
|
|
187
|
+
size?: 'sm' | 'md' | 'lg';
|
|
188
|
+
outline?: boolean;
|
|
189
|
+
disabled?: boolean;
|
|
190
|
+
block?: boolean;
|
|
191
|
+
onclick?: (e: Event) => void;
|
|
192
|
+
type?: string;
|
|
193
|
+
style?: Record<string, string | number>;
|
|
194
|
+
class?: string;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface NavConfig {
|
|
198
|
+
items: Array<{ text: string; href?: string; active?: boolean; onclick?: (e: Event) => void }>;
|
|
199
|
+
variant?: Variant;
|
|
200
|
+
vertical?: boolean;
|
|
201
|
+
style?: Record<string, string | number>;
|
|
202
|
+
class?: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface TabsConfig {
|
|
206
|
+
tabs: Array<{ text: string; content: TacoContent; active?: boolean }>;
|
|
207
|
+
variant?: Variant;
|
|
208
|
+
style?: Record<string, string | number>;
|
|
209
|
+
class?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface AccordionConfig {
|
|
213
|
+
items: Array<{ title: string; content: TacoContent }>;
|
|
214
|
+
multiple?: boolean;
|
|
215
|
+
variant?: Variant;
|
|
216
|
+
style?: Record<string, string | number>;
|
|
217
|
+
class?: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ModalConfig {
|
|
221
|
+
title?: string | Taco;
|
|
222
|
+
content?: TacoContent;
|
|
223
|
+
footer?: TacoContent;
|
|
224
|
+
size?: 'sm' | 'md' | 'lg';
|
|
225
|
+
closable?: boolean;
|
|
226
|
+
variant?: Variant;
|
|
227
|
+
style?: Record<string, string | number>;
|
|
228
|
+
class?: string;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface AlertConfig {
|
|
232
|
+
content?: string | Taco;
|
|
233
|
+
variant?: Variant;
|
|
234
|
+
dismissible?: boolean;
|
|
235
|
+
style?: Record<string, string | number>;
|
|
236
|
+
class?: string;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface TableConfig {
|
|
240
|
+
columns?: Array<string | { key: string; label?: string; sortable?: boolean }>;
|
|
241
|
+
rows?: Array<Record<string, any>>;
|
|
242
|
+
data?: Array<Record<string, any>>;
|
|
243
|
+
sortable?: boolean;
|
|
244
|
+
striped?: boolean;
|
|
245
|
+
bordered?: boolean;
|
|
246
|
+
hover?: boolean;
|
|
247
|
+
style?: Record<string, string | number>;
|
|
248
|
+
class?: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface InputConfig {
|
|
252
|
+
type?: string;
|
|
253
|
+
label?: string;
|
|
254
|
+
placeholder?: string;
|
|
255
|
+
value?: string | number;
|
|
256
|
+
name?: string;
|
|
257
|
+
disabled?: boolean;
|
|
258
|
+
required?: boolean;
|
|
259
|
+
onchange?: (e: Event) => void;
|
|
260
|
+
oninput?: (e: Event) => void;
|
|
261
|
+
style?: Record<string, string | number>;
|
|
262
|
+
class?: string;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface CarouselConfig {
|
|
266
|
+
items: TacoContent[];
|
|
267
|
+
autoPlay?: boolean;
|
|
268
|
+
interval?: number;
|
|
269
|
+
indicators?: boolean;
|
|
270
|
+
controls?: boolean;
|
|
271
|
+
style?: Record<string, string | number>;
|
|
272
|
+
class?: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** Generic config for BCCL components not individually typed */
|
|
276
|
+
export interface ComponentConfig {
|
|
277
|
+
[key: string]: any;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ---------------------------------------------------------------------------
|
|
281
|
+
// Router types
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
|
|
284
|
+
export interface RouterConfig {
|
|
285
|
+
routes: Record<string, (params: Record<string, string>) => Taco>;
|
|
286
|
+
mode?: 'hash' | 'history';
|
|
287
|
+
base?: string;
|
|
288
|
+
target?: string;
|
|
289
|
+
before?: (path: string) => boolean | void;
|
|
290
|
+
after?: (path: string) => void;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface RouterHandle {
|
|
294
|
+
navigate: (path: string, opts?: { replace?: boolean }) => void;
|
|
295
|
+
current: () => string;
|
|
296
|
+
destroy: () => void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ---------------------------------------------------------------------------
|
|
300
|
+
// Main bw namespace
|
|
301
|
+
// ---------------------------------------------------------------------------
|
|
302
|
+
|
|
303
|
+
export interface Bitwrench {
|
|
304
|
+
// -- Version & Environment ------------------------------------------------
|
|
305
|
+
version: string;
|
|
306
|
+
versionInfo: { version: string; name: string; buildDate: string; gitHash: string };
|
|
307
|
+
readonly _isBrowser: boolean;
|
|
308
|
+
_isNode: boolean;
|
|
309
|
+
debug: boolean;
|
|
310
|
+
|
|
311
|
+
// -- TACO Construction & Rendering ----------------------------------------
|
|
312
|
+
/** Create TACO from positional args */
|
|
313
|
+
h(tag: string, attrs?: TacoAttributes | null, content?: TacoContent, options?: TacoOptions): Taco;
|
|
314
|
+
/** Render TACO to HTML string */
|
|
315
|
+
html(taco: Taco | TacoContent, options?: { raw?: boolean; state?: Record<string, any> }): string;
|
|
316
|
+
/** Generate complete HTML page string */
|
|
317
|
+
htmlPage(opts: { title?: string; css?: string; content?: TacoContent; favicon?: string; [key: string]: any }): string;
|
|
318
|
+
/** Create DOM element from TACO (browser only). SVG TACOs ({t:'svg',...}) use createElementNS. */
|
|
319
|
+
createDOM(taco: Taco | TacoContent, options?: Record<string, any>): HTMLElement | SVGElement | DocumentFragment;
|
|
320
|
+
/** Mount TACO into target, replacing contents */
|
|
321
|
+
DOM(target: string | HTMLElement, taco: Taco | TacoContent, options?: Record<string, any>): void;
|
|
322
|
+
/** Mount TACO and return root element (for el.bw access) */
|
|
323
|
+
mount(target: string | HTMLElement, taco: Taco | TacoContent, options?: Record<string, any>): HTMLElement;
|
|
324
|
+
/** Mark string as pre-escaped HTML */
|
|
325
|
+
raw(str: string): BwRaw;
|
|
326
|
+
/** Escape HTML special characters */
|
|
327
|
+
escapeHTML(str: string): string;
|
|
328
|
+
|
|
329
|
+
// -- Lifecycle & State ----------------------------------------------------
|
|
330
|
+
/** Call el._bw_render to re-render element */
|
|
331
|
+
update(target: string | HTMLElement): void;
|
|
332
|
+
/** Quick-patch element content or attribute */
|
|
333
|
+
patch(id: string | HTMLElement, content?: TacoContent, attr?: string): HTMLElement | null;
|
|
334
|
+
/** RFC 6902 JSON Patch on plain objects. Mutates and returns obj. @see bw.patch */
|
|
335
|
+
jsonPatch(obj: object, ops: Array<{ op: string; path: string; value?: any; from?: string }>): object;
|
|
336
|
+
/** Batch patch multiple elements */
|
|
337
|
+
patchAll(patches: Record<string, TacoContent> | Array<{ id: string; content?: TacoContent; attr?: string }>): Record<string, HTMLElement>;
|
|
338
|
+
/** Clean up lifecycle hooks, subscriptions, cache */
|
|
339
|
+
cleanup(element: HTMLElement): void;
|
|
340
|
+
|
|
341
|
+
// -- DOM Selection --------------------------------------------------------
|
|
342
|
+
/** Resolve target to first matching element. Optional apply: string (textContent), function, TACO (mount), or array. @see bw.$ */
|
|
343
|
+
el(target: string | HTMLElement | null, apply?: string | number | boolean | Function | object | any[]): HTMLElement | null;
|
|
344
|
+
/** CSS selector to array of elements. Optional apply applied to each. @see bw.el */
|
|
345
|
+
$(selector: string | HTMLElement | HTMLElement[], apply?: string | number | boolean | Function | object | any[]): HTMLElement[];
|
|
346
|
+
/** Dispatch DOM event */
|
|
347
|
+
emit(target: string | HTMLElement, eventName: string, detail?: any): void;
|
|
348
|
+
/** Add event listener */
|
|
349
|
+
on(target: string | HTMLElement, eventName: string, handler: (e: Event) => void): void;
|
|
350
|
+
|
|
351
|
+
// -- Pub/Sub --------------------------------------------------------------
|
|
352
|
+
/** Publish to topic. Fires exact-match and wildcard subscribers. */
|
|
353
|
+
pub(topic: string, detail?: any): number;
|
|
354
|
+
/** Subscribe to topic (or wildcard pattern ending in '*'); returns unsub(). Handler receives (detail, topic). */
|
|
355
|
+
sub(topic: string, handler: (detail: any, topic?: string) => void, el?: HTMLElement): () => void;
|
|
356
|
+
/** Unsubscribe handler from topic */
|
|
357
|
+
unsub(topic: string, handler: Function): number;
|
|
358
|
+
|
|
359
|
+
// -- UUID & Identity ------------------------------------------------------
|
|
360
|
+
/** Generate unique ID */
|
|
361
|
+
uuid(prefix?: string): string;
|
|
362
|
+
/** Assign UUID class to TACO */
|
|
363
|
+
assignUUID(taco: Taco, forceNew?: boolean): string | null;
|
|
364
|
+
/** Read UUID from TACO or DOM element */
|
|
365
|
+
getUUID(tacoOrElement: Taco | HTMLElement): string | null;
|
|
366
|
+
|
|
367
|
+
// -- Component Messages ---------------------------------------------------
|
|
368
|
+
/** Call method on el.bw: el.bw[action](data) */
|
|
369
|
+
message(target: string | HTMLElement, action: string, data?: any): any;
|
|
370
|
+
/** Execute wire-protocol message object */
|
|
371
|
+
apply(msg: Record<string, any>): any;
|
|
372
|
+
/** Inspect DOM element and subtree, returning plain-object tree with bitwrench metadata */
|
|
373
|
+
inspect(target: string | HTMLElement, depth?: number): Record<string, any> | null;
|
|
374
|
+
|
|
375
|
+
// -- Function Registry ----------------------------------------------------
|
|
376
|
+
funcRegister(fn: Function, name?: string): string;
|
|
377
|
+
funcGetById(name: string, errFn?: Function): Function | null;
|
|
378
|
+
funcGetDispatchStr(name: string, argStr?: string): string;
|
|
379
|
+
funcUnregister(name: string): void;
|
|
380
|
+
funcGetRegistry(): Record<string, Function>;
|
|
381
|
+
|
|
382
|
+
// -- Component Registry ---------------------------------------------------
|
|
383
|
+
render(element: HTMLElement, position: string, taco: Taco): string;
|
|
384
|
+
getComponent(id: string): Record<string, any> | null;
|
|
385
|
+
getAllComponents(): Map<string, any>;
|
|
386
|
+
|
|
387
|
+
// -- CSS & Styles ---------------------------------------------------------
|
|
388
|
+
/** Generate CSS string from JS object */
|
|
389
|
+
css(rules: Record<string, any>, options?: { scopeSelector?: string; selector?: string }): string;
|
|
390
|
+
/** Inject CSS into document */
|
|
391
|
+
injectCSS(css: string, options?: { id?: string; append?: boolean; scope?: string }): HTMLElement;
|
|
392
|
+
/** Responsive media query helper */
|
|
393
|
+
responsive(selector: string, breakpoints: Record<string, Record<string, any>>): string;
|
|
394
|
+
/** Generate styles from config */
|
|
395
|
+
makeStyles(config: StyleConfig): StylesResult;
|
|
396
|
+
/** Inject generated styles */
|
|
397
|
+
applyStyles(styles: StylesResult, scope?: string): void;
|
|
398
|
+
/** Generate + apply (no args = structural CSS only) */
|
|
399
|
+
loadStyles(config?: StyleConfig, scope?: string): StylesResult | void;
|
|
400
|
+
/** Load CSS reset */
|
|
401
|
+
loadReset(): void;
|
|
402
|
+
/** Toggle between primary/alternate theme palettes on all matching elements. @see bw.applyStyles */
|
|
403
|
+
toggleThemeMode(scope?: string | HTMLElement): string;
|
|
404
|
+
/** @deprecated Use bw.toggleThemeMode() instead. Alias kept for one release cycle. */
|
|
405
|
+
toggleStyles(scope?: string | HTMLElement): string;
|
|
406
|
+
/** Remove injected styles */
|
|
407
|
+
clearStyles(scope?: string): void;
|
|
408
|
+
/** Generate type scale from base + ratio */
|
|
409
|
+
generateTypeScale(baseSize: number, ratio: number, steps: number): Record<string, any>;
|
|
410
|
+
|
|
411
|
+
// -- Color Utilities ------------------------------------------------------
|
|
412
|
+
hexToHsl(hex: string): [number, number, number];
|
|
413
|
+
hslToHex(hsl: [number, number, number]): string;
|
|
414
|
+
adjustLightness(hex: string, amount: number): string;
|
|
415
|
+
mixColor(hex1: string, hex2: string, ratio: number): string;
|
|
416
|
+
relativeLuminance(hex: string): number;
|
|
417
|
+
textOnColor(hex: string): string;
|
|
418
|
+
deriveShades(hex: string): ColorShades;
|
|
419
|
+
derivePalette(config: StyleConfig): Palette;
|
|
420
|
+
harmonize(sourceHex: string, targetHex: string, amount: number): string;
|
|
421
|
+
deriveAlternateSeed(hex: string): string;
|
|
422
|
+
deriveAlternateConfig(config: StyleConfig): StyleConfig;
|
|
423
|
+
isLightPalette(config: StyleConfig): boolean;
|
|
424
|
+
colorParse(str: string, defAlpha?: number): [number, number, number, number, string];
|
|
425
|
+
colorRgbToHsl(r: number, g: number, b: number, a?: number, rnd?: boolean): [number, number, number, number];
|
|
426
|
+
colorHslToRgb(h: number, s: number, l: number, a?: number, rnd?: boolean): [number, number, number, number];
|
|
427
|
+
colorInterp(x: number, in0: number, in1: number, colors: string[], stretch?: boolean): string;
|
|
428
|
+
|
|
429
|
+
// -- Router ---------------------------------------------------------------
|
|
430
|
+
router(config: RouterConfig): RouterHandle;
|
|
431
|
+
navigate(path: string, opts?: { replace?: boolean }): void;
|
|
432
|
+
link(path: string, content: TacoContent, attrs?: TacoAttributes): Taco;
|
|
433
|
+
|
|
434
|
+
// -- BCCL Component Factories (all return Taco) ---------------------------
|
|
435
|
+
make(type: string, props?: ComponentConfig): Taco;
|
|
436
|
+
makeCard(config?: CardConfig | string): Taco;
|
|
437
|
+
makeButton(config?: ButtonConfig | string): Taco;
|
|
438
|
+
makeContainer(config?: ComponentConfig): Taco;
|
|
439
|
+
makeRow(config?: ComponentConfig): Taco;
|
|
440
|
+
makeCol(config?: ComponentConfig): Taco;
|
|
441
|
+
makeStack(config?: ComponentConfig): Taco;
|
|
442
|
+
makeSection(config?: ComponentConfig): Taco;
|
|
443
|
+
makeNav(config?: NavConfig): Taco;
|
|
444
|
+
makeNavbar(config?: ComponentConfig): Taco;
|
|
445
|
+
makeBreadcrumb(config?: ComponentConfig): Taco;
|
|
446
|
+
makeTabs(config?: TabsConfig): Taco;
|
|
447
|
+
makePagination(config?: ComponentConfig): Taco;
|
|
448
|
+
makeAlert(config?: AlertConfig | string): Taco;
|
|
449
|
+
makeBadge(config?: ComponentConfig | string): Taco;
|
|
450
|
+
makeProgress(config?: ComponentConfig): Taco;
|
|
451
|
+
makeSpinner(config?: ComponentConfig): Taco;
|
|
452
|
+
makeToast(config?: ComponentConfig): Taco;
|
|
453
|
+
makeTooltip(config?: ComponentConfig): Taco;
|
|
454
|
+
makePopover(config?: ComponentConfig): Taco;
|
|
455
|
+
makeListGroup(config?: ComponentConfig): Taco;
|
|
456
|
+
makeAccordion(config?: AccordionConfig): Taco;
|
|
457
|
+
makeCarousel(config?: CarouselConfig): Taco;
|
|
458
|
+
makeTimeline(config?: ComponentConfig): Taco;
|
|
459
|
+
makeStepper(config?: ComponentConfig): Taco;
|
|
460
|
+
makeChipInput(config?: ComponentConfig): Taco;
|
|
461
|
+
makeModal(config?: ModalConfig): Taco;
|
|
462
|
+
makeDropdown(config?: ComponentConfig): Taco;
|
|
463
|
+
makeForm(config?: ComponentConfig): Taco;
|
|
464
|
+
makeFormGroup(config?: ComponentConfig): Taco;
|
|
465
|
+
makeInput(config?: InputConfig): Taco;
|
|
466
|
+
makeTextarea(config?: ComponentConfig): Taco;
|
|
467
|
+
makeSelect(config?: ComponentConfig): Taco;
|
|
468
|
+
makeCheckbox(config?: ComponentConfig): Taco;
|
|
469
|
+
makeRadio(config?: ComponentConfig): Taco;
|
|
470
|
+
makeSwitch(config?: ComponentConfig): Taco;
|
|
471
|
+
makeRange(config?: ComponentConfig): Taco;
|
|
472
|
+
makeFileUpload(config?: ComponentConfig): Taco;
|
|
473
|
+
makeSearchInput(config?: ComponentConfig): Taco;
|
|
474
|
+
makeButtonGroup(config?: ComponentConfig): Taco;
|
|
475
|
+
makeHero(config?: ComponentConfig): Taco;
|
|
476
|
+
makeFeatureGrid(config?: ComponentConfig): Taco;
|
|
477
|
+
makeCTA(config?: ComponentConfig): Taco;
|
|
478
|
+
makeCodeDemo(config?: ComponentConfig): Taco;
|
|
479
|
+
makeSkeleton(config?: ComponentConfig): Taco;
|
|
480
|
+
makeAvatar(config?: ComponentConfig): Taco;
|
|
481
|
+
makeStatCard(config?: ComponentConfig): Taco;
|
|
482
|
+
makeMediaObject(config?: ComponentConfig): Taco;
|
|
483
|
+
makeTable(config?: TableConfig): Taco;
|
|
484
|
+
makeTableFromArray(config?: TableConfig): Taco;
|
|
485
|
+
makeDataTable(config?: TableConfig): Taco;
|
|
486
|
+
makeBarChart(config?: ComponentConfig): Taco;
|
|
487
|
+
|
|
488
|
+
// -- Corresponding create* (return DOM Element) ---------------------------
|
|
489
|
+
createCard(config?: CardConfig | string): HTMLElement;
|
|
490
|
+
createButton(config?: ButtonConfig | string): HTMLElement;
|
|
491
|
+
createContainer(config?: ComponentConfig): HTMLElement;
|
|
492
|
+
createRow(config?: ComponentConfig): HTMLElement;
|
|
493
|
+
createCol(config?: ComponentConfig): HTMLElement;
|
|
494
|
+
createStack(config?: ComponentConfig): HTMLElement;
|
|
495
|
+
createSection(config?: ComponentConfig): HTMLElement;
|
|
496
|
+
createNav(config?: NavConfig): HTMLElement;
|
|
497
|
+
createNavbar(config?: ComponentConfig): HTMLElement;
|
|
498
|
+
createBreadcrumb(config?: ComponentConfig): HTMLElement;
|
|
499
|
+
createTabs(config?: TabsConfig): HTMLElement;
|
|
500
|
+
createPagination(config?: ComponentConfig): HTMLElement;
|
|
501
|
+
createAlert(config?: AlertConfig | string): HTMLElement;
|
|
502
|
+
createBadge(config?: ComponentConfig | string): HTMLElement;
|
|
503
|
+
createProgress(config?: ComponentConfig): HTMLElement;
|
|
504
|
+
createSpinner(config?: ComponentConfig): HTMLElement;
|
|
505
|
+
createToast(config?: ComponentConfig): HTMLElement;
|
|
506
|
+
createTooltip(config?: ComponentConfig): HTMLElement;
|
|
507
|
+
createPopover(config?: ComponentConfig): HTMLElement;
|
|
508
|
+
createListGroup(config?: ComponentConfig): HTMLElement;
|
|
509
|
+
createAccordion(config?: AccordionConfig): HTMLElement;
|
|
510
|
+
createCarousel(config?: CarouselConfig): HTMLElement;
|
|
511
|
+
createTimeline(config?: ComponentConfig): HTMLElement;
|
|
512
|
+
createStepper(config?: ComponentConfig): HTMLElement;
|
|
513
|
+
createChipInput(config?: ComponentConfig): HTMLElement;
|
|
514
|
+
createModal(config?: ModalConfig): HTMLElement;
|
|
515
|
+
createDropdown(config?: ComponentConfig): HTMLElement;
|
|
516
|
+
createForm(config?: ComponentConfig): HTMLElement;
|
|
517
|
+
createFormGroup(config?: ComponentConfig): HTMLElement;
|
|
518
|
+
createInput(config?: InputConfig): HTMLElement;
|
|
519
|
+
createTextarea(config?: ComponentConfig): HTMLElement;
|
|
520
|
+
createSelect(config?: ComponentConfig): HTMLElement;
|
|
521
|
+
createCheckbox(config?: ComponentConfig): HTMLElement;
|
|
522
|
+
createRadio(config?: ComponentConfig): HTMLElement;
|
|
523
|
+
createSwitch(config?: ComponentConfig): HTMLElement;
|
|
524
|
+
createRange(config?: ComponentConfig): HTMLElement;
|
|
525
|
+
createFileUpload(config?: ComponentConfig): HTMLElement;
|
|
526
|
+
createSearchInput(config?: ComponentConfig): HTMLElement;
|
|
527
|
+
createButtonGroup(config?: ComponentConfig): HTMLElement;
|
|
528
|
+
createHero(config?: ComponentConfig): HTMLElement;
|
|
529
|
+
createFeatureGrid(config?: ComponentConfig): HTMLElement;
|
|
530
|
+
createCTA(config?: ComponentConfig): HTMLElement;
|
|
531
|
+
createCodeDemo(config?: ComponentConfig): HTMLElement;
|
|
532
|
+
createSkeleton(config?: ComponentConfig): HTMLElement;
|
|
533
|
+
createAvatar(config?: ComponentConfig): HTMLElement;
|
|
534
|
+
createStatCard(config?: ComponentConfig): HTMLElement;
|
|
535
|
+
createMediaObject(config?: ComponentConfig): HTMLElement;
|
|
536
|
+
createTable(config?: TableConfig): HTMLElement;
|
|
537
|
+
|
|
538
|
+
// -- Array Utilities ------------------------------------------------------
|
|
539
|
+
arrayUniq(arr: any[]): any[];
|
|
540
|
+
arrayBinA(a: any[], b: any[]): any[];
|
|
541
|
+
arrayBNotInA(a: any[], b: any[]): any[];
|
|
542
|
+
multiArray(value: any, dims: number[]): any[];
|
|
543
|
+
|
|
544
|
+
// -- Math -----------------------------------------------------------------
|
|
545
|
+
mapScale(x: number, in0: number, in1: number, out0: number, out1: number, options?: { clamp?: boolean; invert?: boolean; curve?: string }): number;
|
|
546
|
+
clip(value: number, min: number, max: number): number;
|
|
547
|
+
|
|
548
|
+
// -- Text & Selection -----------------------------------------------------
|
|
549
|
+
choice(x: any, choices: Record<string, any>, def?: any): any;
|
|
550
|
+
loremIpsum(numChars: number, startSpot?: number, startWithCapitalLetter?: boolean): string;
|
|
551
|
+
naturalCompare(a: string, b: string): number;
|
|
552
|
+
|
|
553
|
+
// -- Timing ---------------------------------------------------------------
|
|
554
|
+
setIntervalX(callback: Function, delay: number, repetitions: number): number;
|
|
555
|
+
repeatUntil(testFn: () => boolean, successFn: () => void, failFn?: () => void, delay?: number, maxReps?: number, lastFn?: () => void): void;
|
|
556
|
+
|
|
557
|
+
// -- Type Detection -------------------------------------------------------
|
|
558
|
+
typeOf(value: any, baseTypeOnly?: boolean): string;
|
|
559
|
+
isNodeJS(): boolean;
|
|
560
|
+
|
|
561
|
+
// -- File I/O -------------------------------------------------------------
|
|
562
|
+
saveClientFile(fname: string, data: any): void;
|
|
563
|
+
saveClientJSON(fname: string, data: any): void;
|
|
564
|
+
loadClientFile(fname: string, callback: (data: any, error?: any) => void, options?: { parser?: string }): string;
|
|
565
|
+
loadClientJSON(fname: string, callback: (data: any, error?: any) => void): string;
|
|
566
|
+
loadLocalFile(callback: (data: any, filename: string, error?: any) => void, options?: { parser?: string; accept?: string }): void;
|
|
567
|
+
loadLocalJSON(callback: (data: any, filename: string, error?: any) => void): void;
|
|
568
|
+
|
|
569
|
+
// -- Cookies & URL --------------------------------------------------------
|
|
570
|
+
setCookie(cname: string, cvalue: string, exdays: number, options?: { path?: string; domain?: string; secure?: boolean; sameSite?: string }): void;
|
|
571
|
+
getCookie(cname: string, defaultValue?: any): any;
|
|
572
|
+
getURLParam(key?: string, defaultValue?: any): any;
|
|
573
|
+
|
|
574
|
+
// -- Clipboard ------------------------------------------------------------
|
|
575
|
+
copyToClipboard(text: string): Promise<void>;
|
|
576
|
+
|
|
577
|
+
// -- JSON Parsing ---------------------------------------------------------
|
|
578
|
+
parseJSONFlex(str: string): any;
|
|
579
|
+
|
|
580
|
+
// -- Presets & Constants --------------------------------------------------
|
|
581
|
+
SPACING_PRESETS: Record<string, any>;
|
|
582
|
+
RADIUS_PRESETS: Record<string, any>;
|
|
583
|
+
TYPE_RATIO_PRESETS: Record<string, any>;
|
|
584
|
+
ELEVATION_PRESETS: Record<string, any>;
|
|
585
|
+
MOTION_PRESETS: Record<string, any>;
|
|
586
|
+
DEFAULT_PALETTE_CONFIG: StyleConfig;
|
|
587
|
+
THEME_PRESETS: Record<string, StyleConfig>;
|
|
588
|
+
BCCL: Record<string, any>;
|
|
589
|
+
|
|
590
|
+
// -- Variant helper -------------------------------------------------------
|
|
591
|
+
variantClass(variant: string): string;
|
|
592
|
+
|
|
593
|
+
// -- Internal (access at own risk) ----------------------------------------
|
|
594
|
+
_nodeMap: Record<string, HTMLElement>;
|
|
595
|
+
/** @deprecated Use bw.el() instead. Alias kept for one release cycle. */
|
|
596
|
+
_el(id: string): HTMLElement | null;
|
|
597
|
+
_registerNode(el: HTMLElement, uuid: string): void;
|
|
598
|
+
_deregisterNode(el: HTMLElement, uuid: string): void;
|
|
599
|
+
_unmountCallbacks: Map<string, Function>;
|
|
600
|
+
_topics: Record<string, any[]>;
|
|
601
|
+
_fnRegistry: Record<string, Function>;
|
|
602
|
+
_componentRegistry: Map<string, any>;
|
|
603
|
+
_clientFunctions: Record<string, Function>;
|
|
604
|
+
_allowExec: boolean;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/** The bw namespace (default export) */
|
|
608
|
+
declare const bw: Bitwrench;
|
|
609
|
+
export default bw;
|
|
610
|
+
|
|
611
|
+
// Named BCCL exports for ESM tree-shaking:
|
|
612
|
+
// import { makeCard, makeButton } from 'bitwrench';
|
|
613
|
+
export function makeCard(config?: CardConfig | string): Taco;
|
|
614
|
+
export function makeButton(config?: ButtonConfig | string): Taco;
|
|
615
|
+
export function makeContainer(config?: ComponentConfig): Taco;
|
|
616
|
+
export function makeRow(config?: ComponentConfig): Taco;
|
|
617
|
+
export function makeCol(config?: ComponentConfig): Taco;
|
|
618
|
+
export function makeStack(config?: ComponentConfig): Taco;
|
|
619
|
+
export function makeSection(config?: ComponentConfig): Taco;
|
|
620
|
+
export function makeNav(config?: NavConfig): Taco;
|
|
621
|
+
export function makeNavbar(config?: ComponentConfig): Taco;
|
|
622
|
+
export function makeBreadcrumb(config?: ComponentConfig): Taco;
|
|
623
|
+
export function makeTabs(config?: TabsConfig): Taco;
|
|
624
|
+
export function makePagination(config?: ComponentConfig): Taco;
|
|
625
|
+
export function makeAlert(config?: AlertConfig | string): Taco;
|
|
626
|
+
export function makeBadge(config?: ComponentConfig | string): Taco;
|
|
627
|
+
export function makeProgress(config?: ComponentConfig): Taco;
|
|
628
|
+
export function makeSpinner(config?: ComponentConfig): Taco;
|
|
629
|
+
export function makeToast(config?: ComponentConfig): Taco;
|
|
630
|
+
export function makeTooltip(config?: ComponentConfig): Taco;
|
|
631
|
+
export function makePopover(config?: ComponentConfig): Taco;
|
|
632
|
+
export function makeListGroup(config?: ComponentConfig): Taco;
|
|
633
|
+
export function makeAccordion(config?: AccordionConfig): Taco;
|
|
634
|
+
export function makeCarousel(config?: CarouselConfig): Taco;
|
|
635
|
+
export function makeTimeline(config?: ComponentConfig): Taco;
|
|
636
|
+
export function makeStepper(config?: ComponentConfig): Taco;
|
|
637
|
+
export function makeChipInput(config?: ComponentConfig): Taco;
|
|
638
|
+
export function makeModal(config?: ModalConfig): Taco;
|
|
639
|
+
export function makeDropdown(config?: ComponentConfig): Taco;
|
|
640
|
+
export function makeForm(config?: ComponentConfig): Taco;
|
|
641
|
+
export function makeFormGroup(config?: ComponentConfig): Taco;
|
|
642
|
+
export function makeInput(config?: InputConfig): Taco;
|
|
643
|
+
export function makeTextarea(config?: ComponentConfig): Taco;
|
|
644
|
+
export function makeSelect(config?: ComponentConfig): Taco;
|
|
645
|
+
export function makeCheckbox(config?: ComponentConfig): Taco;
|
|
646
|
+
export function makeRadio(config?: ComponentConfig): Taco;
|
|
647
|
+
export function makeSwitch(config?: ComponentConfig): Taco;
|
|
648
|
+
export function makeRange(config?: ComponentConfig): Taco;
|
|
649
|
+
export function makeFileUpload(config?: ComponentConfig): Taco;
|
|
650
|
+
export function makeSearchInput(config?: ComponentConfig): Taco;
|
|
651
|
+
export function makeButtonGroup(config?: ComponentConfig): Taco;
|
|
652
|
+
export function makeHero(config?: ComponentConfig): Taco;
|
|
653
|
+
export function makeFeatureGrid(config?: ComponentConfig): Taco;
|
|
654
|
+
export function makeCTA(config?: ComponentConfig): Taco;
|
|
655
|
+
export function makeCodeDemo(config?: ComponentConfig): Taco;
|
|
656
|
+
export function makeSkeleton(config?: ComponentConfig): Taco;
|
|
657
|
+
export function makeAvatar(config?: ComponentConfig): Taco;
|
|
658
|
+
export function makeStatCard(config?: ComponentConfig): Taco;
|
|
659
|
+
export function makeMediaObject(config?: ComponentConfig): Taco;
|
|
660
|
+
export function makeTable(config?: TableConfig): Taco;
|
|
661
|
+
export function makeTableFromArray(config?: TableConfig): Taco;
|
|
662
|
+
export function makeDataTable(config?: TableConfig): Taco;
|
|
663
|
+
export function makeBarChart(config?: ComponentConfig): Taco;
|
|
664
|
+
export function make(type: string, props?: ComponentConfig): Taco;
|
|
665
|
+
export function variantClass(variant: string): string;
|
|
666
|
+
export const BCCL: Record<string, any>;
|