css-typed-vars 0.4.7 → 0.4.8

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.
@@ -3,7 +3,7 @@ import {
3
3
  generateDeclaration,
4
4
  generateJs,
5
5
  scanVarNames
6
- } from "./chunk-J7ZV6AUQ.js";
6
+ } from "./chunk-MJEASOAN.js";
7
7
 
8
8
  // src/index.ts
9
9
  import { writeFile, mkdir } from "fs/promises";
@@ -47,7 +47,7 @@ async function scanVarNames(patterns, exclude, selectors) {
47
47
  function toKey(cssVarName, naming = "camelCase") {
48
48
  const stripped = cssVarName.replace(/^--/, "");
49
49
  if (naming === "kebab") return stripped;
50
- const key = naming === "snake" ? stripped.replace(/-/g, "_") : 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()).replace(/-/g, "");
51
51
  return /^\d/.test(key) ? `_${key}` : key;
52
52
  }
53
53
  function applyPrefix(key, prefix, naming = "camelCase") {
@@ -3,7 +3,7 @@ import {
3
3
  generateDeclaration,
4
4
  generateJs,
5
5
  scanVarNames
6
- } from "./chunk-J7ZV6AUQ.js";
6
+ } from "./chunk-MJEASOAN.js";
7
7
 
8
8
  // src/unplugin.ts
9
9
  import { createUnplugin } from "unplugin";
package/dist/cli.cjs CHANGED
@@ -81,7 +81,7 @@ async function scanVarNames(patterns, exclude, selectors) {
81
81
  function toKey(cssVarName, naming = "camelCase") {
82
82
  const stripped = cssVarName.replace(/^--/, "");
83
83
  if (naming === "kebab") return stripped;
84
- const key = naming === "snake" ? stripped.replace(/-/g, "_") : 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()).replace(/-/g, "");
85
85
  return /^\d/.test(key) ? `_${key}` : key;
86
86
  }
