css-typed-vars 0.4.17 → 0.6.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/dist/esbuild.cjs CHANGED
@@ -140,10 +140,28 @@ function maskQuotedContent(text) {
140
140
  }
141
141
  return result;
142
142
  }
143
- function parseVarNames(css, selectors) {
143
+ function extractValue(text, start) {
144
+ let i = start;
145
+ let quote = null;
146
+ for (; i < text.length; i++) {
147
+ const char = text[i];
148
+ if (quote) {
149
+ const step = stepQuote(text, i, quote);
150
+ if (step.closed) quote = null;
151
+ i += step.consumed - 1;
152
+ continue;
153
+ }
154
+ if (char === '"' || char === "'") {
155
+ quote = char;
156
+ continue;
157
+ }
158
+ if (char === ";" || char === "}") break;
159
+ }
160
+ return text.slice(start, i).trim();
161
+ }
162
+ function scanDeclarations(css, selectors, onProperty) {
144
163
  const stripped = stripComments(css);
145
- const names = /* @__PURE__ */ new Set();
146
- const allSelectors = [":root", ...selectors ?? []];
164
+ const allSelectors = [":root", "@theme", ...selectors ?? []];
147
165
  for (const sel of allSelectors) {
148
166
  const escaped = sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
149
167
  const openRegex = new RegExp(`${escaped}(?![\\w-])[^{]*\\{`, "g");
@@ -151,53 +169,135 @@ function parseVarNames(css, selectors) {
151
169
  while (match = openRegex.exec(stripped)) {
152
170
  const start = match.index + match[0].length;
153
171
  const block = extractBlock(stripped, start);
154
- for (const prop of maskQuotedContent(block).matchAll(/--[\w-]+(?=\s*:)/g)) {
155
- names.add(prop[0]);
172
+ const masked = maskQuotedContent(block);
173
+ for (const prop of masked.matchAll(/--[\w-]+(?=\s*:)/g)) {
174
+ const name = prop[0];
175
+ const colonIndex = block.indexOf(":", prop.index + name.length);
176
+ onProperty(name, extractValue(block, colonIndex + 1));
156
177
  }
157
178
  openRegex.lastIndex = start + block.length + 1;
158
179
  }
159
180
  }
160
- return [...names];
181
+ }
182
+ function parseVarDeclarations(css, selectors) {
183
+ const declarations = /* @__PURE__ */ new Map();
184
+ scanDeclarations(css, selectors, (name, value) => declarations.set(name, value));
185
+ return declarations;
186
+ }
187
+ var PROPERTY_DESCRIPTORS = [
188
+ ["syntax", "syntax"],
189
+ ["inherits", "inherits"],
190
+ ["initial-value", "initialValue"]
191
+ ];
192
+ function parsePropertyRules(css) {
193
+ const stripped = stripComments(css);
194
+ const rules = /* @__PURE__ */ new Map();
195
+ const openRegex = /@property\s+(--[\w-]+)\s*\{/g;
196
+ let match;
197
+ while (match = openRegex.exec(stripped)) {
198
+ const name = match[1];
199
+ const start = match.index + match[0].length;
200
+ const block = extractBlock(stripped, start);
201
+ const masked = maskQuotedContent(block);
202
+ const rule = {};
203
+ for (const [descriptor, key] of PROPERTY_DESCRIPTORS) {
204
+ const descRegex = new RegExp(`(?:^|[;{\\s])${descriptor}(?=\\s*:)`);
205
+ const descMatch = descRegex.exec(masked);
206
+ if (!descMatch) continue;
207
+ const nameEnd = descMatch.index + descMatch[0].length;
208
+ const colonIndex = block.indexOf(":", nameEnd);
209
+ rule[key] = extractValue(block, colonIndex + 1);
210
+ }
211
+ if (Object.keys(rule).length > 0) rules.set(name, rule);
212
+ openRegex.lastIndex = start + block.length + 1;
213
+ }
214
+ return rules;
161
215
  }
162
216
 
163
217
  // src/scanner.ts
164
- async function scanVarNames(patterns, exclude, selectors) {
165
- const normalized = (Array.isArray(patterns) ? patterns : [patterns]).map(
166
- (p) => p.replace(/\\/g, "/")
167
- );
168
- const normalizedExclude = exclude ? (Array.isArray(exclude) ? exclude : [exclude]).map((p) => p.replace(/\\/g, "/")) : [];
218
+ function normalizePatterns(patterns) {
219
+ return (Array.isArray(patterns) ? patterns : [patterns]).map((p) => p.replace(/\\/g, "/"));
220
+ }
221
+ async function scanCss(patterns, exclude, selectors) {
222
+ const normalized = normalizePatterns(patterns);
223
+ const normalizedExclude = exclude ? normalizePatterns(exclude) : [];
169
224
  const files = await (0, import_fast_glob.default)(normalized, { absolute: true, ignore: normalizedExclude });
170
- const all = /* @__PURE__ */ new Set();
171
- await Promise.all(
225
+ const perFile = await Promise.all(
172
226
  files.map(async (file) => {
173
227
  let css;
174
228
  try {
175
229
  css = await (0, import_promises.readFile)(file, "utf8");
176
230
  } catch (err) {
177
231
  console.warn(`css-typed-vars: skipping "${file}": ${err.message}`);
178
- return;
232
+ return { declarations: /* @__PURE__ */ new Map(), properties: /* @__PURE__ */ new Map() };
179
233
  }
180
- for (const name of parseVarNames(css, selectors)) {
181
- all.add(name);
234
+ return { declarations: parseVarDeclarations(css, selectors), properties: parsePropertyRules(css) };
235
+ })
236
+ );
237
+ const declarations = /* @__PURE__ */ new Map();
238
+ const properties = /* @__PURE__ */ new Map();
239
+ for (const result of perFile) {
240
+ for (const [name, value] of result.declarations) declarations.set(name, value);
241
+ for (const [name, rule] of result.properties) properties.set(name, rule);
242
+ }
243
+ return { declarations, properties };
244
+ }
245
+ var USAGE_RE = /\bcssVars\s*(?:\.\s*([A-Za-z_$][\w$]*)|\[\s*(['"`])((?:(?!\2).)*)\2\s*\])/g;
246
+ function extractUsedKeys(text, into) {
247
+ for (const match of text.matchAll(USAGE_RE)) {
248
+ into.add(match[1] ?? match[3]);
249
+ }
250
+ }
251
+ async function scanUsedKeys(patterns, exclude) {
252
+ const normalized = normalizePatterns(patterns);
253
+ const normalizedExclude = exclude ? normalizePatterns(exclude) : [];
254
+ const files = await (0, import_fast_glob.default)(normalized, { absolute: true, ignore: normalizedExclude });
255
+ const perFile = await Promise.all(
256
+ files.map(async (file) => {
257
+ const used = /* @__PURE__ */ new Set();
258
+ let text;
259
+ try {
260
+ text = await (0, import_promises.readFile)(file, "utf8");
261
+ } catch (err) {
262
+ console.warn(`css-typed-vars: skipping "${file}": ${err.message}`);
263
+ return used;
182
264
  }
265
+ extractUsedKeys(text, used);
266
+ return used;
183
267
  })
184
268
  );
185
- return [...all].sort();
269
+ const all = /* @__PURE__ */ new Set();
270
+ for (const used of perFile) {
271
+ for (const key of used) all.add(key);
272
+ }
273
+ return all;
186
274
  }
187
275
 
188
276
  // src/generator.ts
189
- var VALID_NAMINGS = ["camelCase", "snake", "kebab"];
277
+ var VALID_NAMINGS = ["camelCase", "snake", "kebab", "constant", "pascal"];
190
278
  function convertCase(value, naming) {
191
279
  if (!VALID_NAMINGS.includes(naming)) {
192
280
  throw new Error(`css-typed-vars: invalid naming "${naming}". Valid values: ${VALID_NAMINGS.join(", ")}`);
193
281
  }
194
282
  if (naming === "kebab") return value;
195
- return naming === "snake" ? value.replace(/-+/g, "_") : value.replace(/-+([a-z0-9])/g, (_, c) => c.toUpperCase()).replace(/-/g, "");
283
+ if (naming === "snake") return value.replace(/-+/g, "_");
284
+ if (naming === "constant") return value.replace(/-+/g, "_").toUpperCase();
285
+ if (naming === "pascal") return value.replace(/(^|-+)([a-z0-9])/g, (_, __, c) => c.toUpperCase()).replace(/-/g, "");
286
+ return value.replace(/-+([a-z0-9])/g, (_, c) => c.toUpperCase()).replace(/-/g, "");
196
287
  }
197
- function toKey(cssVarName, naming = "camelCase") {
198
- const key = convertCase(cssVarName.replace(/^--/, ""), naming);
288
+ function toKeyFragment(fragment, naming = "camelCase") {
289
+ const key = convertCase(fragment, naming);
199
290
  return naming !== "kebab" && /^\d/.test(key) ? `_${key}` : key;
200
291
  }
292
+ function toKey(cssVarName, naming = "camelCase") {
293
+ return toKeyFragment(cssVarName.replace(/^--/, ""), naming);
294
+ }
295
+ function splitGroupKey(cssVarName) {
296
+ const stripped = cssVarName.replace(/^--/, "");
297
+ const dashIndex = stripped.indexOf("-");
298
+ if (dashIndex === -1) return null;
299
+ return { group: stripped.slice(0, dashIndex), rest: stripped.slice(dashIndex + 1) };
300
+ }
201
301
  var LINE_SEPARATOR_CHAR = String.fromCharCode(8232);
202
302
  var PARAGRAPH_SEPARATOR_CHAR = String.fromCharCode(8233);
203
303
  var SINGLE_QUOTE_ESCAPES = {};
@@ -223,13 +323,16 @@ function applyPrefix(key, prefix, naming = "camelCase") {
223
323
  }
224
324
  normalizedPrefix = normalizedPrefix.replace(/[^A-Za-z0-9_$]/g, "");
225
325
  if (/^\d/.test(normalizedPrefix)) normalizedPrefix = `_${normalizedPrefix}`;
226
- if (naming === "snake") return `${normalizedPrefix}_${key}`;
326
+ if (naming === "snake" || naming === "constant") return `${normalizedPrefix}_${key}`;
227
327
  return normalizedPrefix + key.charAt(0).toUpperCase() + key.slice(1);
228
328
  }
229
329
  function formatKey(key, naming = "camelCase") {
230
330
  if (naming === "kebab") return `'${key}'`;
231
331
  return key;
232
332
  }
333
+ function computeKey(cssVarName, prefix, naming) {
334
+ return applyPrefix(toKey(cssVarName, naming), prefix, naming);
335
+ }
233
336
  function findKeyCollisions(varNames, prefix, naming) {
234
337
  const byKey = /* @__PURE__ */ new Map();
235
338
  for (const name of varNames) {
@@ -248,16 +351,112 @@ function warnOnCollisions(varNames, prefix, naming) {
248
351
  console.warn(`css-typed-vars: multiple CSS variables map to the same key "${key}" (${vars.join(", ")}) \u2014 only the last one will be kept.`);
249
352
  }
250
353
  }
251
- function buildEntries(varNames, prefix, naming) {
354
+ function buildEntries(varNames, prefix, naming, declarations, properties) {
252
355
  const byKey = /* @__PURE__ */ new Map();
253
356
  for (const name of varNames) {
254
357
  const key = formatKey(applyPrefix(toKey(name, naming), prefix, naming), naming);
255
- byKey.set(key, name);
358
+ byKey.set(key, { name, value: declarations?.get(name), syntax: properties?.get(name)?.syntax });
359
+ }
360
+ return [...byKey].map(([key, entry]) => ({ key, ...entry }));
361
+ }
362
+ function buildGroupedEntries(varNames, naming, declarations, properties) {
363
+ const groupMap = /* @__PURE__ */ new Map();
364
+ const ungroupedMap = /* @__PURE__ */ new Map();
365
+ for (const name of varNames) {
366
+ const value = declarations?.get(name);
367
+ const syntax = properties?.get(name)?.syntax;
368
+ const split = splitGroupKey(name);
369
+ if (!split) {
370
+ ungroupedMap.set(formatKey(toKey(name, naming), naming), { name, value, syntax });
371
+ continue;
372
+ }
373
+ const groupKey = formatKey(toKeyFragment(split.group, naming), naming);
374
+ const leafKey = formatKey(toKeyFragment(split.rest, naming), naming);
375
+ let leafMap = groupMap.get(groupKey);
376
+ if (!leafMap) {
377
+ leafMap = /* @__PURE__ */ new Map();
378
+ groupMap.set(groupKey, leafMap);
379
+ }
380
+ leafMap.set(leafKey, { name, value, syntax });
381
+ }
382
+ for (const groupKey of groupMap.keys()) ungroupedMap.delete(groupKey);
383
+ const groups = [...groupMap].map(([key, leafMap]) => ({
384
+ key,
385
+ entries: [...leafMap].map(([key2, entry]) => ({ key: key2, ...entry }))
386
+ }));
387
+ const ungrouped = [...ungroupedMap].map(([key, entry]) => ({ key, ...entry }));
388
+ return { groups, ungrouped };
389
+ }
390
+ function formatDefaultComment(value, indent = " ") {
391
+ return `${indent}/** @default ${value.replace(/\*\//g, "*\\/")} */`;
392
+ }
393
+ function unquoteCssString(value) {
394
+ const quote = value[0];
395
+ if ((quote === '"' || quote === "'") && value[value.length - 1] === quote) {
396
+ return value.slice(1, -1);
397
+ }
398
+ return value;
399
+ }
400
+ function formatSyntaxComment(syntax, indent = " ") {
401
+ return `${indent}/** @syntax ${unquoteCssString(syntax).replace(/\*\//g, "*\\/")} */`;
402
+ }
403
+ var ENUM_SYNTAX_RE = /^[\w-]+(?:\s*\|\s*[\w-]+)+$/;
404
+ function parseEnumSyntax(syntax) {
405
+ const unquoted = unquoteCssString(syntax).trim();
406
+ if (!ENUM_SYNTAX_RE.test(unquoted)) return null;
407
+ return unquoted.split("|").map((v) => v.trim());
408
+ }
409
+ function syntaxTypeName(cssVarName) {
410
+ const pascal = convertCase(cssVarName.replace(/^--/, ""), "pascal");
411
+ return (/^\d/.test(pascal) ? `_${pascal}` : pascal) + "Syntax";
412
+ }
413
+ function buildSyntaxTypes(varNames, properties) {
414
+ if (!properties) return [];
415
+ const byName = /* @__PURE__ */ new Map();
416
+ for (const name of varNames) {
417
+ const values = parseEnumSyntax(properties.get(name)?.syntax ?? "");
418
+ if (values) byName.set(syntaxTypeName(name), values);
256
419
  }
257
- return [...byKey].map(([key, name]) => ({ key, name }));
420
+ return [...byName].map(([name, values]) => ({ name, values }));
258
421
  }
259
- function generateJs(varNames, prefix, naming) {
260
- const entries = buildEntries(varNames, prefix, naming).map(({ key, name }) => ` ${key}: 'var(${name})',`);
422
+ function renderSyntaxTypeLines(types) {
423
+ return types.map(({ name, values }) => `export type ${name} = ${values.map((v) => `'${escapeSingleQuoted(v)}'`).join(" | ")};`);
424
+ }
425
+ function buildTailBlocks(varNames, group, properties) {
426
+ const blocks = [];
427
+ if (!group) blocks.push(["export type CssVarName = keyof typeof cssVars;"]);
428
+ const syntaxLines = renderSyntaxTypeLines(buildSyntaxTypes(varNames, properties));
429
+ if (syntaxLines.length > 0) blocks.push(syntaxLines);
430
+ return blocks;
431
+ }
432
+ function renderEntryLines(entries, indent, lineFor) {
433
+ return entries.flatMap(({ key, name, value, syntax }) => [
434
+ ...value ? [formatDefaultComment(value, indent)] : [],
435
+ ...syntax ? [formatSyntaxComment(syntax, indent)] : [],
436
+ `${indent}${lineFor(key, name)}`
437
+ ]);
438
+ }
439
+ function renderGroupedBlock(varNames, naming, declarations, properties, indent, closeSuffix, lineFor) {
440
+ const { groups, ungrouped } = buildGroupedEntries(varNames, naming, declarations, properties);
441
+ const lines = [];
442
+ for (const group of groups) {
443
+ lines.push(`${indent}${group.key}: {`);
444
+ lines.push(...renderEntryLines(group.entries, indent + " ", lineFor));
445
+ lines.push(`${indent}}${closeSuffix}`);
446
+ }
447
+ lines.push(...renderEntryLines(ungrouped, indent, lineFor));
448
+ return lines;
449
+ }
450
+ function assertGroupPrefixCompatible(prefix, group) {
451
+ if (group && prefix) {
452
+ throw new Error('css-typed-vars: the "group" option cannot be combined with "prefix".');
453
+ }
454
+ }
455
+ var codeLineFor = (key, name) => `${key}: 'var(${name})',`;
456
+ var declarationLineFor = (key, name) => `${key}: 'var(${name})';`;
457
+ function generateJs(varNames, prefix, naming, declarations, group, properties) {
458
+ assertGroupPrefixCompatible(prefix, group);
459
+ const entries = group ? renderGroupedBlock(varNames, naming, declarations, properties, " ", ",", codeLineFor) : renderEntryLines(buildEntries(varNames, prefix, naming, declarations, properties), " ", codeLineFor);
261
460
  return [
262
461
  "// generated \u2014 do not edit",
263
462
  "export const cssVars = {",
@@ -266,13 +465,16 @@ function generateJs(varNames, prefix, naming) {
266
465
  ""
267
466
  ].join("\n");
268
467
  }
269
- function generateDeclaration(varNames, prefix, naming) {
270
- const entries = buildEntries(varNames, prefix, naming).map(({ key, name }) => ` ${key}: 'var(${name})';`);
468
+ function generateDeclaration(varNames, prefix, naming, declarations, group, properties) {
469
+ assertGroupPrefixCompatible(prefix, group);
470
+ const entries = group ? renderGroupedBlock(varNames, naming, declarations, properties, " ", ";", declarationLineFor) : renderEntryLines(buildEntries(varNames, prefix, naming, declarations, properties), " ", declarationLineFor);
471
+ const blocks = buildTailBlocks(varNames, group, properties);
472
+ const tailBody = blocks.flatMap((block, i) => i === 0 ? block : ["", ...block]);
271
473
  return [
272
474
  "export declare const cssVars: {",
273
475
  ...entries,
274
476
  "};",
275
- "export type CssVarName = keyof typeof cssVars;",
477
+ ...tailBody,
276
478
  ""
277
479
  ].join("\n");
278
480
  }
@@ -285,7 +487,27 @@ function getDtsPath(options) {
285
487
  return options.dts ? (0, import_node_path.resolve)(process.cwd(), options.dts) : (0, import_node_path.join)(__dirname, "generated.d.ts");
286
488
  }
287
489
  var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
288
- let cachedNames = null;
490
+ if (options.prune) {
491
+ if (options.group) throw new Error('css-typed-vars: "prune" cannot be combined with "group".');
492
+ if (!options.usage) throw new Error('css-typed-vars: "prune" requires "usage" (glob(s) of source files to scan).');
493
+ }
494
+ let cachedScan = null;
495
+ const scan = () => scanCss(options.input, options.exclude, options.selectors);
496
+ const applyPrune = async (names) => {
497
+ if (!options.prune) return names;
498
+ const usedKeys = await scanUsedKeys(options.usage, options.usageExclude);
499
+ const isUsed = (name) => usedKeys.has(computeKey(name, options.prefix, options.naming));
500
+ const unused = names.filter((name) => !isUsed(name));
501
+ if (unused.length > 0) {
502
+ console.warn(`css-typed-vars: pruned ${unused.length} unused variable(s): ${unused.join(", ")}`);
503
+ }
504
+ return names.filter(isUsed);
505
+ };
506
+ const resolveNames = async (declarations) => {
507
+ const names = [...declarations.keys()].sort();
508
+ warnOnCollisions(names, options.prefix, options.naming);
509
+ return applyPrune(names);
510
+ };
289
511
  return {
290
512
  name: "css-typed-vars",
291
513
  vite: {
@@ -296,14 +518,15 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
296
518
  let writeQueue = Promise.resolve();
297
519
  const rescan = async () => {
298
520
  const myGeneration = ++generation;
299
- const namesPromise = scanVarNames(options.input, options.exclude, options.selectors);
300
- cachedNames = namesPromise;
301
- const names = await namesPromise;
521
+ const scanPromise = scan();
522
+ cachedScan = scanPromise;
523
+ const { declarations, properties } = await scanPromise;
524
+ if (myGeneration !== generation) return;
525
+ const names = await resolveNames(declarations);
302
526
  if (myGeneration !== generation) return;
303
- warnOnCollisions(names, options.prefix, options.naming);
304
527
  const dtsPath = getDtsPath(options);
305
528
  if (dtsPath) {
306
- const content = generateDeclaration(names, options.prefix, options.naming);
529
+ const content = generateDeclaration(names, options.prefix, options.naming, declarations, options.group, properties);
307
530
  writeQueue = writeQueue.then(async () => {
308
531
  if (myGeneration !== generation) return;
309
532
  await (0, import_promises2.writeFile)(dtsPath, content, "utf8");
@@ -331,20 +554,21 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
331
554
  }
332
555
  },
333
556
  async buildStart() {
334
- cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
335
- const names = await cachedNames;
336
- warnOnCollisions(names, options.prefix, options.naming);
557
+ cachedScan = scan();
558
+ const { declarations, properties } = await cachedScan;
559
+ const names = await resolveNames(declarations);
337
560
  const dtsPath = getDtsPath(options);
338
561
  if (!dtsPath) return;
339
- await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
562
+ await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming, declarations, options.group, properties), "utf8");
340
563
  },
341
564
  resolveId(id) {
342
565
  if (id === VIRTUAL_ID) return RESOLVED_ID;
343
566
  },
344
567
  async load(id) {
345
568
  if (id === RESOLVED_ID) {
346
- const names = await (cachedNames ?? scanVarNames(options.input, options.exclude, options.selectors));
347
- return generateJs(names, options.prefix, options.naming);
569
+ const { declarations, properties } = await (cachedScan ?? scan());
570
+ const names = await applyPrune([...declarations.keys()].sort());
571
+ return generateJs(names, options.prefix, options.naming, declarations, options.group, properties);
348
572
  }
349
573
  }
350
574
  };
@@ -1,7 +1,7 @@
1
1
  import * as esbuild from 'esbuild';
2
2
  import { Options } from './unplugin.cjs';
3
3
  import 'unplugin';
4
- import './generator-Ba8XeISD.cjs';
4
+ import './generator-C2AppeJL.cjs';
5
5
 
6
6
  declare const _default: (options: Options) => esbuild.Plugin;
7
7
 
package/dist/esbuild.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as esbuild from 'esbuild';
2
2
  import { Options } from './unplugin.js';
3
3
  import 'unplugin';
4
- import './generator-Ba8XeISD.js';
4
+ import './generator-C2AppeJL.js';
5
5
 
6
6
  declare const _default: (options: Options) => esbuild.Plugin;
7
7
 
package/dist/esbuild.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-DOOYTSTY.js";
4
- import "./chunk-WYLYZXQJ.js";
3
+ } from "./chunk-TD7SYMDA.js";
4
+ import "./chunk-LH53WYFF.js";
5
5
 
6
6
  // src/esbuild.ts
7
7
  var esbuild_default = unplugin_default.esbuild;
@@ -0,0 +1,15 @@
1
+ declare function parseVarNames(css: string, selectors?: string[]): string[];
2
+ declare function parseVarDeclarations(css: string, selectors?: string[]): Map<string, string>;
3
+ interface PropertyRule {
4
+ syntax?: string;
5
+ inherits?: string;
6
+ initialValue?: string;
7
+ }
8
+ declare function parsePropertyRules(css: string): Map<string, PropertyRule>;
9
+
10
+ type NamingConvention = 'camelCase' | 'snake' | 'kebab' | 'constant' | 'pascal';
11
+ declare function generateCode(varNames: string[], prefix?: string, naming?: NamingConvention, declarations?: Map<string, string>, group?: boolean, properties?: Map<string, PropertyRule>): string;
12
+ declare function generateJs(varNames: string[], prefix?: string, naming?: NamingConvention, declarations?: Map<string, string>, group?: boolean, properties?: Map<string, PropertyRule>): string;
13
+ declare function generateDeclaration(varNames: string[], prefix?: string, naming?: NamingConvention, declarations?: Map<string, string>, group?: boolean, properties?: Map<string, PropertyRule>): string;
14
+
15
+ export { type NamingConvention as N, type PropertyRule as P, generateDeclaration as a, generateJs as b, parseVarDeclarations as c, parseVarNames as d, generateCode as g, parsePropertyRules as p };
@@ -0,0 +1,15 @@
1
+ declare function parseVarNames(css: string, selectors?: string[]): string[];
2
+ declare function parseVarDeclarations(css: string, selectors?: string[]): Map<string, string>;
3
+ interface PropertyRule {
4
+ syntax?: string;
5
+ inherits?: string;
6
+ initialValue?: string;
7
+ }
8
+ declare function parsePropertyRules(css: string): Map<string, PropertyRule>;
9
+
10
+ type NamingConvention = 'camelCase' | 'snake' | 'kebab' | 'constant' | 'pascal';
11
+ declare function generateCode(varNames: string[], prefix?: string, naming?: NamingConvention, declarations?: Map<string, string>, group?: boolean, properties?: Map<string, PropertyRule>): string;
12
+ declare function generateJs(varNames: string[], prefix?: string, naming?: NamingConvention, declarations?: Map<string, string>, group?: boolean, properties?: Map<string, PropertyRule>): string;
13
+ declare function generateDeclaration(varNames: string[], prefix?: string, naming?: NamingConvention, declarations?: Map<string, string>, group?: boolean, properties?: Map<string, PropertyRule>): string;
14
+
15
+ export { type NamingConvention as N, type PropertyRule as P, generateDeclaration as a, generateJs as b, parseVarDeclarations as c, parseVarNames as d, generateCode as g, parsePropertyRules as p };