tailwind-to-style 4.0.2 → 5.0.0

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/dist/core/tws.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v4.0.2
2
+ * tailwind-to-style v5.0.0
3
3
  * Zero-build runtime Tailwind CSS engine
4
4
  *
5
5
  * @author Bigetion
@@ -2026,6 +2026,60 @@ function generateCssString() {
2026
2026
  return cssString;
2027
2027
  }
2028
2028
 
2029
+ /**
2030
+ * Shared Constants
2031
+ *
2032
+ * All constant values used across the library.
2033
+ * Extracted from monolithic index.js for better maintainability.
2034
+ *
2035
+ * @module shared/constants
2036
+ */
2037
+
2038
+
2039
+ // ============================================================================
2040
+ // Regex Patterns
2041
+ // ============================================================================
2042
+
2043
+ /**
2044
+ * Class parsing (includes . for decimal values like p-0.5)
2045
+ */
2046
+ const CLASS_PARSER_REGEX = /[\w.\-\/]+(?:\/\d+)?(?:\[[^\]]+\])?/g;
2047
+
2048
+ /**
2049
+ * Opacity modifiers
2050
+ */
2051
+ const OPACITY_MODIFIER_REGEX = /\/(\d+)$/;
2052
+
2053
+ /**
2054
+ * Opacity property patterns for substitution
2055
+ */
2056
+ const OPACITY_PROP_REGEXES = {
2057
+ "--text-opacity": /--text-opacity\s*:\s*[\d.]+/gi,
2058
+ "--bg-opacity": /--bg-opacity\s*:\s*[\d.]+/gi,
2059
+ "--border-opacity": /--border-opacity\s*:\s*[\d.]+/gi,
2060
+ "--ring-opacity": /--ring-opacity\s*:\s*[\d.]+/gi,
2061
+ "--placeholder-opacity": /--placeholder-opacity\s*:\s*[\d.]+/gi,
2062
+ "--divide-opacity": /--divide-opacity\s*:\s*[\d.]+/gi
2063
+ };
2064
+
2065
+ /**
2066
+ * CSS variable resolution — supports nested parens in fallback (e.g. rgba(...))
2067
+ */
2068
+ const CSS_VAR_REGEX = /var\((--[\w-]+)(?:,\s*((?:[^()]+|\([^()]*\))*))?\)/g;
2069
+ const CAMEL_CASE_REGEX = /-([a-z])/g;
2070
+
2071
+ /**
2072
+ * String splitting (CSS declarations)
2073
+ */
2074
+ const CSS_SEMICOLON_SPLIT_REGEX = /;/;
2075
+ const CSS_COLON_SPLIT_REGEX = /:/;
2076
+
2077
+ /**
2078
+ * Color property regex patterns (pre-compiled for each color property)
2079
+ * Used in processOpacityModifier for 50-100x performance improvement
2080
+ */
2081
+ const COLOR_PROPERTIES$1 = ["color", "background-color", "border-color", "border-top-color", "border-right-color", "border-bottom-color", "border-left-color"];
2082
+
2029
2083
  /**
2030
2084
  * Proper LRU (Least Recently Used) Cache implementation
2031
2085
  * Efficiently manages memory by removing least recently used items
@@ -2097,6 +2151,250 @@ class LRUCache {
2097
2151
  }
2098
2152
  }
2099
2153
 
2154
+ /**
2155
+ * Opacity Modifier Processing
2156
+ *
2157
+ * Handles Tailwind opacity modifiers (e.g., bg-blue-500/50).
2158
+ * Converts color values to rgba/hsla with specified opacity.
2159
+ *
2160
+ * @module generator/opacity
2161
+ */
2162
+
2163
+
2164
+ // Pre-compile regex patterns for each color property
2165
+ const COLOR_REGEX_PATTERNS$1 = new Map();
2166
+ for (const prop of COLOR_PROPERTIES$1) {
2167
+ const escapedProp = prop.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2168
+ COLOR_REGEX_PATTERNS$1.set(prop, {
2169
+ rgb: new RegExp("(".concat(escapedProp, "\\s*:\\s*)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)"), "gi"),
2170
+ rgba: new RegExp("(".concat(escapedProp, "\\s*:\\s*)rgba\\((\\d+),\\s*(\\d+),\\s*(\\d+),\\s*[\\d.]+\\)"), "gi"),
2171
+ hsl: new RegExp("(".concat(escapedProp, "\\s*:\\s*)hsl\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%)\\)"), "gi"),
2172
+ hsla: new RegExp("(".concat(escapedProp, "\\s*:\\s*)hsla\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%),\\s*[\\d.]+\\)"), "gi"),
2173
+ hex: new RegExp("(".concat(escapedProp, "\\s*:\\s*)(#[0-9a-fA-F]{3,6})"), "gi")
2174
+ });
2175
+ }
2176
+
2177
+ /**
2178
+ * Process opacity modifiers in Tailwind classes.
2179
+ *
2180
+ * Handles:
2181
+ * - Tailwind CSS custom properties (--text-opacity, --bg-opacity, etc.)
2182
+ * - Direct color values (rgb, rgba, hsl, hsla, hex)
2183
+ * - Converts colors to rgba/hsla with specified opacity
2184
+ *
2185
+ * @param {string} className - Tailwind class name (e.g., 'bg-blue-500/50')
2186
+ * @param {string} cssDeclaration - CSS declaration to modify
2187
+ * @returns {string} Modified CSS declaration with opacity applied
2188
+ *
2189
+ * @example
2190
+ * processOpacityModifier('bg-blue-500/50', 'background-color: rgb(59, 130, 246);')
2191
+ * // → 'background-color: rgba(59, 130, 246, 0.5);'
2192
+ *
2193
+ * @example
2194
+ * processOpacityModifier('text-red-600/75', 'color: #dc2626;')
2195
+ * // → 'color: rgba(220, 38, 38, 0.75);'
2196
+ *
2197
+ * @example
2198
+ * processOpacityModifier('bg-blue-500', 'background-color: rgb(59, 130, 246);')
2199
+ * // → 'background-color: rgb(59, 130, 246);' (no change - no opacity modifier)
2200
+ */
2201
+ function processOpacityModifier(className, cssDeclaration) {
2202
+ const opacityMatch = OPACITY_MODIFIER_REGEX.exec(className);
2203
+ if (!opacityMatch) return cssDeclaration;
2204
+ const opacityValue = parseInt(opacityMatch[1], 10);
2205
+ if (opacityValue < 0 || opacityValue > 100) return cssDeclaration;
2206
+ const alphaValue = (opacityValue / 100).toString();
2207
+
2208
+ // Handle Tailwind's CSS custom property pattern
2209
+ let modifiedDeclaration = cssDeclaration;
2210
+
2211
+ // Replace opacity custom properties using pre-compiled regexes
2212
+ for (const prop in OPACITY_PROP_REGEXES) {
2213
+ const regex = OPACITY_PROP_REGEXES[prop];
2214
+ regex.lastIndex = 0; // Reset global regex
2215
+ modifiedDeclaration = modifiedDeclaration.replace(regex, "".concat(prop, ": ").concat(alphaValue));
2216
+ }
2217
+
2218
+ // Also handle direct color values using pre-compiled regex patterns
2219
+ for (const prop of COLOR_PROPERTIES$1) {
2220
+ const patterns = COLOR_REGEX_PATTERNS$1.get(prop);
2221
+ if (!patterns) continue;
2222
+
2223
+ // Reset all regex lastIndex for reuse
2224
+ patterns.rgb.lastIndex = 0;
2225
+ patterns.rgba.lastIndex = 0;
2226
+ patterns.hsl.lastIndex = 0;
2227
+ patterns.hsla.lastIndex = 0;
2228
+ patterns.hex.lastIndex = 0;
2229
+
2230
+ // Convert rgb to rgba with opacity
2231
+ modifiedDeclaration = modifiedDeclaration.replace(patterns.rgb, "$1rgba($2, $3, $4, ".concat(alphaValue, ")"));
2232
+
2233
+ // Update existing rgba opacity
2234
+ modifiedDeclaration = modifiedDeclaration.replace(patterns.rgba, "$1rgba($2, $3, $4, ".concat(alphaValue, ")"));
2235
+
2236
+ // Convert hsl to hsla with opacity
2237
+ modifiedDeclaration = modifiedDeclaration.replace(patterns.hsl, "$1hsla($2, $3, $4, ".concat(alphaValue, ")"));
2238
+
2239
+ // Update existing hsla opacity
2240
+ modifiedDeclaration = modifiedDeclaration.replace(patterns.hsla, "$1hsla($2, $3, $4, ".concat(alphaValue, ")"));
2241
+
2242
+ // Handle hex colors - convert to rgba
2243
+ modifiedDeclaration = modifiedDeclaration.replace(patterns.hex, (match, propPart, hexColor) => {
2244
+ // Convert hex to rgba
2245
+ const hex = hexColor.replace("#", "");
2246
+ let r, g, b;
2247
+ if (hex.length === 3) {
2248
+ r = parseInt(hex[0] + hex[0], 16);
2249
+ g = parseInt(hex[1] + hex[1], 16);
2250
+ b = parseInt(hex[2] + hex[2], 16);
2251
+ } else {
2252
+ r = parseInt(hex.substring(0, 2), 16);
2253
+ g = parseInt(hex.substring(2, 4), 16);
2254
+ b = parseInt(hex.substring(4, 6), 16);
2255
+ }
2256
+ return "".concat(propPart, "rgba(").concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(alphaValue, ")");
2257
+ });
2258
+ }
2259
+ return modifiedDeclaration;
2260
+ }
2261
+
2262
+ /**
2263
+ * CSS String Generation & Resolution
2264
+ *
2265
+ * Utilities for generating and resolving CSS strings.
2266
+ * Handles CSS variable resolution and inline style conversion.
2267
+ *
2268
+ * @module generator/css-string
2269
+ */
2270
+
2271
+
2272
+ /**
2273
+ * Resolve CSS variables in a CSS string to their actual values.
2274
+ *
2275
+ * Extracts CSS custom properties (--var-name) and replaces var() references
2276
+ * with their actual values. Preserves CSS variables in output for later resolution.
2277
+ *
2278
+ * @param {string} cssString - CSS string with possible var() references
2279
+ * @returns {string} CSS string with resolved variables
2280
+ *
2281
+ * @example
2282
+ * resolveCssToClearCss('--text-opacity: 1; color: var(--text-opacity);')
2283
+ * // → '--text-opacity: 1; color: 1;'
2284
+ *
2285
+ * @example
2286
+ * resolveCssToClearCss('background: rgb(59,130,246); color: white;')
2287
+ * // → 'background: rgb(59,130,246); color: white;'
2288
+ */
2289
+ function resolveCssToClearCss(cssString) {
2290
+ const customVars = {};
2291
+ const props = {};
2292
+
2293
+ // Split by semicolon and process declarations
2294
+ const declarations = cssString.split(CSS_SEMICOLON_SPLIT_REGEX);
2295
+ for (let i = 0; i < declarations.length; i++) {
2296
+ const decl = declarations[i];
2297
+ if (!decl) continue;
2298
+ const colonIndex = decl.indexOf(":");
2299
+ if (colonIndex === -1) continue;
2300
+ const key = decl.substring(0, colonIndex).trim();
2301
+ const value = decl.substring(colonIndex + 1).trim();
2302
+ if (!key || !value) continue;
2303
+ if (key.startsWith("--")) {
2304
+ customVars[key] = value;
2305
+ } else {
2306
+ props[key] = value;
2307
+ }
2308
+ }
2309
+
2310
+ // Replace var(--foo) in all values using pre-compiled regex
2311
+ const propKeys = Object.keys(props);
2312
+ for (let i = 0; i < propKeys.length; i++) {
2313
+ const key = propKeys[i];
2314
+ let val = props[key];
2315
+ if (val.includes("var(")) {
2316
+ CSS_VAR_REGEX.lastIndex = 0;
2317
+ val = val.replace(CSS_VAR_REGEX, (m, varName) => customVars[varName] !== undefined ? customVars[varName] : m);
2318
+ props[key] = val;
2319
+ }
2320
+ }
2321
+
2322
+ // Build CSS string - INCLUDE CSS variables so they can be resolved later
2323
+ let result = "";
2324
+ const varKeys = Object.keys(customVars);
2325
+ for (let i = 0; i < varKeys.length; i++) {
2326
+ const key = varKeys[i];
2327
+ result += "".concat(key, ": ").concat(customVars[key], "; ");
2328
+ }
2329
+ for (let i = 0; i < propKeys.length; i++) {
2330
+ const key = propKeys[i];
2331
+ result += "".concat(key, ": ").concat(props[key], "; ");
2332
+ }
2333
+ return result.trim();
2334
+ }
2335
+
2336
+ /**
2337
+ * Convert inline CSS style string to JSON object.
2338
+ *
2339
+ * Converts kebab-case CSS properties to camelCase for React/JS compatibility.
2340
+ * Resolves CSS variables (var()) to their actual values.
2341
+ *
2342
+ * @param {string} styleString - CSS style string
2343
+ * @returns {Object} Style object with camelCase keys
2344
+ *
2345
+ * @example
2346
+ * inlineStyleToJson('background-color: blue; font-size: 16px;')
2347
+ * // → { backgroundColor: 'blue', fontSize: '16px' }
2348
+ *
2349
+ * @example
2350
+ * inlineStyleToJson('--text-color: red; color: var(--text-color);')
2351
+ * // → { color: 'red' }
2352
+ */
2353
+ function inlineStyleToJson(styleString) {
2354
+ const styles = styleString.split(CSS_SEMICOLON_SPLIT_REGEX).filter(style => style.trim() !== "");
2355
+ const styleObject = {};
2356
+ const cssVariables = {};
2357
+
2358
+ // First pass: collect CSS variables
2359
+ for (let i = 0; i < styles.length; i++) {
2360
+ const parts = styles[i].split(CSS_COLON_SPLIT_REGEX, 2);
2361
+ if (parts.length !== 2) continue;
2362
+ const key = parts[0].trim();
2363
+ const value = parts[1].trim();
2364
+ if (key && key.startsWith("--")) {
2365
+ cssVariables[key] = value;
2366
+ }
2367
+ }
2368
+
2369
+ // Helper to resolve CSS variables recursively
2370
+ const resolveVariables = value => {
2371
+ if (!value || !value.includes("var(")) return value;
2372
+ let resolved = value;
2373
+ let maxIterations = 10; // Prevent infinite loops
2374
+
2375
+ while (resolved.includes("var(") && maxIterations-- > 0) {
2376
+ CSS_VAR_REGEX.lastIndex = 0; // Reset global regex
2377
+ resolved = resolved.replace(CSS_VAR_REGEX, (match, variable, fallback) => {
2378
+ return cssVariables[variable] || fallback || match;
2379
+ });
2380
+ }
2381
+ return resolved;
2382
+ };
2383
+
2384
+ // Second pass: create style object with resolved values
2385
+ for (let i = 0; i < styles.length; i++) {
2386
+ const parts = styles[i].split(CSS_COLON_SPLIT_REGEX, 2);
2387
+ if (parts.length !== 2) continue;
2388
+ const key = parts[0].trim();
2389
+ const value = parts[1].trim();
2390
+ if (key && value && !key.startsWith("--")) {
2391
+ const camelCaseKey = key.replace(CAMEL_CASE_REGEX, (_, letter) => letter.toUpperCase());
2392
+ styleObject[camelCaseKey] = resolveVariables(value);
2393
+ }
2394
+ }
2395
+ return styleObject;
2396
+ }
2397
+
2100
2398
  function generator$2S() {
2101
2399
  let configOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2102
2400
  const globalPrefix = configOptions.prefix,
@@ -5718,47 +6016,15 @@ function pluginToLookup(plugin) {
5718
6016
  return lookup;
5719
6017
  }
5720
6018
 
5721
- // ============================================================================
5722
- // PRE-COMPILED REGEX CONSTANTS (Performance Optimization)
5723
- // Pre-compiling regex patterns provides 50-100x performance improvement
5724
- // by avoiding repeated regex object creation in hot code paths
5725
- // ============================================================================
5726
-
5727
- // Class parsing (includes . for decimal values like p-0.5)
5728
- const CLASS_PARSER_REGEX = /[\w.\-\/]+(?:\/\d+)?(?:\[[^\]]+\])?/g;
5729
-
5730
- // Opacity modifiers
5731
- const OPACITY_MODIFIER_REGEX = /\/(\d+)$/;
5732
- const OPACITY_PROP_REGEXES = {
5733
- "--text-opacity": /--text-opacity\s*:\s*[\d.]+/gi,
5734
- "--bg-opacity": /--bg-opacity\s*:\s*[\d.]+/gi,
5735
- "--border-opacity": /--border-opacity\s*:\s*[\d.]+/gi,
5736
- "--ring-opacity": /--ring-opacity\s*:\s*[\d.]+/gi,
5737
- "--divide-opacity": /--divide-opacity\s*:\s*[\d.]+/gi,
5738
- "--placeholder-opacity": /--placeholder-opacity\s*:\s*[\d.]+/gi,
5739
- "--text-decoration-opacity": /--text-decoration-opacity\s*:\s*[\d.]+/gi,
5740
- "--outline-opacity": /--outline-opacity\s*:\s*[\d.]+/gi,
5741
- "--accent-opacity": /--accent-opacity\s*:\s*[\d.]+/gi,
5742
- "--caret-opacity": /--caret-opacity\s*:\s*[\d.]+/gi
5743
- };
5744
-
5745
6019
  // CSS parsing
