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 +4 -4
- package/dist/{chunk-CCFKX6NQ.js → chunk-6OVNVVEP.js} +1 -1
- package/dist/{chunk-Y6U2ERL3.js → chunk-J7ZV6AUQ.js} +2 -2
- package/dist/{chunk-LYWWAGNR.js → chunk-SWVHEM3S.js} +1 -1
- package/dist/cli.cjs +6 -4
- package/dist/cli.js +6 -4
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.js +2 -2
- package/dist/unplugin.cjs +2 -2
- package/dist/unplugin.js +2 -2
- package/dist/vite.cjs +2 -2
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +2 -2
- package/dist/webpack.js +2 -2
- package/package.json +1 -1
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 (
|
|
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 (
|
|
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
|
|
|
@@ -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
|
-
|
|
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;
|
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
|
-
|
|
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
|
|
202
|
+
const inputArgs = getArgs("--input");
|
|
203
|
+
const input = inputArgs.length > 0 ? inputArgs : config.input;
|
|
203
204
|
const output = getArg("--output") ?? config.output;
|
|
204
|
-
const
|
|
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-
|
|
5
|
-
import "./chunk-
|
|
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
|
|
57
|
+
const inputArgs = getArgs("--input");
|
|
58
|
+
const input = inputArgs.length > 0 ? inputArgs : config.input;
|
|
58
59
|
const output = getArg("--output") ?? config.output;
|
|
59
|
-
const
|
|
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
|
-
|
|
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
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
|
-
|
|
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-
|
|
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-
|
|
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
|
-
|
|
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
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
|
-
|
|
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
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
|
-
|
|
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
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
|
-
|
|
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