@pandacss/node 0.40.1 → 0.42.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/index.d.mts +3 -119
- package/dist/index.d.ts +3 -119
- package/dist/index.js +253 -158
- package/dist/index.mjs +253 -158
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/.pnpm/tsup@8.0.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.4.0_postcss@8.4.39_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@8.0.
|
|
38
|
+
"../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.4.0_postcss@8.4.39_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
39
|
"use strict";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -428,49 +428,53 @@ init_cjs_shims();
|
|
|
428
428
|
var import_logger = require("@pandacss/logger");
|
|
429
429
|
var import_filesize = require("filesize");
|
|
430
430
|
var import_promises = require("fs/promises");
|
|
431
|
+
var import_node_path = __toESM(require("path"));
|
|
431
432
|
var import_zlib = __toESM(require("zlib"));
|
|
432
433
|
|
|
434
|
+
// package.json
|
|
435
|
+
var version = "0.42.0";
|
|
436
|
+
|
|
433
437
|
// src/classify.ts
|
|
434
438
|
init_cjs_shims();
|
|
435
439
|
var import_extractor = require("@pandacss/extractor");
|
|
436
440
|
var createReportMaps = () => {
|
|
437
|
-
const
|
|
441
|
+
const byComponentOfKind = /* @__PURE__ */ new Map();
|
|
438
442
|
const byPropertyName = /* @__PURE__ */ new Map();
|
|
439
|
-
const
|
|
443
|
+
const byTokenType = /* @__PURE__ */ new Map();
|
|
440
444
|
const byConditionName = /* @__PURE__ */ new Map();
|
|
441
445
|
const byShorthand = /* @__PURE__ */ new Map();
|
|
442
446
|
const byTokenName = /* @__PURE__ */ new Map();
|
|
443
447
|
const byPropertyPath = /* @__PURE__ */ new Map();
|
|
444
448
|
const fromKind = /* @__PURE__ */ new Map();
|
|
445
449
|
const byType = /* @__PURE__ */ new Map();
|
|
446
|
-
const
|
|
450
|
+
const byComponentName = /* @__PURE__ */ new Map();
|
|
447
451
|
const colorsUsed = /* @__PURE__ */ new Map();
|
|
448
452
|
return {
|
|
449
|
-
|
|
453
|
+
byComponentOfKind,
|
|
450
454
|
byPropertyName,
|
|
451
|
-
|
|
455
|
+
byTokenType,
|
|
452
456
|
byConditionName,
|
|
453
457
|
byShorthand,
|
|
454
458
|
byTokenName,
|
|
455
459
|
byPropertyPath,
|
|
456
460
|
fromKind,
|
|
457
461
|
byType,
|
|
458
|
-
|
|
462
|
+
byComponentName,
|
|
459
463
|
colorsUsed
|
|
460
464
|
};
|
|
461
465
|
};
|
|
462
|
-
var colorPropNames = /* @__PURE__ */ new Set(["background", "outline", "border"]);
|
|
463
466
|
var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
464
467
|
const byId = /* @__PURE__ */ new Map();
|
|
465
|
-
const
|
|
468
|
+
const byComponentIndex = /* @__PURE__ */ new Map();
|
|
466
469
|
const byFilepath = /* @__PURE__ */ new Map();
|
|
467
|
-
const
|
|
470
|
+
const byComponentInFilepath = /* @__PURE__ */ new Map();
|
|
468
471
|
const globalMaps = createReportMaps();
|
|
469
472
|
const byFilePathMaps = /* @__PURE__ */ new Map();
|
|
470
473
|
const conditions = new Map(Object.entries(ctx.conditions.values));
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
+
const { groupByProp } = getPropertyGroupMap(ctx);
|
|
475
|
+
let id = 0, componentIndex = 0;
|
|
476
|
+
const isKnownUtility = (reportItem, componentReportItem) => {
|
|
477
|
+
const { propName, value } = reportItem;
|
|
474
478
|
const utility = ctx.config.utilities?.[propName];
|
|
475
479
|
if (utility) {
|
|
476
480
|
if (!utility.shorthand) {
|
|
@@ -478,8 +482,8 @@ var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
|
478
482
|
}
|
|
479
483
|
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
480
484
|
}
|
|
481
|
-
if (
|
|
482
|
-
const pattern = ctx.patterns.getConfig(
|
|
485
|
+
if (componentReportItem.reportItemType === "pattern") {
|
|
486
|
+
const pattern = ctx.patterns.getConfig(componentReportItem.componentName.toLowerCase());
|
|
483
487
|
const patternProp = pattern?.properties?.[propName];
|
|
484
488
|
if (!patternProp)
|
|
485
489
|
return false;
|
|
@@ -508,75 +512,82 @@ var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
|
508
512
|
set.add(value);
|
|
509
513
|
map.set(key, set);
|
|
510
514
|
};
|
|
511
|
-
const processMap = (map, current,
|
|
512
|
-
const {
|
|
515
|
+
const processMap = (map, current, componentReportItem) => {
|
|
516
|
+
const { reportItemType: type, kind } = componentReportItem;
|
|
517
|
+
const name = componentReportItem.componentName;
|
|
513
518
|
map.value.forEach((attrNode, attrName) => {
|
|
514
519
|
if (import_extractor.box.isLiteral(attrNode) || import_extractor.box.isEmptyInitializer(attrNode)) {
|
|
515
520
|
const value = import_extractor.box.isLiteral(attrNode) ? attrNode.value : true;
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
521
|
+
const propReportItem = {
|
|
522
|
+
index: String(id++),
|
|
523
|
+
componentIndex: String(componentReportItem.componentIndex),
|
|
524
|
+
componentName: name,
|
|
525
|
+
tokenType: void 0,
|
|
520
526
|
propName: attrName,
|
|
521
|
-
|
|
522
|
-
type,
|
|
527
|
+
reportItemKind: "utility",
|
|
528
|
+
reportItemType: type,
|
|
523
529
|
kind,
|
|
524
530
|
filepath,
|
|
525
531
|
path: current.concat(attrName),
|
|
526
532
|
value,
|
|
527
|
-
|
|
528
|
-
|
|
533
|
+
isKnownValue: false,
|
|
534
|
+
range: map.getRange()
|
|
529
535
|
};
|
|
530
|
-
|
|
536
|
+
componentReportItem.contains.push(propReportItem.index);
|
|
531
537
|
if (conditions.has(attrName)) {
|
|
532
|
-
addTo(globalMaps.byConditionName, attrName,
|
|
533
|
-
addTo(localMaps.byConditionName, attrName,
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
538
|
+
addTo(globalMaps.byConditionName, attrName, propReportItem.index);
|
|
539
|
+
addTo(localMaps.byConditionName, attrName, propReportItem.index);
|
|
540
|
+
propReportItem.propName = current[0] ?? attrName;
|
|
541
|
+
propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
|
|
542
|
+
propReportItem.conditionName = attrName;
|
|
537
543
|
} else {
|
|
538
544
|
if (current.length && conditions.has(current[0])) {
|
|
539
|
-
|
|
540
|
-
addTo(globalMaps.byConditionName, current[0],
|
|
541
|
-
addTo(localMaps.byConditionName, current[0],
|
|
545
|
+
propReportItem.conditionName = current[0];
|
|
546
|
+
addTo(globalMaps.byConditionName, current[0], propReportItem.index);
|
|
547
|
+
addTo(localMaps.byConditionName, current[0], propReportItem.index);
|
|
542
548
|
}
|
|
543
549
|
const propName = ctx.utility.shorthands.get(attrName) ?? attrName;
|
|
544
|
-
|
|
550
|
+
propReportItem.propName = propName;
|
|
545
551
|
const utility = ctx.config.utilities?.[propName];
|
|
546
|
-
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
addTo(
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
addTo(
|
|
552
|
+
propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
|
|
553
|
+
const tokenType = typeof utility?.values === "string" ? utility?.values : void 0;
|
|
554
|
+
if (tokenType) {
|
|
555
|
+
propReportItem.reportItemKind = "token";
|
|
556
|
+
propReportItem.tokenType = tokenType;
|
|
557
|
+
}
|
|
558
|
+
addTo(globalMaps.byPropertyName, propName, propReportItem.index);
|
|
559
|
+
addTo(localMaps.byPropertyName, propName, propReportItem.index);
|
|
560
|
+
if (tokenType) {
|
|
561
|
+
addTo(globalMaps.byTokenType, tokenType, propReportItem.index);
|
|
562
|
+
addTo(localMaps.byTokenType, tokenType, propReportItem.index);
|
|
563
|
+
}
|
|
564
|
+
if (propName.toLowerCase().includes("color") || groupByProp.get(propName) === "Color" || tokenType === "colors") {
|
|
565
|
+
addTo(globalMaps.colorsUsed, value, propReportItem.index);
|
|
566
|
+
addTo(localMaps.colorsUsed, value, propReportItem.index);
|
|
556
567
|
}
|
|
557
568
|
if (ctx.utility.shorthands.has(attrName)) {
|
|
558
|
-
addTo(globalMaps.byShorthand, attrName,
|
|
559
|
-
addTo(localMaps.byShorthand, attrName,
|
|
569
|
+
addTo(globalMaps.byShorthand, attrName, propReportItem.index);
|
|
570
|
+
addTo(localMaps.byShorthand, attrName, propReportItem.index);
|
|
560
571
|
}
|
|
561
572
|
}
|
|
562
573
|
if (current.length) {
|
|
563
|
-
addTo(globalMaps.byPropertyPath,
|
|
564
|
-
addTo(localMaps.byPropertyPath,
|
|
574
|
+
addTo(globalMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
|
|
575
|
+
addTo(localMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
|
|
565
576
|
}
|
|
566
|
-
addTo(globalMaps.byTokenName, String(value),
|
|
567
|
-
addTo(localMaps.byTokenName, String(value),
|
|
568
|
-
addTo(globalMaps.byType, type,
|
|
569
|
-
addTo(localMaps.byType, type,
|
|
570
|
-
addTo(globalMaps.
|
|
571
|
-
addTo(localMaps.
|
|
572
|
-
addTo(globalMaps.fromKind, kind,
|
|
573
|
-
addTo(localMaps.fromKind, kind,
|
|
574
|
-
addTo(byFilepath, filepath,
|
|
575
|
-
byId.set(
|
|
577
|
+
addTo(globalMaps.byTokenName, String(value), propReportItem.index);
|
|
578
|
+
addTo(localMaps.byTokenName, String(value), propReportItem.index);
|
|
579
|
+
addTo(globalMaps.byType, type, propReportItem.index);
|
|
580
|
+
addTo(localMaps.byType, type, propReportItem.index);
|
|
581
|
+
addTo(globalMaps.byComponentName, name, propReportItem.index);
|
|
582
|
+
addTo(localMaps.byComponentName, name, propReportItem.index);
|
|
583
|
+
addTo(globalMaps.fromKind, kind, propReportItem.index);
|
|
584
|
+
addTo(localMaps.fromKind, kind, propReportItem.index);
|
|
585
|
+
addTo(byFilepath, filepath, propReportItem.index);
|
|
586
|
+
byId.set(propReportItem.index, propReportItem);
|
|
576
587
|
return;
|
|
577
588
|
}
|
|
578
589
|
if (import_extractor.box.isMap(attrNode) && attrNode.value.size) {
|
|
579
|
-
return processMap(attrNode, current.concat(attrName),
|
|
590
|
+
return processMap(attrNode, current.concat(attrName), componentReportItem);
|
|
580
591
|
}
|
|
581
592
|
});
|
|
582
593
|
};
|
|
@@ -585,45 +596,44 @@ var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
|
585
596
|
return;
|
|
586
597
|
}
|
|
587
598
|
if (!item.data) {
|
|
599
|
+
console.log("no data", item);
|
|
588
600
|
return;
|
|
589
601
|
}
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
from,
|
|
595
|
-
type,
|
|
602
|
+
const componentReportItem = {
|
|
603
|
+
componentIndex: String(componentIndex++),
|
|
604
|
+
componentName: item.name,
|
|
605
|
+
reportItemType: item.type,
|
|
596
606
|
kind,
|
|
597
607
|
filepath,
|
|
598
608
|
value: item.data,
|
|
599
|
-
|
|
609
|
+
range: item.box.getRange(),
|
|
600
610
|
contains: []
|
|
601
611
|
};
|
|
602
612
|
if (import_extractor.box.isArray(item.box)) {
|
|
603
|
-
addTo(
|
|
604
|
-
return
|
|
613
|
+
addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
|
|
614
|
+
return componentReportItem;
|
|
605
615
|
}
|
|
606
616
|
if (import_extractor.box.isMap(item.box) && item.box.value.size) {
|
|
607
|
-
addTo(
|
|
608
|
-
processMap(item.box, [],
|
|
609
|
-
return
|
|
617
|
+
addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
|
|
618
|
+
processMap(item.box, [], componentReportItem);
|
|
619
|
+
return componentReportItem;
|
|
610
620
|
}
|
|
611
621
|
};
|
|
612
622
|
const processComponentResultItem = (item) => {
|
|
613
|
-
const
|
|
614
|
-
if (!
|
|
623
|
+
const componentReportItem = processResultItem(item, "component");
|
|
624
|
+
if (!componentReportItem)
|
|
615
625
|
return;
|
|
616
|
-
addTo(globalMaps.
|
|
617
|
-
addTo(localMaps.
|
|
618
|
-
|
|
626
|
+
addTo(globalMaps.byComponentOfKind, "component", componentReportItem.componentIndex);
|
|
627
|
+
addTo(localMaps.byComponentOfKind, "component", componentReportItem.componentIndex);
|
|
628
|
+
byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
|
|
619
629
|
};
|
|
620
630
|
const processFunctionResultItem = (item) => {
|
|
621
|
-
const
|
|
622
|
-
if (!
|
|
631
|
+
const componentReportItem = processResultItem(item, "function");
|
|
632
|
+
if (!componentReportItem)
|
|
623
633
|
return;
|
|
624
|
-
addTo(globalMaps.
|
|
625
|
-
addTo(localMaps.
|
|
626
|
-
|
|
634
|
+
addTo(globalMaps.byComponentOfKind, "function", componentReportItem.componentIndex);
|
|
635
|
+
addTo(localMaps.byComponentOfKind, "function", componentReportItem.componentIndex);
|
|
636
|
+
byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
|
|
627
637
|
};
|
|
628
638
|
parserResult.jsx.forEach(processComponentResultItem);
|
|
629
639
|
parserResult.css.forEach(processFunctionResultItem);
|
|
@@ -637,37 +647,33 @@ var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
|
637
647
|
byFilePathMaps.set(filepath, localMaps);
|
|
638
648
|
});
|
|
639
649
|
const pickCount = 10;
|
|
640
|
-
const
|
|
641
|
-
Array.from(
|
|
642
|
-
);
|
|
643
|
-
const filesWithMostPropValueCombinations = Object.fromEntries(
|
|
644
|
-
Array.from(byFilepath.entries()).map(([token, list]) => [token, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
|
|
650
|
+
const filesWithMostComponent = Object.fromEntries(
|
|
651
|
+
Array.from(byComponentInFilepath.entries()).map(([filepath, list]) => [filepath, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
|
|
645
652
|
);
|
|
646
653
|
return {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
propNameUsed: globalMaps.byPropertyName.size,
|
|
650
|
-
tokenUsed: globalMaps.byTokenName.size,
|
|
651
|
-
shorthandUsed: globalMaps.byShorthand.size,
|
|
652
|
-
propertyPathUsed: globalMaps.byPropertyPath.size,
|
|
653
|
-
typeUsed: globalMaps.byType.size,
|
|
654
|
-
instanceNameUsed: globalMaps.byInstanceName.size,
|
|
655
|
-
kindUsed: globalMaps.fromKind.size,
|
|
656
|
-
instanceOfKindUsed: globalMaps.byInstanceOfKind.size,
|
|
657
|
-
colorsUsed: globalMaps.colorsUsed.size
|
|
658
|
-
},
|
|
659
|
-
stats: {
|
|
660
|
-
//
|
|
661
|
-
filesWithMostInstance,
|
|
662
|
-
filesWithMostPropValueCombinations,
|
|
663
|
-
//
|
|
664
|
-
mostUseds: getXMostUseds(globalMaps, 10)
|
|
665
|
-
},
|
|
654
|
+
propById: byId,
|
|
655
|
+
componentById: byComponentIndex,
|
|
666
656
|
details: {
|
|
667
|
-
|
|
668
|
-
|
|
657
|
+
counts: {
|
|
658
|
+
filesWithTokens: byFilepath.size,
|
|
659
|
+
propNameUsed: globalMaps.byPropertyName.size,
|
|
660
|
+
tokenUsed: globalMaps.byTokenName.size,
|
|
661
|
+
shorthandUsed: globalMaps.byShorthand.size,
|
|
662
|
+
propertyPathUsed: globalMaps.byPropertyPath.size,
|
|
663
|
+
typeUsed: globalMaps.byType.size,
|
|
664
|
+
componentNameUsed: globalMaps.byComponentName.size,
|
|
665
|
+
kindUsed: globalMaps.fromKind.size,
|
|
666
|
+
componentOfKindUsed: globalMaps.byComponentOfKind.size,
|
|
667
|
+
colorsUsed: globalMaps.colorsUsed.size
|
|
668
|
+
},
|
|
669
|
+
stats: {
|
|
670
|
+
filesWithMostComponent,
|
|
671
|
+
mostUseds: getXMostUseds(globalMaps, 10)
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
derived: {
|
|
669
675
|
byFilepath,
|
|
670
|
-
|
|
676
|
+
byComponentInFilepath,
|
|
671
677
|
globalMaps,
|
|
672
678
|
byFilePathMaps
|
|
673
679
|
}
|
|
@@ -680,17 +686,78 @@ var getXMostUseds = (globalMaps, pickCount) => {
|
|
|
680
686
|
shorthands: getMostUsedInMap(globalMaps.byShorthand, pickCount),
|
|
681
687
|
conditions: getMostUsedInMap(globalMaps.byConditionName, pickCount),
|
|
682
688
|
propertyPaths: getMostUsedInMap(globalMaps.byPropertyPath, pickCount),
|
|
683
|
-
categories: getMostUsedInMap(globalMaps.
|
|
689
|
+
categories: getMostUsedInMap(globalMaps.byTokenType, pickCount),
|
|
684
690
|
types: getMostUsedInMap(globalMaps.byType, pickCount),
|
|
685
|
-
|
|
691
|
+
componentNames: getMostUsedInMap(globalMaps.byComponentName, pickCount),
|
|
686
692
|
fromKinds: getMostUsedInMap(globalMaps.fromKind, pickCount),
|
|
687
|
-
|
|
693
|
+
componentOfKinds: getMostUsedInMap(globalMaps.byComponentOfKind, pickCount),
|
|
688
694
|
colors: getMostUsedInMap(globalMaps.colorsUsed, pickCount)
|
|
689
695
|
};
|
|
690
696
|
};
|
|
691
697
|
var getMostUsedInMap = (map, pickCount) => {
|
|
692
698
|
return Array.from(map.entries()).map(([key, list]) => [key, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount).map(([key, count]) => ({ key, count }));
|
|
693
699
|
};
|
|
700
|
+
var defaultGroupNames = [
|
|
701
|
+
"System",
|
|
702
|
+
"Container",
|
|
703
|
+
"Display",
|
|
704
|
+
"Visibility",
|
|
705
|
+
"Position",
|
|
706
|
+
"Transform",
|
|
707
|
+
"Flex Layout",
|
|
708
|
+
"Grid Layout",
|
|
709
|
+
"Layout",
|
|
710
|
+
"Border",
|
|
711
|
+
"Border Radius",
|
|
712
|
+
"Width",
|
|
713
|
+
"Height",
|
|
714
|
+
"Margin",
|
|
715
|
+
"Padding",
|
|
716
|
+
"Color",
|
|
717
|
+
"Typography",
|
|
718
|
+
"Background",
|
|
719
|
+
"Shadow",
|
|
720
|
+
"Table",
|
|
721
|
+
"List",
|
|
722
|
+
"Scroll",
|
|
723
|
+
"Interactivity",
|
|
724
|
+
"Transition",
|
|
725
|
+
"Effect",
|
|
726
|
+
"Other"
|
|
727
|
+
];
|
|
728
|
+
var getPropertyGroupMap = (context) => {
|
|
729
|
+
const groups = new Map(defaultGroupNames.map((name) => [name, /* @__PURE__ */ new Set()]));
|
|
730
|
+
const groupByProp = /* @__PURE__ */ new Map();
|
|
731
|
+
const systemGroup = groups.get("System");
|
|
732
|
+
systemGroup.add("base");
|
|
733
|
+
systemGroup.add("colorPalette");
|
|
734
|
+
const otherStyleProps = groups.get("Other");
|
|
735
|
+
Object.entries(context.utility.config).map(([key, value]) => {
|
|
736
|
+
const group = value?.group;
|
|
737
|
+
if (!group) {
|
|
738
|
+
otherStyleProps.add(key);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
if (!groups.has(group)) {
|
|
742
|
+
groups.set(group, /* @__PURE__ */ new Set());
|
|
743
|
+
}
|
|
744
|
+
const set = groups.get(group);
|
|
745
|
+
if (value.shorthand) {
|
|
746
|
+
if (Array.isArray(value.shorthand)) {
|
|
747
|
+
value.shorthand.forEach((shorthand) => {
|
|
748
|
+
set.add(shorthand);
|
|
749
|
+
groupByProp.set(shorthand, group);
|
|
750
|
+
});
|
|
751
|
+
} else {
|
|
752
|
+
set.add(value.shorthand);
|
|
753
|
+
groupByProp.set(value.shorthand, group);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
set.add(key);
|
|
757
|
+
groupByProp.set(key, group);
|
|
758
|
+
});
|
|
759
|
+
return { groups, groupByProp };
|
|
760
|
+
};
|
|
694
761
|
|
|
695
762
|
// src/analyze-tokens.ts
|
|
696
763
|
var gzipSizeSync = (code) => import_zlib.default.gzipSync(code, { level: import_zlib.default.constants.Z_BEST_COMPRESSION }).length;
|
|
@@ -698,34 +765,66 @@ function analyzeTokens(ctx, options = {}) {
|
|
|
698
765
|
const filesMap = /* @__PURE__ */ new Map();
|
|
699
766
|
const timesMap = /* @__PURE__ */ new Map();
|
|
700
767
|
const files = ctx.getFiles();
|
|
768
|
+
const sheet = ctx.createSheet();
|
|
769
|
+
ctx.appendLayerParams(sheet);
|
|
770
|
+
ctx.appendBaselineCss(sheet);
|
|
701
771
|
files.forEach((file) => {
|
|
702
772
|
const start2 = performance.now();
|
|
703
773
|
const result = ctx.project.parseSourceFile(file);
|
|
704
774
|
const extractMs = performance.now() - start2;
|
|
705
|
-
|
|
775
|
+
const relativePath = import_node_path.default.relative(ctx.config.cwd, file);
|
|
776
|
+
timesMap.set(relativePath, extractMs);
|
|
706
777
|
import_logger.logger.debug("analyze", `Parsed ${file} in ${extractMs}ms`);
|
|
707
778
|
if (result) {
|
|
708
|
-
filesMap.set(
|
|
779
|
+
filesMap.set(relativePath, result);
|
|
709
780
|
options.onResult?.(file, result);
|
|
710
781
|
}
|
|
711
782
|
});
|
|
712
783
|
const totalMs = Array.from(timesMap.values()).reduce((a, b) => a + b, 0);
|
|
713
784
|
import_logger.logger.debug("analyze", `Analyzed ${files.length} files in ${totalMs.toFixed(2)}ms`);
|
|
714
|
-
|
|
715
|
-
|
|
785
|
+
ctx.appendParserCss(sheet);
|
|
786
|
+
const cssStart = performance.now();
|
|
716
787
|
ctx.config.minify = false;
|
|
717
|
-
const css =
|
|
718
|
-
const
|
|
719
|
-
|
|
788
|
+
const css = ctx.getCss(sheet);
|
|
789
|
+
const cssMs = performance.now() - cssStart;
|
|
790
|
+
const cssMinifyStart = performance.now();
|
|
791
|
+
ctx.config.minify = true;
|
|
792
|
+
const minifiedCss = ctx.getCss(sheet);
|
|
793
|
+
const cssMinifyMs = performance.now() - cssMinifyStart;
|
|
794
|
+
let lightningCss = "";
|
|
795
|
+
let lightningCssMs;
|
|
796
|
+
let lightningCssMinifiedCss = "";
|
|
797
|
+
let lightningCssMinifiedMs;
|
|
798
|
+
const isUsingLightningCss = ctx.config.lightningcss;
|
|
799
|
+
if (!isUsingLightningCss) {
|
|
800
|
+
sheet["context"].lightningcss = true;
|
|
801
|
+
ctx.config.minify = false;
|
|
802
|
+
const lightningcssStart = performance.now();
|
|
803
|
+
lightningCss = ctx.getCss(sheet);
|
|
804
|
+
lightningCssMs = performance.now() - lightningcssStart;
|
|
805
|
+
ctx.config.minify = true;
|
|
806
|
+
const lightningcssMinifyStart = performance.now();
|
|
807
|
+
lightningCssMinifiedCss = ctx.getCss(sheet);
|
|
808
|
+
lightningCssMinifiedMs = performance.now() - lightningcssMinifyStart;
|
|
809
|
+
}
|
|
720
810
|
const start = performance.now();
|
|
721
811
|
const analysis = classifyTokens(ctx, filesMap);
|
|
722
812
|
const classifyMs = performance.now() - start;
|
|
723
|
-
|
|
813
|
+
const details = Object.assign(
|
|
724
814
|
{
|
|
725
815
|
duration: {
|
|
726
|
-
|
|
816
|
+
classify: classifyMs,
|
|
817
|
+
//
|
|
818
|
+
cssMs,
|
|
819
|
+
cssMinifyMs,
|
|
820
|
+
//
|
|
821
|
+
...!isUsingLightningCss ? {
|
|
822
|
+
lightningCssMs,
|
|
823
|
+
lightningCssMinifiedMs
|
|
824
|
+
} : {},
|
|
825
|
+
//
|
|
727
826
|
extractTotal: totalMs,
|
|
728
|
-
|
|
827
|
+
extractTimeByFiles: Object.fromEntries(timesMap.entries())
|
|
729
828
|
},
|
|
730
829
|
fileSizes: {
|
|
731
830
|
lineCount: css.split("\n").length,
|
|
@@ -734,11 +833,24 @@ function analyzeTokens(ctx, options = {}) {
|
|
|
734
833
|
gzip: {
|
|
735
834
|
normal: (0, import_filesize.filesize)(gzipSizeSync(css)),
|
|
736
835
|
minified: (0, import_filesize.filesize)(gzipSizeSync(minifiedCss))
|
|
737
|
-
}
|
|
836
|
+
},
|
|
837
|
+
lightningCss: !isUsingLightningCss ? {
|
|
838
|
+
normal: (0, import_filesize.filesize)(Buffer.byteLength(lightningCss, "utf-8")),
|
|
839
|
+
minified: (0, import_filesize.filesize)(Buffer.byteLength(lightningCssMinifiedCss, "utf-8"))
|
|
840
|
+
} : void 0
|
|
738
841
|
}
|
|
739
842
|
},
|
|
740
|
-
analysis
|
|
843
|
+
analysis.details
|
|
741
844
|
);
|
|
845
|
+
const { globalCss, ...config } = ctx.config;
|
|
846
|
+
return {
|
|
847
|
+
schemaVersion: version,
|
|
848
|
+
details,
|
|
849
|
+
propByIndex: analysis.propById,
|
|
850
|
+
componentByIndex: analysis.componentById,
|
|
851
|
+
derived: analysis.derived,
|
|
852
|
+
config
|
|
853
|
+
};
|
|
742
854
|
}
|
|
743
855
|
var analyzeResultSerializer = (_key, value) => {
|
|
744
856
|
if (value instanceof Set) {
|
|
@@ -750,25 +862,9 @@ var analyzeResultSerializer = (_key, value) => {
|
|
|
750
862
|
return value;
|
|
751
863
|
};
|
|
752
864
|
var writeAnalyzeJSON = (filePath, result, ctx) => {
|
|
753
|
-
result.details.byInstanceId.forEach((item) => {
|
|
754
|
-
item.box = item.box.toJSON();
|
|
755
|
-
});
|
|
756
865
|
const dirname2 = ctx.runtime.path.dirname(filePath);
|
|
757
866
|
ctx.runtime.fs.ensureDirSync(dirname2);
|
|
758
|
-
return (0, import_promises.writeFile)(
|
|
759
|
-
filePath,
|
|
760
|
-
JSON.stringify(
|
|
761
|
-
Object.assign(result, {
|
|
762
|
-
cwd: ctx.config.cwd,
|
|
763
|
-
theme: ctx.config.theme,
|
|
764
|
-
utilities: ctx.config.utilities,
|
|
765
|
-
conditions: ctx.config.conditions,
|
|
766
|
-
shorthands: ctx.utility.shorthands
|
|
767
|
-
}),
|
|
768
|
-
analyzeResultSerializer,
|
|
769
|
-
2
|
|
770
|
-
)
|
|
771
|
-
);
|
|
867
|
+
return (0, import_promises.writeFile)(filePath, JSON.stringify(result, analyzeResultSerializer, 2));
|
|
772
868
|
};
|
|
773
869
|
|
|
774
870
|
// src/build-info.ts
|
|
@@ -1297,10 +1393,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
1297
1393
|
return 3;
|
|
1298
1394
|
}
|
|
1299
1395
|
if ("TERM_PROGRAM" in env) {
|
|
1300
|
-
const
|
|
1396
|
+
const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
1301
1397
|
switch (env.TERM_PROGRAM) {
|
|
1302
1398
|
case "iTerm.app": {
|
|
1303
|
-
return
|
|
1399
|
+
return version2 >= 3 ? 3 : 2;
|
|
1304
1400
|
}
|
|
1305
1401
|
case "Apple_Terminal": {
|
|
1306
1402
|
return 2;
|
|
@@ -2331,8 +2427,8 @@ var nodeRuntime = {
|
|
|
2331
2427
|
readDirSync: import_fs_extra.default.readdirSync,
|
|
2332
2428
|
rmDirSync: import_fs_extra.default.emptyDirSync,
|
|
2333
2429
|
rmFileSync: import_fs_extra.default.removeSync,
|
|
2334
|
-
ensureDirSync(
|
|
2335
|
-
return import_fs_extra.default.ensureDirSync(
|
|
2430
|
+
ensureDirSync(path4) {
|
|
2431
|
+
return import_fs_extra.default.ensureDirSync(path4);
|
|
2336
2432
|
},
|
|
2337
2433
|
watch(options) {
|
|
2338
2434
|
const { include, exclude, cwd, poll } = options;
|
|
@@ -2777,7 +2873,7 @@ var Builder = class {
|
|
|
2777
2873
|
init_cjs_shims();
|
|
2778
2874
|
var import_logger7 = require("@pandacss/logger");
|
|
2779
2875
|
var import_node_fs = __toESM(require("fs"));
|
|
2780
|
-
var
|
|
2876
|
+
var import_node_path2 = __toESM(require("path"));
|
|
2781
2877
|
var import_node_readline = __toESM(require("readline"));
|
|
2782
2878
|
var startProfiling = async (cwd, prefix, isWatching) => {
|
|
2783
2879
|
const inspector = await import("inspector").then((r) => r.default);
|
|
@@ -2842,7 +2938,7 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2842
2938
|
const date = /* @__PURE__ */ new Date();
|
|
2843
2939
|
const timestamp = date.toISOString().replace(/[-:.]/g, "");
|
|
2844
2940
|
const title = `panda-${prefix}-${timestamp}`;
|
|
2845
|
-
const outfile =
|
|
2941
|
+
const outfile = import_node_path2.default.join(cwd, `${title}.cpuprofile`);
|
|
2846
2942
|
import_node_fs.default.writeFileSync(outfile, JSON.stringify(params.profile));
|
|
2847
2943
|
import_logger7.logger.info("cpu-prof", outfile);
|
|
2848
2944
|
cb?.();
|
|
@@ -2895,8 +2991,7 @@ async function debug(ctx, options) {
|
|
|
2895
2991
|
const files = ctx.getFiles();
|
|
2896
2992
|
const measureTotal = import_logger9.logger.time.debug(`Done parsing ${files.length} files`);
|
|
2897
2993
|
ctx.config.minify = false;
|
|
2898
|
-
|
|
2899
|
-
const { fs: fs3, path: path3 } = ctx.runtime;
|
|
2994
|
+
const { fs: fs3, path: path4 } = ctx.runtime;
|
|
2900
2995
|
const outdir = options.outdir;
|
|
2901
2996
|
if (!options.dry && outdir) {
|
|
2902
2997
|
fs3.ensureDirSync(outdir);
|
|
@@ -2926,14 +3021,14 @@ async function debug(ctx, options) {
|
|
|
2926
3021
|
if (outdir) {
|
|
2927
3022
|
filesWithCss.push(file);
|
|
2928
3023
|
const parsedPath = (0, import_path4.parse)(file);
|
|
2929
|
-
const relative2 =
|
|
2930
|
-
const astJsonPath = `${relative2}${
|
|
2931
|
-
const cssPath = `${relative2}${
|
|
3024
|
+
const relative2 = path4.relative(ctx.config.cwd, parsedPath.dir);
|
|
3025
|
+
const astJsonPath = `${relative2}${path4.sep}${parsedPath.name}.ast.json`.replaceAll(path4.sep, "__");
|
|
3026
|
+
const cssPath = `${relative2}${path4.sep}${parsedPath.name}.css`.replaceAll(path4.sep, "__");
|
|
2932
3027
|
import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2933
3028
|
import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/${cssPath}`)}`);
|
|
2934
3029
|
return Promise.allSettled([
|
|
2935
|
-
fs3.writeFile(`${outdir}${
|
|
2936
|
-
fs3.writeFile(`${outdir}${
|
|
3030
|
+
fs3.writeFile(`${outdir}${path4.sep}${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
3031
|
+
fs3.writeFile(`${outdir}${path4.sep}${cssPath}`, css)
|
|
2937
3032
|
]);
|
|
2938
3033
|
}
|
|
2939
3034
|
});
|
|
@@ -3032,12 +3127,12 @@ function setupGitIgnore(ctx) {
|
|
|
3032
3127
|
init_cjs_shims();
|
|
3033
3128
|
var import_logger11 = require("@pandacss/logger");
|
|
3034
3129
|
var import_node_fs2 = __toESM(require("fs"));
|
|
3035
|
-
var
|
|
3130
|
+
var import_node_path3 = __toESM(require("path"));
|
|
3036
3131
|
var setLogStream = (options) => {
|
|
3037
3132
|
const { cwd = process.cwd() } = options;
|
|
3038
3133
|
let stream;
|
|
3039
3134
|
if (options.logfile) {
|
|
3040
|
-
const outPath =
|
|
3135
|
+
const outPath = import_node_path3.default.resolve(cwd, options.logfile);
|
|
3041
3136
|
ensure(outPath);
|
|
3042
3137
|
import_logger11.logger.info("logfile", outPath);
|
|
3043
3138
|
stream = import_node_fs2.default.createWriteStream(outPath, { flags: "a" });
|
|
@@ -3058,7 +3153,7 @@ var setLogStream = (options) => {
|
|
|
3058
3153
|
};
|
|
3059
3154
|
};
|
|
3060
3155
|
var ensure = (outPath) => {
|
|
3061
|
-
const dirname2 =
|
|
3156
|
+
const dirname2 = import_node_path3.default.dirname(outPath);
|
|
3062
3157
|
import_node_fs2.default.mkdirSync(dirname2, { recursive: true });
|
|
3063
3158
|
return outPath;
|
|
3064
3159
|
};
|