5746
6020
  const CSS_CLASS_REGEX = /([a-zA-Z0-9\-_\\/.]+)\s*{\s*([^}]+)\s*}/g;
5747
6021
  const DOUBLE_BACKSLASH_REGEX = /\\\\/g;
5748
6022
  const LEADING_UNDERSCORE_REGEX = /^_/;
5749
6023
  const MULTIPLE_SPACES_REGEX = /\s+/g;
5750
6024
 
5751
- // CSS variable resolution — supports nested parens in fallback (e.g. rgba(...))
5752
- const CSS_VAR_REGEX = /var\((--[\w-]+)(?:,\s*((?:[^()]+|\([^()]*\))*))?\)/g;
5753
- const CAMEL_CASE_REGEX = /-([a-z])/g;
5754
-
5755
6025
  // Custom class detection
5756
6026
  const CUSTOM_VALUE_BRACKET_REGEX = /\[([^\]]+)\]/;
5757
6027
 
5758
- // String splitting (CSS declarations)
5759
- const CSS_SEMICOLON_SPLIT_REGEX = /;/;
5760
- const CSS_COLON_SPLIT_REGEX = /:/;
5761
-
5762
6028
  // Color property regex patterns (pre-compiled for each color property)
5763
6029
  // Used in processOpacityModifier for 50-100x performance improvement
