@pandacss/node 0.0.0-dev-20241206205627 → 0.0.0-dev-20241224161732
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 +116 -523
- package/dist/index.mjs +114 -520
- package/package.json +10 -12
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.3.3/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.3.3/node_modules/tsup/assets/esm_shims.js"() {
|
|
33
33
|
"use strict";
|
|
34
34
|
}
|
|
35
35
|
});
|
|
@@ -397,469 +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.48.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
|
-
|
|
850
|
-
const minify = ctx.config
|
|
851
|
-
|
|
441
|
+
logger.info("cli", `Found ${colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
442
|
+
const { minify, staticCss } = ctx.config;
|
|
443
|
+
logger.info("cli", `Writing ${minify ? "[min] " : " "}${colors.bold(outfile)}`);
|
|
444
|
+
if (staticCss) {
|
|
445
|
+
logger.info("cli", "Adding staticCss definitions...");
|
|
446
|
+
ctx.staticCss.process(staticCss);
|
|
447
|
+
}
|
|
852
448
|
const output = JSON.stringify(ctx.encoder.toJSON(), null, minify ? 0 : 2);
|
|
853
449
|
ctx.output.ensure(outfile, process.cwd());
|
|
854
450
|
await ctx.runtime.fs.writeFile(outfile, output);
|
|
855
|
-
|
|
451
|
+
logger.info("cli", "Done!");
|
|
856
452
|
}
|
|
857
453
|
|
|
858
454
|
// src/builder.ts
|
|
859
455
|
init_esm_shims();
|
|
860
456
|
import { findConfig, getConfigDependencies } from "@pandacss/config";
|
|
861
457
|
import { optimizeCss } from "@pandacss/core";
|
|
862
|
-
import { logger as
|
|
458
|
+
import { logger as logger5 } from "@pandacss/logger";
|
|
863
459
|
import { PandaError, uniq as uniq2 } from "@pandacss/shared";
|
|
864
460
|
import { existsSync, statSync } from "fs";
|
|
865
461
|
import { normalize as normalize2, resolve as resolve3 } from "path";
|
|
@@ -1011,7 +607,7 @@ import browserslist from "browserslist";
|
|
|
1011
607
|
// src/create-context.ts
|
|
1012
608
|
init_esm_shims();
|
|
1013
609
|
import { Generator as Generator2 } from "@pandacss/generator";
|
|
1014
|
-
import { logger as
|
|
610
|
+
import { logger as logger4 } from "@pandacss/logger";
|
|
1015
611
|
import { Project } from "@pandacss/parser";
|
|
1016
612
|
import { uniq } from "@pandacss/shared";
|
|
1017
613
|
import { debounce } from "perfect-debounce";
|
|
@@ -1029,13 +625,12 @@ init_esm_shims();
|
|
|
1029
625
|
// ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
|
1030
626
|
init_esm_shims();
|
|
1031
627
|
|
|
1032
|
-
// ../../node_modules/.pnpm/ansi-regex@6.1
|
|
628
|
+
// ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
|
|
1033
629
|
init_esm_shims();
|
|
1034
630
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1035
|
-
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
1036
631
|
const pattern = [
|
|
1037
|
-
|
|
1038
|
-
"(?:(?:\\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=><~]))"
|
|
1039
634
|
].join("|");
|
|
1040
635
|
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
1041
636
|
}
|
|
@@ -1374,10 +969,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
1374
969
|
return 3;
|
|
1375
970
|
}
|
|
1376
971
|
if ("TERM_PROGRAM" in env) {
|
|
1377
|
-
const
|
|
972
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
1378
973
|
switch (env.TERM_PROGRAM) {
|
|
1379
974
|
case "iTerm.app": {
|
|
1380
|
-
return
|
|
975
|
+
return version >= 3 ? 3 : 2;
|
|
1381
976
|
}
|
|
1382
977
|
case "Apple_Terminal": {
|
|
1383
978
|
return 2;
|
|
@@ -1410,7 +1005,7 @@ var supports_color_default = supportsColor;
|
|
|
1410
1005
|
|
|
1411
1006
|
// ../../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
|
|
1412
1007
|
init_esm_shims();
|
|
1413
|
-
function stringReplaceAll(string, substring,
|
|
1008
|
+
function stringReplaceAll(string, substring, replacer2) {
|
|
1414
1009
|
let index = string.indexOf(substring);
|
|
1415
1010
|
if (index === -1) {
|
|
1416
1011
|
return string;
|
|
@@ -1419,7 +1014,7 @@ function stringReplaceAll(string, substring, replacer) {
|
|
|
1419
1014
|
let endIndex = 0;
|
|
1420
1015
|
let returnValue = "";
|
|
1421
1016
|
do {
|
|
1422
|
-
returnValue += string.slice(endIndex, index) + substring +
|
|
1017
|
+
returnValue += string.slice(endIndex, index) + substring + replacer2;
|
|
1423
1018
|
endIndex = index + substringLength;
|
|
1424
1019
|
index = string.indexOf(substring, endIndex);
|
|
1425
1020
|
} while (index !== -1);
|
|
@@ -2365,7 +1960,7 @@ var DiffEngine = class {
|
|
|
2365
1960
|
|
|
2366
1961
|
// src/node-runtime.ts
|
|
2367
1962
|
init_esm_shims();
|
|
2368
|
-
import { logger as
|
|
1963
|
+
import { logger as logger2 } from "@pandacss/logger";
|
|
2369
1964
|
import chokidar from "chokidar";
|
|
2370
1965
|
import glob from "fast-glob";
|
|
2371
1966
|
import fsExtra from "fs-extra";
|
|
@@ -2408,8 +2003,8 @@ var nodeRuntime = {
|
|
|
2408
2003
|
readDirSync: fsExtra.readdirSync,
|
|
2409
2004
|
rmDirSync: fsExtra.emptyDirSync,
|
|
2410
2005
|
rmFileSync: fsExtra.removeSync,
|
|
2411
|
-
ensureDirSync(
|
|
2412
|
-
return fsExtra.ensureDirSync(
|
|
2006
|
+
ensureDirSync(path3) {
|
|
2007
|
+
return fsExtra.ensureDirSync(path3);
|
|
2413
2008
|
},
|
|
2414
2009
|
watch(options) {
|
|
2415
2010
|
const { include, exclude, cwd, poll } = options;
|
|
@@ -2422,7 +2017,7 @@ var nodeRuntime = {
|
|
|
2422
2017
|
ignored: exclude,
|
|
2423
2018
|
awaitWriteFinish: coalesce ? { stabilityThreshold: 50, pollInterval: 10 } : false
|
|
2424
2019
|
});
|
|
2425
|
-
|
|
2020
|
+
logger2.debug("watch:file", `watching [${include}]`);
|
|
2426
2021
|
process.once("SIGINT", async () => {
|
|
2427
2022
|
await watcher.close();
|
|
2428
2023
|
});
|
|
@@ -2432,15 +2027,15 @@ var nodeRuntime = {
|
|
|
2432
2027
|
};
|
|
2433
2028
|
process.setMaxListeners(Infinity);
|
|
2434
2029
|
process.on("unhandledRejection", (reason) => {
|
|
2435
|
-
|
|
2030
|
+
logger2.error("\u274C", reason);
|
|
2436
2031
|
});
|
|
2437
2032
|
process.on("uncaughtException", (reason) => {
|
|
2438
|
-
|
|
2033
|
+
logger2.error("\u274C", reason);
|
|
2439
2034
|
});
|
|
2440
2035
|
|
|
2441
2036
|
// src/output-engine.ts
|
|
2442
2037
|
init_esm_shims();
|
|
2443
|
-
import { logger as
|
|
2038
|
+
import { logger as logger3 } from "@pandacss/logger";
|
|
2444
2039
|
var OutputEngine = class {
|
|
2445
2040
|
paths;
|
|
2446
2041
|
fs;
|
|
@@ -2471,7 +2066,7 @@ var OutputEngine = class {
|
|
|
2471
2066
|
return;
|
|
2472
2067
|
const { file, code } = artifact;
|
|
2473
2068
|
const absPath = this.path.join(...dir, file);
|
|
2474
|
-
|
|
2069
|
+
logger3.debug("write:file", dir.slice(-1).concat(file).join("/"));
|
|
2475
2070
|
return this.fs.writeFile(absPath, code);
|
|
2476
2071
|
})
|
|
2477
2072
|
);
|
|
@@ -2491,7 +2086,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2491
2086
|
this.runtime = nodeRuntime;
|
|
2492
2087
|
config.cwd ||= this.runtime.cwd();
|
|
2493
2088
|
if (config.logLevel) {
|
|
2494
|
-
|
|
2089
|
+
logger4.level = config.logLevel;
|
|
2495
2090
|
}
|
|
2496
2091
|
this.project = new Project({
|
|
2497
2092
|
...conf.tsconfig,
|
|
@@ -2525,14 +2120,14 @@ var PandaContext = class extends Generator2 {
|
|
|
2525
2120
|
};
|
|
2526
2121
|
parseFile = (filePath, styleEncoder) => {
|
|
2527
2122
|
const file = this.runtime.path.abs(this.config.cwd, filePath);
|
|
2528
|
-
|
|
2529
|
-
const measure =
|
|
2123
|
+
logger4.debug("file:extract", file);
|
|
2124
|
+
const measure = logger4.time.debug(`Parsed ${file}`);
|
|
2530
2125
|
let result;
|
|
2531
2126
|
try {
|
|
2532
2127
|
const encoder = styleEncoder || this.parserOptions.encoder;
|
|
2533
2128
|
result = this.project.parseSourceFile(file, encoder);
|
|
2534
2129
|
} catch (error) {
|
|
2535
|
-
|
|
2130
|
+
logger4.error("file:extract", error);
|
|
2536
2131
|
}
|
|
2537
2132
|
measure();
|
|
2538
2133
|
return result;
|
|
@@ -2543,7 +2138,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2543
2138
|
const filesWithCss = [];
|
|
2544
2139
|
const results = [];
|
|
2545
2140
|
files.forEach((file) => {
|
|
2546
|
-
const measure =
|
|
2141
|
+
const measure = logger4.time.debug(`Parsed ${file}`);
|
|
2547
2142
|
const result = this.project.parseSourceFile(file, encoder);
|
|
2548
2143
|
measure();
|
|
2549
2144
|
if (!result || result.isEmpty() || encoder.isEmpty())
|
|
@@ -2558,7 +2153,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2558
2153
|
};
|
|
2559
2154
|
};
|
|
2560
2155
|
writeCss = (sheet) => {
|
|
2561
|
-
|
|
2156
|
+
logger4.info("css", this.runtime.path.join(...this.paths.root, "styles.css"));
|
|
2562
2157
|
return this.output.write({
|
|
2563
2158
|
id: "styles.css",
|
|
2564
2159
|
dir: this.paths.root,
|
|
@@ -2567,7 +2162,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2567
2162
|
};
|
|
2568
2163
|
watchConfig = (cb, opts) => {
|
|
2569
2164
|
const { cwd, poll, exclude } = opts ?? {};
|
|
2570
|
-
|
|
2165
|
+
logger4.info("ctx:watch", this.messages.configWatch());
|
|
2571
2166
|
const watcher = this.runtime.fs.watch({
|
|
2572
2167
|
include: uniq([...this.explicitDeps, ...this.conf.dependencies]),
|
|
2573
2168
|
exclude,
|
|
@@ -2577,14 +2172,14 @@ var PandaContext = class extends Generator2 {
|
|
|
2577
2172
|
watcher.on(
|
|
2578
2173
|
"change",
|
|
2579
2174
|
debounce(async (file) => {
|
|
2580
|
-
|
|
2175
|
+
logger4.info("ctx:change", "config changed, rebuilding...");
|
|
2581
2176
|
await cb(file);
|
|
2582
2177
|
})
|
|
2583
2178
|
);
|
|
2584
2179
|
};
|
|
2585
2180
|
watchFiles = (cb, opts) => {
|
|
2586
2181
|
const { include, exclude, poll, cwd } = this.config;
|
|
2587
|
-
|
|
2182
|
+
logger4.info("ctx:watch", this.messages.watch());
|
|
2588
2183
|
const watcher = this.runtime.fs.watch({
|
|
2589
2184
|
...opts,
|
|
2590
2185
|
include,
|
|
@@ -2595,7 +2190,7 @@ var PandaContext = class extends Generator2 {
|
|
|
2595
2190
|
watcher.on(
|
|
2596
2191
|
"all",
|
|
2597
2192
|
debounce(async (event, file) => {
|
|
2598
|
-
|
|
2193
|
+
logger4.info(`file:${event}`, file);
|
|
2599
2194
|
await cb(event, file);
|
|
2600
2195
|
})
|
|
2601
2196
|
);
|
|
@@ -2719,11 +2314,11 @@ var Builder = class {
|
|
|
2719
2314
|
configDeps.forEach((file) => {
|
|
2720
2315
|
this.configDependencies.add(file);
|
|
2721
2316
|
});
|
|
2722
|
-
|
|
2723
|
-
|
|
2317
|
+
logger5.debug("builder", "Config dependencies");
|
|
2318
|
+
logger5.debug("builder", configDeps);
|
|
2724
2319
|
}
|
|
2725
2320
|
setup = async (options = {}) => {
|
|
2726
|
-
|
|
2321
|
+
logger5.debug("builder", "\u{1F6A7} Setup");
|
|
2727
2322
|
const configPath = options.configPath ?? findConfig({ cwd: options.cwd });
|
|
2728
2323
|
this.setConfigDependencies({ configPath, cwd: options.cwd });
|
|
2729
2324
|
if (!this.context) {
|
|
@@ -2733,29 +2328,29 @@ var Builder = class {
|
|
|
2733
2328
|
this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2734
2329
|
this.context = new PandaContext(conf);
|
|
2735
2330
|
});
|
|
2736
|
-
|
|
2331
|
+
logger5.debug("builder", this.affecteds);
|
|
2737
2332
|
this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
|
|
2738
2333
|
if (this.explicitDepsMeta.hasFilesChanged) {
|
|
2739
2334
|
this.explicitDepsMeta.changes.forEach((meta, file) => {
|
|
2740
2335
|
fileModifiedMap.set(file, meta.mtime);
|
|
2741
2336
|
});
|
|
2742
|
-
|
|
2337
|
+
logger5.debug("builder", "\u2699\uFE0F Explicit config dependencies changed");
|
|
2743
2338
|
this.affecteds.hasConfigChanged = true;
|
|
2744
2339
|
}
|
|
2745
2340
|
if (this.affecteds.hasConfigChanged) {
|
|
2746
|
-
|
|
2341
|
+
logger5.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2747
2342
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: this.affecteds });
|
|
2748
2343
|
return;
|
|
2749
2344
|
}
|
|
2750
2345
|
this.filesMeta = this.checkFilesChanged(ctx.getFiles());
|
|
2751
2346
|
if (this.filesMeta.hasFilesChanged) {
|
|
2752
|
-
|
|
2347
|
+
logger5.debug("builder", "Files changed, invalidating them");
|
|
2753
2348
|
ctx.project.reloadSourceFiles();
|
|
2754
2349
|
}
|
|
2755
2350
|
};
|
|
2756
2351
|
async emit() {
|
|
2757
2352
|
if (this.hasEmitted && this.affecteds?.hasConfigChanged) {
|
|
2758
|
-
|
|
2353
|
+
logger5.debug("builder", "Emit artifacts after config change");
|
|
2759
2354
|
await codegen(this.getContextOrThrow(), Array.from(this.affecteds.artifacts));
|
|
2760
2355
|
}
|
|
2761
2356
|
this.hasEmitted = true;
|
|
@@ -2805,12 +2400,12 @@ var Builder = class {
|
|
|
2805
2400
|
extract = () => {
|
|
2806
2401
|
const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : true;
|
|
2807
2402
|
if (!this.filesMeta && !hasConfigChanged) {
|
|
2808
|
-
|
|
2403
|
+
logger5.debug("builder", "No files or config changed, skipping extract");
|
|
2809
2404
|
return;
|
|
2810
2405
|
}
|
|
2811
2406
|
const ctx = this.getContextOrThrow();
|
|
2812
2407
|
const files = ctx.getFiles();
|
|
2813
|
-
const done =
|
|
2408
|
+
const done = logger5.time.info("Extracted in");
|
|
2814
2409
|
files.map((file) => this.extractFile(ctx, file));
|
|
2815
2410
|
done();
|
|
2816
2411
|
};
|
|
@@ -2852,9 +2447,9 @@ var Builder = class {
|
|
|
2852
2447
|
|
|
2853
2448
|
// src/cpu-profile.ts
|
|
2854
2449
|
init_esm_shims();
|
|
2855
|
-
import { logger as
|
|
2450
|
+
import { logger as logger6 } from "@pandacss/logger";
|
|
2856
2451
|
import fs from "node:fs";
|
|
2857
|
-
import
|
|
2452
|
+
import path from "node:path";
|
|
2858
2453
|
import readline from "node:readline";
|
|
2859
2454
|
var startProfiling = async (cwd, prefix, isWatching) => {
|
|
2860
2455
|
const inspector = await import("node:inspector").then((r) => r.default);
|
|
@@ -2908,7 +2503,7 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2908
2503
|
session.post("Profiler.stop", (err, params) => {
|
|
2909
2504
|
setState("idle");
|
|
2910
2505
|
if (err) {
|
|
2911
|
-
|
|
2506
|
+
logger6.error("cpu-prof", err);
|
|
2912
2507
|
cb?.();
|
|
2913
2508
|
return;
|
|
2914
2509
|
}
|
|
@@ -2919,9 +2514,9 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2919
2514
|
const date = /* @__PURE__ */ new Date();
|
|
2920
2515
|
const timestamp = date.toISOString().replace(/[-:.]/g, "");
|
|
2921
2516
|
const title = `panda-${prefix}-${timestamp}`;
|
|
2922
|
-
const outfile =
|
|
2517
|
+
const outfile = path.join(cwd, `${title}.cpuprofile`);
|
|
2923
2518
|
fs.writeFileSync(outfile, JSON.stringify(params.profile));
|
|
2924
|
-
|
|
2519
|
+
logger6.info("cpu-prof", outfile);
|
|
2925
2520
|
cb?.();
|
|
2926
2521
|
});
|
|
2927
2522
|
};
|
|
@@ -2930,16 +2525,16 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2930
2525
|
|
|
2931
2526
|
// src/cssgen.ts
|
|
2932
2527
|
init_esm_shims();
|
|
2933
|
-
import { logger as
|
|
2528
|
+
import { logger as logger7 } from "@pandacss/logger";
|
|
2934
2529
|
var cssgen = async (ctx, options) => {
|
|
2935
2530
|
const { outfile, type, minimal } = options;
|
|
2936
2531
|
const sheet = ctx.createSheet();
|
|
2937
2532
|
if (type) {
|
|
2938
|
-
const done =
|
|
2533
|
+
const done = logger7.time.info(ctx.messages.cssArtifactComplete(type));
|
|
2939
2534
|
ctx.appendCssOfType(type, sheet);
|
|
2940
2535
|
if (outfile) {
|
|
2941
2536
|
const css = ctx.getCss(sheet);
|
|
2942
|
-
|
|
2537
|
+
logger7.info("css", ctx.runtime.path.resolve(outfile));
|
|
2943
2538
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2944
2539
|
} else {
|
|
2945
2540
|
await ctx.writeCss(sheet);
|
|
@@ -2947,7 +2542,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2947
2542
|
done();
|
|
2948
2543
|
} else {
|
|
2949
2544
|
const { files } = ctx.parseFiles();
|
|
2950
|
-
const done =
|
|
2545
|
+
const done = logger7.time.info(ctx.messages.buildComplete(files.length));
|
|
2951
2546
|
if (!minimal) {
|
|
2952
2547
|
ctx.appendLayerParams(sheet);
|
|
2953
2548
|
ctx.appendBaselineCss(sheet);
|
|
@@ -2955,7 +2550,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2955
2550
|
ctx.appendParserCss(sheet);
|
|
2956
2551
|
if (outfile) {
|
|
2957
2552
|
const css = ctx.getCss(sheet);
|
|
2958
|
-
|
|
2553
|
+
logger7.info("css", ctx.runtime.path.resolve(outfile));
|
|
2959
2554
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2960
2555
|
} else {
|
|
2961
2556
|
await ctx.writeCss(sheet);
|
|
@@ -2966,17 +2561,17 @@ var cssgen = async (ctx, options) => {
|
|
|
2966
2561
|
|
|
2967
2562
|
// src/debug.ts
|
|
2968
2563
|
init_esm_shims();
|
|
2969
|
-
import { colors as colors2, logger as
|
|
2564
|
+
import { colors as colors2, logger as logger8 } from "@pandacss/logger";
|
|
2970
2565
|
import { parse } from "path";
|
|
2971
2566
|
async function debug(ctx, options) {
|
|
2972
2567
|
const files = ctx.getFiles();
|
|
2973
|
-
const measureTotal =
|
|
2568
|
+
const measureTotal = logger8.time.debug(`Done parsing ${files.length} files`);
|
|
2974
2569
|
ctx.config.minify = false;
|
|
2975
|
-
const { fs: fs3, path:
|
|
2570
|
+
const { fs: fs3, path: path3 } = ctx.runtime;
|
|
2976
2571
|
const outdir = options.outdir;
|
|
2977
2572
|
if (!options.dry && outdir) {
|
|
2978
2573
|
fs3.ensureDirSync(outdir);
|
|
2979
|
-
|
|
2574
|
+
logger8.info("cli", `Writing ${colors2.bold(`${outdir}/config.json`)}`);
|
|
2980
2575
|
await fs3.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2981
2576
|
}
|
|
2982
2577
|
if (options.onlyConfig) {
|
|
@@ -2985,7 +2580,7 @@ async function debug(ctx, options) {
|
|
|
2985
2580
|
}
|
|
2986
2581
|
const filesWithCss = [];
|
|
2987
2582
|
files.map((file) => {
|
|
2988
|
-
const measure =
|
|
2583
|
+
const measure = logger8.time.debug(`Parsed ${file}`);
|
|
2989
2584
|
const encoder = ctx.encoder.clone();
|
|
2990
2585
|
const result = ctx.project.parseSourceFile(file, encoder);
|
|
2991
2586
|
measure();
|
|
@@ -3002,30 +2597,30 @@ async function debug(ctx, options) {
|
|
|
3002
2597
|
if (outdir) {
|
|
3003
2598
|
filesWithCss.push(file);
|
|
3004
2599
|
const parsedPath = parse(file);
|
|
3005
|
-
const relative2 =
|
|
3006
|
-
const astJsonPath = `${relative2}${
|
|
3007
|
-
const cssPath = `${relative2}${
|
|
3008
|
-
|
|
3009
|
-
|
|
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}`)}`);
|
|
3010
2605
|
return Promise.allSettled([
|
|
3011
|
-
fs3.writeFile(`${outdir}${
|
|
3012
|
-
fs3.writeFile(`${outdir}${
|
|
2606
|
+
fs3.writeFile(`${outdir}${path3.sep}${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2607
|
+
fs3.writeFile(`${outdir}${path3.sep}${cssPath}`, css)
|
|
3013
2608
|
]);
|
|
3014
2609
|
}
|
|
3015
2610
|
});
|
|
3016
|
-
|
|
2611
|
+
logger8.info("cli", `Found ${colors2.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
3017
2612
|
measureTotal();
|
|
3018
2613
|
}
|
|
3019
2614
|
|
|
3020
2615
|
// src/generate.ts
|
|
3021
2616
|
init_esm_shims();
|
|
3022
|
-
import { logger as
|
|
2617
|
+
import { logger as logger9 } from "@pandacss/logger";
|
|
3023
2618
|
async function build(ctx, artifactIds) {
|
|
3024
2619
|
await codegen(ctx, artifactIds);
|
|
3025
2620
|
if (ctx.config.emitTokensOnly) {
|
|
3026
|
-
return
|
|
2621
|
+
return logger9.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
|
|
3027
2622
|
}
|
|
3028
|
-
const done =
|
|
2623
|
+
const done = logger9.time.info("");
|
|
3029
2624
|
const sheet = ctx.createSheet();
|
|
3030
2625
|
ctx.appendLayerParams(sheet);
|
|
3031
2626
|
ctx.appendBaselineCss(sheet);
|
|
@@ -3044,7 +2639,7 @@ async function generate(config, configPath) {
|
|
|
3044
2639
|
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
3045
2640
|
ctx = new PandaContext(conf);
|
|
3046
2641
|
});
|
|
3047
|
-
|
|
2642
|
+
logger9.info("ctx:updated", "config rebuilt \u2705");
|
|
3048
2643
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
|
|
3049
2644
|
return build(ctx, Array.from(affecteds.artifacts));
|
|
3050
2645
|
},
|
|
@@ -3054,7 +2649,7 @@ async function generate(config, configPath) {
|
|
|
3054
2649
|
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
3055
2650
|
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
3056
2651
|
if (parserResult) {
|
|
3057
|
-
const done =
|
|
2652
|
+
const done = logger9.time.info(ctx2.messages.buildComplete(1));
|
|
3058
2653
|
const sheet = ctx2.createSheet();
|
|
3059
2654
|
ctx2.appendLayerParams(sheet);
|
|
3060
2655
|
ctx2.appendBaselineCss(sheet);
|
|
@@ -3106,18 +2701,18 @@ function setupGitIgnore(ctx) {
|
|
|
3106
2701
|
|
|
3107
2702
|
// src/logstream.ts
|
|
3108
2703
|
init_esm_shims();
|
|
3109
|
-
import { logger as
|
|
2704
|
+
import { logger as logger10 } from "@pandacss/logger";
|
|
3110
2705
|
import fs2 from "node:fs";
|
|
3111
|
-
import
|
|
2706
|
+
import path2 from "node:path";
|
|
3112
2707
|
var setLogStream = (options) => {
|
|
3113
2708
|
const { cwd = process.cwd() } = options;
|
|
3114
2709
|
let stream;
|
|
3115
2710
|
if (options.logfile) {
|
|
3116
|
-
const outPath =
|
|
2711
|
+
const outPath = path2.resolve(cwd, options.logfile);
|
|
3117
2712
|
ensure(outPath);
|
|
3118
|
-
|
|
2713
|
+
logger10.info("logfile", outPath);
|
|
3119
2714
|
stream = fs2.createWriteStream(outPath, { flags: "a" });
|
|
3120
|
-
|
|
2715
|
+
logger10.onLog = (entry) => {
|
|
3121
2716
|
stream?.write(JSON.stringify(entry) + "\n");
|
|
3122
2717
|
};
|
|
3123
2718
|
}
|
|
@@ -3134,7 +2729,7 @@ var setLogStream = (options) => {
|
|
|
3134
2729
|
};
|
|
3135
2730
|
};
|
|
3136
2731
|
var ensure = (outPath) => {
|
|
3137
|
-
const dirname2 =
|
|
2732
|
+
const dirname2 = path2.dirname(outPath);
|
|
3138
2733
|
fs2.mkdirSync(dirname2, { recursive: true });
|
|
3139
2734
|
return outPath;
|
|
3140
2735
|
};
|
|
@@ -3143,7 +2738,7 @@ var ensure = (outPath) => {
|
|
|
3143
2738
|
init_esm_shims();
|
|
3144
2739
|
import { findConfig as findConfig2 } from "@pandacss/config";
|
|
3145
2740
|
import { messages } from "@pandacss/core";
|
|
3146
|
-
import { logger as
|
|
2741
|
+
import { logger as logger11, quote } from "@pandacss/logger";
|
|
3147
2742
|
import { PandaError as PandaError2 } from "@pandacss/shared";
|
|
3148
2743
|
import fsExtra2 from "fs-extra";
|
|
3149
2744
|
import { lookItUpSync as lookItUpSync2 } from "look-it-up";
|
|
@@ -3166,9 +2761,9 @@ async function setupConfig(cwd, opts = {}) {
|
|
|
3166
2761
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
3167
2762
|
const isTs = lookItUpSync2("tsconfig.json", cwd);
|
|
3168
2763
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
3169
|
-
|
|
2764
|
+
logger11.info("init:config", `creating panda config file: ${quote(file)}`);
|
|
3170
2765
|
if (!force && configFile) {
|
|
3171
|
-
|
|
2766
|
+
logger11.warn("init:config", messages.configExists(cmd));
|
|
3172
2767
|
} else {
|
|
3173
2768
|
const content = outdent2`
|
|
3174
2769
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -3201,11 +2796,11 @@ syntax: '${syntax}'` : ""}
|
|
|
3201
2796
|
})
|
|
3202
2797
|
`;
|
|
3203
2798
|
await fsExtra2.writeFile(join2(cwd, file), await prettier.format(content, { parser: "babel" }));
|
|
3204
|
-
|
|
2799
|
+
logger11.log(messages.thankYou());
|
|
3205
2800
|
}
|
|
3206
2801
|
}
|
|
3207
2802
|
async function setupPostcss(cwd) {
|
|
3208
|
-
|
|
2803
|
+
logger11.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
|
|
3209
2804
|
const content = outdent2`
|
|
3210
2805
|
module.exports = {
|
|
3211
2806
|
plugins: {
|
|
@@ -3218,7 +2813,7 @@ module.exports = {
|
|
|
3218
2813
|
export {
|
|
3219
2814
|
Builder,
|
|
3220
2815
|
PandaContext,
|
|
3221
|
-
|
|
2816
|
+
analyze,
|
|
3222
2817
|
buildInfo,
|
|
3223
2818
|
codegen,
|
|
3224
2819
|
cssgen,
|
|
@@ -3230,6 +2825,5 @@ export {
|
|
|
3230
2825
|
setupConfig,
|
|
3231
2826
|
setupGitIgnore,
|
|
3232
2827
|
setupPostcss,
|
|
3233
|
-
startProfiling
|
|
3234
|
-
writeAnalyzeJSON
|
|
2828
|
+
startProfiling
|
|
3235
2829
|
};
|