css-typed-vars 0.4.3 → 0.4.5

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/README.md CHANGED
@@ -114,17 +114,17 @@ npx css-typed-vars --input "src/styles/**/*.{css,scss}" --output src/cssVars.ts
114
114
  npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --exclude "**/vendor/**"
115
115
  npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --prefix theme --naming snake
116
116
  npx css-typed-vars --input "src/**/*.css" --output src/cssVars.js # generates .js + .d.ts
117
- npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --selector ".dark"
117
+ npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --selector ".dark" --selector "[data-theme='dark']"
118
118
  ```
119
119
 
120
120
  | Flag | Description |
121
121
  |------|-------------|
122
- | `--input` | Glob pattern for CSS/SCSS/Less files |
122
+ | `--input` | Glob pattern for CSS/SCSS/Less files (repeatable: `--input "src/**/*.css" --input "lib/**/*.css"`) |
123
123
  | `--output` | Output file. `.ts` → TypeScript, `.js` → JavaScript + `.d.ts` alongside |
124
- | `--exclude` | Glob pattern for files to exclude (single value; use config file for multiple) |
124
+ | `--exclude` | Glob pattern for files to exclude (repeatable: `--exclude "**/a/**" --exclude "**/b/**"`) |
125
125
  | `--prefix` | Prefix for generated keys: `--prefix theme` → `themeColorPrimary` |
126
126
  | `--naming` | Key naming: `camelCase` (default), `snake`, `kebab` |
127
- | `--selector` | Extra CSS selector to scan for variables (single value; use config file for multiple) |
127
+ | `--selector` | Extra CSS selector to scan for variables (repeatable: `--selector ".dark" --selector "[data-theme='dark']"`) |
128
128
  | `--watch` | Watch for file changes and regenerate |
129
129
  | `--version`, `-v` | Print the version number and exit |
130
130
 
@@ -3,7 +3,7 @@ import {
3
3
  generateDeclaration,
4
4
  generateJs,
5
5
  scanVarNames
6
- } from "./chunk-Y6U2ERL3.js";
6
+ } from "./chunk-J7ZV6AUQ.js";
7
7
 
8
8
  // src/index.ts
9
9
  import { writeFile, mkdir } from "fs/promises";
@@ -46,9 +46,9 @@ async function scanVarNames(patterns, exclude, selectors) {
46
46
  // src/generator.ts
47
47
  function toKey(cssVarName, naming = "camelCase") {
48
48
  const stripped = cssVarName.replace(/^--/, "");
49
- if (naming === "snake") return stripped.replace(/-/g, "_");
50
49
  if (naming === "kebab") return stripped;
51
- return stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
50
+ const key = naming === "snake" ? stripped.replace(/-/g, "_") : stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
51
+ return /^\d/.test(key) ? `_${key}` : key;
52
52
  }
53
53
  function applyPrefix(key, prefix, naming = "camelCase") {
54
54
  if (!prefix) return key;
@@ -3,7 +3,7 @@ import {
3
3
  generateDeclaration,
4
4
  generateJs,
5
5
  scanVarNames
6
- } from "./chunk-Y6U2ERL3.js";
6
+ } from "./chunk-J7ZV6AUQ.js";
7
7
 
8
8
  // src/unplugin.ts
9
9
  import { createUnplugin } from "unplugin";
package/dist/cli.cjs CHANGED
@@ -80,9 +80,9 @@ async function scanVarNames(patterns, exclude, selectors) {
80
80
  // src/generator.ts
81
81
  function toKey(cssVarName, naming = "camelCase") {
82
82
  const stripped = cssVarName.replace(/^--/, "");
83
- if (naming === "snake") return stripped.replace(/-/g, "_");
84
83
  if (naming === "kebab") return stripped;
85
- return stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
84
+ const key = naming === "snake" ? stripped.replace(/-/g, "_") : stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
85
+ return /^\d/.test(key) ? `_${key}` : key;
86
86
  }
87
87
  function applyPrefix(key, prefix, naming = "camelCase") {
88
88
  if (!prefix) return key;
@@ -199,9 +199,11 @@ async function main() {
199
199
  process.exit(0);
200
200
  }
201
201
  const config = await loadConfig();
202
- const input = getArg("--input") ?? config.input;
202
+ const inputArgs = getArgs("--input");
203
+ const input = inputArgs.length > 0 ? inputArgs : config.input;
203
204
  const output = getArg("--output") ?? config.output;
204
- const exclude = getArg("--exclude") ?? config.exclude;
205
+ const excludeArgs = getArgs("--exclude");
206
+ const exclude = excludeArgs.length > 0 ? excludeArgs : config.exclude;
205
207
  const prefix = getArg("--prefix") ?? config.prefix;
206
208
  const naming = getArg("--naming") ?? config.naming;
207
209
  const selectorArgs = getArgs("--selector");
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  generate
4
- } from "./chunk-CCFKX6NQ.js";
5
- import "./chunk-Y6U2ERL3.js";
4
+ } from "./chunk-6OVNVVEP.js";
5
+ import "./chunk-J7ZV6AUQ.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import { readFile } from "fs/promises";
@@ -54,9 +54,11 @@ async function main() {
54
54
  process.exit(0);
55
55
  }
56
56
  const config = await loadConfig();
57
- const input = getArg("--input") ?? config.input;
57
+ const inputArgs = getArgs("--input");
58
+ const input = inputArgs.length > 0 ? inputArgs : config.input;
58
59
  const output = getArg("--output") ?? config.output;
59
- const exclude = getArg("--exclude") ?? config.exclude;
60
+ const excludeArgs = getArgs("--exclude");
61
+ const exclude = excludeArgs.length > 0 ? excludeArgs : config.exclude;
60
62
  const prefix = getArg("--prefix") ?? config.prefix;
61
63
  const naming = getArg("--naming") ?? config.naming;
62
64
  const selectorArgs = getArgs("--selector");
package/dist/esbuild.cjs CHANGED
@@ -82,9 +82,9 @@ async function scanVarNames(patterns, exclude, selectors) {
82
82
  // src/generator.ts
83
83
  function toKey(cssVarName, naming = "camelCase") {
84
84
  const stripped = cssVarName.replace(/^--/, "");
85
- if (naming === "snake") return stripped.replace(/-/g, "_");
86
85
  if (naming === "kebab") return stripped;
87
- return stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
86
+ const key = naming === "snake" ? stripped.replace(/-/g, "_") : stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
87
+ return /^\d/.test(key) ? `_${key}` : key;
88
88
  }
89
89
  function applyPrefix(key, prefix, naming = "camelCase") {
90
90
  if (!prefix) return key;
package/dist/esbuild.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-LYWWAGNR.js";
4
- import "./chunk-Y6U2ERL3.js";
3
+ } from "./chunk-SWVHEM3S.js";
4
+ import "./chunk-J7ZV6AUQ.js";
5
5
 
6
6
  // src/esbuild.ts
7
7
  var esbuild_default = unplugin_default.esbuild;
package/dist/index.cjs CHANGED
@@ -84,9 +84,9 @@ async function scanVarNames(patterns, exclude, selectors) {
84
84
  // src/generator.ts
85
85
  function toKey(cssVarName, naming = "camelCase") {
86
86
  const stripped = cssVarName.replace(/^--/, "");
87
- if (naming === "snake") return stripped.replace(/-/g, "_");
88
87
  if (naming === "kebab") return stripped;
89
- return stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
88
+ const key = naming === "snake" ? stripped.replace(/-/g, "_") : stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
89
+ return /^\d/.test(key) ? `_${key}` : key;
90
90
  }
91
91
  function applyPrefix(key, prefix, naming = "camelCase") {
92
92
  if (!prefix) return key;
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  generate
3
- } from "./chunk-CCFKX6NQ.js";
3
+ } from "./chunk-6OVNVVEP.js";
4
4
  import {
5
5
  generateCode,
6
6
  generateDeclaration,
7
7
  generateJs,
8
8
  parseVarNames,
9
9
  scanVarNames
10
- } from "./chunk-Y6U2ERL3.js";
10
+ } from "./chunk-J7ZV6AUQ.js";
11
11
  export {
12
12
  generate,
13
13
  generateCode,
package/dist/rollup.cjs CHANGED
@@ -82,9 +82,9 @@ async function scanVarNames(patterns, exclude, selectors) {
82
82
  // src/generator.ts
83
83
  function toKey(cssVarName, naming = "camelCase") {
84
84
  const stripped = cssVarName.replace(/^--/, "");
85
- if (naming === "snake") return stripped.replace(/-/g, "_");
86
85
  if (naming === "kebab") return stripped;
87
- return stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
86
+ const key = naming === "snake" ? stripped.replace(/-/g, "_") : stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
87
+ return /^\d/.test(key) ? `_${key}` : key;
88
88
  }
89
89
  function applyPrefix(key, prefix, naming = "camelCase") {
90
90
  if (!prefix) return key;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-LYWWAGNR.js";
4
- import "./chunk-Y6U2ERL3.js";
3
+ } from "./chunk-SWVHEM3S.js";
4
+ import "./chunk-J7ZV6AUQ.js";
5
5
 
6
6
  // src/rollup.ts
7
7
  var rollup_default = unplugin_default.rollup;
package/dist/unplugin.cjs CHANGED
@@ -80,9 +80,9 @@ async function scanVarNames(patterns, exclude, selectors) {
80
80
  // src/generator.ts
81
81
  function toKey(cssVarName, naming = "camelCase") {
82
82
  const stripped = cssVarName.replace(/^--/, "");
83
- if (naming === "snake") return stripped.replace(/-/g, "_");
84
83
  if (naming === "kebab") return stripped;
85
- return stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
84
+ const key = naming === "snake" ? stripped.replace(/-/g, "_") : stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
85
+ return /^\d/.test(key) ? `_${key}` : key;
86
86
  }
87
87
  function applyPrefix(key, prefix, naming = "camelCase") {
88
88
  if (!prefix) return key;
package/dist/unplugin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-LYWWAGNR.js";
4
- import "./chunk-Y6U2ERL3.js";
3
+ } from "./chunk-SWVHEM3S.js";
4
+ import "./chunk-J7ZV6AUQ.js";
5
5
  export {
6
6
  unplugin_default as default
7
7
  };
package/dist/vite.cjs CHANGED
@@ -82,9 +82,9 @@ async function scanVarNames(patterns, exclude, selectors) {
82
82
  // src/generator.ts
83
83
  function toKey(cssVarName, naming = "camelCase") {
84
84
  const stripped = cssVarName.replace(/^--/, "");
85
- if (naming === "snake") return stripped.replace(/-/g, "_");
86
85
  if (naming === "kebab") return stripped;
87
- return stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
86
+ const key = naming === "snake" ? stripped.replace(/-/g, "_") : stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
87
+ return /^\d/.test(key) ? `_${key}` : key;
88
88
  }
89
89
  function applyPrefix(key, prefix, naming = "camelCase") {
90
90
  if (!prefix) return key;
package/dist/vite.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-LYWWAGNR.js";
4
- import "./chunk-Y6U2ERL3.js";
3
+ } from "./chunk-SWVHEM3S.js";
4
+ import "./chunk-J7ZV6AUQ.js";
5
5
 
6
6
  // src/vite.ts
7
7
  var vite_default = unplugin_default.vite;
package/dist/webpack.cjs CHANGED
@@ -82,9 +82,9 @@ async function scanVarNames(patterns, exclude, selectors) {
82
82
  // src/generator.ts
83
83
  function toKey(cssVarName, naming = "camelCase") {
84
84
  const stripped = cssVarName.replace(/^--/, "");
85
- if (naming === "snake") return stripped.replace(/-/g, "_");
86
85
  if (naming === "kebab") return stripped;
87
- return stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
86
+ const key = naming === "snake" ? stripped.replace(/-/g, "_") : stripped.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
87
+ return /^\d/.test(key) ? `_${key}` : key;
88
88
  }
89
89
  function applyPrefix(key, prefix, naming = "camelCase") {
90
90
  if (!prefix) return key;
package/dist/webpack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-LYWWAGNR.js";
4
- import "./chunk-Y6U2ERL3.js";
3
+ } from "./chunk-SWVHEM3S.js";
4
+ import "./chunk-J7ZV6AUQ.js";
5
5
 
6
6
  // src/webpack.ts
7
7
  var webpack_default = unplugin_default.webpack;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-typed-vars",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Generate TypeScript typed constants from CSS custom properties",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",