bitwrench 1.2.16 → 2.0.8

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 (130) hide show
  1. package/README.md +160 -158
  2. package/bin/bitwrench.js +3 -0
  3. package/dist/bitwrench-code-edit.cjs.js +639 -0
  4. package/dist/bitwrench-code-edit.es5.js +875 -0
  5. package/dist/bitwrench-code-edit.es5.min.js +15 -0
  6. package/dist/bitwrench-code-edit.esm.js +628 -0
  7. package/dist/bitwrench-code-edit.esm.min.js +15 -0
  8. package/dist/bitwrench-code-edit.umd.js +645 -0
  9. package/dist/bitwrench-code-edit.umd.min.js +15 -0
  10. package/dist/bitwrench.cjs.js +6983 -0
  11. package/dist/bitwrench.cjs.min.js +62 -0
  12. package/dist/bitwrench.css +5100 -0
  13. package/dist/bitwrench.es5.js +8446 -0
  14. package/dist/bitwrench.es5.min.js +31 -0
  15. package/dist/bitwrench.esm.js +6981 -0
  16. package/dist/bitwrench.esm.min.js +62 -0
  17. package/dist/bitwrench.umd.js +6989 -0
  18. package/dist/bitwrench.umd.min.js +62 -0
  19. package/dist/builds.json +127 -0
  20. package/dist/sri.json +18 -0
  21. package/package.json +86 -24
  22. package/readme.html +288 -0
  23. package/src/bitwrench-code-edit.js +627 -0
  24. package/src/bitwrench-color-utils.js +311 -0
  25. package/src/bitwrench-component-base.js +736 -0
  26. package/src/bitwrench-components-inline.js +374 -0
  27. package/src/bitwrench-components-v2.js +1879 -0
  28. package/src/bitwrench-components.js +610 -0
  29. package/src/bitwrench-styles.js +3240 -0
  30. package/src/bitwrench.js +3367 -0
  31. package/src/cli/convert.js +205 -0
  32. package/src/cli/index.js +122 -0
  33. package/src/cli/inject.js +55 -0
  34. package/src/cli/layout-default.js +142 -0
  35. package/src/generate-css.js +381 -0
  36. package/src/vendor/quikdown.js +654 -0
  37. package/src/version.js +16 -0
  38. package/.eslintrc.json +0 -27
  39. package/.github/workflows/codeql-analysis.yml +0 -72
  40. package/.travis.yml +0 -34
  41. package/bitwrench.css +0 -92
  42. package/bitwrench.js +0 -3348
  43. package/bitwrench.js_sri.txt +0 -1
  44. package/bitwrench.min.js +0 -1
  45. package/bitwrench.min.js_sri.txt +0 -1
  46. package/bitwrench_ESM.js +0 -3207
  47. package/bitwrench_ESM.js_sri.txt +0 -1
  48. package/bitwrench_ESM.min.js +0 -1
  49. package/bitwrench_ESM.min.js_sri.txt +0 -1
  50. package/dev/bitwrench-todo.md +0 -215
  51. package/dev/css-arrows.md +0 -23
  52. package/dev/docStringDev.js +0 -124
  53. package/dev/docStringParseDev.js +0 -171
  54. package/dev/example11-load-mjs-page.html +0 -17
  55. package/dev/figures.html +0 -37
  56. package/dev/html_gen.js +0 -349
  57. package/dev/htmld.md +0 -250
  58. package/dev/htmldev.html +0 -45
  59. package/dev/index-old.html +0 -87
  60. package/dev/misc-notes.md +0 -21
  61. package/dev/norm.css +0 -30
  62. package/dev/notes.md +0 -2
  63. package/dev/pageData.mjs +0 -69
  64. package/dev/sizes.html +0 -49
  65. package/dev/universal-js-module.js +0 -37
  66. package/examples/example1.html +0 -78
  67. package/examples/example10.html +0 -84
  68. package/examples/example11.html +0 -17
  69. package/examples/example12.html +0 -18
  70. package/examples/example2.html +0 -44
  71. package/examples/example3.html +0 -50
  72. package/examples/example4.html +0 -22
  73. package/examples/example5.html +0 -82
  74. package/examples/example6.html +0 -128
  75. package/examples/example7.html +0 -91
  76. package/examples/example8.html +0 -27
  77. package/examples/example9.html +0 -102
  78. package/examples/examplePageData12.mjs +0 -73
  79. package/examples/pageData.mjs +0 -69
  80. package/examples/pico.min.css +0 -5
  81. package/icon/bitwrench-dark-tall.png +0 -0
  82. package/icon/bitwrench-dark.png +0 -0
  83. package/icon/bitwrench-icon-lt-grey.png +0 -0
  84. package/icon/bitwrench-icon.vsd +0 -0
  85. package/icon/bitwrench-logo-dark.png +0 -0
  86. package/icon/bitwrench-logo-full.png +0 -0
  87. package/icon/bitwrench-logo-green.png +0 -0
  88. package/icon/bitwrench-logo-grey.png +0 -0
  89. package/icon/bitwrench-logo-white.png +0 -0
  90. package/icon/bitwrench-logos-colors.png +0 -0
  91. package/icon/bitwrench-thick-logo.png +0 -0
  92. package/icon/bitwrench-thick-teal/android-chrome-192x192.png +0 -0
  93. package/icon/bitwrench-thick-teal/android-chrome-512x512.png +0 -0
  94. package/icon/bitwrench-thick-teal/apple-touch-icon.png +0 -0
  95. package/icon/bitwrench-thick-teal/browserconfig.xml +0 -9
  96. package/icon/bitwrench-thick-teal/favicon-16x16.png +0 -0
  97. package/icon/bitwrench-thick-teal/favicon-32x32.png +0 -0
  98. package/icon/bitwrench-thick-teal/favicon.ico +0 -0
  99. package/icon/bitwrench-thick-teal/mstile-144x144.png +0 -0
  100. package/icon/bitwrench-thick-teal/mstile-150x150.png +0 -0
  101. package/icon/bitwrench-thick-teal/mstile-310x150.png +0 -0
  102. package/icon/bitwrench-thick-teal/mstile-310x310.png +0 -0
  103. package/icon/bitwrench-thick-teal/mstile-70x70.png +0 -0
  104. package/icon/bitwrench-thick-teal/site.webmanifest +0 -19
  105. package/icon/bitwrench-thick-teal.ico +0 -0
  106. package/icon/bitwrench-thick-teal.svg +0 -44
  107. package/icon/bitwrench-thick-teal.zip +0 -0
  108. package/icon/favicon-test.html +0 -20
  109. package/icon/logos-test.PNG +0 -0
  110. package/images/bitwrench-512x512.png +0 -0
  111. package/images/bitwrench-logo-med.png +0 -0
  112. package/images/bitwrench-thick-logo.png +0 -0
  113. package/images/bitwrench-thick-logo.svg +0 -64
  114. package/images/bitwrench-thick-teal.ico +0 -0
  115. package/images/favicon.ico +0 -0
  116. package/index.html +0 -282
  117. package/instr_tmp/bitwrench.js +0 -1350
  118. package/karma.conf.js +0 -140
  119. package/makefile +0 -21
  120. package/quick-docs.html +0 -206
  121. package/test/bitwrench_test.js +0 -1255
  122. package/test/karma-test.js +0 -1081
  123. package/tools/bw_deprecatedNames.js +0 -19
  124. package/tools/bwconsole.js +0 -20
  125. package/tools/createSimpleHTMLPage.js +0 -41
  126. package/tools/emitreadme.sh +0 -4
  127. package/tools/export-bw-default-css.js +0 -41
  128. package/tools/umd2ModuleHack.js +0 -32
  129. package/tools/update-bw-package.js +0 -36
  130. package/tools/updatereadme.js +0 -34
