@pandacss/node 0.0.0-dev-20230321125457 → 0.0.0-dev-20230323194924
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.ts +147 -4
- package/dist/index.js +405 -27
- package/dist/index.mjs +407 -31
- package/package.json +16 -13
package/dist/index.js
CHANGED
|
@@ -402,6 +402,7 @@ var require_ansi_align = __commonJS({
|
|
|
402
402
|
var src_exports = {};
|
|
403
403
|
__export(src_exports, {
|
|
404
404
|
Builder: () => Builder,
|
|
405
|
+
analyzeTokens: () => analyzeTokens,
|
|
405
406
|
createContext: () => createContext,
|
|
406
407
|
discardDuplicate: () => import_core3.discardDuplicate,
|
|
407
408
|
emitAndExtract: () => emitAndExtract,
|
|
@@ -412,17 +413,388 @@ __export(src_exports, {
|
|
|
412
413
|
loadConfigAndCreateContext: () => loadConfigAndCreateContext,
|
|
413
414
|
setupConfig: () => setupConfig,
|
|
414
415
|
setupGitIgnore: () => setupGitIgnore,
|
|
415
|
-
setupPostcss: () => setupPostcss
|
|
416
|
+
setupPostcss: () => setupPostcss,
|
|
417
|
+
writeAnalyzeJSON: () => writeAnalyzeJSON
|
|
416
418
|
});
|
|
417
419
|
module.exports = __toCommonJS(src_exports);
|
|
418
420
|
init_cjs_shims();
|
|
419
421
|
var import_core3 = require("@pandacss/core");
|
|
420
422
|
|
|
423
|
+
// src/analyze-tokens.ts
|
|
424
|
+
init_cjs_shims();
|
|
425
|
+
var import_logger = require("@pandacss/logger");
|
|
426
|
+
var import_promises = require("fs/promises");
|
|
427
|
+
var import_ts_morph = require("ts-morph");
|
|
428
|
+
|
|
429
|
+
// src/classify.ts
|
|
430
|
+
init_cjs_shims();
|
|
431
|
+
var createReportMaps = () => {
|
|
432
|
+
const byInstanceOfKind = /* @__PURE__ */ new Map();
|
|
433
|
+
const byPropertyName = /* @__PURE__ */ new Map();
|
|
434
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
435
|
+
const byConditionName = /* @__PURE__ */ new Map();
|
|
436
|
+
const byShorthand = /* @__PURE__ */ new Map();
|
|
437
|
+
const byTokenName = /* @__PURE__ */ new Map();
|
|
438
|
+
const byPropertyPath = /* @__PURE__ */ new Map();
|
|
439
|
+
const fromKind = /* @__PURE__ */ new Map();
|
|
440
|
+
const byType = /* @__PURE__ */ new Map();
|
|
441
|
+
const byInstanceName = /* @__PURE__ */ new Map();
|
|
442
|
+
const colorsUsed = /* @__PURE__ */ new Map();
|
|
443
|
+
return {
|
|
444
|
+
byInstanceOfKind,
|
|
445
|
+
byPropertyName,
|
|
446
|
+
byCategory,
|
|
447
|
+
byConditionName,
|
|
448
|
+
byShorthand,
|
|
449
|
+
byTokenName,
|
|
450
|
+
byPropertyPath,
|
|
451
|
+
fromKind,
|
|
452
|
+
byType,
|
|
453
|
+
byInstanceName,
|
|
454
|
+
colorsUsed
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
var colorPropNames = /* @__PURE__ */ new Set(["background", "outline", "border"]);
|
|
458
|
+
var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
459
|
+
const byId = /* @__PURE__ */ new Map();
|
|
460
|
+
const byInstanceId = /* @__PURE__ */ new Map();
|
|
461
|
+
const byFilepath = /* @__PURE__ */ new Map();
|
|
462
|
+
const byInstanceInFilepath = /* @__PURE__ */ new Map();
|
|
463
|
+
const globalMaps = createReportMaps();
|
|
464
|
+
const byFilePathMaps = /* @__PURE__ */ new Map();
|
|
465
|
+
const conditions = new Map(Object.entries(ctx.conditions.values));
|
|
466
|
+
let id = 0, instanceId = 0;
|
|
467
|
+
const isKnownUtility = (reportItem) => {
|
|
468
|
+
const { propName, type, value, from } = reportItem;
|
|
469
|
+
const utility = ctx.config.utilities?.[propName];
|
|
470
|
+
if (utility) {
|
|
471
|
+
if (!utility.shorthand) {
|
|
472
|
+
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
473
|
+
}
|
|
474
|
+
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
475
|
+
}
|
|
476
|
+
if (type === "pattern") {
|
|
477
|
+
const pattern = ctx.patterns.getConfig(from.toLowerCase());
|
|
478
|
+
const patternProp = pattern.properties[propName];
|
|
479
|
+
if (!patternProp)
|
|
480
|
+
return false;
|
|
481
|
+
if (patternProp.type === "boolean" || patternProp.type === "number") {
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
if (patternProp.type === "property") {
|
|
485
|
+
return Boolean(ctx.config.utilities?.[patternProp.value]);
|
|
486
|
+
}
|
|
487
|
+
if (patternProp.type === "enum") {
|
|
488
|
+
return Boolean(patternProp.value.includes(String(value)));
|
|
489
|
+
}
|
|
490
|
+
if (patternProp.type === "token") {
|
|
491
|
+
return Boolean(ctx.tokens.getByName(`${patternProp.value}.${value}`));
|
|
492
|
+
}
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
return false;
|
|
496
|
+
};
|
|
497
|
+
parserResultByFilepath.forEach((parserResult, filepath) => {
|
|
498
|
+
if (parserResult.isEmpty())
|
|
499
|
+
return;
|
|
500
|
+
const localMaps = createReportMaps();
|
|
501
|
+
const addTo = (map, key, value) => {
|
|
502
|
+
const set = map.get(key) ?? /* @__PURE__ */ new Set();
|
|
503
|
+
set.add(value);
|
|
504
|
+
map.set(key, set);
|
|
505
|
+
};
|
|
506
|
+
const processMap = (map, current, reportInstanceItem) => {
|
|
507
|
+
const { from, type, kind } = reportInstanceItem;
|
|
508
|
+
map.value.forEach((attrNode, attrName) => {
|
|
509
|
+
if (attrNode.isLiteral() || attrNode.isEmptyInitializer()) {
|
|
510
|
+
const value = attrNode.isLiteral() ? attrNode.value : true;
|
|
511
|
+
const reportItem = {
|
|
512
|
+
id: id++,
|
|
513
|
+
instanceId,
|
|
514
|
+
category: "unknown",
|
|
515
|
+
propName: attrName,
|
|
516
|
+
from,
|
|
517
|
+
type,
|
|
518
|
+
kind,
|
|
519
|
+
filepath,
|
|
520
|
+
path: current.concat(attrName),
|
|
521
|
+
value,
|
|
522
|
+
box: attrNode,
|
|
523
|
+
isKnown: false
|
|
524
|
+
};
|
|
525
|
+
reportInstanceItem.contains.push(reportItem.id);
|
|
526
|
+
if (conditions.has(attrName)) {
|
|
527
|
+
addTo(globalMaps.byConditionName, attrName, reportItem.id);
|
|
528
|
+
addTo(localMaps.byConditionName, attrName, reportItem.id);
|
|
529
|
+
reportItem.propName = current[0] ?? attrName;
|
|
530
|
+
reportItem.isKnown = isKnownUtility(reportItem);
|
|
531
|
+
reportItem.conditionName = attrName;
|
|
532
|
+
} else {
|
|
533
|
+
if (current.length && conditions.has(current[0])) {
|
|
534
|
+
reportItem.conditionName = current[0];
|
|
535
|
+
addTo(globalMaps.byConditionName, current[0], reportItem.id);
|
|
536
|
+
addTo(localMaps.byConditionName, current[0], reportItem.id);
|
|
537
|
+
}
|
|
538
|
+
const propName = ctx.utility.shorthands.get(attrName) ?? attrName;
|
|
539
|
+
reportItem.propName = propName;
|
|
540
|
+
const utility = ctx.config.utilities?.[propName];
|
|
541
|
+
reportItem.isKnown = isKnownUtility(reportItem);
|
|
542
|
+
const category = typeof utility?.values === "string" ? utility?.values : "unknown";
|
|
543
|
+
reportItem.category = category;
|
|
544
|
+
addTo(globalMaps.byPropertyName, propName, reportItem.id);
|
|
545
|
+
addTo(localMaps.byPropertyName, propName, reportItem.id);
|
|
546
|
+
addTo(globalMaps.byCategory, category, reportItem.id);
|
|
547
|
+
addTo(localMaps.byCategory, category, reportItem.id);
|
|
548
|
+
if (propName.toLowerCase().includes("color") || colorPropNames.has(propName)) {
|
|
549
|
+
addTo(globalMaps.colorsUsed, value, reportItem.id);
|
|
550
|
+
addTo(localMaps.colorsUsed, value, reportItem.id);
|
|
551
|
+
}
|
|
552
|
+
if (ctx.utility.shorthands.has(attrName)) {
|
|
553
|
+
addTo(globalMaps.byShorthand, attrName, reportItem.id);
|
|
554
|
+
addTo(localMaps.byShorthand, attrName, reportItem.id);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (current.length) {
|
|
558
|
+
addTo(globalMaps.byPropertyPath, reportItem.path.join("."), reportItem.id);
|
|
559
|
+
addTo(localMaps.byPropertyPath, reportItem.path.join("."), reportItem.id);
|
|
560
|
+
}
|
|
561
|
+
addTo(globalMaps.byTokenName, String(value), reportItem.id);
|
|
562
|
+
addTo(localMaps.byTokenName, String(value), reportItem.id);
|
|
563
|
+
addTo(globalMaps.byType, type, reportItem.id);
|
|
564
|
+
addTo(localMaps.byType, type, reportItem.id);
|
|
565
|
+
addTo(globalMaps.byInstanceName, from, reportItem.id);
|
|
566
|
+
addTo(localMaps.byInstanceName, from, reportItem.id);
|
|
567
|
+
addTo(globalMaps.fromKind, kind, reportItem.id);
|
|
568
|
+
addTo(localMaps.fromKind, kind, reportItem.id);
|
|
569
|
+
addTo(byFilepath, filepath, reportItem.id);
|
|
570
|
+
byId.set(reportItem.id, reportItem);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (attrNode.isMap() && attrNode.value.size) {
|
|
574
|
+
return processMap(attrNode, current.concat(attrName), reportInstanceItem);
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
const processResultItem = (item, kind) => {
|
|
579
|
+
if (!item.box || item.box.isUnresolvable()) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
if (!item.data) {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
const from = item.name;
|
|
586
|
+
const type = item.type;
|
|
587
|
+
const reportInstanceItem = {
|
|
588
|
+
instanceId: instanceId++,
|
|
589
|
+
from,
|
|
590
|
+
type,
|
|
591
|
+
kind,
|
|
592
|
+
filepath,
|
|
593
|
+
value: item.data,
|
|
594
|
+
box: item.box,
|
|
595
|
+
contains: []
|
|
596
|
+
};
|
|
597
|
+
if (item.box.isList()) {
|
|
598
|
+
addTo(byInstanceInFilepath, filepath, reportInstanceItem.instanceId);
|
|
599
|
+
return reportInstanceItem;
|
|
600
|
+
}
|
|
601
|
+
if (item.box.isMap() && item.box.value.size) {
|
|
602
|
+
addTo(byInstanceInFilepath, filepath, reportInstanceItem.instanceId);
|
|
603
|
+
processMap(item.box, [], reportInstanceItem);
|
|
604
|
+
return reportInstanceItem;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
const processComponentResultItem = (item) => {
|
|
608
|
+
const reportInstanceItem = processResultItem(item, "component");
|
|
609
|
+
if (!reportInstanceItem)
|
|
610
|
+
return;
|
|
611
|
+
addTo(globalMaps.byInstanceOfKind, "component", reportInstanceItem.instanceId);
|
|
612
|
+
addTo(localMaps.byInstanceOfKind, "component", reportInstanceItem.instanceId);
|
|
613
|
+
byInstanceId.set(reportInstanceItem.instanceId, reportInstanceItem);
|
|
614
|
+
};
|
|
615
|
+
const processFunctionResultItem = (item) => {
|
|
616
|
+
const reportInstanceItem = processResultItem(item, "function");
|
|
617
|
+
if (!reportInstanceItem)
|
|
618
|
+
return;
|
|
619
|
+
addTo(globalMaps.byInstanceOfKind, "function", reportInstanceItem.instanceId);
|
|
620
|
+
addTo(localMaps.byInstanceOfKind, "function", reportInstanceItem.instanceId);
|
|
621
|
+
byInstanceId.set(reportInstanceItem.instanceId, reportInstanceItem);
|
|
622
|
+
};
|
|
623
|
+
parserResult.jsx.forEach(processComponentResultItem);
|
|
624
|
+
parserResult.css.forEach(processFunctionResultItem);
|
|
625
|
+
parserResult.cva.forEach(processFunctionResultItem);
|
|
626
|
+
parserResult.pattern.forEach((itemList) => {
|
|
627
|
+
itemList.forEach(processFunctionResultItem);
|
|
628
|
+
});
|
|
629
|
+
parserResult.recipe.forEach((itemList) => {
|
|
630
|
+
itemList.forEach(processFunctionResultItem);
|
|
631
|
+
});
|
|
632
|
+
byFilePathMaps.set(filepath, localMaps);
|
|
633
|
+
});
|
|
634
|
+
const pickCount = 10;
|
|
635
|
+
const filesWithMostInstance = Object.fromEntries(
|
|
636
|
+
Array.from(byInstanceInFilepath.entries()).map(([filepath, list]) => [filepath, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
|
|
637
|
+
);
|
|
638
|
+
const filesWithMostPropValueCombinations = Object.fromEntries(
|
|
639
|
+
Array.from(byFilepath.entries()).map(([token, list]) => [token, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
|
|
640
|
+
);
|
|
641
|
+
return {
|
|
642
|
+
counts: {
|
|
643
|
+
filesWithTokens: byFilepath.size,
|
|
644
|
+
propNameUsed: globalMaps.byPropertyName.size,
|
|
645
|
+
tokenUsed: globalMaps.byTokenName.size,
|
|
646
|
+
shorthandUsed: globalMaps.byShorthand.size,
|
|
647
|
+
propertyPathUsed: globalMaps.byPropertyPath.size,
|
|
648
|
+
typeUsed: globalMaps.byType.size,
|
|
649
|
+
instanceNameUsed: globalMaps.byInstanceName.size,
|
|
650
|
+
kindUsed: globalMaps.fromKind.size,
|
|
651
|
+
instanceOfKindUsed: globalMaps.byInstanceOfKind.size,
|
|
652
|
+
colorsUsed: globalMaps.colorsUsed.size
|
|
653
|
+
},
|
|
654
|
+
stats: {
|
|
655
|
+
//
|
|
656
|
+
filesWithMostInstance,
|
|
657
|
+
filesWithMostPropValueCombinations,
|
|
658
|
+
//
|
|
659
|
+
mostUseds: getXMostUseds(globalMaps, 10)
|
|
660
|
+
},
|
|
661
|
+
details: {
|
|
662
|
+
byId,
|
|
663
|
+
byInstanceId,
|
|
664
|
+
byFilepath,
|
|
665
|
+
byInstanceInFilepath,
|
|
666
|
+
globalMaps,
|
|
667
|
+
byFilePathMaps
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
var getXMostUseds = (globalMaps, pickCount) => {
|
|
672
|
+
return {
|
|
673
|
+
propNames: getMostUsedInMap(globalMaps.byPropertyName, pickCount),
|
|
674
|
+
tokens: getMostUsedInMap(globalMaps.byTokenName, pickCount),
|
|
675
|
+
shorthands: getMostUsedInMap(globalMaps.byShorthand, pickCount),
|
|
676
|
+
conditions: getMostUsedInMap(globalMaps.byConditionName, pickCount),
|
|
677
|
+
propertyPaths: getMostUsedInMap(globalMaps.byPropertyPath, pickCount),
|
|
678
|
+
categories: getMostUsedInMap(globalMaps.byCategory, pickCount),
|
|
679
|
+
types: getMostUsedInMap(globalMaps.byType, pickCount),
|
|
680
|
+
instanceNames: getMostUsedInMap(globalMaps.byInstanceName, pickCount),
|
|
681
|
+
fromKinds: getMostUsedInMap(globalMaps.fromKind, pickCount),
|
|
682
|
+
instanceOfKinds: getMostUsedInMap(globalMaps.byInstanceOfKind, pickCount),
|
|
683
|
+
colors: getMostUsedInMap(globalMaps.colorsUsed, pickCount)
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
var getMostUsedInMap = (map, pickCount) => {
|
|
687
|
+
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 }));
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
// src/get-node-range.ts
|
|
691
|
+
init_cjs_shims();
|
|
692
|
+
var getNodeRange = (node) => {
|
|
693
|
+
const src = node.getSourceFile();
|
|
694
|
+
const [startPosition, endPosition] = [node.getStart(), node.getEnd()];
|
|
695
|
+
const startInfo = src.getLineAndColumnAtPos(startPosition);
|
|
696
|
+
const endInfo = src.getLineAndColumnAtPos(endPosition);
|
|
697
|
+
return {
|
|
698
|
+
startPosition,
|
|
699
|
+
startLineNumber: startInfo.line,
|
|
700
|
+
startColumn: startInfo.column,
|
|
701
|
+
endPosition,
|
|
702
|
+
endLineNumber: endInfo.line,
|
|
703
|
+
endColumn: endInfo.column
|
|
704
|
+
};
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
// src/analyze-tokens.ts
|
|
708
|
+
var import_gzip_size = __toESM(require("gzip-size"));
|
|
709
|
+
var import_filesize = require("filesize");
|
|
710
|
+
function analyzeTokens(ctx, options = {
|
|
711
|
+
mode: "box-extractor"
|
|
712
|
+
}) {
|
|
713
|
+
const parserResultByFilepath = /* @__PURE__ */ new Map();
|
|
714
|
+
const extractTimeByFilepath = /* @__PURE__ */ new Map();
|
|
715
|
+
ctx.getFiles().map((file) => {
|
|
716
|
+
const start2 = performance.now();
|
|
717
|
+
const result = ctx.project.parseSourceFile(file, ctx.properties, options.mode);
|
|
718
|
+
const extractMs = performance.now() - start2;
|
|
719
|
+
extractTimeByFilepath.set(file, extractMs);
|
|
720
|
+
import_logger.logger.debug("analyze", `Extracted ${file} in ${extractMs}ms`);
|
|
721
|
+
if (result) {
|
|
722
|
+
parserResultByFilepath.set(file, result);
|
|
723
|
+
options.onResult?.(file, result);
|
|
724
|
+
}
|
|
725
|
+
return [file, result];
|
|
726
|
+
}).filter(([, result]) => result);
|
|
727
|
+
const totalMs = Array.from(extractTimeByFilepath.values()).reduce((a, b) => a + b, 0);
|
|
728
|
+
import_logger.logger.debug("analyze", `Analyzed ${ctx.getFiles().length} files in ${totalMs.toFixed(2)}ms`);
|
|
729
|
+
const minify = ctx.config.minify;
|
|
730
|
+
const files = ctx.chunks.getFiles();
|
|
731
|
+
ctx.config.minify = false;
|
|
732
|
+
const css = ctx.getCss({ files });
|
|
733
|
+
ctx.config.minify = true;
|
|
734
|
+
const minifiedCss = ctx.getCss({ files });
|
|
735
|
+
ctx.config.minify = minify;
|
|
736
|
+
const start = performance.now();
|
|
737
|
+
const analysis = classifyTokens(ctx, parserResultByFilepath);
|
|
738
|
+
const classifyMs = performance.now() - start;
|
|
739
|
+
return Object.assign(
|
|
740
|
+
{
|
|
741
|
+
duration: {
|
|
742
|
+
extractTimeByFiles: Object.fromEntries(extractTimeByFilepath.entries()),
|
|
743
|
+
extractTotal: totalMs,
|
|
744
|
+
classify: classifyMs
|
|
745
|
+
},
|
|
746
|
+
fileSizes: {
|
|
747
|
+
lineCount: css.split("\n").length,
|
|
748
|
+
// rulesCount: css.split('{').length - 1, ?
|
|
749
|
+
normal: (0, import_filesize.filesize)(Buffer.byteLength(css, "utf-8")),
|
|
750
|
+
minified: (0, import_filesize.filesize)(Buffer.byteLength(minifiedCss, "utf-8")),
|
|
751
|
+
gzip: {
|
|
752
|
+
normal: (0, import_filesize.filesize)(import_gzip_size.default.sync(css)),
|
|
753
|
+
minified: (0, import_filesize.filesize)(import_gzip_size.default.sync(minifiedCss))
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
analysis
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
var analyzeResultSerializer = (_key, value) => {
|
|
761
|
+
if (value instanceof Set) {
|
|
762
|
+
return Array.from(value);
|
|
763
|
+
}
|
|
764
|
+
if (value instanceof Map) {
|
|
765
|
+
return Object.fromEntries(value);
|
|
766
|
+
}
|
|
767
|
+
if (import_ts_morph.Node.isNode(value)) {
|
|
768
|
+
return { kind: value.getKindName(), range: getNodeRange(value) };
|
|
769
|
+
}
|
|
770
|
+
return value;
|
|
771
|
+
};
|
|
772
|
+
var writeAnalyzeJSON = (fileName, result, ctx) => {
|
|
773
|
+
result.details.byInstanceId.forEach((item) => {
|
|
774
|
+
item.box = { type: item.box.type, node: item.box.getNode(), stack: item.box.getStack() };
|
|
775
|
+
});
|
|
776
|
+
return (0, import_promises.writeFile)(
|
|
777
|
+
fileName,
|
|
778
|
+
JSON.stringify(
|
|
779
|
+
Object.assign(result, {
|
|
780
|
+
cwd: ctx.config.cwd,
|
|
781
|
+
theme: ctx.config.theme,
|
|
782
|
+
utilities: ctx.config.utilities,
|
|
783
|
+
conditions: ctx.config.conditions,
|
|
784
|
+
shorthands: ctx.utility.shorthands,
|
|
785
|
+
parserOptions: ctx.parserOptions
|
|
786
|
+
}),
|
|
787
|
+
analyzeResultSerializer,
|
|
788
|
+
2
|
|
789
|
+
)
|
|
790
|
+
);
|
|
791
|
+
};
|
|
792
|
+
|
|
421
793
|
// src/builder.ts
|
|
422
794
|
init_cjs_shims();
|
|
423
795
|
var import_core2 = require("@pandacss/core");
|
|
424
796
|
var import_error = require("@pandacss/error");
|
|
425
|
-
var
|
|
797
|
+
var import_logger4 = require("@pandacss/logger");
|
|
426
798
|
var import_shared = require("@pandacss/shared");
|
|
427
799
|
var import_fs = require("fs");
|
|
428
800
|
var import_fs_extra2 = require("fs-extra");
|
|
@@ -476,7 +848,7 @@ var getChunkEngine = ({ paths, config, runtime: { path, fs } }) => ({
|
|
|
476
848
|
|
|
477
849
|
// src/node-runtime.ts
|
|
478
850
|
init_cjs_shims();
|
|
479
|
-
var
|
|
851
|
+
var import_logger2 = require("@pandacss/logger");
|
|
480
852
|
var import_chokidar = __toESM(require("chokidar"));
|
|
481
853
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
482
854
|
var import_fs_extra = require("fs-extra");
|
|
@@ -528,7 +900,7 @@ var nodeRuntime = {
|
|
|
528
900
|
ignored: exclude,
|
|
529
901
|
awaitWriteFinish: coalesce ? { stabilityThreshold: 50, pollInterval: 10 } : false
|
|
530
902
|
});
|
|
531
|
-
|
|
903
|
+
import_logger2.logger.debug("watch:file", `watching [${include}]`);
|
|
532
904
|
process.once("SIGINT", async () => {
|
|
533
905
|
await watcher.close();
|
|
534
906
|
});
|
|
@@ -538,10 +910,10 @@ var nodeRuntime = {
|
|
|
538
910
|
};
|
|
539
911
|
process.setMaxListeners(Infinity);
|
|
540
912
|
process.on("unhandledRejection", (reason) => {
|
|
541
|
-
|
|
913
|
+
import_logger2.logger.error("unhandled-rejection", reason);
|
|
542
914
|
});
|
|
543
915
|
process.on("uncaughtException", (reason) => {
|
|
544
|
-
|
|
916
|
+
import_logger2.logger.error("uncaught-exception", reason);
|
|
545
917
|
});
|
|
546
918
|
|
|
547
919
|
// src/output-engine.ts
|
|
@@ -605,12 +977,15 @@ async function loadConfigAndCreateContext(options = {}) {
|
|
|
605
977
|
if (config) {
|
|
606
978
|
Object.assign(conf.config, config);
|
|
607
979
|
}
|
|
980
|
+
if (options.cwd) {
|
|
981
|
+
conf.config.cwd = options.cwd;
|
|
982
|
+
}
|
|
608
983
|
return createContext(conf);
|
|
609
984
|
}
|
|
610
985
|
|
|
611
986
|
// src/extract.ts
|
|
612
987
|
init_cjs_shims();
|
|
613
|
-
var
|
|
988
|
+
var import_logger3 = require("@pandacss/logger");
|
|
614
989
|
var import_lil_fp2 = require("lil-fp");
|
|
615
990
|
|
|
616
991
|
// src/cli-box.ts
|
|
@@ -1895,7 +2270,7 @@ async function bundleChunks(ctx) {
|
|
|
1895
2270
|
}
|
|
1896
2271
|
async function writeFileChunk(ctx, file) {
|
|
1897
2272
|
const { path } = ctx.runtime;
|
|
1898
|
-
|
|
2273
|
+
import_logger3.logger.debug("chunk:write", `File: ${path.relative(ctx.config.cwd, file)}`);
|
|
1899
2274
|
const css = extractFile(ctx, file);
|
|
1900
2275
|
if (!css)
|
|
1901
2276
|
return;
|
|
@@ -1909,17 +2284,18 @@ function extractFile(ctx, file) {
|
|
|
1909
2284
|
} = ctx;
|
|
1910
2285
|
return (0, import_lil_fp2.pipe)(
|
|
1911
2286
|
{ file: path.abs(cwd, file) },
|
|
1912
|
-
(0, import_lil_fp2.tap)(() =>
|
|
1913
|
-
import_lil_fp2.Obj.bind("measure", () =>
|
|
2287
|
+
(0, import_lil_fp2.tap)(() => import_logger3.logger.debug("file:extract", file)),
|
|
2288
|
+
import_lil_fp2.Obj.bind("measure", () => import_logger3.logger.time.debug(`Extracted ${file}`)),
|
|
1914
2289
|
import_lil_fp2.Obj.bind(
|
|
1915
2290
|
"result",
|
|
1916
2291
|
(0, import_lil_fp2.tryCatch)(
|
|
1917
|
-
({ file: file2 }) => ctx.project.parseSourceFile(file2),
|
|
1918
|
-
(error) =>
|
|
2292
|
+
({ file: file2 }) => ctx.project.parseSourceFile(file2, ctx.properties),
|
|
2293
|
+
(error) => import_logger3.logger.error("file:parse", error)
|
|
1919
2294
|
)
|
|
1920
2295
|
),
|
|
2296
|
+
import_lil_fp2.Obj.bind("measureCss", () => import_logger3.logger.time.debug(`Parsed ${file}`)),
|
|
1921
2297
|
import_lil_fp2.Obj.bind("css", ({ result }) => result ? ctx.getParserCss(result) : void 0),
|
|
1922
|
-
(0, import_lil_fp2.tap)(({ measure }) => measure()),
|
|
2298
|
+
(0, import_lil_fp2.tap)(({ measure, measureCss }) => [measureCss(), measure()]),
|
|
1923
2299
|
import_lil_fp2.Obj.get("css")
|
|
1924
2300
|
);
|
|
1925
2301
|
}
|
|
@@ -2045,7 +2421,7 @@ var Builder = class {
|
|
|
2045
2421
|
}
|
|
2046
2422
|
async extract() {
|
|
2047
2423
|
const ctx = this.ensure();
|
|
2048
|
-
const done =
|
|
2424
|
+
const done = import_logger4.logger.time.info("Extracted in");
|
|
2049
2425
|
await Promise.all(
|
|
2050
2426
|
ctx.getFiles().map(async (file) => {
|
|
2051
2427
|
const mtime = (0, import_fs.existsSync)(file) ? (0, import_fs_extra2.statSync)(file).mtimeMs : -Infinity;
|
|
@@ -2106,7 +2482,7 @@ var Builder = class {
|
|
|
2106
2482
|
|
|
2107
2483
|
// src/exec-command.ts
|
|
2108
2484
|
init_cjs_shims();
|
|
2109
|
-
var
|
|
2485
|
+
var import_logger5 = require("@pandacss/logger");
|
|
2110
2486
|
var import_child_process = require("child_process");
|
|
2111
2487
|
var import_preferred_pm = __toESM(require("preferred-pm"));
|
|
2112
2488
|
async function execCommand(cmd, cwd) {
|
|
@@ -2118,13 +2494,13 @@ async function execCommand(cmd, cwd) {
|
|
|
2118
2494
|
}
|
|
2119
2495
|
const check = (0, import_child_process.spawnSync)(pm, args, { cwd, stdio: "pipe" });
|
|
2120
2496
|
if (check.status !== 0) {
|
|
2121
|
-
|
|
2497
|
+
import_logger5.logger.error("exec", check.stderr.toString());
|
|
2122
2498
|
}
|
|
2123
2499
|
}
|
|
2124
2500
|
|
|
2125
2501
|
// src/generate.ts
|
|
2126
2502
|
init_cjs_shims();
|
|
2127
|
-
var
|
|
2503
|
+
var import_logger6 = require("@pandacss/logger");
|
|
2128
2504
|
var import_ts_pattern = require("ts-pattern");
|
|
2129
2505
|
|
|
2130
2506
|
// src/load-context.ts
|
|
@@ -2142,7 +2518,7 @@ var loadContext = async (config, configPath) => {
|
|
|
2142
2518
|
// src/generate.ts
|
|
2143
2519
|
async function build(ctx) {
|
|
2144
2520
|
const msg = await emitAndExtract(ctx);
|
|
2145
|
-
|
|
2521
|
+
import_logger6.logger.info("css:emit", msg);
|
|
2146
2522
|
}
|
|
2147
2523
|
async function generate(config, configPath) {
|
|
2148
2524
|
const [ctxRef, loadCtx] = await loadContext(config, configPath);
|
|
@@ -2156,13 +2532,13 @@ async function generate(config, configPath) {
|
|
|
2156
2532
|
if (ctx.config.watch) {
|
|
2157
2533
|
const configWatcher = fs.watch({ include: dependencies });
|
|
2158
2534
|
configWatcher.on("change", async () => {
|
|
2159
|
-
|
|
2535
|
+
import_logger6.logger.info("config:change", "Config changed, restarting...");
|
|
2160
2536
|
await loadCtx();
|
|
2161
2537
|
return build(ctxRef.current);
|
|
2162
2538
|
});
|
|
2163
2539
|
const contentWatcher = fs.watch(ctx.config);
|
|
2164
2540
|
contentWatcher.on("all", async (event, file) => {
|
|
2165
|
-
|
|
2541
|
+
import_logger6.logger.info(`file:${event}`, file);
|
|
2166
2542
|
(0, import_ts_pattern.match)(event).with("unlink", () => {
|
|
2167
2543
|
ctx.project.removeSourceFile(path.abs(cwd, file));
|
|
2168
2544
|
ctx.chunks.rm(file);
|
|
@@ -2176,7 +2552,7 @@ async function generate(config, configPath) {
|
|
|
2176
2552
|
}).otherwise(() => {
|
|
2177
2553
|
});
|
|
2178
2554
|
});
|
|
2179
|
-
|
|
2555
|
+
import_logger6.logger.info("ctx:watch", ctx.messages.watch());
|
|
2180
2556
|
}
|
|
2181
2557
|
}
|
|
2182
2558
|
|
|
@@ -2202,7 +2578,7 @@ function setupGitIgnore({ config: { outdir } }) {
|
|
|
2202
2578
|
|
|
2203
2579
|
// src/setup-config.ts
|
|
2204
2580
|
init_cjs_shims();
|
|
2205
|
-
var
|
|
2581
|
+
var import_logger7 = require("@pandacss/logger");
|
|
2206
2582
|
var import_generator2 = require("@pandacss/generator");
|
|
2207
2583
|
var import_fs_extra3 = require("fs-extra");
|
|
2208
2584
|
var import_look_it_up3 = require("look-it-up");
|
|
@@ -2216,9 +2592,9 @@ async function setupConfig(cwd, { force }) {
|
|
|
2216
2592
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
2217
2593
|
const isTs = (0, import_look_it_up3.lookItUpSync)("tsconfig.json", cwd);
|
|
2218
2594
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
2219
|
-
|
|
2595
|
+
import_logger7.logger.info("init:config", `creating panda config file: ${(0, import_logger7.quote)(file)}`);
|
|
2220
2596
|
if (!force && configFile) {
|
|
2221
|
-
|
|
2597
|
+
import_logger7.logger.warn("init:config", import_generator2.messages.configExists(cmd));
|
|
2222
2598
|
} else {
|
|
2223
2599
|
const content = import_outdent2.outdent`
|
|
2224
2600
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -2238,11 +2614,11 @@ async function setupConfig(cwd, { force }) {
|
|
|
2238
2614
|
})
|
|
2239
2615
|
`;
|
|
2240
2616
|
await (0, import_fs_extra3.writeFile)((0, import_path4.join)(cwd, file), content);
|
|
2241
|
-
|
|
2617
|
+
import_logger7.logger.log(import_generator2.messages.thankYou());
|
|
2242
2618
|
}
|
|
2243
2619
|
}
|
|
2244
2620
|
async function setupPostcss(cwd) {
|
|
2245
|
-
|
|
2621
|
+
import_logger7.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger7.quote)("postcss.config.cjs")}`);
|
|
2246
2622
|
const content = import_outdent2.outdent`
|
|
2247
2623
|
module.exports = {
|
|
2248
2624
|
plugins: {
|
|
@@ -2255,6 +2631,7 @@ async function setupPostcss(cwd) {
|
|
|
2255
2631
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2256
2632
|
0 && (module.exports = {
|
|
2257
2633
|
Builder,
|
|
2634
|
+
analyzeTokens,
|
|
2258
2635
|
createContext,
|
|
2259
2636
|
discardDuplicate,
|
|
2260
2637
|
emitAndExtract,
|
|
@@ -2265,5 +2642,6 @@ async function setupPostcss(cwd) {
|
|
|
2265
2642
|
loadConfigAndCreateContext,
|
|
2266
2643
|
setupConfig,
|
|
2267
2644
|
setupGitIgnore,
|
|
2268
|
-
setupPostcss
|
|
2645
|
+
setupPostcss,
|
|
2646
|
+
writeAnalyzeJSON
|
|
2269
2647
|
});
|