dolphincss 1.2.9 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dolphincss",
3
- "version": "1.2.9",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "DolphinCSS - World-class TailwindCSS + React component library",
6
6
  "main": "dolphin-css.css",
package/vite-plugin.js CHANGED
@@ -27,14 +27,16 @@ export default function dolphincssPlugin() {
27
27
  let newOriginalCode = originalCode;
28
28
 
29
29
  for (const [marker, replacement] of Object.entries(components)) {
30
- // Regex matches <div className="marker"></div> with optional spaces/newlines inside, or self-closing <div className="marker" />
30
+ // Regex to match <div className="marker"></div> with any spacing/newlines inside
31
+ // Using [\"'] instead of capture groups to simplify and avoid backreference issues
31
32
  const regex = new RegExp(
32
- `<div\\s+class(?:Name)?=(["'])${marker}\\1\\s*>\\s*</div>|<div\\s+class(?:Name)?=(["'])${marker}\\2\\s*/>`,
33
+ `<div\\s+class(?:Name)?=[\"']${marker}[\"']\\s*>\\s*</div>|<div\\s+class(?:Name)?=[\"']${marker}[\"']\\s*/>`,
33
34
  'g'
34
35
  );
35
36
 
36
37
  if (regex.test(newOriginalCode)) {
37
- newOriginalCode = newOriginalCode.replace(regex, replacement);
38
+ // IMPORTANT: Use () => replacement to avoid $1, $2 substitution from things like $120.50
39
+ newOriginalCode = newOriginalCode.replace(regex, () => replacement);
38
40
  modified = true;
39
41
  console.log(`\n✨ DolphinCSS: Injected '${marker}' into ${path.basename(id)}`);
40
42
  }
@@ -54,11 +56,11 @@ export default function dolphincssPlugin() {
54
56
  let newCode = code;
55
57
  for (const [marker, replacement] of Object.entries(components)) {
56
58
  const regex = new RegExp(
57
- `<div\\s+class(?:Name)?=(["'])${marker}\\1\\s*>\\s*</div>|<div\\s+class(?:Name)?=(["'])${marker}\\2\\s*/>`,
59
+ `<div\\s+class(?:Name)?=[\"']${marker}[\"']\\s*>\\s*</div>|<div\\s+class(?:Name)?=[\"']${marker}[\"']\\s*/>`,
58
60
  'g'
59
61
  );
60
62
  if (regex.test(newCode)) {
61
- newCode = newCode.replace(regex, replacement);
63
+ newCode = newCode.replace(regex, () => replacement);
62
64
  }
63
65
  }
64
66