bitwrench 2.0.17 → 2.0.18

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 (67) hide show
  1. package/README.md +127 -38
  2. package/dist/bitwrench-bccl.cjs.js +8 -8
  3. package/dist/bitwrench-bccl.cjs.min.js +3 -3
  4. package/dist/bitwrench-bccl.esm.js +8 -8
  5. package/dist/bitwrench-bccl.esm.min.js +3 -3
  6. package/dist/bitwrench-bccl.umd.js +8 -8
  7. package/dist/bitwrench-bccl.umd.min.js +2 -2
  8. package/dist/bitwrench-code-edit.cjs.js +1 -1
  9. package/dist/bitwrench-code-edit.cjs.min.js +1 -1
  10. package/dist/bitwrench-code-edit.es5.js +1 -1
  11. package/dist/bitwrench-code-edit.es5.min.js +1 -1
  12. package/dist/bitwrench-code-edit.esm.js +1 -1
  13. package/dist/bitwrench-code-edit.esm.min.js +1 -1
  14. package/dist/bitwrench-code-edit.umd.js +1 -1
  15. package/dist/bitwrench-code-edit.umd.min.js +1 -1
  16. package/dist/bitwrench-lean.cjs.js +941 -775
  17. package/dist/bitwrench-lean.cjs.min.js +20 -20
  18. package/dist/bitwrench-lean.es5.js +1012 -961
  19. package/dist/bitwrench-lean.es5.min.js +18 -18
  20. package/dist/bitwrench-lean.esm.js +941 -775
  21. package/dist/bitwrench-lean.esm.min.js +20 -20
  22. package/dist/bitwrench-lean.umd.js +941 -775
  23. package/dist/bitwrench-lean.umd.min.js +20 -20
  24. package/dist/bitwrench-util-css.cjs.js +236 -0
  25. package/dist/bitwrench-util-css.cjs.min.js +22 -0
  26. package/dist/bitwrench-util-css.es5.js +414 -0
  27. package/dist/bitwrench-util-css.es5.min.js +21 -0
  28. package/dist/bitwrench-util-css.esm.js +230 -0
  29. package/dist/bitwrench-util-css.esm.min.js +21 -0
  30. package/dist/bitwrench-util-css.umd.js +242 -0
  31. package/dist/bitwrench-util-css.umd.min.js +21 -0
  32. package/dist/bitwrench.cjs.js +948 -782
  33. package/dist/bitwrench.cjs.min.js +21 -21
  34. package/dist/bitwrench.css +456 -132
  35. package/dist/bitwrench.es5.js +1024 -970
  36. package/dist/bitwrench.es5.min.js +19 -19
  37. package/dist/bitwrench.esm.js +949 -783
  38. package/dist/bitwrench.esm.min.js +21 -21
  39. package/dist/bitwrench.min.css +1 -1
  40. package/dist/bitwrench.umd.js +948 -782
  41. package/dist/bitwrench.umd.min.js +21 -21
  42. package/dist/builds.json +178 -90
  43. package/dist/bwserve.cjs.js +514 -68
  44. package/dist/bwserve.esm.js +513 -69
  45. package/dist/sri.json +44 -36
  46. package/package.json +3 -2
  47. package/readme.html +136 -49
  48. package/src/bitwrench-bccl.js +7 -7
  49. package/src/bitwrench-color-utils.js +31 -9
  50. package/src/bitwrench-esm-entry.js +11 -0
  51. package/src/bitwrench-styles.js +439 -232
  52. package/src/bitwrench-util-css.js +229 -0
  53. package/src/bitwrench.js +483 -485
  54. package/src/bwserve/attach.js +57 -0
  55. package/src/bwserve/bwclient.js +141 -0
  56. package/src/bwserve/bwshell.js +102 -0
  57. package/src/bwserve/client.js +151 -1
  58. package/src/bwserve/index.js +127 -28
  59. package/src/cli/attach.js +555 -0
  60. package/src/cli/convert.js +2 -5
  61. package/src/cli/index.js +7 -0
  62. package/src/cli/inject.js +1 -1
  63. package/src/cli/serve.js +6 -2
  64. package/src/generate-css.js +11 -4
  65. package/src/vendor/html2canvas.min.js +20 -0
  66. package/src/version.js +3 -3
  67. package/src/bwserve/shell.js +0 -106
