@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.mjs
CHANGED
|
@@ -396,11 +396,381 @@ var require_ansi_align = __commonJS({
|
|
|
396
396
|
init_esm_shims();
|
|
397
397
|
import { discardDuplicate as discardDuplicate2 } from "@pandacss/core";
|
|
398
398
|
|
|
399
|
+
// src/analyze-tokens.ts
|
|
400
|
+
init_esm_shims();
|
|
401
|
+
import { logger } from "@pandacss/logger";
|
|
402
|
+
import { writeFile } from "fs/promises";
|
|
403
|
+
import { Node } from "ts-morph";
|
|
404
|
+
|
|
405
|
+
// src/classify.ts
|
|
406
|
+
init_esm_shims();
|
|
407
|
+
var createReportMaps = () => {
|
|
408
|
+
const byInstanceOfKind = /* @__PURE__ */ new Map();
|
|
409
|
+
const byPropertyName = /* @__PURE__ */ new Map();
|
|
410
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
411
|
+
const byConditionName = /* @__PURE__ */ new Map();
|
|
412
|
+
const byShorthand = /* @__PURE__ */ new Map();
|
|
413
|
+
const byTokenName = /* @__PURE__ */ new Map();
|
|
414
|
+
const byPropertyPath = /* @__PURE__ */ new Map();
|
|
415
|
+
const fromKind = /* @__PURE__ */ new Map();
|
|
416
|
+
const byType = /* @__PURE__ */ new Map();
|
|
417
|
+
const byInstanceName = /* @__PURE__ */ new Map();
|
|
418
|
+
const colorsUsed = /* @__PURE__ */ new Map();
|
|
419
|
+
return {
|
|
420
|
+
byInstanceOfKind,
|
|
421
|
+
byPropertyName,
|
|
422
|
+
byCategory,
|
|
423
|
+
byConditionName,
|
|
424
|
+
byShorthand,
|
|
425
|
+
byTokenName,
|
|
426
|
+
byPropertyPath,
|
|
427
|
+
fromKind,
|
|
428
|
+
byType,
|
|
429
|
+
byInstanceName,
|
|
430
|
+
colorsUsed
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
var colorPropNames = /* @__PURE__ */ new Set(["background", "outline", "border"]);
|
|
434
|
+
var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
435
|
+
const byId = /* @__PURE__ */ new Map();
|
|
436
|
+
const byInstanceId = /* @__PURE__ */ new Map();
|
|
437
|
+
const byFilepath = /* @__PURE__ */ new Map();
|
|
438
|
+
const byInstanceInFilepath = /* @__PURE__ */ new Map();
|
|
439
|
+
const globalMaps = createReportMaps();
|
|
440
|
+
const byFilePathMaps = /* @__PURE__ */ new Map();
|
|
441
|
+
const conditions = new Map(Object.entries(ctx.conditions.values));
|
|
442
|
+
let id = 0, instanceId = 0;
|
|
443
|
+
const isKnownUtility = (reportItem) => {
|
|
444
|
+
const { propName, type, value, from } = reportItem;
|
|
445
|
+
const utility = ctx.config.utilities?.[propName];
|
|
446
|
+
if (utility) {
|
|
447
|
+
if (!utility.shorthand) {
|
|
448
|
+
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
449
|
+
}
|
|
450
|
+
return Boolean(ctx.tokens.getByName(`${utility.values}.${value}`));
|
|
451
|
+
}
|
|
452
|
+
if (type === "pattern") {
|
|
453
|
+
const pattern = ctx.patterns.getConfig(from.toLowerCase());
|
|
454
|
+
const patternProp = pattern.properties[propName];
|
|
455
|
+
if (!patternProp)
|
|
456
|
+
return false;
|
|
457
|
+
if (patternProp.type === "boolean" || patternProp.type === "number") {
|
|
458
|
+
return true;
|
|
459
|
+
}
|
|
460
|
+
if (patternProp.type === "property") {
|
|
461
|
+
return Boolean(ctx.config.utilities?.[patternProp.value]);
|
|
462
|
+
}
|
|
463
|
+
if (patternProp.type === "enum") {
|
|
464
|
+
return Boolean(patternProp.value.includes(String(value)));
|
|
465
|
+
}
|
|
466
|
+
if (patternProp.type === "token") {
|
|
467
|
+
return Boolean(ctx.tokens.getByName(`${patternProp.value}.${value}`));
|
|
468
|
+
}
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
return false;
|
|
472
|
+
};
|
|
473
|
+
parserResultByFilepath.forEach((parserResult, filepath) => {
|
|
474
|
+
if (parserResult.isEmpty())
|
|
475
|
+
return;
|
|
476
|
+
const localMaps = createReportMaps();
|
|
477
|
+
const addTo = (map, key, value) => {
|
|
478
|
+
const set = map.get(key) ?? /* @__PURE__ */ new Set();
|
|
479
|
+
set.add(value);
|
|
480
|
+
map.set(key, set);
|
|
481
|
+
};
|
|
482
|
+
const processMap = (map, current, reportInstanceItem) => {
|
|
483
|
+
const { from, type, kind } = reportInstanceItem;
|
|
484
|
+
map.value.forEach((attrNode, attrName) => {
|
|
485
|
+
if (attrNode.isLiteral() || attrNode.isEmptyInitializer()) {
|
|
486
|
+
const value = attrNode.isLiteral() ? attrNode.value : true;
|
|
487
|
+
const reportItem = {
|
|
488
|
+
id: id++,
|
|
489
|
+
instanceId,
|
|
490
|
+
category: "unknown",
|
|
491
|
+
propName: attrName,
|
|
492
|
+
from,
|
|
493
|
+
type,
|
|
494
|
+
kind,
|
|
495
|
+
filepath,
|
|
496
|
+
path: current.concat(attrName),
|
|
497
|
+
value,
|
|
498
|
+
box: attrNode,
|
|
499
|
+
isKnown: false
|
|
500
|
+
};
|
|
501
|
+
reportInstanceItem.contains.push(reportItem.id);
|
|
502
|
+
if (conditions.has(attrName)) {
|
|
503
|
+
addTo(globalMaps.byConditionName, attrName, reportItem.id);
|
|
504
|
+
addTo(localMaps.byConditionName, attrName, reportItem.id);
|
|
505
|
+
reportItem.propName = current[0] ?? attrName;
|
|
506
|
+
reportItem.isKnown = isKnownUtility(reportItem);
|
|
507
|
+
reportItem.conditionName = attrName;
|
|
508
|
+
} else {
|
|
509
|
+
if (current.length && conditions.has(current[0])) {
|
|
510
|
+
reportItem.conditionName = current[0];
|
|
511
|
+
addTo(globalMaps.byConditionName, current[0], reportItem.id);
|
|
512
|
+
addTo(localMaps.byConditionName, current[0], reportItem.id);
|
|
513
|
+
}
|
|
514
|
+
const propName = ctx.utility.shorthands.get(attrName) ?? attrName;
|
|
515
|
+
reportItem.propName = propName;
|
|
516
|
+
const utility = ctx.config.utilities?.[propName];
|
|
517
|
+
reportItem.isKnown = isKnownUtility(reportItem);
|
|
518
|
+
const category = typeof utility?.values === "string" ? utility?.values : "unknown";
|
|
519
|
+
reportItem.category = category;
|
|
520
|
+
addTo(globalMaps.byPropertyName, propName, reportItem.id);
|
|
521
|
+
addTo(localMaps.byPropertyName, propName, reportItem.id);
|
|
522
|
+
addTo(globalMaps.byCategory, category, reportItem.id);
|
|
523
|
+
addTo(localMaps.byCategory, category, reportItem.id);
|
|
524
|
+
if (propName.toLowerCase().includes("color") || colorPropNames.has(propName)) {
|
|
525
|
+
addTo(globalMaps.colorsUsed, value, reportItem.id);
|
|
526
|
+
addTo(localMaps.colorsUsed, value, reportItem.id);
|
|
527
|
+
}
|
|
528
|
+
if (ctx.utility.shorthands.has(attrName)) {
|
|
529
|
+
addTo(globalMaps.byShorthand, attrName, reportItem.id);
|
|
530
|
+
addTo(localMaps.byShorthand, attrName, reportItem.id);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (current.length) {
|
|
534
|
+
addTo(globalMaps.byPropertyPath, reportItem.path.join("."), reportItem.id);
|
|
535
|
+
addTo(localMaps.byPropertyPath, reportItem.path.join("."), reportItem.id);
|
|
536
|
+
}
|
|
537
|
+
addTo(globalMaps.byTokenName, String(value), reportItem.id);
|
|
538
|
+
addTo(localMaps.byTokenName, String(value), reportItem.id);
|
|
539
|
+
addTo(globalMaps.byType, type, reportItem.id);
|
|
540
|
+
addTo(localMaps.byType, type, reportItem.id);
|
|
541
|
+
addTo(globalMaps.byInstanceName, from, reportItem.id);
|
|
542
|
+
addTo(localMaps.byInstanceName, from, reportItem.id);
|
|
543
|
+
addTo(globalMaps.fromKind, kind, reportItem.id);
|
|
544
|
+
addTo(localMaps.fromKind, kind, reportItem.id);
|
|
545
|
+
addTo(byFilepath, filepath, reportItem.id);
|
|
546
|
+
byId.set(reportItem.id, reportItem);
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
if (attrNode.isMap() && attrNode.value.size) {
|
|
550
|
+
return processMap(attrNode, current.concat(attrName), reportInstanceItem);
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
};
|
|
554
|
+
const processResultItem = (item, kind) => {
|
|
555
|
+
if (!item.box || item.box.isUnresolvable()) {
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
if (!item.data) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
const from = item.name;
|
|
562
|
+
const type = item.type;
|
|
563
|
+
const reportInstanceItem = {
|
|
564
|
+
instanceId: instanceId++,
|
|
565
|
+
from,
|
|
566
|
+
type,
|
|
567
|
+
kind,
|
|
568
|
+
filepath,
|
|
569
|
+
value: item.data,
|
|
570
|
+
box: item.box,
|
|
571
|
+
contains: []
|
|
572
|
+
};
|
|
573
|
+
if (item.box.isList()) {
|
|
574
|
+
addTo(byInstanceInFilepath, filepath, reportInstanceItem.instanceId);
|
|
575
|
+
return reportInstanceItem;
|
|
576
|
+
}
|
|
577
|
+
if (item.box.isMap() && item.box.value.size) {
|
|
578
|
+
addTo(byInstanceInFilepath, filepath, reportInstanceItem.instanceId);
|
|
579
|
+
processMap(item.box, [], reportInstanceItem);
|
|
580
|
+
return reportInstanceItem;
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
const processComponentResultItem = (item) => {
|
|
584
|
+
const reportInstanceItem = processResultItem(item, "component");
|
|
585
|
+
if (!reportInstanceItem)
|
|
586
|
+
return;
|
|
587
|
+
addTo(globalMaps.byInstanceOfKind, "component", reportInstanceItem.instanceId);
|
|
588
|
+
addTo(localMaps.byInstanceOfKind, "component", reportInstanceItem.instanceId);
|
|
589
|
+
byInstanceId.set(reportInstanceItem.instanceId, reportInstanceItem);
|
|
590
|
+
};
|
|
591
|
+
const processFunctionResultItem = (item) => {
|
|
592
|
+
const reportInstanceItem = processResultItem(item, "function");
|
|
593
|
+
if (!reportInstanceItem)
|
|
594
|
+
return;
|
|
595
|
+
addTo(globalMaps.byInstanceOfKind, "function", reportInstanceItem.instanceId);
|
|
596
|
+
addTo(localMaps.byInstanceOfKind, "function", reportInstanceItem.instanceId);
|
|
597
|
+
byInstanceId.set(reportInstanceItem.instanceId, reportInstanceItem);
|
|
598
|
+
};
|
|
599
|
+
parserResult.jsx.forEach(processComponentResultItem);
|
|
600
|
+
parserResult.css.forEach(processFunctionResultItem);
|
|
601
|
+
parserResult.cva.forEach(processFunctionResultItem);
|
|
602
|
+
parserResult.pattern.forEach((itemList) => {
|
|
603
|
+
itemList.forEach(processFunctionResultItem);
|
|
604
|
+
});
|
|
605
|
+
parserResult.recipe.forEach((itemList) => {
|
|
606
|
+
itemList.forEach(processFunctionResultItem);
|
|
607
|
+
});
|
|
608
|
+
byFilePathMaps.set(filepath, localMaps);
|
|
609
|
+
});
|
|
610
|
+
const pickCount = 10;
|
|
611
|
+
const filesWithMostInstance = Object.fromEntries(
|
|
612
|
+
Array.from(byInstanceInFilepath.entries()).map(([filepath, list]) => [filepath, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
|
|
613
|
+
);
|
|
614
|
+
const filesWithMostPropValueCombinations = Object.fromEntries(
|
|
615
|
+
Array.from(byFilepath.entries()).map(([token, list]) => [token, list.size]).sort((a, b) => b[1] - a[1]).slice(0, pickCount)
|
|
616
|
+
);
|
|
617
|
+
return {
|
|
618
|
+
counts: {
|
|
619
|
+
filesWithTokens: byFilepath.size,
|
|
620
|
+
propNameUsed: globalMaps.byPropertyName.size,
|
|
621
|
+
tokenUsed: globalMaps.byTokenName.size,
|
|
622
|
+
shorthandUsed: globalMaps.byShorthand.size,
|
|
623
|
+
propertyPathUsed: globalMaps.byPropertyPath.size,
|
|
624
|
+
typeUsed: globalMaps.byType.size,
|
|
625
|
+
instanceNameUsed: globalMaps.byInstanceName.size,
|
|
626
|
+
kindUsed: globalMaps.fromKind.size,
|
|
627
|
+
instanceOfKindUsed: globalMaps.byInstanceOfKind.size,
|
|
628
|
+
colorsUsed: globalMaps.colorsUsed.size
|
|
629
|
+
},
|
|
630
|
+
stats: {
|
|
631
|
+
//
|
|
632
|
+
filesWithMostInstance,
|
|
633
|
+
filesWithMostPropValueCombinations,
|
|
634
|
+
//
|
|
635
|
+
mostUseds: getXMostUseds(globalMaps, 10)
|
|
636
|
+
},
|
|
637
|
+
details: {
|
|
638
|
+
byId,
|
|
639
|
+
byInstanceId,
|
|
640
|
+
byFilepath,
|
|
641
|
+
byInstanceInFilepath,
|
|
642
|
+
globalMaps,
|
|
643
|
+
byFilePathMaps
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
};
|
|
647
|
+
var getXMostUseds = (globalMaps, pickCount) => {
|
|
648
|
+
return {
|
|
649
|
+
propNames: getMostUsedInMap(globalMaps.byPropertyName, pickCount),
|
|
650
|
+
tokens: getMostUsedInMap(globalMaps.byTokenName, pickCount),
|
|
651
|
+
shorthands: getMostUsedInMap(globalMaps.byShorthand, pickCount),
|
|
652
|
+
conditions: getMostUsedInMap(globalMaps.byConditionName, pickCount),
|
|
653
|
+
propertyPaths: getMostUsedInMap(globalMaps.byPropertyPath, pickCount),
|
|
654
|
+
categories: getMostUsedInMap(globalMaps.byCategory, pickCount),
|
|
655
|
+
types: getMostUsedInMap(globalMaps.byType, pickCount),
|
|
656
|
+
instanceNames: getMostUsedInMap(globalMaps.byInstanceName, pickCount),
|
|
657
|
+
fromKinds: getMostUsedInMap(globalMaps.fromKind, pickCount),
|
|
658
|
+
instanceOfKinds: getMostUsedInMap(globalMaps.byInstanceOfKind, pickCount),
|
|
659
|
+
colors: getMostUsedInMap(globalMaps.colorsUsed, pickCount)
|
|
660
|
+
};
|
|
661
|
+
};
|
|
662
|
+
var getMostUsedInMap = (map, pickCount) => {
|
|
663
|
+
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 }));
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
// src/get-node-range.ts
|
|
667
|
+
init_esm_shims();
|
|
668
|
+
var getNodeRange = (node) => {
|
|
669
|
+
const src = node.getSourceFile();
|
|
670
|
+
const [startPosition, endPosition] = [node.getStart(), node.getEnd()];
|
|
671
|
+
const startInfo = src.getLineAndColumnAtPos(startPosition);
|
|
672
|
+
const endInfo = src.getLineAndColumnAtPos(endPosition);
|
|
673
|
+
return {
|
|
674
|
+
startPosition,
|
|
675
|
+
startLineNumber: startInfo.line,
|
|
676
|
+
startColumn: startInfo.column,
|
|
677
|
+
endPosition,
|
|
678
|
+
endLineNumber: endInfo.line,
|
|
679
|
+
endColumn: endInfo.column
|
|
680
|
+
};
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// src/analyze-tokens.ts
|
|
684
|
+
import gzipSize from "gzip-size";
|
|
685
|
+
import { filesize } from "filesize";
|
|
686
|
+
function analyzeTokens(ctx, options = {
|
|
687
|
+
mode: "box-extractor"
|
|
688
|
+
}) {
|
|
689
|
+
const parserResultByFilepath = /* @__PURE__ */ new Map();
|
|
690
|
+
const extractTimeByFilepath = /* @__PURE__ */ new Map();
|
|
691
|
+
ctx.getFiles().map((file) => {
|
|
692
|
+
const start2 = performance.now();
|
|
693
|
+
const result = ctx.project.parseSourceFile(file, ctx.properties, options.mode);
|
|
694
|
+
const extractMs = performance.now() - start2;
|
|
695
|
+
extractTimeByFilepath.set(file, extractMs);
|
|
696
|
+
logger.debug("analyze", `Extracted ${file} in ${extractMs}ms`);
|
|
697
|
+
if (result) {
|
|
698
|
+
parserResultByFilepath.set(file, result);
|
|
699
|
+
options.onResult?.(file, result);
|
|
700
|
+
}
|
|
701
|
+
return [file, result];
|
|
702
|
+
}).filter(([, result]) => result);
|
|
703
|
+
const totalMs = Array.from(extractTimeByFilepath.values()).reduce((a, b) => a + b, 0);
|
|
704
|
+
logger.debug("analyze", `Analyzed ${ctx.getFiles().length} files in ${totalMs.toFixed(2)}ms`);
|
|
705
|
+
const minify = ctx.config.minify;
|
|
706
|
+
const files = ctx.chunks.getFiles();
|
|
707
|
+
ctx.config.minify = false;
|
|
708
|
+
const css = ctx.getCss({ files });
|
|
709
|
+
ctx.config.minify = true;
|
|
710
|
+
const minifiedCss = ctx.getCss({ files });
|
|
711
|
+
ctx.config.minify = minify;
|
|
712
|
+
const start = performance.now();
|
|
713
|
+
const analysis = classifyTokens(ctx, parserResultByFilepath);
|
|
714
|
+
const classifyMs = performance.now() - start;
|
|
715
|
+
return Object.assign(
|
|
716
|
+
{
|
|
717
|
+
duration: {
|
|
718
|
+
extractTimeByFiles: Object.fromEntries(extractTimeByFilepath.entries()),
|
|
719
|
+
extractTotal: totalMs,
|
|
720
|
+
classify: classifyMs
|
|
721
|
+
},
|
|
722
|
+
fileSizes: {
|
|
723
|
+
lineCount: css.split("\n").length,
|
|
724
|
+
// rulesCount: css.split('{').length - 1, ?
|
|
725
|
+
normal: filesize(Buffer.byteLength(css, "utf-8")),
|
|
726
|
+
minified: filesize(Buffer.byteLength(minifiedCss, "utf-8")),
|
|
727
|
+
gzip: {
|
|
728
|
+
normal: filesize(gzipSize.sync(css)),
|
|
729
|
+
minified: filesize(gzipSize.sync(minifiedCss))
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
analysis
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
var analyzeResultSerializer = (_key, value) => {
|
|
737
|
+
if (value instanceof Set) {
|
|
738
|
+
return Array.from(value);
|
|
739
|
+
}
|
|
740
|
+
if (value instanceof Map) {
|
|
741
|
+
return Object.fromEntries(value);
|
|
742
|
+
}
|
|
743
|
+
if (Node.isNode(value)) {
|
|
744
|
+
return { kind: value.getKindName(), range: getNodeRange(value) };
|
|
745
|
+
}
|
|
746
|
+
return value;
|
|
747
|
+
};
|
|
748
|
+
var writeAnalyzeJSON = (fileName, result, ctx) => {
|
|
749
|
+
result.details.byInstanceId.forEach((item) => {
|
|
750
|
+
item.box = { type: item.box.type, node: item.box.getNode(), stack: item.box.getStack() };
|
|
751
|
+
});
|
|
752
|
+
return writeFile(
|
|
753
|
+
fileName,
|
|
754
|
+
JSON.stringify(
|
|
755
|
+
Object.assign(result, {
|
|
756
|
+
cwd: ctx.config.cwd,
|
|
757
|
+
theme: ctx.config.theme,
|
|
758
|
+
utilities: ctx.config.utilities,
|
|
759
|
+
conditions: ctx.config.conditions,
|
|
760
|
+
shorthands: ctx.utility.shorthands,
|
|
761
|
+
parserOptions: ctx.parserOptions
|
|
762
|
+
}),
|
|
763
|
+
analyzeResultSerializer,
|
|
764
|
+
2
|
|
765
|
+
)
|
|
766
|
+
);
|
|
767
|
+
};
|
|
768
|
+
|
|
399
769
|
// src/builder.ts
|
|
400
770
|
init_esm_shims();
|
|
401
771
|
import { discardDuplicate, mergeCss as mergeCss2 } from "@pandacss/core";
|
|
402
772
|
import { ConfigNotFoundError } from "@pandacss/error";
|
|
403
|
-
import { logger as
|
|
773
|
+
import { logger as logger4 } from "@pandacss/logger";
|
|
404
774
|
import { toHash } from "@pandacss/shared";
|
|
405
775
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
406
776
|
import { statSync } from "fs-extra";
|
|
@@ -454,7 +824,7 @@ var getChunkEngine = ({ paths, config, runtime: { path, fs } }) => ({
|
|
|
454
824
|
|
|
455
825
|
// src/node-runtime.ts
|
|
456
826
|
init_esm_shims();
|
|
457
|
-
import { logger } from "@pandacss/logger";
|
|
827
|
+
import { logger as logger2 } from "@pandacss/logger";
|
|
458
828
|
import chokidar from "chokidar";
|
|
459
829
|
import glob from "fast-glob";
|
|
460
830
|
import {
|
|
@@ -464,7 +834,7 @@ import {
|
|
|
464
834
|
readdirSync,
|
|
465
835
|
readFileSync,
|
|
466
836
|
removeSync,
|
|
467
|
-
writeFile,
|
|
837
|
+
writeFile as writeFile2,
|
|
468
838
|
writeFileSync
|
|
469
839
|
} from "fs-extra";
|
|
470
840
|
import { dirname, extname, isAbsolute, join, relative, sep } from "path";
|
|
@@ -496,7 +866,7 @@ var nodeRuntime = {
|
|
|
496
866
|
return [];
|
|
497
867
|
return glob.sync(opts.include, { cwd: opts.cwd, ignore: opts.exclude, absolute: true });
|
|
498
868
|
},
|
|
499
|
-
writeFile,
|
|
869
|
+
writeFile: writeFile2,
|
|
500
870
|
writeFileSync,
|
|
501
871
|
readDirSync: readdirSync,
|
|
502
872
|
rmDirSync: emptyDirSync,
|
|
@@ -515,7 +885,7 @@ var nodeRuntime = {
|
|
|
515
885
|
ignored: exclude,
|
|
516
886
|
awaitWriteFinish: coalesce ? { stabilityThreshold: 50, pollInterval: 10 } : false
|
|
517
887
|
});
|
|
518
|
-
|
|
888
|
+
logger2.debug("watch:file", `watching [${include}]`);
|
|
519
889
|
process.once("SIGINT", async () => {
|
|
520
890
|
await watcher.close();
|
|
521
891
|
});
|
|
@@ -525,10 +895,10 @@ var nodeRuntime = {
|
|
|
525
895
|
};
|
|
526
896
|
process.setMaxListeners(Infinity);
|
|
527
897
|
process.on("unhandledRejection", (reason) => {
|
|
528
|
-
|
|
898
|
+
logger2.error("unhandled-rejection", reason);
|
|
529
899
|
});
|
|
530
900
|
process.on("uncaughtException", (reason) => {
|
|
531
|
-
|
|
901
|
+
logger2.error("uncaught-exception", reason);
|
|
532
902
|
});
|
|
533
903
|
|
|
534
904
|
// src/output-engine.ts
|
|
@@ -592,12 +962,15 @@ async function loadConfigAndCreateContext(options = {}) {
|
|
|
592
962
|
if (config) {
|
|
593
963
|
Object.assign(conf.config, config);
|
|
594
964
|
}
|
|
965
|
+
if (options.cwd) {
|
|
966
|
+
conf.config.cwd = options.cwd;
|
|
967
|
+
}
|
|
595
968
|
return createContext(conf);
|
|
596
969
|
}
|
|
597
970
|
|
|
598
971
|
// src/extract.ts
|
|
599
972
|
init_esm_shims();
|
|
600
|
-
import { logger as
|
|
973
|
+
import { logger as logger3 } from "@pandacss/logger";
|
|
601
974
|
import { Obj as Obj2, pipe as pipe2, tap as tap2, tryCatch } from "lil-fp";
|
|
602
975
|
|
|
603
976
|
// src/cli-box.ts
|
|
@@ -1882,7 +2255,7 @@ async function bundleChunks(ctx) {
|
|
|
1882
2255
|
}
|
|
1883
2256
|
async function writeFileChunk(ctx, file) {
|
|
1884
2257
|
const { path } = ctx.runtime;
|
|
1885
|
-
|
|
2258
|
+
logger3.debug("chunk:write", `File: ${path.relative(ctx.config.cwd, file)}`);
|
|
1886
2259
|
const css = extractFile(ctx, file);
|
|
1887
2260
|
if (!css)
|
|
1888
2261
|
return;
|
|
@@ -1896,17 +2269,18 @@ function extractFile(ctx, file) {
|
|
|
1896
2269
|
} = ctx;
|
|
1897
2270
|
return pipe2(
|
|
1898
2271
|
{ file: path.abs(cwd, file) },
|
|
1899
|
-
tap2(() =>
|
|
1900
|
-
Obj2.bind("measure", () =>
|
|
2272
|
+
tap2(() => logger3.debug("file:extract", file)),
|
|
2273
|
+
Obj2.bind("measure", () => logger3.time.debug(`Extracted ${file}`)),
|
|
1901
2274
|
Obj2.bind(
|
|
1902
2275
|
"result",
|
|
1903
2276
|
tryCatch(
|
|
1904
|
-
({ file: file2 }) => ctx.project.parseSourceFile(file2),
|
|
1905
|
-
(error) =>
|
|
2277
|
+
({ file: file2 }) => ctx.project.parseSourceFile(file2, ctx.properties),
|
|
2278
|
+
(error) => logger3.error("file:parse", error)
|
|
1906
2279
|
)
|
|
1907
2280
|
),
|
|
2281
|
+
Obj2.bind("measureCss", () => logger3.time.debug(`Parsed ${file}`)),
|
|
1908
2282
|
Obj2.bind("css", ({ result }) => result ? ctx.getParserCss(result) : void 0),
|
|
1909
|
-
tap2(({ measure }) => measure()),
|
|
2283
|
+
tap2(({ measure, measureCss }) => [measureCss(), measure()]),
|
|
1910
2284
|
Obj2.get("css")
|
|
1911
2285
|
);
|
|
1912
2286
|
}
|
|
@@ -2032,7 +2406,7 @@ var Builder = class {
|
|
|
2032
2406
|
}
|
|
2033
2407
|
async extract() {
|
|
2034
2408
|
const ctx = this.ensure();
|
|
2035
|
-
const done =
|
|
2409
|
+
const done = logger4.time.info("Extracted in");
|
|
2036
2410
|
await Promise.all(
|
|
2037
2411
|
ctx.getFiles().map(async (file) => {
|
|
2038
2412
|
const mtime = existsSync2(file) ? statSync(file).mtimeMs : -Infinity;
|
|
@@ -2093,7 +2467,7 @@ var Builder = class {
|
|
|
2093
2467
|
|
|
2094
2468
|
// src/exec-command.ts
|
|
2095
2469
|
init_esm_shims();
|
|
2096
|
-
import { logger as
|
|
2470
|
+
import { logger as logger5 } from "@pandacss/logger";
|
|
2097
2471
|
import { spawnSync } from "child_process";
|
|
2098
2472
|
import getPackageManager from "preferred-pm";
|
|
2099
2473
|
async function execCommand(cmd, cwd) {
|
|
@@ -2105,13 +2479,13 @@ async function execCommand(cmd, cwd) {
|
|
|
2105
2479
|
}
|
|
2106
2480
|
const check = spawnSync(pm, args, { cwd, stdio: "pipe" });
|
|
2107
2481
|
if (check.status !== 0) {
|
|
2108
|
-
|
|
2482
|
+
logger5.error("exec", check.stderr.toString());
|
|
2109
2483
|
}
|
|
2110
2484
|
}
|
|
2111
2485
|
|
|
2112
2486
|
// src/generate.ts
|
|
2113
2487
|
init_esm_shims();
|
|
2114
|
-
import { logger as
|
|
2488
|
+
import { logger as logger6 } from "@pandacss/logger";
|
|
2115
2489
|
import { match } from "ts-pattern";
|
|
2116
2490
|
|
|
2117
2491
|
// src/load-context.ts
|
|
@@ -2129,7 +2503,7 @@ var loadContext = async (config, configPath) => {
|
|
|
2129
2503
|
// src/generate.ts
|
|
2130
2504
|
async function build(ctx) {
|
|
2131
2505
|
const msg = await emitAndExtract(ctx);
|
|
2132
|
-
|
|
2506
|
+
logger6.info("css:emit", msg);
|
|
2133
2507
|
}
|
|
2134
2508
|
async function generate(config, configPath) {
|
|
2135
2509
|
const [ctxRef, loadCtx] = await loadContext(config, configPath);
|
|
@@ -2143,13 +2517,13 @@ async function generate(config, configPath) {
|
|
|
2143
2517
|
if (ctx.config.watch) {
|
|
2144
2518
|
const configWatcher = fs.watch({ include: dependencies });
|
|
2145
2519
|
configWatcher.on("change", async () => {
|
|
2146
|
-
|
|
2520
|
+
logger6.info("config:change", "Config changed, restarting...");
|
|
2147
2521
|
await loadCtx();
|
|
2148
2522
|
return build(ctxRef.current);
|
|
2149
2523
|
});
|
|
2150
2524
|
const contentWatcher = fs.watch(ctx.config);
|
|
2151
2525
|
contentWatcher.on("all", async (event, file) => {
|
|
2152
|
-
|
|
2526
|
+
logger6.info(`file:${event}`, file);
|
|
2153
2527
|
match(event).with("unlink", () => {
|
|
2154
2528
|
ctx.project.removeSourceFile(path.abs(cwd, file));
|
|
2155
2529
|
ctx.chunks.rm(file);
|
|
@@ -2163,7 +2537,7 @@ async function generate(config, configPath) {
|
|
|
2163
2537
|
}).otherwise(() => {
|
|
2164
2538
|
});
|
|
2165
2539
|
});
|
|
2166
|
-
|
|
2540
|
+
logger6.info("ctx:watch", ctx.messages.watch());
|
|
2167
2541
|
}
|
|
2168
2542
|
}
|
|
2169
2543
|
|
|
@@ -2189,9 +2563,9 @@ function setupGitIgnore({ config: { outdir } }) {
|
|
|
2189
2563
|
|
|
2190
2564
|
// src/setup-config.ts
|
|
2191
2565
|
init_esm_shims();
|
|
2192
|
-
import { logger as
|
|
2566
|
+
import { logger as logger7, quote } from "@pandacss/logger";
|
|
2193
2567
|
import { messages } from "@pandacss/generator";
|
|
2194
|
-
import { writeFile as
|
|
2568
|
+
import { writeFile as writeFile3 } from "fs-extra";
|
|
2195
2569
|
import { lookItUpSync as lookItUpSync3 } from "look-it-up";
|
|
2196
2570
|
import { outdent as outdent2 } from "outdent";
|
|
2197
2571
|
import { join as join2 } from "path";
|
|
@@ -2203,9 +2577,9 @@ async function setupConfig(cwd, { force }) {
|
|
|
2203
2577
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
2204
2578
|
const isTs = lookItUpSync3("tsconfig.json", cwd);
|
|
2205
2579
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
2206
|
-
|
|
2580
|
+
logger7.info("init:config", `creating panda config file: ${quote(file)}`);
|
|
2207
2581
|
if (!force && configFile) {
|
|
2208
|
-
|
|
2582
|
+
logger7.warn("init:config", messages.configExists(cmd));
|
|
2209
2583
|
} else {
|
|
2210
2584
|
const content = outdent2`
|
|
2211
2585
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -2224,12 +2598,12 @@ async function setupConfig(cwd, { force }) {
|
|
|
2224
2598
|
outdir: "styled-system",
|
|
2225
2599
|
})
|
|
2226
2600
|
`;
|
|
2227
|
-
await
|
|
2228
|
-
|
|
2601
|
+
await writeFile3(join2(cwd, file), content);
|
|
2602
|
+
logger7.log(messages.thankYou());
|
|
2229
2603
|
}
|
|
2230
2604
|
}
|
|
2231
2605
|
async function setupPostcss(cwd) {
|
|
2232
|
-
|
|
2606
|
+
logger7.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
|
|
2233
2607
|
const content = outdent2`
|
|
2234
2608
|
module.exports = {
|
|
2235
2609
|
plugins: {
|
|
@@ -2237,10 +2611,11 @@ async function setupPostcss(cwd) {
|
|
|
2237
2611
|
},
|
|
2238
2612
|
}
|
|
2239
2613
|
`;
|
|
2240
|
-
await
|
|
2614
|
+
await writeFile3(join2(cwd, "postcss.config.cjs"), content);
|
|
2241
2615
|
}
|
|
2242
2616
|
export {
|
|
2243
2617
|
Builder,
|
|
2618
|
+
analyzeTokens,
|
|
2244
2619
|
createContext,
|
|
2245
2620
|
discardDuplicate2 as discardDuplicate,
|
|
2246
2621
|
emitAndExtract,
|
|
@@ -2251,5 +2626,6 @@ export {
|
|
|
2251
2626
|
loadConfigAndCreateContext,
|
|
2252
2627
|
setupConfig,
|
|
2253
2628
|
setupGitIgnore,
|
|
2254
|
-
setupPostcss
|
|
2629
|
+
setupPostcss,
|
|
2630
|
+
writeAnalyzeJSON
|
|
2255
2631
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/node",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20230323194924",
|
|
4
4
|
"description": "The core css panda library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"chokidar": "^3.5.3",
|
|
18
18
|
"fast-glob": "^3.2.12",
|
|
19
|
+
"file-size": "^1.0.0",
|
|
20
|
+
"filesize": "^10.0.6",
|
|
19
21
|
"fs-extra": "11.1.1",
|
|
20
22
|
"glob-parent": "^6.0.2",
|
|
23
|
+
"gzip-size": "^6.0.0",
|
|
21
24
|
"hookable": "5.5.1",
|
|
22
25
|
"is-glob": "^4.0.3",
|
|
23
26
|
"javascript-stringify": "2.1.0",
|
|
@@ -29,18 +32,18 @@
|
|
|
29
32
|
"pluralize": "8.0.0",
|
|
30
33
|
"postcss": "8.4.21",
|
|
31
34
|
"preferred-pm": "^3.0.3",
|
|
32
|
-
"ts-pattern": "4.2.1",
|
|
33
35
|
"ts-morph": "17.0.1",
|
|
34
|
-
"
|
|
35
|
-
"@pandacss/
|
|
36
|
-
"@pandacss/core": "0.0.0-dev-
|
|
37
|
-
"@pandacss/error": "0.0.0-dev-
|
|
38
|
-
"@pandacss/
|
|
39
|
-
"@pandacss/
|
|
40
|
-
"@pandacss/
|
|
41
|
-
"@pandacss/
|
|
42
|
-
"@pandacss/
|
|
43
|
-
"@pandacss/
|
|
36
|
+
"ts-pattern": "4.2.1",
|
|
37
|
+
"@pandacss/config": "0.0.0-dev-20230323194924",
|
|
38
|
+
"@pandacss/core": "0.0.0-dev-20230323194924",
|
|
39
|
+
"@pandacss/error": "0.0.0-dev-20230323194924",
|
|
40
|
+
"@pandacss/generator": "0.0.0-dev-20230323194924",
|
|
41
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230323194924",
|
|
42
|
+
"@pandacss/logger": "0.0.0-dev-20230323194924",
|
|
43
|
+
"@pandacss/parser": "0.0.0-dev-20230323194924",
|
|
44
|
+
"@pandacss/shared": "0.0.0-dev-20230323194924",
|
|
45
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20230323194924",
|
|
46
|
+
"@pandacss/types": "0.0.0-dev-20230323194924"
|
|
44
47
|
},
|
|
45
48
|
"devDependencies": {
|
|
46
49
|
"@types/fs-extra": "11.0.1",
|
|
@@ -49,7 +52,7 @@
|
|
|
49
52
|
"@types/lodash.merge": "4.6.7",
|
|
50
53
|
"@types/pluralize": "0.0.29",
|
|
51
54
|
"boxen": "^7.0.2",
|
|
52
|
-
"@pandacss/fixture": "0.0.0-dev-
|
|
55
|
+
"@pandacss/fixture": "0.0.0-dev-20230323194924"
|
|
53
56
|
},
|
|
54
57
|
"scripts": {
|
|
55
58
|
"build": "tsup src/index.ts --format=cjs,esm --shims --dts",
|