@pandacss/node 0.49.0 → 0.51.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 +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.js +112 -523
- package/dist/index.mjs +110 -520
- package/package.json +11 -13
package/dist/index.mjs
CHANGED
|
@@ -27,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// ../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.7.6_@swc+helpers@0.4.36__postcss@8.4.49_typescript@5.6.2/node_modules/tsup/assets/esm_shims.js
|
|
31
31
|
var init_esm_shims = __esm({
|
|
32
|
-
"../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.
|
|
32
|
+
"../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.7.6_@swc+helpers@0.4.36__postcss@8.4.49_typescript@5.6.2/node_modules/tsup/assets/esm_shims.js"() {
|
|
33
33
|
"use strict";
|
|
34
34
|
}
|
|
35
35
|
});
|
|
@@ -397,473 +397,65 @@ var require_ansi_align = __commonJS({
|
|
|
397
397
|
// src/index.ts
|
|
398
398
|
init_esm_shims();
|
|
399
399
|
|
|
400
|
-
// src/analyze
|
|
400
|
+
// src/analyze.ts
|
|
401
401
|
init_esm_shims();
|
|
402
|
-
import {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
var version = "0.49.0";
|
|
410
|
-
|
|
411
|
-
// src/classify.ts
|
|
412
|
-
init_esm_shims();
|
|
413
|
-
import { box } from "@pandacss/extractor";
|
|
414
|
-
var createReportMaps = () => {
|
|
415
|
-
const byComponentOfKind = /* @__PURE__ */ new Map();
|
|
416
|
-
const byPropertyName = /* @__PURE__ */ new Map();
|
|
417
|
-
const byTokenType = /* @__PURE__ */ new Map();
|
|
418
|
-
const byConditionName = /* @__PURE__ */ new Map();
|
|
419
|
-
const byShorthand = /* @__PURE__ */ new Map();
|
|
420
|
-
const byTokenName = /* @__PURE__ */ new Map();
|
|
421
|
-
const byPropertyPath = /* @__PURE__ */ new Map();
|
|
422
|
-
const fromKind = /* @__PURE__ */ new Map();
|
|
423
|
-
const byType = /* @__PURE__ */ new Map();
|
|
424
|
-
const byComponentName = /* @__PURE__ */ new Map();
|
|
425
|
-
const colorsUsed = /* @__PURE__ */ new Map();
|
|
426
|
-
return {
|
|
427
|
-
byComponentOfKind,
|
|
428
|
-
byPropertyName,
|
|
429
|
-
byTokenType,
|
|
430
|
-
byConditionName,
|
|
431
|
-
byShorthand,
|
|
432
|
-
byTokenName,
|
|
433
|
-
byPropertyPath,
|
|
434
|
-
fromKind,
|
|
435
|
-
byType,
|
|
436
|
-
byComponentName,
|
|
437
|
-
colorsUsed
|
|
438
|
-
};
|
|
439
|
-
};
|
|
440
|
-
var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
441
|
-
const byId = /* @__PURE__ */ new Map();
|
|
442
|
-
const byComponentIndex = /* @__PURE__ */ new Map();
|
|
443
|
-
const byFilepath = /* @__PURE__ */ new Map();
|
|
444
|
-
const byComponentInFilepath = /* @__PURE__ */ new Map();
|
|
445
|
-
const globalMaps = createReportMaps();
|
|
446
|
-
const byFilePathMaps = /* @__PURE__ */ new Map();
|
|
447
|
-
const conditions = new Map(Object.entries(ctx.conditions.values));
|
|
448
|
-
const { groupByProp } = getPropertyGroupMap(ctx);
|
|
449
|
-
let id = 0, componentIndex = 0;
|
|
450
|
-
const isKnownUtility = (reportItem, componentReportItem) => {
|
|
451
|
-
const { propName, value } = reportItem;
|
|
452
|
-
const utility = ctx.config.utilities?.[propName];
|
|
453
|
-
if (utility) {
|
|
454
|
-
if (!utility.shorthand) {
|
|
455
|
-
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
456
|
-
}
|
|
457
|
-
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
458
|
-
}
|
|
459
|
-
if (componentReportItem.reportItemType === "pattern") {
|
|
460
|
-
const pattern = ctx.patterns.getConfig(componentReportItem.componentName.toLowerCase());
|
|
461
|
-
const patternProp = pattern?.properties?.[propName];
|
|
462
|
-
if (!patternProp)
|
|
463
|
-
return false;
|
|
464
|
-
if (patternProp.type === "boolean" || patternProp.type === "number") {
|
|
465
|
-
return true;
|
|
466
|
-
}
|
|
467
|
-
if (patternProp.type === "property" && patternProp.value) {
|
|
468
|
-
return Boolean(ctx.config.utilities?.[patternProp.value]);
|
|
469
|
-
}
|
|
470
|
-
if (patternProp.type === "enum" && patternProp.value) {
|
|
471
|
-
return Boolean(patternProp.value.includes(String(value)));
|
|
472
|
-
}
|
|
473
|
-
if (patternProp.type === "token") {
|
|
474
|
-
return Boolean(ctx.tokens.getByName(`${patternProp.value}.${value}`));
|
|
475
|
-
}
|
|
476
|
-
return false;
|
|
477
|
-
}
|
|
478
|
-
return false;
|
|
479
|
-
};
|
|
480
|
-
parserResultByFilepath.forEach((parserResult, filepath) => {
|
|
481
|
-
if (parserResult.isEmpty())
|
|
482
|
-
return;
|
|
483
|
-
const localMaps = createReportMaps();
|
|
484
|
-
const addTo = (map, key, value) => {
|
|
485
|
-
const set = map.get(key) ?? /* @__PURE__ */ new Set();
|
|
486
|
-
set.add(value);
|
|
487
|
-
map.set(key, set);
|
|
488
|
-
};
|
|
489
|
-
const processMap = (map, current, componentReportItem) => {
|
|
490
|
-
const { reportItemType: type, kind } = componentReportItem;
|
|
491
|
-
const name = componentReportItem.componentName;
|
|
492
|
-
map.value.forEach((attrNode, attrName) => {
|
|
493
|
-
if (box.isLiteral(attrNode) || box.isEmptyInitializer(attrNode)) {
|
|
494
|
-
const value = box.isLiteral(attrNode) ? attrNode.value : true;
|
|
495
|
-
const propReportItem = {
|
|
496
|
-
index: String(id++),
|
|
497
|
-
componentIndex: String(componentReportItem.componentIndex),
|
|
498
|
-
componentName: name,
|
|
499
|
-
tokenType: void 0,
|
|
500
|
-
propName: attrName,
|
|
501
|
-
reportItemKind: "utility",
|
|
502
|
-
reportItemType: type,
|
|
503
|
-
kind,
|
|
504
|
-
filepath,
|
|
505
|
-
path: current.concat(attrName),
|
|
506
|
-
value,
|
|
507
|
-
isKnownValue: false,
|
|
508
|
-
range: map.getRange()
|
|
509
|
-
};
|
|
510
|
-
componentReportItem.contains.push(propReportItem.index);
|
|
511
|
-
if (conditions.has(attrName)) {
|
|
512
|
-
addTo(globalMaps.byConditionName, attrName, propReportItem.index);
|
|
513
|
-
addTo(localMaps.byConditionName, attrName, propReportItem.index);
|
|
514
|
-
propReportItem.propName = current[0] ?? attrName;
|
|
515
|
-
propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
|
|
516
|
-
propReportItem.conditionName = attrName;
|
|
517
|
-
} else {
|
|
518
|
-
if (current.length && conditions.has(current[0])) {
|
|
519
|
-
propReportItem.conditionName = current[0];
|
|
520
|
-
addTo(globalMaps.byConditionName, current[0], propReportItem.index);
|
|
521
|
-
addTo(localMaps.byConditionName, current[0], propReportItem.index);
|
|
522
|
-
}
|
|
523
|
-
const propName = ctx.utility.shorthands.get(attrName) ?? attrName;
|
|
524
|
-
propReportItem.propName = propName;
|
|
525
|
-
const utility = ctx.config.utilities?.[propName];
|
|
526
|
-
propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
|
|
527
|
-
const tokenType = typeof utility?.values === "string" ? utility?.values : void 0;
|
|
528
|
-
if (tokenType) {
|
|
529
|
-
propReportItem.reportItemKind = "token";
|
|
530
|
-
propReportItem.tokenType = tokenType;
|
|
531
|
-
}
|
|
532
|
-
addTo(globalMaps.byPropertyName, propName, propReportItem.index);
|
|
533
|
-
addTo(localMaps.byPropertyName, propName, propReportItem.index);
|
|
534
|
-
if (tokenType) {
|
|
535
|
-
addTo(globalMaps.byTokenType, tokenType, propReportItem.index);
|
|
536
|
-
addTo(localMaps.byTokenType, tokenType, propReportItem.index);
|
|
537
|
-
}
|
|
538
|
-
if (propName.toLowerCase().includes("color") || groupByProp.get(propName) === "Color" || tokenType === "colors") {
|
|
539
|
-
addTo(globalMaps.colorsUsed, value, propReportItem.index);
|
|
540
|
-
addTo(localMaps.colorsUsed, value, propReportItem.index);
|
|
541
|
-
}
|
|
542
|
-
if (ctx.utility.shorthands.has(attrName)) {
|
|
543
|
-
addTo(globalMaps.byShorthand, attrName, propReportItem.index);
|
|
544
|
-
addTo(localMaps.byShorthand, attrName, propReportItem.index);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
if (current.length) {
|
|
548
|
-
addTo(globalMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
|
|
549
|
-
addTo(localMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
|
|
550
|
-
}
|
|
551
|
-
addTo(globalMaps.byTokenName, String(value), propReportItem.index);
|
|
552
|
-
addTo(localMaps.byTokenName, String(value), propReportItem.index);
|
|
553
|
-
addTo(globalMaps.byType, type, propReportItem.index);
|
|
554
|
-
addTo(localMaps.byType, type, propReportItem.index);
|
|
555
|
-
addTo(globalMaps.byComponentName, name, propReportItem.index);
|
|
556
|
-
addTo(localMaps.byComponentName, name, propReportItem.index);
|
|
557
|
-
addTo(globalMaps.fromKind, kind, propReportItem.index);
|
|
558
|
-
addTo(localMaps.fromKind, kind, propReportItem.index);
|
|
559
|
-
addTo(byFilepath, filepath, propReportItem.index);
|
|
560
|
-
byId.set(propReportItem.index, propReportItem);
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
if (box.isMap(attrNode) && attrNode.value.size) {
|
|
564
|
-
return processMap(attrNode, current.concat(attrName), componentReportItem);
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
};
|
|
568
|
-
const processResultItem = (item, kind) => {
|
|
569
|
-
if (!item.box || box.isUnresolvable(item.box)) {
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
if (!item.data) {
|
|
573
|
-
console.log("no data", item);
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
const componentReportItem = {
|
|
577
|
-
componentIndex: String(componentIndex++),
|
|
578
|
-
componentName: item.name,
|
|
579
|
-
reportItemType: item.type,
|
|
580
|
-
kind,
|
|
581
|
-
filepath,
|
|
582
|
-
value: item.data,
|
|
583
|
-
range: item.box.getRange(),
|
|
584
|
-
contains: []
|
|
585
|
-
};
|
|
586
|
-
if (box.isArray(item.box)) {
|
|
587
|
-
addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
|
|
588
|
-
return componentReportItem;
|
|
589
|
-
}
|
|
590
|
-
if (box.isMap(item.box) && item.box.value.size) {
|
|
591
|
-
addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
|
|
592
|
-
processMap(item.box, [], componentReportItem);
|
|
593
|
-
return componentReportItem;
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
const processComponentResultItem = (item) => {
|
|
597
|
-
const componentReportItem = processResultItem(item, "component");
|
|
598
|
-
if (!componentReportItem)
|
|
599
|
-
return;
|
|
600
|
-
addTo(globalMaps.byComponentOfKind, "component", componentReportItem.componentIndex);
|
|
601
|
-
addTo(localMaps.byComponentOfKind, "component", componentReportItem.componentIndex);
|
|
602
|
-
byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
|
|
603
|
-
};
|
|
604
|
-
const processFunctionResultItem = (item) => {
|
|
605
|
-
const componentReportItem = processResultItem(item, "function");
|
|
606
|
-
if (!componentReportItem)
|
|
607
|
-
return;
|
|
608
|
-
addTo(globalMaps.byComponentOfKind, "function", componentReportItem.componentIndex);
|
|
609
|
-
addTo(localMaps.byComponentOfKind, "function", componentReportItem.componentIndex);
|
|
610
|
-
byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
|
|
611
|
-
};
|
|
612
|
-
parserResult.jsx.forEach(processComponentResultItem);
|
|
613
|
-
parserResult.css.forEach(processFunctionResultItem);
|
|
614
|
-
parserResult.cva.forEach(processFunctionResultItem);
|
|
615
|
-
parserResult.pattern.forEach((itemList) => {
|
|
616
|
-
itemList.forEach(processFunctionResultItem);
|
|
617
|
-
});
|
|
618
|
-
parserResult.recipe.forEach((itemList) => {
|
|
619
|
-
itemList.forEach(processFunctionResultItem);
|
|
620
|
-
});
|
|
621
|
-
byFilePathMaps.set(filepath, localMaps);
|
|
402
|
+
import { Reporter, formatRecipeReport, formatTokenReport } from "@pandacss/reporter";
|
|
403
|
+
function analyze(ctx, options = {}) {
|
|
404
|
+
const reporter = new Reporter(ctx, {
|
|
405
|
+
project: ctx.project,
|
|
406
|
+
getRelativePath: ctx.runtime.path.relative,
|
|
407
|
+
getFiles: ctx.getFiles,
|
|
408
|
+
...options
|
|
622
409
|
});
|
|
623
|
-
|
|
624
|
-
const filesWithMostComponent = Object.fromEntries(
|
|
625
|
-
Array.from(byComponentInFilepath.entries()).map(([filepath, list]) => [filepath, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
|
|
626
|
-
);
|
|
410
|
+
reporter.init();
|
|
627
411
|
return {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
counts: {
|
|
632
|
-
filesWithTokens: byFilepath.size,
|
|
633
|
-
propNameUsed: globalMaps.byPropertyName.size,
|
|
634
|
-
tokenUsed: globalMaps.byTokenName.size,
|
|
635
|
-
shorthandUsed: globalMaps.byShorthand.size,
|
|
636
|
-
propertyPathUsed: globalMaps.byPropertyPath.size,
|
|
637
|
-
typeUsed: globalMaps.byType.size,
|
|
638
|
-
componentNameUsed: globalMaps.byComponentName.size,
|
|
639
|
-
kindUsed: globalMaps.fromKind.size,
|
|
640
|
-
componentOfKindUsed: globalMaps.byComponentOfKind.size,
|
|
641
|
-
colorsUsed: globalMaps.colorsUsed.size
|
|
642
|
-
},
|
|
643
|
-
stats: {
|
|
644
|
-
filesWithMostComponent,
|
|
645
|
-
mostUseds: getXMostUseds(globalMaps, 10)
|
|
646
|
-
}
|
|
412
|
+
getRecipeReport(format = "table") {
|
|
413
|
+
const report = reporter.getRecipeReport();
|
|
414
|
+
return { report, formatted: formatRecipeReport(report, format) };
|
|
647
415
|
},
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
globalMaps,
|
|
652
|
-
byFilePathMaps
|
|
653
|
-
}
|
|
654
|
-
};
|
|
655
|
-
};
|
|
656
|
-
var getXMostUseds = (globalMaps, pickCount) => {
|
|
657
|
-
return {
|
|
658
|
-
propNames: getMostUsedInMap(globalMaps.byPropertyName, pickCount),
|
|
659
|
-
tokens: getMostUsedInMap(globalMaps.byTokenName, pickCount),
|
|
660
|
-
shorthands: getMostUsedInMap(globalMaps.byShorthand, pickCount),
|
|
661
|
-
conditions: getMostUsedInMap(globalMaps.byConditionName, pickCount),
|
|
662
|
-
propertyPaths: getMostUsedInMap(globalMaps.byPropertyPath, pickCount),
|
|
663
|
-
categories: getMostUsedInMap(globalMaps.byTokenType, pickCount),
|
|
664
|
-
types: getMostUsedInMap(globalMaps.byType, pickCount),
|
|
665
|
-
componentNames: getMostUsedInMap(globalMaps.byComponentName, pickCount),
|
|
666
|
-
fromKinds: getMostUsedInMap(globalMaps.fromKind, pickCount),
|
|
667
|
-
componentOfKinds: getMostUsedInMap(globalMaps.byComponentOfKind, pickCount),
|
|
668
|
-
colors: getMostUsedInMap(globalMaps.colorsUsed, pickCount)
|
|
669
|
-
};
|
|
670
|
-
};
|
|
671
|
-
var getMostUsedInMap = (map, pickCount) => {
|
|
672
|
-
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 }));
|
|
673
|
-
};
|
|
674
|
-
var defaultGroupNames = [
|
|
675
|
-
"System",
|
|
676
|
-
"Container",
|
|
677
|
-
"Display",
|
|
678
|
-
"Visibility",
|
|
679
|
-
"Position",
|
|
680
|
-
"Transform",
|
|
681
|
-
"Flex Layout",
|
|
682
|
-
"Grid Layout",
|
|
683
|
-
"Layout",
|
|
684
|
-
"Border",
|
|
685
|
-
"Border Radius",
|
|
686
|
-
"Width",
|
|
687
|
-
"Height",
|
|
688
|
-
"Margin",
|
|
689
|
-
"Padding",
|
|
690
|
-
"Color",
|
|
691
|
-
"Typography",
|
|
692
|
-
"Background",
|
|
693
|
-
"Shadow",
|
|
694
|
-
"Table",
|
|
695
|
-
"List",
|
|
696
|
-
"Scroll",
|
|
697
|
-
"Interactivity",
|
|
698
|
-
"Transition",
|
|
699
|
-
"Effect",
|
|
700
|
-
"Other"
|
|
701
|
-
];
|
|
702
|
-
var getPropertyGroupMap = (context) => {
|
|
703
|
-
const groups = new Map(defaultGroupNames.map((name) => [name, /* @__PURE__ */ new Set()]));
|
|
704
|
-
const groupByProp = /* @__PURE__ */ new Map();
|
|
705
|
-
const systemGroup = groups.get("System");
|
|
706
|
-
systemGroup.add("base");
|
|
707
|
-
systemGroup.add("colorPalette");
|
|
708
|
-
const otherStyleProps = groups.get("Other");
|
|
709
|
-
Object.entries(context.utility.config).map(([key, value]) => {
|
|
710
|
-
const group = value?.group;
|
|
711
|
-
if (!group) {
|
|
712
|
-
otherStyleProps.add(key);
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
if (!groups.has(group)) {
|
|
716
|
-
groups.set(group, /* @__PURE__ */ new Set());
|
|
717
|
-
}
|
|
718
|
-
const set = groups.get(group);
|
|
719
|
-
if (value.shorthand) {
|
|
720
|
-
if (Array.isArray(value.shorthand)) {
|
|
721
|
-
value.shorthand.forEach((shorthand) => {
|
|
722
|
-
set.add(shorthand);
|
|
723
|
-
groupByProp.set(shorthand, group);
|
|
724
|
-
});
|
|
725
|
-
} else {
|
|
726
|
-
set.add(value.shorthand);
|
|
727
|
-
groupByProp.set(value.shorthand, group);
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
set.add(key);
|
|
731
|
-
groupByProp.set(key, group);
|
|
732
|
-
});
|
|
733
|
-
return { groups, groupByProp };
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
// src/analyze-tokens.ts
|
|
737
|
-
var gzipSizeSync = (code) => zlib.gzipSync(code, { level: zlib.constants.Z_BEST_COMPRESSION }).length;
|
|
738
|
-
function analyzeTokens(ctx, options = {}) {
|
|
739
|
-
const filesMap = /* @__PURE__ */ new Map();
|
|
740
|
-
const timesMap = /* @__PURE__ */ new Map();
|
|
741
|
-
const files = ctx.getFiles();
|
|
742
|
-
const sheet = ctx.createSheet();
|
|
743
|
-
ctx.appendLayerParams(sheet);
|
|
744
|
-
ctx.appendBaselineCss(sheet);
|
|
745
|
-
files.forEach((file) => {
|
|
746
|
-
const start2 = performance.now();
|
|
747
|
-
const result = ctx.project.parseSourceFile(file);
|
|
748
|
-
const extractMs = performance.now() - start2;
|
|
749
|
-
const relativePath = path.relative(ctx.config.cwd, file);
|
|
750
|
-
timesMap.set(relativePath, extractMs);
|
|
751
|
-
logger.debug("analyze", `Parsed ${file} in ${extractMs}ms`);
|
|
752
|
-
if (result) {
|
|
753
|
-
filesMap.set(relativePath, result);
|
|
754
|
-
options.onResult?.(file, result);
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
const totalMs = Array.from(timesMap.values()).reduce((a, b) => a + b, 0);
|
|
758
|
-
logger.debug("analyze", `Analyzed ${files.length} files in ${totalMs.toFixed(2)}ms`);
|
|
759
|
-
ctx.appendParserCss(sheet);
|
|
760
|
-
const cssStart = performance.now();
|
|
761
|
-
ctx.config.minify = false;
|
|
762
|
-
const css = ctx.getCss(sheet);
|
|
763
|
-
const cssMs = performance.now() - cssStart;
|
|
764
|
-
const cssMinifyStart = performance.now();
|
|
765
|
-
ctx.config.minify = true;
|
|
766
|
-
const minifiedCss = ctx.getCss(sheet);
|
|
767
|
-
const cssMinifyMs = performance.now() - cssMinifyStart;
|
|
768
|
-
let lightningCss = "";
|
|
769
|
-
let lightningCssMs;
|
|
770
|
-
let lightningCssMinifiedCss = "";
|
|
771
|
-
let lightningCssMinifiedMs;
|
|
772
|
-
const isUsingLightningCss = ctx.config.lightningcss;
|
|
773
|
-
if (!isUsingLightningCss) {
|
|
774
|
-
sheet["context"].lightningcss = true;
|
|
775
|
-
ctx.config.minify = false;
|
|
776
|
-
const lightningcssStart = performance.now();
|
|
777
|
-
lightningCss = ctx.getCss(sheet);
|
|
778
|
-
lightningCssMs = performance.now() - lightningcssStart;
|
|
779
|
-
ctx.config.minify = true;
|
|
780
|
-
const lightningcssMinifyStart = performance.now();
|
|
781
|
-
lightningCssMinifiedCss = ctx.getCss(sheet);
|
|
782
|
-
lightningCssMinifiedMs = performance.now() - lightningcssMinifyStart;
|
|
783
|
-
}
|
|
784
|
-
const start = performance.now();
|
|
785
|
-
const analysis = classifyTokens(ctx, filesMap);
|
|
786
|
-
const classifyMs = performance.now() - start;
|
|
787
|
-
const details = Object.assign(
|
|
788
|
-
{
|
|
789
|
-
duration: {
|
|
790
|
-
classify: classifyMs,
|
|
791
|
-
//
|
|
792
|
-
cssMs,
|
|
793
|
-
cssMinifyMs,
|
|
794
|
-
//
|
|
795
|
-
...!isUsingLightningCss ? {
|
|
796
|
-
lightningCssMs,
|
|
797
|
-
lightningCssMinifiedMs
|
|
798
|
-
} : {},
|
|
799
|
-
//
|
|
800
|
-
extractTotal: totalMs,
|
|
801
|
-
extractTimeByFiles: Object.fromEntries(timesMap.entries())
|
|
802
|
-
},
|
|
803
|
-
fileSizes: {
|
|
804
|
-
lineCount: css.split("\n").length,
|
|
805
|
-
normal: filesize(Buffer.byteLength(css, "utf-8")),
|
|
806
|
-
minified: filesize(Buffer.byteLength(minifiedCss, "utf-8")),
|
|
807
|
-
gzip: {
|
|
808
|
-
normal: filesize(gzipSizeSync(css)),
|
|
809
|
-
minified: filesize(gzipSizeSync(minifiedCss))
|
|
810
|
-
},
|
|
811
|
-
lightningCss: !isUsingLightningCss ? {
|
|
812
|
-
normal: filesize(Buffer.byteLength(lightningCss, "utf-8")),
|
|
813
|
-
minified: filesize(Buffer.byteLength(lightningCssMinifiedCss, "utf-8"))
|
|
814
|
-
} : void 0
|
|
815
|
-
}
|
|
416
|
+
getTokenReport(format = "table") {
|
|
417
|
+
const report = reporter.getTokenReport();
|
|
418
|
+
return { report, formatted: formatTokenReport(report.getSummary(), format) };
|
|
816
419
|
},
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
propByIndex: analysis.propById,
|
|
824
|
-
componentByIndex: analysis.componentById,
|
|
825
|
-
derived: analysis.derived,
|
|
826
|
-
config
|
|
420
|
+
writeReport(filePath) {
|
|
421
|
+
const dirname2 = ctx.runtime.path.dirname(filePath);
|
|
422
|
+
ctx.runtime.fs.ensureDirSync(dirname2);
|
|
423
|
+
const str = JSON.stringify(reporter.report, replacer, 2);
|
|
424
|
+
return ctx.runtime.fs.writeFile(filePath, str);
|
|
425
|
+
}
|
|
827
426
|
};
|
|
828
427
|
}
|
|
829
|
-
|
|
830
|
-
if (value instanceof Set)
|
|
428
|
+
function replacer(_, value) {
|
|
429
|
+
if (value instanceof Set)
|
|
831
430
|
return Array.from(value);
|
|
832
|
-
|
|
833
|
-
if (value instanceof Map) {
|
|
431
|
+
if (value instanceof Map)
|
|
834
432
|
return Object.fromEntries(value);
|
|
835
|
-
}
|
|
836
433
|
return value;
|
|
837
|
-
}
|
|
838
|
-
var writeAnalyzeJSON = (filePath, result, ctx) => {
|
|
839
|
-
const dirname2 = ctx.runtime.path.dirname(filePath);
|
|
840
|
-
ctx.runtime.fs.ensureDirSync(dirname2);
|
|
841
|
-
return writeFile(filePath, JSON.stringify(result, analyzeResultSerializer, 2));
|
|
842
|
-
};
|
|
434
|
+
}
|
|
843
435
|
|
|
844
436
|
// src/build-info.ts
|
|
845
437
|
init_esm_shims();
|
|
846
|
-
import { colors, logger
|
|
438
|
+
import { colors, logger } from "@pandacss/logger";
|
|
847
439
|
async function buildInfo(ctx, outfile) {
|
|
848
440
|
const { filesWithCss, files } = ctx.parseFiles();
|
|
849
|
-
|
|
441
|
+
logger.info("cli", `Found ${colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
850
442
|
const { minify, staticCss } = ctx.config;
|
|
851
|
-
|
|
443
|
+
logger.info("cli", `Writing ${minify ? "[min] " : " "}${colors.bold(outfile)}`);
|
|
852
444
|
if (staticCss) {
|
|
853
|
-
|
|
445
|
+
logger.info("cli", "Adding staticCss definitions...");
|
|
854
446
|
ctx.staticCss.process(staticCss);
|
|
855
447
|
}
|
|
856
448
|
const output = JSON.stringify(ctx.encoder.toJSON(), null, minify ? 0 : 2);
|
|
857
449
|
ctx.output.ensure(outfile, process.cwd());
|
|
858
450
|
await ctx.runtime.fs.writeFile(outfile, output);
|
|
859
|
-
|
|
451
|
+
logger.info("cli", "Done!");
|
|
860
452
|
}
|
|
861
453
|
|
|
862
454
|
// src/builder.ts
|
|
863
455
|
init_esm_shims();
|
|
864
456
|
import { findConfig, getConfigDependencies } from "@pandacss/config";
|
|
865
457
|
import { optimizeCss } from "@pandacss/core";
|
|
866
|
-
import { logger as
|
|
458
|
+
import { logger as logger5 } from "@pandacss/logger";
|
|
867
459
|
import { PandaError, uniq as uniq2 } from "@pandacss/shared";
|
|
868
460
|
import { existsSync, statSync } from "fs";
|
|
869
461
|
import { normalize as normalize2, resolve as resolve3 } from "path";
|
|
@@ -1015,7 +607,7 @@ import browserslist from "browserslist";
|
|
|
1015
607
|
// src/create-context.ts
|
|
1016
608
|
init_esm_shims();
|
|
1017
609
|
import { Generator as Generator2 } from "@pandacss/generator";
|
|
1018
|
-
import { logger as
|
|
610
|
+
import { logger as logger4 } from "@pandacss/logger";
|
|
1019
611
|
import { Project } from "@pandacss/parser";
|
|
1020
612
|
import { uniq } from "@pandacss/shared";
|
|
1021
613
|
import { debounce } from "perfect-debounce";
|
|
@@ -1033,13 +625,12 @@ init_esm_shims();
|
|
|
1033
625
|
// ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
|
1034
626
|
init_esm_shims();
|
|
1035
627
|
|
|
1036
|
-
// ../../node_modules/.pnpm/ansi-regex@6.1
|
|
628
|
+
// ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
|
|
1037
629
|
init_esm_shims();
|
|
1038
630
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1039
|
-
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
1040
631
|
const pattern = [
|
|
1041
|
-
|
|
1042
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-
|
|
632
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
633
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
1043
634
|
].join("|");
|
|
1044
635
|
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
1045
636
|
}
|
|
@@ -1378,10 +969,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
1378
969
|
return 3;
|
|
1379
970
|
}
|
|
1380
971
|
if ("TERM_PROGRAM" in env) {
|
|
1381
|
-
const
|
|
972
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
1382
973
|
switch (env.TERM_PROGRAM) {
|
|
1383
974
|
case "iTerm.app": {
|
|
1384
|
-
return
|
|
975
|
+
return version >= 3 ? 3 : 2;
|
|
1385
976
|
}
|
|
1386
977
|
case "Apple_Terminal": {
|
|
1387
978
|
return 2;
|
|
@@ -1414,7 +1005,7 @@ var supports_color_default = supportsColor;
|
|
|
1414
1005
|
|
|
1415
1006
|
// ../../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
|
|
1416
1007
|
init_esm_shims();
|
|
1417
|
-
function stringReplaceAll(string, substring,
|
|
1008
|
+
function stringReplaceAll(string, substring, replacer2) {
|
|
1418
1009
|
let index = string.indexOf(substring);
|
|
1419
1010
|
if (index === -1) {
|
|
1420
1011
|
return string;
|
|
@@ -1423,7 +1014,7 @@ function stringReplaceAll(string, substring, replacer) {
|
|
|
1423
1014
|
let endIndex = 0;
|
|
1424
1015
|
let returnValue = "";
|
|
1425
1016
|
do {
|
|
1426
|
-
returnValue += string.slice(endIndex, index) + substring +
|
|
1017
|
+
returnValue += string.slice(endIndex, index) + substring + replacer2;
|
|
1427
1018
|
endIndex = index + substringLength;
|
|
1428
1019
|
index = string.indexOf(substring, endIndex);
|
|
1429
1020
|
} while (index !== -1);
|
|
@@ -2369,7 +1960,7 @@ var DiffEngine = class {
|
|
|
2369
1960
|
|
|
2370
1961
|
// src/node-runtime.ts
|
|
2371
1962
|
init_esm_shims();
|
|
2372
|
-
import { logger as
|
|
1963
|
+
import { logger as logger2 } from "@pandacss/logger";
|
|
2373
1964
|
import chokidar from "chokidar";
|
|
2374
1965
|
import glob from "fast-glob";
|
|
2375
1966
|
import fsExtra from "fs-extra";
|
|
@@ -2412,8 +2003,8 @@ var nodeRuntime = {
|
|
|
2412
2003
|
readDirSync: fsExtra.readdirSync,
|
|
2413
2004
|
rmDirSync: fsExtra.emptyDirSync,
|
|
2414
2005
|
rmFileSync: fsExtra.removeSync,
|
|
2415
|
-
ensureDirSync(
|
|
2416
|
-
return fsExtra.ensureDirSync(
|
|
2006
|
+
ensureDirSync(path3) {
|
|
2007
|
+
return fsExtra.ensureDirSync(path3);
|
|
2417
2008
|
},
|
|
2418
2009
|
watch(options) {
|
|
2419
2010
|
const { include, exclude, cwd, poll } = options;
|
|
@@ -2426,7 +2017,7 @@ var nodeRuntime = {
|
|
|
2426
2017
|
ignored: exclude,
|
|
2427
2018
|
awaitWriteFinish: coalesce ? { stabilityThreshold: 50, pollInterval: 10 } : false
|
|
2428
2019
|
});
|
|
2429
|
-
|
|
2020
|
+
logger2.debug("watch:file", `watching [${include}]`);
|
|
2430
2021
|
process.once("SIGINT", async () => {
|
|
2431
2022
|
await watcher.close();
|
|
2432
2023
|
});
|
|
@@ -2436,15 +2027,15 @@ var nodeRuntime = {
|
|
|
2436
2027
|
};
|
|
2437
2028
|
process.setMaxListeners(Infinity);
|
|
2438
2029
|
process.on("unhandledRejection", (reason) => {
|
|
2439
|
-
|
|
2030
|
+
logger2.error("\u274C", reason);
|
|
2440
2031
|
});
|
|
2441
2032
|
process.on("uncaughtException", (reason) => {
|
|
2442
|
-
|
|
2033
|
+
logger2.error("\u274C", reason);
|
|
2443
2034
|
});
|
|
2444
2035
|
|
|
2445
2036
|
// src/output-engine.ts
|
|
2446
2037
|
init_esm_shims();
|
|
2447
|
-
import { logger as
|
|
2038
|
+
import { logger as logger3 } from "@pandacss/logger";
|
|
2448
2039
|
var OutputEngine = class {
|
|
2449
2040
|
paths;
|
|
2450
2041
|
fs;
|
|
@@ -2475,7 +2066,7 @@ var OutputEngine = class {
|
|
|
2475
2066
|
return;
|
|
2476
2067
|
const { file, code } = artifact;
|
|
2477
2068
|
const absPath = this.path.join(...dir, file);
|
|
2478
|
-
|
|
2069
|
+
logger3.debug("write:file", dir.slice(-1).concat(file).join("/"));
|
|
2479
2070
|
return this.fs.writeFile(absPath, code);
|
|
2480
2071
|
})
|
|
2481
2072
|
);
|
|
@@ -2495,7 +2086,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2495
2086
|
this.runtime = nodeRuntime;
|
|
2496
2087
|
config.cwd ||= this.runtime.cwd();
|
|
2497
2088
|
if (config.logLevel) {
|
|
2498
|
-
|
|
2089
|
+
logger4.level = config.logLevel;
|
|
2499
2090
|
}
|
|
2500
2091
|
this.project = new Project({
|
|
2501
2092
|
...conf.tsconfig,
|
|
@@ -2529,14 +2120,14 @@ var PandaContext = class extends Generator2 {
|
|
|
2529
2120
|
};
|
|
2530
2121
|
parseFile = (filePath, styleEncoder) => {
|
|
2531
2122
|
const file = this.runtime.path.abs(this.config.cwd, filePath);
|
|
2532
|
-
|
|
2533
|
-
const measure =
|
|
2123
|
+
logger4.debug("file:extract", file);
|
|
2124
|
+
const measure = logger4.time.debug(`Parsed ${file}`);
|
|
2534
2125
|
let result;
|
|
2535
2126
|
try {
|
|
2536
2127
|
const encoder = styleEncoder || this.parserOptions.encoder;
|
|
2537
2128
|
result = this.project.parseSourceFile(file, encoder);
|
|
2538
2129
|
} catch (error) {
|
|
2539
|
-
|
|
2130
|
+
logger4.error("file:extract", error);
|
|
2540
2131
|
}
|
|
2541
2132
|
measure();
|
|
2542
2133
|
return result;
|
|
@@ -2547,7 +2138,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2547
2138
|
const filesWithCss = [];
|
|
2548
2139
|
const results = [];
|
|
2549
2140
|
files.forEach((file) => {
|
|
2550
|
-
const measure =
|
|
2141
|
+
const measure = logger4.time.debug(`Parsed ${file}`);
|
|
2551
2142
|
const result = this.project.parseSourceFile(file, encoder);
|
|
2552
2143
|
measure();
|
|
2553
2144
|
if (!result || result.isEmpty() || encoder.isEmpty())
|
|
@@ -2562,7 +2153,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2562
2153
|
};
|
|
2563
2154
|
};
|
|
2564
2155
|
writeCss = (sheet) => {
|
|
2565
|
-
|
|
2156
|
+
logger4.info("css", this.runtime.path.join(...this.paths.root, "styles.css"));
|
|
2566
2157
|
return this.output.write({
|
|
2567
2158
|
id: "styles.css",
|
|
2568
2159
|
dir: this.paths.root,
|
|
@@ -2571,7 +2162,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2571
2162
|
};
|
|
2572
2163
|
watchConfig = (cb, opts) => {
|
|
2573
2164
|
const { cwd, poll, exclude } = opts ?? {};
|
|
2574
|
-
|
|
2165
|
+
logger4.info("ctx:watch", this.messages.configWatch());
|
|
2575
2166
|
const watcher = this.runtime.fs.watch({
|
|
2576
2167
|
include: uniq([...this.explicitDeps, ...this.conf.dependencies]),
|
|
2577
2168
|
exclude,
|
|
@@ -2581,14 +2172,14 @@ var PandaContext = class extends Generator2 {
|
|
|
2581
2172
|
watcher.on(
|
|
2582
2173
|
"change",
|
|
2583
2174
|
debounce(async (file) => {
|
|
2584
|
-
|
|
2175
|
+
logger4.info("ctx:change", "config changed, rebuilding...");
|
|
2585
2176
|
await cb(file);
|
|
2586
2177
|
})
|
|
2587
2178
|
);
|
|
2588
2179
|
};
|
|
2589
2180
|
watchFiles = (cb, opts) => {
|
|
2590
2181
|
const { include, exclude, poll, cwd } = this.config;
|
|
2591
|
-
|
|
2182
|
+
logger4.info("ctx:watch", this.messages.watch());
|
|
2592
2183
|
const watcher = this.runtime.fs.watch({
|
|
2593
2184
|
...opts,
|
|
2594
2185
|
include,
|
|
@@ -2599,7 +2190,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2599
2190
|
watcher.on(
|
|
2600
2191
|
"all",
|
|
2601
2192
|
debounce(async (event, file) => {
|
|
2602
|
-
|
|
2193
|
+
logger4.info(`file:${event}`, file);
|
|
2603
2194
|
await cb(event, file);
|
|
2604
2195
|
})
|
|
2605
2196
|
);
|
|
@@ -2723,11 +2314,11 @@ var Builder = class {
|
|
|
2723
2314
|
configDeps.forEach((file) => {
|
|
2724
2315
|
this.configDependencies.add(file);
|
|
2725
2316
|
});
|
|
2726
|
-
|
|
2727
|
-
|
|
2317
|
+
logger5.debug("builder", "Config dependencies");
|
|
2318
|
+
logger5.debug("builder", configDeps);
|
|
2728
2319
|
}
|
|
2729
2320
|
setup = async (options = {}) => {
|
|
2730
|
-
|
|
2321
|
+
logger5.debug("builder", "\u{1F6A7} Setup");
|
|
2731
2322
|
const configPath = options.configPath ?? findConfig({ cwd: options.cwd });
|
|
2732
2323
|
this.setConfigDependencies({ configPath, cwd: options.cwd });
|
|
2733
2324
|
if (!this.context) {
|
|
@@ -2737,29 +2328,29 @@ var Builder = class {
|
|
|
2737
2328
|
this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2738
2329
|
this.context = new PandaContext(conf);
|
|
2739
2330
|
});
|
|
2740
|
-
|
|
2331
|
+
logger5.debug("builder", this.affecteds);
|
|
2741
2332
|
this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
|
|
2742
2333
|
if (this.explicitDepsMeta.hasFilesChanged) {
|
|
2743
2334
|
this.explicitDepsMeta.changes.forEach((meta, file) => {
|
|
2744
2335
|
fileModifiedMap.set(file, meta.mtime);
|
|
2745
2336
|
});
|
|
2746
|
-
|
|
2337
|
+
logger5.debug("builder", "\u2699\uFE0F Explicit config dependencies changed");
|
|
2747
2338
|
this.affecteds.hasConfigChanged = true;
|
|
2748
2339
|
}
|
|
2749
2340
|
if (this.affecteds.hasConfigChanged) {
|
|
2750
|
-
|
|
2341
|
+
logger5.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2751
2342
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: this.affecteds });
|
|
2752
2343
|
return;
|
|
2753
2344
|
}
|
|
2754
2345
|
this.filesMeta = this.checkFilesChanged(ctx.getFiles());
|
|
2755
2346
|
if (this.filesMeta.hasFilesChanged) {
|
|
2756
|
-
|
|
2347
|
+
logger5.debug("builder", "Files changed, invalidating them");
|
|
2757
2348
|
ctx.project.reloadSourceFiles();
|
|
2758
2349
|
}
|
|
2759
2350
|
};
|
|
2760
2351
|
async emit() {
|
|
2761
2352
|
if (this.hasEmitted && this.affecteds?.hasConfigChanged) {
|
|
2762
|
-
|
|
2353
|
+
logger5.debug("builder", "Emit artifacts after config change");
|
|
2763
2354
|
await codegen(this.getContextOrThrow(), Array.from(this.affecteds.artifacts));
|
|
2764
2355
|
}
|
|
2765
2356
|
this.hasEmitted = true;
|
|
@@ -2809,12 +2400,12 @@ var Builder = class {
|
|
|
2809
2400
|
extract = () => {
|
|
2810
2401
|
const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : true;
|
|
2811
2402
|
if (!this.filesMeta && !hasConfigChanged) {
|
|
2812
|
-
|
|
2403
|
+
logger5.debug("builder", "No files or config changed, skipping extract");
|
|
2813
2404
|
return;
|
|
2814
2405
|
}
|
|
2815
2406
|
const ctx = this.getContextOrThrow();
|
|
2816
2407
|
const files = ctx.getFiles();
|
|
2817
|
-
const done =
|
|
2408
|
+
const done = logger5.time.info("Extracted in");
|
|
2818
2409
|
files.map((file) => this.extractFile(ctx, file));
|
|
2819
2410
|
done();
|
|
2820
2411
|
};
|
|
@@ -2856,9 +2447,9 @@ var Builder = class {
|
|
|
2856
2447
|
|
|
2857
2448
|
// src/cpu-profile.ts
|
|
2858
2449
|
init_esm_shims();
|
|
2859
|
-
import { logger as
|
|
2450
|
+
import { logger as logger6 } from "@pandacss/logger";
|
|
2860
2451
|
import fs from "node:fs";
|
|
2861
|
-
import
|
|
2452
|
+
import path from "node:path";
|
|
2862
2453
|
import readline from "node:readline";
|
|
2863
2454
|
var startProfiling = async (cwd, prefix, isWatching) => {
|
|
2864
2455
|
const inspector = await import("node:inspector").then((r) => r.default);
|
|
@@ -2912,7 +2503,7 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2912
2503
|
session.post("Profiler.stop", (err, params) => {
|
|
2913
2504
|
setState("idle");
|
|
2914
2505
|
if (err) {
|
|
2915
|
-
|
|
2506
|
+
logger6.error("cpu-prof", err);
|
|
2916
2507
|
cb?.();
|
|
2917
2508
|
return;
|
|
2918
2509
|
}
|
|
@@ -2923,9 +2514,9 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2923
2514
|
const date = /* @__PURE__ */ new Date();
|
|
2924
2515
|
const timestamp = date.toISOString().replace(/[-:.]/g, "");
|
|
2925
2516
|
const title = `panda-${prefix}-${timestamp}`;
|
|
2926
|
-
const outfile =
|
|
2517
|
+
const outfile = path.join(cwd, `${title}.cpuprofile`);
|
|
2927
2518
|
fs.writeFileSync(outfile, JSON.stringify(params.profile));
|
|
2928
|
-
|
|
2519
|
+
logger6.info("cpu-prof", outfile);
|
|
2929
2520
|
cb?.();
|
|
2930
2521
|
});
|
|
2931
2522
|
};
|
|
@@ -2934,16 +2525,16 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2934
2525
|
|
|
2935
2526
|
// src/cssgen.ts
|
|
2936
2527
|
init_esm_shims();
|
|
2937
|
-
import { logger as
|
|
2528
|
+
import { logger as logger7 } from "@pandacss/logger";
|
|
2938
2529
|
var cssgen = async (ctx, options) => {
|
|
2939
2530
|
const { outfile, type, minimal } = options;
|
|
2940
2531
|
const sheet = ctx.createSheet();
|
|
2941
2532
|
if (type) {
|
|
2942
|
-
const done =
|
|
2533
|
+
const done = logger7.time.info(ctx.messages.cssArtifactComplete(type));
|
|
2943
2534
|
ctx.appendCssOfType(type, sheet);
|
|
2944
2535
|
if (outfile) {
|
|
2945
2536
|
const css = ctx.getCss(sheet);
|
|
2946
|
-
|
|
2537
|
+
logger7.info("css", ctx.runtime.path.resolve(outfile));
|
|
2947
2538
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2948
2539
|
} else {
|
|
2949
2540
|
await ctx.writeCss(sheet);
|
|
@@ -2951,7 +2542,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2951
2542
|
done();
|
|
2952
2543
|
} else {
|
|
2953
2544
|
const { files } = ctx.parseFiles();
|
|
2954
|
-
const done =
|
|
2545
|
+
const done = logger7.time.info(ctx.messages.buildComplete(files.length));
|
|
2955
2546
|
if (!minimal) {
|
|
2956
2547
|
ctx.appendLayerParams(sheet);
|
|
2957
2548
|
ctx.appendBaselineCss(sheet);
|
|
@@ -2959,7 +2550,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2959
2550
|
ctx.appendParserCss(sheet);
|
|
2960
2551
|
if (outfile) {
|
|
2961
2552
|
const css = ctx.getCss(sheet);
|
|
2962
|
-
|
|
2553
|
+
logger7.info("css", ctx.runtime.path.resolve(outfile));
|
|
2963
2554
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2964
2555
|
} else {
|
|
2965
2556
|
await ctx.writeCss(sheet);
|
|
@@ -2970,17 +2561,17 @@ var cssgen = async (ctx, options) => {
|
|
|
2970
2561
|
|
|
2971
2562
|
// src/debug.ts
|
|
2972
2563
|
init_esm_shims();
|
|
2973
|
-
import { colors as colors2, logger as
|
|
2564
|
+
import { colors as colors2, logger as logger8 } from "@pandacss/logger";
|
|
2974
2565
|
import { parse } from "path";
|
|
2975
2566
|
async function debug(ctx, options) {
|
|
2976
2567
|
const files = ctx.getFiles();
|
|
2977
|
-
const measureTotal =
|
|
2568
|
+
const measureTotal = logger8.time.debug(`Done parsing ${files.length} files`);
|
|
2978
2569
|
ctx.config.minify = false;
|
|
2979
|
-
const { fs: fs3, path:
|
|
2570
|
+
const { fs: fs3, path: path3 } = ctx.runtime;
|
|
2980
2571
|
const outdir = options.outdir;
|
|
2981
2572
|
if (!options.dry && outdir) {
|
|
2982
2573
|
fs3.ensureDirSync(outdir);
|
|
2983
|
-
|
|
2574
|
+
logger8.info("cli", `Writing ${colors2.bold(`${outdir}/config.json`)}`);
|
|
2984
2575
|
await fs3.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2985
2576
|
}
|
|
2986
2577
|
if (options.onlyConfig) {
|
|
@@ -2989,7 +2580,7 @@ async function debug(ctx, options) {
|
|
|
2989
2580
|
}
|
|
2990
2581
|
const filesWithCss = [];
|
|
2991
2582
|
files.map((file) => {
|
|
2992
|
-
const measure =
|
|
2583
|
+
const measure = logger8.time.debug(`Parsed ${file}`);
|
|
2993
2584
|
const encoder = ctx.encoder.clone();
|
|
2994
2585
|
const result = ctx.project.parseSourceFile(file, encoder);
|
|
2995
2586
|
measure();
|
|
@@ -3006,30 +2597,30 @@ async function debug(ctx, options) {
|
|
|
3006
2597
|
if (outdir) {
|
|
3007
2598
|
filesWithCss.push(file);
|
|
3008
2599
|
const parsedPath = parse(file);
|
|
3009
|
-
const relative2 =
|
|
3010
|
-
const astJsonPath = `${relative2}${
|
|
3011
|
-
const cssPath = `${relative2}${
|
|
3012
|
-
|
|
3013
|
-
|
|
2600
|
+
const relative2 = path3.relative(ctx.config.cwd, parsedPath.dir);
|
|
2601
|
+
const astJsonPath = `${relative2}${path3.sep}${parsedPath.name}.ast.json`.replaceAll(path3.sep, "__");
|
|
2602
|
+
const cssPath = `${relative2}${path3.sep}${parsedPath.name}.css`.replaceAll(path3.sep, "__");
|
|
2603
|
+
logger8.info("cli", `Writing ${colors2.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2604
|
+
logger8.info("cli", `Writing ${colors2.bold(`${outdir}/${cssPath}`)}`);
|
|
3014
2605
|
return Promise.allSettled([
|
|
3015
|
-
fs3.writeFile(`${outdir}${
|
|
3016
|
-
fs3.writeFile(`${outdir}${
|
|
2606
|
+
fs3.writeFile(`${outdir}${path3.sep}${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2607
|
+
fs3.writeFile(`${outdir}${path3.sep}${cssPath}`, css)
|
|
3017
2608
|
]);
|
|
3018
2609
|
}
|
|
3019
2610
|
});
|
|
3020
|
-
|
|
2611
|
+
logger8.info("cli", `Found ${colors2.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
3021
2612
|
measureTotal();
|
|
3022
2613
|
}
|
|
3023
2614
|
|
|
3024
2615
|
// src/generate.ts
|
|
3025
2616
|
init_esm_shims();
|
|
3026
|
-
import { logger as
|
|
2617
|
+
import { logger as logger9 } from "@pandacss/logger";
|
|
3027
2618
|
async function build(ctx, artifactIds) {
|
|
3028
2619
|
await codegen(ctx, artifactIds);
|
|
3029
2620
|
if (ctx.config.emitTokensOnly) {
|
|
3030
|
-
return
|
|
2621
|
+
return logger9.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
|
|
3031
2622
|
}
|
|
3032
|
-
const done =
|
|
2623
|
+
const done = logger9.time.info("");
|
|
3033
2624
|
const sheet = ctx.createSheet();
|
|
3034
2625
|
ctx.appendLayerParams(sheet);
|
|
3035
2626
|
ctx.appendBaselineCss(sheet);
|
|
@@ -3048,7 +2639,7 @@ async function generate(config, configPath) {
|
|
|
3048
2639
|
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
3049
2640
|
ctx = new PandaContext(conf);
|
|
3050
2641
|
});
|
|
3051
|
-
|
|
2642
|
+
logger9.info("ctx:updated", "config rebuilt \u2705");
|
|
3052
2643
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
|
|
3053
2644
|
return build(ctx, Array.from(affecteds.artifacts));
|
|
3054
2645
|
},
|
|
@@ -3058,7 +2649,7 @@ async function generate(config, configPath) {
|
|
|
3058
2649
|
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
3059
2650
|
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
3060
2651
|
if (parserResult) {
|
|
3061
|
-
const done =
|
|
2652
|
+
const done = logger9.time.info(ctx2.messages.buildComplete(1));
|
|
3062
2653
|
const sheet = ctx2.createSheet();
|
|
3063
2654
|
ctx2.appendLayerParams(sheet);
|
|
3064
2655
|
ctx2.appendBaselineCss(sheet);
|
|
@@ -3110,18 +2701,18 @@ function setupGitIgnore(ctx) {
|
|
|
3110
2701
|
|
|
3111
2702
|
// src/logstream.ts
|
|
3112
2703
|
init_esm_shims();
|
|
3113
|
-
import { logger as
|
|
2704
|
+
import { logger as logger10 } from "@pandacss/logger";
|
|
3114
2705
|
import fs2 from "node:fs";
|
|
3115
|
-
import
|
|
2706
|
+
import path2 from "node:path";
|
|
3116
2707
|
var setLogStream = (options) => {
|
|
3117
2708
|
const { cwd = process.cwd() } = options;
|
|
3118
2709
|
let stream;
|
|
3119
2710
|
if (options.logfile) {
|
|
3120
|
-
const outPath =
|
|
2711
|
+
const outPath = path2.resolve(cwd, options.logfile);
|
|
3121
2712
|
ensure(outPath);
|
|
3122
|
-
|
|
2713
|
+
logger10.info("logfile", outPath);
|
|
3123
2714
|
stream = fs2.createWriteStream(outPath, { flags: "a" });
|
|
3124
|
-
|
|
2715
|
+
logger10.onLog = (entry) => {
|
|
3125
2716
|
stream?.write(JSON.stringify(entry) + "\n");
|
|
3126
2717
|
};
|
|
3127
2718
|
}
|
|
@@ -3138,7 +2729,7 @@ var setLogStream = (options) => {
|
|
|
3138
2729
|
};
|
|
3139
2730
|
};
|
|
3140
2731
|
var ensure = (outPath) => {
|
|
3141
|
-
const dirname2 =
|
|
2732
|
+
const dirname2 = path2.dirname(outPath);
|
|
3142
2733
|
fs2.mkdirSync(dirname2, { recursive: true });
|
|
3143
2734
|
return outPath;
|
|
3144
2735
|
};
|
|
@@ -3147,7 +2738,7 @@ var ensure = (outPath) => {
|
|
|
3147
2738
|
init_esm_shims();
|
|
3148
2739
|
import { findConfig as findConfig2 } from "@pandacss/config";
|
|
3149
2740
|
import { messages } from "@pandacss/core";
|
|
3150
|
-
import { logger as
|
|
2741
|
+
import { logger as logger11, quote } from "@pandacss/logger";
|
|
3151
2742
|
import { PandaError as PandaError2 } from "@pandacss/shared";
|
|
3152
2743
|
import fsExtra2 from "fs-extra";
|
|
3153
2744
|
import { lookItUpSync as lookItUpSync2 } from "look-it-up";
|
|
@@ -3170,9 +2761,9 @@ async function setupConfig(cwd, opts = {}) {
|
|
|
3170
2761
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
3171
2762
|
const isTs = lookItUpSync2("tsconfig.json", cwd);
|
|
3172
2763
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
3173
|
-
|
|
2764
|
+
logger11.info("init:config", `creating panda config file: ${quote(file)}`);
|
|
3174
2765
|
if (!force && configFile) {
|
|
3175
|
-
|
|
2766
|
+
logger11.warn("init:config", messages.configExists(cmd));
|
|
3176
2767
|
} else {
|
|
3177
2768
|
const content = outdent2`
|
|
3178
2769
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -3205,11 +2796,11 @@ syntax: '${syntax}'` : ""}
|
|
|
3205
2796
|
})
|
|
3206
2797
|
`;
|
|
3207
2798
|
await fsExtra2.writeFile(join2(cwd, file), await prettier.format(content, { parser: "babel" }));
|
|
3208
|
-
|
|
2799
|
+
logger11.log(messages.thankYou());
|
|
3209
2800
|
}
|
|
3210
2801
|
}
|
|
3211
2802
|
async function setupPostcss(cwd) {
|
|
3212
|
-
|
|
2803
|
+
logger11.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
|
|
3213
2804
|
const content = outdent2`
|
|
3214
2805
|
module.exports = {
|
|
3215
2806
|
plugins: {
|
|
@@ -3222,7 +2813,7 @@ module.exports = {
|
|
|
3222
2813
|
export {
|
|
3223
2814
|
Builder,
|
|
3224
2815
|
PandaContext,
|
|
3225
|
-
|
|
2816
|
+
analyze,
|
|
3226
2817
|
buildInfo,
|
|
3227
2818
|
codegen,
|
|
3228
2819
|
cssgen,
|
|
@@ -3234,6 +2825,5 @@ export {
|
|
|
3234
2825
|
setupConfig,
|
|
3235
2826
|
setupGitIgnore,
|
|
3236
2827
|
setupPostcss,
|
|
3237
|
-
startProfiling
|
|
3238
|
-
writeAnalyzeJSON
|
|
2828
|
+
startProfiling
|
|
3239
2829
|
};
|