@pandacss/node 0.32.1 → 0.34.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 CHANGED
@@ -232,7 +232,7 @@ declare function loadConfigAndCreateContext(options?: {
232
232
  configPath?: string;
233
233
  }): Promise<PandaContext>;
234
234
 
235
- declare const startProfiling: (cwd: string, prefix: string) => Promise<() => void>;
235
+ declare const startProfiling: (cwd: string, prefix: string, isWatching?: boolean) => Promise<(cb?: () => void) => void>;
236
236
 
237
237
  interface CssGenOptions {
238
238
  cwd: string;
package/dist/index.d.ts CHANGED
@@ -232,7 +232,7 @@ declare function loadConfigAndCreateContext(options?: {
232
232
  configPath?: string;
233
233
  }): Promise<PandaContext>;
234
234
 
235
- declare const startProfiling: (cwd: string, prefix: string) => Promise<() => void>;
235
+ declare const startProfiling: (cwd: string, prefix: string, isWatching?: boolean) => Promise<(cb?: () => void) => void>;
236
236
 
237
237
  interface CssGenOptions {
238
238
  cwd: string;
package/dist/index.js CHANGED
@@ -2776,31 +2776,76 @@ var Builder = class {
2776
2776
  // src/cpu-profile.ts
2777
2777
  init_cjs_shims();
2778
2778
  var import_logger7 = require("@pandacss/logger");
2779
- var import_fs2 = __toESM(require("fs"));
2780
- var import_path4 = __toESM(require("path"));
2781
- var startProfiling = async (cwd, prefix) => {
2779
+ var import_node_fs = __toESM(require("fs"));
2780
+ var import_node_path = __toESM(require("path"));
2781
+ var import_node_readline = __toESM(require("readline"));
2782
+ var startProfiling = async (cwd, prefix, isWatching) => {
2782
2783
  const inspector = await import("inspector").then((r) => r.default);
2783
2784
  const session = new inspector.Session();
2784
2785
  session.connect();
2786
+ let state = "idle";
2787
+ const setState = (s) => {
2788
+ state = s;
2789
+ };
2785
2790
  await new Promise((resolve4) => {
2786
2791
  session.post("Profiler.enable", () => {
2787
- session.post("Profiler.start", resolve4);
2792
+ session.post("Profiler.start", () => {
2793
+ setState("profiling");
2794
+ resolve4();
2795
+ });
2788
2796
  });
2789
2797
  });
2790
- const stopProfiling = () => {
2791
- session.post("Profiler.stop", (err, { profile }) => {
2798
+ const toggleProfiler = () => {
2799
+ if (state === "idle") {
2800
+ console.log("Starting CPU profiling...");
2801
+ setState("starting");
2802
+ session.post("Profiler.start", () => {
2803
+ setState("profiling");
2804
+ console.log("Press 'p' to stop profiling...");
2805
+ });
2806
+ } else if (state === "profiling") {
2807
+ console.log("Stopping CPU profiling...");
2808
+ stopProfiling();
2809
+ }
2810
+ };
2811
+ if (isWatching) {
2812
+ import_node_readline.default.emitKeypressEvents(process.stdin);
2813
+ if (process.stdin.isTTY)
2814
+ process.stdin.setRawMode(true);
2815
+ console.log("Press 'p' to stop profiling...");
2816
+ process.stdin.on("keypress", (str, key) => {
2817
+ if (key.name === "p") {
2818
+ toggleProfiler();
2819
+ }
2820
+ if (key.ctrl && key.name === "c") {
2821
+ stopProfiling(() => process.exit());
2822
+ }
2823
+ });
2824
+ }
2825
+ const stopProfiling = (cb) => {
2826
+ if (state !== "profiling") {
2827
+ cb?.();
2828
+ return;
2829
+ }
2830
+ setState("stopping");
2831
+ session.post("Profiler.stop", (err, params) => {
2832
+ setState("idle");
2792
2833
  if (err) {
2793
2834
  import_logger7.logger.error("cpu-prof", err);
2835
+ cb?.();
2794
2836
  return;
2795
2837
  }
2796
- if (!profile)
2838
+ if (!params?.profile) {
2839
+ cb?.();
2797
2840
  return;
2841
+ }
2798
2842
  const date = /* @__PURE__ */ new Date();
2799
2843
  const timestamp = date.toISOString().replace(/[-:.]/g, "");
2800
2844
  const title = `panda-${prefix}-${timestamp}`;
2801
- const outfile = import_path4.default.join(cwd, `${title}.cpuprofile`);
2802
- import_fs2.default.writeFileSync(outfile, JSON.stringify(profile));
2845
+ const outfile = import_node_path.default.join(cwd, `${title}.cpuprofile`);
2846
+ import_node_fs.default.writeFileSync(outfile, JSON.stringify(params.profile));
2803
2847
  import_logger7.logger.info("cpu-prof", outfile);
2848
+ cb?.();
2804
2849
  });
2805
2850
  };
2806
2851
  return stopProfiling;
@@ -2845,7 +2890,7 @@ var cssgen = async (ctx, options) => {
2845
2890
  // src/debug.ts
2846
2891
  init_cjs_shims();
2847
2892
  var import_logger9 = require("@pandacss/logger");
2848
- var import_path5 = require("path");
2893
+ var import_path4 = require("path");
2849
2894
  async function debug(ctx, options) {
2850
2895
  const files = ctx.getFiles();
2851
2896
  const measureTotal = import_logger9.logger.time.debug(`Done parsing ${files.length} files`);
@@ -2880,7 +2925,7 @@ async function debug(ctx, options) {
2880
2925
  }
2881
2926
  if (outdir) {
2882
2927
  filesWithCss.push(file);
2883
- const parsedPath = (0, import_path5.parse)(file);
2928
+ const parsedPath = (0, import_path4.parse)(file);
2884
2929
  const relative2 = path3.relative(ctx.config.cwd, parsedPath.dir);
2885
2930
  const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path3.sep, "__");
2886
2931
  const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path3.sep, "__");
@@ -2960,7 +3005,7 @@ async function generate(config, configPath) {
2960
3005
 
2961
3006
  // src/git-ignore.ts
2962
3007
  init_cjs_shims();
2963
- var import_fs3 = require("fs");
3008
+ var import_fs2 = require("fs");
2964
3009
  var import_look_it_up = require("look-it-up");
2965
3010
  var import_outdent = __toESM(require("outdent"));
2966
3011
  function setupGitIgnore(ctx) {
@@ -2975,27 +3020,27 @@ function setupGitIgnore(ctx) {
2975
3020
  `;
2976
3021
  const file = (0, import_look_it_up.lookItUpSync)(".gitignore");
2977
3022
  if (!file) {
2978
- return (0, import_fs3.writeFileSync)(".gitignore", txt);
3023
+ return (0, import_fs2.writeFileSync)(".gitignore", txt);
2979
3024
  }
2980
- const content = (0, import_fs3.readFileSync)(file, "utf-8");
3025
+ const content = (0, import_fs2.readFileSync)(file, "utf-8");
2981
3026
  if (!content.includes(outdir)) {
2982
- (0, import_fs3.appendFileSync)(file, txt);
3027
+ (0, import_fs2.appendFileSync)(file, txt);
2983
3028
  }
2984
3029
  }
2985
3030
 
2986
3031
  // src/logstream.ts
2987
3032
  init_cjs_shims();
2988
3033
  var import_logger11 = require("@pandacss/logger");
2989
- var import_node_fs = __toESM(require("fs"));
2990
- var import_node_path = __toESM(require("path"));
3034
+ var import_node_fs2 = __toESM(require("fs"));
3035
+ var import_node_path2 = __toESM(require("path"));
2991
3036
  var setLogStream = (options) => {
2992
3037
  const { cwd = process.cwd() } = options;
2993
3038
  let stream;
2994
3039
  if (options.logfile) {
2995
- const outPath = import_node_path.default.resolve(cwd, options.logfile);
3040
+ const outPath = import_node_path2.default.resolve(cwd, options.logfile);
2996
3041
  ensure(outPath);
2997
3042
  import_logger11.logger.info("logfile", outPath);
2998
- stream = import_node_fs.default.createWriteStream(outPath, { flags: "a" });
3043
+ stream = import_node_fs2.default.createWriteStream(outPath, { flags: "a" });
2999
3044
  import_logger11.logger.onLog = (entry) => {
3000
3045
  stream?.write(JSON.stringify(entry) + "\n");
3001
3046
  };
@@ -3013,8 +3058,8 @@ var setLogStream = (options) => {
3013
3058
  };
3014
3059
  };
3015
3060
  var ensure = (outPath) => {
3016
- const dirname2 = import_node_path.default.dirname(outPath);
3017
- import_node_fs.default.mkdirSync(dirname2, { recursive: true });
3061
+ const dirname2 = import_node_path2.default.dirname(outPath);
3062
+ import_node_fs2.default.mkdirSync(dirname2, { recursive: true });
3018
3063
  return outPath;
3019
3064
  };
3020
3065
 
@@ -3027,7 +3072,7 @@ var import_shared3 = require("@pandacss/shared");
3027
3072
  var import_fs_extra2 = __toESM(require("fs-extra"));
3028
3073
  var import_look_it_up2 = require("look-it-up");
3029
3074
  var import_outdent2 = require("outdent");
3030
- var import_path6 = require("path");
3075
+ var import_path5 = require("path");
3031
3076
  var import_preferred_pm = __toESM(require("preferred-pm"));
3032
3077
  var import_prettier = __toESM(require("prettier"));
3033
3078
  async function setupConfig(cwd, opts = {}) {
@@ -3079,7 +3124,7 @@ jsxFramework: '${jsxFramework}',` : ""}
3079
3124
  syntax: '${syntax}'` : ""}
3080
3125
  })
3081
3126
  `;
3082
- await import_fs_extra2.default.writeFile((0, import_path6.join)(cwd, file), import_prettier.default.format(content, { parser: "babel" }));
3127
+ await import_fs_extra2.default.writeFile((0, import_path5.join)(cwd, file), await import_prettier.default.format(content, { parser: "babel" }));
3083
3128
  import_logger12.logger.log(import_core2.messages.thankYou());
3084
3129
  }
3085
3130
  }
@@ -3092,7 +3137,7 @@ module.exports = {
3092
3137
  },
3093
3138
  }
3094
3139
  `;
3095
- await import_fs_extra2.default.writeFile((0, import_path6.join)(cwd, "postcss.config.cjs"), content);
3140
+ await import_fs_extra2.default.writeFile((0, import_path5.join)(cwd, "postcss.config.cjs"), content);
3096
3141
  }
3097
3142
  // Annotate the CommonJS export names for ESM import in node:
3098
3143
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -2750,31 +2750,76 @@ var Builder = class {
2750
2750
  // src/cpu-profile.ts
2751
2751
  init_esm_shims();
2752
2752
  import { logger as logger7 } from "@pandacss/logger";
2753
- import fs from "fs";
2754
- import path from "path";
2755
- var startProfiling = async (cwd, prefix) => {
2753
+ import fs from "node:fs";
2754
+ import path from "node:path";
2755
+ import readline from "node:readline";
2756
+ var startProfiling = async (cwd, prefix, isWatching) => {
2756
2757
  const inspector = await import("node:inspector").then((r) => r.default);
2757
2758
  const session = new inspector.Session();
2758
2759
  session.connect();
2760
+ let state = "idle";
2761
+ const setState = (s) => {
2762
+ state = s;
2763
+ };
2759
2764
  await new Promise((resolve4) => {
2760
2765
  session.post("Profiler.enable", () => {
2761
- session.post("Profiler.start", resolve4);
2766
+ session.post("Profiler.start", () => {
2767
+ setState("profiling");
2768
+ resolve4();
2769
+ });
2762
2770
  });
2763
2771
  });
2764
- const stopProfiling = () => {
2765
- session.post("Profiler.stop", (err, { profile }) => {
2772
+ const toggleProfiler = () => {
2773
+ if (state === "idle") {
2774
+ console.log("Starting CPU profiling...");
2775
+ setState("starting");
2776
+ session.post("Profiler.start", () => {
2777
+ setState("profiling");
2778
+ console.log("Press 'p' to stop profiling...");
2779
+ });
2780
+ } else if (state === "profiling") {
2781
+ console.log("Stopping CPU profiling...");
2782
+ stopProfiling();
2783
+ }
2784
+ };
2785
+ if (isWatching) {
2786
+ readline.emitKeypressEvents(process.stdin);
2787
+ if (process.stdin.isTTY)
2788
+ process.stdin.setRawMode(true);
2789
+ console.log("Press 'p' to stop profiling...");
2790
+ process.stdin.on("keypress", (str, key) => {
2791
+ if (key.name === "p") {
2792
+ toggleProfiler();
2793
+ }
2794
+ if (key.ctrl && key.name === "c") {
2795
+ stopProfiling(() => process.exit());
2796
+ }
2797
+ });
2798
+ }
2799
+ const stopProfiling = (cb) => {
2800
+ if (state !== "profiling") {
2801
+ cb?.();
2802
+ return;
2803
+ }
2804
+ setState("stopping");
2805
+ session.post("Profiler.stop", (err, params) => {
2806
+ setState("idle");
2766
2807
  if (err) {
2767
2808
  logger7.error("cpu-prof", err);
2809
+ cb?.();
2768
2810
  return;
2769
2811
  }
2770
- if (!profile)
2812
+ if (!params?.profile) {
2813
+ cb?.();
2771
2814
  return;
2815
+ }
2772
2816
  const date = /* @__PURE__ */ new Date();
2773
2817
  const timestamp = date.toISOString().replace(/[-:.]/g, "");
2774
2818
  const title = `panda-${prefix}-${timestamp}`;
2775
2819
  const outfile = path.join(cwd, `${title}.cpuprofile`);
2776
- fs.writeFileSync(outfile, JSON.stringify(profile));
2820
+ fs.writeFileSync(outfile, JSON.stringify(params.profile));
2777
2821
  logger7.info("cpu-prof", outfile);
2822
+ cb?.();
2778
2823
  });
2779
2824
  };
2780
2825
  return stopProfiling;
@@ -3053,7 +3098,7 @@ jsxFramework: '${jsxFramework}',` : ""}
3053
3098
  syntax: '${syntax}'` : ""}
3054
3099
  })
3055
3100
  `;
3056
- await fsExtra2.writeFile(join2(cwd, file), prettier.format(content, { parser: "babel" }));
3101
+ await fsExtra2.writeFile(join2(cwd, file), await prettier.format(content, { parser: "babel" }));
3057
3102
  logger12.log(messages.thankYou());
3058
3103
  }
3059
3104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.32.1",
3
+ "version": "0.34.0",
4
4
  "description": "The core css panda library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -48,19 +48,19 @@
48
48
  "pluralize": "8.0.0",
49
49
  "postcss": "8.4.35",
50
50
  "preferred-pm": "3.1.2",
51
- "prettier": "2.8.8",
51
+ "prettier": "3.2.5",
52
52
  "ts-morph": "21.0.1",
53
53
  "ts-pattern": "5.0.8",
54
54
  "tsconfck": "3.0.2",
55
- "@pandacss/config": "0.32.1",
56
- "@pandacss/core": "0.32.1",
57
- "@pandacss/extractor": "0.32.1",
58
- "@pandacss/generator": "0.32.1",
59
- "@pandacss/logger": "0.32.1",
60
- "@pandacss/parser": "0.32.1",
61
- "@pandacss/shared": "0.32.1",
62
- "@pandacss/token-dictionary": "0.32.1",
63
- "@pandacss/types": "0.32.1"
55
+ "@pandacss/config": "0.34.0",
56
+ "@pandacss/core": "0.34.0",
57
+ "@pandacss/extractor": "0.34.0",
58
+ "@pandacss/generator": "0.34.0",
59
+ "@pandacss/logger": "0.34.0",
60
+ "@pandacss/parser": "0.34.0",
61
+ "@pandacss/shared": "0.34.0",
62
+ "@pandacss/token-dictionary": "0.34.0",
63
+ "@pandacss/types": "0.34.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/fs-extra": "11.0.4",