@pandacss/node 0.27.3 → 0.28.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
@@ -1,5 +1,5 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
- import { LoadConfigResult, Artifact, Runtime, PandaHookable, ConfigResultWithHooks, WatchOptions, WatcherEventType, ParserResultInterface, ArtifactId, Config, CssArtifactType } from '@pandacss/types';
2
+ import { LoadConfigResult, Artifact, Runtime, PandaHooks, WatchOptions, WatcherEventType, ParserResultInterface, ArtifactId, Config, CssArtifactType } from '@pandacss/types';
3
3
  import { StyleEncoder, Stylesheet } from '@pandacss/core';
4
4
  import { Generator } from '@pandacss/generator';
5
5
  import * as _pandacss_parser from '@pandacss/parser';
@@ -25,7 +25,7 @@ declare class DiffEngine {
25
25
 
26
26
  interface OutputEngineOptions extends Generator {
27
27
  runtime: Runtime;
28
- hooks: PandaHookable;
28
+ hooks: Partial<PandaHooks>;
29
29
  }
30
30
  declare class OutputEngine {
31
31
  private paths;
@@ -42,7 +42,7 @@ declare class PandaContext extends Generator {
42
42
  project: Project;
43
43
  output: OutputEngine;
44
44
  diff: DiffEngine;
45
- constructor(conf: ConfigResultWithHooks);
45
+ constructor(conf: LoadConfigResult);
46
46
  getFiles: () => string[];
47
47
  parseFile: (filePath: string, styleEncoder?: StyleEncoder) => ParserResult | undefined;
48
48
  parseFiles: (styleEncoder?: StyleEncoder) => {
@@ -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
@@ -1,5 +1,5 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
- import { LoadConfigResult, Artifact, Runtime, PandaHookable, ConfigResultWithHooks, WatchOptions, WatcherEventType, ParserResultInterface, ArtifactId, Config, CssArtifactType } from '@pandacss/types';
2
+ import { LoadConfigResult, Artifact, Runtime, PandaHooks, WatchOptions, WatcherEventType, ParserResultInterface, ArtifactId, Config, CssArtifactType } from '@pandacss/types';
3
3
  import { StyleEncoder, Stylesheet } from '@pandacss/core';
4
4
  import { Generator } from '@pandacss/generator';
5
5
  import * as _pandacss_parser from '@pandacss/parser';
@@ -25,7 +25,7 @@ declare class DiffEngine {
25
25
 
26
26
  interface OutputEngineOptions extends Generator {
27
27
  runtime: Runtime;
28
- hooks: PandaHookable;
28
+ hooks: Partial<PandaHooks>;
29
29
  }
30
30
  declare class OutputEngine {
31
31
  private paths;
@@ -42,7 +42,7 @@ declare class PandaContext extends Generator {
42
42
  project: Project;
43
43
  output: OutputEngine;
44
44
  diff: DiffEngine;
45
- constructor(conf: ConfigResultWithHooks);
45
+ constructor(conf: LoadConfigResult);
46
46
  getFiles: () => string[];
47
47
  parseFile: (filePath: string, styleEncoder?: StyleEncoder) => ParserResult | undefined;
48
48
  parseFiles: (styleEncoder?: StyleEncoder) => {
@@ -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);
@@ -2224,7 +2225,7 @@ async function codegen(ctx, ids) {
2224
2225
  ctx.output.empty();
2225
2226
  const promises = ctx.getArtifacts(ids).map((artifact) => limit(() => ctx.output.write(artifact)));
2226
2227
  await Promise.allSettled(promises);
2227
- void ctx.hooks.callHook("generator:done");
2228
+ await ctx.hooks["codegen:done"]?.({ changed: ids });
2228
2229
  return {
2229
2230
  box: createBox({
2230
2231
  content: ctx.messages.codegenComplete(),
@@ -2238,7 +2239,6 @@ async function codegen(ctx, ids) {
2238
2239
  init_cjs_shims();
2239
2240
  var import_config3 = require("@pandacss/config");
2240
2241
  var import_browserslist = __toESM(require("browserslist"));
2241
- var import_hookable = require("hookable");
2242
2242
 
2243
2243
  // src/create-context.ts
2244
2244
  init_cjs_shims();
@@ -2326,8 +2326,8 @@ var nodeRuntime = {
2326
2326
  readDirSync: import_fs_extra.default.readdirSync,
2327
2327
  rmDirSync: import_fs_extra.default.emptyDirSync,
2328
2328
  rmFileSync: import_fs_extra.default.removeSync,
2329
- ensureDirSync(path) {
2330
- return import_fs_extra.default.ensureDirSync(path);
2329
+ ensureDirSync(path2) {
2330
+ return import_fs_extra.default.ensureDirSync(path2);
2331
2331
  },
2332
2332
  watch(options) {
2333
2333
  const { include, exclude, cwd, poll } = options;
@@ -2551,15 +2551,7 @@ async function loadConfigAndCreateContext(options = {}) {
2551
2551
  if (tsConfResult) {
2552
2552
  Object.assign(conf, tsConfResult);
2553
2553
  }
2554
- const hooks = (0, import_hookable.createHooks)();
2555
- if (conf.config.hooks) {
2556
- hooks.addHooks(conf.config.hooks);
2557
- }
2558
- await hooks.callHook("config:resolved", conf);
2559
- if (conf.config.logLevel === "debug") {
2560
- (0, import_hookable.createDebugger)(hooks, { tag: "panda" });
2561
- }
2562
- return new PandaContext({ ...conf, hooks });
2554
+ return new PandaContext(conf);
2563
2555
  }
2564
2556
 
2565
2557
  // src/parse-dependency.ts
@@ -2646,12 +2638,12 @@ var Builder = class {
2646
2638
  }
2647
2639
  const ctx = this.getContextOrThrow();
2648
2640
  this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
2649
- this.context = new PandaContext({ ...conf, hooks: ctx.hooks });
2641
+ this.context = new PandaContext(conf);
2650
2642
  });
2651
2643
  import_logger6.logger.debug("builder", this.affecteds);
2652
2644
  if (this.affecteds.hasConfigChanged) {
2653
2645
  import_logger6.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
2654
- await ctx.hooks.callHook("config:change", ctx.config);
2646
+ await ctx.hooks["config:change"]?.({ config: ctx.config, changes: this.affecteds });
2655
2647
  return;
2656
2648
  }
2657
2649
  this.filesMeta = this.checkFilesChanged(ctx.getFiles());
@@ -2753,14 +2745,44 @@ var Builder = class {
2753
2745
  };
2754
2746
  };
2755
2747
 
2756
- // src/cssgen.ts
2748
+ // src/cpu-profile.ts
2757
2749
  init_cjs_shims();
2758
2750
  var import_logger7 = require("@pandacss/logger");
2751
+ var import_fs2 = __toESM(require("fs"));
2752
+ var import_path4 = __toESM(require("path"));
2753
+ var startProfiling = async (cwd, prefix) => {
2754
+ const v8Profiler = (await import("v8-profiler-next")).default;
2755
+ const date = /* @__PURE__ */ new Date();
2756
+ const timestamp = date.toISOString().replace(/[-:.]/g, "");
2757
+ const title = `panda-${prefix}-${timestamp}`;
2758
+ v8Profiler.setGenerateType(1);
2759
+ v8Profiler.startProfiling(title, true);
2760
+ const stopProfiling = () => {
2761
+ const profile = v8Profiler.stopProfiling(title);
2762
+ profile.export(function(error, result) {
2763
+ if (error) {
2764
+ console.error(error);
2765
+ return;
2766
+ }
2767
+ if (!result)
2768
+ return;
2769
+ const outfile = import_path4.default.join(cwd, `${title}.cpuprofile`);
2770
+ import_fs2.default.writeFileSync(outfile, result);
2771
+ import_logger7.logger.info("cpu-prof", outfile);
2772
+ profile.delete();
2773
+ });
2774
+ };
2775
+ return stopProfiling;
2776
+ };
2777
+
2778
+ // src/cssgen.ts
2779
+ init_cjs_shims();
2780
+ var import_logger8 = require("@pandacss/logger");
2759
2781
  var cssgen = async (ctx, options) => {
2760
2782
  const { outfile, type, minimal } = options;
2761
2783
  const sheet = ctx.createSheet();
2762
2784
  if (type) {
2763
- const done = import_logger7.logger.time.info(ctx.messages.cssArtifactComplete(type));
2785
+ const done = import_logger8.logger.time.info(ctx.messages.cssArtifactComplete(type));
2764
2786
  ctx.appendCssOfType(type, sheet);
2765
2787
  if (outfile) {
2766
2788
  const css = ctx.getCss(sheet);
@@ -2771,7 +2793,7 @@ var cssgen = async (ctx, options) => {
2771
2793
  done();
2772
2794
  } else {
2773
2795
  const { files } = ctx.parseFiles();
2774
- const done = import_logger7.logger.time.info(ctx.messages.buildComplete(files.length));
2796
+ const done = import_logger8.logger.time.info(ctx.messages.buildComplete(files.length));
2775
2797
  if (!minimal) {
2776
2798
  ctx.appendLayerParams(sheet);
2777
2799
  ctx.appendBaselineCss(sheet);
@@ -2789,19 +2811,19 @@ var cssgen = async (ctx, options) => {
2789
2811
 
2790
2812
  // src/debug.ts
2791
2813
  init_cjs_shims();
2792
- var import_logger8 = require("@pandacss/logger");
2793
- var import_path4 = require("path");
2814
+ var import_logger9 = require("@pandacss/logger");
2815
+ var import_path5 = require("path");
2794
2816
  async function debug(ctx, options) {
2795
2817
  const files = ctx.getFiles();
2796
- const measureTotal = import_logger8.logger.time.debug(`Done parsing ${files.length} files`);
2818
+ const measureTotal = import_logger9.logger.time.debug(`Done parsing ${files.length} files`);
2797
2819
  ctx.config.minify = false;
2798
2820
  ctx.config.optimize = true;
2799
- const { fs, path } = ctx.runtime;
2821
+ const { fs: fs2, path: path2 } = ctx.runtime;
2800
2822
  const outdir = options.outdir;
2801
2823
  if (!options.dry && outdir) {
2802
- fs.ensureDirSync(outdir);
2803
- import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/config.json`)}`);
2804
- await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2824
+ fs2.ensureDirSync(outdir);
2825
+ import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/config.json`)}`);
2826
+ await fs2.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2805
2827
  }
2806
2828
  if (options.onlyConfig) {
2807
2829
  measureTotal();
@@ -2809,14 +2831,14 @@ async function debug(ctx, options) {
2809
2831
  }
2810
2832
  const filesWithCss = [];
2811
2833
  files.map((file) => {
2812
- const measure = import_logger8.logger.time.debug(`Parsed ${file}`);
2834
+ const measure = import_logger9.logger.time.debug(`Parsed ${file}`);
2813
2835
  const encoder = ctx.encoder.clone();
2814
2836
  const result = ctx.project.parseSourceFile(file, encoder);
2815
2837
  measure();
2816
2838
  if (!result || result.isEmpty() || encoder.isEmpty())
2817
2839
  return;
2818
2840
  const styles4 = ctx.decoder.clone().collect(encoder);
2819
- const css = ctx.getParserCss(styles4, file);
2841
+ const css = ctx.getParserCss(styles4);
2820
2842
  if (!css)
2821
2843
  return;
2822
2844
  if (options.dry) {
@@ -2825,32 +2847,32 @@ async function debug(ctx, options) {
2825
2847
  }
2826
2848
  if (outdir) {
2827
2849
  filesWithCss.push(file);
2828
- const parsedPath = (0, import_path4.parse)(file);
2829
- const relative2 = path.relative(ctx.config.cwd, parsedPath.dir);
2830
- const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path.sep, "__");
2831
- const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path.sep, "__");
2832
- import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${astJsonPath}`)}`);
2833
- import_logger8.logger.info("cli", `Writing ${import_logger8.colors.bold(`${outdir}/${cssPath}`)}`);
2850
+ const parsedPath = (0, import_path5.parse)(file);
2851
+ const relative2 = path2.relative(ctx.config.cwd, parsedPath.dir);
2852
+ const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
2853
+ const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
2854
+ import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/${astJsonPath}`)}`);
2855
+ import_logger9.logger.info("cli", `Writing ${import_logger9.colors.bold(`${outdir}/${cssPath}`)}`);
2834
2856
  return Promise.allSettled([
2835
- fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2836
- fs.writeFile(`${outdir}/${cssPath}`, css)
2857
+ fs2.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2858
+ fs2.writeFile(`${outdir}/${cssPath}`, css)
2837
2859
  ]);
2838
2860
  }
2839
2861
  });
2840
- import_logger8.logger.info("cli", `Found ${import_logger8.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2862
+ import_logger9.logger.info("cli", `Found ${import_logger9.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2841
2863
  measureTotal();
2842
2864
  }
2843
2865
 
2844
2866
  // src/generate.ts
2845
2867
  init_cjs_shims();
2846
- var import_logger9 = require("@pandacss/logger");
2868
+ var import_logger10 = require("@pandacss/logger");
2847
2869
  var import_ts_pattern = require("ts-pattern");
2848
2870
  async function build(ctx, artifactIds) {
2849
2871
  await codegen(ctx, artifactIds);
2850
2872
  if (ctx.config.emitTokensOnly) {
2851
- return import_logger9.logger.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
2873
+ return import_logger10.logger.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
2852
2874
  }
2853
- const done = import_logger9.logger.time.info("");
2875
+ const done = import_logger10.logger.time.info("");
2854
2876
  const sheet = ctx.createSheet();
2855
2877
  ctx.appendLayerParams(sheet);
2856
2878
  ctx.appendBaselineCss(sheet);
@@ -2863,24 +2885,24 @@ async function generate(config, configPath) {
2863
2885
  let ctx = await loadConfigAndCreateContext({ config, configPath });
2864
2886
  await build(ctx);
2865
2887
  const {
2866
- runtime: { fs, path },
2888
+ runtime: { fs: fs2, path: path2 },
2867
2889
  config: { cwd }
2868
2890
  } = ctx;
2869
2891
  if (ctx.config.watch) {
2870
- const configWatcher = fs.watch({ include: ctx.conf.dependencies });
2892
+ const configWatcher = fs2.watch({ include: ctx.conf.dependencies });
2871
2893
  configWatcher.on("change", async () => {
2872
2894
  const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
2873
- ctx = new PandaContext({ ...conf, hooks: ctx.hooks });
2895
+ ctx = new PandaContext(conf);
2874
2896
  });
2875
2897
  if (!affecteds.hasConfigChanged) {
2876
- import_logger9.logger.debug("builder", "Config didnt change, skipping rebuild");
2898
+ import_logger10.logger.debug("builder", "Config didnt change, skipping rebuild");
2877
2899
  return;
2878
2900
  }
2879
- import_logger9.logger.info("config:change", "Config changed, restarting...");
2880
- await ctx.hooks.callHook("config:change", ctx.config);
2901
+ import_logger10.logger.info("config:change", "Config changed, restarting...");
2902
+ await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
2881
2903
  return build(ctx, Array.from(affecteds.artifacts));
2882
2904
  });
2883
- const contentWatcher = fs.watch(ctx.config);
2905
+ const contentWatcher = fs2.watch(ctx.config);
2884
2906
  const bundleStyles = async (ctx2, changedFilePath) => {
2885
2907
  const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
2886
2908
  const parserResult = ctx2.project.parseSourceFile(changedFilePath);
@@ -2895,10 +2917,10 @@ async function generate(config, configPath) {
2895
2917
  }
2896
2918
  };
2897
2919
  contentWatcher.on("all", async (event, file) => {
2898
- import_logger9.logger.info(`file:${event}`, file);
2899
- const filePath = path.abs(cwd, file);
2920
+ import_logger10.logger.info(`file:${event}`, file);
2921
+ const filePath = path2.abs(cwd, file);
2900
2922
  (0, import_ts_pattern.match)(event).with("unlink", () => {
2901
- ctx.project.removeSourceFile(path.abs(cwd, file));
2923
+ ctx.project.removeSourceFile(path2.abs(cwd, file));
2902
2924
  }).with("change", async () => {
2903
2925
  ctx.project.reloadSourceFile(file);
2904
2926
  return bundleStyles(ctx, filePath);
@@ -2908,13 +2930,13 @@ async function generate(config, configPath) {
2908
2930
  }).otherwise(() => {
2909
2931
  });
2910
2932
  });
2911
- import_logger9.logger.info("ctx:watch", ctx.messages.watch());
2933
+ import_logger10.logger.info("ctx:watch", ctx.messages.watch());
2912
2934
  }
2913
2935
  }
2914
2936
 
2915
2937
  // src/git-ignore.ts
2916
2938
  init_cjs_shims();
2917
- var import_fs2 = require("fs");
2939
+ var import_fs3 = require("fs");
2918
2940
  var import_look_it_up = require("look-it-up");
2919
2941
  var import_outdent = __toESM(require("outdent"));
2920
2942
  function setupGitIgnore(ctx) {
@@ -2929,11 +2951,11 @@ function setupGitIgnore(ctx) {
2929
2951
  `;
2930
2952
  const file = (0, import_look_it_up.lookItUpSync)(".gitignore");
2931
2953
  if (!file) {
2932
- return (0, import_fs2.writeFileSync)(".gitignore", txt);
2954
+ return (0, import_fs3.writeFileSync)(".gitignore", txt);
2933
2955
  }
2934
- const content = (0, import_fs2.readFileSync)(file, "utf-8");
2956
+ const content = (0, import_fs3.readFileSync)(file, "utf-8");
2935
2957
  if (!content.includes(outdir)) {
2936
- (0, import_fs2.appendFileSync)(file, txt);
2958
+ (0, import_fs3.appendFileSync)(file, txt);
2937
2959
  }
2938
2960
  }
2939
2961
 
@@ -2941,11 +2963,11 @@ function setupGitIgnore(ctx) {
2941
2963
  init_cjs_shims();
2942
2964
  var import_config7 = require("@pandacss/config");
2943
2965
  var import_core2 = require("@pandacss/core");
2944
- var import_logger10 = require("@pandacss/logger");
2966
+ var import_logger11 = require("@pandacss/logger");
2945
2967
  var import_fs_extra2 = __toESM(require("fs-extra"));
2946
2968
  var import_look_it_up2 = require("look-it-up");
2947
2969
  var import_outdent2 = require("outdent");
2948
- var import_path5 = require("path");
2970
+ var import_path6 = require("path");
2949
2971
  var import_preferred_pm = __toESM(require("preferred-pm"));
2950
2972
  var import_prettier = __toESM(require("prettier"));
2951
2973
  async function setupConfig(cwd, opts = {}) {
@@ -2956,9 +2978,9 @@ async function setupConfig(cwd, opts = {}) {
2956
2978
  const cmd = pm === "npm" ? "npm run" : pm;
2957
2979
  const isTs = (0, import_look_it_up2.lookItUpSync)("tsconfig.json", cwd);
2958
2980
  const file = isTs ? "panda.config.ts" : "panda.config.mjs";
2959
- import_logger10.logger.info("init:config", `creating panda config file: ${(0, import_logger10.quote)(file)}`);
2981
+ import_logger11.logger.info("init:config", `creating panda config file: ${(0, import_logger11.quote)(file)}`);
2960
2982
  if (!force && configFile) {
2961
- import_logger10.logger.warn("init:config", import_core2.messages.configExists(cmd));
2983
+ import_logger11.logger.warn("init:config", import_core2.messages.configExists(cmd));
2962
2984
  } else {
2963
2985
  const content = import_outdent2.outdent`
2964
2986
  import { defineConfig } from "@pandacss/dev"
@@ -2990,12 +3012,12 @@ jsxFramework: '${jsxFramework}',` : ""}
2990
3012
  syntax: '${syntax}'` : ""}
2991
3013
  })
2992
3014
  `;
2993
- await import_fs_extra2.default.writeFile((0, import_path5.join)(cwd, file), import_prettier.default.format(content, { parser: "babel" }));
2994
- import_logger10.logger.log(import_core2.messages.thankYou());
3015
+ await import_fs_extra2.default.writeFile((0, import_path6.join)(cwd, file), import_prettier.default.format(content, { parser: "babel" }));
3016
+ import_logger11.logger.log(import_core2.messages.thankYou());
2995
3017
  }
2996
3018
  }
2997
3019
  async function setupPostcss(cwd) {
2998
- import_logger10.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger10.quote)("postcss.config.cjs")}`);
3020
+ import_logger11.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger11.quote)("postcss.config.cjs")}`);
2999
3021
  const content = import_outdent2.outdent`
3000
3022
  module.exports = {
3001
3023
  plugins: {
@@ -3003,7 +3025,7 @@ module.exports = {
3003
3025
  },
3004
3026
  }
3005
3027
  `;
3006
- await import_fs_extra2.default.writeFile((0, import_path5.join)(cwd, "postcss.config.cjs"), content);
3028
+ await import_fs_extra2.default.writeFile((0, import_path6.join)(cwd, "postcss.config.cjs"), content);
3007
3029
  }
3008
3030
  // Annotate the CommonJS export names for ESM import in node:
3009
3031
  0 && (module.exports = {
@@ -3020,5 +3042,6 @@ module.exports = {
3020
3042
  setupConfig,
3021
3043
  setupGitIgnore,
3022
3044
  setupPostcss,
3045
+ startProfiling,
3023
3046
  writeAnalyzeJSON
3024
3047
  });
package/dist/index.mjs CHANGED
@@ -2200,7 +2200,7 @@ async function codegen(ctx, ids) {
2200
2200
  ctx.output.empty();
2201
2201
  const promises = ctx.getArtifacts(ids).map((artifact) => limit(() => ctx.output.write(artifact)));
2202
2202
  await Promise.allSettled(promises);
2203
- void ctx.hooks.callHook("generator:done");
2203
+ await ctx.hooks["codegen:done"]?.({ changed: ids });
2204
2204
  return {
2205
2205
  box: createBox({
2206
2206
  content: ctx.messages.codegenComplete(),
@@ -2214,7 +2214,6 @@ async function codegen(ctx, ids) {
2214
2214
  init_esm_shims();
2215
2215
  import { loadConfig as loadConfig2 } from "@pandacss/config";
2216
2216
  import browserslist from "browserslist";
2217
- import { createDebugger, createHooks } from "hookable";
2218
2217
 
2219
2218
  // src/create-context.ts
2220
2219
  init_esm_shims();
@@ -2302,8 +2301,8 @@ var nodeRuntime = {
2302
2301
  readDirSync: fsExtra.readdirSync,
2303
2302
  rmDirSync: fsExtra.emptyDirSync,
2304
2303
  rmFileSync: fsExtra.removeSync,
2305
- ensureDirSync(path) {
2306
- return fsExtra.ensureDirSync(path);
2304
+ ensureDirSync(path2) {
2305
+ return fsExtra.ensureDirSync(path2);
2307
2306
  },
2308
2307
  watch(options) {
2309
2308
  const { include, exclude, cwd, poll } = options;
@@ -2527,15 +2526,7 @@ async function loadConfigAndCreateContext(options = {}) {
2527
2526
  if (tsConfResult) {
2528
2527
  Object.assign(conf, tsConfResult);
2529
2528
  }
2530
- const hooks = createHooks();
2531
- if (conf.config.hooks) {
2532
- hooks.addHooks(conf.config.hooks);
2533
- }
2534
- await hooks.callHook("config:resolved", conf);
2535
- if (conf.config.logLevel === "debug") {
2536
- createDebugger(hooks, { tag: "panda" });
2537
- }
2538
- return new PandaContext({ ...conf, hooks });
2529
+ return new PandaContext(conf);
2539
2530
  }
2540
2531
 
2541
2532
  // src/parse-dependency.ts
@@ -2622,12 +2613,12 @@ var Builder = class {
2622
2613
  }
2623
2614
  const ctx = this.getContextOrThrow();
2624
2615
  this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
2625
- this.context = new PandaContext({ ...conf, hooks: ctx.hooks });
2616
+ this.context = new PandaContext(conf);
2626
2617
  });
2627
2618
  logger6.debug("builder", this.affecteds);
2628
2619
  if (this.affecteds.hasConfigChanged) {
2629
2620
  logger6.debug("builder", "\u2699\uFE0F Config changed, reloading");
2630
- await ctx.hooks.callHook("config:change", ctx.config);
2621
+ await ctx.hooks["config:change"]?.({ config: ctx.config, changes: this.affecteds });
2631
2622
  return;
2632
2623
  }
2633
2624
  this.filesMeta = this.checkFilesChanged(ctx.getFiles());
@@ -2729,14 +2720,44 @@ var Builder = class {
2729
2720
  };
2730
2721
  };
2731
2722
 
2732
- // src/cssgen.ts
2723
+ // src/cpu-profile.ts
2733
2724
  init_esm_shims();
2734
2725
  import { logger as logger7 } from "@pandacss/logger";
2726
+ import fs from "fs";
2727
+ import path from "path";
2728
+ var startProfiling = async (cwd, prefix) => {
2729
+ const v8Profiler = (await import("v8-profiler-next")).default;
2730
+ const date = /* @__PURE__ */ new Date();
2731
+ const timestamp = date.toISOString().replace(/[-:.]/g, "");
2732
+ const title = `panda-${prefix}-${timestamp}`;
2733
+ v8Profiler.setGenerateType(1);
2734
+ v8Profiler.startProfiling(title, true);
2735
+ const stopProfiling = () => {
2736
+ const profile = v8Profiler.stopProfiling(title);
2737
+ profile.export(function(error, result) {
2738
+ if (error) {
2739
+ console.error(error);
2740
+ return;
2741
+ }
2742
+ if (!result)
2743
+ return;
2744
+ const outfile = path.join(cwd, `${title}.cpuprofile`);
2745
+ fs.writeFileSync(outfile, result);
2746
+ logger7.info("cpu-prof", outfile);
2747
+ profile.delete();
2748
+ });
2749
+ };
2750
+ return stopProfiling;
2751
+ };
2752
+
2753
+ // src/cssgen.ts
2754
+ init_esm_shims();
2755
+ import { logger as logger8 } from "@pandacss/logger";
2735
2756
  var cssgen = async (ctx, options) => {
2736
2757
  const { outfile, type, minimal } = options;
2737
2758
  const sheet = ctx.createSheet();
2738
2759
  if (type) {
2739
- const done = logger7.time.info(ctx.messages.cssArtifactComplete(type));
2760
+ const done = logger8.time.info(ctx.messages.cssArtifactComplete(type));
2740
2761
  ctx.appendCssOfType(type, sheet);
2741
2762
  if (outfile) {
2742
2763
  const css = ctx.getCss(sheet);
@@ -2747,7 +2768,7 @@ var cssgen = async (ctx, options) => {
2747
2768
  done();
2748
2769
  } else {
2749
2770
  const { files } = ctx.parseFiles();
2750
- const done = logger7.time.info(ctx.messages.buildComplete(files.length));
2771
+ const done = logger8.time.info(ctx.messages.buildComplete(files.length));
2751
2772
  if (!minimal) {
2752
2773
  ctx.appendLayerParams(sheet);
2753
2774
  ctx.appendBaselineCss(sheet);
@@ -2765,19 +2786,19 @@ var cssgen = async (ctx, options) => {
2765
2786
 
2766
2787
  // src/debug.ts
2767
2788
  init_esm_shims();
2768
- import { colors as colors2, logger as logger8 } from "@pandacss/logger";
2789
+ import { colors as colors2, logger as logger9 } from "@pandacss/logger";
2769
2790
  import { parse as parse2 } from "path";
2770
2791
  async function debug(ctx, options) {
2771
2792
  const files = ctx.getFiles();
2772
- const measureTotal = logger8.time.debug(`Done parsing ${files.length} files`);
2793
+ const measureTotal = logger9.time.debug(`Done parsing ${files.length} files`);
2773
2794
  ctx.config.minify = false;
2774
2795
  ctx.config.optimize = true;
2775
- const { fs, path } = ctx.runtime;
2796
+ const { fs: fs2, path: path2 } = ctx.runtime;
2776
2797
  const outdir = options.outdir;
2777
2798
  if (!options.dry && outdir) {
2778
- fs.ensureDirSync(outdir);
2779
- logger8.info("cli", `Writing ${colors2.bold(`${outdir}/config.json`)}`);
2780
- await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2799
+ fs2.ensureDirSync(outdir);
2800
+ logger9.info("cli", `Writing ${colors2.bold(`${outdir}/config.json`)}`);
2801
+ await fs2.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2781
2802
  }
2782
2803
  if (options.onlyConfig) {
2783
2804
  measureTotal();
@@ -2785,14 +2806,14 @@ async function debug(ctx, options) {
2785
2806
  }
2786
2807
  const filesWithCss = [];
2787
2808
  files.map((file) => {
2788
- const measure = logger8.time.debug(`Parsed ${file}`);
2809
+ const measure = logger9.time.debug(`Parsed ${file}`);
2789
2810
  const encoder = ctx.encoder.clone();
2790
2811
  const result = ctx.project.parseSourceFile(file, encoder);
2791
2812
  measure();
2792
2813
  if (!result || result.isEmpty() || encoder.isEmpty())
2793
2814
  return;
2794
2815
  const styles4 = ctx.decoder.clone().collect(encoder);
2795
- const css = ctx.getParserCss(styles4, file);
2816
+ const css = ctx.getParserCss(styles4);
2796
2817
  if (!css)
2797
2818
  return;
2798
2819
  if (options.dry) {
@@ -2802,31 +2823,31 @@ async function debug(ctx, options) {
2802
2823
  if (outdir) {
2803
2824
  filesWithCss.push(file);
2804
2825
  const parsedPath = parse2(file);
2805
- const relative2 = path.relative(ctx.config.cwd, parsedPath.dir);
2806
- const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path.sep, "__");
2807
- const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path.sep, "__");
2808
- logger8.info("cli", `Writing ${colors2.bold(`${outdir}/${astJsonPath}`)}`);
2809
- logger8.info("cli", `Writing ${colors2.bold(`${outdir}/${cssPath}`)}`);
2826
+ const relative2 = path2.relative(ctx.config.cwd, parsedPath.dir);
2827
+ const astJsonPath = `${relative2}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
2828
+ const cssPath = `${relative2}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
2829
+ logger9.info("cli", `Writing ${colors2.bold(`${outdir}/${astJsonPath}`)}`);
2830
+ logger9.info("cli", `Writing ${colors2.bold(`${outdir}/${cssPath}`)}`);
2810
2831
  return Promise.allSettled([
2811
- fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2812
- fs.writeFile(`${outdir}/${cssPath}`, css)
2832
+ fs2.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2833
+ fs2.writeFile(`${outdir}/${cssPath}`, css)
2813
2834
  ]);
2814
2835
  }
2815
2836
  });
2816
- logger8.info("cli", `Found ${colors2.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2837
+ logger9.info("cli", `Found ${colors2.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2817
2838
  measureTotal();
2818
2839
  }
2819
2840
 
2820
2841
  // src/generate.ts
2821
2842
  init_esm_shims();
2822
- import { logger as logger9 } from "@pandacss/logger";
2843
+ import { logger as logger10 } from "@pandacss/logger";
2823
2844
  import { match } from "ts-pattern";
2824
2845
  async function build(ctx, artifactIds) {
2825
2846
  await codegen(ctx, artifactIds);
2826
2847
  if (ctx.config.emitTokensOnly) {
2827
- return logger9.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
2848
+ return logger10.info("css:emit", "Successfully rebuilt the css variables and js function to query your tokens \u2728");
2828
2849
  }
2829
- const done = logger9.time.info("");
2850
+ const done = logger10.time.info("");
2830
2851
  const sheet = ctx.createSheet();
2831
2852
  ctx.appendLayerParams(sheet);
2832
2853
  ctx.appendBaselineCss(sheet);
@@ -2839,24 +2860,24 @@ async function generate(config, configPath) {
2839
2860
  let ctx = await loadConfigAndCreateContext({ config, configPath });
2840
2861
  await build(ctx);
2841
2862
  const {
2842
- runtime: { fs, path },
2863
+ runtime: { fs: fs2, path: path2 },
2843
2864
  config: { cwd }
2844
2865
  } = ctx;
2845
2866
  if (ctx.config.watch) {
2846
- const configWatcher = fs.watch({ include: ctx.conf.dependencies });
2867
+ const configWatcher = fs2.watch({ include: ctx.conf.dependencies });
2847
2868
  configWatcher.on("change", async () => {
2848
2869
  const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
2849
- ctx = new PandaContext({ ...conf, hooks: ctx.hooks });
2870
+ ctx = new PandaContext(conf);
2850
2871
  });
2851
2872
  if (!affecteds.hasConfigChanged) {
2852
- logger9.debug("builder", "Config didnt change, skipping rebuild");
2873
+ logger10.debug("builder", "Config didnt change, skipping rebuild");
2853
2874
  return;
2854
2875
  }
2855
- logger9.info("config:change", "Config changed, restarting...");
2856
- await ctx.hooks.callHook("config:change", ctx.config);
2876
+ logger10.info("config:change", "Config changed, restarting...");
2877
+ await ctx.hooks["config:change"]?.({ config: ctx.config, changes: affecteds });
2857
2878
  return build(ctx, Array.from(affecteds.artifacts));
2858
2879
  });
2859
- const contentWatcher = fs.watch(ctx.config);
2880
+ const contentWatcher = fs2.watch(ctx.config);
2860
2881
  const bundleStyles = async (ctx2, changedFilePath) => {
2861
2882
  const outfile = ctx2.runtime.path.join(...ctx2.paths.root, "styles.css");
2862
2883
  const parserResult = ctx2.project.parseSourceFile(changedFilePath);
@@ -2871,10 +2892,10 @@ async function generate(config, configPath) {
2871
2892
  }
2872
2893
  };
2873
2894
  contentWatcher.on("all", async (event, file) => {
2874
- logger9.info(`file:${event}`, file);
2875
- const filePath = path.abs(cwd, file);
2895
+ logger10.info(`file:${event}`, file);
2896
+ const filePath = path2.abs(cwd, file);
2876
2897
  match(event).with("unlink", () => {
2877
- ctx.project.removeSourceFile(path.abs(cwd, file));
2898
+ ctx.project.removeSourceFile(path2.abs(cwd, file));
2878
2899
  }).with("change", async () => {
2879
2900
  ctx.project.reloadSourceFile(file);
2880
2901
  return bundleStyles(ctx, filePath);
@@ -2884,7 +2905,7 @@ async function generate(config, configPath) {
2884
2905
  }).otherwise(() => {
2885
2906
  });
2886
2907
  });
2887
- logger9.info("ctx:watch", ctx.messages.watch());
2908
+ logger10.info("ctx:watch", ctx.messages.watch());
2888
2909
  }
2889
2910
  }
2890
2911
 
@@ -2917,7 +2938,7 @@ function setupGitIgnore(ctx) {
2917
2938
  init_esm_shims();
2918
2939
  import { findConfig as findConfig2 } from "@pandacss/config";
2919
2940
  import { messages } from "@pandacss/core";
2920
- import { logger as logger10, quote } from "@pandacss/logger";
2941
+ import { logger as logger11, quote } from "@pandacss/logger";
2921
2942
  import fsExtra2 from "fs-extra";
2922
2943
  import { lookItUpSync as lookItUpSync2 } from "look-it-up";
2923
2944
  import { outdent as outdent2 } from "outdent";
@@ -2932,9 +2953,9 @@ async function setupConfig(cwd, opts = {}) {
2932
2953
  const cmd = pm === "npm" ? "npm run" : pm;
2933
2954
  const isTs = lookItUpSync2("tsconfig.json", cwd);
2934
2955
  const file = isTs ? "panda.config.ts" : "panda.config.mjs";
2935
- logger10.info("init:config", `creating panda config file: ${quote(file)}`);
2956
+ logger11.info("init:config", `creating panda config file: ${quote(file)}`);
2936
2957
  if (!force && configFile) {
2937
- logger10.warn("init:config", messages.configExists(cmd));
2958
+ logger11.warn("init:config", messages.configExists(cmd));
2938
2959
  } else {
2939
2960
  const content = outdent2`
2940
2961
  import { defineConfig } from "@pandacss/dev"
@@ -2967,11 +2988,11 @@ syntax: '${syntax}'` : ""}
2967
2988
  })
2968
2989
  `;
2969
2990
  await fsExtra2.writeFile(join2(cwd, file), prettier.format(content, { parser: "babel" }));
2970
- logger10.log(messages.thankYou());
2991
+ logger11.log(messages.thankYou());
2971
2992
  }
2972
2993
  }
2973
2994
  async function setupPostcss(cwd) {
2974
- logger10.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
2995
+ logger11.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
2975
2996
  const content = outdent2`
2976
2997
  module.exports = {
2977
2998
  plugins: {
@@ -2995,5 +3016,6 @@ export {
2995
3016
  setupConfig,
2996
3017
  setupGitIgnore,
2997
3018
  setupPostcss,
3019
+ startProfiling,
2998
3020
  writeAnalyzeJSON
2999
3021
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.27.3",
3
+ "version": "0.28.0",
4
4
  "description": "The core css panda library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -39,7 +39,6 @@
39
39
  "filesize": "^10.0.8",
40
40
  "fs-extra": "11.1.1",
41
41
  "glob-parent": "^6.0.2",
42
- "hookable": "5.5.3",
43
42
  "is-glob": "^4.0.3",
44
43
  "lodash.merge": "4.6.2",
45
44
  "look-it-up": "2.1.0",
@@ -53,16 +52,17 @@
53
52
  "ts-morph": "19.0.0",
54
53
  "ts-pattern": "5.0.5",
55
54
  "tsconfck": "^2.1.2",
56
- "@pandacss/config": "0.27.3",
57
- "@pandacss/core": "0.27.3",
58
- "@pandacss/error": "0.27.3",
59
- "@pandacss/extractor": "0.27.3",
60
- "@pandacss/generator": "0.27.3",
61
- "@pandacss/logger": "0.27.3",
62
- "@pandacss/parser": "0.27.3",
63
- "@pandacss/shared": "0.27.3",
64
- "@pandacss/token-dictionary": "0.27.3",
65
- "@pandacss/types": "0.27.3"
55
+ "v8-profiler-next": "^1.10.0",
56
+ "@pandacss/config": "0.28.0",
57
+ "@pandacss/core": "0.28.0",
58
+ "@pandacss/error": "0.28.0",
59
+ "@pandacss/extractor": "0.28.0",
60
+ "@pandacss/generator": "0.28.0",
61
+ "@pandacss/logger": "0.28.0",
62
+ "@pandacss/parser": "0.28.0",
63
+ "@pandacss/shared": "0.28.0",
64
+ "@pandacss/token-dictionary": "0.28.0",
65
+ "@pandacss/types": "0.28.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/fs-extra": "11.0.4",