@pandacss/node 0.0.0-dev-20240119193256 → 0.0.0-dev-20240120164018
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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +78 -46
- package/dist/index.mjs +68 -37
- package/package.json +12 -11
package/dist/index.d.mts
CHANGED
|
@@ -245,6 +245,8 @@ declare function codegen(ctx: PandaContext, ids?: ArtifactId[]): Promise<{
|
|
|
245
245
|
msg: string;
|
|
246
246
|
}>;
|
|
247
247
|
|
|
248
|
+
declare const startProfiling: (cwd: string, prefix: string) => Promise<() => void>;
|
|
249
|
+
|
|
248
250
|
declare function loadConfigAndCreateContext(options?: {
|
|
249
251
|
cwd?: string;
|
|
250
252
|
config?: Config;
|
|
@@ -278,4 +280,4 @@ type SetupOptions = Partial<Config> & {
|
|
|
278
280
|
declare function setupConfig(cwd: string, opts?: SetupOptions): Promise<void>;
|
|
279
281
|
declare function setupPostcss(cwd: string): Promise<void>;
|
|
280
282
|
|
|
281
|
-
export { Builder, type CssGenOptions, PandaContext, analyzeTokens, buildInfo, codegen, cssgen, debug, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, writeAnalyzeJSON };
|
|
283
|
+
export { Builder, type CssGenOptions, PandaContext, analyzeTokens, buildInfo, codegen, cssgen, debug, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, startProfiling, writeAnalyzeJSON };
|
package/dist/index.d.ts
CHANGED
|
@@ -245,6 +245,8 @@ declare function codegen(ctx: PandaContext, ids?: ArtifactId[]): Promise<{
|
|
|
245
245
|
msg: string;
|
|
246
246
|
}>;
|
|
247
247
|
|
|
248
|
+
declare const startProfiling: (cwd: string, prefix: string) => Promise<() => void>;
|
|
249
|
+
|
|
248
250
|
declare function loadConfigAndCreateContext(options?: {
|
|
249
251
|
cwd?: string;
|
|
250
252
|
config?: Config;
|
|
@@ -278,4 +280,4 @@ type SetupOptions = Partial<Config> & {
|
|
|
278
280
|
declare function setupConfig(cwd: string, opts?: SetupOptions): Promise<void>;
|
|
279
281
|
declare function setupPostcss(cwd: string): Promise<void>;
|
|
280
282
|
|
|
281
|
-
export { Builder, type CssGenOptions, PandaContext, analyzeTokens, buildInfo, codegen, cssgen, debug, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, writeAnalyzeJSON };
|
|
283
|
+
export { Builder, type CssGenOptions, PandaContext, analyzeTokens, buildInfo, codegen, cssgen, debug, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, startProfiling, writeAnalyzeJSON };
|
package/dist/index.js
CHANGED
|
@@ -416,6 +416,7 @@ __export(src_exports, {
|
|
|
416
416
|
setupConfig: () => setupConfig,
|
|
417
417
|
setupGitIgnore: () => setupGitIgnore,
|
|
418
418
|
setupPostcss: () => setupPostcss,
|
|
419
|
+
startProfiling: () => startProfiling,
|
|
419
420
|
writeAnalyzeJSON: () => writeAnalyzeJSON
|
|
420
421
|
});
|
|
421
422
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -2326,8 +2327,8 @@ var nodeRuntime = {
|
|
|
2326
2327
|
readDirSync: import_fs_extra.default.readdirSync,
|
|
2327
2328
|
rmDirSync: import_fs_extra.default.emptyDirSync,
|
|
2328
2329
|
rmFileSync: import_fs_extra.default.removeSync,
|
|
2329
|
-
ensureDirSync(
|
|
2330
|
-
return import_fs_extra.default.ensureDirSync(
|
|
2330
|
+
ensureDirSync(path2) {
|
|
2331
|
+
return import_fs_extra.default.ensureDirSync(path2);
|
|
2331
2332
|
},
|
|
2332
2333
|
watch(options) {
|
|
2333
2334
|
const { include, exclude, cwd, poll } = options;
|
|
@@ -2753,14 +2754,44 @@ var Builder = class {
|
|
|
2753
2754
|
};
|
|
2754
2755
|
};
|
|
2755
2756
|
|
|
2756
|
-
// src/
|
|
2757
|
+
// src/cpu-profile.ts
|
|
2757
2758
|
init_cjs_shims();
|
|
2758
2759
|
var import_logger7 = require("@pandacss/logger");
|
|
2760
|
+
var import_fs2 = __toESM(require("fs"));
|
|
2761
|
+
var import_path4 = __toESM(require("path"));
|
|
2762
|
+
var startProfiling = async (cwd, prefix) => {
|
|
2763
|
+
const v8Profiler = (await import("v8-profiler-next")).default;
|
|
2764
|
+
const date = /* @__PURE__ */ new Date();
|
|
2765
|
+
const timestamp = date.toISOString().replace(/[-:.]/g, "");
|
|
2766
|
+
const title = `panda-${prefix}-${timestamp}`;
|
|
2767
|
+
v8Profiler.setGenerateType(1);
|
|
2768
|
+
v8Profiler.startProfiling(title, true);
|
|
2769
|
+
const stopProfiling = () => {
|
|
2770
|
+
const profile = v8Profiler.stopProfiling(title);
|
|
2771
|
+
profile.export(function(error, result) {
|
|
2772
|
+
if (error) {
|
|
2773
|
+
console.error(error);
|
|
2774
|
+
return;
|
|
2775
|
+
}
|
|
2776
|
+
if (!result)
|
|
2777
|
+
return;
|
|
2778
|
+
const outfile = import_path4.default.join(cwd, `${title}.cpuprofile`);
|
|
2779
|
+
import_fs2.default.writeFileSync(outfile, result);
|
|
2780
|
+
import_logger7.logger.info("cpu-prof", outfile);
|
|
2781
|
+
profile.delete();
|
|
2782
|
+
});
|
|
2783
|
+
};
|
|
2784
|
+
return stopProfiling;
|
|
2785
|
+
};
|
|
2786
|
+
|
|
2787
|
+
// src/cssgen.ts
|
|
2788
|
+
init_cjs_shims();
|
|
2789
|
+
var import_logger8 = require("@pandacss/logger");
|
|
2759
2790
|
var cssgen = async (ctx, options) => {
|
|
2760
2791
|
const { outfile, type, minimal } = options;
|
|
2761
2792
|
const sheet = ctx.createSheet();
|
|
2762
2793
|
if (type) {
|
|
2763
|
-
const done =
|
|
2794
|
+
const done = import_logger8.logger.time.info(ctx.messages.cssArtifactComplete(type));
|
|
2764
2795
|
ctx.appendCssOfType(type, sheet);
|
|
2765
2796
|
if (outfile) {
|
|
2766
2797
|
const css = ctx.getCss(sheet);
|
|
@@ -2771,7 +2802,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2771
2802
|
done();
|
|
2772
2803
|
} else {
|
|
2773
2804
|
const { files } = ctx.parseFiles();
|
|
2774
|
-
const done =
|
|
2805
|
+
const done = import_logger8.logger.time.info(ctx.messages.buildComplete(files.length));
|
|
2775
2806
|
if (!minimal) {
|
|
2776
2807
|
ctx.appendLayerParams(sheet);
|
|
2777
2808
|
ctx.appendBaselineCss(sheet);
|
|
@@ -2789,19 +2820,19 @@ var cssgen = async (ctx, options) => {
|
|
|
2789
2820
|
|
|
2790
2821
|
// src/debug.ts
|
|
2791
2822
|
init_cjs_shims();
|
|
2792
|
-
var
|
|
2793
|
-
var
|
|
2823
|
+
var import_logger9 = require("@pandacss/logger");
|
|
2824
|
+
var import_path5 = require("path");
|
|
2794
2825
|
async function debug(ctx, options) {
|
|
2795
2826
|
const files = ctx.getFiles();
|
|
2796
|
-
const measureTotal =
|
|
2827
|
+
const measureTotal = import_logger9.logger.time.debug(`Done parsing ${files.length} files`);
|
|
2797
2828
|
ctx.config.minify = false;
|
|
2798
2829
|
ctx.config.optimize = true;
|
|
2799
|
-
const { fs, path } = ctx.runtime;
|
|
2830
|
+
const { fs: fs2, path: path2 } = ctx.runtime;
|
|
2800
2831
|
const outdir = options.outdir;
|
|
2801
2832
|
if (!options.dry && outdir) {
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
await
|
|
2833
|
+
fs2.ensureDirSync(outdir);
|
|
2834
|
+
import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/config.json`)}`);
|
|
2835
|
+
await fs2.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2805
2836
|
}
|
|
2806
2837
|
if (options.onlyConfig) {
|
|
2807
2838
|
measureTotal();
|
|
@@ -2809,7 +2840,7 @@ async function debug(ctx, options) {
|
|
|
2809
2840
|
}
|
|
2810
2841
|
const filesWithCss = [];
|
|
2811
2842
|
files.map((file) => {
|
|
2812
|
-
const measure =
|
|
2843
|
+
const measure = import_logger9.logger.time.debug(`Parsed ${file}`);
|
|
2813
2844
|
const encoder = ctx.encoder.clone();
|
|
2814
2845
|
const result = ctx.project.parseSourceFile(file, encoder);
|
|
2815
2846
|
measure();
|
|
@@ -2825,32 +2856,32 @@ async function debug(ctx, options) {
|
|
|
2825
2856
|
}
|
|
2826
2857
|
if (outdir) {
|
|
2827
2858
|
filesWithCss.push(file);
|
|
2828
|
-
const parsedPath = (0,
|
|
2829
|
-
const relative2 =
|
|
2830
|
-
const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(
|
|
2831
|
-
const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(
|
|
2832
|
-
|
|
2833
|
-
|
|
2859
|
+
const parsedPath = (0, import_path5.parse)(file);
|
|
2860
|
+
const relative2 = path2.relative(ctx.config.cwd, parsedPath.dir);
|
|
2861
|
+
const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
|
|
2862
|
+
const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
|
|
2863
|
+
import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2864
|
+
import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/${cssPath}`)}`);
|
|
2834
2865
|
return Promise.allSettled([
|
|
2835
|
-
|
|
2836
|
-
|
|
2866
|
+
fs2.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2867
|
+
fs2.writeFile(`${outdir}/${cssPath}`, css)
|
|
2837
2868
|
]);
|
|
2838
2869
|
}
|
|
2839
2870
|
});
|
|
2840
|
-
|
|
2871
|
+
import_logger9.logger.info("cli", `Found ${import_logger9.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
2841
2872
|
measureTotal();
|
|
2842
2873
|
}
|
|
2843
2874
|
|
|
2844
2875
|
// src/generate.ts
|
|
2845
2876
|
init_cjs_shims();
|
|
2846
|
-
var
|
|
2877
|
+
var import_logger10 = require("@pandacss/logger");
|
|
2847
2878
|
var import_ts_pattern = require("ts-pattern");
|
|
2848
2879
|
async function build(ctx, artifactIds) {
|
|
2849
2880
|
await codegen(ctx, artifactIds);
|
|
2850
2881
|
if (ctx.config.emitTokensOnly) {
|
|
2851
|
-
return
|
|
2882
|
+
return import_logger10.logger.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
|
|
2852
2883
|
}
|
|
2853
|
-
const done =
|
|
2884
|
+
const done = import_logger10.logger.time.info("");
|
|
2854
2885
|
const sheet = ctx.createSheet();
|
|
2855
2886
|
ctx.appendLayerParams(sheet);
|
|
2856
2887
|
ctx.appendBaselineCss(sheet);
|
|
@@ -2863,24 +2894,24 @@ async function generate(config, configPath) {
|
|
|
2863
2894
|
let ctx = await loadConfigAndCreateContext({ config, configPath });
|
|
2864
2895
|
await build(ctx);
|
|
2865
2896
|
const {
|
|
2866
|
-
runtime: { fs, path },
|
|
2897
|
+
runtime: { fs: fs2, path: path2 },
|
|
2867
2898
|
config: { cwd }
|
|
2868
2899
|
} = ctx;
|
|
2869
2900
|
if (ctx.config.watch) {
|
|
2870
|
-
const configWatcher =
|
|
2901
|
+
const configWatcher = fs2.watch({ include: ctx.conf.dependencies });
|
|
2871
2902
|
configWatcher.on("change", async () => {
|
|
2872
2903
|
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2873
2904
|
ctx = new PandaContext({ ...conf, hooks: ctx.hooks });
|
|
2874
2905
|
});
|
|
2875
2906
|
if (!affecteds.hasConfigChanged) {
|
|
2876
|
-
|
|
2907
|
+
import_logger10.logger.debug("builder", "Config didnt change, skipping rebuild");
|
|
2877
2908
|
return;
|
|
2878
2909
|
}
|
|
2879
|
-
|
|
2910
|
+
import_logger10.logger.info("config:change", "Config changed, restarting...");
|
|
2880
2911
|
await ctx.hooks.callHook("config:change", ctx.config);
|
|
2881
2912
|
return build(ctx, Array.from(affecteds.artifacts));
|
|
2882
2913
|
});
|
|
2883
|
-
const contentWatcher =
|
|
2914
|
+
const contentWatcher = fs2.watch(ctx.config);
|
|
2884
2915
|
const bundleStyles = async (ctx2, changedFilePath) => {
|
|
2885
2916
|
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
2886
2917
|
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
@@ -2895,10 +2926,10 @@ async function generate(config, configPath) {
|
|
|
2895
2926
|
}
|
|
2896
2927
|
};
|
|
2897
2928
|
contentWatcher.on("all", async (event, file) => {
|
|
2898
|
-
|
|
2899
|
-
const filePath =
|
|
2929
|
+
import_logger10.logger.info(`file:${event}`, file);
|
|
2930
|
+
const filePath = path2.abs(cwd, file);
|
|
2900
2931
|
(0, import_ts_pattern.match)(event).with("unlink", () => {
|
|
2901
|
-
ctx.project.removeSourceFile(
|
|
2932
|
+
ctx.project.removeSourceFile(path2.abs(cwd, file));
|
|
2902
2933
|
}).with("change", async () => {
|
|
2903
2934
|
ctx.project.reloadSourceFile(file);
|
|
2904
2935
|
return bundleStyles(ctx, filePath);
|
|
@@ -2908,13 +2939,13 @@ async function generate(config, configPath) {
|
|
|
2908
2939
|
}).otherwise(() => {
|
|
2909
2940
|
});
|
|
2910
2941
|
});
|
|
2911
|
-
|
|
2942
|
+
import_logger10.logger.info("ctx:watch", ctx.messages.watch());
|
|
2912
2943
|
}
|
|
2913
2944
|
}
|
|
2914
2945
|
|
|
2915
2946
|
// src/git-ignore.ts
|
|
2916
2947
|
init_cjs_shims();
|
|
2917
|
-
var
|
|
2948
|
+
var import_fs3 = require("fs");
|
|
2918
2949
|
var import_look_it_up = require("look-it-up");
|
|
2919
2950
|
var import_outdent = __toESM(require("outdent"));
|
|
2920
2951
|
function setupGitIgnore(ctx) {
|
|
@@ -2929,11 +2960,11 @@ function setupGitIgnore(ctx) {
|
|
|
2929
2960
|
`;
|
|
2930
2961
|
const file = (0, import_look_it_up.lookItUpSync)(".gitignore");
|
|
2931
2962
|
if (!file) {
|
|
2932
|
-
return (0,
|
|
2963
|
+
return (0, import_fs3.writeFileSync)(".gitignore", txt);
|
|
2933
2964
|
}
|
|
2934
|
-
const content = (0,
|
|
2965
|
+
const content = (0, import_fs3.readFileSync)(file, "utf-8");
|
|
2935
2966
|
if (!content.includes(outdir)) {
|
|
2936
|
-
(0,
|
|
2967
|
+
(0, import_fs3.appendFileSync)(file, txt);
|
|
2937
2968
|
}
|
|
2938
2969
|
}
|
|
2939
2970
|
|
|
@@ -2941,11 +2972,11 @@ function setupGitIgnore(ctx) {
|
|
|
2941
2972
|
init_cjs_shims();
|
|
2942
2973
|
var import_config7 = require("@pandacss/config");
|
|
2943
2974
|
var import_core2 = require("@pandacss/core");
|
|
2944
|
-
var
|
|
2975
|
+
var import_logger11 = require("@pandacss/logger");
|
|
2945
2976
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
2946
2977
|
var import_look_it_up2 = require("look-it-up");
|
|
2947
2978
|
var import_outdent2 = require("outdent");
|
|
2948
|
-
var
|
|
2979
|
+
var import_path6 = require("path");
|
|
2949
2980
|
var import_preferred_pm = __toESM(require("preferred-pm"));
|
|
2950
2981
|
var import_prettier = __toESM(require("prettier"));
|
|
2951
2982
|
async function setupConfig(cwd, opts = {}) {
|
|
@@ -2956,9 +2987,9 @@ async function setupConfig(cwd, opts = {}) {
|
|
|
2956
2987
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
2957
2988
|
const isTs = (0, import_look_it_up2.lookItUpSync)("tsconfig.json", cwd);
|
|
2958
2989
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
2959
|
-
|
|
2990
|
+
import_logger11.logger.info("init:config", `creating panda config file: ${(0, import_logger11.quote)(file)}`);
|
|
2960
2991
|
if (!force && configFile) {
|
|
2961
|
-
|
|
2992
|
+
import_logger11.logger.warn("init:config", import_core2.messages.configExists(cmd));
|
|
2962
2993
|
} else {
|
|
2963
2994
|
const content = import_outdent2.outdent`
|
|
2964
2995
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -2990,12 +3021,12 @@ jsxFramework: '${jsxFramework}',` : ""}
|
|
|
2990
3021
|
syntax: '${syntax}'` : ""}
|
|
2991
3022
|
})
|
|
2992
3023
|
`;
|
|
2993
|
-
await import_fs_extra2.default.writeFile((0,
|
|
2994
|
-
|
|
3024
|
+
await import_fs_extra2.default.writeFile((0, import_path6.join)(cwd, file), import_prettier.default.format(content, { parser: "babel" }));
|
|
3025
|
+
import_logger11.logger.log(import_core2.messages.thankYou());
|
|
2995
3026
|
}
|
|
2996
3027
|
}
|
|
2997
3028
|
async function setupPostcss(cwd) {
|
|
2998
|
-
|
|
3029
|
+
import_logger11.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger11.quote)("postcss.config.cjs")}`);
|
|
2999
3030
|
const content = import_outdent2.outdent`
|
|
3000
3031
|
module.exports = {
|
|
3001
3032
|
plugins: {
|
|
@@ -3003,7 +3034,7 @@ module.exports = {
|
|
|
3003
3034
|
},
|
|
3004
3035
|
}
|
|
3005
3036
|
`;
|
|
3006
|
-
await import_fs_extra2.default.writeFile((0,
|
|
3037
|
+
await import_fs_extra2.default.writeFile((0, import_path6.join)(cwd, "postcss.config.cjs"), content);
|
|
3007
3038
|
}
|
|
3008
3039
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3009
3040
|
0 && (module.exports = {
|
|
@@ -3020,5 +3051,6 @@ module.exports = {
|
|
|
3020
3051
|
setupConfig,
|
|
3021
3052
|
setupGitIgnore,
|
|
3022
3053
|
setupPostcss,
|
|
3054
|
+
startProfiling,
|
|
3023
3055
|
writeAnalyzeJSON
|
|
3024
3056
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2302,8 +2302,8 @@ var nodeRuntime = {
|
|
|
2302
2302
|
readDirSync: fsExtra.readdirSync,
|
|
2303
2303
|
rmDirSync: fsExtra.emptyDirSync,
|
|
2304
2304
|
rmFileSync: fsExtra.removeSync,
|
|
2305
|
-
ensureDirSync(
|
|
2306
|
-
return fsExtra.ensureDirSync(
|
|
2305
|
+
ensureDirSync(path2) {
|
|
2306
|
+
return fsExtra.ensureDirSync(path2);
|
|
2307
2307
|
},
|
|
2308
2308
|
watch(options) {
|
|
2309
2309
|
const { include, exclude, cwd, poll } = options;
|
|
@@ -2729,14 +2729,44 @@ var Builder = class {
|
|
|
2729
2729
|
};
|
|
2730
2730
|
};
|
|
2731
2731
|
|
|
2732
|
-
// src/
|
|
2732
|
+
// src/cpu-profile.ts
|
|
2733
2733
|
init_esm_shims();
|
|
2734
2734
|
import { logger as logger7 } from "@pandacss/logger";
|
|
2735
|
+
import fs from "fs";
|
|
2736
|
+
import path from "path";
|
|
2737
|
+
var startProfiling = async (cwd, prefix) => {
|
|
2738
|
+
const v8Profiler = (await import("v8-profiler-next")).default;
|
|
2739
|
+
const date = /* @__PURE__ */ new Date();
|
|
2740
|
+
const timestamp = date.toISOString().replace(/[-:.]/g, "");
|
|
2741
|
+
const title = `panda-${prefix}-${timestamp}`;
|
|
2742
|
+
v8Profiler.setGenerateType(1);
|
|
2743
|
+
v8Profiler.startProfiling(title, true);
|
|
2744
|
+
const stopProfiling = () => {
|
|
2745
|
+
const profile = v8Profiler.stopProfiling(title);
|
|
2746
|
+
profile.export(function(error, result) {
|
|
2747
|
+
if (error) {
|
|
2748
|
+
console.error(error);
|
|
2749
|
+
return;
|
|
2750
|
+
}
|
|
2751
|
+
if (!result)
|
|
2752
|
+
return;
|
|
2753
|
+
const outfile = path.join(cwd, `${title}.cpuprofile`);
|
|
2754
|
+
fs.writeFileSync(outfile, result);
|
|
2755
|
+
logger7.info("cpu-prof", outfile);
|
|
2756
|
+
profile.delete();
|
|
2757
|
+
});
|
|
2758
|
+
};
|
|
2759
|
+
return stopProfiling;
|
|
2760
|
+
};
|
|
2761
|
+
|
|
2762
|
+
// src/cssgen.ts
|
|
2763
|
+
init_esm_shims();
|
|
2764
|
+
import { logger as logger8 } from "@pandacss/logger";
|
|
2735
2765
|
var cssgen = async (ctx, options) => {
|
|
2736
2766
|
const { outfile, type, minimal } = options;
|
|
2737
2767
|
const sheet = ctx.createSheet();
|
|
2738
2768
|
if (type) {
|
|
2739
|
-
const done =
|
|
2769
|
+
const done = logger8.time.info(ctx.messages.cssArtifactComplete(type));
|
|
2740
2770
|
ctx.appendCssOfType(type, sheet);
|
|
2741
2771
|
if (outfile) {
|
|
2742
2772
|
const css = ctx.getCss(sheet);
|
|
@@ -2747,7 +2777,7 @@ var cssgen = async (ctx, options) => {
|
|
|
2747
2777
|
done();
|
|
2748
2778
|
} else {
|
|
2749
2779
|
const { files } = ctx.parseFiles();
|
|
2750
|
-
const done =
|
|
2780
|
+
const done = logger8.time.info(ctx.messages.buildComplete(files.length));
|
|
2751
2781
|
if (!minimal) {
|
|
2752
2782
|
ctx.appendLayerParams(sheet);
|
|
2753
2783
|
ctx.appendBaselineCss(sheet);
|
|
@@ -2765,19 +2795,19 @@ var cssgen = async (ctx, options) => {
|
|
|
2765
2795
|
|
|
2766
2796
|
// src/debug.ts
|
|
2767
2797
|
init_esm_shims();
|
|
2768
|
-
import { colors as colors2, logger as
|
|
2798
|
+
import { colors as colors2, logger as logger9 } from "@pandacss/logger";
|
|
2769
2799
|
import { parse as parse2 } from "path";
|
|
2770
2800
|
async function debug(ctx, options) {
|
|
2771
2801
|
const files = ctx.getFiles();
|
|
2772
|
-
const measureTotal =
|
|
2802
|
+
const measureTotal = logger9.time.debug(`Done parsing ${files.length} files`);
|
|
2773
2803
|
ctx.config.minify = false;
|
|
2774
2804
|
ctx.config.optimize = true;
|
|
2775
|
-
const { fs, path } = ctx.runtime;
|
|
2805
|
+
const { fs: fs2, path: path2 } = ctx.runtime;
|
|
2776
2806
|
const outdir = options.outdir;
|
|
2777
2807
|
if (!options.dry && outdir) {
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
await
|
|
2808
|
+
fs2.ensureDirSync(outdir);
|
|
2809
|
+
logger9.info("cli", `Writing ${colors2.bold(`${outdir}/config.json`)}`);
|
|
2810
|
+
await fs2.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
|
|
2781
2811
|
}
|
|
2782
2812
|
if (options.onlyConfig) {
|
|
2783
2813
|
measureTotal();
|
|
@@ -2785,7 +2815,7 @@ async function debug(ctx, options) {
|
|
|
2785
2815
|
}
|
|
2786
2816
|
const filesWithCss = [];
|
|
2787
2817
|
files.map((file) => {
|
|
2788
|
-
const measure =
|
|
2818
|
+
const measure = logger9.time.debug(`Parsed ${file}`);
|
|
2789
2819
|
const encoder = ctx.encoder.clone();
|
|
2790
2820
|
const result = ctx.project.parseSourceFile(file, encoder);
|
|
2791
2821
|
measure();
|
|
@@ -2802,31 +2832,31 @@ async function debug(ctx, options) {
|
|
|
2802
2832
|
if (outdir) {
|
|
2803
2833
|
filesWithCss.push(file);
|
|
2804
2834
|
const parsedPath = parse2(file);
|
|
2805
|
-
const relative2 =
|
|
2806
|
-
const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(
|
|
2807
|
-
const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(
|
|
2808
|
-
|
|
2809
|
-
|
|
2835
|
+
const relative2 = path2.relative(ctx.config.cwd, parsedPath.dir);
|
|
2836
|
+
const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
|
|
2837
|
+
const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
|
|
2838
|
+
logger9.info("cli", `Writing ${colors2.bold(`${outdir}/${astJsonPath}`)}`);
|
|
2839
|
+
logger9.info("cli", `Writing ${colors2.bold(`${outdir}/${cssPath}`)}`);
|
|
2810
2840
|
return Promise.allSettled([
|
|
2811
|
-
|
|
2812
|
-
|
|
2841
|
+
fs2.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
|
|
2842
|
+
fs2.writeFile(`${outdir}/${cssPath}`, css)
|
|
2813
2843
|
]);
|
|
2814
2844
|
}
|
|
2815
2845
|
});
|
|
2816
|
-
|
|
2846
|
+
logger9.info("cli", `Found ${colors2.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
|
|
2817
2847
|
measureTotal();
|
|
2818
2848
|
}
|
|
2819
2849
|
|
|
2820
2850
|
// src/generate.ts
|
|
2821
2851
|
init_esm_shims();
|
|
2822
|
-
import { logger as
|
|
2852
|
+
import { logger as logger10 } from "@pandacss/logger";
|
|
2823
2853
|
import { match } from "ts-pattern";
|
|
2824
2854
|
async function build(ctx, artifactIds) {
|
|
2825
2855
|
await codegen(ctx, artifactIds);
|
|
2826
2856
|
if (ctx.config.emitTokensOnly) {
|
|
2827
|
-
return
|
|
2857
|
+
return logger10.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
|
|
2828
2858
|
}
|
|
2829
|
-
const done =
|
|
2859
|
+
const done = logger10.time.info("");
|
|
2830
2860
|
const sheet = ctx.createSheet();
|
|
2831
2861
|
ctx.appendLayerParams(sheet);
|
|
2832
2862
|
ctx.appendBaselineCss(sheet);
|
|
@@ -2839,24 +2869,24 @@ async function generate(config, configPath) {
|
|
|
2839
2869
|
let ctx = await loadConfigAndCreateContext({ config, configPath });
|
|
2840
2870
|
await build(ctx);
|
|
2841
2871
|
const {
|
|
2842
|
-
runtime: { fs, path },
|
|
2872
|
+
runtime: { fs: fs2, path: path2 },
|
|
2843
2873
|
config: { cwd }
|
|
2844
2874
|
} = ctx;
|
|
2845
2875
|
if (ctx.config.watch) {
|
|
2846
|
-
const configWatcher =
|
|
2876
|
+
const configWatcher = fs2.watch({ include: ctx.conf.dependencies });
|
|
2847
2877
|
configWatcher.on("change", async () => {
|
|
2848
2878
|
const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
|
|
2849
2879
|
ctx = new PandaContext({ ...conf, hooks: ctx.hooks });
|
|
2850
2880
|
});
|
|
2851
2881
|
if (!affecteds.hasConfigChanged) {
|
|
2852
|
-
|
|
2882
|
+
logger10.debug("builder", "Config didnt change, skipping rebuild");
|
|
2853
2883
|
return;
|
|
2854
2884
|
}
|
|
2855
|
-
|
|
2885
|
+
logger10.info("config:change", "Config changed, restarting...");
|
|
2856
2886
|
await ctx.hooks.callHook("config:change", ctx.config);
|
|
2857
2887
|
return build(ctx, Array.from(affecteds.artifacts));
|
|
2858
2888
|
});
|
|
2859
|
-
const contentWatcher =
|
|
2889
|
+
const contentWatcher = fs2.watch(ctx.config);
|
|
2860
2890
|
const bundleStyles = async (ctx2, changedFilePath) => {
|
|
2861
2891
|
const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
|
|
2862
2892
|
const parserResult = ctx2.project.parseSourceFile(changedFilePath);
|
|
@@ -2871,10 +2901,10 @@ async function generate(config, configPath) {
|
|
|
2871
2901
|
}
|
|
2872
2902
|
};
|
|
2873
2903
|
contentWatcher.on("all", async (event, file) => {
|
|
2874
|
-
|
|
2875
|
-
const filePath =
|
|
2904
|
+
logger10.info(`file:${event}`, file);
|
|
2905
|
+
const filePath = path2.abs(cwd, file);
|
|
2876
2906
|
match(event).with("unlink", () => {
|
|
2877
|
-
ctx.project.removeSourceFile(
|
|
2907
|
+
ctx.project.removeSourceFile(path2.abs(cwd, file));
|
|
2878
2908
|
}).with("change", async () => {
|
|
2879
2909
|
ctx.project.reloadSourceFile(file);
|
|
2880
2910
|
return bundleStyles(ctx, filePath);
|
|
@@ -2884,7 +2914,7 @@ async function generate(config, configPath) {
|
|
|
2884
2914
|
}).otherwise(() => {
|
|
2885
2915
|
});
|
|
2886
2916
|
});
|
|
2887
|
-
|
|
2917
|
+
logger10.info("ctx:watch", ctx.messages.watch());
|
|
2888
2918
|
}
|
|
2889
2919
|
}
|
|
2890
2920
|
|
|
@@ -2917,7 +2947,7 @@ function setupGitIgnore(ctx) {
|
|
|
2917
2947
|
init_esm_shims();
|
|
2918
2948
|
import { findConfig as findConfig2 } from "@pandacss/config";
|
|
2919
2949
|
import { messages } from "@pandacss/core";
|
|
2920
|
-
import { logger as
|
|
2950
|
+
import { logger as logger11, quote } from "@pandacss/logger";
|
|
2921
2951
|
import fsExtra2 from "fs-extra";
|
|
2922
2952
|
import { lookItUpSync as lookItUpSync2 } from "look-it-up";
|
|
2923
2953
|
import { outdent as outdent2 } from "outdent";
|
|
@@ -2932,9 +2962,9 @@ async function setupConfig(cwd, opts = {}) {
|
|
|
2932
2962
|
const cmd = pm === "npm" ? "npm run" : pm;
|
|
2933
2963
|
const isTs = lookItUpSync2("tsconfig.json", cwd);
|
|
2934
2964
|
const file = isTs ? "panda.config.ts" : "panda.config.mjs";
|
|
2935
|
-
|
|
2965
|
+
logger11.info("init:config", `creating panda config file: ${quote(file)}`);
|
|
2936
2966
|
if (!force && configFile) {
|
|
2937
|
-
|
|
2967
|
+
logger11.warn("init:config", messages.configExists(cmd));
|
|
2938
2968
|
} else {
|
|
2939
2969
|
const content = outdent2`
|
|
2940
2970
|
import { defineConfig } from "@pandacss/dev"
|
|
@@ -2967,11 +2997,11 @@ syntax: '${syntax}'` : ""}
|
|
|
2967
2997
|
})
|
|
2968
2998
|
`;
|
|
2969
2999
|
await fsExtra2.writeFile(join2(cwd, file), prettier.format(content, { parser: "babel" }));
|
|
2970
|
-
|
|
3000
|
+
logger11.log(messages.thankYou());
|
|
2971
3001
|
}
|
|
2972
3002
|
}
|
|
2973
3003
|
async function setupPostcss(cwd) {
|
|
2974
|
-
|
|
3004
|
+
logger11.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
|
|
2975
3005
|
const content = outdent2`
|
|
2976
3006
|
module.exports = {
|
|
2977
3007
|
plugins: {
|
|
@@ -2995,5 +3025,6 @@ export {
|
|
|
2995
3025
|
setupConfig,
|
|
2996
3026
|
setupGitIgnore,
|
|
2997
3027
|
setupPostcss,
|
|
3028
|
+
startProfiling,
|
|
2998
3029
|
writeAnalyzeJSON
|
|
2999
3030
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/node",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20240120164018",
|
|
4
4
|
"description": "The core css panda library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -53,16 +53,17 @@
|
|
|
53
53
|
"ts-morph": "19.0.0",
|
|
54
54
|
"ts-pattern": "5.0.5",
|
|
55
55
|
"tsconfck": "^2.1.2",
|
|
56
|
-
"
|
|
57
|
-
"@pandacss/
|
|
58
|
-
"@pandacss/
|
|
59
|
-
"@pandacss/
|
|
60
|
-
"@pandacss/
|
|
61
|
-
"@pandacss/
|
|
62
|
-
"@pandacss/
|
|
63
|
-
"@pandacss/
|
|
64
|
-
"@pandacss/
|
|
65
|
-
"@pandacss/
|
|
56
|
+
"v8-profiler-next": "^1.10.0",
|
|
57
|
+
"@pandacss/config": "0.0.0-dev-20240120164018",
|
|
58
|
+
"@pandacss/core": "0.0.0-dev-20240120164018",
|
|
59
|
+
"@pandacss/error": "0.0.0-dev-20240120164018",
|
|
60
|
+
"@pandacss/extractor": "0.0.0-dev-20240120164018",
|
|
61
|
+
"@pandacss/generator": "0.0.0-dev-20240120164018",
|
|
62
|
+
"@pandacss/logger": "0.0.0-dev-20240120164018",
|
|
63
|
+
"@pandacss/parser": "0.0.0-dev-20240120164018",
|
|
64
|
+
"@pandacss/shared": "0.0.0-dev-20240120164018",
|
|
65
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20240120164018",
|
|
66
|
+
"@pandacss/types": "0.0.0-dev-20240120164018"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@types/fs-extra": "11.0.4",
|