package/README.md CHANGED
@@ -1,202 +1,204 @@
1
+ # bitwrench.js
2
+
1
3
  [![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
2
4
  [![NPM version](https://img.shields.io/npm/v/bitwrench.svg?style=flat-square)](https://www.npmjs.com/package/bitwrench)
3
- [![Build Status](https://travis-ci.org/deftio/bitwrench.svg?branch=master)](https://travis-ci.org/deftio/fifostr)
4
-
5
- [![bitwrench](./images/bitwrench-logo-med.png)](http://www.deftio.com/bitwrench)
6
-
7
-
8
- ## Welcome to bitwrench.js
9
-
10
- bitwrench.js is a javascript library for for creating quick demos with almost no depedancies. With bitwrench one can create web pages and components with pure json or javascript dictionaries including handlers (e.g. onclick="...code.." ==> onclick:function_ref, css , etc. )
11
- bitwrench.js also has handyman functions such as loremIpsum generation, ranged random numbers and interpolaters, and color blenders. Use it for throwing up quick web pages which don't depend on any server side framework but need a little prettyifcation or for visualizing quick data. For example when debugging C/C++ embedded projects where we don't want to clutter the build dirs with lots of "weird web stuff" - just write a simple HTML page with bitwrench and still load and view raw text files, JSON, arrays and other bits of embedded files with no extra dependancies.
5
+ [![CI](https://github.com/deftio/bitwrench/actions/workflows/ci.yml/badge.svg)](https://github.com/deftio/bitwrench/actions/workflows/ci.yml)
12
6
 
13
- For those used to modern frameworks such as react / vue / svelte etc. bitwrench.js comes from a pre 2011 time period - so it has more of a jquery like feel, but with a declaritve syntax. See example code and page below for more. bitwrench.js does work in older browsers such Internet Explorer (v7 and later).
7
+ [![bitwrench](./images/bitwrench-logo-med.png)](https://deftio.github.io/bitwrench/pages/)
14
8
 
9
+ Bitwrench is a UI library in a single script that provides HTML generation, reactive state, CSS and theme generation, 30+ components, and a static site CLI — all from plain JavaScript objects, with zero dependencies and zero compile steps. Works in browsers (including IE11) and Node.js.
15
10
 
16
- ### Features
11
+ ## Quick Example
17
12
 
18
- * **HTML quick emits** -- create HTML objects either client or server side from pure JSON. useful for making quick components or dynamic content w/o any inline HTML
19
- * html(["div", {class:"class1 class2", onclick:"myFunction(this)","This is the content"}]
20
- * DOM selects and applies e.g.
21
- * bw.DOM("h3","tada") // set all "h3" tags to have the content "tada"
22
- * bw.DOM(".myClass",function(x){... do something on each element described by CSS selector .myClass})
23
- * supports "deep" hieararchical JSON constructs and arrays
24
- * registerFunction abilities allow functions to be passed statically to HTML elements (see docs)
25
- * Useful as a "onefile" framework which an interpret rich JSON in to full web pages.
26
- * **Color conversions and interpolation**
27
- * RGB, RGBa, HSL, HSLa, and theme generation both as numeric values also as CSS outputs
28
- * **setting/getting cookies**
29
- * **pretty printing json**
30
- * **Saving/Loading application data files** (works in both browser or node)
31
- * save / load files as raw or JSON
32
- * **Getting URL parameters with defaults**
33
- * simple parsing of URL params, also can be used for command line scripts, also packs simple dicts back to URLs. note that this functionality predated modern URL libs so you might want to use those for modern apps. However bitwrench versions do work on old browers such as IE8 and iPodTouch 4th generation
34
- * **Data manipulation functions** and other "random" things
35
- * numeric interpolation & clipping
36
- * create multi-d arrays
37
- * random(4,11) ==> put out a random number in the range 4-11, also provides multidim arrays of random numbers useful for testing tables etc
38
- * prandom() ==> pseudorandom numbers with range settings, also provides multidim arrays of random numbers useful for testing tables etc
39
- * **Logging** with time-stamps, messaging, and pretty printing (raw, HTML, and text)
40
- * Logging also has auto dissolve so one can log a process and then dump later or suppress in 'production'
41
- * **Built-in docString parsing** with extraction support
42
- * bitwrench.js self-documents in that from the browser DOM one can pull out a given function's doc strings such as bw.docString("DOM") ==> gives docString inforfor that function.
43
- * note that bitwrench.min.js strips comments so built-in help is not available.
44
-
45
-
46
-
47
- There is no great structure here, just a bunch of kitchen sink things that seemed to be handy in alot of quick web dev situations. All non-dom specific calls can be run either server side or client side.
48
-
49
- A minified form bitwrench.min.js is provided with identical functionality
13
+ ```javascript
14
+ const card = {
15
+ t: 'div', a: { class: 'bw-card' },
16
+ c: [
17
+ { t: 'h3', c: 'Hello bitwrench' },
18
+ { t: 'p', c: 'UI as native JavaScript objects.' }
19
+ ]
20
+ };
21
+
22
+ // Mount to the DOM
23
+ bw.DOM('#app', card);
24
+
25
+ // Or render to an HTML string (Node.js, emails, static pages)
26
+ const html = bw.html(card);
27
+ ```
50
28
 
51
- ## Usage
52
- See the quick docs here:
53
- [bitwrench quick docs](./quick-docs.html)
29
+ Each object has four keys: **t** (tag), **a** (attributes), **c** (content), and optionally **o** (options for state and lifecycle). Nest them, loop them, compose them — it's just JavaScript.
54
30
 
55
- other examples here:
56
- [bitwrench examples](./examples)
31
+ ## Installation
57
32
 
58
- ### node.js
59
33
  ```bash
60
- #Installation (server side)
61
- npm install bitwrench --save
34
+ npm install bitwrench
62
35
  ```
63
36
 
64
37
  ```javascript
65
- //usage in nodejs
66
- var bw = require('./bitwrench.js'); //adds to current scope
67
- var s = bw.html(["div",{"class":"foo"},"This is some HTML"]); // now... ===> s = "<div class='foo'>This is some HTML</div>
38
+ // ES module
39
+ import bw from 'bitwrench';
68
40
 
41
+ // CommonJS
42
+ const bw = require('bitwrench');
69
43
  ```
70
44
 
71
- ### browser
72
- In the browser bitwrench is loaded like any script library. Note that parameters can be passed to bitwrench to control the loading process.
73
- bitwrench generates its own default css from javascript and loads those. You can see these statically in the bitwrench.css file (note that bitwrench.css can also be used standalone without the bitwrench.js library).
74
- [Example Page](./examples/example5.html) source code here:
45
+ Or include directly in a page:
75
46
 
76
47
  ```html
48
+ <script src="https://cdn.jsdelivr.net/npm/bitwrench/dist/bitwrench.umd.min.js"></script>
49
+ ```
50
+
51
+ ## Features
52
+
53
+ - **HTML from plain objects** — describe UI as JavaScript objects, render to live DOM with `bw.DOM()` or to HTML strings with `bw.html()` for server-side rendering, emails, and static pages
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
+ - **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
+ - **30+ ready-made components** — cards, buttons, sortable tables, form inputs, alerts, badges, tabs, navbars, spinners, progress bars — each a single function call that returns a composable object
57
+ - **Static site CLI** — the `bitwrench` command converts Markdown, HTML, and JSON files into styled, self-contained pages with theme support
58
+ - **Utilities** — color interpolation, random data generation, lorem ipsum, cookies, URL params, file I/O for both browser and Node.js
59
+
60
+ ## Getting Started
77
61
 
62
+ ```html
78
63
  <!DOCTYPE html>
79
64
  <html lang="en">
80
65
  <head>
81
- <script src="../bitwrench.js" ></script>
66
+ <script src="https://cdn.jsdelivr.net/npm/bitwrench/dist/bitwrench.umd.min.js"></script>
82
67
  </head>
83
- <body class="bw-def-page-setup bw-font-sans-serif">
84
- <script>
85
- var htmlData = {c: //for more on the format, see docs github.com/deftio/bitwrench
86
- [
87
- ["h1" ,{"class":"bw-h1"},"Bitwrench Test Area" ],
88
- "bitwrench version: "+bw.version().version +"<br><br>",
89
- ["div",{"class":"foo"} ,"This page has HTML content which is entirely written as Javascript objects (JSON-like but with support for functions) by content using "+bw.html(["a",{href:"https://github.com/deftio/bitwrench"},"bitwrench.js"])+". Bitwrench has built-in grids, tables,headings, and other quick-n-dirty html prototyping tasks. Bitwrench html generation runs either client or server side."],
90
- "<hr>",
91
- ["h2","Lorem Ipsum Generator"],
92
- "Good for testing simple layout ideas.<br><br>",
93
- ["div",{},bw.loremIpsum(230)],
94
- "<hr>",
95
- ["h2",{},"Sample Content with 3 Columns"],
96
- ["div",{"class":"bw-row"},
97
- [
98
- ["div",{"class":"bw-col-4 bw-left "},"<h3>Left justified</h3>"+bw.loremIpsum(95)], //mix text and html freely
99
- ["div",{"class":"bw-col-4 bw-center bw-pad1"},"<h3>Centered</h3>"+bw.loremIpsum(95,3)],
100
- ["div",{"class":"bw-col-4 bw-right "},"<h3>Right justified</h3>"+bw.loremIpsum(95,2)],
101
- ],
102
- ],
103
- "<br><hr>",
104
- ["h2", {}, "Example Sortable Table"],
105
- bw.htmlTable( // json to table (note table data can be functions as well)
106
- [
107
- ["Name","Age", "Prof", "Fav Color"], // just an 2D array
108
- ["Sue", 34, "Engineer", {a:{style:"color:red"},c:"red"}], // inline json-html objects
109
- ["Bob" ,35, "Teacher", {a:{style:"color:green"},c:"green"}],
110
- ["Vito",23, "Mechanic", {a:{style:"color:blue",onclick:"alert('blue!')"},c:"blue"}],
111
- ["Hank",73, "Retired", {a:{style:"color:purple"},c:"purple"}]
112
- ],{sortable:true}),
113
- "<br><hr>",
114
- ["h2",{},"Sample Buttons"],
115
- "These buttons have function handlers attached.<br><br>",
116
- ["button",{onclick:"alert('button pressed!')"},"Alert Button"], // staight js
117
- "&nbsp;&nbsp;",
118
- ["button",{onclick:myFunc},"Time Button"], // bitwrench maps and registers event functions
119
- "<br><hr>",
120
- ["h2","Built in Headings"],
121
- [1,2,3,4,5,6].map( function(x){return bw.html(["h"+x,"Heading "+x])}).join(""), // Headings
122
- "<br><hr>",
123
- ["h2","Grid System (responsive)"],
124
- "Grid system (just uses css so can use either bitwrench.js loader or just bitwrench.css with no javascript. Use -fluid for responsive<br><br>",
125
- ["style",{},"\n.boxEv {background-color: #aaa; height: 30px; border-radius:5px; border:1px solid black;}\n.boxOd {background-color: #ddd; height:30px; border-radius:5px;border:1px solid black;;}\n"], // some styles (note bw has CSS generation shown in another example)
126
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-1 boxEv"},c:"bw-col-1"},{a:{class:"bw-col-1 boxOd"},c:"bw-col-1"},{a:{class:"bw-col-1 boxEv"},c:"bw-col-1"},{a:{class:"bw-col-1 boxOd"},c:"bw-col-1"},{a:{class:"bw-col-1 boxEv"},c:"bw-col-1"},{a:{class:"bw-col-1 boxOd"},c:"bw-col-1"},{a:{class:"bw-col-1 boxEv"},c:"bw-col-1"},{a:{class:"bw-col-1 boxOd"},c:"bw-col-1"},{a:{class:"bw-col-1 boxEv"},c:"bw-col-1"},{a:{class:"bw-col-1 boxOd"},c:"bw-col-1"},{a:{class:"bw-col-1 boxEv"},c:"bw-col-1"},{a:{class:"bw-col-1 boxOd"},c:"bw-col-1"}]],
127
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-2 boxEv"},c:"bw-col-2"},{a:{class:"bw-col-2 boxOd"},c:"bw-col-2"},{a:{class:"bw-col-2 boxEv"},c:"bw-col-2"},{a:{class:"bw-col-2 boxOd"},c:"bw-col-2"},{a:{class:"bw-col-2 boxEv"},c:"bw-col-2"},{a:{class:"bw-col-2 boxOd"},c:"bw-col-2"}]],
128
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-3 boxEv"},c:"bw-col-3"},{a:{class:"bw-col-3 boxOd"},c:"bw-col-3"},{a:{class:"bw-col-3 boxEv"},c:"bw-col-3"},{a:{class:"bw-col-3 boxOd"},c:"bw-col-3"}]],
129
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-4 boxEv"},c:"bw-col-4"},{a:{class:"bw-col-4 boxOd"},c:"bw-col-4"},{a:{class:"bw-col-4 boxEv"},c:"bw-col-4"}]],
130
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-5 boxEv"},c:"bw-col-5"},{a:{class:"bw-col-7 boxOd"},c:"bw-col-7"}]],
131
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-6 boxEv"},c:"bw-col-6"},{a:{class:"bw-col-6 boxOd"},c:"bw-col-6"}]],
132
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-7 boxEv"},c:"bw-col-7"},{a:{class:"bw-col-5 boxOd"},c:"bw-col-5"}]],
133
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-8 boxEv"},c:"bw-col-8"},{a:{class:"bw-col-4 boxOd"},c:"bw-col-4"}]],
134
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-9 boxEv"},c:"bw-col-9"},{a:{class:"bw-col-3 boxOd"},c:"bw-col-3"}]],
135
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-10 boxEv"},c:"bw-col-10"},{a:{class:"bw-col-2 boxOd"},c:"bw-col-2"}]],
136
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-11 boxEv"},c:"bw-col-11"},{a:{class:"bw-col-1 boxOd"},c:"bw-col-1"}]],
137
- ["div",{class:"bw-row bw-center"},[{a:{class:"bw-col-12 boxEv"},c:"bw-col-12"}]],
138
-
139
- "<br><hr>",
140
- ["h2",{},"Simple Sign"],
141
- ["div",{style:"padding:10%; border:1px solid black;"},bw.htmlSign("This is a big sign!")],
142
- "<br><hr>",
143
- ["h2",{},"Tabbed Content"],
144
- bw.htmlTabs([
145
- ["Tab1",bw.loremIpsum(300)],
146
- ["Tab2",bw.loremIpsum(300,20)],
147
- ["Tab3",bw.loremIpsum(300,50)]],{tab_atr:{style:""}}) ,
148
- "<br>",
149
- ]};
150
-
151
- bw.DOMInsertElement("body",bw.html(htmlData),true);
152
- function myFunc(x){return x.innerHTML = (new Date()).toLocaleTimeString();} // button function
153
-
154
-
155
- bw.DOMInsertElement("head",bw.html(bw.htmlFavicon("\u266C","teal"))); // insert a favicon on the top tab of the page, "X" for a single letter
156
- bw.DOMInsertElement("head",bw.html({t:"title",c:"Bitwrench HTML Gen "})); // insert a page title on the browser tab
157
- </script>
68
+ <body>
69
+ <div id="app"></div>
70
+ <script>
71
+ bw.loadDefaultStyles();
72
+
73
+ bw.DOM('#app', {
74
+ t: 'div', a: { class: 'bw-container' },
75
+ c: [
76
+ { t: 'h1', c: 'My App' },
77
+ bw.makeCard({
78
+ title: 'Welcome',
79
+ content: 'Built with plain JavaScript objects.'
80
+ }),
81
+ bw.makeButton({ label: 'Click me', variant: 'primary' })
82
+ ]
83
+ });
84
+ </script>
158
85
  </body>
159
86
  </html>
160
87
  ```
161
-
162
88
 
163
- ## Source code home
164
- all source is at github:
165
- [bitwrench on github](http://github.com/deftio/bitwrench)
89
+ ## Adding State
166
90
 
91
+ The `o` key adds state and a render function to any element. When state changes, call `bw.update()` to re-render:
167
92
 
168
- ## Linting
169
- bitwrench uses eslint for static code checking and analysis. Due to bitwrench's age we've kept ";" as a required part of the linting process. After running lint you should see no errors or warnings.
93
+ ```javascript
94
+ bw.DOM('#counter', {
95
+ t: 'div',
96
+ o: {
97
+ state: { count: 0 },
98
+ render: function(el) {
99
+ var s = el._bw_state;
100
+ bw.DOM(el, {
101
+ t: 'div', c: [
102
+ { t: 'span', c: 'Count: ' + s.count },
103
+ { t: 'button', a: {
104
+ onclick: function() { s.count++; bw.update(el); }
105
+ }, c: '+1' }
106
+ ]
107
+ });
108
+ }
109
+ }
110
+ });
111
+ ```
170
112
 
171
- ```bash
172
- npm install eslint --save-dev
113
+ For communication between components, use pub/sub:
173
114
 
174
- ./node_modules/.bin/eslint --init
115
+ ```javascript
116
+ bw.sub('item-added', function(detail) {
117
+ console.log('New item:', detail.name);
118
+ });
175
119
 
120
+ bw.pub('item-added', { name: 'Widget' });
176
121
  ```
177
- Now run the lint test like this:
178
- ```bash
179
- npm run lint
122
+
123
+ ## Theming
124
+
125
+ Generate a complete theme from two seed colors. All components — buttons, alerts, badges, cards, forms, tables — are styled automatically:
126
+
127
+ ```javascript
128
+ bw.generateTheme('my-theme', {
129
+ primary: '#336699',
130
+ secondary: '#cc6633'
131
+ });
132
+
133
+ bw.toggleDarkMode();
180
134
  ```
181
135
 
182
- ## Tests (requires mocha and chai test suites)
183
- bitwrench is tested with the mocha framework installed locally using npm along with instanbul for code / line coverage
136
+ ## Core API
137
+
138
+ | Function | Description |
139
+ |---|---|
140
+ | `bw.html(obj)` | Convert an object to an HTML string |
141
+ | `bw.DOM(selector, obj)` | Mount an object to a DOM element |
142
+ | `bw.css(rules)` | Generate CSS from a JS object |
143
+ | `bw.loadDefaultStyles()` | Inject the built-in stylesheet |
144
+ | `bw.generateTheme(name, config)` | Generate a scoped theme from seed colors |
145
+ | `bw.patch(id, content)` | Update a specific element by UUID |
146
+ | `bw.update(el)` | Re-render via the element's `o.render` function |
147
+ | `bw.pub(topic, detail)` | Publish a message to subscribers |
148
+ | `bw.sub(topic, handler)` | Subscribe to a topic; returns an unsub function |
149
+
150
+ See the full [API Reference](https://deftio.github.io/bitwrench/pages/08-api-reference.html) for all functions.
151
+
152
+ ## CLI
153
+
154
+ Convert Markdown, HTML, or JSON files to styled standalone pages:
184
155
 
185
156
  ```bash
186
- npm install mocha --save-dev mocha
157
+ # Convert Markdown to a self-contained HTML page
158
+ bitwrench README.md -o index.html --standalone
187
159
 
160
+ # Apply a theme preset
161
+ bitwrench doc.md -o doc.html --standalone --theme ocean
162
+
163
+ # Custom colors
164
+ bitwrench doc.md -o doc.html --standalone --theme "#336699,#cc6633"
188
165
  ```
189
166
 
190
- Run the tests as follows:
191
- ```bash
192
- npm run test
167
+ Flags: `--output/-o`, `--standalone/-s`, `--cdn`, `--theme/-t`, `--css/-c`, `--title`, `--favicon/-f`, `--highlight`, `--verbose/-v`
168
+
169
+ ## Build Formats
170
+
171
+ | Format | File | Use case |
172
+ |--------|------|----------|
173
+ | UMD | `bitwrench.umd.min.js` | Browsers and Node.js |
174
+ | ESM | `bitwrench.esm.min.js` | Modern bundlers (Vite, webpack, etc.) |
175
+ | CJS | `bitwrench.cjs.min.js` | Node.js `require()` |
176
+ | ES5 | `bitwrench.es5.min.js` | Legacy browsers (IE11) |
177
+
178
+ All formats include source maps. A separate CSS file (`bitwrench.css`) is also available for use without JavaScript.
193
179
 
180
+ ## Documentation
181
+
182
+ - [Interactive docs and demos](https://deftio.github.io/bitwrench/pages/) — full tutorial site with live examples
183
+ - [Quick Start](https://deftio.github.io/bitwrench/pages/00-quick-start.html) — first steps with `bw.DOM()`
184
+ - [Components](https://deftio.github.io/bitwrench/pages/01-components.html) — buttons, cards, alerts, badges, navbars
185
+ - [Styling & Theming](https://deftio.github.io/bitwrench/pages/03-styling.html) — CSS generation and theming strategies
186
+ - [State & Interactivity](https://deftio.github.io/bitwrench/pages/05-state.html) — `bw.patch()`, `bw.update()`, pub/sub
187
+ - [Tic Tac Toe Tutorial](https://deftio.github.io/bitwrench/pages/06-tic-tac-toe-tutorial.html) — step-by-step game with state management
188
+ - [Framework Comparison](https://deftio.github.io/bitwrench/pages/07-framework-comparison.html) — bitwrench vs React, Vue, Svelte
189
+
190
+ ## Development
191
+
192
+ ```bash
193
+ npm install # install dev dependencies
194
+ npm run build # build all dist formats (UMD, ESM, CJS, ES5)
195
+ npm test # run unit tests (284 tests)
196
+ npm run test:cli # run CLI tests (49 tests)
197
+ npm run test:e2e # run Playwright browser tests
198
+ npm run lint # run ESLint
199
+ npm run cleanbuild # full production build with SRI hashes
194
200
  ```
195
201
 
196
- ## Release History
197
- * 1.2x Initial release
198
-
199
- ## License
200
- bitwrench is released under the OSI Approved FreeBSD 2-clause license
202
+ ## License
201
203
 
202
- see LICENSE.txt file
204
+ [BSD-2-Clause](./LICENSE.txt) — (c) M. A. Chatterjee / [deftio](https://github.com/deftio)
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { run } from '../src/cli/index.js';
3
+ run(process.argv.slice(2));