87
87
  function applyPrefix(key, prefix, naming = "camelCase") {
@@ -208,7 +208,12 @@ async function main() {
208
208
  const excludeArgs = getArgs("--exclude");
209
209
  const exclude = excludeArgs.length > 0 ? excludeArgs : config.exclude;
210
210
  const prefix = getArg("--prefix") ?? config.prefix;
211
- const naming = getArg("--naming") ?? config.naming;
211
+ const namingRaw = getArg("--naming") ?? config.naming;
212
+ if (namingRaw !== void 0 && !["camelCase", "snake", "kebab"].includes(namingRaw)) {
213
+ console.error(`css-typed-vars: invalid --naming value "${namingRaw}". Valid values: camelCase, snake, kebab`);
214
+ process.exit(1);
215
+ }
216
+ const naming = namingRaw;
212
217
  const selectorArgs = getArgs("--selector");
213
218
  const selectors = selectorArgs.length > 0 ? selectorArgs : config.selectors;
214
219
  if (!input || !output) {
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  generate
4
- } from "./chunk-6OVNVVEP.js";
5
- import "./chunk-J7ZV6AUQ.js";
4
+ } from "./chunk-CDJTXVSE.js";
5
+ import "./chunk-MJEASOAN.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import { readFile } from "fs/promises";
@@ -63,7 +63,12 @@ async function main() {
63
63
  const excludeArgs = getArgs("--exclude");
64
64
  const exclude = excludeArgs.length > 0 ? excludeArgs : config.exclude;
65
65
  const prefix = getArg("--prefix") ?? config.prefix;
66
- const naming = getArg("--naming") ?? config.naming;
66
+ const namingRaw = getArg("--naming") ?? config.naming;
67
+ if (namingRaw !== void 0 && !["camelCase", "snake", "kebab"].includes(namingRaw)) {
68
+ console.error(`css-typed-vars: invalid --naming value "${namingRaw}". Valid values: camelCase, snake, kebab`);
69
+ process.exit(1);
70
+ }
71
+ const naming = namingRaw;
67
72
  const selectorArgs = getArgs("--selector");
68
73
  const selectors = selectorArgs.length > 0 ? selectorArgs : config.selectors;
69
74
  if (!input || !output) {
package/dist/esbuild.cjs CHANGED
@@ -83,7 +83,7 @@ async function scanVarNames(patterns, exclude, selectors) {
83
83
  function toKey(cssVarName, naming = "camelCase") {
84
84
  const stripped = cssVarName.replace(/^--/, "");
85
85
  if (naming === "kebab") return stripped;
86
- const key = naming === "snake" ? stripped.replace(/-/g, "_") : 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()).replace(/-/g, "");
87
87
  return /^\d/.test(key) ? `_${key}` : key;
88
88
  }
89
89
  function applyPrefix(key, prefix, naming = "camelCase") {
package/dist/esbuild.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-PYNEJIVI.js";
4
- import "./chunk-J7ZV6AUQ.js";
3
+ } from "./chunk-QJWQDFW4.js";
4
+ import "./chunk-MJEASOAN.js";
5
5
 
6
6
  // src/esbuild.ts
7
7
  var esbuild_default = unplugin_default.esbuild;
package/dist/index.cjs CHANGED
@@ -85,7 +85,7 @@ async function scanVarNames(patterns, exclude, selectors) {
85
85
  function toKey(cssVarName, naming = "camelCase") {
86
86
  const stripped = cssVarName.replace(/^--/, "");
87
87
  if (naming === "kebab") return stripped;
88
- const key = naming === "snake" ? stripped.replace(/-/g, "_") : 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()).replace(/-/g, "");
89
89
  return /^\d/.test(key) ? `_${key}` : key;
90
90
  }
91
91
  function applyPrefix(key, prefix, naming = "camelCase") {
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  generate
3
- } from "./chunk-6OVNVVEP.js";
3
+ } from "./chunk-CDJTXVSE.js";
4
4
  import {
5
5
  generateCode,
6
6
  generateDeclaration,
7
7
  generateJs,
8
8
  parseVarNames,
9
9
  scanVarNames
10
- } from "./chunk-J7ZV6AUQ.js";
10
+ } from "./chunk-MJEASOAN.js";
11
11
  export {
12
12
  generate,
13
13
  generateCode,
package/dist/rollup.cjs CHANGED
@@ -83,7 +83,7 @@ async function scanVarNames(patterns, exclude, selectors) {
83
83
  function toKey(cssVarName, naming = "camelCase") {
84
84
  const stripped = cssVarName.replace(/^--/, "");
85
85
  if (naming === "kebab") return stripped;
86
- const key = naming === "snake" ? stripped.replace(/-/g, "_") : 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()).replace(/-/g, "");
87
87
  return /^\d/.test(key) ? `_${key}` : key;
88
88
  }
89
89
  function applyPrefix(key, prefix, naming = "camelCase") {
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-PYNEJIVI.js";
4
- import "./chunk-J7ZV6AUQ.js";
3
+ } from "./chunk-QJWQDFW4.js";
4
+ import "./chunk-MJEASOAN.js";
5
5
 
6
6
  // src/rollup.ts
7
7
  var rollup_default = unplugin_default.rollup;
package/dist/unplugin.cjs CHANGED
@@ -81,7 +81,7 @@ async function scanVarNames(patterns, exclude, selectors) {
81
81
  function toKey(cssVarName, naming = "camelCase") {
82
82
  const stripped = cssVarName.replace(/^--/, "");
83
83
  if (naming === "kebab") return stripped;
84
- const key = naming === "snake" ? stripped.replace(/-/g, "_") : 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()).replace(/-/g, "");
85
85
  return /^\d/.test(key) ? `_${key}` : key;
86
86
  }
87
87
  function applyPrefix(key, prefix, naming = "camelCase") {
package/dist/unplugin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-PYNEJIVI.js";
4
- import "./chunk-J7ZV6AUQ.js";
3
+ } from "./chunk-QJWQDFW4.js";
4
+ import "./chunk-MJEASOAN.js";
5
5
  export {
6
6
  unplugin_default as default
7
7
  };
package/dist/vite.cjs CHANGED
@@ -83,7 +83,7 @@ async function scanVarNames(patterns, exclude, selectors) {
83
83
  function toKey(cssVarName, naming = "camelCase") {
84
84
  const stripped = cssVarName.replace(/^--/, "");
85
85
  if (naming === "kebab") return stripped;
86
- const key = naming === "snake" ? stripped.replace(/-/g, "_") : 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()).replace(/-/g, "");
87
87
  return /^\d/.test(key) ? `_${key}` : key;
88
88
  }
89
89
  function applyPrefix(key, prefix, naming = "camelCase") {
package/dist/vite.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-PYNEJIVI.js";
4
- import "./chunk-J7ZV6AUQ.js";
3
+ } from "./chunk-QJWQDFW4.js";
4
+ import "./chunk-MJEASOAN.js";
5
5
 
6
6
  // src/vite.ts
7
7
  var vite_default = unplugin_default.vite;
package/dist/webpack.cjs CHANGED
@@ -83,7 +83,7 @@ async function scanVarNames(patterns, exclude, selectors) {
83
83
  function toKey(cssVarName, naming = "camelCase") {
84
84
  const stripped = cssVarName.replace(/^--/, "");
85
85
  if (naming === "kebab") return stripped;
86
- const key = naming === "snake" ? stripped.replace(/-/g, "_") : 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()).replace(/-/g, "");
87
87
  return /^\d/.test(key) ? `_${key}` : key;
88
88
  }
89
89
  function applyPrefix(key, prefix, naming = "camelCase") {
package/dist/webpack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-PYNEJIVI.js";
4
- import "./chunk-J7ZV6AUQ.js";
3
+ } from "./chunk-QJWQDFW4.js";
4
+ import "./chunk-MJEASOAN.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.7",
3
+ "version": "0.4.8",
4
4
  "description": "Generate TypeScript typed constants from CSS custom properties",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",