@pandacss/node 0.22.1 → 0.24.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.mts +61 -50
- package/dist/index.d.ts +61 -50
- package/dist/index.js +518 -552
- package/dist/index.mjs +515 -547
- package/package.json +21 -18
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.0";
|
|
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,18 +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;
|
|
2608
|
+
filesMeta;
|
|
2659
2609
|
affecteds;
|
|
2660
|
-
getConfigPath = () => {
|
|
2661
|
-
const configPath = findConfig();
|
|
2610
|
+
getConfigPath = (cwd) => {
|
|
2611
|
+
const configPath = (0, import_config3.findConfig)({ cwd });
|
|
2662
2612
|
if (!configPath) {
|
|
2663
2613
|
throw new import_error.ConfigNotFoundError();
|
|
2664
2614
|
}
|
|
@@ -2666,35 +2616,36 @@ var Builder = class {
|
|
|
2666
2616
|
};
|
|
2667
2617
|
setup = async (options = {}) => {
|
|
2668
2618
|
import_logger6.logger.debug("builder", "\u{1F6A7} Setup");
|
|
2669
|
-
const configPath = options.configPath ?? this.getConfigPath();
|
|
2619
|
+
const configPath = options.configPath ?? this.getConfigPath(options.cwd);
|
|
2670
2620
|
if (!this.context) {
|
|
2671
2621
|
return this.setupContext({ configPath, cwd: options.cwd });
|
|
2672
2622
|
}
|
|
2673
2623
|
const ctx = this.getContextOrThrow();
|
|
2674
2624
|
this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2675
2625
|
this.context = new PandaContext({ ...conf, hooks: ctx.hooks });
|
|
2676
|
-
this.context.appendBaselineCss();
|
|
2677
2626
|
});
|
|
2627
|
+
import_logger6.logger.debug("builder", this.affecteds);
|
|
2678
2628
|
if (this.affecteds.hasConfigChanged) {
|
|
2679
2629
|
import_logger6.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
|
|
2680
2630
|
await ctx.hooks.callHook("config:change", ctx.config);
|
|
2681
2631
|
return;
|
|
2682
2632
|
}
|
|
2683
|
-
|
|
2684
|
-
if (hasFilesChanged) {
|
|
2633
|
+
this.filesMeta = this.checkFilesChanged(ctx.getFiles());
|
|
2634
|
+
if (this.filesMeta.hasFilesChanged) {
|
|
2635
|
+
import_logger6.logger.debug("builder", "Files changed, invalidating them");
|
|
2685
2636
|
ctx.project.reloadSourceFiles();
|
|
2686
2637
|
}
|
|
2687
2638
|
};
|
|
2688
2639
|
async emit() {
|
|
2689
2640
|
if (this.hasEmitted && this.affecteds?.hasConfigChanged) {
|
|
2690
|
-
|
|
2641
|
+
import_logger6.logger.debug("builder", "Emit artifacts after config change");
|
|
2642
|
+
await codegen(this.getContextOrThrow(), Array.from(this.affecteds.artifacts));
|
|
2691
2643
|
}
|
|
2692
2644
|
this.hasEmitted = true;
|
|
2693
2645
|
}
|
|
2694
2646
|
setupContext = async (options) => {
|
|
2695
2647
|
const { configPath, cwd } = options;
|
|
2696
2648
|
const ctx = await loadConfigAndCreateContext({ configPath, cwd });
|
|
2697
|
-
ctx.appendBaselineCss();
|
|
2698
2649
|
this.context = ctx;
|
|
2699
2650
|
return ctx;
|
|
2700
2651
|
};
|
|
@@ -2705,62 +2656,68 @@ var Builder = class {
|
|
|
2705
2656
|
return this.context;
|
|
2706
2657
|
};
|
|
2707
2658
|
getFileMeta = (file) => {
|
|
2708
|
-
const mtime = (0, import_fs.existsSync)(file) ?
|
|
2659
|
+
const mtime = (0, import_fs.existsSync)(file) ? (0, import_fs.statSync)(file).mtimeMs : -Infinity;
|
|
2709
2660
|
const isUnchanged = fileModifiedMap.has(file) && mtime === fileModifiedMap.get(file);
|
|
2710
2661
|
return { mtime, isUnchanged };
|
|
2711
2662
|
};
|
|
2712
|
-
|
|
2713
|
-
const
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
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
|
+
}
|
|
2717
2672
|
}
|
|
2718
|
-
|
|
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);
|
|
2719
2681
|
fileModifiedMap.set(file, meta.mtime);
|
|
2720
|
-
|
|
2721
|
-
parserResultMap.set(file, result);
|
|
2722
|
-
}
|
|
2723
|
-
return result;
|
|
2682
|
+
return parserResult;
|
|
2724
2683
|
};
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2684
|
+
extract = () => {
|
|
2685
|
+
const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : true;
|
|
2686
|
+
if (!this.filesMeta && !hasConfigChanged) {
|
|
2687
|
+
import_logger6.logger.debug("builder", "No files or config changed, skipping extract");
|
|
2688
|
+
return;
|
|
2689
|
+
}
|
|
2729
2690
|
const ctx = this.getContextOrThrow();
|
|
2730
2691
|
const files = ctx.getFiles();
|
|
2731
|
-
const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : false;
|
|
2732
|
-
if (hasConfigChanged)
|
|
2733
|
-
return;
|
|
2734
2692
|
const done = import_logger6.logger.time.info("Extracted in");
|
|
2735
|
-
|
|
2736
|
-
await Promise.allSettled(promises);
|
|
2693
|
+
files.map((file) => this.extractFile(ctx, file));
|
|
2737
2694
|
done();
|
|
2738
2695
|
};
|
|
2739
|
-
toString = () => {
|
|
2740
|
-
const ctx = this.getContextOrThrow();
|
|
2741
|
-
return ctx.getCss();
|
|
2742
|
-
};
|
|
2743
2696
|
isValidRoot = (root) => {
|
|
2744
2697
|
const ctx = this.getContextOrThrow();
|
|
2745
2698
|
let valid = false;
|
|
2746
2699
|
root.walkAtRules("layer", (rule) => {
|
|
2747
|
-
if (ctx.
|
|
2700
|
+
if (ctx.isValidLayerParams(rule.params)) {
|
|
2748
2701
|
valid = true;
|
|
2749
2702
|
}
|
|
2750
2703
|
});
|
|
2751
2704
|
return valid;
|
|
2752
2705
|
};
|
|
2753
|
-
initialRoot;
|
|
2754
2706
|
write = (root) => {
|
|
2755
|
-
|
|
2756
|
-
this.initialRoot = root.toString();
|
|
2757
|
-
}
|
|
2707
|
+
const rootCssContent = root.toString();
|
|
2758
2708
|
root.removeAll();
|
|
2759
|
-
const
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2709
|
+
const ctx = this.getContextOrThrow();
|
|
2710
|
+
const sheet = ctx.createSheet();
|
|
2711
|
+
ctx.appendLayerParams(sheet);
|
|
2712
|
+
ctx.appendBaselineCss(sheet);
|
|
2713
|
+
ctx.appendParserCss(sheet);
|
|
2714
|
+
const css = ctx.getCss(sheet);
|
|
2715
|
+
root.append(
|
|
2716
|
+
(0, import_core.optimizeCss)(`
|
|
2717
|
+
${rootCssContent}
|
|
2718
|
+
${css}
|
|
2719
|
+
`)
|
|
2720
|
+
);
|
|
2764
2721
|
};
|
|
2765
2722
|
registerDependency = (fn) => {
|
|
2766
2723
|
const ctx = this.getContextOrThrow();
|
|
@@ -2771,23 +2728,64 @@ var Builder = class {
|
|
|
2771
2728
|
}
|
|
2772
2729
|
}
|
|
2773
2730
|
for (const file of ctx.conf.dependencies) {
|
|
2774
|
-
fn({ type: "dependency", file:
|
|
2731
|
+
fn({ type: "dependency", file: ctx.runtime.path.resolve(file) });
|
|
2775
2732
|
}
|
|
2776
2733
|
};
|
|
2777
2734
|
};
|
|
2778
2735
|
|
|
2779
|
-
// src/
|
|
2736
|
+
// src/cssgen.ts
|
|
2780
2737
|
init_cjs_shims();
|
|
2781
2738
|
var import_logger7 = require("@pandacss/logger");
|
|
2782
|
-
var
|
|
2783
|
-
|
|
2739
|
+
var cssgen = async (ctx, options) => {
|
|
2740
|
+
const { cwd, outfile, type, minimal } = options;
|
|
2741
|
+
let outPath = ctx.runtime.path.join(...ctx.paths.getFilePath("styles.css"));
|
|
2742
|
+
const sheet = ctx.createSheet();
|
|
2743
|
+
if (type) {
|
|
2744
|
+
ctx.appendCssOfType(type, sheet);
|
|
2745
|
+
if (outfile) {
|
|
2746
|
+
outPath = ctx.output.ensure(outfile, cwd);
|
|
2747
|
+
const css = ctx.getCss(sheet);
|
|
2748
|
+
ctx.runtime.fs.writeFileSync(outfile, css);
|
|
2749
|
+
} else {
|
|
2750
|
+
await ctx.writeCss(sheet);
|
|
2751
|
+
}
|
|
2752
|
+
const msg = ctx.messages.cssArtifactComplete(type);
|
|
2753
|
+
import_logger7.logger.info("css:emit:path", outPath);
|
|
2754
|
+
import_logger7.logger.info("css:emit:artifact", msg);
|
|
2755
|
+
} else {
|
|
2756
|
+
if (!minimal) {
|
|
2757
|
+
ctx.appendLayerParams(sheet);
|
|
2758
|
+
ctx.appendBaselineCss(sheet);
|
|
2759
|
+
}
|
|
2760
|
+
const { files } = ctx.parseFiles();
|
|
2761
|
+
ctx.appendParserCss(sheet);
|
|
2762
|
+
if (outfile) {
|
|
2763
|
+
outPath = ctx.output.ensure(outfile, cwd);
|
|
2764
|
+
const css = ctx.getCss(sheet);
|
|
2765
|
+
ctx.runtime.fs.writeFileSync(outfile, css);
|
|
2766
|
+
} else {
|
|
2767
|
+
await ctx.writeCss(sheet);
|
|
2768
|
+
}
|
|
2769
|
+
const msg = ctx.messages.buildComplete(files.length);
|
|
2770
|
+
import_logger7.logger.info("css:emit:path", outPath);
|
|
2771
|
+
import_logger7.logger.info("css:emit:out", msg);
|
|
2772
|
+
}
|
|
2773
|
+
};
|
|
2774
|
+
|
|
2775
|
+
// src/debug.ts
|
|
2776
|
+
init_cjs_shims();
|
|
2777
|
+
var import_logger8 = require("@pandacss/logger");
|
|
2778
|
+
var import_pathe3 = require("pathe");
|
|
2779
|
+
async function debug(ctx, options) {
|
|
2784
2780
|
const files = ctx.getFiles();
|
|
2785
|
-
const measureTotal =
|
|
2786
|
-
|
|
2781
|
+
const measureTotal = import_logger8.logger.time.debug(`Done parsing ${files.length} files`);
|
|
2782
|
+
ctx.config.minify = false;
|
|
2783
|
+
ctx.config.optimize = true;
|
|
2784
|
+
const { fs, path } = ctx.runtime;
|
|
2787
2785
|
const outdir = options.outdir;
|
|
2788
2786
|
if (!options.dry && outdir) {
|
|
2789
2787
|
fs.ensureDirSync(outdir);
|
|
2790
|
-
|
|
2788
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/config.json`)}`);
|
|
2791
2789
|
await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2792
2790
|
}
|
|
2793
2791
|
if (options.onlyConfig) {
|
|
@@ -2795,77 +2793,61 @@ async function debugFiles(ctx, options) {
|
|
|
2795
2793
|
return;
|
|
2796
2794
|
}
|
|
2797
2795
|
const filesWithCss = [];
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
if (!
|
|
2796
|
+
files.map((file) => {
|
|
2797
|
+
const measure = import_logger8.logger.time.debug(`Parsed ${file}`);
|
|
2798
|
+
const encoder = ctx.encoder.clone();
|
|
2799
|
+
const result = ctx.project.parseSourceFile(file, encoder);
|
|
2800
|
+
measure();
|
|
2801
|
+
if (!result || result.isEmpty() || encoder.isEmpty())
|
|
2802
|
+
return;
|
|
2803
|
+
const styles4 = ctx.decoder.clone().collect(encoder);
|
|
2804
|
+
const css = ctx.getParserCss(styles4, file);
|
|
2805
|
+
if (!css)
|
|
2808
2806
|
return;
|
|
2809
|
-
ctx.stylesheet.clean();
|
|
2810
|
-
ctx.appendParserCss(result);
|
|
2811
|
-
const css2 = ctx.stylesheet.toCss({ optimize: true, minify: false });
|
|
2812
2807
|
if (options.dry) {
|
|
2813
|
-
console.log({ path: file, ast: result, code:
|
|
2808
|
+
console.log({ path: file, ast: result, code: css });
|
|
2809
|
+
return;
|
|
2814
2810
|
}
|
|
2815
2811
|
if (outdir) {
|
|
2816
2812
|
filesWithCss.push(file);
|
|
2817
|
-
const parsedPath = (0,
|
|
2818
|
-
const
|
|
2819
|
-
const astJsonPath = `${
|
|
2820
|
-
const cssPath = `${
|
|
2821
|
-
|
|
2822
|
-
|
|
2813
|
+
const parsedPath = (0, import_pathe3.parse)(file);
|
|
2814
|
+
const relative2 = path.relative(ctx.config.cwd, parsedPath.dir);
|
|
2815
|
+
const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path.sep, "__");
|
|
2816
|
+
const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path.sep, "__");
|
|
2817
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2818
|
+
import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${cssPath}`)}`);
|
|
2823
2819
|
return Promise.allSettled([
|
|
2824
2820
|
fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2825
|
-
fs.writeFile(`${outdir}/${cssPath}`,
|
|
2821
|
+
fs.writeFile(`${outdir}/${cssPath}`, css)
|
|
2826
2822
|
]);
|
|
2827
2823
|
}
|
|
2828
2824
|
});
|
|
2829
|
-
|
|
2825
|
+
import_logger8.logger.info("cli", `Found ${import_logger8.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
2830
2826
|
measureTotal();
|
|
2831
2827
|
}
|
|
2832
2828
|
|
|
2833
|
-
// src/exec-command.ts
|
|
2834
|
-
init_cjs_shims();
|
|
2835
|
-
var import_logger8 = require("@pandacss/logger");
|
|
2836
|
-
var import_child_process = require("child_process");
|
|
2837
|
-
var import_preferred_pm = __toESM(require("preferred-pm"));
|
|
2838
|
-
async function execCommand(cmd, cwd) {
|
|
2839
|
-
const manager = await (0, import_preferred_pm.default)(cwd);
|
|
2840
|
-
const pm = manager?.name ?? "npm";
|
|
2841
|
-
const args = cmd.split(" ");
|
|
2842
|
-
if (pm === "npm") {
|
|
2843
|
-
args.unshift("run");
|
|
2844
|
-
}
|
|
2845
|
-
const check = (0, import_child_process.spawnSync)(pm, args, { cwd, stdio: "pipe" });
|
|
2846
|
-
if (check.status !== 0) {
|
|
2847
|
-
import_logger8.logger.error("exec", check.stderr.toString());
|
|
2848
|
-
}
|
|
2849
|
-
}
|
|
2850
|
-
|
|
2851
2829
|
// src/generate.ts
|
|
2852
2830
|
init_cjs_shims();
|
|
2853
2831
|
var import_logger9 = require("@pandacss/logger");
|
|
2854
2832
|
var import_ts_pattern = require("ts-pattern");
|
|
2855
|
-
async function build(ctx,
|
|
2856
|
-
await
|
|
2833
|
+
async function build(ctx, artifactIds) {
|
|
2834
|
+
await codegen(ctx, artifactIds);
|
|
2857
2835
|
if (ctx.config.emitTokensOnly) {
|
|
2858
2836
|
return import_logger9.logger.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
|
|
2859
2837
|
}
|
|
2860
|
-
ctx.
|
|
2861
|
-
|
|
2838
|
+
const sheet = ctx.createSheet();
|
|
2839
|
+
ctx.appendLayerParams(sheet);
|
|
2840
|
+
ctx.appendBaselineCss(sheet);
|
|
2841
|
+
ctx.parseFiles();
|
|
2842
|
+
ctx.appendParserCss(sheet);
|
|
2843
|
+
await ctx.writeCss(sheet);
|
|
2862
2844
|
import_logger9.logger.info("css:emit", "Successfully built the css files \u2728");
|
|
2863
2845
|
}
|
|
2864
2846
|
async function generate(config, configPath) {
|
|
2865
2847
|
let ctx = await loadConfigAndCreateContext({ config, configPath });
|
|
2866
2848
|
await build(ctx);
|
|
2867
2849
|
const {
|
|
2868
|
-
runtime: { fs, path
|
|
2850
|
+
runtime: { fs, path },
|
|
2869
2851
|
config: { cwd }
|
|
2870
2852
|
} = ctx;
|
|
2871
2853
|
if (ctx.config.watch) {
|
|
@@ -2874,27 +2856,39 @@ async function generate(config, configPath) {
|
|
|
2874
2856
|
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2875
2857
|
ctx = new PandaContext({ ...conf, hooks: ctx.hooks });
|
|
2876
2858
|
});
|
|
2877
|
-
if (!affecteds.
|
|
2859
|
+
if (!affecteds.hasConfigChanged) {
|
|
2860
|
+
import_logger9.logger.debug("builder", "Config didnt change, skipping rebuild");
|
|
2878
2861
|
return;
|
|
2862
|
+
}
|
|
2879
2863
|
import_logger9.logger.info("config:change", "Config changed, restarting...");
|
|
2880
2864
|
await ctx.hooks.callHook("config:change", ctx.config);
|
|
2881
2865
|
return build(ctx, Array.from(affecteds.artifacts));
|
|
2882
2866
|
});
|
|
2883
2867
|
const contentWatcher = fs.watch(ctx.config);
|
|
2868
|
+
const bundleStyles = async (ctx2, changedFilePath) => {
|
|
2869
|
+
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
2870
|
+
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
2871
|
+
if (parserResult) {
|
|
2872
|
+
const sheet = ctx2.createSheet();
|
|
2873
|
+
ctx2.appendLayerParams(sheet);
|
|
2874
|
+
ctx2.appendBaselineCss(sheet);
|
|
2875
|
+
ctx2.appendParserCss(sheet);
|
|
2876
|
+
const css = ctx2.getCss(sheet);
|
|
2877
|
+
await ctx2.runtime.fs.writeFile(outfile, css);
|
|
2878
|
+
return { msg: ctx2.messages.buildComplete(1) };
|
|
2879
|
+
}
|
|
2880
|
+
};
|
|
2884
2881
|
contentWatcher.on("all", async (event, file) => {
|
|
2885
2882
|
import_logger9.logger.info(`file:${event}`, file);
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2883
|
+
const filePath = path.abs(cwd, file);
|
|
2884
|
+
(0, import_ts_pattern.match)(event).with("unlink", () => {
|
|
2885
|
+
ctx.project.removeSourceFile(path.abs(cwd, file));
|
|
2886
|
+
}).with("change", async () => {
|
|
2889
2887
|
ctx.project.reloadSourceFile(file);
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
return ctx.writeCss();
|
|
2893
|
-
}).with("add", () => {
|
|
2888
|
+
return bundleStyles(ctx, filePath);
|
|
2889
|
+
}).with("add", async () => {
|
|
2894
2890
|
ctx.project.createSourceFile(file);
|
|
2895
|
-
|
|
2896
|
-
ctx.appendParserCss(result);
|
|
2897
|
-
return ctx.writeCss();
|
|
2891
|
+
return bundleStyles(ctx, filePath);
|
|
2898
2892
|
}).otherwise(() => {
|
|
2899
2893
|
});
|
|
2900
2894
|
});
|
|
@@ -2905,7 +2899,7 @@ async function generate(config, configPath) {
|
|
|
2905
2899
|
// src/git-ignore.ts
|
|
2906
2900
|
init_cjs_shims();
|
|
2907
2901
|
var import_fs2 = require("fs");
|
|
2908
|
-
var
|
|
2902
|
+
var import_look_it_up = require("look-it-up");
|
|
2909
2903
|
var import_outdent = __toESM(require("outdent"));
|
|
2910
2904
|
function setupGitIgnore(ctx) {
|
|
2911
2905
|
const { outdir, gitignore } = ctx.config;
|
|
@@ -2917,7 +2911,7 @@ function setupGitIgnore(ctx) {
|
|
|
2917
2911
|
${outdir}
|
|
2918
2912
|
${ctx.studio.outdir}
|
|
2919
2913
|
`;
|
|
2920
|
-
const file = (0,
|
|
2914
|
+
const file = (0, import_look_it_up.lookItUpSync)(".gitignore");
|
|
2921
2915
|
if (!file) {
|
|
2922
2916
|
return (0, import_fs2.writeFileSync)(".gitignore", txt);
|
|
2923
2917
|
}
|
|
@@ -2929,21 +2923,22 @@ function setupGitIgnore(ctx) {
|
|
|
2929
2923
|
|
|
2930
2924
|
// src/setup-config.ts
|
|
2931
2925
|
init_cjs_shims();
|
|
2926
|
+
var import_config6 = require("@pandacss/config");
|
|
2932
2927
|
var import_generator3 = require("@pandacss/generator");
|
|
2933
2928
|
var import_logger10 = require("@pandacss/logger");
|
|
2934
|
-
var
|
|
2935
|
-
var
|
|
2929
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
2930
|
+
var import_look_it_up2 = require("look-it-up");
|
|
2936
2931
|
var import_outdent2 = require("outdent");
|
|
2937
|
-
var
|
|
2938
|
-
var
|
|
2932
|
+
var import_pathe4 = require("pathe");
|
|
2933
|
+
var import_preferred_pm = __toESM(require("preferred-pm"));
|
|
2939
2934
|
var import_prettier = __toESM(require("prettier"));
|
|
2940
2935
|
async function setupConfig(cwd, opts = {}) {
|
|
2941
2936
|
const { force, outExtension, jsxFramework, syntax } = opts;
|
|
2942
|
-
const configFile = findConfig();
|
|
2943
|
-
const pmResult = await (0,
|
|
2937
|
+
const configFile = (0, import_config6.findConfig)({ cwd });
|
|
2938
|
+
const pmResult = await (0, import_preferred_pm.default)(cwd);
|
|
2944
2939
|
const pm = pmResult?.name ?? "npm";
|
|
2945
2940
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
2946
|
-
const isTs = (0,
|
|
2941
|
+
const isTs = (0, import_look_it_up2.lookItUpSync)("tsconfig.json", cwd);
|
|
2947
2942
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
2948
2943
|
import_logger10.logger.info("init:config", `creating panda config file: ${(0, import_logger10.quote)(file)}`);
|
|
2949
2944
|
if (!force && configFile) {
|
|
@@ -2979,7 +2974,7 @@ jsxFramework: '${jsxFramework}',` : ""}
|
|
|
2979
2974
|
syntax: '${syntax}'` : ""}
|
|
2980
2975
|
})
|
|
2981
2976
|
`;
|
|
2982
|
-
await
|
|
2977
|
+
await import_fs_extra2.default.writeFile((0, import_pathe4.join)(cwd, file), import_prettier.default.format(content));
|
|
2983
2978
|
import_logger10.logger.log(import_generator3.messages.thankYou());
|
|
2984
2979
|
}
|
|
2985
2980
|
}
|
|
@@ -2992,51 +2987,22 @@ module.exports = {
|
|
|
2992
2987
|
},
|
|
2993
2988
|
}
|
|
2994
2989
|
`;
|
|
2995
|
-
await
|
|
2996
|
-
}
|
|
2997
|
-
|
|
2998
|
-
// src/ship-files.ts
|
|
2999
|
-
init_cjs_shims();
|
|
3000
|
-
var import_logger11 = require("@pandacss/logger");
|
|
3001
|
-
var import_parser2 = require("@pandacss/parser");
|
|
3002
|
-
var import_promises2 = require("fs/promises");
|
|
3003
|
-
var path = __toESM(require("pathe"));
|
|
3004
|
-
async function shipFiles(ctx, outfile) {
|
|
3005
|
-
const files = ctx.getFiles();
|
|
3006
|
-
const extractResult = (0, import_parser2.createParserResult)();
|
|
3007
|
-
const filesWithCss = [];
|
|
3008
|
-
files.forEach(async (file) => {
|
|
3009
|
-
const result = ctx.project.parseSourceFile(file);
|
|
3010
|
-
if (!result || result.isEmpty())
|
|
3011
|
-
return;
|
|
3012
|
-
extractResult.merge(result);
|
|
3013
|
-
filesWithCss.push(path.relative(ctx.config.cwd, file));
|
|
3014
|
-
});
|
|
3015
|
-
import_logger11.logger.info("cli", `Found ${import_logger11.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
3016
|
-
const minify = ctx.config.minify;
|
|
3017
|
-
import_logger11.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger11.colors.bold(outfile)}`);
|
|
3018
|
-
const output = JSON.stringify(extractResult.toJSON(), null, minify ? 0 : 2);
|
|
3019
|
-
const dirname2 = ctx.runtime.path.dirname(outfile);
|
|
3020
|
-
ctx.runtime.fs.ensureDirSync(dirname2);
|
|
3021
|
-
await (0, import_promises2.writeFile)(outfile, output);
|
|
3022
|
-
import_logger11.logger.info("cli", "Done!");
|
|
2990
|
+
await import_fs_extra2.default.writeFile((0, import_pathe4.join)(cwd, "postcss.config.cjs"), content);
|
|
3023
2991
|
}
|
|
3024
2992
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3025
2993
|
0 && (module.exports = {
|
|
3026
2994
|
Builder,
|
|
3027
2995
|
PandaContext,
|
|
3028
2996
|
analyzeTokens,
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
findConfig,
|
|
2997
|
+
buildInfo,
|
|
2998
|
+
codegen,
|
|
2999
|
+
cssgen,
|
|
3000
|
+
debug,
|
|
3034
3001
|
generate,
|
|
3035
3002
|
loadConfigAndCreateContext,
|
|
3036
3003
|
parseDependency,
|
|
3037
3004
|
setupConfig,
|
|
3038
3005
|
setupGitIgnore,
|
|
3039
3006
|
setupPostcss,
|
|
3040
|
-
shipFiles,
|
|
3041
3007
|
writeAnalyzeJSON
|
|
3042
3008
|
});
|