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,236 @@
1
+ /*! bitwrench-util-css v2.0.18 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * bitwrench-util-css.js - Rule-based CSS utility parser plugin
8
+ *
9
+ * Replaces the old static `bw.u` dictionary with a parser that generates
10
+ * style objects, CSS strings, or class names from shorthand tokens.
11
+ *
12
+ * Three output methods:
13
+ * bw.u('flex gap4 p4') → { display: 'flex', gap: '1rem', padding: '1rem' }
14
+ * bw.u.css('flex gap4 p4') → "display:flex;gap:1rem;padding:1rem"
15
+ * bw.u.cls('flex gap4 p4') → "bw_flex bw_gap_4 bw_p_4"
16
+ * bw.u.extend({ name: fn }) → register custom rules
17
+ *
18
+ * Can be loaded standalone (browser script tag after bitwrench.umd.js),
19
+ * or imported as an ES module / CJS module.
20
+ *
21
+ * @module bitwrench-util-css
22
+ * @license BSD-2-Clause
23
+ */
24
+
25
+ // -- Scale: n → rem (0.25rem increments) ---------------------------------
26
+ function _rem(n) { return (n * 0.25) + 'rem'; }
27
+
28
+ // -- Built-in parametric rules -------------------------------------------
29
+ // Each returns a style object or null (not recognized).
30
+ var PARAMETRIC = {
31
+ p: function(n) { return { padding: _rem(n) }; },
32
+ pt: function(n) { return { paddingTop: _rem(n) }; },
33
+ pb: function(n) { return { paddingBottom: _rem(n) }; },
34
+ pl: function(n) { return { paddingLeft: _rem(n) }; },
35
+ pr: function(n) { return { paddingRight: _rem(n) }; },
36
+ px: function(n) { return { paddingLeft: _rem(n), paddingRight: _rem(n) }; },
37
+ py: function(n) { return { paddingTop: _rem(n), paddingBottom: _rem(n) }; },
38
+ m: function(n) { return { margin: _rem(n) }; },
39
+ mt: function(n) { return { marginTop: _rem(n) }; },
40
+ mb: function(n) { return { marginBottom: _rem(n) }; },
41
+ ml: function(n) { return { marginLeft: _rem(n) }; },
42
+ mr: function(n) { return { marginRight: _rem(n) }; },
43
+ mx: function(n) { return { marginLeft: _rem(n), marginRight: _rem(n) }; },
44
+ my: function(n) { return { marginTop: _rem(n), marginBottom: _rem(n) }; },
45
+ gap: function(n) { return { gap: _rem(n) }; },
46
+ w: function(n) { return { width: _rem(n) }; },
47
+ h: function(n) { return { height: _rem(n) }; },
48
+ rounded: function(n) { return { borderRadius: _rem(n) }; },
49
+ textSm: function() { return { fontSize: '0.875rem' }; },
50
+ textBase: function() { return { fontSize: '1rem' }; },
51
+ textLg: function() { return { fontSize: '1.125rem' }; },
52
+ textXl: function() { return { fontSize: '1.25rem' }; },
53
+ text2xl: function() { return { fontSize: '1.5rem' }; },
54
+ text3xl: function() { return { fontSize: '1.875rem' }; }
55
+ };
56
+
57
+ // -- Static keywords (no numeric param) ----------------------------------
58
+ var STATICS = {
59
+ flex: { display: 'flex' },
60
+ flexCol: { display: 'flex', flexDirection: 'column' },
61
+ flexRow: { display: 'flex', flexDirection: 'row' },
62
+ flexWrap: { display: 'flex', flexWrap: 'wrap' },
63
+ block: { display: 'block' },
64
+ inline: { display: 'inline' },
65
+ hidden: { display: 'none' },
66
+ bold: { fontWeight: '700' },
67
+ semibold: { fontWeight: '600' },
68
+ italic: { fontStyle: 'italic' },
69
+ textCenter: { textAlign: 'center' },
70
+ textRight: { textAlign: 'right' },
71
+ justifyCenter: { justifyContent: 'center' },
72
+ justifyBetween: { justifyContent: 'space-between' },
73
+ justifyEnd: { justifyContent: 'flex-end' },
74
+ alignCenter: { alignItems: 'center' },
75
+ alignStart: { alignItems: 'flex-start' },
76
+ alignEnd: { alignItems: 'flex-end' },
77
+ wFull: { width: '100%' },
78
+ hFull: { height: '100%' },
79
+ transition: { transition: 'all 0.2s ease' }
80
+ };
81
+
82
+ // -- Custom rules (added via u.extend) -----------------------------------
83
+ var _custom = {};
84
+
85
+ // -- Token parser --------------------------------------------------------
86
+ // Regex: split on whitespace
87
+ var _splitRe = /\s+/;
88
+
89
+ // Match parametric token: name + digits, e.g. "p4", "gap8", "rounded2"
90
+ var _paramRe = /^([a-zA-Z]+?)(\d+)$/;
91
+
92
+ // Match color rules: bg-<name>, text-<name>, bg-[#hex]
93
+ var _bgBracketRe = /^bg-\[([^\]]+)\]$/;
94
+ var _textBracketRe = /^text-\[([^\]]+)\]$/;
95
+ var _bgNameRe = /^bg-(.+)$/;
96
+ var _textNameRe = /^text-(.+)$/;
97
+
98
+ /**
99
+ * Parse a single token into a style object, or null if unknown.
100
+ */
101
+ function _parseToken(token) {
102
+ // 1. Custom rules first
103
+ if (_custom[token]) {
104
+ var val = _custom[token];
105
+ return typeof val === 'function' ? val(token) : val;
106
+ }
107
+
108
+ // 2. Static keywords
109
+ if (STATICS[token]) return STATICS[token];
110
+
111
+ // 3. Parametric rules (e.g. p4, gap8, mb2)
112
+ var pm = _paramRe.exec(token);
113
+ if (pm) {
114
+ var name = pm[1];
115
+ var num = parseInt(pm[2], 10);
116
+ if (PARAMETRIC[name]) return PARAMETRIC[name](num);
117
+ }
118
+
119
+ // 4. Non-numeric parametric (text sizes like textSm)
120
+ if (PARAMETRIC[token]) return PARAMETRIC[token]();
121
+
122
+ // 5. Color: bg-[#hex]
123
+ var bgBr = _bgBracketRe.exec(token);
124
+ if (bgBr) return { background: bgBr[1] };
125
+
126
+ // 6. Color: text-[#hex]
127
+ var textBr = _textBracketRe.exec(token);
128
+ if (textBr) return { color: textBr[1] };
129
+
130
+ // 7. Color: bg-<name>
131
+ var bgN = _bgNameRe.exec(token);
132
+ if (bgN) return { background: bgN[1] };
133
+
134
+ // 8. Color: text-<name>
135
+ var textN = _textNameRe.exec(token);
136
+ if (textN) return { color: textN[1] };
137
+
138
+ // Unknown → silently ignored
139
+ return null;
140
+ }
141
+
142
+ /**
143
+ * Parse a space-separated string of utility tokens into a merged style object.
144
+ *
145
+ * @param {string} str - Space-separated utility tokens
146
+ * @returns {Object} Merged style object
147
+ */
148
+ function u(str) {
149
+ if (!str || typeof str !== 'string') return {};
150
+ var tokens = str.trim().split(_splitRe);
151
+ var result = {};
152
+ for (var i = 0; i < tokens.length; i++) {
153
+ var style = _parseToken(tokens[i]);
154
+ if (style) {
155
+ var keys = Object.keys(style);
156
+ for (var j = 0; j < keys.length; j++) {
157
+ result[keys[j]] = style[keys[j]];
158
+ }
159
+ }
160
+ }
161
+ return result;
162
+ }
163
+
164
+ /**
165
+ * Parse tokens and return a CSS declaration string.
166
+ *
167
+ * @param {string} str - Space-separated utility tokens
168
+ * @returns {string} CSS declarations (e.g. "display:flex;gap:1rem")
169
+ */
170
+ u.css = function(str) {
171
+ var style = u(str);
172
+ var parts = [];
173
+ var keys = Object.keys(style);
174
+ for (var i = 0; i < keys.length; i++) {
175
+ // Convert camelCase to kebab-case
176
+ var prop = keys[i].replace(/([A-Z])/g, function(m) { return '-' + m.toLowerCase(); });
177
+ parts.push(prop + ':' + style[keys[i]]);
178
+ }
179
+ return parts.join(';');
180
+ };
181
+
182
+ /**
183
+ * Parse tokens and return BEM-style class names (bw_ prefixed).
184
+ *
185
+ * @param {string} str - Space-separated utility tokens
186
+ * @returns {string} Space-separated class names
187
+ */
188
+ u.cls = function(str) {
189
+ if (!str || typeof str !== 'string') return '';
190
+ var tokens = str.trim().split(_splitRe);
191
+ var classes = [];
192
+ for (var i = 0; i < tokens.length; i++) {
193
+ var token = tokens[i];
194
+ // Only emit classes for recognized tokens
195
+ if (_parseToken(token)) {
196
+ // Convert camelCase to underscore, digits get underscore prefix
197
+ var cls = 'bw_' + token
198
+ .replace(/([A-Z])/g, function(m) { return '_' + m.toLowerCase(); })
199
+ .replace(/(\d+)/g, function(m) { return '_' + m; });
200
+ classes.push(cls);
201
+ }
202
+ }
203
+ return classes.join(' ');
204
+ };
205
+
206
+ /**
207
+ * Register custom rules. Each key is a token name, value is either
208
+ * a style object or a function returning a style object.
209
+ *
210
+ * @param {Object} rules - Map of token → style object or function
211
+ */
212
+ u.extend = function(rules) {
213
+ if (!rules || typeof rules !== 'object') return;
214
+ var keys = Object.keys(rules);
215
+ for (var i = 0; i < keys.length; i++) {
216
+ _custom[keys[i]] = rules[keys[i]];
217
+ }
218
+ };
219
+
220
+ // -- Plugin installation -------------------------------------------------
221
+ function install(bw) {
222
+ if (!bw) return;
223
+ bw.utilCSS = u;
224
+ bw.u = u;
225
+ }
226
+
227
+ // Auto-install if bw is on window (script tag usage)
228
+ if (typeof window !== 'undefined' && window.bw) {
229
+ install(window.bw);
230
+ }
231
+ var bitwrenchUtilCss = { utilCSS: u, install };
232
+
233
+ exports.default = bitwrenchUtilCss;
234
+ exports.install = install;
235
+ exports.utilCSS = u;
236
+ //# sourceMappingURL=bitwrench-util-css.cjs.js.map
@@ -0,0 +1,22 @@
1
+ /*! bitwrench-util-css v2.0.18 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
2
+ "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
+ */
21
+ function t(t){return.25*t+"rem"}Object.defineProperty(exports,"__esModule",{value:!0});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};exports.default=p,exports.install=d,exports.utilCSS=g;
22
+ //# sourceMappingURL=bitwrench-util-css.cjs.min.js.map
@@ -0,0 +1,414 @@
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
+ function _typeof(o) {
9
+ "@babel/helpers - typeof";
10
+
11
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
12
+ return typeof o;
13
+ } : function (o) {
14
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
15
+ }, _typeof(o);
16
+ }
17
+
18
+ /**
19
+ * bitwrench-util-css.js - Rule-based CSS utility parser plugin
20
+ *
21
+ * Replaces the old static `bw.u` dictionary with a parser that generates
22
+ * style objects, CSS strings, or class names from shorthand tokens.
23
+ *
24
+ * Three output methods:
25
+ * bw.u('flex gap4 p4') → { display: 'flex', gap: '1rem', padding: '1rem' }
26
+ * bw.u.css('flex gap4 p4') → "display:flex;gap:1rem;padding:1rem"
27
+ * bw.u.cls('flex gap4 p4') → "bw_flex bw_gap_4 bw_p_4"
28
+ * bw.u.extend({ name: fn }) → register custom rules
29
+ *
30
+ * Can be loaded standalone (browser script tag after bitwrench.umd.js),
31
+ * or imported as an ES module / CJS module.
32
+ *
33
+ * @module bitwrench-util-css
34
+ * @license BSD-2-Clause
35
+ */
36
+
37
+ // -- Scale: n → rem (0.25rem increments) ---------------------------------
38
+ function _rem(n) {
39
+ return n * 0.25 + 'rem';
40
+ }
41
+
42
+ // -- Built-in parametric rules -------------------------------------------
43
+ // Each returns a style object or null (not recognized).
44
+ var PARAMETRIC = {
45
+ p: function p(n) {
46
+ return {
47
+ padding: _rem(n)
48
+ };
49
+ },
50
+ pt: function pt(n) {
51
+ return {
52
+ paddingTop: _rem(n)
53
+ };
54
+ },
55
+ pb: function pb(n) {
56
+ return {
57
+ paddingBottom: _rem(n)
58
+ };
59
+ },
60
+ pl: function pl(n) {
61
+ return {
62
+ paddingLeft: _rem(n)
63
+ };
64
+ },
65
+ pr: function pr(n) {
66
+ return {
67
+ paddingRight: _rem(n)
68
+ };
69
+ },
70
+ px: function px(n) {
71
+ return {
72
+ paddingLeft: _rem(n),
73
+ paddingRight: _rem(n)
74
+ };
75
+ },
76
+ py: function py(n) {
77
+ return {
78
+ paddingTop: _rem(n),
79
+ paddingBottom: _rem(n)
80
+ };
81
+ },
82
+ m: function m(n) {
83
+ return {
84
+ margin: _rem(n)
85
+ };
86
+ },
87
+ mt: function mt(n) {
88
+ return {
89
+ marginTop: _rem(n)
90
+ };
91
+ },
92
+ mb: function mb(n) {
93
+ return {
94
+ marginBottom: _rem(n)
95
+ };
96
+ },
97
+ ml: function ml(n) {
98
+ return {
99
+ marginLeft: _rem(n)
100
+ };
101
+ },
102
+ mr: function mr(n) {
103
+ return {
104
+ marginRight: _rem(n)
105
+ };
106
+ },
107
+ mx: function mx(n) {
108
+ return {
109
+ marginLeft: _rem(n),
110
+ marginRight: _rem(n)
111
+ };
112
+ },
113
+ my: function my(n) {
114
+ return {
115
+ marginTop: _rem(n),
116
+ marginBottom: _rem(n)
117
+ };
118
+ },
119
+ gap: function gap(n) {
120
+ return {
121
+ gap: _rem(n)
122
+ };
123
+ },
124
+ w: function w(n) {
125
+ return {
126
+ width: _rem(n)
127
+ };
128
+ },
129
+ h: function h(n) {
130
+ return {
131
+ height: _rem(n)
132
+ };
133
+ },
134
+ rounded: function rounded(n) {
135
+ return {
136
+ borderRadius: _rem(n)
137
+ };
138
+ },
139
+ textSm: function textSm() {
140
+ return {
141
+ fontSize: '0.875rem'
142
+ };
143
+ },
144
+ textBase: function textBase() {
145
+ return {
146
+ fontSize: '1rem'
147
+ };
148
+ },
149
+ textLg: function textLg() {
150
+ return {
151
+ fontSize: '1.125rem'
152
+ };
153
+ },
154
+ textXl: function textXl() {
155
+ return {
156
+ fontSize: '1.25rem'
157
+ };
158
+ },
159
+ text2xl: function text2xl() {
160
+ return {
161
+ fontSize: '1.5rem'
162
+ };
163
+ },
164
+ text3xl: function text3xl() {
165
+ return {
166
+ fontSize: '1.875rem'
167
+ };
168
+ }
169
+ };
170
+
171
+ // -- Static keywords (no numeric param) ----------------------------------
172
+ var STATICS = {
173
+ flex: {
174
+ display: 'flex'
175
+ },
176
+ flexCol: {
177
+ display: 'flex',
178
+ flexDirection: 'column'
179
+ },
180
+ flexRow: {
181
+ display: 'flex',
182
+ flexDirection: 'row'
183
+ },
184
+ flexWrap: {
185
+ display: 'flex',
186
+ flexWrap: 'wrap'
187
+ },
188
+ block: {
189
+ display: 'block'
190
+ },
191
+ inline: {
192
+ display: 'inline'
193
+ },
194
+ hidden: {
195
+ display: 'none'
196
+ },
197
+ bold: {
198
+ fontWeight: '700'
199
+ },
200
+ semibold: {
201
+ fontWeight: '600'
202
+ },
203
+ italic: {
204
+ fontStyle: 'italic'
205
+ },
206
+ textCenter: {
207
+ textAlign: 'center'
208
+ },
209
+ textRight: {
210
+ textAlign: 'right'
211
+ },
212
+ justifyCenter: {
213
+ justifyContent: 'center'
214
+ },
215
+ justifyBetween: {
216
+ justifyContent: 'space-between'
217
+ },
218
+ justifyEnd: {
219
+ justifyContent: 'flex-end'
220
+ },
221
+ alignCenter: {
222
+ alignItems: 'center'
223
+ },
224
+ alignStart: {
225
+ alignItems: 'flex-start'
226
+ },
227
+ alignEnd: {
228
+ alignItems: 'flex-end'
229
+ },
230
+ wFull: {
231
+ width: '100%'
232
+ },
233
+ hFull: {
234
+ height: '100%'
235
+ },
236
+ transition: {
237
+ transition: 'all 0.2s ease'
238
+ }
239
+ };
240
+
241
+ // -- Custom rules (added via u.extend) -----------------------------------
242
+ var _custom = {};
243
+
244
+ // -- Token parser --------------------------------------------------------
245
+ // Regex: split on whitespace
246
+ var _splitRe = /\s+/;
247
+
248
+ // Match parametric token: name + digits, e.g. "p4", "gap8", "rounded2"
249
+ var _paramRe = /^([a-zA-Z]+?)(\d+)$/;
250
+
251
+ // Match color rules: bg-<name>, text-<name>, bg-[#hex]
252
+ var _bgBracketRe = /^bg-\[([^\]]+)\]$/;
253
+ var _textBracketRe = /^text-\[([^\]]+)\]$/;
254
+ var _bgNameRe = /^bg-(.+)$/;
255
+ var _textNameRe = /^text-(.+)$/;
256
+
257
+ /**
258
+ * Parse a single token into a style object, or null if unknown.
259
+ */
260
+ function _parseToken(token) {
261
+ // 1. Custom rules first
262
+ if (_custom[token]) {
263
+ var val = _custom[token];
264
+ return typeof val === 'function' ? val(token) : val;
265
+ }
266
+
267
+ // 2. Static keywords
268
+ if (STATICS[token]) return STATICS[token];
269
+
270
+ // 3. Parametric rules (e.g. p4, gap8, mb2)
271
+ var pm = _paramRe.exec(token);
272
+ if (pm) {
273
+ var name = pm[1];
274
+ var num = parseInt(pm[2], 10);
275
+ if (PARAMETRIC[name]) return PARAMETRIC[name](num);
276
+ }
277
+
278
+ // 4. Non-numeric parametric (text sizes like textSm)
279
+ if (PARAMETRIC[token]) return PARAMETRIC[token]();
280
+
281
+ // 5. Color: bg-[#hex]
282
+ var bgBr = _bgBracketRe.exec(token);
283
+ if (bgBr) return {
284
+ background: bgBr[1]
285
+ };
286
+
287
+ // 6. Color: text-[#hex]
288
+ var textBr = _textBracketRe.exec(token);
289
+ if (textBr) return {
290
+ color: textBr[1]
291
+ };
292
+
293
+ // 7. Color: bg-<name>
294
+ var bgN = _bgNameRe.exec(token);
295
+ if (bgN) return {
296
+ background: bgN[1]
297
+ };
298
+
299
+ // 8. Color: text-<name>
300
+ var textN = _textNameRe.exec(token);
301
+ if (textN) return {
302
+ color: textN[1]
303
+ };
304
+
305
+ // Unknown → silently ignored
306
+ return null;
307
+ }
308
+
309
+ /**
310
+ * Parse a space-separated string of utility tokens into a merged style object.
311
+ *
312
+ * @param {string} str - Space-separated utility tokens
313
+ * @returns {Object} Merged style object
314
+ */
315
+ function u(str) {
316
+ if (!str || typeof str !== 'string') return {};
317
+ var tokens = str.trim().split(_splitRe);
318
+ var result = {};
319
+ for (var i = 0; i < tokens.length; i++) {
320
+ var style = _parseToken(tokens[i]);
321
+ if (style) {
322
+ var keys = Object.keys(style);
323
+ for (var j = 0; j < keys.length; j++) {
324
+ result[keys[j]] = style[keys[j]];
325
+ }
326
+ }
327
+ }
328
+ return result;
329
+ }
330
+
331
+ /**
332
+ * Parse tokens and return a CSS declaration string.
333
+ *
334
+ * @param {string} str - Space-separated utility tokens
335
+ * @returns {string} CSS declarations (e.g. "display:flex;gap:1rem")
336
+ */
337
+ u.css = function (str) {
338
+ var style = u(str);
339
+ var parts = [];
340
+ var keys = Object.keys(style);
341
+ for (var i = 0; i < keys.length; i++) {
342
+ // Convert camelCase to kebab-case
343
+ var prop = keys[i].replace(/([A-Z])/g, function (m) {
344
+ return '-' + m.toLowerCase();
345
+ });
346
+ parts.push(prop + ':' + style[keys[i]]);
347
+ }
348
+ return parts.join(';');
349
+ };
350
+
351
+ /**
352
+ * Parse tokens and return BEM-style class names (bw_ prefixed).
353
+ *
354
+ * @param {string} str - Space-separated utility tokens
355
+ * @returns {string} Space-separated class names
356
+ */
357
+ u.cls = function (str) {
358
+ if (!str || typeof str !== 'string') return '';
359
+ var tokens = str.trim().split(_splitRe);
360
+ var classes = [];
361
+ for (var i = 0; i < tokens.length; i++) {
362
+ var token = tokens[i];
363
+ // Only emit classes for recognized tokens
364
+ if (_parseToken(token)) {
365
+ // Convert camelCase to underscore, digits get underscore prefix
366
+ var cls = 'bw_' + token.replace(/([A-Z])/g, function (m) {
367
+ return '_' + m.toLowerCase();
368
+ }).replace(/(\d+)/g, function (m) {
369
+ return '_' + m;
370
+ });
371
+ classes.push(cls);
372
+ }
373
+ }
374
+ return classes.join(' ');
375
+ };
376
+
377
+ /**
378
+ * Register custom rules. Each key is a token name, value is either
379
+ * a style object or a function returning a style object.
380
+ *
381
+ * @param {Object} rules - Map of token → style object or function
382
+ */
383
+ u.extend = function (rules) {
384
+ if (!rules || _typeof(rules) !== 'object') return;
385
+ var keys = Object.keys(rules);
386
+ for (var i = 0; i < keys.length; i++) {
387
+ _custom[keys[i]] = rules[keys[i]];
388
+ }
389
+ };
390
+
391
+ // -- Plugin installation -------------------------------------------------
392
+ function install(bw) {
393
+ if (!bw) return;
394
+ bw.utilCSS = u;
395
+ bw.u = u;
396
+ }
397
+
398
+ // Auto-install if bw is on window (script tag usage)
399
+ if (typeof window !== 'undefined' && window.bw) {
400
+ install(window.bw);
401
+ }
402
+ var bitwrenchUtilCss = {
403
+ utilCSS: u,
404
+ install: install
405
+ };
406
+
407
+ exports.default = bitwrenchUtilCss;
408
+ exports.install = install;
409
+ exports.utilCSS = u;
410
+
411
+ Object.defineProperty(exports, '__esModule', { value: true });
412
+
413
+ }));
414
+ //# sourceMappingURL=bitwrench-util-css.es5.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";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}
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 e(t){return.25*t+"rem"}var r={p:function(t){return{padding:e(t)}},pt:function(t){return{paddingTop:e(t)}},pb:function(t){return{paddingBottom:e(t)}},pl:function(t){return{paddingLeft:e(t)}},pr:function(t){return{paddingRight:e(t)}},px:function(t){return{paddingLeft:e(t),paddingRight:e(t)}},py:function(t){return{paddingTop:e(t),paddingBottom:e(t)}},m:function(t){return{margin:e(t)}},mt:function(t){return{marginTop:e(t)}},mb:function(t){return{marginBottom:e(t)}},ml:function(t){return{marginLeft:e(t)}},mr:function(t){return{marginRight:e(t)}},mx:function(t){return{marginLeft:e(t),marginRight:e(t)}},my:function(t){return{marginTop:e(t),marginBottom:e(t)}},gap:function(t){return{gap:e(t)}},w:function(t){return{width:e(t)}},h:function(t){return{height:e(t)}},rounded:function(t){return{borderRadius:e(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"}}},i={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"}},o={},f=/\s+/,u=/^([a-zA-Z]+?)(\d+)$/,l=/^bg-\[([^\]]+)\]$/,a=/^text-\[([^\]]+)\]$/,c=/^bg-(.+)$/,d=/^text-(.+)$/;function p(t){if(o[t]){var n=o[t];return"function"==typeof n?n(t):n}if(i[t])return i[t];var e=u.exec(t);if(e){var f=e[1],p=parseInt(e[2],10);if(r[f])return r[f](p)}if(r[t])return r[t]();var s=l.exec(t);if(s)return{background:s[1]};var g=a.exec(t);if(g)return{color:g[1]};var m=c.exec(t);if(m)return{background:m[1]};var y=d.exec(t);return y?{color:y[1]}:null}function s(t){if(!t||"string"!=typeof t)return{};for(var n=t.trim().split(f),e={},r=0;r<n.length;r++){var i=p(n[r]);if(i)for(var o=Object.keys(i),u=0;u<o.length;u++)e[o[u]]=i[o[u]]}return e}function g(t){t&&(t.utilCSS=s,t.u=s)}s.css=function(t){for(var n=s(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(";")},s.cls=function(t){if(!t||"string"!=typeof t)return"";for(var n=t.trim().split(f),e=[],r=0;r<n.length;r++){var i=n[r];if(p(i)){var o="bw_"+i.replace(/([A-Z])/g,function(t){return"_"+t.toLowerCase()}).replace(/(\d+)/g,function(t){return"_"+t});e.push(o)}}return e.join(" ")},s.extend=function(t){if(t&&"object"===n(t))for(var e=Object.keys(t),r=0;r<e.length;r++)o[e[r]]=t[e[r]]},"undefined"!=typeof window&&window.bw&&g(window.bw);var m={utilCSS:s,install:g};t.default=m,t.install=g,t.utilCSS=s,Object.defineProperty(t,"__esModule",{value:!0})});
21
+ //# sourceMappingURL=bitwrench-util-css.es5.min.js.map