@pandacss/node 0.49.0 → 0.50.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 +15 -7
- package/dist/index.d.ts +15 -7
- package/dist/index.js +112 -523
- package/dist/index.mjs +110 -520
- package/package.json +10 -12
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.2_@swc+core@1.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.7.6_postcss@8.4.49_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.2_@swc+core@1.
|
|
38
|
+
"../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.7.6_postcss@8.4.49_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
39
|
"use strict";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -405,7 +405,7 @@ var src_exports = {};
|
|
|
405
405
|
__export(src_exports, {
|
|
406
406
|
Builder: () => Builder,
|
|
407
407
|
PandaContext: () => PandaContext,
|
|
408
|
-
|
|
408
|
+
analyze: () => analyze,
|
|
409
409
|
buildInfo: () => buildInfo,
|
|
410
410
|
codegen: () => codegen,
|
|
411
411
|
cssgen: () => cssgen,
|
|
@@ -417,479 +417,70 @@ __export(src_exports, {
|
|
|
417
417
|
setupConfig: () => setupConfig,
|
|
418
418
|
setupGitIgnore: () => setupGitIgnore,
|
|
419
419
|
setupPostcss: () => setupPostcss,
|
|
420
|
-
startProfiling: () => startProfiling
|
|
421
|
-
writeAnalyzeJSON: () => writeAnalyzeJSON
|
|
420
|
+
startProfiling: () => startProfiling
|
|
422
421
|
});
|
|
423
422
|
module.exports = __toCommonJS(src_exports);
|
|
424
423
|
init_cjs_shims();
|
|
425
424
|
|
|
426
|
-
// src/analyze
|
|
425
|
+
// src/analyze.ts
|
|
427
426
|
init_cjs_shims();
|
|
428
|
-
var
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
var version = "0.49.0";
|
|
436
|
-
|
|
437
|
-
// src/classify.ts
|
|
438
|
-
init_cjs_shims();
|
|
439
|
-
var import_extractor = require("@pandacss/extractor");
|
|
440
|
-
var createReportMaps = () => {
|
|
441
|
-
const byComponentOfKind = /* @__PURE__ */ new Map();
|
|
442
|
-
const byPropertyName = /* @__PURE__ */ new Map();
|
|
443
|
-
const byTokenType = /* @__PURE__ */ new Map();
|
|
444
|
-
const byConditionName = /* @__PURE__ */ new Map();
|
|
445
|
-
const byShorthand = /* @__PURE__ */ new Map();
|
|
446
|
-
const byTokenName = /* @__PURE__ */ new Map();
|
|
447
|
-
const byPropertyPath = /* @__PURE__ */ new Map();
|
|
448
|
-
const fromKind = /* @__PURE__ */ new Map();
|
|
449
|
-
const byType = /* @__PURE__ */ new Map();
|
|
450
|
-
const byComponentName = /* @__PURE__ */ new Map();
|
|
451
|
-
const colorsUsed = /* @__PURE__ */ new Map();
|
|
452
|
-
return {
|
|
453
|
-
byComponentOfKind,
|
|
454
|
-
byPropertyName,
|
|
455
|
-
byTokenType,
|
|
456
|
-
byConditionName,
|
|
457
|
-
byShorthand,
|
|
458
|
-
byTokenName,
|
|
459
|
-
byPropertyPath,
|
|
460
|
-
fromKind,
|
|
461
|
-
byType,
|
|
462
|
-
byComponentName,
|
|
463
|
-
colorsUsed
|
|
464
|
-
};
|
|
465
|
-
};
|
|
466
|
-
var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
467
|
-
const byId = /* @__PURE__ */ new Map();
|
|
468
|
-
const byComponentIndex = /* @__PURE__ */ new Map();
|
|
469
|
-
const byFilepath = /* @__PURE__ */ new Map();
|
|
470
|
-
const byComponentInFilepath = /* @__PURE__ */ new Map();
|
|
471
|
-
const globalMaps = createReportMaps();
|
|
472
|
-
const byFilePathMaps = /* @__PURE__ */ new Map();
|
|
473
|
-
const conditions = new Map(Object.entries(ctx.conditions.values));
|
|
474
|
-
const { groupByProp } = getPropertyGroupMap(ctx);
|
|
475
|
-
let id = 0, componentIndex = 0;
|
|
476
|
-
const isKnownUtility = (reportItem, componentReportItem) => {
|
|
477
|
-
const { propName, value } = reportItem;
|
|
478
|
-
const utility = ctx.config.utilities?.[propName];
|
|
479
|
-
if (utility) {
|
|
480
|
-
if (!utility.shorthand) {
|
|
481
|
-
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
482
|
-
}
|
|
483
|
-
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
484
|
-
}
|
|
485
|
-
if (componentReportItem.reportItemType === "pattern") {
|
|
486
|
-
const pattern = ctx.patterns.getConfig(componentReportItem.componentName.toLowerCase());
|
|
487
|
-
const patternProp = pattern?.properties?.[propName];
|
|
488
|
-
if (!patternProp)
|
|
489
|
-
return false;
|
|
490
|
-
if (patternProp.type === "boolean" || patternProp.type === "number") {
|
|
491
|
-
return true;
|
|
492
|
-
}
|
|
493
|
-
if (patternProp.type === "property" && patternProp.value) {
|
|
494
|
-
return Boolean(ctx.config.utilities?.[patternProp.value]);
|
|
495
|
-
}
|
|
496
|
-
if (patternProp.type === "enum" && patternProp.value) {
|
|
497
|
-
return Boolean(patternProp.value.includes(String(value)));
|
|
498
|
-
}
|
|
499
|
-
if (patternProp.type === "token") {
|
|
500
|
-
return Boolean(ctx.tokens.getByName(`${patternProp.value}.${value}`));
|
|
501
|
-
}
|
|
502
|
-
return false;
|
|
503
|
-
}
|
|
504
|
-
return false;
|
|
505
|
-
};
|
|
506
|
-
parserResultByFilepath.forEach((parserResult, filepath) => {
|
|
507
|
-
if (parserResult.isEmpty())
|
|
508
|
-
return;
|
|
509
|
-
const localMaps = createReportMaps();
|
|
510
|
-
const addTo = (map, key, value) => {
|
|
511
|
-
const set = map.get(key) ?? /* @__PURE__ */ new Set();
|
|
512
|
-
set.add(value);
|
|
513
|
-
map.set(key, set);
|
|
514
|
-
};
|
|
515
|
-
const processMap = (map, current, componentReportItem) => {
|
|
516
|
-
const { reportItemType: type, kind } = componentReportItem;
|
|
517
|
-
const name = componentReportItem.componentName;
|
|
518
|
-
map.value.forEach((attrNode, attrName) => {
|
|
519
|
-
if (import_extractor.box.isLiteral(attrNode) || import_extractor.box.isEmptyInitializer(attrNode)) {
|
|
520
|
-
const value = import_extractor.box.isLiteral(attrNode) ? attrNode.value : true;
|
|
521
|
-
const propReportItem = {
|
|
522
|
-
index: String(id++),
|
|
523
|
-
componentIndex: String(componentReportItem.componentIndex),
|
|
524
|
-
componentName: name,
|
|
525
|
-
tokenType: void 0,
|
|
526
|
-
propName: attrName,
|
|
527
|
-
reportItemKind: "utility",
|
|
528
|
-
reportItemType: type,
|
|
529
|
-
kind,
|
|
530
|
-
filepath,
|
|
531
|
-
path: current.concat(attrName),
|
|
532
|
-
value,
|
|
533
|
-
isKnownValue: false,
|
|
534
|
-
range: map.getRange()
|
|
535
|
-
};
|
|
536
|
-
componentReportItem.contains.push(propReportItem.index);
|
|
537
|
-
if (conditions.has(attrName)) {
|
|
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;
|
|
543
|
-
} else {
|
|
544
|
-
if (current.length && conditions.has(current[0])) {
|
|
545
|
-
propReportItem.conditionName = current[0];
|
|
546
|
-
addTo(globalMaps.byConditionName, current[0], propReportItem.index);
|
|
547
|
-
addTo(localMaps.byConditionName, current[0], propReportItem.index);
|
|
548
|
-
}
|
|
549
|
-
const propName = ctx.utility.shorthands.get(attrName) ?? attrName;
|
|
550
|
-
propReportItem.propName = propName;
|
|
551
|
-
const utility = ctx.config.utilities?.[propName];
|
|
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);
|
|
567
|
-
}
|
|
568
|
-
if (ctx.utility.shorthands.has(attrName)) {
|
|
569
|
-
addTo(globalMaps.byShorthand, attrName, propReportItem.index);
|
|
570
|
-
addTo(localMaps.byShorthand, attrName, propReportItem.index);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
if (current.length) {
|
|
574
|
-
addTo(globalMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
|
|
575
|
-
addTo(localMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
|
|
576
|
-
}
|
|
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);
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
if (import_extractor.box.isMap(attrNode) && attrNode.value.size) {
|
|
590
|
-
return processMap(attrNode, current.concat(attrName), componentReportItem);
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
};
|
|
594
|
-
const processResultItem = (item, kind) => {
|
|
595
|
-
if (!item.box || import_extractor.box.isUnresolvable(item.box)) {
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
if (!item.data) {
|
|
599
|
-
console.log("no data", item);
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
const componentReportItem = {
|
|
603
|
-
componentIndex: String(componentIndex++),
|
|
604
|
-
componentName: item.name,
|
|
605
|
-
reportItemType: item.type,
|
|
606
|
-
kind,
|
|
607
|
-
filepath,
|
|
608
|
-
value: item.data,
|
|
609
|
-
range: item.box.getRange(),
|
|
610
|
-
contains: []
|
|
611
|
-
};
|
|
612
|
-
if (import_extractor.box.isArray(item.box)) {
|
|
613
|
-
addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
|
|
614
|
-
return componentReportItem;
|
|
615
|
-
}
|
|
616
|
-
if (import_extractor.box.isMap(item.box) && item.box.value.size) {
|
|
617
|
-
addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
|
|
618
|
-
processMap(item.box, [], componentReportItem);
|
|
619
|
-
return componentReportItem;
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
const processComponentResultItem = (item) => {
|
|
623
|
-
const componentReportItem = processResultItem(item, "component");
|
|
624
|
-
if (!componentReportItem)
|
|
625
|
-
return;
|
|
626
|
-
addTo(globalMaps.byComponentOfKind, "component", componentReportItem.componentIndex);
|
|
627
|
-
addTo(localMaps.byComponentOfKind, "component", componentReportItem.componentIndex);
|
|
628
|
-
byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
|
|
629
|
-
};
|
|
630
|
-
const processFunctionResultItem = (item) => {
|
|
631
|
-
const componentReportItem = processResultItem(item, "function");
|
|
632
|
-
if (!componentReportItem)
|
|
633
|
-
return;
|
|
634
|
-
addTo(globalMaps.byComponentOfKind, "function", componentReportItem.componentIndex);
|
|
635
|
-
addTo(localMaps.byComponentOfKind, "function", componentReportItem.componentIndex);
|
|
636
|
-
byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
|
|
637
|
-
};
|
|
638
|
-
parserResult.jsx.forEach(processComponentResultItem);
|
|
639
|
-
parserResult.css.forEach(processFunctionResultItem);
|
|
640
|
-
parserResult.cva.forEach(processFunctionResultItem);
|
|
641
|
-
parserResult.pattern.forEach((itemList) => {
|
|
642
|
-
itemList.forEach(processFunctionResultItem);
|
|
643
|
-
});
|
|
644
|
-
parserResult.recipe.forEach((itemList) => {
|
|
645
|
-
itemList.forEach(processFunctionResultItem);
|
|
646
|
-
});
|
|
647
|
-
byFilePathMaps.set(filepath, localMaps);
|
|
427
|
+
var import_reporter = require("@pandacss/reporter");
|
|
428
|
+
function analyze(ctx, options = {}) {
|
|
429
|
+
const reporter = new import_reporter.Reporter(ctx, {
|
|
430
|
+
project: ctx.project,
|
|
431
|
+
getRelativePath: ctx.runtime.path.relative,
|
|
432
|
+
getFiles: ctx.getFiles,
|
|
433
|
+
...options
|
|
648
434
|
});
|
|
649
|
-
|
|
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)
|
|
652
|
-
);
|
|
435
|
+
reporter.init();
|
|
653
436
|
return {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
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
|
-
}
|
|
437
|
+
getRecipeReport(format = "table") {
|
|
438
|
+
const report = reporter.getRecipeReport();
|
|
439
|
+
return { report, formatted: (0, import_reporter.formatRecipeReport)(report, format) };
|
|
673
440
|
},
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
globalMaps,
|
|
678
|
-
byFilePathMaps
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
};
|
|
682
|
-
var getXMostUseds = (globalMaps, pickCount) => {
|
|
683
|
-
return {
|
|
684
|
-
propNames: getMostUsedInMap(globalMaps.byPropertyName, pickCount),
|
|
685
|
-
tokens: getMostUsedInMap(globalMaps.byTokenName, pickCount),
|
|
686
|
-
shorthands: getMostUsedInMap(globalMaps.byShorthand, pickCount),
|
|
687
|
-
conditions: getMostUsedInMap(globalMaps.byConditionName, pickCount),
|
|
688
|
-
propertyPaths: getMostUsedInMap(globalMaps.byPropertyPath, pickCount),
|
|
689
|
-
categories: getMostUsedInMap(globalMaps.byTokenType, pickCount),
|
|
690
|
-
types: getMostUsedInMap(globalMaps.byType, pickCount),
|
|
691
|
-
componentNames: getMostUsedInMap(globalMaps.byComponentName, pickCount),
|
|
692
|
-
fromKinds: getMostUsedInMap(globalMaps.fromKind, pickCount),
|
|
693
|
-
componentOfKinds: getMostUsedInMap(globalMaps.byComponentOfKind, pickCount),
|
|
694
|
-
colors: getMostUsedInMap(globalMaps.colorsUsed, pickCount)
|
|
695
|
-
};
|
|
696
|
-
};
|
|
697
|
-
var getMostUsedInMap = (map, pickCount) => {
|
|
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 }));
|
|
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
|
-
};
|
|
761
|
-
|
|
762
|
-
// src/analyze-tokens.ts
|
|
763
|
-
var gzipSizeSync = (code) => import_zlib.default.gzipSync(code, { level: import_zlib.default.constants.Z_BEST_COMPRESSION }).length;
|
|
764
|
-
function analyzeTokens(ctx, options = {}) {
|
|
765
|
-
const filesMap = /* @__PURE__ */ new Map();
|
|
766
|
-
const timesMap = /* @__PURE__ */ new Map();
|
|
767
|
-
const files = ctx.getFiles();
|
|
768
|
-
const sheet = ctx.createSheet();
|
|
769
|
-
ctx.appendLayerParams(sheet);
|
|
770
|
-
ctx.appendBaselineCss(sheet);
|
|
771
|
-
files.forEach((file) => {
|
|
772
|
-
const start2 = performance.now();
|
|
773
|
-
const result = ctx.project.parseSourceFile(file);
|
|
774
|
-
const extractMs = performance.now() - start2;
|
|
775
|
-
const relativePath = import_node_path.default.relative(ctx.config.cwd, file);
|
|
776
|
-
timesMap.set(relativePath, extractMs);
|
|
777
|
-
import_logger.logger.debug("analyze", `Parsed ${file} in ${extractMs}ms`);
|
|
778
|
-
if (result) {
|
|
779
|
-
filesMap.set(relativePath, result);
|
|
780
|
-
options.onResult?.(file, result);
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
const totalMs = Array.from(timesMap.values()).reduce((a, b) => a + b, 0);
|
|
784
|
-
import_logger.logger.debug("analyze", `Analyzed ${files.length} files in ${totalMs.toFixed(2)}ms`);
|
|
785
|
-
ctx.appendParserCss(sheet);
|
|
786
|
-
const cssStart = performance.now();
|
|
787
|
-
ctx.config.minify = false;
|
|
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
|
-
}
|
|
810
|
-
const start = performance.now();
|
|
811
|
-
const analysis = classifyTokens(ctx, filesMap);
|
|
812
|
-
const classifyMs = performance.now() - start;
|
|
813
|
-
const details = Object.assign(
|
|
814
|
-
{
|
|
815
|
-
duration: {
|
|
816
|
-
classify: classifyMs,
|
|
817
|
-
//
|
|
818
|
-
cssMs,
|
|
819
|
-
cssMinifyMs,
|
|
820
|
-
//
|
|
821
|
-
...!isUsingLightningCss ? {
|
|
822
|
-
lightningCssMs,
|
|
823
|
-
lightningCssMinifiedMs
|
|
824
|
-
} : {},
|
|
825
|
-
//
|
|
826
|
-
extractTotal: totalMs,
|
|
827
|
-
extractTimeByFiles: Object.fromEntries(timesMap.entries())
|
|
828
|
-
},
|
|
829
|
-
fileSizes: {
|
|
830
|
-
lineCount: css.split("\n").length,
|
|
831
|
-
normal: (0, import_filesize.filesize)(Buffer.byteLength(css, "utf-8")),
|
|
832
|
-
minified: (0, import_filesize.filesize)(Buffer.byteLength(minifiedCss, "utf-8")),
|
|
833
|
-
gzip: {
|
|
834
|
-
normal: (0, import_filesize.filesize)(gzipSizeSync(css)),
|
|
835
|
-
minified: (0, import_filesize.filesize)(gzipSizeSync(minifiedCss))
|
|
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
|
|
841
|
-
}
|
|
441
|
+
getTokenReport(format = "table") {
|
|
442
|
+
const report = reporter.getTokenReport();
|
|
443
|
+
return { report, formatted: (0, import_reporter.formatTokenReport)(report.getSummary(), format) };
|
|
842
444
|
},
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
propByIndex: analysis.propById,
|
|
850
|
-
componentByIndex: analysis.componentById,
|
|
851
|
-
derived: analysis.derived,
|
|
852
|
-
config
|
|
445
|
+
writeReport(filePath) {
|
|
446
|
+
const dirname2 = ctx.runtime.path.dirname(filePath);
|
|
447
|
+
ctx.runtime.fs.ensureDirSync(dirname2);
|
|
448
|
+
const str = JSON.stringify(reporter.report, replacer, 2);
|
|
449
|
+
return ctx.runtime.fs.writeFile(filePath, str);
|
|
450
|
+
}
|
|
853
451
|
};
|
|
854
452
|
}
|
|
855
|
-
|
|
856
|
-
if (value instanceof Set)
|
|
453
|
+
function replacer(_, value) {
|
|
454
|
+
if (value instanceof Set)
|
|
857
455
|
return Array.from(value);
|
|
858
|
-
|
|
859
|
-
if (value instanceof Map) {
|
|
456
|
+
if (value instanceof Map)
|
|
860
457
|
return Object.fromEntries(value);
|
|
861
|
-
}
|
|
862
458
|
return value;
|
|
863
|
-
}
|
|
864
|
-
var writeAnalyzeJSON = (filePath, result, ctx) => {
|
|
865
|
-
const dirname2 = ctx.runtime.path.dirname(filePath);
|
|
866
|
-
ctx.runtime.fs.ensureDirSync(dirname2);
|
|
867
|
-
return (0, import_promises.writeFile)(filePath, JSON.stringify(result, analyzeResultSerializer, 2));
|
|
868
|
-
};
|
|
459
|
+
}
|
|
869
460
|
|
|
870
461
|
// src/build-info.ts
|
|
871
462
|
init_cjs_shims();
|
|
872
|
-
var
|
|
463
|
+
var import_logger = require("@pandacss/logger");
|
|
873
464
|
async function buildInfo(ctx, outfile) {
|
|
874
465
|
const { filesWithCss, files } = ctx.parseFiles();
|
|
875
|
-
|
|
466
|
+
import_logger.logger.info("cli", `Found ${import_logger.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
876
467
|
const { minify, staticCss } = ctx.config;
|
|
877
|
-
|
|
468
|
+
import_logger.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger.colors.bold(outfile)}`);
|
|
878
469
|
if (staticCss) {
|
|
879
|
-
|
|
470
|
+
import_logger.logger.info("cli", "Adding staticCss definitions...");
|
|
880
471
|
ctx.staticCss.process(staticCss);
|
|
881
472
|
}
|
|
882
473
|
const output = JSON.stringify(ctx.encoder.toJSON(), null, minify ? 0 : 2);
|
|
883
474
|
ctx.output.ensure(outfile, process.cwd());
|
|
884
475
|
await ctx.runtime.fs.writeFile(outfile, output);
|
|
885
|
-
|
|
476
|
+
import_logger.logger.info("cli", "Done!");
|
|
886
477
|
}
|
|
887
478
|
|
|
888
479
|
// src/builder.ts
|
|
889
480
|
init_cjs_shims();
|
|
890
481
|
var import_config4 = require("@pandacss/config");
|
|
891
482
|
var import_core = require("@pandacss/core");
|
|
892
|
-
var
|
|
483
|
+
var import_logger5 = require("@pandacss/logger");
|
|
893
484
|
var import_shared2 = require("@pandacss/shared");
|
|
894
485
|
var import_fs = require("fs");
|
|
895
486
|
var import_path3 = require("path");
|
|
@@ -1041,7 +632,7 @@ var import_browserslist = __toESM(require("browserslist"));
|
|
|
1041
632
|
// src/create-context.ts
|
|
1042
633
|
init_cjs_shims();
|
|
1043
634
|
var import_generator2 = require("@pandacss/generator");
|
|
1044
|
-
var
|
|
635
|
+
var import_logger4 = require("@pandacss/logger");
|
|
1045
636
|
var import_parser = require("@pandacss/parser");
|
|
1046
637
|
var import_shared = require("@pandacss/shared");
|
|
1047
638
|
var import_perfect_debounce = require("perfect-debounce");
|
|
@@ -1059,13 +650,12 @@ init_cjs_shims();
|
|
|
1059
650
|
// ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
|
1060
651
|
init_cjs_shims();
|
|
1061
652
|
|
|
1062
|
-
// ../../node_modules/.pnpm/ansi-regex@6.1
|
|
653
|
+
// ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
|
|
1063
654
|
init_cjs_shims();
|
|
1064
655
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1065
|
-
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
1066
656
|
const pattern = [
|
|
1067
|
-
|
|
1068
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-
|
|
657
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
658
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
1069
659
|
].join("|");
|
|
1070
660
|
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
1071
661
|
}
|
|
@@ -1404,10 +994,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
1404
994
|
return 3;
|
|
1405
995
|
}
|
|
1406
996
|
if ("TERM_PROGRAM" in env) {
|
|
1407
|
-
const
|
|
997
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
1408
998
|
switch (env.TERM_PROGRAM) {
|
|
1409
999
|
case "iTerm.app": {
|
|
1410
|
-
return
|
|
1000
|
+
return version >= 3 ? 3 : 2;
|
|
1411
1001
|
}
|
|
1412
1002
|
case "Apple_Terminal": {
|
|
1413
1003
|
return 2;
|
|
@@ -1440,7 +1030,7 @@ var supports_color_default = supportsColor;
|
|
|
1440
1030
|
|
|
1441
1031
|
// ../../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
|
|
1442
1032
|
init_cjs_shims();
|
|
1443
|
-
function stringReplaceAll(string, substring,
|
|
1033
|
+
function stringReplaceAll(string, substring, replacer2) {
|
|
1444
1034
|
let index = string.indexOf(substring);
|
|
1445
1035
|
if (index === -1) {
|
|
1446
1036
|
return string;
|
|
@@ -1449,7 +1039,7 @@ function stringReplaceAll(string, substring, replacer) {
|
|
|
1449
1039
|
let endIndex = 0;
|
|
1450
1040
|
let returnValue = "";
|
|
1451
1041
|
do {
|
|
1452
|
-
returnValue += string.slice(endIndex, index) + substring +
|
|
1042
|
+
returnValue += string.slice(endIndex, index) + substring + replacer2;
|
|
1453
1043
|
endIndex = index + substringLength;
|
|
1454
1044
|
index = string.indexOf(substring, endIndex);
|
|
1455
1045
|
} while (index !== -1);
|
|
@@ -2395,7 +1985,7 @@ var DiffEngine = class {
|
|
|
2395
1985
|
|
|
2396
1986
|
// src/node-runtime.ts
|
|
2397
1987
|
init_cjs_shims();
|
|
2398
|
-
var
|
|
1988
|
+
var import_logger2 = require("@pandacss/logger");
|
|
2399
1989
|
var import_chokidar = __toESM(require("chokidar"));
|
|
2400
1990
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
2401
1991
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
@@ -2438,8 +2028,8 @@ var nodeRuntime = {
|
|
|
2438
2028
|
readDirSync: import_fs_extra.default.readdirSync,
|
|
2439
2029
|
rmDirSync: import_fs_extra.default.emptyDirSync,
|
|
2440
2030
|
rmFileSync: import_fs_extra.default.removeSync,
|
|
2441
|
-
ensureDirSync(
|
|
2442
|
-
return import_fs_extra.default.ensureDirSync(
|
|
2031
|
+
ensureDirSync(path3) {
|
|
2032
|
+
return import_fs_extra.default.ensureDirSync(path3);
|
|
2443
2033
|
},
|
|
2444
2034
|
watch(options) {
|
|
2445
2035
|
const { include, exclude, cwd, poll } = options;
|
|
@@ -2452,7 +2042,7 @@ var nodeRuntime = {
|
|
|
2452
2042
|
ignored: exclude,
|
|
2453
2043
|
awaitWriteFinish: coalesce ? { stabilityThreshold: 50, pollInterval: 10 } : false
|
|
2454
2044
|
});
|
|
2455
|
-
|
|
2045
|
+
import_logger2.logger.debug("watch:file", `watching [${include}]`);
|
|
2456
2046
|
process.once("SIGINT", async () => {
|
|
2457
2047
|
await watcher.close();
|
|
2458
2048
|
});
|
|
@@ -2462,15 +2052,15 @@ var nodeRuntime = {
|
|
|
2462
2052
|
};
|
|
2463
2053
|
process.setMaxListeners(Infinity);
|
|
2464
2054
|
process.on("unhandledRejection", (reason) => {
|
|
2465
|
-
|
|
2055
|
+
import_logger2.logger.error("\u274C", reason);
|
|
2466
2056
|
});
|
|
2467
2057
|
process.on("uncaughtException", (reason) => {
|
|
2468
|
-
|
|
2058
|
+
import_logger2.logger.error("\u274C", reason);
|
|
2469
2059
|
});
|
|
2470
2060
|
|
|
2471
2061
|
// src/output-engine.ts
|
|
2472
2062
|
init_cjs_shims();
|
|
2473
|
-
var
|
|
2063
|
+
var import_logger3 = require("@pandacss/logger");
|
|
2474
2064
|
var OutputEngine = class {
|
|
2475
2065
|
paths;
|
|
2476
2066
|
fs;
|
|
@@ -2501,7 +2091,7 @@ var OutputEngine = class {
|
|
|
2501
2091
|
return;
|
|
2502
2092
|
const { file, code } = artifact;
|
|
2503
2093
|
const absPath = this.path.join(...dir, file);
|
|
2504
|
-
|
|
2094
|
+
import_logger3.logger.debug("write:file", dir.slice(-1).concat(file).join("/"));
|
|
2505
2095
|
return this.fs.writeFile(absPath, code);
|
|
2506
2096
|
})
|
|
2507
2097
|
);
|
|
@@ -2521,7 +2111,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2521
2111
|
this.runtime = nodeRuntime;
|
|
2522
2112
|
config.cwd ||= this.runtime.cwd();
|
|
2523
2113
|
if (config.logLevel) {
|
|
2524
|
-
|
|
2114
|
+
import_logger4.logger.level = config.logLevel;
|
|
2525
2115
|
}
|
|
2526
2116
|
this.project = new import_parser.Project({
|
|
2527
2117
|
...conf.tsconfig,
|
|
@@ -2555,14 +2145,14 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2555
2145
|
};
|
|
2556
2146
|
parseFile = (filePath, styleEncoder) => {
|
|
2557
2147
|
const file = this.runtime.path.abs(this.config.cwd, filePath);
|
|
2558
|
-
|
|
2559
|
-
const measure =
|
|
2148
|
+
import_logger4.logger.debug("file:extract", file);
|
|
2149
|
+
const measure = import_logger4.logger.time.debug(`Parsed ${file}`);
|
|
2560
2150
|
let result;
|
|
2561
2151
|
try {
|
|
2562
2152
|
const encoder = styleEncoder || this.parserOptions.encoder;
|
|
2563
2153
|
result = this.project.parseSourceFile(file, encoder);
|
|
2564
2154
|
} catch (error) {
|
|
2565
|
-
|
|
2155
|
+
import_logger4.logger.error("file:extract", error);
|
|
2566
2156
|
}
|
|
2567
2157
|
measure();
|
|
2568
2158
|
return result;
|
|
@@ -2573,7 +2163,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2573
2163
|
const filesWithCss = [];
|
|
2574
2164
|
const results = [];
|
|
2575
2165
|
files.forEach((file) => {
|
|
2576
|
-
const measure =
|
|
2166
|
+
const measure = import_logger4.logger.time.debug(`Parsed ${file}`);
|
|
2577
2167
|
const result = this.project.parseSourceFile(file, encoder);
|
|
2578
2168
|
measure();
|
|
2579
2169
|
if (!result || result.isEmpty() || encoder.isEmpty())
|
|
@@ -2588,7 +2178,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2588
2178
|
};
|
|
2589
2179
|
};
|
|
2590
2180
|
writeCss = (sheet) => {
|
|
2591
|
-
|
|
2181
|
+
import_logger4.logger.info("css", this.runtime.path.join(...this.paths.root, "styles.css"));
|
|
2592
2182
|
return this.output.write({
|
|
2593
2183
|
id: "styles.css",
|
|
2594
2184
|
dir: this.paths.root,
|
|
@@ -2597,7 +2187,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2597
2187
|
};
|
|
2598
2188
|
watchConfig = (cb, opts) => {
|
|
2599
2189
|
const { cwd, poll, exclude } = opts ?? {};
|
|
2600
|
-
|
|
2190
|
+
import_logger4.logger.info("ctx:watch", this.messages.configWatch());
|
|
2601
2191
|
const watcher = this.runtime.fs.watch({
|
|
2602
2192
|
include: (0, import_shared.uniq)([...this.explicitDeps, ...this.conf.dependencies]),
|
|
2603
2193
|
exclude,
|
|
@@ -2607,14 +2197,14 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2607
2197
|
watcher.on(
|
|
2608
2198
|
"change",
|
|
2609
2199
|
(0, import_perfect_debounce.debounce)(async (file) => {
|
|
2610
|
-
|
|
2200
|
+
import_logger4.logger.info("ctx:change", "config changed, rebuilding...");
|
|
2611
2201
|
await cb(file);
|
|
2612
2202
|
})
|
|
2613
2203
|
);
|
|
2614
2204
|
};
|
|
2615
2205
|
watchFiles = (cb, opts) => {
|
|
2616
2206
|
const { include, exclude, poll, cwd } = this.config;
|
|
2617
|
-
|
|
2207
|
+
import_logger4.logger.info("ctx:watch", this.messages.watch());
|
|
2618
2208
|
const watcher = this.runtime.fs.watch({
|
|
2619
2209
|
...opts,
|
|
2620
2210
|
include,
|
|
@@ -2625,7 +2215,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2625
2215
|
watcher.on(
|
|
2626
2216
|
"all",
|
|
2627
2217
|
(0, import_perfect_debounce.debounce)(async (event, file) => {
|
|
2628
|
-
|
|
2218
|
+
import_logger4.logger.info(`file:${event}`, file);
|
|
2629
2219
|
await cb(event, file);
|
|
2630
2220
|
})
|
|
2631
2221
|
);
|
|
@@ -2749,11 +2339,11 @@ var Builder = class {
|
|
|
2749
2339
|
configDeps.forEach((file) => {
|
|
2750
2340
|
this.configDependencies.add(file);
|
|
2751
2341
|
});
|
|
2752
|
-
|
|
2753
|
-
|
|
2342
|
+
import_logger5.logger.debug("builder", "Config dependencies");
|
|
2343
|
+
import_logger5.logger.debug("builder", configDeps);
|
|
2754
2344
|
}
|
|
2755
2345
|
setup = async (options = {}) => {
|
|
2756
|
-
|
|
2346
|
+
import_logger5.logger.debug("builder", "\u{1F6A7} Setup");
|
|
2757
2347
|
const configPath = options.configPath ?? (0, import_config4.findConfig)({ cwd: options.cwd });
|
|
2758
2348
|
this.setConfigDependencies({ configPath, cwd: options.cwd });
|
|
2759
2349
|
if (!this.context) {
|
|
@@ -2763,29 +2353,29 @@ var Builder = class {
|
|
|
2763
2353
|
this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2764
2354
|
this.context = new PandaContext(conf);
|
|
2765
2355
|
});
|
|
2766
|
-
|
|
2356
|
+
import_logger5.logger.debug("builder", this.affecteds);
|
|
2767
2357
|
this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
|
|
2768
2358
|
if (this.explicitDepsMeta.hasFilesChanged) {
|
|
2769
2359
|
this.explicitDepsMeta.changes.forEach((meta, file) => {
|
|
2770
2360
|
fileModifiedMap.set(file, meta.mtime);
|
|
2771
2361
|
});
|
|
2772
|
-
|
|
2362
|
+
import_logger5.logger.debug("builder", "\u2699\uFE0F Explicit config dependencies changed");
|
|
2773
2363
|
this.affecteds.hasConfigChanged = true;
|
|
2774
2364
|
}
|
|
2775
2365
|
if (this.affecteds.hasConfigChanged) {
|
|
2776
|
-
|
|
2366
|
+
import_logger5.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2777
2367
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: this.affecteds });
|
|
2778
2368
|
return;
|
|
2779
2369
|
}
|
|
2780
2370
|
this.filesMeta = this.checkFilesChanged(ctx.getFiles());
|
|
2781
2371
|
if (this.filesMeta.hasFilesChanged) {
|
|
2782
|
-
|
|
2372
|
+
import_logger5.logger.debug("builder", "Files changed, invalidating them");
|
|
2783
2373
|
ctx.project.reloadSourceFiles();
|
|
2784
2374
|
}
|
|
2785
2375
|
};
|
|
2786
2376
|
async emit() {
|
|
2787
2377
|
if (this.hasEmitted && this.affecteds?.hasConfigChanged) {
|
|
2788
|
-
|
|
2378
|
+
import_logger5.logger.debug("builder", "Emit artifacts after config change");
|
|
2789
2379
|
await codegen(this.getContextOrThrow(), Array.from(this.affecteds.artifacts));
|
|
2790
2380
|
}
|
|
2791
2381
|
this.hasEmitted = true;
|
|
@@ -2835,12 +2425,12 @@ var Builder = class {
|
|
|
2835
2425
|
extract = () => {
|
|
2836
2426
|
const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : true;
|
|
2837
2427
|
if (!this.filesMeta && !hasConfigChanged) {
|
|
2838
|
-
|
|
2428
|
+
import_logger5.logger.debug("builder", "No files or config changed, skipping extract");
|
|
2839
2429
|
return;
|
|
2840
2430
|
}
|
|
2841
2431
|
const ctx = this.getContextOrThrow();
|
|
2842
2432
|
const files = ctx.getFiles();
|
|
2843
|
-
const done =
|
|
2433
|
+
const done = import_logger5.logger.time.info("Extracted in");
|
|
2844
2434
|
files.map((file) => this.extractFile(ctx, file));
|
|
2845
2435
|
done();
|
|
2846
2436
|
};
|
|
@@ -2882,9 +2472,9 @@ var Builder = class {
|
|
|
2882
2472
|
|
|
2883
2473
|
// src/cpu-profile.ts
|
|
2884
2474
|
init_cjs_shims();
|
|
2885
|
-
var
|
|
2475
|
+
var import_logger6 = require("@pandacss/logger");
|
|
2886
2476
|
var import_node_fs = __toESM(require("fs"));
|
|
2887
|
-
var
|
|
2477
|
+
var import_node_path = __toESM(require("path"));
|
|
2888
2478
|
var import_node_readline = __toESM(require("readline"));
|
|
2889
2479
|
var startProfiling = async (cwd, prefix, isWatching) => {
|
|
2890
2480
|
const inspector = await import("inspector").then((r) => r.default);
|
|
@@ -2938,7 +2528,7 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2938
2528
|
session.post("Profiler.stop", (err, params) => {
|
|
2939
2529
|
setState("idle");
|
|
2940
2530
|
if (err) {
|
|
2941
|
-
|
|
2531
|
+
import_logger6.logger.error("cpu-prof", err);
|
|
2942
2532
|
cb?.();
|
|
2943
2533
|
return;
|
|
2944
2534
|
}
|
|
@@ -2949,9 +2539,9 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2949
2539
|
const date = /* @__PURE__ */ new Date();
|
|
2950
2540
|
const timestamp = date.toISOString().replace(/[-:.]/g, "");
|
|
2951
2541
|
const title = `panda-${prefix}-${timestamp}`;
|
|
2952
|
-
const outfile =
|
|
2542
|
+
const outfile = import_node_path.default.join(cwd, `${title}.cpuprofile`);
|
|
2953
2543
|
import_node_fs.default.writeFileSync(outfile, JSON.stringify(params.profile));
|
|
2954
|
-
|
|
2544
|
+
import_logger6.logger.info("cpu-prof", outfile);
|
|
2955
2545
|
cb?.();
|
|
2956
2546
|
});
|
|
2957
2547
|
};
|
|
@@ -2960,16 +2550,16 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2960
2550
|
|
|
2961
2551
|
// src/cssgen.ts
|
|
2962
2552
|
init_cjs_shims();
|
|
2963
|
-
var
|
|
2553
|
+
var import_logger7 = require("@pandacss/logger");
|
|
2964
2554
|
var cssgen = async (ctx, options) => {
|
|
2965
2555
|
const { outfile, type, minimal } = options;
|
|
2966
2556
|
const sheet = ctx.createSheet();
|
|
2967
2557
|
if (type) {
|
|
2968
|
-
const done =
|
|
2558
|
+
const done = import_logger7.logger.time.info(ctx.messages.cssArtifactComplete(type));
|
|
2969
2559
|
ctx.appendCssOfType(type, sheet);
|
|
2970
2560
|
if (outfile) {
|
|
2971
2561
|
const css = ctx.getCss(sheet);
|
|
2972
|
-
|
|
2562
|
+
import_logger7.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
2973
2563
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2974
2564
|
} else {
|
|
2975
2565
|
await ctx.writeCss(sheet);
|
|
@@ -2977,7 +2567,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2977
2567
|
done();
|
|
2978
2568
|
} else {
|
|
2979
2569
|
const { files } = ctx.parseFiles();
|
|
2980
|
-
const done =
|
|
2570
|
+
const done = import_logger7.logger.time.info(ctx.messages.buildComplete(files.length));
|
|
2981
2571
|
if (!minimal) {
|
|
2982
2572
|
ctx.appendLayerParams(sheet);
|
|
2983
2573
|
ctx.appendBaselineCss(sheet);
|
|
@@ -2985,7 +2575,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2985
2575
|
ctx.appendParserCss(sheet);
|
|
2986
2576
|
if (outfile) {
|
|
2987
2577
|
const css = ctx.getCss(sheet);
|
|
2988
|
-
|
|
2578
|
+
import_logger7.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
2989
2579
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2990
2580
|
} else {
|
|
2991
2581
|
await ctx.writeCss(sheet);
|
|
@@ -2996,17 +2586,17 @@ var cssgen = async (ctx, options) => {
|
|
|
2996
2586
|
|
|
2997
2587
|
// src/debug.ts
|
|
2998
2588
|
init_cjs_shims();
|
|
2999
|
-
var
|
|
2589
|
+
var import_logger8 = require("@pandacss/logger");
|
|
3000
2590
|
var import_path4 = require("path");
|
|
3001
2591
|
async function debug(ctx, options) {
|
|
3002
2592
|
const files = ctx.getFiles();
|
|
3003
|
-
const measureTotal =
|
|
2593
|
+
const measureTotal = import_logger8.logger.time.debug(`Done parsing ${files.length} files`);
|
|
3004
2594
|
ctx.config.minify = false;
|
|
3005
|
-
const { fs: fs3, path:
|
|
2595
|
+
const { fs: fs3, path: path3 } = ctx.runtime;
|
|
3006
2596
|
const outdir = options.outdir;
|
|
3007
2597
|
if (!options.dry && outdir) {
|
|
3008
2598
|
fs3.ensureDirSync(outdir);
|
|
3009
|
-
|
|
2599
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/config.json`)}`);
|
|
3010
2600
|
await fs3.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
3011
2601
|
}
|
|
3012
2602
|
if (options.onlyConfig) {
|
|
@@ -3015,7 +2605,7 @@ async function debug(ctx, options) {
|
|
|
3015
2605
|
}
|
|
3016
2606
|
const filesWithCss = [];
|
|
3017
2607
|
files.map((file) => {
|
|
3018
|
-
const measure =
|
|
2608
|
+
const measure = import_logger8.logger.time.debug(`Parsed ${file}`);
|
|
3019
2609
|
const encoder = ctx.encoder.clone();
|
|
3020
2610
|
const result = ctx.project.parseSourceFile(file, encoder);
|
|
3021
2611
|
measure();
|
|
@@ -3032,30 +2622,30 @@ async function debug(ctx, options) {
|
|
|
3032
2622
|
if (outdir) {
|
|
3033
2623
|
filesWithCss.push(file);
|
|
3034
2624
|
const parsedPath = (0, import_path4.parse)(file);
|
|
3035
|
-
const relative2 =
|
|
3036
|
-
const astJsonPath = `${relative2}${
|
|
3037
|
-
const cssPath = `${relative2}${
|
|
3038
|
-
|
|
3039
|
-
|
|
2625
|
+
const relative2 = path3.relative(ctx.config.cwd, parsedPath.dir);
|
|
2626
|
+
const astJsonPath = `${relative2}${path3.sep}${parsedPath.name}.ast.json`.replaceAll(path3.sep, "__");
|
|
2627
|
+
const cssPath = `${relative2}${path3.sep}${parsedPath.name}.css`.replaceAll(path3.sep, "__");
|
|
2628
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2629
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${cssPath}`)}`);
|
|
3040
2630
|
return Promise.allSettled([
|
|
3041
|
-
fs3.writeFile(`${outdir}${
|
|
3042
|
-
fs3.writeFile(`${outdir}${
|
|
2631
|
+
fs3.writeFile(`${outdir}${path3.sep}${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2632
|
+
fs3.writeFile(`${outdir}${path3.sep}${cssPath}`, css)
|
|
3043
2633
|
]);
|
|
3044
2634
|
}
|
|
3045
2635
|
});
|
|
3046
|
-
|
|
2636
|
+
import_logger8.logger.info("cli", `Found ${import_logger8.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
3047
2637
|
measureTotal();
|
|
3048
2638
|
}
|
|
3049
2639
|
|
|
3050
2640
|
// src/generate.ts
|
|
3051
2641
|
init_cjs_shims();
|
|
3052
|
-
var
|
|
2642
|
+
var import_logger9 = require("@pandacss/logger");
|
|
3053
2643
|
async function build(ctx, artifactIds) {
|
|
3054
2644
|
await codegen(ctx, artifactIds);
|
|
3055
2645
|
if (ctx.config.emitTokensOnly) {
|
|
3056
|
-
return
|
|
2646
|
+
return import_logger9.logger.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
|
|
3057
2647
|
}
|
|
3058
|
-
const done =
|
|
2648
|
+
const done = import_logger9.logger.time.info("");
|
|
3059
2649
|
const sheet = ctx.createSheet();
|
|
3060
2650
|
ctx.appendLayerParams(sheet);
|
|
3061
2651
|
ctx.appendBaselineCss(sheet);
|
|
@@ -3074,7 +2664,7 @@ async function generate(config, configPath) {
|
|
|
3074
2664
|
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
3075
2665
|
ctx = new PandaContext(conf);
|
|
3076
2666
|
});
|
|
3077
|
-
|
|
2667
|
+
import_logger9.logger.info("ctx:updated", "config rebuilt \u2705");
|
|
3078
2668
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
|
|
3079
2669
|
return build(ctx, Array.from(affecteds.artifacts));
|
|
3080
2670
|
},
|
|
@@ -3084,7 +2674,7 @@ async function generate(config, configPath) {
|
|
|
3084
2674
|
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
3085
2675
|
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
3086
2676
|
if (parserResult) {
|
|
3087
|
-
const done =
|
|
2677
|
+
const done = import_logger9.logger.time.info(ctx2.messages.buildComplete(1));
|
|
3088
2678
|
const sheet = ctx2.createSheet();
|
|
3089
2679
|
ctx2.appendLayerParams(sheet);
|
|
3090
2680
|
ctx2.appendBaselineCss(sheet);
|
|
@@ -3136,18 +2726,18 @@ function setupGitIgnore(ctx) {
|
|
|
3136
2726
|
|
|
3137
2727
|
// src/logstream.ts
|
|
3138
2728
|
init_cjs_shims();
|
|
3139
|
-
var
|
|
2729
|
+
var import_logger10 = require("@pandacss/logger");
|
|
3140
2730
|
var import_node_fs2 = __toESM(require("fs"));
|
|
3141
|
-
var
|
|
2731
|
+
var import_node_path2 = __toESM(require("path"));
|
|
3142
2732
|
var setLogStream = (options) => {
|
|
3143
2733
|
const { cwd = process.cwd() } = options;
|
|
3144
2734
|
let stream;
|
|
3145
2735
|
if (options.logfile) {
|
|
3146
|
-
const outPath =
|
|
2736
|
+
const outPath = import_node_path2.default.resolve(cwd, options.logfile);
|
|
3147
2737
|
ensure(outPath);
|
|
3148
|
-
|
|
2738
|
+
import_logger10.logger.info("logfile", outPath);
|
|
3149
2739
|
stream = import_node_fs2.default.createWriteStream(outPath, { flags: "a" });
|
|
3150
|
-
|
|
2740
|
+
import_logger10.logger.onLog = (entry) => {
|
|
3151
2741
|
stream?.write(JSON.stringify(entry) + "\n");
|
|
3152
2742
|
};
|
|
3153
2743
|
}
|
|
@@ -3164,7 +2754,7 @@ var setLogStream = (options) => {
|
|
|
3164
2754
|
};
|
|
3165
2755
|
};
|
|
3166
2756
|
var ensure = (outPath) => {
|
|
3167
|
-
const dirname2 =
|
|
2757
|
+
const dirname2 = import_node_path2.default.dirname(outPath);
|
|
3168
2758
|
import_node_fs2.default.mkdirSync(dirname2, { recursive: true });
|
|
3169
2759
|
return outPath;
|
|
3170
2760
|
};
|
|
@@ -3173,7 +2763,7 @@ var ensure = (outPath) => {
|
|
|
3173
2763
|
init_cjs_shims();
|
|
3174
2764
|
var import_config7 = require("@pandacss/config");
|
|
3175
2765
|
var import_core2 = require("@pandacss/core");
|
|
3176
|
-
var
|
|
2766
|
+
var import_logger11 = require("@pandacss/logger");
|
|
3177
2767
|
var import_shared3 = require("@pandacss/shared");
|
|
3178
2768
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
3179
2769
|
var import_look_it_up2 = require("look-it-up");
|
|
@@ -3196,9 +2786,9 @@ async function setupConfig(cwd, opts = {}) {
|
|
|
3196
2786
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
3197
2787
|
const isTs = (0, import_look_it_up2.lookItUpSync)("tsconfig.json", cwd);
|
|
3198
2788
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
3199
|
-
|
|
2789
|
+
import_logger11.logger.info("init:config", `creating panda config file: ${(0, import_logger11.quote)(file)}`);
|
|
3200
2790
|
if (!force && configFile) {
|
|
3201
|
-
|
|
2791
|
+
import_logger11.logger.warn("init:config", import_core2.messages.configExists(cmd));
|
|
3202
2792
|
} else {
|
|
3203
2793
|
const content = import_outdent2.outdent`
|
|
3204
2794
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -3231,11 +2821,11 @@ syntax: '${syntax}'` : ""}
|
|
|
3231
2821
|
})
|
|
3232
2822
|
`;
|
|
3233
2823
|
await import_fs_extra2.default.writeFile((0, import_path5.join)(cwd, file), await import_prettier.default.format(content, { parser: "babel" }));
|
|
3234
|
-
|
|
2824
|
+
import_logger11.logger.log(import_core2.messages.thankYou());
|
|
3235
2825
|
}
|
|
3236
2826
|
}
|
|
3237
2827
|
async function setupPostcss(cwd) {
|
|
3238
|
-
|
|
2828
|
+
import_logger11.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger11.quote)("postcss.config.cjs")}`);
|
|
3239
2829
|
const content = import_outdent2.outdent`
|
|
3240
2830
|
module.exports = {
|
|
3241
2831
|
plugins: {
|
|
@@ -3249,7 +2839,7 @@ module.exports = {
|
|
|
3249
2839
|
0 && (module.exports = {
|
|
3250
2840
|
Builder,
|
|
3251
2841
|
PandaContext,
|
|
3252
|
-
|
|
2842
|
+
analyze,
|
|
3253
2843
|
buildInfo,
|
|
3254
2844
|
codegen,
|
|
3255
2845
|
cssgen,
|
|
@@ -3261,6 +2851,5 @@ module.exports = {
|
|
|
3261
2851
|
setupConfig,
|
|
3262
2852
|
setupGitIgnore,
|
|
3263
2853
|
setupPostcss,
|
|
3264
|
-
startProfiling
|
|
3265
|
-
writeAnalyzeJSON
|
|
2854
|
+
startProfiling
|
|
3266
2855
|
});
|