@pandacss/node 0.23.0 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +61 -50
- package/dist/index.d.ts +61 -50
- package/dist/index.js +511 -547
- package/dist/index.mjs +508 -542
- package/package.json +20 -16
package/dist/index.js
CHANGED
|
@@ -11,9 +11,9 @@ var __esm = (fn, res) => function __init() {
|
|
|
11
11
|
var __commonJS = (cb, mod) => function __require() {
|
|
12
12
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
13
|
};
|
|
14
|
-
var __export = (target,
|
|
15
|
-
for (var name in
|
|
16
|
-
__defProp(target, name, { get:
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
17
|
};
|
|
18
18
|
var __copyProps = (to, from, except, desc) => {
|
|
19
19
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/.pnpm/tsup@
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.0.1_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@
|
|
38
|
+
"../../node_modules/.pnpm/tsup@8.0.1_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
39
|
"use strict";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -406,18 +406,16 @@ __export(src_exports, {
|
|
|
406
406
|
Builder: () => Builder,
|
|
407
407
|
PandaContext: () => PandaContext,
|
|
408
408
|
analyzeTokens: () => analyzeTokens,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
findConfig: () => findConfig,
|
|
409
|
+
buildInfo: () => buildInfo,
|
|
410
|
+
codegen: () => codegen,
|
|
411
|
+
cssgen: () => cssgen,
|
|
412
|
+
debug: () => debug,
|
|
414
413
|
generate: () => generate,
|
|
415
414
|
loadConfigAndCreateContext: () => loadConfigAndCreateContext,
|
|
416
415
|
parseDependency: () => parseDependency,
|
|
417
416
|
setupConfig: () => setupConfig,
|
|
418
417
|
setupGitIgnore: () => setupGitIgnore,
|
|
419
418
|
setupPostcss: () => setupPostcss,
|
|
420
|
-
shipFiles: () => shipFiles,
|
|
421
419
|
writeAnalyzeJSON: () => writeAnalyzeJSON
|
|
422
420
|
});
|
|
423
421
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -714,7 +712,7 @@ function analyzeTokens(ctx, options = {}) {
|
|
|
714
712
|
const minify = ctx.config.minify;
|
|
715
713
|
ctx.config.optimize = true;
|
|
716
714
|
ctx.config.minify = false;
|
|
717
|
-
const
|
|
715
|
+
const css = "";
|
|
718
716
|
const minifiedCss = "";
|
|
719
717
|
ctx.config.minify = minify;
|
|
720
718
|
const start = performance.now();
|
|
@@ -728,11 +726,11 @@ function analyzeTokens(ctx, options = {}) {
|
|
|
728
726
|
classify: classifyMs
|
|
729
727
|
},
|
|
730
728
|
fileSizes: {
|
|
731
|
-
lineCount:
|
|
732
|
-
normal: (0, import_filesize.filesize)(Buffer.byteLength(
|
|
729
|
+
lineCount: css.split("\n").length,
|
|
730
|
+
normal: (0, import_filesize.filesize)(Buffer.byteLength(css, "utf-8")),
|
|
733
731
|
minified: (0, import_filesize.filesize)(Buffer.byteLength(minifiedCss, "utf-8")),
|
|
734
732
|
gzip: {
|
|
735
|
-
normal: (0, import_filesize.filesize)(gzipSizeSync(
|
|
733
|
+
normal: (0, import_filesize.filesize)(gzipSizeSync(css)),
|
|
736
734
|
minified: (0, import_filesize.filesize)(gzipSizeSync(minifiedCss))
|
|
737
735
|
}
|
|
738
736
|
}
|
|
@@ -772,13 +770,42 @@ var writeAnalyzeJSON = (filePath, result, ctx) => {
|
|
|
772
770
|
);
|
|
773
771
|
};
|
|
774
772
|
|
|
773
|
+
// src/build-info.ts
|
|
774
|
+
init_cjs_shims();
|
|
775
|
+
var import_logger2 = require("@pandacss/logger");
|
|
776
|
+
|
|
777
|
+
// package.json
|
|
778
|
+
var version = "0.24.1";
|
|
779
|
+
|
|
780
|
+
// src/build-info.ts
|
|
781
|
+
async function buildInfo(ctx, outfile) {
|
|
782
|
+
const { filesWithCss, files } = ctx.parseFiles();
|
|
783
|
+
import_logger2.logger.info("cli", `Found ${import_logger2.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
784
|
+
const minify = ctx.config.minify;
|
|
785
|
+
import_logger2.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger2.colors.bold(outfile)}`);
|
|
786
|
+
const output = JSON.stringify(
|
|
787
|
+
{
|
|
788
|
+
schemaVersion: version,
|
|
789
|
+
styles: ctx.encoder.toJSON()
|
|
790
|
+
},
|
|
791
|
+
null,
|
|
792
|
+
minify ? 0 : 2
|
|
793
|
+
);
|
|
794
|
+
ctx.output.ensure(outfile, process.cwd());
|
|
795
|
+
await ctx.runtime.fs.writeFile(outfile, output);
|
|
796
|
+
import_logger2.logger.info("cli", "Done!");
|
|
797
|
+
}
|
|
798
|
+
|
|
775
799
|
// src/builder.ts
|
|
776
800
|
init_cjs_shims();
|
|
801
|
+
var import_config3 = require("@pandacss/config");
|
|
777
802
|
var import_core = require("@pandacss/core");
|
|
778
803
|
var import_error = require("@pandacss/error");
|
|
779
804
|
var import_logger6 = require("@pandacss/logger");
|
|
780
805
|
var import_fs = require("fs");
|
|
781
|
-
|
|
806
|
+
|
|
807
|
+
// src/codegen.ts
|
|
808
|
+
init_cjs_shims();
|
|
782
809
|
|
|
783
810
|
// ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
784
811
|
init_cjs_shims();
|
|
@@ -887,372 +914,6 @@ function pLimit(concurrency) {
|
|
|
887
914
|
return generator;
|
|
888
915
|
}
|
|
889
916
|
|
|
890
|
-
// src/builder.ts
|
|
891
|
-
var import_pathe3 = require("pathe");
|
|
892
|
-
|
|
893
|
-
// src/config.ts
|
|
894
|
-
init_cjs_shims();
|
|
895
|
-
var import_config2 = require("@pandacss/config");
|
|
896
|
-
var import_hookable = require("hookable");
|
|
897
|
-
var import_look_it_up = require("look-it-up");
|
|
898
|
-
var import_tsconfck = require("tsconfck");
|
|
899
|
-
|
|
900
|
-
// src/create-context.ts
|
|
901
|
-
init_cjs_shims();
|
|
902
|
-
var import_generator2 = require("@pandacss/generator");
|
|
903
|
-
var import_logger4 = require("@pandacss/logger");
|
|
904
|
-
var import_parser = require("@pandacss/parser");
|
|
905
|
-
|
|
906
|
-
// src/diff-engine.ts
|
|
907
|
-
init_cjs_shims();
|
|
908
|
-
var import_config = require("@pandacss/config");
|
|
909
|
-
var import_generator = require("@pandacss/generator");
|
|
910
|
-
var import_shared = require("@pandacss/shared");
|
|
911
|
-
var import_microdiff = __toESM(require("microdiff"));
|
|
912
|
-
|
|
913
|
-
// src/matcher.ts
|
|
914
|
-
init_cjs_shims();
|
|
915
|
-
function createMatcher(id, patterns) {
|
|
916
|
-
if (!patterns?.length)
|
|
917
|
-
return () => void 0;
|
|
918
|
-
const includePatterns = [];
|
|
919
|
-
const excludePatterns = [];
|
|
920
|
-
const deduped = new Set(patterns);
|
|
921
|
-
deduped.forEach((pattern) => {
|
|
922
|
-
const regexString = pattern.replace(/\*/g, ".*");
|
|
923
|
-
if (pattern.startsWith("!")) {
|
|
924
|
-
excludePatterns.push(regexString.slice(1));
|
|
925
|
-
} else {
|
|
926
|
-
includePatterns.push(regexString);
|
|
927
|
-
}
|
|
928
|
-
});
|
|
929
|
-
const include = new RegExp(includePatterns.join("|"));
|
|
930
|
-
const exclude = new RegExp(excludePatterns.join("|"));
|
|
931
|
-
return (path2) => {
|
|
932
|
-
if (excludePatterns.length && exclude.test(path2))
|
|
933
|
-
return;
|
|
934
|
-
return include.test(path2) ? id : void 0;
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
// src/diff-engine.ts
|
|
939
|
-
var all = ["outdir", "forceConsistentTypeExtension", "outExtension"];
|
|
940
|
-
var format = ["syntax", "hash", "prefix", "separator"];
|
|
941
|
-
var tokens = ["utilities", "conditions", "theme.tokens", "theme.semanticTokens", "theme.breakpoints"];
|
|
942
|
-
var jsx = ["jsxFramework", "jsxFactory", "jsxStyleProps", "syntax"];
|
|
943
|
-
var css = ["layers", "optimize", "minify"];
|
|
944
|
-
var common = tokens.concat(jsx, format);
|
|
945
|
-
var artifactConfigDeps = {
|
|
946
|
-
helpers: ["syntax", "jsxFramework"],
|
|
947
|
-
keyframes: ["theme.keyframes", "layers"],
|
|
948
|
-
"design-tokens": ["layers", "!utilities.*.className"].concat(tokens),
|
|
949
|
-
types: ["!utilities.*.className"].concat(common),
|
|
950
|
-
"css-fn": common,
|
|
951
|
-
cva: ["syntax"],
|
|
952
|
-
sva: ["syntax"],
|
|
953
|
-
cx: [],
|
|
954
|
-
"create-recipe": ["separator", "prefix", "hash"],
|
|
955
|
-
"recipes-index": ["theme.recipes", "theme.slotRecipes"],
|
|
956
|
-
recipes: ["theme.recipes", "theme.slotRecipes"],
|
|
957
|
-
"patterns-index": ["syntax", "patterns"],
|
|
958
|
-
patterns: ["syntax", "patterns"],
|
|
959
|
-
"jsx-is-valid-prop": common,
|
|
960
|
-
"jsx-factory": jsx,
|
|
961
|
-
"jsx-helpers": jsx,
|
|
962
|
-
"jsx-patterns": jsx.concat("patterns"),
|
|
963
|
-
"jsx-patterns-index": jsx.concat("patterns"),
|
|
964
|
-
"css-index": ["syntax"],
|
|
965
|
-
"reset.css": ["preflight", "layers"],
|
|
966
|
-
"global.css": ["globalCss"].concat(css),
|
|
967
|
-
"static.css": ["staticCss", "theme.breakpoints"].concat(css),
|
|
968
|
-
"styles.css": tokens.concat(format),
|
|
969
|
-
"package.json": ["emitPackage"]
|
|
970
|
-
};
|
|
971
|
-
var configDeps = {
|
|
972
|
-
artifacts: artifactConfigDeps
|
|
973
|
-
};
|
|
974
|
-
var matchers = {
|
|
975
|
-
artifacts: Object.keys(configDeps.artifacts).map((key) => {
|
|
976
|
-
const paths = configDeps.artifacts[key];
|
|
977
|
-
if (!paths.length)
|
|
978
|
-
return () => void 0;
|
|
979
|
-
return createMatcher(key, paths.concat(all));
|
|
980
|
-
})
|
|
981
|
-
};
|
|
982
|
-
var DiffEngine = class {
|
|
983
|
-
constructor(ctx) {
|
|
984
|
-
this.ctx = ctx;
|
|
985
|
-
this.previousConfig = ctx.conf.deserialize();
|
|
986
|
-
}
|
|
987
|
-
previousConfig;
|
|
988
|
-
/**
|
|
989
|
-
* Reload config from disk and refresh the context
|
|
990
|
-
*/
|
|
991
|
-
async reloadConfigAndRefreshContext(fn) {
|
|
992
|
-
const conf = await (0, import_config.loadConfigFile)({ cwd: this.ctx.config.cwd, file: this.ctx.conf.path });
|
|
993
|
-
return this.refresh(conf, fn);
|
|
994
|
-
}
|
|
995
|
-
/**
|
|
996
|
-
* Update the context from the refreshed config
|
|
997
|
-
* then persist the changes on each affected engines
|
|
998
|
-
* Returns the list of affected artifacts/engines
|
|
999
|
-
*/
|
|
1000
|
-
refresh(conf, fn) {
|
|
1001
|
-
const affected = {
|
|
1002
|
-
artifacts: /* @__PURE__ */ new Set(),
|
|
1003
|
-
hasConfigChanged: false,
|
|
1004
|
-
diffs: []
|
|
1005
|
-
};
|
|
1006
|
-
if (!this.previousConfig) {
|
|
1007
|
-
affected.hasConfigChanged = true;
|
|
1008
|
-
return affected;
|
|
1009
|
-
}
|
|
1010
|
-
const newConfig = conf.deserialize();
|
|
1011
|
-
const configDiff = (0, import_microdiff.default)(this.previousConfig, newConfig);
|
|
1012
|
-
if (!configDiff.length) {
|
|
1013
|
-
return affected;
|
|
1014
|
-
}
|
|
1015
|
-
affected.hasConfigChanged = true;
|
|
1016
|
-
affected.diffs = configDiff;
|
|
1017
|
-
this.previousConfig = newConfig;
|
|
1018
|
-
fn?.(conf);
|
|
1019
|
-
configDiff.forEach((change) => {
|
|
1020
|
-
const changePath = change.path.join(".");
|
|
1021
|
-
matchers.artifacts.forEach((matcher) => {
|
|
1022
|
-
const id = matcher(changePath);
|
|
1023
|
-
if (!id)
|
|
1024
|
-
return;
|
|
1025
|
-
if (id === "recipes") {
|
|
1026
|
-
const name = (0, import_shared.dashCase)(change.path.slice(1, 3).join("."));
|
|
1027
|
-
affected.artifacts.add(name);
|
|
1028
|
-
}
|
|
1029
|
-
if (id === "patterns") {
|
|
1030
|
-
const name = (0, import_shared.dashCase)(change.path.slice(0, 2).join("."));
|
|
1031
|
-
affected.artifacts.add(name);
|
|
1032
|
-
}
|
|
1033
|
-
affected.artifacts.add(id);
|
|
1034
|
-
});
|
|
1035
|
-
});
|
|
1036
|
-
return affected;
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
|
|
1040
|
-
// src/node-runtime.ts
|
|
1041
|
-
init_cjs_shims();
|
|
1042
|
-
var import_logger2 = require("@pandacss/logger");
|
|
1043
|
-
var import_chokidar = __toESM(require("chokidar"));
|
|
1044
|
-
var import_fast_glob = __toESM(require("fast-glob"));
|
|
1045
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1046
|
-
var import_pathe = require("pathe");
|
|
1047
|
-
var nodeRuntime = {
|
|
1048
|
-
cwd() {
|
|
1049
|
-
return process.cwd();
|
|
1050
|
-
},
|
|
1051
|
-
env(name) {
|
|
1052
|
-
return process.env[name];
|
|
1053
|
-
},
|
|
1054
|
-
path: {
|
|
1055
|
-
join: import_pathe.join,
|
|
1056
|
-
relative: import_pathe.relative,
|
|
1057
|
-
dirname: import_pathe.dirname,
|
|
1058
|
-
extname: import_pathe.extname,
|
|
1059
|
-
isAbsolute: import_pathe.isAbsolute,
|
|
1060
|
-
sep: import_pathe.sep,
|
|
1061
|
-
abs(cwd, str) {
|
|
1062
|
-
return (0, import_pathe.isAbsolute)(str) ? str : (0, import_pathe.join)(cwd, str);
|
|
1063
|
-
}
|
|
1064
|
-
},
|
|
1065
|
-
fs: {
|
|
1066
|
-
existsSync: import_fs_extra.default.existsSync,
|
|
1067
|
-
readFileSync(filePath) {
|
|
1068
|
-
return import_fs_extra.default.readFileSync(filePath, "utf8");
|
|
1069
|
-
},
|
|
1070
|
-
glob(opts) {
|
|
1071
|
-
if (!opts.include)
|
|
1072
|
-
return [];
|
|
1073
|
-
const ignore = opts.exclude ?? [];
|
|
1074
|
-
if (!ignore.length) {
|
|
1075
|
-
ignore.push("**/*.d.ts");
|
|
1076
|
-
}
|
|
1077
|
-
return import_fast_glob.default.sync(opts.include, { cwd: opts.cwd, ignore, absolute: true });
|
|
1078
|
-
},
|
|
1079
|
-
writeFile: import_fs_extra.default.writeFile,
|
|
1080
|
-
writeFileSync: import_fs_extra.default.writeFileSync,
|
|
1081
|
-
readDirSync: import_fs_extra.default.readdirSync,
|
|
1082
|
-
rmDirSync: import_fs_extra.default.emptyDirSync,
|
|
1083
|
-
rmFileSync: import_fs_extra.default.removeSync,
|
|
1084
|
-
ensureDirSync(path2) {
|
|
1085
|
-
return import_fs_extra.default.ensureDirSync(path2);
|
|
1086
|
-
},
|
|
1087
|
-
watch(options) {
|
|
1088
|
-
const { include, exclude, cwd, poll } = options;
|
|
1089
|
-
const coalesce = poll || process.platform === "win32";
|
|
1090
|
-
const watcher = import_chokidar.default.watch(include, {
|
|
1091
|
-
usePolling: poll,
|
|
1092
|
-
cwd,
|
|
1093
|
-
ignoreInitial: true,
|
|
1094
|
-
ignorePermissionErrors: true,
|
|
1095
|
-
ignored: exclude,
|
|
1096
|
-
awaitWriteFinish: coalesce ? { stabilityThreshold: 50, pollInterval: 10 } : false
|
|
1097
|
-
});
|
|
1098
|
-
import_logger2.logger.debug("watch:file", `watching [${include}]`);
|
|
1099
|
-
process.once("SIGINT", async () => {
|
|
1100
|
-
await watcher.close();
|
|
1101
|
-
});
|
|
1102
|
-
return watcher;
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
process.setMaxListeners(Infinity);
|
|
1107
|
-
process.on("unhandledRejection", (reason) => {
|
|
1108
|
-
import_logger2.logger.error("\u274C", reason);
|
|
1109
|
-
});
|
|
1110
|
-
process.on("uncaughtException", (reason) => {
|
|
1111
|
-
import_logger2.logger.error("\u274C", reason);
|
|
1112
|
-
});
|
|
1113
|
-
|
|
1114
|
-
// src/output-engine.ts
|
|
1115
|
-
init_cjs_shims();
|
|
1116
|
-
var import_logger3 = require("@pandacss/logger");
|
|
1117
|
-
var PandaOutputEngine = class {
|
|
1118
|
-
paths;
|
|
1119
|
-
fs;
|
|
1120
|
-
path;
|
|
1121
|
-
constructor({ paths, runtime: { path: path2, fs } }) {
|
|
1122
|
-
this.paths = paths;
|
|
1123
|
-
this.fs = fs;
|
|
1124
|
-
this.path = path2;
|
|
1125
|
-
}
|
|
1126
|
-
empty() {
|
|
1127
|
-
this.fs.rmDirSync(this.path.join(...this.paths.root));
|
|
1128
|
-
}
|
|
1129
|
-
async write(output) {
|
|
1130
|
-
if (!output)
|
|
1131
|
-
return;
|
|
1132
|
-
const { dir = this.paths.root, files } = output;
|
|
1133
|
-
this.fs.ensureDirSync(this.path.join(...dir));
|
|
1134
|
-
return Promise.allSettled(
|
|
1135
|
-
files.map(async (artifact) => {
|
|
1136
|
-
if (!artifact?.code)
|
|
1137
|
-
return;
|
|
1138
|
-
const { file, code } = artifact;
|
|
1139
|
-
const absPath = this.path.join(...dir, file);
|
|
1140
|
-
import_logger3.logger.debug("write:file", dir.slice(-1).concat(file).join("/"));
|
|
1141
|
-
return this.fs.writeFile(absPath, code);
|
|
1142
|
-
})
|
|
1143
|
-
);
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1146
|
-
|
|
1147
|
-
// src/create-context.ts
|
|
1148
|
-
var PandaContext = class extends import_generator2.Generator {
|
|
1149
|
-
runtime;
|
|
1150
|
-
project;
|
|
1151
|
-
getFiles;
|
|
1152
|
-
output;
|
|
1153
|
-
diff;
|
|
1154
|
-
constructor(conf) {
|
|
1155
|
-
super(conf);
|
|
1156
|
-
const config = conf.config;
|
|
1157
|
-
this.runtime = nodeRuntime;
|
|
1158
|
-
config.cwd ||= this.runtime.cwd();
|
|
1159
|
-
if (config.logLevel) {
|
|
1160
|
-
import_logger4.logger.level = config.logLevel;
|
|
1161
|
-
}
|
|
1162
|
-
const { include, exclude, cwd } = config;
|
|
1163
|
-
this.getFiles = () => this.runtime.fs.glob({ include, exclude, cwd });
|
|
1164
|
-
this.project = (0, import_parser.createProject)({
|
|
1165
|
-
...conf.tsconfig,
|
|
1166
|
-
getFiles: this.getFiles.bind(this),
|
|
1167
|
-
readFile: this.runtime.fs.readFileSync.bind(this),
|
|
1168
|
-
hooks: conf.hooks,
|
|
1169
|
-
parserOptions: { join: this.runtime.path.join, ...this.parserOptions }
|
|
1170
|
-
});
|
|
1171
|
-
this.output = new PandaOutputEngine(this);
|
|
1172
|
-
this.diff = new DiffEngine(this);
|
|
1173
|
-
}
|
|
1174
|
-
appendFilesCss() {
|
|
1175
|
-
const files = this.getFiles();
|
|
1176
|
-
const filesWithCss = [];
|
|
1177
|
-
const mergedResult = (0, import_parser.createParserResult)();
|
|
1178
|
-
files.forEach((file) => {
|
|
1179
|
-
const measure = import_logger4.logger.time.debug(`Parsed ${file}`);
|
|
1180
|
-
const result = this.project.parseSourceFile(file);
|
|
1181
|
-
measure();
|
|
1182
|
-
if (!result)
|
|
1183
|
-
return;
|
|
1184
|
-
mergedResult.merge(result);
|
|
1185
|
-
filesWithCss.push(file);
|
|
1186
|
-
});
|
|
1187
|
-
this.appendParserCss(mergedResult);
|
|
1188
|
-
return filesWithCss;
|
|
1189
|
-
}
|
|
1190
|
-
appendAllCss() {
|
|
1191
|
-
this.appendLayerParams();
|
|
1192
|
-
this.appendBaselineCss();
|
|
1193
|
-
this.appendFilesCss();
|
|
1194
|
-
}
|
|
1195
|
-
async writeCss() {
|
|
1196
|
-
return this.output.write({
|
|
1197
|
-
id: "styles.css",
|
|
1198
|
-
dir: this.paths.root,
|
|
1199
|
-
files: [{ file: "styles.css", code: this.getCss() }]
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
|
-
};
|
|
1203
|
-
|
|
1204
|
-
// src/config.ts
|
|
1205
|
-
var configs = [".ts", ".js", ".mts", ".mjs", ".cts", ".cjs"];
|
|
1206
|
-
function findConfig() {
|
|
1207
|
-
for (const config of configs) {
|
|
1208
|
-
const result = (0, import_look_it_up.lookItUpSync)(`panda.config${config}`);
|
|
1209
|
-
if (result) {
|
|
1210
|
-
return result;
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
async function loadConfigAndCreateContext(options = {}) {
|
|
1215
|
-
const { config, configPath } = options;
|
|
1216
|
-
const cwd = options.cwd ?? options?.config?.cwd ?? process.cwd();
|
|
1217
|
-
const conf = await (0, import_config2.loadConfigFile)({ cwd, file: configPath });
|
|
1218
|
-
if (config) {
|
|
1219
|
-
Object.assign(conf.config, config);
|
|
1220
|
-
}
|
|
1221
|
-
if (options.cwd) {
|
|
1222
|
-
conf.config.cwd = options.cwd;
|
|
1223
|
-
}
|
|
1224
|
-
const tsconfigResult = await (0, import_tsconfck.parse)(conf.path, {
|
|
1225
|
-
root: cwd,
|
|
1226
|
-
// @ts-ignore
|
|
1227
|
-
resolveWithEmptyIfConfigNotFound: true
|
|
1228
|
-
});
|
|
1229
|
-
if (tsconfigResult) {
|
|
1230
|
-
conf.tsconfig = tsconfigResult.tsconfig;
|
|
1231
|
-
conf.tsconfigFile = tsconfigResult.tsconfigFile;
|
|
1232
|
-
const options2 = tsconfigResult.tsconfig?.compilerOptions;
|
|
1233
|
-
if (options2?.paths) {
|
|
1234
|
-
const baseUrl = options2.baseUrl;
|
|
1235
|
-
conf.tsOptions = {
|
|
1236
|
-
baseUrl,
|
|
1237
|
-
pathMappings: (0, import_config2.convertTsPathsToRegexes)(options2.paths, baseUrl ?? cwd)
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
conf.config.outdir ??= "styled-system";
|
|
1242
|
-
const hooks = (0, import_hookable.createHooks)();
|
|
1243
|
-
if (conf.config.hooks) {
|
|
1244
|
-
hooks.addHooks(conf.config.hooks);
|
|
1245
|
-
}
|
|
1246
|
-
await hooks.callHook("config:resolved", conf);
|
|
1247
|
-
if (conf.config.logLevel === "debug") {
|
|
1248
|
-
(0, import_hookable.createDebugger)(hooks, { tag: "panda" });
|
|
1249
|
-
}
|
|
1250
|
-
return new PandaContext({ ...conf, hooks });
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
// src/emit-artifact.ts
|
|
1254
|
-
init_cjs_shims();
|
|
1255
|
-
|
|
1256
917
|
// src/cli-box.ts
|
|
1257
918
|
init_cjs_shims();
|
|
1258
919
|
|
|
@@ -1610,10 +1271,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
1610
1271
|
return 3;
|
|
1611
1272
|
}
|
|
1612
1273
|
if ("TERM_PROGRAM" in env) {
|
|
1613
|
-
const
|
|
1274
|
+
const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
1614
1275
|
switch (env.TERM_PROGRAM) {
|
|
1615
1276
|
case "iTerm.app": {
|
|
1616
|
-
return
|
|
1277
|
+
return version2 >= 3 ? 3 : 2;
|
|
1617
1278
|
}
|
|
1618
1279
|
case "Apple_Terminal": {
|
|
1619
1280
|
return 2;
|
|
@@ -2565,11 +2226,11 @@ var createBox = (options) => boxen(options.content, {
|
|
|
2565
2226
|
titleAlignment: "center"
|
|
2566
2227
|
});
|
|
2567
2228
|
|
|
2568
|
-
// src/
|
|
2229
|
+
// src/codegen.ts
|
|
2569
2230
|
var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
|
|
2570
2231
|
var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|
2571
2232
|
var limit = pLimit(20);
|
|
2572
|
-
async function
|
|
2233
|
+
async function codegen(ctx, ids) {
|
|
2573
2234
|
if (ctx.config.clean)
|
|
2574
2235
|
ctx.output.empty();
|
|
2575
2236
|
const promises = ctx.getArtifacts(ids).map((artifact) => limit(() => ctx.output.write(artifact)));
|
|
@@ -2584,22 +2245,312 @@ async function emitArtifacts(ctx, ids) {
|
|
|
2584
2245
|
};
|
|
2585
2246
|
}
|
|
2586
2247
|
|
|
2587
|
-
// src/
|
|
2248
|
+
// src/config.ts
|
|
2588
2249
|
init_cjs_shims();
|
|
2589
|
-
var
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2250
|
+
var import_config2 = require("@pandacss/config");
|
|
2251
|
+
var import_hookable = require("hookable");
|
|
2252
|
+
var import_tsconfck = require("tsconfck");
|
|
2253
|
+
|
|
2254
|
+
// src/create-context.ts
|
|
2255
|
+
init_cjs_shims();
|
|
2256
|
+
var import_generator2 = require("@pandacss/generator");
|
|
2257
|
+
var import_logger5 = require("@pandacss/logger");
|
|
2258
|
+
var import_parser = require("@pandacss/parser");
|
|
2259
|
+
var import_perfect_debounce = require("perfect-debounce");
|
|
2260
|
+
|
|
2261
|
+
// src/diff-engine.ts
|
|
2262
|
+
init_cjs_shims();
|
|
2263
|
+
var import_config = require("@pandacss/config");
|
|
2264
|
+
var import_generator = require("@pandacss/generator");
|
|
2265
|
+
var DiffEngine = class {
|
|
2266
|
+
constructor(ctx) {
|
|
2267
|
+
this.ctx = ctx;
|
|
2268
|
+
this.prevConfig = ctx.conf.deserialize();
|
|
2269
|
+
}
|
|
2270
|
+
prevConfig;
|
|
2271
|
+
/**
|
|
2272
|
+
* Reload config from disk and refresh the context
|
|
2273
|
+
*/
|
|
2274
|
+
async reloadConfigAndRefreshContext(fn) {
|
|
2275
|
+
const conf = await (0, import_config.loadConfig)({ cwd: this.ctx.config.cwd, file: this.ctx.conf.path });
|
|
2276
|
+
return this.refresh(conf, fn);
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* Update the context from the refreshed config
|
|
2280
|
+
* then persist the changes on each affected engines
|
|
2281
|
+
* Returns the list of affected artifacts/engines
|
|
2282
|
+
*/
|
|
2283
|
+
refresh(conf, fn) {
|
|
2284
|
+
const affected = (0, import_config.diffConfigs)(() => conf.deserialize(), this.prevConfig);
|
|
2285
|
+
if (!affected.hasConfigChanged || !this.prevConfig)
|
|
2286
|
+
return affected;
|
|
2287
|
+
fn?.(conf);
|
|
2288
|
+
this.prevConfig = conf.deserialize();
|
|
2289
|
+
return affected;
|
|
2290
|
+
}
|
|
2291
|
+
};
|
|
2292
|
+
|
|
2293
|
+
// src/node-runtime.ts
|
|
2294
|
+
init_cjs_shims();
|
|
2295
|
+
var import_logger3 = require("@pandacss/logger");
|
|
2296
|
+
var import_chokidar = __toESM(require("chokidar"));
|
|
2297
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
2298
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
2299
|
+
var import_pathe = require("pathe");
|
|
2300
|
+
var nodeRuntime = {
|
|
2301
|
+
cwd() {
|
|
2302
|
+
return process.cwd();
|
|
2303
|
+
},
|
|
2304
|
+
env(name) {
|
|
2305
|
+
return process.env[name];
|
|
2306
|
+
},
|
|
2307
|
+
path: {
|
|
2308
|
+
join: import_pathe.join,
|
|
2309
|
+
relative: import_pathe.relative,
|
|
2310
|
+
dirname: import_pathe.dirname,
|
|
2311
|
+
extname: import_pathe.extname,
|
|
2312
|
+
isAbsolute: import_pathe.isAbsolute,
|
|
2313
|
+
sep: import_pathe.sep,
|
|
2314
|
+
resolve: import_pathe.resolve,
|
|
2315
|
+
abs(cwd, str) {
|
|
2316
|
+
return (0, import_pathe.isAbsolute)(str) ? str : (0, import_pathe.join)(cwd, str);
|
|
2317
|
+
}
|
|
2318
|
+
},
|
|
2319
|
+
fs: {
|
|
2320
|
+
existsSync: import_fs_extra.default.existsSync,
|
|
2321
|
+
readFileSync(filePath) {
|
|
2322
|
+
return import_fs_extra.default.readFileSync(filePath, "utf8");
|
|
2323
|
+
},
|
|
2324
|
+
glob(opts) {
|
|
2325
|
+
if (!opts.include)
|
|
2326
|
+
return [];
|
|
2327
|
+
const ignore = opts.exclude ?? [];
|
|
2328
|
+
if (!ignore.length) {
|
|
2329
|
+
ignore.push("**/*.d.ts");
|
|
2330
|
+
}
|
|
2331
|
+
return import_fast_glob.default.sync(opts.include, { cwd: opts.cwd, ignore, absolute: true });
|
|
2332
|
+
},
|
|
2333
|
+
writeFile: import_fs_extra.default.writeFile,
|
|
2334
|
+
writeFileSync: import_fs_extra.default.writeFileSync,
|
|
2335
|
+
readDirSync: import_fs_extra.default.readdirSync,
|
|
2336
|
+
rmDirSync: import_fs_extra.default.emptyDirSync,
|
|
2337
|
+
rmFileSync: import_fs_extra.default.removeSync,
|
|
2338
|
+
ensureDirSync(path) {
|
|
2339
|
+
return import_fs_extra.default.ensureDirSync(path);
|
|
2340
|
+
},
|
|
2341
|
+
watch(options) {
|
|
2342
|
+
const { include, exclude, cwd, poll } = options;
|
|
2343
|
+
const coalesce = poll || process.platform === "win32";
|
|
2344
|
+
const watcher = import_chokidar.default.watch(include, {
|
|
2345
|
+
usePolling: poll,
|
|
2346
|
+
cwd,
|
|
2347
|
+
ignoreInitial: true,
|
|
2348
|
+
ignorePermissionErrors: true,
|
|
2349
|
+
ignored: exclude,
|
|
2350
|
+
awaitWriteFinish: coalesce ? { stabilityThreshold: 50, pollInterval: 10 } : false
|
|
2351
|
+
});
|
|
2352
|
+
import_logger3.logger.debug("watch:file", `watching [${include}]`);
|
|
2353
|
+
process.once("SIGINT", async () => {
|
|
2354
|
+
await watcher.close();
|
|
2355
|
+
});
|
|
2356
|
+
return watcher;
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2360
|
+
process.setMaxListeners(Infinity);
|
|
2361
|
+
process.on("unhandledRejection", (reason) => {
|
|
2362
|
+
import_logger3.logger.error("\u274C", reason);
|
|
2363
|
+
});
|
|
2364
|
+
process.on("uncaughtException", (reason) => {
|
|
2365
|
+
import_logger3.logger.error("\u274C", reason);
|
|
2366
|
+
});
|
|
2367
|
+
|
|
2368
|
+
// src/output-engine.ts
|
|
2369
|
+
init_cjs_shims();
|
|
2370
|
+
var import_logger4 = require("@pandacss/logger");
|
|
2371
|
+
var OutputEngine = class {
|
|
2372
|
+
paths;
|
|
2373
|
+
fs;
|
|
2374
|
+
path;
|
|
2375
|
+
constructor(options) {
|
|
2376
|
+
const { paths, runtime } = options;
|
|
2377
|
+
this.paths = paths;
|
|
2378
|
+
this.fs = runtime.fs;
|
|
2379
|
+
this.path = runtime.path;
|
|
2380
|
+
}
|
|
2381
|
+
empty = () => {
|
|
2382
|
+
this.fs.rmDirSync(this.path.join(...this.paths.root));
|
|
2383
|
+
};
|
|
2384
|
+
ensure = (file, cwd) => {
|
|
2385
|
+
const outPath = this.path.resolve(cwd, file);
|
|
2386
|
+
const dirname2 = this.path.dirname(outPath);
|
|
2387
|
+
this.fs.ensureDirSync(dirname2);
|
|
2388
|
+
return outPath;
|
|
2389
|
+
};
|
|
2390
|
+
write = (output) => {
|
|
2391
|
+
if (!output)
|
|
2392
|
+
return;
|
|
2393
|
+
const { dir = this.paths.root, files } = output;
|
|
2394
|
+
this.fs.ensureDirSync(this.path.join(...dir));
|
|
2395
|
+
return Promise.allSettled(
|
|
2396
|
+
files.map(async (artifact) => {
|
|
2397
|
+
if (!artifact?.code)
|
|
2398
|
+
return;
|
|
2399
|
+
const { file, code } = artifact;
|
|
2400
|
+
const absPath = this.path.join(...dir, file);
|
|
2401
|
+
import_logger4.logger.debug("write:file", dir.slice(-1).concat(file).join("/"));
|
|
2402
|
+
return this.fs.writeFile(absPath, code);
|
|
2403
|
+
})
|
|
2404
|
+
);
|
|
2405
|
+
};
|
|
2406
|
+
};
|
|
2407
|
+
|
|
2408
|
+
// src/create-context.ts
|
|
2409
|
+
var PandaContext = class extends import_generator2.Generator {
|
|
2410
|
+
runtime;
|
|
2411
|
+
project;
|
|
2412
|
+
output;
|
|
2413
|
+
diff;
|
|
2414
|
+
constructor(conf) {
|
|
2415
|
+
super(conf);
|
|
2416
|
+
const config = conf.config;
|
|
2417
|
+
this.runtime = nodeRuntime;
|
|
2418
|
+
config.cwd ||= this.runtime.cwd();
|
|
2419
|
+
if (config.logLevel) {
|
|
2420
|
+
import_logger5.logger.level = config.logLevel;
|
|
2421
|
+
}
|
|
2422
|
+
this.project = new import_parser.Project({
|
|
2423
|
+
...conf.tsconfig,
|
|
2424
|
+
getFiles: this.getFiles.bind(this),
|
|
2425
|
+
readFile: this.runtime.fs.readFileSync.bind(this),
|
|
2426
|
+
hooks: conf.hooks,
|
|
2427
|
+
parserOptions: {
|
|
2428
|
+
...this.parserOptions,
|
|
2429
|
+
join: this.runtime.path.join || this.parserOptions.join
|
|
2430
|
+
}
|
|
2431
|
+
});
|
|
2432
|
+
this.output = new OutputEngine(this);
|
|
2433
|
+
this.diff = new DiffEngine(this);
|
|
2434
|
+
}
|
|
2435
|
+
getFiles = () => {
|
|
2436
|
+
const { include, exclude, cwd } = this.config;
|
|
2437
|
+
return this.runtime.fs.glob({ include, exclude, cwd });
|
|
2438
|
+
};
|
|
2439
|
+
parseFile = (filePath, styleEncoder) => {
|
|
2440
|
+
const file = this.runtime.path.abs(this.config.cwd, filePath);
|
|
2441
|
+
import_logger5.logger.debug("file:extract", file);
|
|
2442
|
+
const measure = import_logger5.logger.time.debug(`Parsed ${file}`);
|
|
2443
|
+
let result;
|
|
2444
|
+
try {
|
|
2445
|
+
const encoder = styleEncoder || this.parserOptions.encoder;
|
|
2446
|
+
result = this.project.parseSourceFile(file, encoder);
|
|
2447
|
+
} catch (error) {
|
|
2448
|
+
import_logger5.logger.error("file:extract", error);
|
|
2449
|
+
}
|
|
2450
|
+
measure();
|
|
2451
|
+
return result;
|
|
2452
|
+
};
|
|
2453
|
+
parseFiles = (styleEncoder) => {
|
|
2454
|
+
const encoder = styleEncoder || this.parserOptions.encoder;
|
|
2455
|
+
const files = this.getFiles();
|
|
2456
|
+
const filesWithCss = [];
|
|
2457
|
+
const results = [];
|
|
2458
|
+
files.forEach((file) => {
|
|
2459
|
+
const measure = import_logger5.logger.time.debug(`Parsed ${file}`);
|
|
2460
|
+
const result = this.project.parseSourceFile(file, encoder);
|
|
2461
|
+
measure();
|
|
2462
|
+
if (!result || result.isEmpty() || encoder.isEmpty())
|
|
2463
|
+
return;
|
|
2464
|
+
filesWithCss.push(file);
|
|
2465
|
+
results.push(result);
|
|
2466
|
+
});
|
|
2467
|
+
return {
|
|
2468
|
+
filesWithCss,
|
|
2469
|
+
files,
|
|
2470
|
+
results
|
|
2471
|
+
};
|
|
2472
|
+
};
|
|
2473
|
+
writeCss = (sheet) => {
|
|
2474
|
+
return this.output.write({
|
|
2475
|
+
id: "styles.css",
|
|
2476
|
+
dir: this.paths.root,
|
|
2477
|
+
files: [{ file: "styles.css", code: this.getCss(sheet) }]
|
|
2478
|
+
});
|
|
2479
|
+
};
|
|
2480
|
+
watchConfig = (cb, opts) => {
|
|
2481
|
+
const { cwd, poll, exclude } = opts ?? {};
|
|
2482
|
+
import_logger5.logger.info("ctx:watch", this.messages.configWatch());
|
|
2483
|
+
const watcher = this.runtime.fs.watch({
|
|
2484
|
+
include: this.conf.dependencies,
|
|
2485
|
+
exclude,
|
|
2486
|
+
cwd,
|
|
2487
|
+
poll
|
|
2488
|
+
});
|
|
2489
|
+
watcher.on(
|
|
2490
|
+
"change",
|
|
2491
|
+
(0, import_perfect_debounce.debounce)(async () => {
|
|
2492
|
+
import_logger5.logger.info("ctx:change", "config changed, rebuilding...");
|
|
2493
|
+
await cb();
|
|
2494
|
+
})
|
|
2495
|
+
);
|
|
2496
|
+
};
|
|
2497
|
+
watchFiles = (cb) => {
|
|
2498
|
+
const { include, exclude, poll, cwd } = this.config;
|
|
2499
|
+
import_logger5.logger.info("ctx:watch", this.messages.watch());
|
|
2500
|
+
const watcher = this.runtime.fs.watch({
|
|
2501
|
+
include,
|
|
2502
|
+
exclude,
|
|
2503
|
+
poll,
|
|
2504
|
+
cwd
|
|
2505
|
+
});
|
|
2506
|
+
watcher.on(
|
|
2507
|
+
"all",
|
|
2508
|
+
(0, import_perfect_debounce.debounce)(async (event, file) => {
|
|
2509
|
+
import_logger5.logger.info(`file:${event}`, file);
|
|
2510
|
+
await cb(event, file);
|
|
2511
|
+
})
|
|
2512
|
+
);
|
|
2513
|
+
};
|
|
2514
|
+
};
|
|
2515
|
+
|
|
2516
|
+
// src/config.ts
|
|
2517
|
+
async function loadConfigAndCreateContext(options = {}) {
|
|
2518
|
+
const { config, configPath } = options;
|
|
2519
|
+
const cwd = options.cwd ?? options?.config?.cwd ?? process.cwd();
|
|
2520
|
+
const conf = await (0, import_config2.loadConfig)({ cwd, file: configPath });
|
|
2521
|
+
if (config) {
|
|
2522
|
+
Object.assign(conf.config, config);
|
|
2523
|
+
}
|
|
2524
|
+
if (options.cwd) {
|
|
2525
|
+
conf.config.cwd = options.cwd;
|
|
2526
|
+
}
|
|
2527
|
+
const tsconfigResult = await (0, import_tsconfck.parse)(conf.path, {
|
|
2528
|
+
root: cwd,
|
|
2529
|
+
// @ts-ignore
|
|
2530
|
+
resolveWithEmptyIfConfigNotFound: true
|
|
2531
|
+
});
|
|
2532
|
+
if (tsconfigResult) {
|
|
2533
|
+
conf.tsconfig = tsconfigResult.tsconfig;
|
|
2534
|
+
conf.tsconfigFile = tsconfigResult.tsconfigFile;
|
|
2535
|
+
const options2 = tsconfigResult.tsconfig?.compilerOptions;
|
|
2536
|
+
if (options2?.paths) {
|
|
2537
|
+
const baseUrl = options2.baseUrl;
|
|
2538
|
+
conf.tsOptions = {
|
|
2539
|
+
baseUrl,
|
|
2540
|
+
pathMappings: (0, import_config2.convertTsPathsToRegexes)(options2.paths, baseUrl ?? cwd)
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
conf.config.outdir ??= "styled-system";
|
|
2545
|
+
const hooks = (0, import_hookable.createHooks)();
|
|
2546
|
+
if (conf.config.hooks) {
|
|
2547
|
+
hooks.addHooks(conf.config.hooks);
|
|
2548
|
+
}
|
|
2549
|
+
await hooks.callHook("config:resolved", conf);
|
|
2550
|
+
if (conf.config.logLevel === "debug") {
|
|
2551
|
+
(0, import_hookable.createDebugger)(hooks, { tag: "panda" });
|
|
2552
|
+
}
|
|
2553
|
+
return new PandaContext({ ...conf, hooks });
|
|
2603
2554
|
}
|
|
2604
2555
|
|
|
2605
2556
|
// src/parse-dependency.ts
|
|
@@ -2647,19 +2598,17 @@ function parseDependency(fileOrGlob) {
|
|
|
2647
2598
|
}
|
|
2648
2599
|
|
|
2649
2600
|
// src/builder.ts
|
|
2650
|
-
var parserResultMap = /* @__PURE__ */ new Map();
|
|
2651
2601
|
var fileModifiedMap = /* @__PURE__ */ new Map();
|
|
2652
|
-
var limit2 = pLimit(20);
|
|
2653
2602
|
var Builder = class {
|
|
2654
2603
|
/**
|
|
2655
2604
|
* The current panda context
|
|
2656
2605
|
*/
|
|
2657
2606
|
context;
|
|
2658
2607
|
hasEmitted = false;
|
|
2659
|
-
|
|
2608
|
+
filesMeta;
|
|
2660
2609
|
affecteds;
|
|
2661
|
-
getConfigPath = () => {
|
|
2662
|
-
const configPath = findConfig();
|
|
2610
|
+
getConfigPath = (cwd) => {
|
|
2611
|
+
const configPath = (0, import_config3.findConfig)({ cwd });
|
|
2663
2612
|
if (!configPath) {
|
|
2664
2613
|
throw new import_error.ConfigNotFoundError();
|
|
2665
2614
|
}
|
|
@@ -2667,14 +2616,13 @@ var Builder = class {
|
|
|
2667
2616
|
};
|
|
2668
2617
|
setup = async (options = {}) => {
|
|
2669
2618
|
import_logger6.logger.debug("builder", "\u{1F6A7} Setup");
|
|
2670
|
-
const configPath = options.configPath ?? this.getConfigPath();
|
|
2619
|
+
const configPath = options.configPath ?? this.getConfigPath(options.cwd);
|
|
2671
2620
|
if (!this.context) {
|
|
2672
2621
|
return this.setupContext({ configPath, cwd: options.cwd });
|
|
2673
2622
|
}
|
|
2674
2623
|
const ctx = this.getContextOrThrow();
|
|
2675
2624
|
this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2676
2625
|
this.context = new PandaContext({ ...conf, hooks: ctx.hooks });
|
|
2677
|
-
this.context.appendBaselineCss();
|
|
2678
2626
|
});
|
|
2679
2627
|
import_logger6.logger.debug("builder", this.affecteds);
|
|
2680
2628
|
if (this.affecteds.hasConfigChanged) {
|
|
@@ -2682,8 +2630,8 @@ var Builder = class {
|
|
|
2682
2630
|
await ctx.hooks.callHook("config:change", ctx.config);
|
|
2683
2631
|
return;
|
|
2684
2632
|
}
|
|
2685
|
-
this.
|
|
2686
|
-
if (this.hasFilesChanged) {
|
|
2633
|
+
this.filesMeta = this.checkFilesChanged(ctx.getFiles());
|
|
2634
|
+
if (this.filesMeta.hasFilesChanged) {
|
|
2687
2635
|
import_logger6.logger.debug("builder", "Files changed, invalidating them");
|
|
2688
2636
|
ctx.project.reloadSourceFiles();
|
|
2689
2637
|
}
|
|
@@ -2691,14 +2639,13 @@ var Builder = class {
|
|
|
2691
2639
|
async emit() {
|
|
2692
2640
|
if (this.hasEmitted && this.affecteds?.hasConfigChanged) {
|
|
2693
2641
|
import_logger6.logger.debug("builder", "Emit artifacts after config change");
|
|
2694
|
-
await
|
|
2642
|
+
await codegen(this.getContextOrThrow(), Array.from(this.affecteds.artifacts));
|
|
2695
2643
|
}
|
|
2696
2644
|
this.hasEmitted = true;
|
|
2697
2645
|
}
|
|
2698
2646
|
setupContext = async (options) => {
|
|
2699
2647
|
const { configPath, cwd } = options;
|
|
2700
2648
|
const ctx = await loadConfigAndCreateContext({ configPath, cwd });
|
|
2701
|
-
ctx.appendBaselineCss();
|
|
2702
2649
|
this.context = ctx;
|
|
2703
2650
|
return ctx;
|
|
2704
2651
|
};
|
|
@@ -2709,48 +2656,48 @@ var Builder = class {
|
|
|
2709
2656
|
return this.context;
|
|
2710
2657
|
};
|
|
2711
2658
|
getFileMeta = (file) => {
|
|
2712
|
-
const mtime = (0, import_fs.existsSync)(file) ?
|
|
2659
|
+
const mtime = (0, import_fs.existsSync)(file) ? (0, import_fs.statSync)(file).mtimeMs : -Infinity;
|
|
2713
2660
|
const isUnchanged = fileModifiedMap.has(file) && mtime === fileModifiedMap.get(file);
|
|
2714
2661
|
return { mtime, isUnchanged };
|
|
2715
2662
|
};
|
|
2716
|
-
|
|
2717
|
-
const
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2663
|
+
checkFilesChanged(files) {
|
|
2664
|
+
const changes = /* @__PURE__ */ new Map();
|
|
2665
|
+
let hasFilesChanged = false;
|
|
2666
|
+
for (const file of files) {
|
|
2667
|
+
const meta = this.getFileMeta(file);
|
|
2668
|
+
changes.set(file, meta);
|
|
2669
|
+
if (!meta.isUnchanged) {
|
|
2670
|
+
hasFilesChanged = true;
|
|
2671
|
+
}
|
|
2721
2672
|
}
|
|
2722
|
-
|
|
2673
|
+
return { changes, hasFilesChanged };
|
|
2674
|
+
}
|
|
2675
|
+
extractFile = (ctx, file) => {
|
|
2676
|
+
const meta = this.filesMeta?.changes.get(file) ?? this.getFileMeta(file);
|
|
2677
|
+
const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : true;
|
|
2678
|
+
if (meta.isUnchanged && !hasConfigChanged)
|
|
2679
|
+
return;
|
|
2680
|
+
const parserResult = ctx.parseFile(file);
|
|
2723
2681
|
fileModifiedMap.set(file, meta.mtime);
|
|
2724
|
-
|
|
2725
|
-
parserResultMap.set(file, result);
|
|
2726
|
-
}
|
|
2727
|
-
return result;
|
|
2682
|
+
return parserResult;
|
|
2728
2683
|
};
|
|
2729
|
-
|
|
2730
|
-
return files.some((file) => !this.getFileMeta(file).isUnchanged);
|
|
2731
|
-
}
|
|
2732
|
-
extract = async () => {
|
|
2684
|
+
extract = () => {
|
|
2733
2685
|
const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : true;
|
|
2734
|
-
if (!this.
|
|
2686
|
+
if (!this.filesMeta && !hasConfigChanged) {
|
|
2735
2687
|
import_logger6.logger.debug("builder", "No files or config changed, skipping extract");
|
|
2736
2688
|
return;
|
|
2737
2689
|
}
|
|
2738
2690
|
const ctx = this.getContextOrThrow();
|
|
2739
2691
|
const files = ctx.getFiles();
|
|
2740
2692
|
const done = import_logger6.logger.time.info("Extracted in");
|
|
2741
|
-
|
|
2742
|
-
await Promise.allSettled(promises);
|
|
2693
|
+
files.map((file) => this.extractFile(ctx, file));
|
|
2743
2694
|
done();
|
|
2744
2695
|
};
|
|
2745
|
-
toString = () => {
|
|
2746
|
-
const ctx = this.getContextOrThrow();
|
|
2747
|
-
return ctx.getCss();
|
|
2748
|
-
};
|
|
2749
2696
|
isValidRoot = (root) => {
|
|
2750
2697
|
const ctx = this.getContextOrThrow();
|
|
2751
2698
|
let valid = false;
|
|
2752
2699
|
root.walkAtRules("layer", (rule) => {
|
|
2753
|
-
if (ctx.
|
|
2700
|
+
if (ctx.isValidLayerParams(rule.params)) {
|
|
2754
2701
|
valid = true;
|
|
2755
2702
|
}
|
|
2756
2703
|
});
|
|
@@ -2762,12 +2709,17 @@ var Builder = class {
|
|
|
2762
2709
|
this.initialRoot = root.toString();
|
|
2763
2710
|
}
|
|
2764
2711
|
root.removeAll();
|
|
2765
|
-
const
|
|
2766
|
-
const
|
|
2712
|
+
const ctx = this.getContextOrThrow();
|
|
2713
|
+
const sheet = ctx.createSheet();
|
|
2714
|
+
ctx.appendBaselineCss(sheet);
|
|
2715
|
+
ctx.appendParserCss(sheet);
|
|
2716
|
+
const css = ctx.getCss(sheet);
|
|
2717
|
+
root.append(
|
|
2718
|
+
(0, import_core.optimizeCss)(`
|
|
2767
2719
|
${this.initialRoot}
|
|
2768
|
-
${
|
|
2769
|
-
`)
|
|
2770
|
-
|
|
2720
|
+
${css}
|
|
2721
|
+
`)
|
|
2722
|
+
);
|
|
2771
2723
|
};
|
|
2772
2724
|
registerDependency = (fn) => {
|
|
2773
2725
|
const ctx = this.getContextOrThrow();
|
|
@@ -2778,98 +2730,126 @@ var Builder = class {
|
|
|
2778
2730
|
}
|
|
2779
2731
|
}
|
|
2780
2732
|
for (const file of ctx.conf.dependencies) {
|
|
2781
|
-
fn({ type: "dependency", file:
|
|
2733
|
+
fn({ type: "dependency", file: ctx.runtime.path.resolve(file) });
|
|
2782
2734
|
}
|
|
2783
2735
|
};
|
|
2784
2736
|
};
|
|
2785
2737
|
|
|
2786
|
-
// src/
|
|
2738
|
+
// src/cssgen.ts
|
|
2787
2739
|
init_cjs_shims();
|
|
2788
2740
|
var import_logger7 = require("@pandacss/logger");
|
|
2789
|
-
var
|
|
2790
|
-
|
|
2741
|
+
var cssgen = async (ctx, options) => {
|
|
2742
|
+
const { cwd, outfile, type, minimal } = options;
|
|
2743
|
+
let outPath = ctx.runtime.path.join(...ctx.paths.getFilePath("styles.css"));
|
|
2744
|
+
const sheet = ctx.createSheet();
|
|
2745
|
+
if (type) {
|
|
2746
|
+
ctx.appendCssOfType(type, sheet);
|
|
2747
|
+
if (outfile) {
|
|
2748
|
+
outPath = ctx.output.ensure(outfile, cwd);
|
|
2749
|
+
const css = ctx.getCss(sheet);
|
|
2750
|
+
ctx.runtime.fs.writeFileSync(outfile, css);
|
|
2751
|
+
} else {
|
|
2752
|
+
await ctx.writeCss(sheet);
|
|
2753
|
+
}
|
|
2754
|
+
const msg = ctx.messages.cssArtifactComplete(type);
|
|
2755
|
+
import_logger7.logger.info("css:emit:path", outPath);
|
|
2756
|
+
import_logger7.logger.info("css:emit:artifact", msg);
|
|
2757
|
+
} else {
|
|
2758
|
+
if (!minimal) {
|
|
2759
|
+
ctx.appendLayerParams(sheet);
|
|
2760
|
+
ctx.appendBaselineCss(sheet);
|
|
2761
|
+
}
|
|
2762
|
+
const { files } = ctx.parseFiles();
|
|
2763
|
+
ctx.appendParserCss(sheet);
|
|
2764
|
+
if (outfile) {
|
|
2765
|
+
outPath = ctx.output.ensure(outfile, cwd);
|
|
2766
|
+
const css = ctx.getCss(sheet);
|
|
2767
|
+
ctx.runtime.fs.writeFileSync(outfile, css);
|
|
2768
|
+
} else {
|
|
2769
|
+
await ctx.writeCss(sheet);
|
|
2770
|
+
}
|
|
2771
|
+
const msg = ctx.messages.buildComplete(files.length);
|
|
2772
|
+
import_logger7.logger.info("css:emit:path", outPath);
|
|
2773
|
+
import_logger7.logger.info("css:emit:out", msg);
|
|
2774
|
+
}
|
|
2775
|
+
};
|
|
2776
|
+
|
|
2777
|
+
// src/debug.ts
|
|
2778
|
+
init_cjs_shims();
|
|
2779
|
+
var import_logger8 = require("@pandacss/logger");
|
|
2780
|
+
var import_pathe3 = require("pathe");
|
|
2781
|
+
async function debug(ctx, options) {
|
|
2791
2782
|
const files = ctx.getFiles();
|
|
2792
|
-
const measureTotal =
|
|
2793
|
-
|
|
2783
|
+
const measureTotal = import_logger8.logger.time.debug(`Done parsing ${files.length} files`);
|
|
2784
|
+
ctx.config.minify = false;
|
|
2785
|
+
ctx.config.optimize = true;
|
|
2786
|
+
const { fs, path } = ctx.runtime;
|
|
2794
2787
|
const outdir = options.outdir;
|
|
2795
2788
|
if (!options.dry && outdir) {
|
|
2796
2789
|
fs.ensureDirSync(outdir);
|
|
2797
|
-
|
|
2790
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/config.json`)}`);
|
|
2798
2791
|
await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2799
2792
|
}
|
|
2800
2793
|
if (options.onlyConfig) {
|
|
2801
2794
|
measureTotal();
|
|
2802
2795
|
return;
|
|
2803
2796
|
}
|
|
2804
|
-
const
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
const css2 = ctx.stylesheet.toCss({ optimize: true, minify: false });
|
|
2797
|
+
const filesWithCss = [];
|
|
2798
|
+
files.map((file) => {
|
|
2799
|
+
const measure = import_logger8.logger.time.debug(`Parsed ${file}`);
|
|
2800
|
+
const encoder = ctx.encoder.clone();
|
|
2801
|
+
const result = ctx.project.parseSourceFile(file, encoder);
|
|
2802
|
+
measure();
|
|
2803
|
+
if (!result || result.isEmpty() || encoder.isEmpty())
|
|
2804
|
+
return;
|
|
2805
|
+
const styles4 = ctx.decoder.clone().collect(encoder);
|
|
2806
|
+
const css = ctx.getParserCss(styles4, file);
|
|
2807
|
+
if (!css)
|
|
2808
|
+
return;
|
|
2817
2809
|
if (options.dry) {
|
|
2818
|
-
console.log({ path: file, ast: result, code:
|
|
2810
|
+
console.log({ path: file, ast: result, code: css });
|
|
2811
|
+
return;
|
|
2819
2812
|
}
|
|
2820
2813
|
if (outdir) {
|
|
2821
|
-
|
|
2822
|
-
const
|
|
2823
|
-
const
|
|
2824
|
-
const
|
|
2825
|
-
|
|
2826
|
-
|
|
2814
|
+
filesWithCss.push(file);
|
|
2815
|
+
const parsedPath = (0, import_pathe3.parse)(file);
|
|
2816
|
+
const relative2 = path.relative(ctx.config.cwd, parsedPath.dir);
|
|
2817
|
+
const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path.sep, "__");
|
|
2818
|
+
const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path.sep, "__");
|
|
2819
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2820
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${cssPath}`)}`);
|
|
2827
2821
|
return Promise.allSettled([
|
|
2828
2822
|
fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2829
|
-
fs.writeFile(`${outdir}/${cssPath}`,
|
|
2823
|
+
fs.writeFile(`${outdir}/${cssPath}`, css)
|
|
2830
2824
|
]);
|
|
2831
2825
|
}
|
|
2832
2826
|
});
|
|
2833
|
-
|
|
2827
|
+
import_logger8.logger.info("cli", `Found ${import_logger8.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
2834
2828
|
measureTotal();
|
|
2835
2829
|
}
|
|
2836
2830
|
|
|
2837
|
-
// src/exec-command.ts
|
|
2838
|
-
init_cjs_shims();
|
|
2839
|
-
var import_logger8 = require("@pandacss/logger");
|
|
2840
|
-
var import_child_process = require("child_process");
|
|
2841
|
-
var import_preferred_pm = __toESM(require("preferred-pm"));
|
|
2842
|
-
async function execCommand(cmd, cwd) {
|
|
2843
|
-
const manager = await (0, import_preferred_pm.default)(cwd);
|
|
2844
|
-
const pm = manager?.name ?? "npm";
|
|
2845
|
-
const args = cmd.split(" ");
|
|
2846
|
-
if (pm === "npm") {
|
|
2847
|
-
args.unshift("run");
|
|
2848
|
-
}
|
|
2849
|
-
const check = (0, import_child_process.spawnSync)(pm, args, { cwd, stdio: "pipe" });
|
|
2850
|
-
if (check.status !== 0) {
|
|
2851
|
-
import_logger8.logger.error("exec", check.stderr.toString());
|
|
2852
|
-
}
|
|
2853
|
-
}
|
|
2854
|
-
|
|
2855
2831
|
// src/generate.ts
|
|
2856
2832
|
init_cjs_shims();
|
|
2857
2833
|
var import_logger9 = require("@pandacss/logger");
|
|
2858
2834
|
var import_ts_pattern = require("ts-pattern");
|
|
2859
|
-
async function build(ctx,
|
|
2860
|
-
await
|
|
2835
|
+
async function build(ctx, artifactIds) {
|
|
2836
|
+
await codegen(ctx, artifactIds);
|
|
2861
2837
|
if (ctx.config.emitTokensOnly) {
|
|
2862
2838
|
return import_logger9.logger.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
|
|
2863
2839
|
}
|
|
2864
|
-
ctx.
|
|
2865
|
-
|
|
2840
|
+
const sheet = ctx.createSheet();
|
|
2841
|
+
ctx.appendLayerParams(sheet);
|
|
2842
|
+
ctx.appendBaselineCss(sheet);
|
|
2843
|
+
ctx.parseFiles();
|
|
2844
|
+
ctx.appendParserCss(sheet);
|
|
2845
|
+
await ctx.writeCss(sheet);
|
|
2866
2846
|
import_logger9.logger.info("css:emit", "Successfully built the css files \u2728");
|
|
2867
2847
|
}
|
|
2868
2848
|
async function generate(config, configPath) {
|
|
2869
2849
|
let ctx = await loadConfigAndCreateContext({ config, configPath });
|
|
2870
2850
|
await build(ctx);
|
|
2871
2851
|
const {
|
|
2872
|
-
runtime: { fs, path
|
|
2852
|
+
runtime: { fs, path },
|
|
2873
2853
|
config: { cwd }
|
|
2874
2854
|
} = ctx;
|
|
2875
2855
|
if (ctx.config.watch) {
|
|
@@ -2878,27 +2858,39 @@ async function generate(config, configPath) {
|
|
|
2878
2858
|
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2879
2859
|
ctx = new PandaContext({ ...conf, hooks: ctx.hooks });
|
|
2880
2860
|
});
|
|
2881
|
-
if (!affecteds.
|
|
2861
|
+
if (!affecteds.hasConfigChanged) {
|
|
2862
|
+
import_logger9.logger.debug("builder", "Config didnt change, skipping rebuild");
|
|
2882
2863
|
return;
|
|
2864
|
+
}
|
|
2883
2865
|
import_logger9.logger.info("config:change", "Config changed, restarting...");
|
|
2884
2866
|
await ctx.hooks.callHook("config:change", ctx.config);
|
|
2885
2867
|
return build(ctx, Array.from(affecteds.artifacts));
|
|
2886
2868
|
});
|
|
2887
2869
|
const contentWatcher = fs.watch(ctx.config);
|
|
2870
|
+
const bundleStyles = async (ctx2, changedFilePath) => {
|
|
2871
|
+
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
2872
|
+
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
2873
|
+
if (parserResult) {
|
|
2874
|
+
const sheet = ctx2.createSheet();
|
|
2875
|
+
ctx2.appendLayerParams(sheet);
|
|
2876
|
+
ctx2.appendBaselineCss(sheet);
|
|
2877
|
+
ctx2.appendParserCss(sheet);
|
|
2878
|
+
const css = ctx2.getCss(sheet);
|
|
2879
|
+
await ctx2.runtime.fs.writeFile(outfile, css);
|
|
2880
|
+
return { msg: ctx2.messages.buildComplete(1) };
|
|
2881
|
+
}
|
|
2882
|
+
};
|
|
2888
2883
|
contentWatcher.on("all", async (event, file) => {
|
|
2889
2884
|
import_logger9.logger.info(`file:${event}`, file);
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2885
|
+
const filePath = path.abs(cwd, file);
|
|
2886
|
+
(0, import_ts_pattern.match)(event).with("unlink", () => {
|
|
2887
|
+
ctx.project.removeSourceFile(path.abs(cwd, file));
|
|
2888
|
+
}).with("change", async () => {
|
|
2893
2889
|
ctx.project.reloadSourceFile(file);
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
return ctx.writeCss();
|
|
2897
|
-
}).with("add", () => {
|
|
2890
|
+
return bundleStyles(ctx, filePath);
|
|
2891
|
+
}).with("add", async () => {
|
|
2898
2892
|
ctx.project.createSourceFile(file);
|
|
2899
|
-
|
|
2900
|
-
ctx.appendParserCss(result);
|
|
2901
|
-
return ctx.writeCss();
|
|
2893
|
+
return bundleStyles(ctx, filePath);
|
|
2902
2894
|
}).otherwise(() => {
|
|
2903
2895
|
});
|
|
2904
2896
|
});
|
|
@@ -2909,7 +2901,7 @@ async function generate(config, configPath) {
|
|
|
2909
2901
|
// src/git-ignore.ts
|
|
2910
2902
|
init_cjs_shims();
|
|
2911
2903
|
var import_fs2 = require("fs");
|
|
2912
|
-
var
|
|
2904
|
+
var import_look_it_up = require("look-it-up");
|
|
2913
2905
|
var import_outdent = __toESM(require("outdent"));
|
|
2914
2906
|
function setupGitIgnore(ctx) {
|
|
2915
2907
|
const { outdir, gitignore } = ctx.config;
|
|
@@ -2921,7 +2913,7 @@ function setupGitIgnore(ctx) {
|
|
|
2921
2913
|
${outdir}
|
|
2922
2914
|
${ctx.studio.outdir}
|
|
2923
2915
|
`;
|
|
2924
|
-
const file = (0,
|
|
2916
|
+
const file = (0, import_look_it_up.lookItUpSync)(".gitignore");
|
|
2925
2917
|
if (!file) {
|
|
2926
2918
|
return (0, import_fs2.writeFileSync)(".gitignore", txt);
|
|
2927
2919
|
}
|
|
@@ -2933,21 +2925,22 @@ function setupGitIgnore(ctx) {
|
|
|
2933
2925
|
|
|
2934
2926
|
// src/setup-config.ts
|
|
2935
2927
|
init_cjs_shims();
|
|
2928
|
+
var import_config6 = require("@pandacss/config");
|
|
2936
2929
|
var import_generator3 = require("@pandacss/generator");
|
|
2937
2930
|
var import_logger10 = require("@pandacss/logger");
|
|
2938
|
-
var
|
|
2939
|
-
var
|
|
2931
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
2932
|
+
var import_look_it_up2 = require("look-it-up");
|
|
2940
2933
|
var import_outdent2 = require("outdent");
|
|
2941
|
-
var
|
|
2942
|
-
var
|
|
2934
|
+
var import_pathe4 = require("pathe");
|
|
2935
|
+
var import_preferred_pm = __toESM(require("preferred-pm"));
|
|
2943
2936
|
var import_prettier = __toESM(require("prettier"));
|
|
2944
2937
|
async function setupConfig(cwd, opts = {}) {
|
|
2945
2938
|
const { force, outExtension, jsxFramework, syntax } = opts;
|
|
2946
|
-
const configFile = findConfig();
|
|
2947
|
-
const pmResult = await (0,
|
|
2939
|
+
const configFile = (0, import_config6.findConfig)({ cwd });
|
|
2940
|
+
const pmResult = await (0, import_preferred_pm.default)(cwd);
|
|
2948
2941
|
const pm = pmResult?.name ?? "npm";
|
|
2949
2942
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
2950
|
-
const isTs = (0,
|
|
2943
|
+
const isTs = (0, import_look_it_up2.lookItUpSync)("tsconfig.json", cwd);
|
|
2951
2944
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
2952
2945
|
import_logger10.logger.info("init:config", `creating panda config file: ${(0, import_logger10.quote)(file)}`);
|
|
2953
2946
|
if (!force && configFile) {
|
|
@@ -2983,7 +2976,7 @@ jsxFramework: '${jsxFramework}',` : ""}
|
|
|
2983
2976
|
syntax: '${syntax}'` : ""}
|
|
2984
2977
|
})
|
|
2985
2978
|
`;
|
|
2986
|
-
await
|
|
2979
|
+
await import_fs_extra2.default.writeFile((0, import_pathe4.join)(cwd, file), import_prettier.default.format(content));
|
|
2987
2980
|
import_logger10.logger.log(import_generator3.messages.thankYou());
|
|
2988
2981
|
}
|
|
2989
2982
|
}
|
|
@@ -2996,51 +2989,22 @@ module.exports = {
|
|
|
2996
2989
|
},
|
|
2997
2990
|
}
|
|
2998
2991
|
`;
|
|
2999
|
-
await
|
|
3000
|
-
}
|
|
3001
|
-
|
|
3002
|
-
// src/ship-files.ts
|
|
3003
|
-
init_cjs_shims();
|
|
3004
|
-
var import_logger11 = require("@pandacss/logger");
|
|
3005
|
-
var import_parser2 = require("@pandacss/parser");
|
|
3006
|
-
var import_promises2 = require("fs/promises");
|
|
3007
|
-
var path = __toESM(require("pathe"));
|
|
3008
|
-
async function shipFiles(ctx, outfile) {
|
|
3009
|
-
const files = ctx.getFiles();
|
|
3010
|
-
const extractResult = (0, import_parser2.createParserResult)();
|
|
3011
|
-
const filesWithCss = [];
|
|
3012
|
-
files.forEach(async (file) => {
|
|
3013
|
-
const result = ctx.project.parseSourceFile(file);
|
|
3014
|
-
if (!result || result.isEmpty())
|
|
3015
|
-
return;
|
|
3016
|
-
extractResult.merge(result);
|
|
3017
|
-
filesWithCss.push(path.relative(ctx.config.cwd, file));
|
|
3018
|
-
});
|
|
3019
|
-
import_logger11.logger.info("cli", `Found ${import_logger11.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
3020
|
-
const minify = ctx.config.minify;
|
|
3021
|
-
import_logger11.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger11.colors.bold(outfile)}`);
|
|
3022
|
-
const output = JSON.stringify(extractResult.toJSON(), null, minify ? 0 : 2);
|
|
3023
|
-
const dirname2 = ctx.runtime.path.dirname(outfile);
|
|
3024
|
-
ctx.runtime.fs.ensureDirSync(dirname2);
|
|
3025
|
-
await (0, import_promises2.writeFile)(outfile, output);
|
|
3026
|
-
import_logger11.logger.info("cli", "Done!");
|
|
2992
|
+
await import_fs_extra2.default.writeFile((0, import_pathe4.join)(cwd, "postcss.config.cjs"), content);
|
|
3027
2993
|
}
|
|
3028
2994
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3029
2995
|
0 && (module.exports = {
|
|
3030
2996
|
Builder,
|
|
3031
2997
|
PandaContext,
|
|
3032
2998
|
analyzeTokens,
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
findConfig,
|
|
2999
|
+
buildInfo,
|
|
3000
|
+
codegen,
|
|
3001
|
+
cssgen,
|
|
3002
|
+
debug,
|
|
3038
3003
|
generate,
|
|
3039
3004
|
loadConfigAndCreateContext,
|
|
3040
3005
|
parseDependency,
|
|
3041
3006
|
setupConfig,
|
|
3042
3007
|
setupGitIgnore,
|
|
3043
3008
|
setupPostcss,
|
|
3044
|
-
shipFiles,
|
|
3045
3009
|
writeAnalyzeJSON
|
|
3046
3010
|
});
|