@pandacss/node 0.0.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +27 -12
- package/dist/index.js +254 -340
- package/dist/index.mjs +236 -324
- package/package.json +14 -16
package/dist/index.js
CHANGED
|
@@ -33,83 +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@6.7.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@6.7.
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// ../../node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js
|
|
43
|
-
var require_duplexer = __commonJS({
|
|
44
|
-
"../../node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js"(exports, module2) {
|
|
45
|
-
init_cjs_shims();
|
|
46
|
-
var Stream = require("stream");
|
|
47
|
-
var writeMethods = ["write", "end", "destroy"];
|
|
48
|
-
var readMethods = ["resume", "pause"];
|
|
49
|
-
var readEvents = ["data", "close"];
|
|
50
|
-
var slice = Array.prototype.slice;
|
|
51
|
-
module2.exports = duplex;
|
|
52
|
-
function forEach(arr, fn) {
|
|
53
|
-
if (arr.forEach) {
|
|
54
|
-
return arr.forEach(fn);
|
|
55
|
-
}
|
|
56
|
-
for (var i = 0; i < arr.length; i++) {
|
|
57
|
-
fn(arr[i], i);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function duplex(writer, reader) {
|
|
61
|
-
var stream2 = new Stream();
|
|
62
|
-
var ended = false;
|
|
63
|
-
forEach(writeMethods, proxyWriter);
|
|
64
|
-
forEach(readMethods, proxyReader);
|
|
65
|
-
forEach(readEvents, proxyStream);
|
|
66
|
-
reader.on("end", handleEnd);
|
|
67
|
-
writer.on("drain", function() {
|
|
68
|
-
stream2.emit("drain");
|
|
69
|
-
});
|
|
70
|
-
writer.on("error", reemit);
|
|
71
|
-
reader.on("error", reemit);
|
|
72
|
-
stream2.writable = writer.writable;
|
|
73
|
-
stream2.readable = reader.readable;
|
|
74
|
-
return stream2;
|
|
75
|
-
function proxyWriter(methodName) {
|
|
76
|
-
stream2[methodName] = method;
|
|
77
|
-
function method() {
|
|
78
|
-
return writer[methodName].apply(writer, arguments);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function proxyReader(methodName) {
|
|
82
|
-
stream2[methodName] = method;
|
|
83
|
-
function method() {
|
|
84
|
-
stream2.emit(methodName);
|
|
85
|
-
var func = reader[methodName];
|
|
86
|
-
if (func) {
|
|
87
|
-
return func.apply(reader, arguments);
|
|
88
|
-
}
|
|
89
|
-
reader.emit(methodName);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function proxyStream(methodName) {
|
|
93
|
-
reader.on(methodName, reemit2);
|
|
94
|
-
function reemit2() {
|
|
95
|
-
var args = slice.call(arguments);
|
|
96
|
-
args.unshift(methodName);
|
|
97
|
-
stream2.emit.apply(stream2, args);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function handleEnd() {
|
|
101
|
-
if (ended) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
ended = true;
|
|
105
|
-
var args = slice.call(arguments);
|
|
106
|
-
args.unshift("end");
|
|
107
|
-
stream2.emit.apply(stream2, args);
|
|
108
|
-
}
|
|
109
|
-
function reemit(err) {
|
|
110
|
-
stream2.emit("error", err);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
38
|
+
"../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.1.3/node_modules/tsup/assets/cjs_shims.js"() {
|
|
113
39
|
}
|
|
114
40
|
});
|
|
115
41
|
|
|
@@ -484,11 +410,15 @@ __export(src_exports, {
|
|
|
484
410
|
emitArtifacts: () => emitArtifacts,
|
|
485
411
|
execCommand: () => execCommand,
|
|
486
412
|
extractCss: () => extractCss,
|
|
413
|
+
extractFile: () => extractFile,
|
|
414
|
+
findConfig: () => findConfig,
|
|
487
415
|
generate: () => generate,
|
|
488
416
|
loadConfigAndCreateContext: () => loadConfigAndCreateContext,
|
|
417
|
+
parseDependency: () => parseDependency,
|
|
489
418
|
setupConfig: () => setupConfig,
|
|
490
419
|
setupGitIgnore: () => setupGitIgnore,
|
|
491
420
|
setupPostcss: () => setupPostcss,
|
|
421
|
+
shipFiles: () => shipFiles,
|
|
492
422
|
writeAnalyzeJSON: () => writeAnalyzeJSON
|
|
493
423
|
});
|
|
494
424
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -498,8 +428,9 @@ var import_core3 = require("@pandacss/core");
|
|
|
498
428
|
// src/analyze-tokens.ts
|
|
499
429
|
init_cjs_shims();
|
|
500
430
|
var import_logger = require("@pandacss/logger");
|
|
431
|
+
var import_filesize = require("filesize");
|
|
501
432
|
var import_promises = require("fs/promises");
|
|
502
|
-
var
|
|
433
|
+
var import_zlib = __toESM(require("zlib"));
|
|
503
434
|
|
|
504
435
|
// src/classify.ts
|
|
505
436
|
init_cjs_shims();
|
|
@@ -551,7 +482,7 @@ var classifyTokens = (ctx, parserResultByFilepath) => {
|
|
|
551
482
|
}
|
|
552
483
|
if (type === "pattern") {
|
|
553
484
|
const pattern = ctx.patterns.getConfig(from.toLowerCase());
|
|
554
|
-
const patternProp = pattern
|
|
485
|
+
const patternProp = pattern?.properties?.[propName];
|
|
555
486
|
if (!patternProp)
|
|
556
487
|
return false;
|
|
557
488
|
if (patternProp.type === "boolean" || patternProp.type === "number") {
|
|
@@ -763,58 +694,25 @@ var getMostUsedInMap = (map, pickCount) => {
|
|
|
763
694
|
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 }));
|
|
764
695
|
};
|
|
765
696
|
|
|
766
|
-
// src/get-node-range.ts
|
|
767
|
-
init_cjs_shims();
|
|
768
|
-
var getNodeRange = (node) => {
|
|
769
|
-
const src = node.getSourceFile();
|
|
770
|
-
const [startPosition, endPosition] = [node.getStart(), node.getEnd()];
|
|
771
|
-
const startInfo = src.getLineAndColumnAtPos(startPosition);
|
|
772
|
-
const endInfo = src.getLineAndColumnAtPos(endPosition);
|
|
773
|
-
return {
|
|
774
|
-
startPosition,
|
|
775
|
-
startLineNumber: startInfo.line,
|
|
776
|
-
startColumn: startInfo.column,
|
|
777
|
-
endPosition,
|
|
778
|
-
endLineNumber: endInfo.line,
|
|
779
|
-
endColumn: endInfo.column
|
|
780
|
-
};
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
// src/analyze-tokens.ts
|
|
784
|
-
var import_filesize = require("filesize");
|
|
785
|
-
|
|
786
|
-
// ../../node_modules/.pnpm/gzip-size@7.0.0/node_modules/gzip-size/index.js
|
|
787
|
-
init_cjs_shims();
|
|
788
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
789
|
-
var import_node_stream = __toESM(require("stream"), 1);
|
|
790
|
-
var import_node_zlib = __toESM(require("zlib"), 1);
|
|
791
|
-
var import_node_util = require("util");
|
|
792
|
-
var import_duplexer = __toESM(require_duplexer(), 1);
|
|
793
|
-
var getOptions = (options) => ({ level: 9, ...options });
|
|
794
|
-
var gzip = (0, import_node_util.promisify)(import_node_zlib.default.gzip);
|
|
795
|
-
function gzipSizeSync(input, options) {
|
|
796
|
-
return import_node_zlib.default.gzipSync(input, getOptions(options)).length;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
697
|
// src/analyze-tokens.ts
|
|
698
|
+
var gzipSizeSync = (code) => import_zlib.default.gzipSync(code, { level: import_zlib.default.constants.Z_BEST_COMPRESSION }).length;
|
|
800
699
|
function analyzeTokens(ctx, options = {}) {
|
|
801
|
-
const
|
|
802
|
-
const
|
|
803
|
-
const
|
|
804
|
-
|
|
700
|
+
const filesMap = /* @__PURE__ */ new Map();
|
|
701
|
+
const timesMap = /* @__PURE__ */ new Map();
|
|
702
|
+
const files = ctx.getFiles();
|
|
703
|
+
files.forEach((file) => {
|
|
805
704
|
const start2 = performance.now();
|
|
806
705
|
const result = ctx.project.parseSourceFile(file);
|
|
807
706
|
const extractMs = performance.now() - start2;
|
|
808
|
-
|
|
707
|
+
timesMap.set(file, extractMs);
|
|
809
708
|
import_logger.logger.debug("analyze", `Parsed ${file} in ${extractMs}ms`);
|
|
810
709
|
if (result) {
|
|
811
|
-
|
|
710
|
+
filesMap.set(file, result);
|
|
812
711
|
options.onResult?.(file, result);
|
|
813
712
|
}
|
|
814
|
-
return [file, result];
|
|
815
713
|
});
|
|
816
|
-
const totalMs = Array.from(
|
|
817
|
-
import_logger.logger.debug("analyze", `Analyzed ${
|
|
714
|
+
const totalMs = Array.from(timesMap.values()).reduce((a, b) => a + b, 0);
|
|
715
|
+
import_logger.logger.debug("analyze", `Analyzed ${files.length} files in ${totalMs.toFixed(2)}ms`);
|
|
818
716
|
const minify = ctx.config.minify;
|
|
819
717
|
const chunkFiles = ctx.chunks.getFiles();
|
|
820
718
|
ctx.config.optimize = true;
|
|
@@ -824,18 +722,17 @@ function analyzeTokens(ctx, options = {}) {
|
|
|
824
722
|
const minifiedCss = ctx.getCss({ files: chunkFiles });
|
|
825
723
|
ctx.config.minify = minify;
|
|
826
724
|
const start = performance.now();
|
|
827
|
-
const analysis = classifyTokens(ctx,
|
|
725
|
+
const analysis = classifyTokens(ctx, filesMap);
|
|
828
726
|
const classifyMs = performance.now() - start;
|
|
829
727
|
return Object.assign(
|
|
830
728
|
{
|
|
831
729
|
duration: {
|
|
832
|
-
extractTimeByFiles: Object.fromEntries(
|
|
730
|
+
extractTimeByFiles: Object.fromEntries(timesMap.entries()),
|
|
833
731
|
extractTotal: totalMs,
|
|
834
732
|
classify: classifyMs
|
|
835
733
|
},
|
|
836
734
|
fileSizes: {
|
|
837
735
|
lineCount: css.split("\n").length,
|
|
838
|
-
// rulesCount: css.split('{').length - 1, ?
|
|
839
736
|
normal: (0, import_filesize.filesize)(Buffer.byteLength(css, "utf-8")),
|
|
840
737
|
minified: (0, import_filesize.filesize)(Buffer.byteLength(minifiedCss, "utf-8")),
|
|
841
738
|
gzip: {
|
|
@@ -854,14 +751,11 @@ var analyzeResultSerializer = (_key, value) => {
|
|
|
854
751
|
if (value instanceof Map) {
|
|
855
752
|
return Object.fromEntries(value);
|
|
856
753
|
}
|
|
857
|
-
if (import_ts_morph.Node.isNode(value)) {
|
|
858
|
-
return { kind: value.getKindName(), range: getNodeRange(value) };
|
|
859
|
-
}
|
|
860
754
|
return value;
|
|
861
755
|
};
|
|
862
756
|
var writeAnalyzeJSON = (fileName, result, ctx) => {
|
|
863
757
|
result.details.byInstanceId.forEach((item) => {
|
|
864
|
-
item.box =
|
|
758
|
+
item.box = item.box.toJSON();
|
|
865
759
|
});
|
|
866
760
|
return (0, import_promises.writeFile)(
|
|
867
761
|
fileName,
|
|
@@ -882,16 +776,18 @@ var writeAnalyzeJSON = (fileName, result, ctx) => {
|
|
|
882
776
|
|
|
883
777
|
// src/builder.ts
|
|
884
778
|
init_cjs_shims();
|
|
779
|
+
var import_config2 = require("@pandacss/config");
|
|
885
780
|
var import_core2 = require("@pandacss/core");
|
|
886
781
|
var import_error = require("@pandacss/error");
|
|
887
782
|
var import_logger4 = require("@pandacss/logger");
|
|
888
|
-
var
|
|
783
|
+
var import_fs = require("fs");
|
|
889
784
|
var import_fs_extra2 = require("fs-extra");
|
|
890
|
-
var
|
|
785
|
+
var import_path3 = require("path");
|
|
891
786
|
|
|
892
787
|
// src/config.ts
|
|
893
788
|
init_cjs_shims();
|
|
894
789
|
var import_config = require("@pandacss/config");
|
|
790
|
+
var import_hookable = require("hookable");
|
|
895
791
|
var import_look_it_up = require("look-it-up");
|
|
896
792
|
|
|
897
793
|
// src/create-context.ts
|
|
@@ -903,18 +799,22 @@ var import_lil_fp = require("lil-fp");
|
|
|
903
799
|
// src/chunk-engine.ts
|
|
904
800
|
init_cjs_shims();
|
|
905
801
|
var import_core = require("@pandacss/core");
|
|
906
|
-
var getChunkEngine = ({
|
|
907
|
-
|
|
802
|
+
var getChunkEngine = ({
|
|
803
|
+
paths,
|
|
804
|
+
config,
|
|
805
|
+
runtime: { path: path2, fs }
|
|
806
|
+
}) => ({
|
|
807
|
+
dir: path2.join(...paths.chunk),
|
|
908
808
|
readFile(file) {
|
|
909
|
-
const fileName =
|
|
910
|
-
return
|
|
809
|
+
const fileName = path2.join(...paths.chunk, this.format(file));
|
|
810
|
+
return fs.existsSync(fileName) ? fs.readFileSync(fileName) : "";
|
|
911
811
|
},
|
|
912
812
|
getFiles() {
|
|
913
|
-
const files =
|
|
914
|
-
return files.map((file) =>
|
|
813
|
+
const files = fs.existsSync(this.dir) ? fs.readDirSync(this.dir) : [];
|
|
814
|
+
return files.map((file) => fs.readFileSync(path2.join(this.dir, file)));
|
|
915
815
|
},
|
|
916
816
|
format(file) {
|
|
917
|
-
return
|
|
817
|
+
return path2.relative(config.cwd, file).replaceAll(path2.sep, "__").replace(path2.extname(file), ".css");
|
|
918
818
|
},
|
|
919
819
|
getArtifact(file, css) {
|
|
920
820
|
const fileName = this.format(file);
|
|
@@ -925,10 +825,10 @@ var getChunkEngine = ({ paths, config, runtime: { path: path3, fs: fs3 } }) => (
|
|
|
925
825
|
};
|
|
926
826
|
},
|
|
927
827
|
rm(file) {
|
|
928
|
-
return
|
|
828
|
+
return fs.rmFileSync(path2.join(...paths.chunk, this.format(file)));
|
|
929
829
|
},
|
|
930
830
|
empty() {
|
|
931
|
-
return
|
|
831
|
+
return fs.rmDirSync(this.dir);
|
|
932
832
|
},
|
|
933
833
|
get glob() {
|
|
934
834
|
return [`${this.dir}/**/*.css`];
|
|
@@ -968,15 +868,19 @@ var nodeRuntime = {
|
|
|
968
868
|
glob(opts) {
|
|
969
869
|
if (!opts.include)
|
|
970
870
|
return [];
|
|
971
|
-
|
|
871
|
+
const ignore = opts.exclude ?? [];
|
|
872
|
+
if (!ignore.length) {
|
|
873
|
+
ignore.push("**/*.d.ts");
|
|
874
|
+
}
|
|
875
|
+
return import_fast_glob.default.sync(opts.include, { cwd: opts.cwd, ignore, absolute: true });
|
|
972
876
|
},
|
|
973
877
|
writeFile: import_fs_extra.writeFile,
|
|
974
878
|
writeFileSync: import_fs_extra.writeFileSync,
|
|
975
879
|
readDirSync: import_fs_extra.readdirSync,
|
|
976
880
|
rmDirSync: import_fs_extra.emptyDirSync,
|
|
977
881
|
rmFileSync: import_fs_extra.removeSync,
|
|
978
|
-
ensureDirSync(
|
|
979
|
-
return (0, import_fs_extra.ensureDirSync)(
|
|
882
|
+
ensureDirSync(path2) {
|
|
883
|
+
return (0, import_fs_extra.ensureDirSync)(path2);
|
|
980
884
|
},
|
|
981
885
|
watch(options) {
|
|
982
886
|
const { include, exclude, cwd, poll } = options;
|
|
@@ -1007,20 +911,23 @@ process.on("uncaughtException", (reason) => {
|
|
|
1007
911
|
|
|
1008
912
|
// src/output-engine.ts
|
|
1009
913
|
init_cjs_shims();
|
|
1010
|
-
var getOutputEngine = ({
|
|
914
|
+
var getOutputEngine = ({
|
|
915
|
+
paths,
|
|
916
|
+
runtime: { path: path2, fs }
|
|
917
|
+
}) => ({
|
|
1011
918
|
empty() {
|
|
1012
|
-
|
|
919
|
+
fs.rmDirSync(path2.join(...paths.root));
|
|
1013
920
|
},
|
|
1014
921
|
async write(output) {
|
|
1015
922
|
if (!output)
|
|
1016
923
|
return;
|
|
1017
924
|
const { dir = paths.root, files } = output;
|
|
1018
|
-
|
|
925
|
+
fs.ensureDirSync(path2.join(...dir));
|
|
1019
926
|
return Promise.all(
|
|
1020
927
|
files.map(async ({ file, code }) => {
|
|
1021
|
-
const absPath =
|
|
928
|
+
const absPath = path2.join(...dir, file);
|
|
1022
929
|
if (code) {
|
|
1023
|
-
return
|
|
930
|
+
return fs.writeFile(absPath, code);
|
|
1024
931
|
}
|
|
1025
932
|
})
|
|
1026
933
|
);
|
|
@@ -1031,18 +938,19 @@ var getOutputEngine = ({ paths, runtime: { path: path3, fs: fs3 } }) => ({
|
|
|
1031
938
|
var createContext = (conf) => (0, import_lil_fp.pipe)(
|
|
1032
939
|
conf,
|
|
1033
940
|
import_generator.createGenerator,
|
|
1034
|
-
import_lil_fp.Obj.assign({ runtime: nodeRuntime }),
|
|
941
|
+
import_lil_fp.Obj.assign({ runtime: nodeRuntime, hooks: conf.hooks }),
|
|
1035
942
|
(0, import_lil_fp.tap)(({ config, runtime }) => {
|
|
1036
943
|
config.cwd ||= runtime.cwd();
|
|
1037
944
|
}),
|
|
1038
|
-
import_lil_fp.Obj.bind("getFiles", ({ config, runtime: { fs
|
|
945
|
+
import_lil_fp.Obj.bind("getFiles", ({ config, runtime: { fs } }) => () => {
|
|
1039
946
|
const { include, exclude, cwd } = config;
|
|
1040
|
-
return
|
|
947
|
+
return fs.glob({ include, exclude, cwd });
|
|
1041
948
|
}),
|
|
1042
|
-
import_lil_fp.Obj.bind("project", ({ getFiles, runtime: { fs
|
|
949
|
+
import_lil_fp.Obj.bind("project", ({ getFiles, runtime: { fs }, parserOptions }) => {
|
|
1043
950
|
return (0, import_parser.createProject)({
|
|
1044
951
|
getFiles,
|
|
1045
|
-
readFile:
|
|
952
|
+
readFile: fs.readFileSync,
|
|
953
|
+
hooks: conf.hooks,
|
|
1046
954
|
parserOptions
|
|
1047
955
|
});
|
|
1048
956
|
}),
|
|
@@ -1061,6 +969,7 @@ function findConfig() {
|
|
|
1061
969
|
}
|
|
1062
970
|
}
|
|
1063
971
|
async function loadConfigAndCreateContext(options = {}) {
|
|
972
|
+
const hooks = (0, import_hookable.createHooks)();
|
|
1064
973
|
const { cwd = process.cwd(), config, configPath } = options;
|
|
1065
974
|
const conf = await (0, import_config.loadConfigFile)({ cwd, file: configPath });
|
|
1066
975
|
if (config) {
|
|
@@ -1069,7 +978,15 @@ async function loadConfigAndCreateContext(options = {}) {
|
|
|
1069
978
|
if (options.cwd) {
|
|
1070
979
|
conf.config.cwd = options.cwd;
|
|
1071
980
|
}
|
|
1072
|
-
|
|
981
|
+
conf.config.outdir ??= "styled-system";
|
|
982
|
+
if (conf.config.hooks) {
|
|
983
|
+
hooks.addHooks(conf.config.hooks);
|
|
984
|
+
}
|
|
985
|
+
await hooks.callHook("config:resolved", conf);
|
|
986
|
+
if (conf.config.logLevel === "debug") {
|
|
987
|
+
(0, import_hookable.createDebugger)(hooks, { tag: "panda" });
|
|
988
|
+
}
|
|
989
|
+
return createContext({ ...conf, hooks });
|
|
1073
990
|
}
|
|
1074
991
|
|
|
1075
992
|
// src/extract.ts
|
|
@@ -1087,7 +1004,7 @@ var import_node_process2 = __toESM(require("process"), 1);
|
|
|
1087
1004
|
// ../../node_modules/.pnpm/string-width@5.1.2/node_modules/string-width/index.js
|
|
1088
1005
|
init_cjs_shims();
|
|
1089
1006
|
|
|
1090
|
-
// ../../node_modules/.pnpm/strip-ansi@7.0
|
|
1007
|
+
// ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
|
1091
1008
|
init_cjs_shims();
|
|
1092
1009
|
|
|
1093
1010
|
// ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
|
|
@@ -1100,12 +1017,13 @@ function ansiRegex({ onlyFirst = false } = {}) {
|
|
|
1100
1017
|
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
1101
1018
|
}
|
|
1102
1019
|
|
|
1103
|
-
// ../../node_modules/.pnpm/strip-ansi@7.0
|
|
1020
|
+
// ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
|
1021
|
+
var regex = ansiRegex();
|
|
1104
1022
|
function stripAnsi(string) {
|
|
1105
1023
|
if (typeof string !== "string") {
|
|
1106
1024
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
1107
1025
|
}
|
|
1108
|
-
return string.replace(
|
|
1026
|
+
return string.replace(regex, "");
|
|
1109
1027
|
}
|
|
1110
1028
|
|
|
1111
1029
|
// ../../node_modules/.pnpm/string-width@5.1.2/node_modules/string-width/index.js
|
|
@@ -1454,9 +1372,9 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
1454
1372
|
}
|
|
1455
1373
|
return min;
|
|
1456
1374
|
}
|
|
1457
|
-
function createSupportsColor(
|
|
1458
|
-
const level = _supportsColor(
|
|
1459
|
-
streamIsTTY:
|
|
1375
|
+
function createSupportsColor(stream, options = {}) {
|
|
1376
|
+
const level = _supportsColor(stream, {
|
|
1377
|
+
streamIsTTY: stream && stream.isTTY,
|
|
1460
1378
|
...options
|
|
1461
1379
|
});
|
|
1462
1380
|
return translateLevel(level);
|
|
@@ -1747,70 +1665,78 @@ var import_ansi_align = __toESM(require_ansi_align(), 1);
|
|
|
1747
1665
|
// ../../node_modules/.pnpm/wrap-ansi@8.1.0/node_modules/wrap-ansi/index.js
|
|
1748
1666
|
init_cjs_shims();
|
|
1749
1667
|
|
|
1750
|
-
// ../../node_modules/.pnpm/ansi-styles@6.
|
|
1668
|
+
// ../../node_modules/.pnpm/ansi-styles@6.2.1/node_modules/ansi-styles/index.js
|
|
1751
1669
|
init_cjs_shims();
|
|
1752
1670
|
var ANSI_BACKGROUND_OFFSET2 = 10;
|
|
1753
1671
|
var wrapAnsi162 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
1754
1672
|
var wrapAnsi2562 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
1755
1673
|
var wrapAnsi16m2 = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
1674
|
+
var styles3 = {
|
|
1675
|
+
modifier: {
|
|
1676
|
+
reset: [0, 0],
|
|
1677
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
1678
|
+
bold: [1, 22],
|
|
1679
|
+
dim: [2, 22],
|
|
1680
|
+
italic: [3, 23],
|
|
1681
|
+
underline: [4, 24],
|
|
1682
|
+
overline: [53, 55],
|
|
1683
|
+
inverse: [7, 27],
|
|
1684
|
+
hidden: [8, 28],
|
|
1685
|
+
strikethrough: [9, 29]
|
|
1686
|
+
},
|
|
1687
|
+
color: {
|
|
1688
|
+
black: [30, 39],
|
|
1689
|
+
red: [31, 39],
|
|
1690
|
+
green: [32, 39],
|
|
1691
|
+
yellow: [33, 39],
|
|
1692
|
+
blue: [34, 39],
|
|
1693
|
+
magenta: [35, 39],
|
|
1694
|
+
cyan: [36, 39],
|
|
1695
|
+
white: [37, 39],
|
|
1696
|
+
// Bright color
|
|
1697
|
+
blackBright: [90, 39],
|
|
1698
|
+
gray: [90, 39],
|
|
1699
|
+
// Alias of `blackBright`
|
|
1700
|
+
grey: [90, 39],
|
|
1701
|
+
// Alias of `blackBright`
|
|
1702
|
+
redBright: [91, 39],
|
|
1703
|
+
greenBright: [92, 39],
|
|
1704
|
+
yellowBright: [93, 39],
|
|
1705
|
+
blueBright: [94, 39],
|
|
1706
|
+
magentaBright: [95, 39],
|
|
1707
|
+
cyanBright: [96, 39],
|
|
1708
|
+
whiteBright: [97, 39]
|
|
1709
|
+
},
|
|
1710
|
+
bgColor: {
|
|
1711
|
+
bgBlack: [40, 49],
|
|
1712
|
+
bgRed: [41, 49],
|
|
1713
|
+
bgGreen: [42, 49],
|
|
1714
|
+
bgYellow: [43, 49],
|
|
1715
|
+
bgBlue: [44, 49],
|
|
1716
|
+
bgMagenta: [45, 49],
|
|
1717
|
+
bgCyan: [46, 49],
|
|
1718
|
+
bgWhite: [47, 49],
|
|
1719
|
+
// Bright color
|
|
1720
|
+
bgBlackBright: [100, 49],
|
|
1721
|
+
bgGray: [100, 49],
|
|
1722
|
+
// Alias of `bgBlackBright`
|
|
1723
|
+
bgGrey: [100, 49],
|
|
1724
|
+
// Alias of `bgBlackBright`
|
|
1725
|
+
bgRedBright: [101, 49],
|
|
1726
|
+
bgGreenBright: [102, 49],
|
|
1727
|
+
bgYellowBright: [103, 49],
|
|
1728
|
+
bgBlueBright: [104, 49],
|
|
1729
|
+
bgMagentaBright: [105, 49],
|
|
1730
|
+
bgCyanBright: [106, 49],
|
|
1731
|
+
bgWhiteBright: [107, 49]
|
|
1732
|
+
}
|
|
1733
|
+
};
|
|
1734
|
+
var modifierNames2 = Object.keys(styles3.modifier);
|
|
1735
|
+
var foregroundColorNames2 = Object.keys(styles3.color);
|
|
1736
|
+
var backgroundColorNames2 = Object.keys(styles3.bgColor);
|
|
1737
|
+
var colorNames2 = [...foregroundColorNames2, ...backgroundColorNames2];
|
|
1756
1738
|
function assembleStyles2() {
|
|
1757
1739
|
const codes = /* @__PURE__ */ new Map();
|
|
1758
|
-
const styles3 = {
|
|
1759
|
-
modifier: {
|
|
1760
|
-
reset: [0, 0],
|
|
1761
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
1762
|
-
bold: [1, 22],
|
|
1763
|
-
dim: [2, 22],
|
|
1764
|
-
italic: [3, 23],
|
|
1765
|
-
underline: [4, 24],
|
|
1766
|
-
overline: [53, 55],
|
|
1767
|
-
inverse: [7, 27],
|
|
1768
|
-
hidden: [8, 28],
|
|
1769
|
-
strikethrough: [9, 29]
|
|
1770
|
-
},
|
|
1771
|
-
color: {
|
|
1772
|
-
black: [30, 39],
|
|
1773
|
-
red: [31, 39],
|
|
1774
|
-
green: [32, 39],
|
|
1775
|
-
yellow: [33, 39],
|
|
1776
|
-
blue: [34, 39],
|
|
1777
|
-
magenta: [35, 39],
|
|
1778
|
-
cyan: [36, 39],
|
|
1779
|
-
white: [37, 39],
|
|
1780
|
-
// Bright color
|
|
1781
|
-
blackBright: [90, 39],
|
|
1782
|
-
redBright: [91, 39],
|
|
1783
|
-
greenBright: [92, 39],
|
|
1784
|
-
yellowBright: [93, 39],
|
|
1785
|
-
blueBright: [94, 39],
|
|
1786
|
-
magentaBright: [95, 39],
|
|
1787
|
-
cyanBright: [96, 39],
|
|
1788
|
-
whiteBright: [97, 39]
|
|
1789
|
-
},
|
|
1790
|
-
bgColor: {
|
|
1791
|
-
bgBlack: [40, 49],
|
|
1792
|
-
bgRed: [41, 49],
|
|
1793
|
-
bgGreen: [42, 49],
|
|
1794
|
-
bgYellow: [43, 49],
|
|
1795
|
-
bgBlue: [44, 49],
|
|
1796
|
-
bgMagenta: [45, 49],
|
|
1797
|
-
bgCyan: [46, 49],
|
|
1798
|
-
bgWhite: [47, 49],
|
|
1799
|
-
// Bright color
|
|
1800
|
-
bgBlackBright: [100, 49],
|
|
1801
|
-
bgRedBright: [101, 49],
|
|
1802
|
-
bgGreenBright: [102, 49],
|
|
1803
|
-
bgYellowBright: [103, 49],
|
|
1804
|
-
bgBlueBright: [104, 49],
|
|
1805
|
-
bgMagentaBright: [105, 49],
|
|
1806
|
-
bgCyanBright: [106, 49],
|
|
1807
|
-
bgWhiteBright: [107, 49]
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
|
-
styles3.color.gray = styles3.color.blackBright;
|
|
1811
|
-
styles3.bgColor.bgGray = styles3.bgColor.bgBlackBright;
|
|
1812
|
-
styles3.color.grey = styles3.color.blackBright;
|
|
1813
|
-
styles3.bgColor.bgGrey = styles3.bgColor.bgBlackBright;
|
|
1814
1740
|
for (const [groupName, group] of Object.entries(styles3)) {
|
|
1815
1741
|
for (const [styleName, style] of Object.entries(group)) {
|
|
1816
1742
|
styles3[styleName] = {
|
|
@@ -2375,8 +2301,8 @@ async function bundleChunks(ctx) {
|
|
|
2375
2301
|
});
|
|
2376
2302
|
}
|
|
2377
2303
|
async function writeFileChunk(ctx, file) {
|
|
2378
|
-
const { path:
|
|
2379
|
-
import_logger3.logger.debug("chunk:write", `File: ${
|
|
2304
|
+
const { path: path2 } = ctx.runtime;
|
|
2305
|
+
import_logger3.logger.debug("chunk:write", `File: ${path2.relative(ctx.config.cwd, file)}`);
|
|
2380
2306
|
const css = extractFile(ctx, file);
|
|
2381
2307
|
if (!css)
|
|
2382
2308
|
return;
|
|
@@ -2385,11 +2311,11 @@ async function writeFileChunk(ctx, file) {
|
|
|
2385
2311
|
}
|
|
2386
2312
|
function extractFile(ctx, file) {
|
|
2387
2313
|
const {
|
|
2388
|
-
runtime: { path:
|
|
2314
|
+
runtime: { path: path2 },
|
|
2389
2315
|
config: { cwd }
|
|
2390
2316
|
} = ctx;
|
|
2391
2317
|
return (0, import_lil_fp2.pipe)(
|
|
2392
|
-
{ file:
|
|
2318
|
+
{ file: path2.abs(cwd, file) },
|
|
2393
2319
|
(0, import_lil_fp2.tap)(() => import_logger3.logger.debug("file:extract", file)),
|
|
2394
2320
|
import_lil_fp2.Obj.bind("measure", () => import_logger3.logger.time.debug(`Extracted ${file}`)),
|
|
2395
2321
|
import_lil_fp2.Obj.bind(
|
|
@@ -2431,62 +2357,10 @@ async function extractCss(ctx) {
|
|
|
2431
2357
|
return ctx.messages.buildComplete(ctx.getFiles().length);
|
|
2432
2358
|
}
|
|
2433
2359
|
|
|
2434
|
-
// src/get-mod-deps.ts
|
|
2435
|
-
init_cjs_shims();
|
|
2436
|
-
var import_fs = __toESM(require("fs"));
|
|
2437
|
-
var import_path2 = __toESM(require("path"));
|
|
2438
|
-
var jsExtensions = [".js", ".cjs", ".mjs"];
|
|
2439
|
-
var jsResolutionOrder = ["", ".js", ".cjs", ".mjs", ".ts", ".cts", ".mts", ".jsx", ".tsx"];
|
|
2440
|
-
var tsResolutionOrder = ["", ".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"];
|
|
2441
|
-
function resolveWithExtension(file, extensions) {
|
|
2442
|
-
for (const ext of extensions) {
|
|
2443
|
-
const full = `${file}${ext}`;
|
|
2444
|
-
if (import_fs.default.existsSync(full) && import_fs.default.statSync(full).isFile()) {
|
|
2445
|
-
return full;
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
for (const ext of extensions) {
|
|
2449
|
-
const full = `${file}/index${ext}`;
|
|
2450
|
-
if (import_fs.default.existsSync(full)) {
|
|
2451
|
-
return full;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
return null;
|
|
2455
|
-
}
|
|
2456
|
-
function* getDeps(filename, base, seen, ext = import_path2.default.extname(filename)) {
|
|
2457
|
-
const absoluteFile = resolveWithExtension(
|
|
2458
|
-
import_path2.default.resolve(base, filename),
|
|
2459
|
-
jsExtensions.includes(ext) ? jsResolutionOrder : tsResolutionOrder
|
|
2460
|
-
);
|
|
2461
|
-
if (absoluteFile === null)
|
|
2462
|
-
return;
|
|
2463
|
-
if (seen.has(absoluteFile))
|
|
2464
|
-
return;
|
|
2465
|
-
seen.add(absoluteFile);
|
|
2466
|
-
yield absoluteFile;
|
|
2467
|
-
base = import_path2.default.dirname(absoluteFile);
|
|
2468
|
-
ext = import_path2.default.extname(absoluteFile);
|
|
2469
|
-
const contents = import_fs.default.readFileSync(absoluteFile, "utf-8");
|
|
2470
|
-
for (const match2 of [
|
|
2471
|
-
...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
|
|
2472
|
-
...contents.matchAll(/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi),
|
|
2473
|
-
...contents.matchAll(/require\(['"`](.+)['"`]\)/gi)
|
|
2474
|
-
]) {
|
|
2475
|
-
if (!match2[1].startsWith("."))
|
|
2476
|
-
continue;
|
|
2477
|
-
yield* getDeps(match2[1], base, seen, ext);
|
|
2478
|
-
}
|
|
2479
|
-
}
|
|
2480
|
-
function getModuleDependencies(filePath) {
|
|
2481
|
-
if (filePath === null)
|
|
2482
|
-
return /* @__PURE__ */ new Set();
|
|
2483
|
-
return new Set(getDeps(filePath, import_path2.default.dirname(filePath), /* @__PURE__ */ new Set()));
|
|
2484
|
-
}
|
|
2485
|
-
|
|
2486
2360
|
// src/parse-dependency.ts
|
|
2487
2361
|
init_cjs_shims();
|
|
2488
2362
|
var import_is_glob = __toESM(require("is-glob"));
|
|
2489
|
-
var
|
|
2363
|
+
var import_path2 = require("path");
|
|
2490
2364
|
|
|
2491
2365
|
// src/parse-glob.ts
|
|
2492
2366
|
init_cjs_shims();
|
|
@@ -2517,9 +2391,9 @@ function parseDependency(fileOrGlob) {
|
|
|
2517
2391
|
let message = null;
|
|
2518
2392
|
if ((0, import_is_glob.default)(fileOrGlob)) {
|
|
2519
2393
|
const { base, glob: glob2 } = parseGlob(fileOrGlob);
|
|
2520
|
-
message = { type: "dir-dependency", dir: (0,
|
|
2394
|
+
message = { type: "dir-dependency", dir: (0, import_path2.resolve)(base), glob: glob2 };
|
|
2521
2395
|
} else {
|
|
2522
|
-
message = { type: "dependency", file: (0,
|
|
2396
|
+
message = { type: "dependency", file: (0, import_path2.resolve)(fileOrGlob) };
|
|
2523
2397
|
}
|
|
2524
2398
|
if (message.type === "dir-dependency" && process.env.ROLLUP_WATCH === "true") {
|
|
2525
2399
|
message = { type: "dependency", file: message.dir };
|
|
@@ -2559,7 +2433,7 @@ var Builder = class {
|
|
|
2559
2433
|
delete require.cache[file];
|
|
2560
2434
|
}
|
|
2561
2435
|
if (setupCount > 0) {
|
|
2562
|
-
import_logger4.logger.
|
|
2436
|
+
import_logger4.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2563
2437
|
}
|
|
2564
2438
|
return { isModified: true, modifiedMap: newModified };
|
|
2565
2439
|
}
|
|
@@ -2570,15 +2444,18 @@ var Builder = class {
|
|
|
2570
2444
|
}
|
|
2571
2445
|
return configPath;
|
|
2572
2446
|
}
|
|
2573
|
-
async setup() {
|
|
2574
|
-
|
|
2575
|
-
const
|
|
2447
|
+
async setup(options = {}) {
|
|
2448
|
+
import_logger4.logger.debug("builder", "\u{1F6A7} Setup");
|
|
2449
|
+
const configPath = options.configPath ?? this.getConfigPath();
|
|
2450
|
+
const { deps: configDeps } = (0, import_config2.getConfigDependencies)(configPath);
|
|
2576
2451
|
const deps = this.checkConfigDeps(configPath, configDeps);
|
|
2577
2452
|
if (deps.isModified) {
|
|
2578
|
-
|
|
2453
|
+
await this.setupContext({
|
|
2579
2454
|
configPath,
|
|
2580
2455
|
depsModifiedMap: deps.modifiedMap
|
|
2581
2456
|
});
|
|
2457
|
+
const updatedCtx = this.context;
|
|
2458
|
+
await updatedCtx.hooks.callHook("config:change", updatedCtx.config);
|
|
2582
2459
|
}
|
|
2583
2460
|
const cache = configCache.get(configPath);
|
|
2584
2461
|
if (cache) {
|
|
@@ -2600,7 +2477,7 @@ var Builder = class {
|
|
|
2600
2477
|
}
|
|
2601
2478
|
configCache.set(configPath, {
|
|
2602
2479
|
context: this.context,
|
|
2603
|
-
deps: new Set(this.context.
|
|
2480
|
+
deps: new Set(this.context.dependencies ?? []),
|
|
2604
2481
|
depsModifiedMap
|
|
2605
2482
|
});
|
|
2606
2483
|
contentFilesCache.set(this.context, {
|
|
@@ -2623,7 +2500,7 @@ var Builder = class {
|
|
|
2623
2500
|
return contentFilesCache.get(ctx).fileCssMap;
|
|
2624
2501
|
}
|
|
2625
2502
|
async extractFile(ctx, file) {
|
|
2626
|
-
const mtime = (0,
|
|
2503
|
+
const mtime = (0, import_fs.existsSync)(file) ? (0, import_fs_extra2.statSync)(file).mtimeMs : -Infinity;
|
|
2627
2504
|
const isUnchanged = this.fileModifiedMap.has(file) && mtime === this.fileModifiedMap.get(file);
|
|
2628
2505
|
if (isUnchanged)
|
|
2629
2506
|
return;
|
|
@@ -2677,7 +2554,7 @@ var Builder = class {
|
|
|
2677
2554
|
}
|
|
2678
2555
|
}
|
|
2679
2556
|
for (const file of ctx.dependencies) {
|
|
2680
|
-
fn({ type: "dependency", file: (0,
|
|
2557
|
+
fn({ type: "dependency", file: (0, import_path3.resolve)(file) });
|
|
2681
2558
|
}
|
|
2682
2559
|
}
|
|
2683
2560
|
};
|
|
@@ -2685,17 +2562,18 @@ var Builder = class {
|
|
|
2685
2562
|
// src/debug-files.ts
|
|
2686
2563
|
init_cjs_shims();
|
|
2687
2564
|
var import_logger5 = require("@pandacss/logger");
|
|
2688
|
-
var
|
|
2689
|
-
var path2 = __toESM(require("path"));
|
|
2565
|
+
var nodePath = __toESM(require("path"));
|
|
2690
2566
|
async function debugFiles(ctx, options) {
|
|
2691
2567
|
const files = ctx.getFiles();
|
|
2692
2568
|
const measureTotal = import_logger5.logger.time.debug(`Done parsing ${files.length} files`);
|
|
2693
2569
|
ctx.config.minify = false;
|
|
2694
2570
|
ctx.config.optimize = true;
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2571
|
+
const { fs, path: path2 } = ctx.runtime;
|
|
2572
|
+
const outdir = options.outdir;
|
|
2573
|
+
if (!options.dry && outdir) {
|
|
2574
|
+
fs.ensureDirSync(outdir);
|
|
2575
|
+
import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/config.json`)}`);
|
|
2576
|
+
await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2699
2577
|
}
|
|
2700
2578
|
const filesWithCss = [];
|
|
2701
2579
|
await Promise.all(
|
|
@@ -2705,18 +2583,7 @@ async function debugFiles(ctx, options) {
|
|
|
2705
2583
|
measure();
|
|
2706
2584
|
if (!result)
|
|
2707
2585
|
return;
|
|
2708
|
-
const list = result.
|
|
2709
|
-
const node = result2.box.getNode();
|
|
2710
|
-
const range = getNodeRange(node);
|
|
2711
|
-
return {
|
|
2712
|
-
name: result2.name,
|
|
2713
|
-
type: result2.type,
|
|
2714
|
-
data: result2.data,
|
|
2715
|
-
kind: node.getKindName(),
|
|
2716
|
-
line: range.startLineNumber,
|
|
2717
|
-
column: range.startColumn
|
|
2718
|
-
};
|
|
2719
|
-
});
|
|
2586
|
+
const list = result.toArray().map((resultItem) => resultItem.box?.toJSON?.() ?? resultItem);
|
|
2720
2587
|
const css = ctx.getParserCss(result);
|
|
2721
2588
|
if (!css)
|
|
2722
2589
|
return;
|
|
@@ -2724,17 +2591,17 @@ async function debugFiles(ctx, options) {
|
|
|
2724
2591
|
console.log({ path: file, ast: list, code: css });
|
|
2725
2592
|
return Promise.resolve();
|
|
2726
2593
|
}
|
|
2727
|
-
if (
|
|
2594
|
+
if (outdir) {
|
|
2728
2595
|
filesWithCss.push(file);
|
|
2729
|
-
const parsedPath =
|
|
2596
|
+
const parsedPath = nodePath.parse(file);
|
|
2730
2597
|
const relative3 = path2.relative(ctx.config.cwd, parsedPath.dir);
|
|
2731
2598
|
const astJsonPath = `${relative3}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
|
|
2732
2599
|
const cssPath = `${relative3}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
|
|
2733
|
-
import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${
|
|
2734
|
-
import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${
|
|
2600
|
+
import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2601
|
+
import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/${cssPath}`)}`);
|
|
2735
2602
|
return Promise.all([
|
|
2736
|
-
|
|
2737
|
-
|
|
2603
|
+
fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(list, debugResultSerializer, 2)),
|
|
2604
|
+
fs.writeFile(`${outdir}/${cssPath}`, css)
|
|
2738
2605
|
]);
|
|
2739
2606
|
}
|
|
2740
2607
|
})
|
|
@@ -2797,22 +2664,23 @@ async function generate(config, configPath) {
|
|
|
2797
2664
|
const ctx = ctxRef.current;
|
|
2798
2665
|
await build(ctx);
|
|
2799
2666
|
const {
|
|
2800
|
-
runtime: { fs
|
|
2667
|
+
runtime: { fs, path: path2 },
|
|
2801
2668
|
dependencies,
|
|
2802
2669
|
config: { cwd }
|
|
2803
2670
|
} = ctx;
|
|
2804
2671
|
if (ctx.config.watch) {
|
|
2805
|
-
const configWatcher =
|
|
2672
|
+
const configWatcher = fs.watch({ include: dependencies });
|
|
2806
2673
|
configWatcher.on("change", async () => {
|
|
2807
2674
|
import_logger7.logger.info("config:change", "Config changed, restarting...");
|
|
2808
2675
|
await loadCtx();
|
|
2676
|
+
await ctxRef.current.hooks.callHook("config:change", ctxRef.current.config);
|
|
2809
2677
|
return build(ctxRef.current);
|
|
2810
2678
|
});
|
|
2811
|
-
const contentWatcher =
|
|
2679
|
+
const contentWatcher = fs.watch(ctx.config);
|
|
2812
2680
|
contentWatcher.on("all", async (event, file) => {
|
|
2813
2681
|
import_logger7.logger.info(`file:${event}`, file);
|
|
2814
2682
|
(0, import_ts_pattern.match)(event).with("unlink", () => {
|
|
2815
|
-
ctx.project.removeSourceFile(
|
|
2683
|
+
ctx.project.removeSourceFile(path2.abs(cwd, file));
|
|
2816
2684
|
ctx.chunks.rm(file);
|
|
2817
2685
|
}).with("change", async () => {
|
|
2818
2686
|
ctx.project.reloadSourceFile(file);
|
|
@@ -2830,23 +2698,26 @@ async function generate(config, configPath) {
|
|
|
2830
2698
|
|
|
2831
2699
|
// src/git-ignore.ts
|
|
2832
2700
|
init_cjs_shims();
|
|
2833
|
-
var
|
|
2701
|
+
var import_fs2 = require("fs");
|
|
2834
2702
|
var import_look_it_up2 = require("look-it-up");
|
|
2835
2703
|
var import_outdent = __toESM(require("outdent"));
|
|
2836
|
-
function setupGitIgnore(
|
|
2704
|
+
function setupGitIgnore(ctx) {
|
|
2705
|
+
const { outdir, gitignore } = ctx.config;
|
|
2837
2706
|
if (!gitignore)
|
|
2838
2707
|
return;
|
|
2839
|
-
const txt = import_outdent.default
|
|
2708
|
+
const txt = import_outdent.default`
|
|
2709
|
+
|
|
2710
|
+
## Panda
|
|
2840
2711
|
${outdir}
|
|
2841
|
-
${outdir}
|
|
2712
|
+
${ctx.studio.outdir}
|
|
2842
2713
|
`;
|
|
2843
2714
|
const file = (0, import_look_it_up2.lookItUpSync)(".gitignore");
|
|
2844
2715
|
if (!file) {
|
|
2845
|
-
return (0,
|
|
2716
|
+
return (0, import_fs2.writeFileSync)(".gitignore", txt);
|
|
2846
2717
|
}
|
|
2847
|
-
const content = (0,
|
|
2718
|
+
const content = (0, import_fs2.readFileSync)(file, "utf-8");
|
|
2848
2719
|
if (!content.includes(outdir)) {
|
|
2849
|
-
(0,
|
|
2720
|
+
(0, import_fs2.appendFileSync)(file, txt);
|
|
2850
2721
|
}
|
|
2851
2722
|
}
|
|
2852
2723
|
|
|
@@ -2857,9 +2728,10 @@ var import_generator2 = require("@pandacss/generator");
|
|
|
2857
2728
|
var import_fs_extra3 = require("fs-extra");
|
|
2858
2729
|
var import_look_it_up3 = require("look-it-up");
|
|
2859
2730
|
var import_outdent2 = require("outdent");
|
|
2860
|
-
var
|
|
2731
|
+
var import_path4 = require("path");
|
|
2861
2732
|
var import_preferred_pm2 = __toESM(require("preferred-pm"));
|
|
2862
|
-
async function setupConfig(cwd,
|
|
2733
|
+
async function setupConfig(cwd, opts = {}) {
|
|
2734
|
+
const { force, outExtension, jsxFramework } = opts;
|
|
2863
2735
|
const configFile = findConfig();
|
|
2864
2736
|
const pmResult = await (0, import_preferred_pm2.default)(cwd);
|
|
2865
2737
|
const pm = pmResult?.name ?? "npm";
|
|
@@ -2871,36 +2743,74 @@ async function setupConfig(cwd, { force }) {
|
|
|
2871
2743
|
import_logger8.logger.warn("init:config", import_generator2.messages.configExists(cmd));
|
|
2872
2744
|
} else {
|
|
2873
2745
|
const content = import_outdent2.outdent`
|
|
2874
|
-
|
|
2746
|
+
import { defineConfig } from "@pandacss/dev"
|
|
2747
|
+
|
|
2748
|
+
export default defineConfig({
|
|
2749
|
+
// Whether to use css reset
|
|
2750
|
+
preflight: true,
|
|
2751
|
+
${outExtension ? `
|
|
2752
|
+
// The extension for the emitted JavaScript files
|
|
2753
|
+
outExtension: '${outExtension}',` : ""}
|
|
2754
|
+
// Where to look for your css declarations
|
|
2755
|
+
include: ["./src/**/*.{js,jsx,ts,tsx}", "./pages/**/*.{js,jsx,ts,tsx}"],
|
|
2756
|
+
|
|
2757
|
+
// Files to exclude
|
|
2758
|
+
exclude: [],
|
|
2875
2759
|
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
outdir: "styled-system",
|
|
2888
|
-
})
|
|
2760
|
+
// Useful for theme customization
|
|
2761
|
+
theme: {
|
|
2762
|
+
extend: {}
|
|
2763
|
+
},
|
|
2764
|
+
|
|
2765
|
+
// The output directory for your css system
|
|
2766
|
+
outdir: "styled-system",
|
|
2767
|
+
${jsxFramework ? `
|
|
2768
|
+
// The JSX framework to use
|
|
2769
|
+
jsxFramework: '${jsxFramework}'` : ""}
|
|
2770
|
+
})
|
|
2889
2771
|
`;
|
|
2890
|
-
await (0, import_fs_extra3.writeFile)((0,
|
|
2772
|
+
await (0, import_fs_extra3.writeFile)((0, import_path4.join)(cwd, file), content);
|
|
2891
2773
|
import_logger8.logger.log(import_generator2.messages.thankYou());
|
|
2892
2774
|
}
|
|
2893
2775
|
}
|
|
2894
2776
|
async function setupPostcss(cwd) {
|
|
2895
2777
|
import_logger8.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger8.quote)("postcss.config.cjs")}`);
|
|
2896
2778
|
const content = import_outdent2.outdent`
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2779
|
+
module.exports = {
|
|
2780
|
+
plugins: {
|
|
2781
|
+
'@pandacss/dev/postcss': {},
|
|
2782
|
+
},
|
|
2783
|
+
}
|
|
2902
2784
|
`;
|
|
2903
|
-
await (0, import_fs_extra3.writeFile)((0,
|
|
2785
|
+
await (0, import_fs_extra3.writeFile)((0, import_path4.join)(cwd, "postcss.config.cjs"), content);
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
// src/ship-files.ts
|
|
2789
|
+
init_cjs_shims();
|
|
2790
|
+
var import_logger9 = require("@pandacss/logger");
|
|
2791
|
+
var import_parser2 = require("@pandacss/parser");
|
|
2792
|
+
var import_promises2 = require("fs/promises");
|
|
2793
|
+
var path = __toESM(require("path"));
|
|
2794
|
+
async function shipFiles(ctx, outfile) {
|
|
2795
|
+
const files = ctx.getFiles();
|
|
2796
|
+
const extractResult = (0, import_parser2.createParserResult)();
|
|
2797
|
+
const filesWithCss = [];
|
|
2798
|
+
files.forEach(async (file) => {
|
|
2799
|
+
const result = ctx.project.parseSourceFile(file);
|
|
2800
|
+
if (!result || result.isEmpty())
|
|
2801
|
+
return;
|
|
2802
|
+
const css = ctx.getParserCss(result);
|
|
2803
|
+
if (!css)
|
|
2804
|
+
return;
|
|
2805
|
+
extractResult.merge(result);
|
|
2806
|
+
filesWithCss.push(path.relative(ctx.config.cwd, file));
|
|
2807
|
+
});
|
|
2808
|
+
import_logger9.logger.info("cli", `Found ${import_logger9.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
2809
|
+
const minify = ctx.config.minify;
|
|
2810
|
+
import_logger9.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger9.colors.bold(outfile)}`);
|
|
2811
|
+
const output = JSON.stringify(extractResult.toJSON(), null, minify ? 0 : 2);
|
|
2812
|
+
await (0, import_promises2.writeFile)(outfile, output);
|
|
2813
|
+
import_logger9.logger.info("cli", "Done!");
|
|
2904
2814
|
}
|
|
2905
2815
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2906
2816
|
0 && (module.exports = {
|
|
@@ -2913,10 +2823,14 @@ async function setupPostcss(cwd) {
|
|
|
2913
2823
|
emitArtifacts,
|
|
2914
2824
|
execCommand,
|
|
2915
2825
|
extractCss,
|
|
2826
|
+
extractFile,
|
|
2827
|
+
findConfig,
|
|
2916
2828
|
generate,
|
|
2917
2829
|
loadConfigAndCreateContext,
|
|
2830
|
+
parseDependency,
|
|
2918
2831
|
setupConfig,
|
|
2919
2832
|
setupGitIgnore,
|
|
2920
2833
|
setupPostcss,
|
|
2834
|
+
shipFiles,
|
|
2921
2835
|
writeAnalyzeJSON
|
|
2922
2836
|
});
|