dispersa 0.4.3 → 1.1.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/README.md +65 -30
- package/dist/android-CRDfSB3_.d.cts +126 -0
- package/dist/android-DANJjjPO.d.ts +126 -0
- package/dist/builders.cjs +206 -62
- package/dist/builders.cjs.map +1 -1
- package/dist/builders.d.cts +12 -11
- package/dist/builders.d.ts +12 -11
- package/dist/builders.js +206 -62
- package/dist/builders.js.map +1 -1
- package/dist/cli/cli.js +120 -7
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/config.d.ts +321 -0
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.js +119 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/dispersa-BC1kDF5u.d.ts +118 -0
- package/dist/dispersa-DL3J_Pmz.d.cts +118 -0
- package/dist/errors-qT4sJgSA.d.cts +104 -0
- package/dist/errors-qT4sJgSA.d.ts +104 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +1 -83
- package/dist/errors.d.ts +1 -83
- package/dist/errors.js.map +1 -1
- package/dist/filters.cjs.map +1 -1
- package/dist/filters.d.cts +2 -2
- package/dist/filters.d.ts +2 -2
- package/dist/filters.js.map +1 -1
- package/dist/{index-CNT2Meyf.d.cts → index-Dajm5rvM.d.ts} +311 -132
- package/dist/{index-CqdaN3X0.d.ts → index-De6SjZYH.d.cts} +311 -132
- package/dist/index.cjs +799 -353
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -329
- package/dist/index.d.ts +8 -329
- package/dist/index.js +793 -353
- package/dist/index.js.map +1 -1
- package/dist/lint.cjs +1029 -0
- package/dist/lint.cjs.map +1 -0
- package/dist/lint.d.cts +463 -0
- package/dist/lint.d.ts +463 -0
- package/dist/lint.js +1009 -0
- package/dist/lint.js.map +1 -0
- package/dist/preprocessors.d.cts +2 -2
- package/dist/preprocessors.d.ts +2 -2
- package/dist/renderers.cjs.map +1 -1
- package/dist/renderers.d.cts +7 -6
- package/dist/renderers.d.ts +7 -6
- package/dist/renderers.js.map +1 -1
- package/dist/transforms.d.cts +2 -2
- package/dist/transforms.d.ts +2 -2
- package/dist/{types-CZb19kiq.d.ts → types-8MLtztK3.d.ts} +56 -1
- package/dist/{types-CussyWwe.d.cts → types-BHBHRm0a.d.cts} +56 -1
- package/dist/{types-BAv39mum.d.cts → types-BltzwVYK.d.cts} +1 -1
- package/dist/{types-DWKq-eJj.d.cts → types-CAdUV-fa.d.cts} +1 -1
- package/dist/{types-CzHa7YkW.d.ts → types-DztXKlka.d.ts} +1 -1
- package/dist/{types-Bc0kA7De.d.ts → types-TQHV1MrY.d.cts} +19 -1
- package/dist/{types-Bc0kA7De.d.cts → types-TQHV1MrY.d.ts} +19 -1
- package/dist/{types-BzNcG-rI.d.ts → types-ebxDimRz.d.ts} +1 -1
- package/package.json +19 -9
package/dist/builders.cjs
CHANGED
|
@@ -47,19 +47,6 @@ var init_errors = __esm({
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
// src/shared/utils/token-utils.ts
|
|
50
|
-
function formatDeprecationMessage(token, description = "", format = "bracket") {
|
|
51
|
-
if (token.$deprecated == null || token.$deprecated === false) {
|
|
52
|
-
return description;
|
|
53
|
-
}
|
|
54
|
-
const deprecationMsg = typeof token.$deprecated === "string" ? token.$deprecated : "";
|
|
55
|
-
if (format === "comment") {
|
|
56
|
-
const msg2 = deprecationMsg ? ` ${deprecationMsg}` : "";
|
|
57
|
-
return `DEPRECATED${msg2}`;
|
|
58
|
-
}
|
|
59
|
-
const msg = deprecationMsg ? `: ${deprecationMsg}` : "";
|
|
60
|
-
const prefix = `[DEPRECATED${msg}]`;
|
|
61
|
-
return description ? `${prefix} ${description}` : prefix;
|
|
62
|
-
}
|
|
63
50
|
function stripInternalTokenMetadata(tokens) {
|
|
64
51
|
const cleaned = {};
|
|
65
52
|
for (const [name, token] of Object.entries(tokens)) {
|
|
@@ -337,6 +324,94 @@ var init_utils = __esm({
|
|
|
337
324
|
}
|
|
338
325
|
});
|
|
339
326
|
|
|
327
|
+
// src/renderers/metadata.ts
|
|
328
|
+
function sanitizeText(text, format) {
|
|
329
|
+
switch (format) {
|
|
330
|
+
case "css":
|
|
331
|
+
case "tailwind":
|
|
332
|
+
return text.replace(/\*\//g, "*\\/").replace(/\r?\n/g, " ").trim();
|
|
333
|
+
case "kotlin":
|
|
334
|
+
return text.replace(/\*\//g, "* /").replace(/\r?\n/g, " ").trim();
|
|
335
|
+
case "js":
|
|
336
|
+
case "swift":
|
|
337
|
+
return text.replace(/\r?\n/g, " ").trim();
|
|
338
|
+
default:
|
|
339
|
+
return text.trim();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function buildDeprecationText(token) {
|
|
343
|
+
if (token.$deprecated == null || token.$deprecated === false) {
|
|
344
|
+
return "";
|
|
345
|
+
}
|
|
346
|
+
const msg = typeof token.$deprecated === "string" ? token.$deprecated : "";
|
|
347
|
+
return msg ? `DEPRECATED: ${msg}` : "DEPRECATED";
|
|
348
|
+
}
|
|
349
|
+
function buildTokenDescriptionComment(token, format) {
|
|
350
|
+
if (!token.$description || token.$description === "") {
|
|
351
|
+
return void 0;
|
|
352
|
+
}
|
|
353
|
+
const text = sanitizeText(token.$description, format);
|
|
354
|
+
switch (format) {
|
|
355
|
+
case "css":
|
|
356
|
+
case "tailwind":
|
|
357
|
+
return `/* ${text} */`;
|
|
358
|
+
case "js":
|
|
359
|
+
return `// ${text}`;
|
|
360
|
+
case "swift":
|
|
361
|
+
return `/// ${text}`;
|
|
362
|
+
case "kotlin":
|
|
363
|
+
return `/** ${text} */`;
|
|
364
|
+
default:
|
|
365
|
+
return void 0;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function buildTokenDeprecationComment(token, format) {
|
|
369
|
+
const text = buildDeprecationText(token);
|
|
370
|
+
if (!text) {
|
|
371
|
+
return void 0;
|
|
372
|
+
}
|
|
373
|
+
switch (format) {
|
|
374
|
+
case "css":
|
|
375
|
+
case "tailwind":
|
|
376
|
+
return `/* ${text} */`;
|
|
377
|
+
case "js":
|
|
378
|
+
return `// ${text}`;
|
|
379
|
+
case "swift":
|
|
380
|
+
return `/// ${text}`;
|
|
381
|
+
case "kotlin":
|
|
382
|
+
return `/** ${text} */`;
|
|
383
|
+
default:
|
|
384
|
+
return void 0;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
function buildModifierComment(modifier, context) {
|
|
388
|
+
return `/* Modifier: ${modifier}=${context} */`;
|
|
389
|
+
}
|
|
390
|
+
function buildSwiftDeprecationAttribute(token) {
|
|
391
|
+
if (token.$deprecated == null || token.$deprecated === false) {
|
|
392
|
+
return void 0;
|
|
393
|
+
}
|
|
394
|
+
const msg = typeof token.$deprecated === "string" ? token.$deprecated : "";
|
|
395
|
+
if (msg) {
|
|
396
|
+
return `@available(*, deprecated, message: "${sanitizeText(msg, "swift")}")`;
|
|
397
|
+
}
|
|
398
|
+
return "@available(*, deprecated)";
|
|
399
|
+
}
|
|
400
|
+
function buildKotlinDeprecationAnnotation(token) {
|
|
401
|
+
if (token.$deprecated == null || token.$deprecated === false) {
|
|
402
|
+
return void 0;
|
|
403
|
+
}
|
|
404
|
+
const msg = typeof token.$deprecated === "string" ? token.$deprecated : "";
|
|
405
|
+
if (msg) {
|
|
406
|
+
return `@Deprecated(message = "${sanitizeText(msg, "kotlin")}")`;
|
|
407
|
+
}
|
|
408
|
+
return "@Deprecated";
|
|
409
|
+
}
|
|
410
|
+
var init_metadata = __esm({
|
|
411
|
+
"src/renderers/metadata.ts"() {
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
|
|
340
415
|
// src/renderers/bundlers/js.ts
|
|
341
416
|
var js_exports = {};
|
|
342
417
|
__export(js_exports, {
|
|
@@ -441,7 +516,7 @@ async function bundleAsJsModule(bundleData, resolver, options, formatTokens) {
|
|
|
441
516
|
}
|
|
442
517
|
const metadata = buildMetadata(resolver);
|
|
443
518
|
const jsBlocks = [];
|
|
444
|
-
for (const { tokens, modifierInputs } of bundleData) {
|
|
519
|
+
for (const { tokens, modifierInputs, isBase } of bundleData) {
|
|
445
520
|
const cleanTokens = stripInternalMetadata(tokens);
|
|
446
521
|
const key = buildStableDashKey({
|
|
447
522
|
modifierInputs,
|
|
@@ -449,10 +524,30 @@ async function bundleAsJsModule(bundleData, resolver, options, formatTokens) {
|
|
|
449
524
|
defaults: metadata.defaults
|
|
450
525
|
});
|
|
451
526
|
const camelKey = toCamelKey(key);
|
|
527
|
+
const normalizedInputs = normalizeModifierInputs(modifierInputs);
|
|
528
|
+
const modifierParts = [];
|
|
529
|
+
for (const dim of metadata.dimensions) {
|
|
530
|
+
const value = normalizedInputs[dim.toLowerCase()];
|
|
531
|
+
if (value) {
|
|
532
|
+
modifierParts.push(`${dim}=${value}`);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
452
535
|
const formattedJs = await formatTokens(cleanTokens);
|
|
453
536
|
const tokenObject = extractObjectFromJsModule(formattedJs);
|
|
454
537
|
const indentedObject = tokenObject.replace(/\n/g, "\n ");
|
|
455
|
-
|
|
538
|
+
let comment;
|
|
539
|
+
if (modifierParts.length > 0) {
|
|
540
|
+
const modifierPart = modifierParts[0];
|
|
541
|
+
const eqIndex = modifierPart.indexOf("=");
|
|
542
|
+
const modifier = modifierPart.slice(0, eqIndex);
|
|
543
|
+
const context = modifierPart.slice(eqIndex + 1);
|
|
544
|
+
comment = buildModifierComment(modifier, context);
|
|
545
|
+
} else if (isBase) {
|
|
546
|
+
comment = "// Base permutation";
|
|
547
|
+
} else {
|
|
548
|
+
comment = `// ${key}`;
|
|
549
|
+
}
|
|
550
|
+
jsBlocks.push(` ${comment}
|
|
456
551
|
${JSON.stringify(camelKey)}: ${indentedObject}`);
|
|
457
552
|
}
|
|
458
553
|
return assembleJsBundle(metadata, jsBlocks, options?.generateHelper ?? false);
|
|
@@ -460,6 +555,7 @@ async function bundleAsJsModule(bundleData, resolver, options, formatTokens) {
|
|
|
460
555
|
var init_js = __esm({
|
|
461
556
|
"src/renderers/bundlers/js.ts"() {
|
|
462
557
|
init_errors();
|
|
558
|
+
init_metadata();
|
|
463
559
|
init_utils();
|
|
464
560
|
}
|
|
465
561
|
});
|
|
@@ -579,6 +675,7 @@ function durationObjectToString(duration) {
|
|
|
579
675
|
init_errors();
|
|
580
676
|
init_token_utils();
|
|
581
677
|
init_utils();
|
|
678
|
+
init_metadata();
|
|
582
679
|
|
|
583
680
|
// src/renderers/output-tree.ts
|
|
584
681
|
var outputTree = (files) => {
|
|
@@ -639,9 +736,6 @@ function resolveColorFormat(format) {
|
|
|
639
736
|
function escapeKotlinString(str) {
|
|
640
737
|
return str.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\$/g, "\\$");
|
|
641
738
|
}
|
|
642
|
-
function escapeKDoc(str) {
|
|
643
|
-
return str.replace(/\*\//g, "* /").replace(/\r?\n/g, " ").trim();
|
|
644
|
-
}
|
|
645
739
|
function formatKotlinNumber(value) {
|
|
646
740
|
return Number.isInteger(value) ? `${value}.0` : String(value);
|
|
647
741
|
}
|
|
@@ -773,8 +867,13 @@ var AndroidRenderer = class {
|
|
|
773
867
|
const kotlinName = this.buildFlatKotlinName(token);
|
|
774
868
|
const kotlinValue = this.formatKotlinValue(token, options, baseDepth + 1);
|
|
775
869
|
const annotation = this.typeAnnotationSuffix(token);
|
|
776
|
-
|
|
777
|
-
|
|
870
|
+
const descriptionComment = buildTokenDescriptionComment(token, "kotlin");
|
|
871
|
+
if (descriptionComment) {
|
|
872
|
+
lines.push(`${valIndent}${descriptionComment}`);
|
|
873
|
+
}
|
|
874
|
+
const deprecation = buildKotlinDeprecationAnnotation(token);
|
|
875
|
+
if (deprecation) {
|
|
876
|
+
lines.push(`${valIndent}${deprecation}`);
|
|
778
877
|
}
|
|
779
878
|
lines.push(
|
|
780
879
|
`${valIndent}${options.visPrefix}val ${kotlinName}${annotation} = ${kotlinValue}`
|
|
@@ -810,8 +909,13 @@ var AndroidRenderer = class {
|
|
|
810
909
|
const kotlinName = toSafeIdentifier(key, KOTLIN_KEYWORDS, false);
|
|
811
910
|
const kotlinValue = this.formatKotlinValue(token, options, depth);
|
|
812
911
|
const annotation = this.typeAnnotationSuffix(token);
|
|
813
|
-
|
|
814
|
-
|
|
912
|
+
const descriptionComment = buildTokenDescriptionComment(token, "kotlin");
|
|
913
|
+
if (descriptionComment) {
|
|
914
|
+
lines.push(`${pad}${descriptionComment}`);
|
|
915
|
+
}
|
|
916
|
+
const deprecation = buildKotlinDeprecationAnnotation(token);
|
|
917
|
+
if (deprecation) {
|
|
918
|
+
lines.push(`${pad}${deprecation}`);
|
|
815
919
|
}
|
|
816
920
|
lines.push(`${pad}${options.visPrefix}val ${kotlinName}${annotation} = ${kotlinValue}`);
|
|
817
921
|
}
|
|
@@ -1588,10 +1692,8 @@ function stableInputsKey(modifierInputs) {
|
|
|
1588
1692
|
|
|
1589
1693
|
// src/renderers/css.ts
|
|
1590
1694
|
init_utils();
|
|
1695
|
+
init_metadata();
|
|
1591
1696
|
var CssRenderer = class _CssRenderer {
|
|
1592
|
-
sanitizeCssCommentText(text) {
|
|
1593
|
-
return text.replace(/\*\//g, "*\\/").replace(/\r?\n/g, " ").trim();
|
|
1594
|
-
}
|
|
1595
1697
|
async format(context, options) {
|
|
1596
1698
|
const opts = {
|
|
1597
1699
|
preset: options?.preset ?? "bundle",
|
|
@@ -1671,12 +1773,13 @@ var CssRenderer = class _CssRenderer {
|
|
|
1671
1773
|
}
|
|
1672
1774
|
pushTokenLines(lines, token, tokens, referenceTokens, preserveReferences, indent, newline, space) {
|
|
1673
1775
|
const entries = this.buildCssEntries(token, tokens, referenceTokens, preserveReferences);
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
lines.push(`${indent}
|
|
1776
|
+
const deprecationComment = buildTokenDeprecationComment(token, "css");
|
|
1777
|
+
if (deprecationComment) {
|
|
1778
|
+
lines.push(`${indent}${deprecationComment}${newline}`);
|
|
1677
1779
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1780
|
+
const descriptionComment = buildTokenDescriptionComment(token, "css");
|
|
1781
|
+
if (descriptionComment) {
|
|
1782
|
+
lines.push(`${indent}${descriptionComment}${newline}`);
|
|
1680
1783
|
}
|
|
1681
1784
|
for (const entry of entries) {
|
|
1682
1785
|
lines.push(`${indent}--${entry.name}:${space}${entry.value};${newline}`);
|
|
@@ -2327,6 +2430,7 @@ function isBorderToken(token) {
|
|
|
2327
2430
|
|
|
2328
2431
|
// src/renderers/ios.ts
|
|
2329
2432
|
init_utils();
|
|
2433
|
+
init_metadata();
|
|
2330
2434
|
var toSRGB2 = culori.converter("rgb");
|
|
2331
2435
|
var toP32 = culori.converter("p3");
|
|
2332
2436
|
var SWIFT_TYPE_GROUP_MAP = {
|
|
@@ -2470,9 +2574,13 @@ var IosRenderer = class {
|
|
|
2470
2574
|
const swiftValue = this.formatSwiftValue(token, options);
|
|
2471
2575
|
const typeAnnotation = this.getTypeAnnotation(token);
|
|
2472
2576
|
const annotation = typeAnnotation ? `: ${typeAnnotation}` : "";
|
|
2473
|
-
const docComment =
|
|
2577
|
+
const docComment = buildTokenDescriptionComment(token, "swift");
|
|
2474
2578
|
if (docComment) {
|
|
2475
|
-
lines.push(docComment);
|
|
2579
|
+
lines.push(`${indent}${docComment}`);
|
|
2580
|
+
}
|
|
2581
|
+
const deprecationAttr = buildSwiftDeprecationAttribute(token);
|
|
2582
|
+
if (deprecationAttr) {
|
|
2583
|
+
lines.push(`${indent}${deprecationAttr}`);
|
|
2476
2584
|
}
|
|
2477
2585
|
lines.push(`${indent}${access} ${staticPrefix}${swiftName}${annotation} = ${swiftValue}`);
|
|
2478
2586
|
}
|
|
@@ -2487,15 +2595,6 @@ var IosRenderer = class {
|
|
|
2487
2595
|
}
|
|
2488
2596
|
return Array.from(imports).sort();
|
|
2489
2597
|
}
|
|
2490
|
-
/**
|
|
2491
|
-
* Builds a `///` doc comment from a token's `$description`, if present.
|
|
2492
|
-
*/
|
|
2493
|
-
buildDocComment(token, indent) {
|
|
2494
|
-
if (!token.$description) {
|
|
2495
|
-
return void 0;
|
|
2496
|
-
}
|
|
2497
|
-
return `${indent}/// ${token.$description}`;
|
|
2498
|
-
}
|
|
2499
2598
|
/**
|
|
2500
2599
|
* Builds a qualified Swift name from a token's path, preserving parent
|
|
2501
2600
|
* hierarchy segments to avoid duplicate identifiers.
|
|
@@ -2886,6 +2985,7 @@ function iosRenderer() {
|
|
|
2886
2985
|
// src/renderers/js-module.ts
|
|
2887
2986
|
init_utils();
|
|
2888
2987
|
init_token_utils();
|
|
2988
|
+
init_metadata();
|
|
2889
2989
|
var JsModuleRenderer = class {
|
|
2890
2990
|
async format(context, options) {
|
|
2891
2991
|
const opts = {
|
|
@@ -2923,17 +3023,10 @@ var JsModuleRenderer = class {
|
|
|
2923
3023
|
return outputTree(files);
|
|
2924
3024
|
}
|
|
2925
3025
|
async formatTokens(tokens, options) {
|
|
2926
|
-
const opts = {
|
|
2927
|
-
preset: options.preset ?? "standalone",
|
|
2928
|
-
structure: options.structure ?? "nested",
|
|
2929
|
-
minify: options.minify ?? false,
|
|
2930
|
-
moduleName: options.moduleName ?? "tokens",
|
|
2931
|
-
generateHelper: options.generateHelper ?? false
|
|
2932
|
-
};
|
|
2933
3026
|
const lines = [];
|
|
2934
|
-
lines.push(...this.formatAsObject(tokens,
|
|
3027
|
+
lines.push(...this.formatAsObject(tokens, options));
|
|
2935
3028
|
const code = lines.join("\n");
|
|
2936
|
-
if (
|
|
3029
|
+
if (options.minify) {
|
|
2937
3030
|
return code;
|
|
2938
3031
|
}
|
|
2939
3032
|
return await prettier__default.default.format(code, {
|
|
@@ -2946,20 +3039,53 @@ var JsModuleRenderer = class {
|
|
|
2946
3039
|
trailingComma: "es5"
|
|
2947
3040
|
});
|
|
2948
3041
|
}
|
|
2949
|
-
/**
|
|
2950
|
-
* Format as default export object
|
|
2951
|
-
*/
|
|
2952
3042
|
formatAsObject(tokens, options) {
|
|
2953
3043
|
const lines = [];
|
|
2954
|
-
const
|
|
3044
|
+
const tokenMap = this.buildTokenMap(tokens);
|
|
2955
3045
|
const varName = options.moduleName !== "" ? options.moduleName : "tokens";
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
3046
|
+
if (options.structure === "flat") {
|
|
3047
|
+
lines.push(`const ${varName} = {`);
|
|
3048
|
+
this.addFlatProperties(lines, tokens, 1);
|
|
3049
|
+
lines.push("}");
|
|
3050
|
+
} else {
|
|
3051
|
+
lines.push(`const ${varName} = {`);
|
|
3052
|
+
const tokenObj = this.tokensToPlainObject(tokens, "nested");
|
|
3053
|
+
this.addNestedProperties(lines, tokenObj, tokenMap, 1);
|
|
3054
|
+
lines.push("}");
|
|
3055
|
+
}
|
|
2959
3056
|
lines.push("");
|
|
2960
3057
|
lines.push(`export default ${varName}`);
|
|
2961
3058
|
return lines;
|
|
2962
3059
|
}
|
|
3060
|
+
buildTokenMap(tokens) {
|
|
3061
|
+
const map = /* @__PURE__ */ new Map();
|
|
3062
|
+
for (const [name, token] of Object.entries(tokens)) {
|
|
3063
|
+
map.set(name, token);
|
|
3064
|
+
}
|
|
3065
|
+
return map;
|
|
3066
|
+
}
|
|
3067
|
+
addFlatProperties(lines, tokens, indent) {
|
|
3068
|
+
const indentStr2 = " ".repeat(indent);
|
|
3069
|
+
const sortedEntries = getSortedTokenEntries(tokens);
|
|
3070
|
+
for (let i = 0; i < sortedEntries.length; i++) {
|
|
3071
|
+
const [name, token] = sortedEntries[i];
|
|
3072
|
+
const isLast = i === sortedEntries.length - 1;
|
|
3073
|
+
this.pushTokenComments(lines, token, indentStr2);
|
|
3074
|
+
lines.push(
|
|
3075
|
+
`${indentStr2}${this.quoteKey(name)}: ${JSON.stringify(token.$value)}${isLast ? "" : ","}`
|
|
3076
|
+
);
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
pushTokenComments(lines, token, indent) {
|
|
3080
|
+
const deprecationComment = buildTokenDeprecationComment(token, "js");
|
|
3081
|
+
if (deprecationComment) {
|
|
3082
|
+
lines.push(`${indent}${deprecationComment}`);
|
|
3083
|
+
}
|
|
3084
|
+
const descriptionComment = buildTokenDescriptionComment(token, "js");
|
|
3085
|
+
if (descriptionComment) {
|
|
3086
|
+
lines.push(`${indent}${descriptionComment}`);
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
2963
3089
|
tokensToPlainObject(tokens, structure) {
|
|
2964
3090
|
if (structure === "nested") {
|
|
2965
3091
|
return buildNestedTokenObject(tokens, (token) => token.$value);
|
|
@@ -2970,7 +3096,7 @@ var JsModuleRenderer = class {
|
|
|
2970
3096
|
}
|
|
2971
3097
|
return result;
|
|
2972
3098
|
}
|
|
2973
|
-
|
|
3099
|
+
addNestedProperties(lines, obj, tokenMap, indent) {
|
|
2974
3100
|
const indentStr2 = " ".repeat(indent);
|
|
2975
3101
|
const entries = Object.entries(obj).sort(([keyA], [keyB]) => keyA.localeCompare(keyB));
|
|
2976
3102
|
for (let i = 0; i < entries.length; i++) {
|
|
@@ -2982,19 +3108,20 @@ var JsModuleRenderer = class {
|
|
|
2982
3108
|
const isLast = i === entries.length - 1;
|
|
2983
3109
|
const isNestedObject = typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2984
3110
|
if (!isNestedObject) {
|
|
3111
|
+
const token = tokenMap.get(key);
|
|
3112
|
+
if (token) {
|
|
3113
|
+
this.pushTokenComments(lines, token, indentStr2);
|
|
3114
|
+
}
|
|
2985
3115
|
lines.push(
|
|
2986
3116
|
`${indentStr2}${this.quoteKey(key)}: ${JSON.stringify(value)}${isLast ? "" : ","}`
|
|
2987
3117
|
);
|
|
2988
3118
|
continue;
|
|
2989
3119
|
}
|
|
2990
3120
|
lines.push(`${indentStr2}${this.quoteKey(key)}: {`);
|
|
2991
|
-
this.
|
|
3121
|
+
this.addNestedProperties(lines, value, tokenMap, indent + 1);
|
|
2992
3122
|
lines.push(`${indentStr2}}${isLast ? "" : ","}`);
|
|
2993
3123
|
}
|
|
2994
3124
|
}
|
|
2995
|
-
/**
|
|
2996
|
-
* Quote key if necessary
|
|
2997
|
-
*/
|
|
2998
3125
|
quoteKey(key) {
|
|
2999
3126
|
if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)) {
|
|
3000
3127
|
return key;
|
|
@@ -3230,6 +3357,7 @@ function resolveOptions(options) {
|
|
|
3230
3357
|
|
|
3231
3358
|
// src/renderers/tailwind.ts
|
|
3232
3359
|
init_utils();
|
|
3360
|
+
init_metadata();
|
|
3233
3361
|
var TAILWIND_NAMESPACE_MAP = {
|
|
3234
3362
|
color: "color",
|
|
3235
3363
|
dimension: "spacing",
|
|
@@ -3283,6 +3411,14 @@ var TailwindRenderer = class {
|
|
|
3283
3411
|
for (const [, token] of getSortedTokenEntries(tokens)) {
|
|
3284
3412
|
const varName = this.buildVariableName(token);
|
|
3285
3413
|
const varValue = this.formatValue(token);
|
|
3414
|
+
const deprecationComment = buildTokenDeprecationComment(token, "tailwind");
|
|
3415
|
+
if (deprecationComment) {
|
|
3416
|
+
lines.push(`${indent}${deprecationComment}${newline}`);
|
|
3417
|
+
}
|
|
3418
|
+
const descriptionComment = buildTokenDescriptionComment(token, "tailwind");
|
|
3419
|
+
if (descriptionComment) {
|
|
3420
|
+
lines.push(`${indent}${descriptionComment}${newline}`);
|
|
3421
|
+
}
|
|
3286
3422
|
lines.push(`${indent}--${varName}:${space}${varValue};${newline}`);
|
|
3287
3423
|
}
|
|
3288
3424
|
lines.push(`}${newline}`);
|
|
@@ -3309,6 +3445,14 @@ var TailwindRenderer = class {
|
|
|
3309
3445
|
for (const [, token] of getSortedTokenEntries(tokens)) {
|
|
3310
3446
|
const varName = this.buildVariableName(token);
|
|
3311
3447
|
const varValue = this.formatValue(token);
|
|
3448
|
+
const deprecationComment = buildTokenDeprecationComment(token, "tailwind");
|
|
3449
|
+
if (deprecationComment) {
|
|
3450
|
+
lines.push(`${tokenIndent}${deprecationComment}${newline}`);
|
|
3451
|
+
}
|
|
3452
|
+
const descriptionComment = buildTokenDescriptionComment(token, "tailwind");
|
|
3453
|
+
if (descriptionComment) {
|
|
3454
|
+
lines.push(`${tokenIndent}${descriptionComment}${newline}`);
|
|
3455
|
+
}
|
|
3312
3456
|
lines.push(`${tokenIndent}--${varName}:${space}${varValue};${newline}`);
|
|
3313
3457
|
}
|
|
3314
3458
|
if (hasMediaQuery) {
|