5764
6030
  const COLOR_PROPERTIES = ["color", "background-color", "border-color", "text-decoration-color", "outline-color", "fill", "stroke", "caret-color", "accent-color"];
@@ -5967,52 +6233,7 @@ const plugins = {
5967
6233
  * @param {string} cssString
5968
6234
  * @returns {string} e.g. 'color: rgba(255,255,255,1); background: #fff;'
5969
6235
  */
5970
- function resolveCssToClearCss(cssString) {
5971
- const customVars = {};
5972
- const props = {};
5973
-
5974
- // Split by semicolon and process declarations
5975
- const declarations = cssString.split(CSS_SEMICOLON_SPLIT_REGEX);
5976
- for (let i = 0; i < declarations.length; i++) {
5977
- const decl = declarations[i];
5978
- if (!decl) continue;
5979
- const colonIndex = decl.indexOf(":");
5980
- if (colonIndex === -1) continue;
5981
- const key = decl.substring(0, colonIndex).trim();
5982
- const value = decl.substring(colonIndex + 1).trim();
5983
- if (!key || !value) continue;
5984
- if (key.startsWith("--")) {
5985
- customVars[key] = value;
5986
- } else {
5987
- props[key] = value;
5988
- }
5989
- }
5990
-
5991
- // Replace var(--foo) in all values using pre-compiled regex
5992
- const propKeys = Object.keys(props);
5993
- for (let i = 0; i < propKeys.length; i++) {
5994
- const key = propKeys[i];
5995
- let val = props[key];
5996
- if (val.includes("var(")) {
5997
- CSS_VAR_REGEX.lastIndex = 0;
5998
- val = val.replace(CSS_VAR_REGEX, (m, varName) => customVars[varName] !== undefined ? customVars[varName] : m);
5999
- props[key] = val;
6000
- }
6001
- }
6002
-
6003
- // Build CSS string - INCLUDE CSS variables so they can be resolved later
6004
- let result = "";
6005
- const varKeys = Object.keys(customVars);
6006
- for (let i = 0; i < varKeys.length; i++) {
6007
- const key = varKeys[i];
6008
- result += "".concat(key, ": ").concat(customVars[key], "; ");
6009
- }
6010
- for (let i = 0; i < propKeys.length; i++) {
6011
- const key = propKeys[i];
6012
- result += "".concat(key, ": ").concat(props[key], "; ");
6013
- }
6014
- return result.trim();
6015
- }
6236
+ // NOTE: resolveCssToClearCss now imported from ./generator/css-string.js
6016
6237
 
6017
6238
  // Cache for getConfigOptions - use LRU cache
6018
6239
  const configOptionsCache = new LRUCache(500);
@@ -6081,50 +6302,8 @@ function convertCssToObject(cssString) {
6081
6302
  const tailwindCache = getTailwindCache();
6082
6303
  const fractionDenominators = [2, 3, 4, 5, 6, 12];
6083
6304
  const fractionPrefixes = ["w-", "h-", "max-w-", "max-h-", "min-w-", "min-h-", "top-", "bottom-", "left-", "right-", "inset-", "inset-x-", "inset-y-", "translate-x-", "translate-y-", "rounded-t-", "rounded-b-", "rounded-l-", "rounded-r-", "rounded-bl-", "rounded-br-", "rounded-tl-", "rounded-tr-", "flex-basis-", "z-"];
6084
- function inlineStyleToJson(styleString) {
6085
- const styles = styleString.split(CSS_SEMICOLON_SPLIT_REGEX).filter(style => style.trim() !== "");
6086
- const styleObject = {};
6087
- const cssVariables = {};
6088
-
6089
- // First pass: collect CSS variables
6090
- for (let i = 0; i < styles.length; i++) {
6091
- const parts = styles[i].split(CSS_COLON_SPLIT_REGEX, 2);
6092
- if (parts.length !== 2) continue;
6093
- const key = parts[0].trim();
6094
- const value = parts[1].trim();
6095
- if (key && key.startsWith("--")) {
6096
- cssVariables[key] = value;
6097
- }
6098
- }
6099
6305
 
6100
- // Helper to resolve CSS variables recursively
6101
- const resolveVariables = value => {
6102
- if (!value || !value.includes("var(")) return value;
6103
- let resolved = value;
6104
- let maxIterations = 10; // Prevent infinite loops
6105
-
6106
- while (resolved.includes("var(") && maxIterations-- > 0) {
6107
- CSS_VAR_REGEX.lastIndex = 0; // Reset global regex
6108
- resolved = resolved.replace(CSS_VAR_REGEX, (match, variable, fallback) => {
6109
- return cssVariables[variable] || fallback || match;
6110
- });
6111
- }
6112
- return resolved;
6113
- };
6114
-
6115
- // Second pass: create style object with resolved values
6116
- for (let i = 0; i < styles.length; i++) {
6117
- const parts = styles[i].split(CSS_COLON_SPLIT_REGEX, 2);
6118
- if (parts.length !== 2) continue;
6119
- const key = parts[0].trim();
6120
- const value = parts[1].trim();
6121
- if (key && value && !key.startsWith("--")) {
6122
- const camelCaseKey = key.replace(CAMEL_CASE_REGEX, (_, letter) => letter.toUpperCase());
6123
- styleObject[camelCaseKey] = resolveVariables(value);
6124
- }
6125
- }
6126
- return styleObject;
6127
- }
6306
+ // NOTE: inlineStyleToJson now imported from ./generator/css-string.js
6128
6307
 
6129
6308
  // Cache for CSS resolution
6130
6309
  const cssResolutionCache = new LRUCache(1000);
@@ -6298,66 +6477,7 @@ function separateAndResolveCSS(arr) {
6298
6477
  * @param {string} cssDeclaration - CSS declaration to modify
6299
6478
  * @returns {string} Modified CSS declaration with opacity applied
6300
6479
  */
6301
- function processOpacityModifier(className, cssDeclaration) {
6302
- const opacityMatch = OPACITY_MODIFIER_REGEX.exec(className);
6303
- if (!opacityMatch) return cssDeclaration;
6304
- const opacityValue = parseInt(opacityMatch[1], 10);
6305
- if (opacityValue < 0 || opacityValue > 100) return cssDeclaration;
6306
- const alphaValue = (opacityValue / 100).toString();
6307
-
6308
- // Handle Tailwind's CSS custom property pattern
6309
- let modifiedDeclaration = cssDeclaration;
6310
-
6311
- // Replace opacity custom properties using pre-compiled regexes
6312
- for (const prop in OPACITY_PROP_REGEXES) {
6313
- const regex = OPACITY_PROP_REGEXES[prop];
6314
- regex.lastIndex = 0; // Reset global regex
6315
- modifiedDeclaration = modifiedDeclaration.replace(regex, "".concat(prop, ": ").concat(alphaValue));
6316
- }
6317
-
6318
- // Also handle direct color values using pre-compiled regex patterns
6319
- for (const prop of COLOR_PROPERTIES) {
6320
- const patterns = COLOR_REGEX_PATTERNS.get(prop);
6321
- if (!patterns) continue;
6322
-
6323
- // Reset all regex lastIndex for reuse
6324
- patterns.rgb.lastIndex = 0;
6325
- patterns.rgba.lastIndex = 0;
6326
- patterns.hsl.lastIndex = 0;
6327
- patterns.hsla.lastIndex = 0;
6328
- patterns.hex.lastIndex = 0;
6329
-
6330
- // Convert rgb to rgba with opacity
6331
- modifiedDeclaration = modifiedDeclaration.replace(patterns.rgb, "$1rgba($2, $3, $4, ".concat(alphaValue, ")"));
6332
-
6333
- // Update existing rgba opacity
6334
- modifiedDeclaration = modifiedDeclaration.replace(patterns.rgba, "$1rgba($2, $3, $4, ".concat(alphaValue, ")"));
6335
-
6336
- // Convert hsl to hsla with opacity
6337
- modifiedDeclaration = modifiedDeclaration.replace(patterns.hsl, "$1hsla($2, $3, $4, ".concat(alphaValue, ")"));
6338
-
6339
- // Update existing hsla opacity
6340
- modifiedDeclaration = modifiedDeclaration.replace(patterns.hsla, "$1hsla($2, $3, $4, ".concat(alphaValue, ")"));
6341
-
6342
- // Handle hex colors - convert to rgba
6343
- modifiedDeclaration = modifiedDeclaration.replace(patterns.hex, (match, propPart, hexColor) => {
6344
- // Convert hex to rgba
6345
- const hex = hexColor.replace("#", "");
6346
- let r, g, b;
6347
- if (hex.length === 3) {
6348
- r = parseInt(hex[0] + hex[0], 16);
6349
- g = parseInt(hex[1] + hex[1], 16);
6350
- b = parseInt(hex[2] + hex[2], 16);
6351
- } else {
6352
- r = parseInt(hex.substring(0, 2), 16);
6353
- g = parseInt(hex.substring(2, 4), 16);
6354
- b = parseInt(hex.substring(4, 6), 16);
6355
- }
6356
- return "".concat(propPart, "rgba(").concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(alphaValue, ")");
6357
- });
6358
- }
6359
- return modifiedDeclaration;
6360
- }
6480
+ // NOTE: processOpacityModifier now imported from ./generator/opacity.js
6361
6481
 
6362
6482
  /**
6363
6483
  * Convert Tailwind class string to inline CSS styles or JSON object
@@ -6491,6 +6611,17 @@ const performanceMonitor = {
6491
6611
  }
6492
6612
  };
6493
6613
 
6614
+ // NOTE: getCssHash now imported from ./shared/hash.js
6615
+ // NOTE: injectedCssHashSet now imported from ./shared/cache.js
6616
+ // NOTE: _cssBlockRegistry now imported from ./shared/cache.js (as cssBlockRegistry)
6617
+
6618
+ /**
6619
+ * Rebuild the single twsx style tag from the full CSS block registry.
6620
+ * Called whenever a block is added or updated.
6621
+ */
6622
+ // NOTE: rebuildStyleTag now imported from ./injector/dom.js
6623
+ // NOTE: autoInjectCss now imported from ./injector/dom.js
6624
+
6494
6625
  // Enhanced debounced functions with performance monitoring configuration
6495
6626
  /**
6496
6627
  * Debounced version of tws function with performance monitoring
@@ -6500,5 +6631,14 @@ const performanceMonitor = {
6500
6631
  */
6501
6632
  const debouncedTws = debounce(tws, 50); // Faster debounce for tws
6502
6633
 
6634
+ // ============================================================================
6635
+ // Main API Exports
6636
+ // ============================================================================
6637
+ // twsxClassName - Unified CSS-in-JS API with variants and slots
6638
+ // tw - Atomic CSS class generator with pseudo-class support
6639
+ // REMOVED: Re-export removed to break circular dependency
6640
+ // Import directly from './className/index.js' if needed
6641
+ // export { twsxClassName, tw } from "./className/index.js";
6642
+
6503
6643
  exports.debouncedTws = debouncedTws;
6504
6644
  exports.tws = tws;