@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.js
CHANGED
|
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.7.6_@swc+helpers@0.4.36__postcss@8.4.49_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.
|
|
38
|
+
"../../node_modules/.pnpm/tsup@8.0.2_@swc+core@1.7.6_@swc+helpers@0.4.36__postcss@8.4.49_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
39
|
"use strict";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -405,7 +405,7 @@ var src_exports = {};
|
|
|
405
405
|
__export(src_exports, {
|
|
406
406
|
Builder: () => Builder,
|
|
407
407
|
PandaContext: () => PandaContext,
|
|
408
|
-
|
|
408
|
+
analyze: () => analyze,
|
|
409
409
|
buildInfo: () => buildInfo,
|
|
410
410
|
codegen: () => codegen,
|
|
411
411
|
cssgen: () => cssgen,
|
|
@@ -417,475 +417,70 @@ __export(src_exports, {
|
|
|
417
417
|
setupConfig: () => setupConfig,
|
|
418
418
|
setupGitIgnore: () => setupGitIgnore,
|
|
419
419
|
setupPostcss: () => setupPostcss,
|
|
420
|
-
startProfiling: () => startProfiling
|
|
421
|
-
writeAnalyzeJSON: () => writeAnalyzeJSON
|
|
420
|
+
startProfiling: () => startProfiling
|
|
422
421
|
});
|
|
423
422
|
module.exports = __toCommonJS(src_exports);
|
|
424
423
|
init_cjs_shims();
|
|
425
424
|
|
|
426
|
-
// src/analyze
|
|
425
|
+
// src/analyze.ts
|
|
427
426
|
init_cjs_shims();
|
|
428
|
-
var
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
var version = "0.48.0";
|
|
436
|
-
|
|
437
|
-
// src/classify.ts
|
|
438
|
-
init_cjs_shims();
|
|
439
|
-
var import_extractor = require("@pandacss/extractor");
|
|
440
|
-
var createReportMaps = () => {
|
|
441
|
-
const byComponentOfKind = /* @__PURE__ */ new Map();
|
|
442
|
-
const byPropertyName = /* @__PURE__ */ new Map();
|
|
443
|
-
const byTokenType = /* @__PURE__ */ new Map();
|
|
444
|
-
const byConditionName = /* @__PURE__ */ new Map();
|
|
445
|
-
const byShorthand = /* @__PURE__ */ new Map();
|
|
446
|
-
const byTokenName = /* @__PURE__ */ new Map();
|
|
447
|
-
const byPropertyPath = /* @__PURE__ */ new Map();
|
|
448
|
-
const fromKind = /* @__PURE__ */ new Map();
|
|
449
|
-
const byType = /* @__PURE__ */ new Map();
|
|
450
|
-
const byComponentName = /* @__PURE__ */ new Map();
|
|
451
|
-
const colorsUsed = /* @__PURE__ */ new Map();
|
|
452
|
-
return {
|
|
453
|
-
byComponentOfKind,
|
|
454
|
-
byPropertyName,
|
|
455
|
-
byTokenType,
|
|
456
|
-
byConditionName,
|
|
457
|
-
byShorthand,
|
|
458
|
-
byTokenName,
|
|
459
|
-
byPropertyPath,
|
|
460
|
-
fromKind,
|
|
461
|
-
byType,
|
|
462
|
-
byComponentName,
|
|
463
|
-
colorsUsed
|
|
464
|
-
};
|
|
465
|
-
};
|
|
466
|
-
var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
467
|
-
const byId = /* @__PURE__ */ new Map();
|
|
468
|
-
const byComponentIndex = /* @__PURE__ */ new Map();
|
|
469
|
-
const byFilepath = /* @__PURE__ */ new Map();
|
|
470
|
-
const byComponentInFilepath = /* @__PURE__ */ new Map();
|
|
471
|
-
const globalMaps = createReportMaps();
|
|
472
|
-
const byFilePathMaps = /* @__PURE__ */ new Map();
|
|
473
|
-
const conditions = new Map(Object.entries(ctx.conditions.values));
|
|
474
|
-
const { groupByProp } = getPropertyGroupMap(ctx);
|
|
475
|
-
let id = 0, componentIndex = 0;
|
|
476
|
-
const isKnownUtility = (reportItem, componentReportItem) => {
|
|
477
|
-
const { propName, value } = reportItem;
|
|
478
|
-
const utility = ctx.config.utilities?.[propName];
|
|
479
|
-
if (utility) {
|
|
480
|
-
if (!utility.shorthand) {
|
|
481
|
-
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
482
|
-
}
|
|
483
|
-
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
484
|
-
}
|
|
485
|
-
if (componentReportItem.reportItemType === "pattern") {
|
|
486
|
-
const pattern = ctx.patterns.getConfig(componentReportItem.componentName.toLowerCase());
|
|
487
|
-
const patternProp = pattern?.properties?.[propName];
|
|
488
|
-
if (!patternProp)
|
|
489
|
-
return false;
|
|
490
|
-
if (patternProp.type === "boolean" || patternProp.type === "number") {
|
|
491
|
-
return true;
|
|
492
|
-
}
|
|
493
|
-
if (patternProp.type === "property" && patternProp.value) {
|
|
494
|
-
return Boolean(ctx.config.utilities?.[patternProp.value]);
|
|
495
|
-
}
|
|
496
|
-
if (patternProp.type === "enum" && patternProp.value) {
|
|
497
|
-
return Boolean(patternProp.value.includes(String(value)));
|
|
498
|
-
}
|
|
499
|
-
if (patternProp.type === "token") {
|
|
500
|
-
return Boolean(ctx.tokens.getByName(`${patternProp.value}.${value}`));
|
|
501
|
-
}
|
|
502
|
-
return false;
|
|
503
|
-
}
|
|
504
|
-
return false;
|
|
505
|
-
};
|
|
506
|
-
parserResultByFilepath.forEach((parserResult, filepath) => {
|
|
507
|
-
if (parserResult.isEmpty())
|
|
508
|
-
return;
|
|
509
|
-
const localMaps = createReportMaps();
|
|
510
|
-
const addTo = (map, key, value) => {
|
|
511
|
-
const set = map.get(key) ?? /* @__PURE__ */ new Set();
|
|
512
|
-
set.add(value);
|
|
513
|
-
map.set(key, set);
|
|
514
|
-
};
|
|
515
|
-
const processMap = (map, current, componentReportItem) => {
|
|
516
|
-
const { reportItemType: type, kind } = componentReportItem;
|
|
517
|
-
const name = componentReportItem.componentName;
|
|
518
|
-
map.value.forEach((attrNode, attrName) => {
|
|
519
|
-
if (import_extractor.box.isLiteral(attrNode) || import_extractor.box.isEmptyInitializer(attrNode)) {
|
|
520
|
-
const value = import_extractor.box.isLiteral(attrNode) ? attrNode.value : true;
|
|
521
|
-
const propReportItem = {
|
|
522
|
-
index: String(id++),
|
|
523
|
-
componentIndex: String(componentReportItem.componentIndex),
|
|
524
|
-
componentName: name,
|
|
525
|
-
tokenType: void 0,
|
|
526
|
-
propName: attrName,
|
|
527
|
-
reportItemKind: "utility",
|
|
528
|
-
reportItemType: type,
|
|
529
|
-
kind,
|
|
530
|
-
filepath,
|
|
531
|
-
path: current.concat(attrName),
|
|
532
|
-
value,
|
|
533
|
-
isKnownValue: false,
|
|
534
|
-
range: map.getRange()
|
|
535
|
-
};
|
|
536
|
-
componentReportItem.contains.push(propReportItem.index);
|
|
537
|
-
if (conditions.has(attrName)) {
|
|
538
|
-
addTo(globalMaps.byConditionName, attrName, propReportItem.index);
|
|
539
|
-
addTo(localMaps.byConditionName, attrName, propReportItem.index);
|
|
540
|
-
propReportItem.propName = current[0] ?? attrName;
|
|
541
|
-
propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
|
|
542
|
-
propReportItem.conditionName = attrName;
|
|
543
|
-
} else {
|
|
544
|
-
if (current.length && conditions.has(current[0])) {
|
|
545
|
-
propReportItem.conditionName = current[0];
|
|
546
|
-
addTo(globalMaps.byConditionName, current[0], propReportItem.index);
|
|
547
|
-
addTo(localMaps.byConditionName, current[0], propReportItem.index);
|
|
548
|
-
}
|
|
549
|
-
const propName = ctx.utility.shorthands.get(attrName) ?? attrName;
|
|
550
|
-
propReportItem.propName = propName;
|
|
551
|
-
const utility = ctx.config.utilities?.[propName];
|
|
552
|
-
propReportItem.isKnownValue = isKnownUtility(propReportItem, componentReportItem);
|
|
553
|
-
const tokenType = typeof utility?.values === "string" ? utility?.values : void 0;
|
|
554
|
-
if (tokenType) {
|
|
555
|
-
propReportItem.reportItemKind = "token";
|
|
556
|
-
propReportItem.tokenType = tokenType;
|
|
557
|
-
}
|
|
558
|
-
addTo(globalMaps.byPropertyName, propName, propReportItem.index);
|
|
559
|
-
addTo(localMaps.byPropertyName, propName, propReportItem.index);
|
|
560
|
-
if (tokenType) {
|
|
561
|
-
addTo(globalMaps.byTokenType, tokenType, propReportItem.index);
|
|
562
|
-
addTo(localMaps.byTokenType, tokenType, propReportItem.index);
|
|
563
|
-
}
|
|
564
|
-
if (propName.toLowerCase().includes("color") || groupByProp.get(propName) === "Color" || tokenType === "colors") {
|
|
565
|
-
addTo(globalMaps.colorsUsed, value, propReportItem.index);
|
|
566
|
-
addTo(localMaps.colorsUsed, value, propReportItem.index);
|
|
567
|
-
}
|
|
568
|
-
if (ctx.utility.shorthands.has(attrName)) {
|
|
569
|
-
addTo(globalMaps.byShorthand, attrName, propReportItem.index);
|
|
570
|
-
addTo(localMaps.byShorthand, attrName, propReportItem.index);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
if (current.length) {
|
|
574
|
-
addTo(globalMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
|
|
575
|
-
addTo(localMaps.byPropertyPath, propReportItem.path.join("."), propReportItem.index);
|
|
576
|
-
}
|
|
577
|
-
addTo(globalMaps.byTokenName, String(value), propReportItem.index);
|
|
578
|
-
addTo(localMaps.byTokenName, String(value), propReportItem.index);
|
|
579
|
-
addTo(globalMaps.byType, type, propReportItem.index);
|
|
580
|
-
addTo(localMaps.byType, type, propReportItem.index);
|
|
581
|
-
addTo(globalMaps.byComponentName, name, propReportItem.index);
|
|
582
|
-
addTo(localMaps.byComponentName, name, propReportItem.index);
|
|
583
|
-
addTo(globalMaps.fromKind, kind, propReportItem.index);
|
|
584
|
-
addTo(localMaps.fromKind, kind, propReportItem.index);
|
|
585
|
-
addTo(byFilepath, filepath, propReportItem.index);
|
|
586
|
-
byId.set(propReportItem.index, propReportItem);
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
if (import_extractor.box.isMap(attrNode) && attrNode.value.size) {
|
|
590
|
-
return processMap(attrNode, current.concat(attrName), componentReportItem);
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
};
|
|
594
|
-
const processResultItem = (item, kind) => {
|
|
595
|
-
if (!item.box || import_extractor.box.isUnresolvable(item.box)) {
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
if (!item.data) {
|
|
599
|
-
console.log("no data", item);
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
const componentReportItem = {
|
|
603
|
-
componentIndex: String(componentIndex++),
|
|
604
|
-
componentName: item.name,
|
|
605
|
-
reportItemType: item.type,
|
|
606
|
-
kind,
|
|
607
|
-
filepath,
|
|
608
|
-
value: item.data,
|
|
609
|
-
range: item.box.getRange(),
|
|
610
|
-
contains: []
|
|
611
|
-
};
|
|
612
|
-
if (import_extractor.box.isArray(item.box)) {
|
|
613
|
-
addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
|
|
614
|
-
return componentReportItem;
|
|
615
|
-
}
|
|
616
|
-
if (import_extractor.box.isMap(item.box) && item.box.value.size) {
|
|
617
|
-
addTo(byComponentInFilepath, filepath, componentReportItem.componentIndex);
|
|
618
|
-
processMap(item.box, [], componentReportItem);
|
|
619
|
-
return componentReportItem;
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
const processComponentResultItem = (item) => {
|
|
623
|
-
const componentReportItem = processResultItem(item, "component");
|
|
624
|
-
if (!componentReportItem)
|
|
625
|
-
return;
|
|
626
|
-
addTo(globalMaps.byComponentOfKind, "component", componentReportItem.componentIndex);
|
|
627
|
-
addTo(localMaps.byComponentOfKind, "component", componentReportItem.componentIndex);
|
|
628
|
-
byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
|
|
629
|
-
};
|
|
630
|
-
const processFunctionResultItem = (item) => {
|
|
631
|
-
const componentReportItem = processResultItem(item, "function");
|
|
632
|
-
if (!componentReportItem)
|
|
633
|
-
return;
|
|
634
|
-
addTo(globalMaps.byComponentOfKind, "function", componentReportItem.componentIndex);
|
|
635
|
-
addTo(localMaps.byComponentOfKind, "function", componentReportItem.componentIndex);
|
|
636
|
-
byComponentIndex.set(componentReportItem.componentIndex, componentReportItem);
|
|
637
|
-
};
|
|
638
|
-
parserResult.jsx.forEach(processComponentResultItem);
|
|
639
|
-
parserResult.css.forEach(processFunctionResultItem);
|
|
640
|
-
parserResult.cva.forEach(processFunctionResultItem);
|
|
641
|
-
parserResult.pattern.forEach((itemList) => {
|
|
642
|
-
itemList.forEach(processFunctionResultItem);
|
|
643
|
-
});
|
|
644
|
-
parserResult.recipe.forEach((itemList) => {
|
|
645
|
-
itemList.forEach(processFunctionResultItem);
|
|
646
|
-
});
|
|
647
|
-
byFilePathMaps.set(filepath, localMaps);
|
|
427
|
+
var import_reporter = require("@pandacss/reporter");
|
|
428
|
+
function analyze(ctx, options = {}) {
|
|
429
|
+
const reporter = new import_reporter.Reporter(ctx, {
|
|
430
|
+
project: ctx.project,
|
|
431
|
+
getRelativePath: ctx.runtime.path.relative,
|
|
432
|
+
getFiles: ctx.getFiles,
|
|
433
|
+
...options
|
|
648
434
|
});
|
|
649
|
-
|
|
650
|
-
const filesWithMostComponent = Object.fromEntries(
|
|
651
|
-
Array.from(byComponentInFilepath.entries()).map(([filepath, list]) => [filepath, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
|
|
652
|
-
);
|
|
435
|
+
reporter.init();
|
|
653
436
|
return {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
counts: {
|
|
658
|
-
filesWithTokens: byFilepath.size,
|
|
659
|
-
propNameUsed: globalMaps.byPropertyName.size,
|
|
660
|
-
tokenUsed: globalMaps.byTokenName.size,
|
|
661
|
-
shorthandUsed: globalMaps.byShorthand.size,
|
|
662
|
-
propertyPathUsed: globalMaps.byPropertyPath.size,
|
|
663
|
-
typeUsed: globalMaps.byType.size,
|
|
664
|
-
componentNameUsed: globalMaps.byComponentName.size,
|
|
665
|
-
kindUsed: globalMaps.fromKind.size,
|
|
666
|
-
componentOfKindUsed: globalMaps.byComponentOfKind.size,
|
|
667
|
-
colorsUsed: globalMaps.colorsUsed.size
|
|
668
|
-
},
|
|
669
|
-
stats: {
|
|
670
|
-
filesWithMostComponent,
|
|
671
|
-
mostUseds: getXMostUseds(globalMaps, 10)
|
|
672
|
-
}
|
|
437
|
+
getRecipeReport(format = "table") {
|
|
438
|
+
const report = reporter.getRecipeReport();
|
|
439
|
+
return { report, formatted: (0, import_reporter.formatRecipeReport)(report, format) };
|
|
673
440
|
},
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
globalMaps,
|
|
678
|
-
byFilePathMaps
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
};
|
|
682
|
-
var getXMostUseds = (globalMaps, pickCount) => {
|
|
683
|
-
return {
|
|
684
|
-
propNames: getMostUsedInMap(globalMaps.byPropertyName, pickCount),
|
|
685
|
-
tokens: getMostUsedInMap(globalMaps.byTokenName, pickCount),
|
|
686
|
-
shorthands: getMostUsedInMap(globalMaps.byShorthand, pickCount),
|
|
687
|
-
conditions: getMostUsedInMap(globalMaps.byConditionName, pickCount),
|
|
688
|
-
propertyPaths: getMostUsedInMap(globalMaps.byPropertyPath, pickCount),
|
|
689
|
-
categories: getMostUsedInMap(globalMaps.byTokenType, pickCount),
|
|
690
|
-
types: getMostUsedInMap(globalMaps.byType, pickCount),
|
|
691
|
-
componentNames: getMostUsedInMap(globalMaps.byComponentName, pickCount),
|
|
692
|
-
fromKinds: getMostUsedInMap(globalMaps.fromKind, pickCount),
|
|
693
|
-
componentOfKinds: getMostUsedInMap(globalMaps.byComponentOfKind, pickCount),
|
|
694
|
-
colors: getMostUsedInMap(globalMaps.colorsUsed, pickCount)
|
|
695
|
-
};
|
|
696
|
-
};
|
|
697
|
-
var getMostUsedInMap = (map, pickCount) => {
|
|
698
|
-
return Array.from(map.entries()).map(([key, list]) => [key, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount).map(([key, count]) => ({ key, count }));
|
|
699
|
-
};
|
|
700
|
-
var defaultGroupNames = [
|
|
701
|
-
"System",
|
|
702
|
-
"Container",
|
|
703
|
-
"Display",
|
|
704
|
-
"Visibility",
|
|
705
|
-
"Position",
|
|
706
|
-
"Transform",
|
|
707
|
-
"Flex Layout",
|
|
708
|
-
"Grid Layout",
|
|
709
|
-
"Layout",
|
|
710
|
-
"Border",
|
|
711
|
-
"Border Radius",
|
|
712
|
-
"Width",
|
|
713
|
-
"Height",
|
|
714
|
-
"Margin",
|
|
715
|
-
"Padding",
|
|
716
|
-
"Color",
|
|
717
|
-
"Typography",
|
|
718
|
-
"Background",
|
|
719
|
-
"Shadow",
|
|
720
|
-
"Table",
|
|
721
|
-
"List",
|
|
722
|
-
"Scroll",
|
|
723
|
-
"Interactivity",
|
|
724
|
-
"Transition",
|
|
725
|
-
"Effect",
|
|
726
|
-
"Other"
|
|
727
|
-
];
|
|
728
|
-
var getPropertyGroupMap = (context) => {
|
|
729
|
-
const groups = new Map(defaultGroupNames.map((name) => [name, /* @__PURE__ */ new Set()]));
|
|
730
|
-
const groupByProp = /* @__PURE__ */ new Map();
|
|
731
|
-
const systemGroup = groups.get("System");
|
|
732
|
-
systemGroup.add("base");
|
|
733
|
-
systemGroup.add("colorPalette");
|
|
734
|
-
const otherStyleProps = groups.get("Other");
|
|
735
|
-
Object.entries(context.utility.config).map(([key, value]) => {
|
|
736
|
-
const group = value?.group;
|
|
737
|
-
if (!group) {
|
|
738
|
-
otherStyleProps.add(key);
|
|
739
|
-
return;
|
|
740
|
-
}
|
|
741
|
-
if (!groups.has(group)) {
|
|
742
|
-
groups.set(group, /* @__PURE__ */ new Set());
|
|
743
|
-
}
|
|
744
|
-
const set = groups.get(group);
|
|
745
|
-
if (value.shorthand) {
|
|
746
|
-
if (Array.isArray(value.shorthand)) {
|
|
747
|
-
value.shorthand.forEach((shorthand) => {
|
|
748
|
-
set.add(shorthand);
|
|
749
|
-
groupByProp.set(shorthand, group);
|
|
750
|
-
});
|
|
751
|
-
} else {
|
|
752
|
-
set.add(value.shorthand);
|
|
753
|
-
groupByProp.set(value.shorthand, group);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
set.add(key);
|
|
757
|
-
groupByProp.set(key, group);
|
|
758
|
-
});
|
|
759
|
-
return { groups, groupByProp };
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
// src/analyze-tokens.ts
|
|
763
|
-
var gzipSizeSync = (code) => import_zlib.default.gzipSync(code, { level: import_zlib.default.constants.Z_BEST_COMPRESSION }).length;
|
|
764
|
-
function analyzeTokens(ctx, options = {}) {
|
|
765
|
-
const filesMap = /* @__PURE__ */ new Map();
|
|
766
|
-
const timesMap = /* @__PURE__ */ new Map();
|
|
767
|
-
const files = ctx.getFiles();
|
|
768
|
-
const sheet = ctx.createSheet();
|
|
769
|
-
ctx.appendLayerParams(sheet);
|
|
770
|
-
ctx.appendBaselineCss(sheet);
|
|
771
|
-
files.forEach((file) => {
|
|
772
|
-
const start2 = performance.now();
|
|
773
|
-
const result = ctx.project.parseSourceFile(file);
|
|
774
|
-
const extractMs = performance.now() - start2;
|
|
775
|
-
const relativePath = import_node_path.default.relative(ctx.config.cwd, file);
|
|
776
|
-
timesMap.set(relativePath, extractMs);
|
|
777
|
-
import_logger.logger.debug("analyze", `Parsed ${file} in ${extractMs}ms`);
|
|
778
|
-
if (result) {
|
|
779
|
-
filesMap.set(relativePath, result);
|
|
780
|
-
options.onResult?.(file, result);
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
const totalMs = Array.from(timesMap.values()).reduce((a, b) => a + b, 0);
|
|
784
|
-
import_logger.logger.debug("analyze", `Analyzed ${files.length} files in ${totalMs.toFixed(2)}ms`);
|
|
785
|
-
ctx.appendParserCss(sheet);
|
|
786
|
-
const cssStart = performance.now();
|
|
787
|
-
ctx.config.minify = false;
|
|
788
|
-
const css = ctx.getCss(sheet);
|
|
789
|
-
const cssMs = performance.now() - cssStart;
|
|
790
|
-
const cssMinifyStart = performance.now();
|
|
791
|
-
ctx.config.minify = true;
|
|
792
|
-
const minifiedCss = ctx.getCss(sheet);
|
|
793
|
-
const cssMinifyMs = performance.now() - cssMinifyStart;
|
|
794
|
-
let lightningCss = "";
|
|
795
|
-
let lightningCssMs;
|
|
796
|
-
let lightningCssMinifiedCss = "";
|
|
797
|
-
let lightningCssMinifiedMs;
|
|
798
|
-
const isUsingLightningCss = ctx.config.lightningcss;
|
|
799
|
-
if (!isUsingLightningCss) {
|
|
800
|
-
sheet["context"].lightningcss = true;
|
|
801
|
-
ctx.config.minify = false;
|
|
802
|
-
const lightningcssStart = performance.now();
|
|
803
|
-
lightningCss = ctx.getCss(sheet);
|
|
804
|
-
lightningCssMs = performance.now() - lightningcssStart;
|
|
805
|
-
ctx.config.minify = true;
|
|
806
|
-
const lightningcssMinifyStart = performance.now();
|
|
807
|
-
lightningCssMinifiedCss = ctx.getCss(sheet);
|
|
808
|
-
lightningCssMinifiedMs = performance.now() - lightningcssMinifyStart;
|
|
809
|
-
}
|
|
810
|
-
const start = performance.now();
|
|
811
|
-
const analysis = classifyTokens(ctx, filesMap);
|
|
812
|
-
const classifyMs = performance.now() - start;
|
|
813
|
-
const details = Object.assign(
|
|
814
|
-
{
|
|
815
|
-
duration: {
|
|
816
|
-
classify: classifyMs,
|
|
817
|
-
//
|
|
818
|
-
cssMs,
|
|
819
|
-
cssMinifyMs,
|
|
820
|
-
//
|
|
821
|
-
...!isUsingLightningCss ? {
|
|
822
|
-
lightningCssMs,
|
|
823
|
-
lightningCssMinifiedMs
|
|
824
|
-
} : {},
|
|
825
|
-
//
|
|
826
|
-
extractTotal: totalMs,
|
|
827
|
-
extractTimeByFiles: Object.fromEntries(timesMap.entries())
|
|
828
|
-
},
|
|
829
|
-
fileSizes: {
|
|
830
|
-
lineCount: css.split("\n").length,
|
|
831
|
-
normal: (0, import_filesize.filesize)(Buffer.byteLength(css, "utf-8")),
|
|
832
|
-
minified: (0, import_filesize.filesize)(Buffer.byteLength(minifiedCss, "utf-8")),
|
|
833
|
-
gzip: {
|
|
834
|
-
normal: (0, import_filesize.filesize)(gzipSizeSync(css)),
|
|
835
|
-
minified: (0, import_filesize.filesize)(gzipSizeSync(minifiedCss))
|
|
836
|
-
},
|
|
837
|
-
lightningCss: !isUsingLightningCss ? {
|
|
838
|
-
normal: (0, import_filesize.filesize)(Buffer.byteLength(lightningCss, "utf-8")),
|
|
839
|
-
minified: (0, import_filesize.filesize)(Buffer.byteLength(lightningCssMinifiedCss, "utf-8"))
|
|
840
|
-
} : void 0
|
|
841
|
-
}
|
|
441
|
+
getTokenReport(format = "table") {
|
|
442
|
+
const report = reporter.getTokenReport();
|
|
443
|
+
return { report, formatted: (0, import_reporter.formatTokenReport)(report.getSummary(), format) };
|
|
842
444
|
},
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
propByIndex: analysis.propById,
|
|
850
|
-
componentByIndex: analysis.componentById,
|
|
851
|
-
derived: analysis.derived,
|
|
852
|
-
config
|
|
445
|
+
writeReport(filePath) {
|
|
446
|
+
const dirname2 = ctx.runtime.path.dirname(filePath);
|
|
447
|
+
ctx.runtime.fs.ensureDirSync(dirname2);
|
|
448
|
+
const str = JSON.stringify(reporter.report, replacer, 2);
|
|
449
|
+
return ctx.runtime.fs.writeFile(filePath, str);
|
|
450
|
+
}
|
|
853
451
|
};
|
|
854
452
|
}
|
|
855
|
-
|
|
856
|
-
if (value instanceof Set)
|
|
453
|
+
function replacer(_, value) {
|
|
454
|
+
if (value instanceof Set)
|
|
857
455
|
return Array.from(value);
|
|
858
|
-
|
|
859
|
-
if (value instanceof Map) {
|
|
456
|
+
if (value instanceof Map)
|
|
860
457
|
return Object.fromEntries(value);
|
|
861
|
-
}
|
|
862
458
|
return value;
|
|
863
|
-
}
|
|
864
|
-
var writeAnalyzeJSON = (filePath, result, ctx) => {
|
|
865
|
-
const dirname2 = ctx.runtime.path.dirname(filePath);
|
|
866
|
-
ctx.runtime.fs.ensureDirSync(dirname2);
|
|
867
|
-
return (0, import_promises.writeFile)(filePath, JSON.stringify(result, analyzeResultSerializer, 2));
|
|
868
|
-
};
|
|
459
|
+
}
|
|
869
460
|
|
|
870
461
|
// src/build-info.ts
|
|
871
462
|
init_cjs_shims();
|
|
872
|
-
var
|
|
463
|
+
var import_logger = require("@pandacss/logger");
|
|
873
464
|
async function buildInfo(ctx, outfile) {
|
|
874
465
|
const { filesWithCss, files } = ctx.parseFiles();
|
|
875
|
-
|
|
876
|
-
const minify = ctx.config
|
|
877
|
-
|
|
466
|
+
import_logger.logger.info("cli", `Found ${import_logger.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
467
|
+
const { minify, staticCss } = ctx.config;
|
|
468
|
+
import_logger.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger.colors.bold(outfile)}`);
|
|
469
|
+
if (staticCss) {
|
|
470
|
+
import_logger.logger.info("cli", "Adding staticCss definitions...");
|
|
471
|
+
ctx.staticCss.process(staticCss);
|
|
472
|
+
}
|
|
878
473
|
const output = JSON.stringify(ctx.encoder.toJSON(), null, minify ? 0 : 2);
|
|
879
474
|
ctx.output.ensure(outfile, process.cwd());
|
|
880
475
|
await ctx.runtime.fs.writeFile(outfile, output);
|
|
881
|
-
|
|
476
|
+
import_logger.logger.info("cli", "Done!");
|
|
882
477
|
}
|
|
883
478
|
|
|
884
479
|
// src/builder.ts
|
|
885
480
|
init_cjs_shims();
|
|
886
481
|
var import_config4 = require("@pandacss/config");
|
|
887
482
|
var import_core = require("@pandacss/core");
|
|
888
|
-
var
|
|
483
|
+
var import_logger5 = require("@pandacss/logger");
|
|
889
484
|
var import_shared2 = require("@pandacss/shared");
|
|
890
485
|
var import_fs = require("fs");
|
|
891
486
|
var import_path3 = require("path");
|
|
@@ -1037,7 +632,7 @@ var import_browserslist = __toESM(require("browserslist"));
|
|
|
1037
632
|
// src/create-context.ts
|
|
1038
633
|
init_cjs_shims();
|
|
1039
634
|
var import_generator2 = require("@pandacss/generator");
|
|
1040
|
-
var
|
|
635
|
+
var import_logger4 = require("@pandacss/logger");
|
|
1041
636
|
var import_parser = require("@pandacss/parser");
|
|
1042
637
|
var import_shared = require("@pandacss/shared");
|
|
1043
638
|
var import_perfect_debounce = require("perfect-debounce");
|
|
@@ -1055,13 +650,12 @@ init_cjs_shims();
|
|
|
1055
650
|
// ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
|
1056
651
|
init_cjs_shims();
|
|
1057
652
|
|
|
1058
|
-
// ../../node_modules/.pnpm/ansi-regex@6.1
|
|
653
|
+
// ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
|
|
1059
654
|
init_cjs_shims();
|
|
1060
655
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1061
|
-
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
1062
656
|
const pattern = [
|
|
1063
|
-
|
|
1064
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-
|
|
657
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
658
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
1065
659
|
].join("|");
|
|
1066
660
|
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
1067
661
|
}
|
|
@@ -1400,10 +994,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
1400
994
|
return 3;
|
|
1401
995
|
}
|
|
1402
996
|
if ("TERM_PROGRAM" in env) {
|
|
1403
|
-
const
|
|
997
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
1404
998
|
switch (env.TERM_PROGRAM) {
|
|
1405
999
|
case "iTerm.app": {
|
|
1406
|
-
return
|
|
1000
|
+
return version >= 3 ? 3 : 2;
|
|
1407
1001
|
}
|
|
1408
1002
|
case "Apple_Terminal": {
|
|
1409
1003
|
return 2;
|
|
@@ -1436,7 +1030,7 @@ var supports_color_default = supportsColor;
|
|
|
1436
1030
|
|
|
1437
1031
|
// ../../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
|
|
1438
1032
|
init_cjs_shims();
|
|
1439
|
-
function stringReplaceAll(string, substring,
|
|
1033
|
+
function stringReplaceAll(string, substring, replacer2) {
|
|
1440
1034
|
let index = string.indexOf(substring);
|
|
1441
1035
|
if (index === -1) {
|
|
1442
1036
|
return string;
|
|
@@ -1445,7 +1039,7 @@ function stringReplaceAll(string, substring, replacer) {
|
|
|
1445
1039
|
let endIndex = 0;
|
|
1446
1040
|
let returnValue = "";
|
|
1447
1041
|
do {
|
|
1448
|
-
returnValue += string.slice(endIndex, index) + substring +
|
|
1042
|
+
returnValue += string.slice(endIndex, index) + substring + replacer2;
|
|
1449
1043
|
endIndex = index + substringLength;
|
|
1450
1044
|
index = string.indexOf(substring, endIndex);
|
|
1451
1045
|
} while (index !== -1);
|
|
@@ -2391,7 +1985,7 @@ var DiffEngine = class {
|
|
|
2391
1985
|
|
|
2392
1986
|
// src/node-runtime.ts
|
|
2393
1987
|
init_cjs_shims();
|
|
2394
|
-
var
|
|
1988
|
+
var import_logger2 = require("@pandacss/logger");
|
|
2395
1989
|
var import_chokidar = __toESM(require("chokidar"));
|
|
2396
1990
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
2397
1991
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
@@ -2434,8 +2028,8 @@ var nodeRuntime = {
|
|
|
2434
2028
|
readDirSync: import_fs_extra.default.readdirSync,
|
|
2435
2029
|
rmDirSync: import_fs_extra.default.emptyDirSync,
|
|
2436
2030
|
rmFileSync: import_fs_extra.default.removeSync,
|
|
2437
|
-
ensureDirSync(
|
|
2438
|
-
return import_fs_extra.default.ensureDirSync(
|
|
2031
|
+
ensureDirSync(path3) {
|
|
2032
|
+
return import_fs_extra.default.ensureDirSync(path3);
|
|
2439
2033
|
},
|
|
2440
2034
|
watch(options) {
|
|
2441
2035
|
const { include, exclude, cwd, poll } = options;
|
|
@@ -2448,7 +2042,7 @@ var nodeRuntime = {
|
|
|
2448
2042
|
ignored: exclude,
|
|
2449
2043
|
awaitWriteFinish: coalesce ? { stabilityThreshold: 50, pollInterval: 10 } : false
|
|
2450
2044
|
});
|
|
2451
|
-
|
|
2045
|
+
import_logger2.logger.debug("watch:file", `watching [${include}]`);
|
|
2452
2046
|
process.once("SIGINT", async () => {
|
|
2453
2047
|
await watcher.close();
|
|
2454
2048
|
});
|
|
@@ -2458,15 +2052,15 @@ var nodeRuntime = {
|
|
|
2458
2052
|
};
|
|
2459
2053
|
process.setMaxListeners(Infinity);
|
|
2460
2054
|
process.on("unhandledRejection", (reason) => {
|
|
2461
|
-
|
|
2055
|
+
import_logger2.logger.error("\u274C", reason);
|
|
2462
2056
|
});
|
|
2463
2057
|
process.on("uncaughtException", (reason) => {
|
|
2464
|
-
|
|
2058
|
+
import_logger2.logger.error("\u274C", reason);
|
|
2465
2059
|
});
|
|
2466
2060
|
|
|
2467
2061
|
// src/output-engine.ts
|
|
2468
2062
|
init_cjs_shims();
|
|
2469
|
-
var
|
|
2063
|
+
var import_logger3 = require("@pandacss/logger");
|
|
2470
2064
|
var OutputEngine = class {
|
|
2471
2065
|
paths;
|
|
2472
2066
|
fs;
|
|
@@ -2497,7 +2091,7 @@ var OutputEngine = class {
|
|
|
2497
2091
|
return;
|
|
2498
2092
|
const { file, code } = artifact;
|
|
2499
2093
|
const absPath = this.path.join(...dir, file);
|
|
2500
|
-
|
|
2094
|
+
import_logger3.logger.debug("write:file", dir.slice(-1).concat(file).join("/"));
|
|
2501
2095
|
return this.fs.writeFile(absPath, code);
|
|
2502
2096
|
})
|
|
2503
2097
|
);
|
|
@@ -2517,7 +2111,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2517
2111
|
this.runtime = nodeRuntime;
|
|
2518
2112
|
config.cwd ||= this.runtime.cwd();
|
|
2519
2113
|
if (config.logLevel) {
|
|
2520
|
-
|
|
2114
|
+
import_logger4.logger.level = config.logLevel;
|
|
2521
2115
|
}
|
|
2522
2116
|
this.project = new import_parser.Project({
|
|
2523
2117
|
...conf.tsconfig,
|
|
@@ -2551,14 +2145,14 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2551
2145
|
};
|
|
2552
2146
|
parseFile = (filePath, styleEncoder) => {
|
|
2553
2147
|
const file = this.runtime.path.abs(this.config.cwd, filePath);
|
|
2554
|
-
|
|
2555
|
-
const measure =
|
|
2148
|
+
import_logger4.logger.debug("file:extract", file);
|
|
2149
|
+
const measure = import_logger4.logger.time.debug(`Parsed ${file}`);
|
|
2556
2150
|
let result;
|
|
2557
2151
|
try {
|
|
2558
2152
|
const encoder = styleEncoder || this.parserOptions.encoder;
|
|
2559
2153
|
result = this.project.parseSourceFile(file, encoder);
|
|
2560
2154
|
} catch (error) {
|
|
2561
|
-
|
|
2155
|
+
import_logger4.logger.error("file:extract", error);
|
|
2562
2156
|
}
|
|
2563
2157
|
measure();
|
|
2564
2158
|
return result;
|
|
@@ -2569,7 +2163,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2569
2163
|
const filesWithCss = [];
|
|
2570
2164
|
const results = [];
|
|
2571
2165
|
files.forEach((file) => {
|
|
2572
|
-
const measure =
|
|
2166
|
+
const measure = import_logger4.logger.time.debug(`Parsed ${file}`);
|
|
2573
2167
|
const result = this.project.parseSourceFile(file, encoder);
|
|
2574
2168
|
measure();
|
|
2575
2169
|
if (!result || result.isEmpty() || encoder.isEmpty())
|
|
@@ -2584,7 +2178,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2584
2178
|
};
|
|
2585
2179
|
};
|
|
2586
2180
|
writeCss = (sheet) => {
|
|
2587
|
-
|
|
2181
|
+
import_logger4.logger.info("css", this.runtime.path.join(...this.paths.root, "styles.css"));
|
|
2588
2182
|
return this.output.write({
|
|
2589
2183
|
id: "styles.css",
|
|
2590
2184
|
dir: this.paths.root,
|
|
@@ -2593,7 +2187,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2593
2187
|
};
|
|
2594
2188
|
watchConfig = (cb, opts) => {
|
|
2595
2189
|
const { cwd, poll, exclude } = opts ?? {};
|
|
2596
|
-
|
|
2190
|
+
import_logger4.logger.info("ctx:watch", this.messages.configWatch());
|
|
2597
2191
|
const watcher = this.runtime.fs.watch({
|
|
2598
2192
|
include: (0, import_shared.uniq)([...this.explicitDeps, ...this.conf.dependencies]),
|
|
2599
2193
|
exclude,
|
|
@@ -2603,14 +2197,14 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2603
2197
|
watcher.on(
|
|
2604
2198
|
"change",
|
|
2605
2199
|
(0, import_perfect_debounce.debounce)(async (file) => {
|
|
2606
|
-
|
|
2200
|
+
import_logger4.logger.info("ctx:change", "config changed, rebuilding...");
|
|
2607
2201
|
await cb(file);
|
|
2608
2202
|
})
|
|
2609
2203
|
);
|
|
2610
2204
|
};
|
|
2611
2205
|
watchFiles = (cb, opts) => {
|
|
2612
2206
|
const { include, exclude, poll, cwd } = this.config;
|
|
2613
|
-
|
|
2207
|
+
import_logger4.logger.info("ctx:watch", this.messages.watch());
|
|
2614
2208
|
const watcher = this.runtime.fs.watch({
|
|
2615
2209
|
...opts,
|
|
2616
2210
|
include,
|
|
@@ -2621,7 +2215,7 @@ var PandaContext = class extends import_generator2.Generator {
|
|
|
2621
2215
|
watcher.on(
|
|
2622
2216
|
"all",
|
|
2623
2217
|
(0, import_perfect_debounce.debounce)(async (event, file) => {
|
|
2624
|
-
|
|
2218
|
+
import_logger4.logger.info(`file:${event}`, file);
|
|
2625
2219
|
await cb(event, file);
|
|
2626
2220
|
})
|
|
2627
2221
|
);
|
|
@@ -2745,11 +2339,11 @@ var Builder = class {
|
|
|
2745
2339
|
configDeps.forEach((file) => {
|
|
2746
2340
|
this.configDependencies.add(file);
|
|
2747
2341
|
});
|
|
2748
|
-
|
|
2749
|
-
|
|
2342
|
+
import_logger5.logger.debug("builder", "Config dependencies");
|
|
2343
|
+
import_logger5.logger.debug("builder", configDeps);
|
|
2750
2344
|
}
|
|
2751
2345
|
setup = async (options = {}) => {
|
|
2752
|
-
|
|
2346
|
+
import_logger5.logger.debug("builder", "\u{1F6A7} Setup");
|
|
2753
2347
|
const configPath = options.configPath ?? (0, import_config4.findConfig)({ cwd: options.cwd });
|
|
2754
2348
|
this.setConfigDependencies({ configPath, cwd: options.cwd });
|
|
2755
2349
|
if (!this.context) {
|
|
@@ -2759,29 +2353,29 @@ var Builder = class {
|
|
|
2759
2353
|
this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2760
2354
|
this.context = new PandaContext(conf);
|
|
2761
2355
|
});
|
|
2762
|
-
|
|
2356
|
+
import_logger5.logger.debug("builder", this.affecteds);
|
|
2763
2357
|
this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
|
|
2764
2358
|
if (this.explicitDepsMeta.hasFilesChanged) {
|
|
2765
2359
|
this.explicitDepsMeta.changes.forEach((meta, file) => {
|
|
2766
2360
|
fileModifiedMap.set(file, meta.mtime);
|
|
2767
2361
|
});
|
|
2768
|
-
|
|
2362
|
+
import_logger5.logger.debug("builder", "\u2699\uFE0F Explicit config dependencies changed");
|
|
2769
2363
|
this.affecteds.hasConfigChanged = true;
|
|
2770
2364
|
}
|
|
2771
2365
|
if (this.affecteds.hasConfigChanged) {
|
|
2772
|
-
|
|
2366
|
+
import_logger5.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2773
2367
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: this.affecteds });
|
|
2774
2368
|
return;
|
|
2775
2369
|
}
|
|
2776
2370
|
this.filesMeta = this.checkFilesChanged(ctx.getFiles());
|
|
2777
2371
|
if (this.filesMeta.hasFilesChanged) {
|
|
2778
|
-
|
|
2372
|
+
import_logger5.logger.debug("builder", "Files changed, invalidating them");
|
|
2779
2373
|
ctx.project.reloadSourceFiles();
|
|
2780
2374
|
}
|
|
2781
2375
|
};
|
|
2782
2376
|
async emit() {
|
|
2783
2377
|
if (this.hasEmitted && this.affecteds?.hasConfigChanged) {
|
|
2784
|
-
|
|
2378
|
+
import_logger5.logger.debug("builder", "Emit artifacts after config change");
|
|
2785
2379
|
await codegen(this.getContextOrThrow(), Array.from(this.affecteds.artifacts));
|
|
2786
2380
|
}
|
|
2787
2381
|
this.hasEmitted = true;
|
|
@@ -2831,12 +2425,12 @@ var Builder = class {
|
|
|
2831
2425
|
extract = () => {
|
|
2832
2426
|
const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : true;
|
|
2833
2427
|
if (!this.filesMeta && !hasConfigChanged) {
|
|
2834
|
-
|
|
2428
|
+
import_logger5.logger.debug("builder", "No files or config changed, skipping extract");
|
|
2835
2429
|
return;
|
|
2836
2430
|
}
|
|
2837
2431
|
const ctx = this.getContextOrThrow();
|
|
2838
2432
|
const files = ctx.getFiles();
|
|
2839
|
-
const done =
|
|
2433
|
+
const done = import_logger5.logger.time.info("Extracted in");
|
|
2840
2434
|
files.map((file) => this.extractFile(ctx, file));
|
|
2841
2435
|
done();
|
|
2842
2436
|
};
|
|
@@ -2878,9 +2472,9 @@ var Builder = class {
|
|
|
2878
2472
|
|
|
2879
2473
|
// src/cpu-profile.ts
|
|
2880
2474
|
init_cjs_shims();
|
|
2881
|
-
var
|
|
2475
|
+
var import_logger6 = require("@pandacss/logger");
|
|
2882
2476
|
var import_node_fs = __toESM(require("fs"));
|
|
2883
|
-
var
|
|
2477
|
+
var import_node_path = __toESM(require("path"));
|
|
2884
2478
|
var import_node_readline = __toESM(require("readline"));
|
|
2885
2479
|
var startProfiling = async (cwd, prefix, isWatching) => {
|
|
2886
2480
|
const inspector = await import("inspector").then((r) => r.default);
|
|
@@ -2934,7 +2528,7 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2934
2528
|
session.post("Profiler.stop", (err, params) => {
|
|
2935
2529
|
setState("idle");
|
|
2936
2530
|
if (err) {
|
|
2937
|
-
|
|
2531
|
+
import_logger6.logger.error("cpu-prof", err);
|
|
2938
2532
|
cb?.();
|
|
2939
2533
|
return;
|
|
2940
2534
|
}
|
|
@@ -2945,9 +2539,9 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2945
2539
|
const date = /* @__PURE__ */ new Date();
|
|
2946
2540
|
const timestamp = date.toISOString().replace(/[-:.]/g, "");
|
|
2947
2541
|
const title = `panda-${prefix}-${timestamp}`;
|
|
2948
|
-
const outfile =
|
|
2542
|
+
const outfile = import_node_path.default.join(cwd, `${title}.cpuprofile`);
|
|
2949
2543
|
import_node_fs.default.writeFileSync(outfile, JSON.stringify(params.profile));
|
|
2950
|
-
|
|
2544
|
+
import_logger6.logger.info("cpu-prof", outfile);
|
|
2951
2545
|
cb?.();
|
|
2952
2546
|
});
|
|
2953
2547
|
};
|
|
@@ -2956,16 +2550,16 @@ var startProfiling = async (cwd, prefix, isWatching) => {
|
|
|
2956
2550
|
|
|
2957
2551
|
// src/cssgen.ts
|
|
2958
2552
|
init_cjs_shims();
|
|
2959
|
-
var
|
|
2553
|
+
var import_logger7 = require("@pandacss/logger");
|
|
2960
2554
|
var cssgen = async (ctx, options) => {
|
|
2961
2555
|
const { outfile, type, minimal } = options;
|
|
2962
2556
|
const sheet = ctx.createSheet();
|
|
2963
2557
|
if (type) {
|
|
2964
|
-
const done =
|
|
2558
|
+
const done = import_logger7.logger.time.info(ctx.messages.cssArtifactComplete(type));
|
|
2965
2559
|
ctx.appendCssOfType(type, sheet);
|
|
2966
2560
|
if (outfile) {
|
|
2967
2561
|
const css = ctx.getCss(sheet);
|
|
2968
|
-
|
|
2562
|
+
import_logger7.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
2969
2563
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2970
2564
|
} else {
|
|
2971
2565
|
await ctx.writeCss(sheet);
|
|
@@ -2973,7 +2567,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2973
2567
|
done();
|
|
2974
2568
|
} else {
|
|
2975
2569
|
const { files } = ctx.parseFiles();
|
|
2976
|
-
const done =
|
|
2570
|
+
const done = import_logger7.logger.time.info(ctx.messages.buildComplete(files.length));
|
|
2977
2571
|
if (!minimal) {
|
|
2978
2572
|
ctx.appendLayerParams(sheet);
|
|
2979
2573
|
ctx.appendBaselineCss(sheet);
|
|
@@ -2981,7 +2575,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2981
2575
|
ctx.appendParserCss(sheet);
|
|
2982
2576
|
if (outfile) {
|
|
2983
2577
|
const css = ctx.getCss(sheet);
|
|
2984
|
-
|
|
2578
|
+
import_logger7.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
2985
2579
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2986
2580
|
} else {
|
|
2987
2581
|
await ctx.writeCss(sheet);
|
|
@@ -2992,17 +2586,17 @@ var cssgen = async (ctx, options) => {
|
|
|
2992
2586
|
|
|
2993
2587
|
// src/debug.ts
|
|
2994
2588
|
init_cjs_shims();
|
|
2995
|
-
var
|
|
2589
|
+
var import_logger8 = require("@pandacss/logger");
|
|
2996
2590
|
var import_path4 = require("path");
|
|
2997
2591
|
async function debug(ctx, options) {
|
|
2998
2592
|
const files = ctx.getFiles();
|
|
2999
|
-
const measureTotal =
|
|
2593
|
+
const measureTotal = import_logger8.logger.time.debug(`Done parsing ${files.length} files`);
|
|
3000
2594
|
ctx.config.minify = false;
|
|
3001
|
-
const { fs: fs3, path:
|
|
2595
|
+
const { fs: fs3, path: path3 } = ctx.runtime;
|
|
3002
2596
|
const outdir = options.outdir;
|
|
3003
2597
|
if (!options.dry && outdir) {
|
|
3004
2598
|
fs3.ensureDirSync(outdir);
|
|
3005
|
-
|
|
2599
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/config.json`)}`);
|
|
3006
2600
|
await fs3.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
3007
2601
|
}
|
|
3008
2602
|
if (options.onlyConfig) {
|
|
@@ -3011,7 +2605,7 @@ async function debug(ctx, options) {
|
|
|
3011
2605
|
}
|
|
3012
2606
|
const filesWithCss = [];
|
|
3013
2607
|
files.map((file) => {
|
|
3014
|
-
const measure =
|
|
2608
|
+
const measure = import_logger8.logger.time.debug(`Parsed ${file}`);
|
|
3015
2609
|
const encoder = ctx.encoder.clone();
|
|
3016
2610
|
const result = ctx.project.parseSourceFile(file, encoder);
|
|
3017
2611
|
measure();
|
|
@@ -3028,30 +2622,30 @@ async function debug(ctx, options) {
|
|
|
3028
2622
|
if (outdir) {
|
|
3029
2623
|
filesWithCss.push(file);
|
|
3030
2624
|
const parsedPath = (0, import_path4.parse)(file);
|
|
3031
|
-
const relative2 =
|
|
3032
|
-
const astJsonPath = `${relative2}${
|
|
3033
|
-
const cssPath = `${relative2}${
|
|
3034
|
-
|
|
3035
|
-
|
|
2625
|
+
const relative2 = path3.relative(ctx.config.cwd, parsedPath.dir);
|
|
2626
|
+
const astJsonPath = `${relative2}${path3.sep}${parsedPath.name}.ast.json`.replaceAll(path3.sep, "__");
|
|
2627
|
+
const cssPath = `${relative2}${path3.sep}${parsedPath.name}.css`.replaceAll(path3.sep, "__");
|
|
2628
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2629
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${cssPath}`)}`);
|
|
3036
2630
|
return Promise.allSettled([
|
|
3037
|
-
fs3.writeFile(`${outdir}${
|
|
3038
|
-
fs3.writeFile(`${outdir}${
|
|
2631
|
+
fs3.writeFile(`${outdir}${path3.sep}${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2632
|
+
fs3.writeFile(`${outdir}${path3.sep}${cssPath}`, css)
|
|
3039
2633
|
]);
|
|
3040
2634
|
}
|
|
3041
2635
|
});
|
|
3042
|
-
|
|
2636
|
+
import_logger8.logger.info("cli", `Found ${import_logger8.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
3043
2637
|
measureTotal();
|
|
3044
2638
|
}
|
|
3045
2639
|
|
|
3046
2640
|
// src/generate.ts
|
|
3047
2641
|
init_cjs_shims();
|
|
3048
|
-
var
|
|
2642
|
+
var import_logger9 = require("@pandacss/logger");
|
|
3049
2643
|
async function build(ctx, artifactIds) {
|
|
3050
2644
|
await codegen(ctx, artifactIds);
|
|
3051
2645
|
if (ctx.config.emitTokensOnly) {
|
|
3052
|
-
return
|
|
2646
|
+
return import_logger9.logger.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
|
|
3053
2647
|
}
|
|
3054
|
-
const done =
|
|
2648
|
+
const done = import_logger9.logger.time.info("");
|
|
3055
2649
|
const sheet = ctx.createSheet();
|
|
3056
2650
|
ctx.appendLayerParams(sheet);
|
|
3057
2651
|
ctx.appendBaselineCss(sheet);
|
|
@@ -3070,7 +2664,7 @@ async function generate(config, configPath) {
|
|
|
3070
2664
|
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
3071
2665
|
ctx = new PandaContext(conf);
|
|
3072
2666
|
});
|
|
3073
|
-
|
|
2667
|
+
import_logger9.logger.info("ctx:updated", "config rebuilt \u2705");
|
|
3074
2668
|
await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
|
|
3075
2669
|
return build(ctx, Array.from(affecteds.artifacts));
|
|
3076
2670
|
},
|
|
@@ -3080,7 +2674,7 @@ async function generate(config, configPath) {
|
|
|
3080
2674
|
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
3081
2675
|
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
3082
2676
|
if (parserResult) {
|
|
3083
|
-
const done =
|
|
2677
|
+
const done = import_logger9.logger.time.info(ctx2.messages.buildComplete(1));
|
|
3084
2678
|
const sheet = ctx2.createSheet();
|
|
3085
2679
|
ctx2.appendLayerParams(sheet);
|
|
3086
2680
|
ctx2.appendBaselineCss(sheet);
|
|
@@ -3132,18 +2726,18 @@ function setupGitIgnore(ctx) {
|
|
|
3132
2726
|
|
|
3133
2727
|
// src/logstream.ts
|
|
3134
2728
|
init_cjs_shims();
|
|
3135
|
-
var
|
|
2729
|
+
var import_logger10 = require("@pandacss/logger");
|
|
3136
2730
|
var import_node_fs2 = __toESM(require("fs"));
|
|
3137
|
-
var
|
|
2731
|
+
var import_node_path2 = __toESM(require("path"));
|
|
3138
2732
|
var setLogStream = (options) => {
|
|
3139
2733
|
const { cwd = process.cwd() } = options;
|
|
3140
2734
|
let stream;
|
|
3141
2735
|
if (options.logfile) {
|
|
3142
|
-
const outPath =
|
|
2736
|
+
const outPath = import_node_path2.default.resolve(cwd, options.logfile);
|
|
3143
2737
|
ensure(outPath);
|
|
3144
|
-
|
|
2738
|
+
import_logger10.logger.info("logfile", outPath);
|
|
3145
2739
|
stream = import_node_fs2.default.createWriteStream(outPath, { flags: "a" });
|
|
3146
|
-
|
|
2740
|
+
import_logger10.logger.onLog = (entry) => {
|
|
3147
2741
|
stream?.write(JSON.stringify(entry) + "\n");
|
|
3148
2742
|
};
|
|
3149
2743
|
}
|
|
@@ -3160,7 +2754,7 @@ var setLogStream = (options) => {
|
|
|
3160
2754
|
};
|
|
3161
2755
|
};
|
|
3162
2756
|
var ensure = (outPath) => {
|
|
3163
|
-
const dirname2 =
|
|
2757
|
+
const dirname2 = import_node_path2.default.dirname(outPath);
|
|
3164
2758
|
import_node_fs2.default.mkdirSync(dirname2, { recursive: true });
|
|
3165
2759
|
return outPath;
|
|
3166
2760
|
};
|
|
@@ -3169,7 +2763,7 @@ var ensure = (outPath) => {
|
|
|
3169
2763
|
init_cjs_shims();
|
|
3170
2764
|
var import_config7 = require("@pandacss/config");
|
|
3171
2765
|
var import_core2 = require("@pandacss/core");
|
|
3172
|
-
var
|
|
2766
|
+
var import_logger11 = require("@pandacss/logger");
|
|
3173
2767
|
var import_shared3 = require("@pandacss/shared");
|
|
3174
2768
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
3175
2769
|
var import_look_it_up2 = require("look-it-up");
|
|
@@ -3192,9 +2786,9 @@ async function setupConfig(cwd, opts = {}) {
|
|
|
3192
2786
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
3193
2787
|
const isTs = (0, import_look_it_up2.lookItUpSync)("tsconfig.json", cwd);
|
|
3194
2788
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
3195
|
-
|
|
2789
|
+
import_logger11.logger.info("init:config", `creating panda config file: ${(0, import_logger11.quote)(file)}`);
|
|
3196
2790
|
if (!force && configFile) {
|
|
3197
|
-
|
|
2791
|
+
import_logger11.logger.warn("init:config", import_core2.messages.configExists(cmd));
|
|
3198
2792
|
} else {
|
|
3199
2793
|
const content = import_outdent2.outdent`
|
|
3200
2794
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -3227,11 +2821,11 @@ syntax: '${syntax}'` : ""}
|
|
|
3227
2821
|
})
|
|
3228
2822
|
`;
|
|
3229
2823
|
await import_fs_extra2.default.writeFile((0, import_path5.join)(cwd, file), await import_prettier.default.format(content, { parser: "babel" }));
|
|
3230
|
-
|
|
2824
|
+
import_logger11.logger.log(import_core2.messages.thankYou());
|
|
3231
2825
|
}
|
|
3232
2826
|
}
|
|
3233
2827
|
async function setupPostcss(cwd) {
|
|
3234
|
-
|
|
2828
|
+
import_logger11.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger11.quote)("postcss.config.cjs")}`);
|
|
3235
2829
|
const content = import_outdent2.outdent`
|
|
3236
2830
|
module.exports = {
|
|
3237
2831
|
plugins: {
|
|
@@ -3245,7 +2839,7 @@ module.exports = {
|
|
|
3245
2839
|
0 && (module.exports = {
|
|
3246
2840
|
Builder,
|
|
3247
2841
|
PandaContext,
|
|
3248
|
-
|
|
2842
|
+
analyze,
|
|
3249
2843
|
buildInfo,
|
|
3250
2844
|
codegen,
|
|
3251
2845
|
cssgen,
|
|
@@ -3257,6 +2851,5 @@ module.exports = {
|
|
|
3257
2851
|
setupConfig,
|
|
3258
2852
|
setupGitIgnore,
|
|
3259
2853
|
setupPostcss,
|
|
3260
|
-
startProfiling
|
|
3261
|
-
writeAnalyzeJSON
|
|
2854
|
+
startProfiling
|
|
3262
2855
|
});
|