@@ -0,0 +1,230 @@
1
+ /*! bitwrench-util-css v2.0.18 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
2
+ /**
3
+ * bitwrench-util-css.js - Rule-based CSS utility parser plugin
4
+ *
5
+ * Replaces the old static `bw.u` dictionary with a parser that generates
6
+ * style objects, CSS strings, or class names from shorthand tokens.
7
+ *
8
+ * Three output methods:
9
+ * bw.u('flex gap4 p4') → { display: 'flex', gap: '1rem', padding: '1rem' }
10
+ * bw.u.css('flex gap4 p4') → "display:flex;gap:1rem;padding:1rem"
11
+ * bw.u.cls('flex gap4 p4') → "bw_flex bw_gap_4 bw_p_4"
12
+ * bw.u.extend({ name: fn }) → register custom rules
13
+ *
14
+ * Can be loaded standalone (browser script tag after bitwrench.umd.js),
15
+ * or imported as an ES module / CJS module.
16
+ *
17
+ * @module bitwrench-util-css
18
+ * @license BSD-2-Clause
19
+ */
20
+
21
+ // -- Scale: n → rem (0.25rem increments) ---------------------------------
22
+ function _rem(n) { return (n * 0.25) + 'rem'; }
23
+
24
+ // -- Built-in parametric rules -------------------------------------------
25
+ // Each returns a style object or null (not recognized).
26
+ var PARAMETRIC = {
27
+ p: function(n) { return { padding: _rem(n) }; },
28
+ pt: function(n) { return { paddingTop: _rem(n) }; },
29
+ pb: function(n) { return { paddingBottom: _rem(n) }; },
30
+ pl: function(n) { return { paddingLeft: _rem(n) }; },
31
+ pr: function(n) { return { paddingRight: _rem(n) }; },
32
+ px: function(n) { return { paddingLeft: _rem(n), paddingRight: _rem(n) }; },
33
+ py: function(n) { return { paddingTop: _rem(n), paddingBottom: _rem(n) }; },
34
+ m: function(n) { return { margin: _rem(n) }; },
35
+ mt: function(n) { return { marginTop: _rem(n) }; },
36
+ mb: function(n) { return { marginBottom: _rem(n) }; },
37
+ ml: function(n) { return { marginLeft: _rem(n) }; },
38
+ mr: function(n) { return { marginRight: _rem(n) }; },
39
+ mx: function(n) { return { marginLeft: _rem(n), marginRight: _rem(n) }; },
40
+ my: function(n) { return { marginTop: _rem(n), marginBottom: _rem(n) }; },
41
+ gap: function(n) { return { gap: _rem(n) }; },
42
+ w: function(n) { return { width: _rem(n) }; },
43
+ h: function(n) { return { height: _rem(n) }; },
44
+ rounded: function(n) { return { borderRadius: _rem(n) }; },
45
+ textSm: function() { return { fontSize: '0.875rem' }; },
46
+ textBase: function() { return { fontSize: '1rem' }; },
47
+ textLg: function() { return { fontSize: '1.125rem' }; },
48
+ textXl: function() { return { fontSize: '1.25rem' }; },
49
+ text2xl: function() { return { fontSize: '1.5rem' }; },
50
+ text3xl: function() { return { fontSize: '1.875rem' }; }
51
+ };
52
+
53
+ // -- Static keywords (no numeric param) ----------------------------------
54
+ var STATICS = {
55
+ flex: { display: 'flex' },
56
+ flexCol: { display: 'flex', flexDirection: 'column' },
57
+ flexRow: { display: 'flex', flexDirection: 'row' },
58
+ flexWrap: { display: 'flex', flexWrap: 'wrap' },
59
+ block: { display: 'block' },
60
+ inline: { display: 'inline' },
61
+ hidden: { display: 'none' },
62
+ bold: { fontWeight: '700' },
63
+ semibold: { fontWeight: '600' },
64
+ italic: { fontStyle: 'italic' },
65
+ textCenter: { textAlign: 'center' },
66
+ textRight: { textAlign: 'right' },
67
+ justifyCenter: { justifyContent: 'center' },
68
+ justifyBetween: { justifyContent: 'space-between' },
69
+ justifyEnd: { justifyContent: 'flex-end' },
70
+ alignCenter: { alignItems: 'center' },
71
+ alignStart: { alignItems: 'flex-start' },
72
+ alignEnd: { alignItems: 'flex-end' },
73
+ wFull: { width: '100%' },
74
+ hFull: { height: '100%' },
75
+ transition: { transition: 'all 0.2s ease' }
76
+ };
77
+
78
+ // -- Custom rules (added via u.extend) -----------------------------------
79
+ var _custom = {};
80
+
81
+ // -- Token parser --------------------------------------------------------
82
+ // Regex: split on whitespace
83
+ var _splitRe = /\s+/;
84
+
85
+ // Match parametric token: name + digits, e.g. "p4", "gap8", "rounded2"
86
+ var _paramRe = /^([a-zA-Z]+?)(\d+)$/;
87
+
88
+ // Match color rules: bg-<name>, text-<name>, bg-[#hex]
89
+ var _bgBracketRe = /^bg-\[([^\]]+)\]$/;
90
+ var _textBracketRe = /^text-\[([^\]]+)\]$/;
91
+ var _bgNameRe = /^bg-(.+)$/;
92
+ var _textNameRe = /^text-(.+)$/;
93
+
94
+ /**
95
+ * Parse a single token into a style object, or null if unknown.
96
+ */
97
+ function _parseToken(token) {
98
+ // 1. Custom rules first
99
+ if (_custom[token]) {
100
+ var val = _custom[token];
101
+ return typeof val === 'function' ? val(token) : val;
102
+ }
103
+
104
+ // 2. Static keywords
105
+ if (STATICS[token]) return STATICS[token];
106
+
107
+ // 3. Parametric rules (e.g. p4, gap8, mb2)
108
+ var pm = _paramRe.exec(token);
109
+ if (pm) {
110
+ var name = pm[1];
111
+ var num = parseInt(pm[2], 10);
112
+ if (PARAMETRIC[name]) return PARAMETRIC[name](num);
113
+ }
114
+
115
+ // 4. Non-numeric parametric (text sizes like textSm)
116
+ if (PARAMETRIC[token]) return PARAMETRIC[token]();
117
+
118
+ // 5. Color: bg-[#hex]
119
+ var bgBr = _bgBracketRe.exec(token);
120
+ if (bgBr) return { background: bgBr[1] };
121
+
122
+ // 6. Color: text-[#hex]
123
+ var textBr = _textBracketRe.exec(token);
124
+ if (textBr) return { color: textBr[1] };
125
+
126
+ // 7. Color: bg-<name>
127
+ var bgN = _bgNameRe.exec(token);
128
+ if (bgN) return { background: bgN[1] };
129
+
130
+ // 8. Color: text-<name>
131
+ var textN = _textNameRe.exec(token);
132
+ if (textN) return { color: textN[1] };
133
+
134
+ // Unknown → silently ignored
135
+ return null;
136
+ }
137
+
138
+ /**
139
+ * Parse a space-separated string of utility tokens into a merged style object.
140
+ *
141
+ * @param {string} str - Space-separated utility tokens
142
+ * @returns {Object} Merged style object
143
+ */
144
+ function u(str) {
145
+ if (!str || typeof str !== 'string') return {};
146
+ var tokens = str.trim().split(_splitRe);
147
+ var result = {};
148
+ for (var i = 0; i < tokens.length; i++) {
149
+ var style = _parseToken(tokens[i]);
150
+ if (style) {
151
+ var keys = Object.keys(style);
152
+ for (var j = 0; j < keys.length; j++) {
153
+ result[keys[j]] = style[keys[j]];
154
+ }
155
+ }
156
+ }
157
+ return result;
158
+ }
159
+
160
+ /**
161
+ * Parse tokens and return a CSS declaration string.
162
+ *
163
+ * @param {string} str - Space-separated utility tokens
164
+ * @returns {string} CSS declarations (e.g. "display:flex;gap:1rem")
165
+ */
166
+ u.css = function(str) {
167
+ var style = u(str);
168
+ var parts = [];
169
+ var keys = Object.keys(style);
170
+ for (var i = 0; i < keys.length; i++) {
171
+ // Convert camelCase to kebab-case
172
+ var prop = keys[i].replace(/([A-Z])/g, function(m) { return '-' + m.toLowerCase(); });
173
+ parts.push(prop + ':' + style[keys[i]]);
174
+ }
175
+ return parts.join(';');
176
+ };
177
+
178
+ /**
179
+ * Parse tokens and return BEM-style class names (bw_ prefixed).
180
+ *
181
+ * @param {string} str - Space-separated utility tokens
182
+ * @returns {string} Space-separated class names
183
+ */
184
+ u.cls = function(str) {
185
+ if (!str || typeof str !== 'string') return '';
186
+ var tokens = str.trim().split(_splitRe);
187
+ var classes = [];
188
+ for (var i = 0; i < tokens.length; i++) {
189
+ var token = tokens[i];
190
+ // Only emit classes for recognized tokens
191
+ if (_parseToken(token)) {
192
+ // Convert camelCase to underscore, digits get underscore prefix
193
+ var cls = 'bw_' + token
194
+ .replace(/([A-Z])/g, function(m) { return '_' + m.toLowerCase(); })
195
+ .replace(/(\d+)/g, function(m) { return '_' + m; });
196
+ classes.push(cls);
197
+ }
198
+ }
199
+ return classes.join(' ');
200
+ };
201
+
202
+ /**
203
+ * Register custom rules. Each key is a token name, value is either
204
+ * a style object or a function returning a style object.
205
+ *
206
+ * @param {Object} rules - Map of token → style object or function
207
+ */
208
+ u.extend = function(rules) {
209
+ if (!rules || typeof rules !== 'object') return;
210
+ var keys = Object.keys(rules);
211
+ for (var i = 0; i < keys.length; i++) {
212
+ _custom[keys[i]] = rules[keys[i]];
213
+ }
214
+ };
215
+
216
+ // -- Plugin installation -------------------------------------------------
217
+ function install(bw) {
218
+ if (!bw) return;
219
+ bw.utilCSS = u;
220
+ bw.u = u;
221
+ }
222
+
223
+ // Auto-install if bw is on window (script tag usage)
224
+ if (typeof window !== 'undefined' && window.bw) {
225
+ install(window.bw);
226
+ }
227
+ var bitwrenchUtilCss = { utilCSS: u, install };
228
+
229
+ export { bitwrenchUtilCss as default, install, u as utilCSS };
230
+ //# sourceMappingURL=bitwrench-util-css.esm.js.map
@@ -0,0 +1,21 @@
1
+ /*! bitwrench-util-css v2.0.18 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
2
+ /**
3
+ * bitwrench-util-css.js - Rule-based CSS utility parser plugin
4
+ *
5
+ * Replaces the old static `bw.u` dictionary with a parser that generates
6
+ * style objects, CSS strings, or class names from shorthand tokens.
7
+ *
8
+ * Three output methods:
9
+ * bw.u('flex gap4 p4') → { display: 'flex', gap: '1rem', padding: '1rem' }
10
+ * bw.u.css('flex gap4 p4') → "display:flex;gap:1rem;padding:1rem"
11
+ * bw.u.cls('flex gap4 p4') → "bw_flex bw_gap_4 bw_p_4"
12
+ * bw.u.extend({ name: fn }) → register custom rules
13
+ *
14
+ * Can be loaded standalone (browser script tag after bitwrench.umd.js),
15
+ * or imported as an ES module / CJS module.
16
+ *
17
+ * @module bitwrench-util-css
18
+ * @license BSD-2-Clause
19
+ */
20
+ function t(t){return.25*t+"rem"}var n={p:function(n){return{padding:t(n)}},pt:function(n){return{paddingTop:t(n)}},pb:function(n){return{paddingBottom:t(n)}},pl:function(n){return{paddingLeft:t(n)}},pr:function(n){return{paddingRight:t(n)}},px:function(n){return{paddingLeft:t(n),paddingRight:t(n)}},py:function(n){return{paddingTop:t(n),paddingBottom:t(n)}},m:function(n){return{margin:t(n)}},mt:function(n){return{marginTop:t(n)}},mb:function(n){return{marginBottom:t(n)}},ml:function(n){return{marginLeft:t(n)}},mr:function(n){return{marginRight:t(n)}},mx:function(n){return{marginLeft:t(n),marginRight:t(n)}},my:function(n){return{marginTop:t(n),marginBottom:t(n)}},gap:function(n){return{gap:t(n)}},w:function(n){return{width:t(n)}},h:function(n){return{height:t(n)}},rounded:function(n){return{borderRadius:t(n)}},textSm:function(){return{fontSize:"0.875rem"}},textBase:function(){return{fontSize:"1rem"}},textLg:function(){return{fontSize:"1.125rem"}},textXl:function(){return{fontSize:"1.25rem"}},text2xl:function(){return{fontSize:"1.5rem"}},text3xl:function(){return{fontSize:"1.875rem"}}},e={flex:{display:"flex"},flexCol:{display:"flex",flexDirection:"column"},flexRow:{display:"flex",flexDirection:"row"},flexWrap:{display:"flex",flexWrap:"wrap"},block:{display:"block"},inline:{display:"inline"},hidden:{display:"none"},bold:{fontWeight:"700"},semibold:{fontWeight:"600"},italic:{fontStyle:"italic"},textCenter:{textAlign:"center"},textRight:{textAlign:"right"},justifyCenter:{justifyContent:"center"},justifyBetween:{justifyContent:"space-between"},justifyEnd:{justifyContent:"flex-end"},alignCenter:{alignItems:"center"},alignStart:{alignItems:"flex-start"},alignEnd:{alignItems:"flex-end"},wFull:{width:"100%"},hFull:{height:"100%"},transition:{transition:"all 0.2s ease"}},r={},i=/\s+/,o=/^([a-zA-Z]+?)(\d+)$/,u=/^bg-\[([^\]]+)\]$/,f=/^text-\[([^\]]+)\]$/,a=/^bg-(.+)$/,l=/^text-(.+)$/;function c(t){if(r[t]){var i=r[t];return"function"==typeof i?i(t):i}if(e[t])return e[t];var c=o.exec(t);if(c){var g=c[1],d=parseInt(c[2],10);if(n[g])return n[g](d)}if(n[t])return n[t]();var p=u.exec(t);if(p)return{background:p[1]};var s=f.exec(t);if(s)return{color:s[1]};var x=a.exec(t);if(x)return{background:x[1]};var m=l.exec(t);return m?{color:m[1]}:null}function g(t){if(!t||"string"!=typeof t)return{};for(var n=t.trim().split(i),e={},r=0;r<n.length;r++){var o=c(n[r]);if(o)for(var u=Object.keys(o),f=0;f<u.length;f++)e[u[f]]=o[u[f]]}return e}function d(t){t&&(t.utilCSS=g,t.u=g)}g.css=function(t){for(var n=g(t),e=[],r=Object.keys(n),i=0;i<r.length;i++){var o=r[i].replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()});e.push(o+":"+n[r[i]])}return e.join(";")},g.cls=function(t){if(!t||"string"!=typeof t)return"";for(var n=t.trim().split(i),e=[],r=0;r<n.length;r++){var o=n[r];if(c(o)){var u="bw_"+o.replace(/([A-Z])/g,function(t){return"_"+t.toLowerCase()}).replace(/(\d+)/g,function(t){return"_"+t});e.push(u)}}return e.join(" ")},g.extend=function(t){if(t&&"object"==typeof t)for(var n=Object.keys(t),e=0;e<n.length;e++)r[n[e]]=t[n[e]]},"undefined"!=typeof window&&window.bw&&d(window.bw);var p={utilCSS:g,install:d};export{p as default,d as install,g as utilCSS};
21
+ //# sourceMappingURL=bitwrench-util-css.esm.min.js.map
@@ -0,0 +1,242 @@
1
+ /*! bitwrench-util-css v2.0.18 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
2
+ (function (global, factory) {
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
5
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bwUtilCSS = {}));
6
+ })(this, (function (exports) { 'use strict';
7
+
8
+ /**
9
+ * bitwrench-util-css.js - Rule-based CSS utility parser plugin
10
+ *
11
+ * Replaces the old static `bw.u` dictionary with a parser that generates
12
+ * style objects, CSS strings, or class names from shorthand tokens.
13
+ *
14
+ * Three output methods:
15
+ * bw.u('flex gap4 p4') → { display: 'flex', gap: '1rem', padding: '1rem' }
16
+ * bw.u.css('flex gap4 p4') → "display:flex;gap:1rem;padding:1rem"
17
+ * bw.u.cls('flex gap4 p4') → "bw_flex bw_gap_4 bw_p_4"
18
+ * bw.u.extend({ name: fn }) → register custom rules
19
+ *
20
+ * Can be loaded standalone (browser script tag after bitwrench.umd.js),
21
+ * or imported as an ES module / CJS module.
22
+ *
23
+ * @module bitwrench-util-css
24
+ * @license BSD-2-Clause
25
+ */
26
+
27
+ // -- Scale: n → rem (0.25rem increments) ---------------------------------
28
+ function _rem(n) { return (n * 0.25) + 'rem'; }
29
+
30
+ // -- Built-in parametric rules -------------------------------------------
31
+ // Each returns a style object or null (not recognized).
32
+ var PARAMETRIC = {
33
+ p: function(n) { return { padding: _rem(n) }; },
34
+ pt: function(n) { return { paddingTop: _rem(n) }; },
35
+ pb: function(n) { return { paddingBottom: _rem(n) }; },
36
+ pl: function(n) { return { paddingLeft: _rem(n) }; },
37
+ pr: function(n) { return { paddingRight: _rem(n) }; },
38
+ px: function(n) { return { paddingLeft: _rem(n), paddingRight: _rem(n) }; },
39
+ py: function(n) { return { paddingTop: _rem(n), paddingBottom: _rem(n) }; },
40
+ m: function(n) { return { margin: _rem(n) }; },
41
+ mt: function(n) { return { marginTop: _rem(n) }; },
42
+ mb: function(n) { return { marginBottom: _rem(n) }; },
43
+ ml: function(n) { return { marginLeft: _rem(n) }; },
44
+ mr: function(n) { return { marginRight: _rem(n) }; },
45
+ mx: function(n) { return { marginLeft: _rem(n), marginRight: _rem(n) }; },
46
+ my: function(n) { return { marginTop: _rem(n), marginBottom: _rem(n) }; },
47
+ gap: function(n) { return { gap: _rem(n) }; },
48
+ w: function(n) { return { width: _rem(n) }; },
49
+ h: function(n) { return { height: _rem(n) }; },
50
+ rounded: function(n) { return { borderRadius: _rem(n) }; },
51
+ textSm: function() { return { fontSize: '0.875rem' }; },
52
+ textBase: function() { return { fontSize: '1rem' }; },
53
+ textLg: function() { return { fontSize: '1.125rem' }; },
54
+ textXl: function() { return { fontSize: '1.25rem' }; },
55
+ text2xl: function() { return { fontSize: '1.5rem' }; },
56
+ text3xl: function() { return { fontSize: '1.875rem' }; }
57
+ };
58
+
59
+ // -- Static keywords (no numeric param) ----------------------------------
60
+ var STATICS = {
61
+ flex: { display: 'flex' },
62
+ flexCol: { display: 'flex', flexDirection: 'column' },
63
+ flexRow: { display: 'flex', flexDirection: 'row' },
64
+ flexWrap: { display: 'flex', flexWrap: 'wrap' },
65
+ block: { display: 'block' },
66
+ inline: { display: 'inline' },
67
+ hidden: { display: 'none' },
68
+ bold: { fontWeight: '700' },
69
+ semibold: { fontWeight: '600' },
70
+ italic: { fontStyle: 'italic' },
71
+ textCenter: { textAlign: 'center' },
72
+ textRight: { textAlign: 'right' },
73
+ justifyCenter: { justifyContent: 'center' },
74
+ justifyBetween: { justifyContent: 'space-between' },
75
+ justifyEnd: { justifyContent: 'flex-end' },
76
+ alignCenter: { alignItems: 'center' },
77
+ alignStart: { alignItems: 'flex-start' },
78
+ alignEnd: { alignItems: 'flex-end' },
79
+ wFull: { width: '100%' },
80
+ hFull: { height: '100%' },
81
+ transition: { transition: 'all 0.2s ease' }
82
+ };
83
+
84
+ // -- Custom rules (added via u.extend) -----------------------------------
85
+ var _custom = {};
86
+
87
+ // -- Token parser --------------------------------------------------------
88
+ // Regex: split on whitespace
89
+ var _splitRe = /\s+/;
90
+
91
+ // Match parametric token: name + digits, e.g. "p4", "gap8", "rounded2"
92
+ var _paramRe = /^([a-zA-Z]+?)(\d+)$/;
93
+
94
+ // Match color rules: bg-<name>, text-<name>, bg-[#hex]
95
+ var _bgBracketRe = /^bg-\[([^\]]+)\]$/;
96
+ var _textBracketRe = /^text-\[([^\]]+)\]$/;
97
+ var _bgNameRe = /^bg-(.+)$/;
98
+ var _textNameRe = /^text-(.+)$/;
99
+
100
+ /**
101
+ * Parse a single token into a style object, or null if unknown.
102
+ */
103
+ function _parseToken(token) {
104
+ // 1. Custom rules first
105
+ if (_custom[token]) {
106
+ var val = _custom[token];
107
+ return typeof val === 'function' ? val(token) : val;
108
+ }
109
+
110
+ // 2. Static keywords
111
+ if (STATICS[token]) return STATICS[token];
112
+
113
+ // 3. Parametric rules (e.g. p4, gap8, mb2)
114
+ var pm = _paramRe.exec(token);
115
+ if (pm) {
116
+ var name = pm[1];
117
+ var num = parseInt(pm[2], 10);
118
+ if (PARAMETRIC[name]) return PARAMETRIC[name](num);
119
+ }
120
+
121
+ // 4. Non-numeric parametric (text sizes like textSm)
122
+ if (PARAMETRIC[token]) return PARAMETRIC[token]();
123
+
124
+ // 5. Color: bg-[#hex]
125
+ var bgBr = _bgBracketRe.exec(token);
126
+ if (bgBr) return { background: bgBr[1] };
127
+
128
+ // 6. Color: text-[#hex]
129
+ var textBr = _textBracketRe.exec(token);
130
+ if (textBr) return { color: textBr[1] };
131
+
132
+ // 7. Color: bg-<name>
133
+ var bgN = _bgNameRe.exec(token);
134
+ if (bgN) return { background: bgN[1] };
135
+
136
+ // 8. Color: text-<name>
137
+ var textN = _textNameRe.exec(token);
138
+ if (textN) return { color: textN[1] };
139
+
140
+ // Unknown → silently ignored
141
+ return null;
142
+ }
143
+
144
+ /**
145
+ * Parse a space-separated string of utility tokens into a merged style object.
146
+ *
147
+ * @param {string} str - Space-separated utility tokens
148
+ * @returns {Object} Merged style object
149
+ */
150
+ function u(str) {
151
+ if (!str || typeof str !== 'string') return {};
152
+ var tokens = str.trim().split(_splitRe);
153
+ var result = {};
154
+ for (var i = 0; i < tokens.length; i++) {
155
+ var style = _parseToken(tokens[i]);
156
+ if (style) {
157
+ var keys = Object.keys(style);
158
+ for (var j = 0; j < keys.length; j++) {
159
+ result[keys[j]] = style[keys[j]];
160
+ }
161
+ }
162
+ }
163
+ return result;
164
+ }
165
+
166
+ /**
167
+ * Parse tokens and return a CSS declaration string.
168
+ *
169
+ * @param {string} str - Space-separated utility tokens
170
+ * @returns {string} CSS declarations (e.g. "display:flex;gap:1rem")
171
+ */
172
+ u.css = function(str) {
173
+ var style = u(str);
174
+ var parts = [];
175
+ var keys = Object.keys(style);
176
+ for (var i = 0; i < keys.length; i++) {
177
+ // Convert camelCase to kebab-case
178
+ var prop = keys[i].replace(/([A-Z])/g, function(m) { return '-' + m.toLowerCase(); });
179
+ parts.push(prop + ':' + style[keys[i]]);
180
+ }
181
+ return parts.join(';');
182
+ };
183
+
184
+ /**
185
+ * Parse tokens and return BEM-style class names (bw_ prefixed).
186
+ *
187
+ * @param {string} str - Space-separated utility tokens
188
+ * @returns {string} Space-separated class names
189
+ */
190
+ u.cls = function(str) {
191
+ if (!str || typeof str !== 'string') return '';
192
+ var tokens = str.trim().split(_splitRe);
193
+ var classes = [];
194
+ for (var i = 0; i < tokens.length; i++) {
195
+ var token = tokens[i];
196
+ // Only emit classes for recognized tokens
197
+ if (_parseToken(token)) {
198
+ // Convert camelCase to underscore, digits get underscore prefix
199
+ var cls = 'bw_' + token
200
+ .replace(/([A-Z])/g, function(m) { return '_' + m.toLowerCase(); })
201
+ .replace(/(\d+)/g, function(m) { return '_' + m; });
202
+ classes.push(cls);
203
+ }
204
+ }
205
+ return classes.join(' ');
206
+ };
207
+
208
+ /**
209
+ * Register custom rules. Each key is a token name, value is either
210
+ * a style object or a function returning a style object.
211
+ *
212
+ * @param {Object} rules - Map of token → style object or function
213
+ */
214
+ u.extend = function(rules) {
215
+ if (!rules || typeof rules !== 'object') return;
216
+ var keys = Object.keys(rules);
217
+ for (var i = 0; i < keys.length; i++) {
218
+ _custom[keys[i]] = rules[keys[i]];
219
+ }
220
+ };
221
+
222
+ // -- Plugin installation -------------------------------------------------
223
+ function install(bw) {
224
+ if (!bw) return;
225
+ bw.utilCSS = u;
226
+ bw.u = u;
227
+ }
228
+
229
+ // Auto-install if bw is on window (script tag usage)
230
+ if (typeof window !== 'undefined' && window.bw) {
231
+ install(window.bw);
232
+ }
233
+ var bitwrenchUtilCss = { utilCSS: u, install };
234
+
235
+ exports.default = bitwrenchUtilCss;
236
+ exports.install = install;
237
+ exports.utilCSS = u;
238
+
239
+ Object.defineProperty(exports, '__esModule', { value: true });
240
+
241
+ }));
242
+ //# sourceMappingURL=bitwrench-util-css.umd.js.map
@@ -0,0 +1,21 @@
1
+ /*! bitwrench-util-css v2.0.18 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
2
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).bwUtilCSS={})}(this,function(t){"use strict";
3
+ /**
4
+ * bitwrench-util-css.js - Rule-based CSS utility parser plugin
5
+ *
6
+ * Replaces the old static `bw.u` dictionary with a parser that generates
7
+ * style objects, CSS strings, or class names from shorthand tokens.
8
+ *
9
+ * Three output methods:
10
+ * bw.u('flex gap4 p4') → { display: 'flex', gap: '1rem', padding: '1rem' }
11
+ * bw.u.css('flex gap4 p4') → "display:flex;gap:1rem;padding:1rem"
12
+ * bw.u.cls('flex gap4 p4') → "bw_flex bw_gap_4 bw_p_4"
13
+ * bw.u.extend({ name: fn }) → register custom rules
14
+ *
15
+ * Can be loaded standalone (browser script tag after bitwrench.umd.js),
16
+ * or imported as an ES module / CJS module.
17
+ *
18
+ * @module bitwrench-util-css
19
+ * @license BSD-2-Clause
20
+ */function n(t){return.25*t+"rem"}var e={p:function(t){return{padding:n(t)}},pt:function(t){return{paddingTop:n(t)}},pb:function(t){return{paddingBottom:n(t)}},pl:function(t){return{paddingLeft:n(t)}},pr:function(t){return{paddingRight:n(t)}},px:function(t){return{paddingLeft:n(t),paddingRight:n(t)}},py:function(t){return{paddingTop:n(t),paddingBottom:n(t)}},m:function(t){return{margin:n(t)}},mt:function(t){return{marginTop:n(t)}},mb:function(t){return{marginBottom:n(t)}},ml:function(t){return{marginLeft:n(t)}},mr:function(t){return{marginRight:n(t)}},mx:function(t){return{marginLeft:n(t),marginRight:n(t)}},my:function(t){return{marginTop:n(t),marginBottom:n(t)}},gap:function(t){return{gap:n(t)}},w:function(t){return{width:n(t)}},h:function(t){return{height:n(t)}},rounded:function(t){return{borderRadius:n(t)}},textSm:function(){return{fontSize:"0.875rem"}},textBase:function(){return{fontSize:"1rem"}},textLg:function(){return{fontSize:"1.125rem"}},textXl:function(){return{fontSize:"1.25rem"}},text2xl:function(){return{fontSize:"1.5rem"}},text3xl:function(){return{fontSize:"1.875rem"}}},r={flex:{display:"flex"},flexCol:{display:"flex",flexDirection:"column"},flexRow:{display:"flex",flexDirection:"row"},flexWrap:{display:"flex",flexWrap:"wrap"},block:{display:"block"},inline:{display:"inline"},hidden:{display:"none"},bold:{fontWeight:"700"},semibold:{fontWeight:"600"},italic:{fontStyle:"italic"},textCenter:{textAlign:"center"},textRight:{textAlign:"right"},justifyCenter:{justifyContent:"center"},justifyBetween:{justifyContent:"space-between"},justifyEnd:{justifyContent:"flex-end"},alignCenter:{alignItems:"center"},alignStart:{alignItems:"flex-start"},alignEnd:{alignItems:"flex-end"},wFull:{width:"100%"},hFull:{height:"100%"},transition:{transition:"all 0.2s ease"}},i={},o=/\s+/,f=/^([a-zA-Z]+?)(\d+)$/,u=/^bg-\[([^\]]+)\]$/,l=/^text-\[([^\]]+)\]$/,a=/^bg-(.+)$/,c=/^text-(.+)$/;function d(t){if(i[t]){var n=i[t];return"function"==typeof n?n(t):n}if(r[t])return r[t];var o=f.exec(t);if(o){var d=o[1],g=parseInt(o[2],10);if(e[d])return e[d](g)}if(e[t])return e[t]();var p=u.exec(t);if(p)return{background:p[1]};var s=l.exec(t);if(s)return{color:s[1]};var x=a.exec(t);if(x)return{background:x[1]};var m=c.exec(t);return m?{color:m[1]}:null}function g(t){if(!t||"string"!=typeof t)return{};for(var n=t.trim().split(o),e={},r=0;r<n.length;r++){var i=d(n[r]);if(i)for(var f=Object.keys(i),u=0;u<f.length;u++)e[f[u]]=i[f[u]]}return e}function p(t){t&&(t.utilCSS=g,t.u=g)}g.css=function(t){for(var n=g(t),e=[],r=Object.keys(n),i=0;i<r.length;i++){var o=r[i].replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()});e.push(o+":"+n[r[i]])}return e.join(";")},g.cls=function(t){if(!t||"string"!=typeof t)return"";for(var n=t.trim().split(o),e=[],r=0;r<n.length;r++){var i=n[r];if(d(i)){var f="bw_"+i.replace(/([A-Z])/g,function(t){return"_"+t.toLowerCase()}).replace(/(\d+)/g,function(t){return"_"+t});e.push(f)}}return e.join(" ")},g.extend=function(t){if(t&&"object"==typeof t)for(var n=Object.keys(t),e=0;e<n.length;e++)i[n[e]]=t[n[e]]},"undefined"!=typeof window&&window.bw&&p(window.bw);var s={utilCSS:g,install:p};t.default=s,t.install=p,t.utilCSS=g,Object.defineProperty(t,"__esModule",{value:!0})});
21
+ //# sourceMappingURL=bitwrench-util-css.umd.min.js.map