css-module-sync 1.0.1 → 1.0.3

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": "css-module-sync",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Auto sync css module classes with react components",
5
5
  "author": "Max Matinpalo",
6
6
  "type": "module",
package/src/css_parser.js CHANGED
@@ -2,7 +2,6 @@
2
2
  export function parse(input) {
3
3
  let i = 0;
4
4
  const n = input.length;
5
-
6
5
  const root = { type: "block", selector: null, children: [], comments: [] };
7
6
  let pending = [];
8
7
 
@@ -19,15 +18,21 @@ export function parse(input) {
19
18
  };
20
19
 
21
20
  const read_until = stops => {
22
- let out = "", q = null, esc = false;
21
+ let out = "", q = null, esc = false, cmt = false, p = 0;
23
22
  while (i < n) {
24
23
  const c = input[i];
25
24
  if (esc) { out += c; esc = false; i++; continue; }
26
25
  if (c === "\\") { out += c; esc = true; i++; continue; }
26
+ if (!cmt && !q && c === "/" && input[i + 1] === "*") { cmt = true; out += "/*"; i += 2; continue; }
27
+ if (cmt && c === "*" && input[i + 1] === "/") { cmt = false; out += "*/"; i += 2; continue; }
28
+ if (cmt) { out += c; i++; continue; }
27
29
  if (q) { if (c === q) q = null; out += c; i++; continue; }
28
30
  if (c === "'" || c === `"`) { q = c; out += c; i++; continue; }
29
- if (stops.includes(c)) break;
30
- out += c; i++;
31
+ if (c === "(") p++;
32
+ if (c === ")") if (p > 0) p--;
33
+ if (p === 0 && stops.includes(c)) break;
34
+ out += c;
35
+ i++;
31
36
  }
32
37
  return out;
33
38
  };
@@ -35,7 +40,7 @@ export function parse(input) {
35
40
  const parse_block = selector => {
36
41
  const node = { type: "block", selector, children: [], comments: pending };
37
42
  pending = [];
38
- i++; // skip '{'
43
+ i++;
39
44
  while (i < n) {
40
45
  skip_ws();
41
46
  const cmt = read_comment();
@@ -74,4 +79,4 @@ export function parse(input) {
74
79
 
75
80
  if (pending.length) root.comments = pending;
76
81
  return root;
77
- }
82
+ }
package/src/css_sync.js CHANGED
@@ -263,7 +263,7 @@ async function main() {
263
263
  console.warn(`[RENAME] Multiple orphan .module.css in ${dir}; skipping:\n` +
264
264
  orphans.map(p => `- ${path.basename(p)}`).join("\n"));
265
265
  }
266
- }, 150);
266
+ }, 50); // Decreased timeout to run before sync_file
267
267
  }
268
268
  }
269
269
 
@@ -273,7 +273,7 @@ async function main() {
273
273
  debouncers.delete(full_path);
274
274
  if (is_tsx) sync_file(full_path).catch(() => { });
275
275
  else if (FLAGS.sort) format_css_only(full_path).catch(() => { });
276
- }, 100));
276
+ }, 150)); // Increased timeout to run after rename
277
277
  });
278
278
  }
279
279
  }