@pandacss/node 0.16.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,14 +1,10 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
- import { PandaHookable, Artifact, ConfigResultWithHooks, Runtime as Runtime$1, ParserResultType, Config } from '@pandacss/types';
2
+ import { Artifact, ConfigResultWithHooks, Runtime, PandaHookable, ParserResultType, Config } from '@pandacss/types';
3
3
  import { Generator } from '@pandacss/generator';
4
- import { Project } from '@pandacss/parser';
5
- import { Runtime } from '@pandacss/types/src/runtime';
4
+ import { PandaProject } from '@pandacss/parser';
6
5
  import { Root, Message } from 'postcss';
7
6
 
8
- declare const getChunkEngine: ({ paths, config, runtime: { path, fs }, }: Generator & {
9
- runtime: Runtime;
10
- hooks: PandaHookable;
11
- }) => {
7
+ interface PandaChunksEngine {
12
8
  dir: string;
13
9
  readFile(file: string): string;
14
10
  getFiles(): string[];
@@ -16,30 +12,27 @@ declare const getChunkEngine: ({ paths, config, runtime: { path, fs }, }: Genera
16
12
  getArtifact(file: string, css: string): Artifact;
17
13
  rm(file: string): void;
18
14
  empty(): void;
19
- readonly glob: string[];
20
- };
15
+ glob: string[];
16
+ }
21
17
 
22
- declare const getOutputEngine: ({ paths, runtime: { path, fs }, }: Generator & {
23
- runtime: Runtime;
24
- hooks: PandaHookable;
25
- }) => {
18
+ interface PandaOutputEngine {
26
19
  empty(): void;
27
20
  write(output: Artifact | undefined): Promise<PromiseSettledResult<void>[] | undefined>;
28
- };
21
+ }
29
22
 
30
23
  declare const createContext: (conf: ConfigResultWithHooks) => PandaContext;
31
- type PandaContext = Generator & {
32
- runtime: Runtime$1;
24
+ interface PandaContext extends Generator {
25
+ runtime: Runtime;
33
26
  hooks: PandaHookable;
34
- project: Project;
27
+ project: PandaProject;
35
28
  getFiles: () => string[];
36
- chunks: ReturnType<typeof getChunkEngine>;
37
- output: ReturnType<typeof getOutputEngine>;
38
- };
29
+ chunks: PandaChunksEngine;
30
+ output: PandaOutputEngine;
31
+ }
39
32
 
40
- type Options = {
33
+ interface Options {
41
34
  onResult?: (file: string, result: ParserResultType) => void;
42
- };
35
+ }
43
36
  declare function analyzeTokens(ctx: PandaContext, options?: Options): {
44
37
  duration: {
45
38
  extractTimeByFiles: {
@@ -179,23 +172,26 @@ declare function analyzeTokens(ctx: PandaContext, options?: Options): {
179
172
  };
180
173
  declare const writeAnalyzeJSON: (fileName: string, result: ReturnType<typeof analyzeTokens>, ctx: PandaContext) => Promise<void>;
181
174
 
182
- type ConfigDepsResult = {
175
+ interface ConfigDepsResult {
183
176
  modifiedMap: Map<string, number>;
184
177
  isModified: boolean;
185
- };
178
+ }
186
179
  declare class Builder {
187
180
  /**
188
181
  * The current panda context
189
182
  */
190
183
  context: PandaContext | undefined;
184
+ hasEmitted: boolean;
191
185
  configDependencies: Set<string>;
192
186
  writeFileCss: (file: string, css: string) => void;
193
187
  checkConfigDeps: (configPath: string, deps: Set<string>) => ConfigDepsResult;
194
188
  getConfigPath: () => string;
189
+ hasConfigChanged: boolean;
195
190
  setup: (options?: {
196
191
  configPath?: string;
197
192
  cwd?: string;
198
193
  }) => Promise<void>;
194
+ emit(): void;
199
195
  setupContext: (options: {
200
196
  configPath: string;
201
197
  depsModifiedMap: Map<string, number>;
package/dist/index.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
- import { PandaHookable, Artifact, ConfigResultWithHooks, Runtime as Runtime$1, ParserResultType, Config } from '@pandacss/types';
2
+ import { Artifact, ConfigResultWithHooks, Runtime, PandaHookable, ParserResultType, Config } from '@pandacss/types';
3
3
  import { Generator } from '@pandacss/generator';
4
- import { Project } from '@pandacss/parser';
5
- import { Runtime } from '@pandacss/types/src/runtime';
4
+ import { PandaProject } from '@pandacss/parser';
6
5
  import { Root, Message } from 'postcss';
7
6
 
8
- declare const getChunkEngine: ({ paths, config, runtime: { path, fs }, }: Generator & {
9
- runtime: Runtime;
10
- hooks: PandaHookable;
11
- }) => {
7
+ interface PandaChunksEngine {
12
8
  dir: string;
13
9
  readFile(file: string): string;
14
10
  getFiles(): string[];
@@ -16,30 +12,27 @@ declare const getChunkEngine: ({ paths, config, runtime: { path, fs }, }: Genera
16
12
  getArtifact(file: string, css: string): Artifact;
17
13
  rm(file: string): void;
18
14
  empty(): void;
19
- readonly glob: string[];
20
- };
15
+ glob: string[];
16
+ }
21
17
 
22
- declare const getOutputEngine: ({ paths, runtime: { path, fs }, }: Generator & {
23
- runtime: Runtime;
24
- hooks: PandaHookable;
25
- }) => {
18
+ interface PandaOutputEngine {
26
19
  empty(): void;
27
20
  write(output: Artifact | undefined): Promise<PromiseSettledResult<void>[] | undefined>;
28
- };
21
+ }
29
22
 
30
23
  declare const createContext: (conf: ConfigResultWithHooks) => PandaContext;
31
- type PandaContext = Generator & {
32
- runtime: Runtime$1;
24
+ interface PandaContext extends Generator {
25
+ runtime: Runtime;
33
26
  hooks: PandaHookable;
34
- project: Project;
27
+ project: PandaProject;
35
28
  getFiles: () => string[];
36
- chunks: ReturnType<typeof getChunkEngine>;
37
- output: ReturnType<typeof getOutputEngine>;
38
- };
29
+ chunks: PandaChunksEngine;
30
+ output: PandaOutputEngine;
31
+ }
39
32
 
40
- type Options = {
33
+ interface Options {
41
34
  onResult?: (file: string, result: ParserResultType) => void;
42
- };
35
+ }
43
36
  declare function analyzeTokens(ctx: PandaContext, options?: Options): {
44
37
  duration: {
45
38
  extractTimeByFiles: {
@@ -179,23 +172,26 @@ declare function analyzeTokens(ctx: PandaContext, options?: Options): {
179
172
  };
180
173
  declare const writeAnalyzeJSON: (fileName: string, result: ReturnType<typeof analyzeTokens>, ctx: PandaContext) => Promise<void>;
181
174
 
182
- type ConfigDepsResult = {
175
+ interface ConfigDepsResult {
183
176
  modifiedMap: Map<string, number>;
184
177
  isModified: boolean;
185
- };
178
+ }
186
179
  declare class Builder {
187
180
  /**
188
181
  * The current panda context
189
182
  */
190
183
  context: PandaContext | undefined;
184
+ hasEmitted: boolean;
191
185
  configDependencies: Set<string>;
192
186
  writeFileCss: (file: string, css: string) => void;
193
187
  checkConfigDeps: (configPath: string, deps: Set<string>) => ConfigDepsResult;
194
188
  getConfigPath: () => string;
189
+ hasConfigChanged: boolean;
195
190
  setup: (options?: {
196
191
  configPath?: string;
197
192
  cwd?: string;
198
193
  }) => Promise<void>;
194
+ emit(): void;
199
195
  setupContext: (options: {
200
196
  configPath: string;
201
197
  depsModifiedMap: Map<string, number>;
package/dist/index.js CHANGED
@@ -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@7.1.0_postcss@8.4.27_typescript@5.2.2/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.31_typescript@5.2.2/node_modules/tsup/assets/cjs_shims.js
37
37
  var init_cjs_shims = __esm({
38
- "../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.27_typescript@5.2.2/node_modules/tsup/assets/cjs_shims.js"() {
38
+ "../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.31_typescript@5.2.2/node_modules/tsup/assets/cjs_shims.js"() {
39
39
  "use strict";
40
40
  }
41
41
  });
@@ -782,11 +782,118 @@ init_cjs_shims();
782
782
  var import_config2 = require("@pandacss/config");
783
783
  var import_core3 = require("@pandacss/core");
784
784
  var import_error = require("@pandacss/error");
785
- var import_logger4 = require("@pandacss/logger");
785
+ var import_logger5 = require("@pandacss/logger");
786
786
  var import_fs = require("fs");
787
787
  var import_fs_extra2 = require("fs-extra");
788
788
  var import_path2 = require("path");
789
789
 
790
+ // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
791
+ init_cjs_shims();
792
+
793
+ // ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
794
+ init_cjs_shims();
795
+ var Node = class {
796
+ value;
797
+ next;
798
+ constructor(value) {
799
+ this.value = value;
800
+ }
801
+ };
802
+ var Queue = class {
803
+ #head;
804
+ #tail;
805
+ #size;
806
+ constructor() {
807
+ this.clear();
808
+ }
809
+ enqueue(value) {
810
+ const node = new Node(value);
811
+ if (this.#head) {
812
+ this.#tail.next = node;
813
+ this.#tail = node;
814
+ } else {
815
+ this.#head = node;
816
+ this.#tail = node;
817
+ }
818
+ this.#size++;
819
+ }
820
+ dequeue() {
821
+ const current = this.#head;
822
+ if (!current) {
823
+ return;
824
+ }
825
+ this.#head = this.#head.next;
826
+ this.#size--;
827
+ return current.value;
828
+ }
829
+ clear() {
830
+ this.#head = void 0;
831
+ this.#tail = void 0;
832
+ this.#size = 0;
833
+ }
834
+ get size() {
835
+ return this.#size;
836
+ }
837
+ *[Symbol.iterator]() {
838
+ let current = this.#head;
839
+ while (current) {
840
+ yield current.value;
841
+ current = current.next;
842
+ }
843
+ }
844
+ };
845
+
846
+ // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
847
+ function pLimit(concurrency) {
848
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
849
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
850
+ }
851
+ const queue = new Queue();
852
+ let activeCount = 0;
853
+ const next = () => {
854
+ activeCount--;
855
+ if (queue.size > 0) {
856
+ queue.dequeue()();
857
+ }
858
+ };
859
+ const run = async (fn, resolve3, args) => {
860
+ activeCount++;
861
+ const result = (async () => fn(...args))();
862
+ resolve3(result);
863
+ try {
864
+ await result;
865
+ } catch {
866
+ }
867
+ next();
868
+ };
869
+ const enqueue = (fn, resolve3, args) => {
870
+ queue.enqueue(run.bind(void 0, fn, resolve3, args));
871
+ (async () => {
872
+ await Promise.resolve();
873
+ if (activeCount < concurrency && queue.size > 0) {
874
+ queue.dequeue()();
875
+ }
876
+ })();
877
+ };
878
+ const generator = (fn, ...args) => new Promise((resolve3) => {
879
+ enqueue(fn, resolve3, args);
880
+ });
881
+ Object.defineProperties(generator, {
882
+ activeCount: {
883
+ get: () => activeCount
884
+ },
885
+ pendingCount: {
886
+ get: () => queue.size
887
+ },
888
+ clearQueue: {
889
+ value: () => {
890
+ queue.clear();
891
+ }
892
+ }
893
+ });
894
+ return generator;
895
+ }
896
+
790
897
  // src/config.ts
791
898
  init_cjs_shims();
792
899
  var import_config = require("@pandacss/config");
@@ -797,6 +904,7 @@ var import_tsconfck = require("tsconfck");
797
904
  // src/create-context.ts
798
905
  init_cjs_shims();
799
906
  var import_generator = require("@pandacss/generator");
907
+ var import_logger3 = require("@pandacss/logger");
800
908
  var import_parser = require("@pandacss/parser");
801
909
 
802
910
  // src/chunk-engine.ts
@@ -927,11 +1035,14 @@ var getOutputEngine = ({
927
1035
  const { dir = paths.root, files } = output;
928
1036
  fs.ensureDirSync(path2.join(...dir));
929
1037
  return Promise.allSettled(
930
- files.map(async ({ file, code }) => {
1038
+ files.map(async (artifact) => {
1039
+ if (!artifact)
1040
+ return;
1041
+ const { file, code } = artifact;
931
1042
  const absPath = path2.join(...dir, file);
932
- if (code) {
933
- return fs.writeFile(absPath, code);
934
- }
1043
+ if (!code)
1044
+ return;
1045
+ return fs.writeFile(absPath, code);
935
1046
  })
936
1047
  );
937
1048
  }
@@ -943,6 +1054,9 @@ var createContext = (conf) => {
943
1054
  const config = conf.config;
944
1055
  const runtime = nodeRuntime;
945
1056
  config.cwd ||= runtime.cwd();
1057
+ if (config.logLevel) {
1058
+ import_logger3.logger.level = config.logLevel;
1059
+ }
946
1060
  const { include, exclude, cwd } = config;
947
1061
  const getFiles = () => runtime.fs.glob({ include, exclude, cwd });
948
1062
  const ctx = {
@@ -974,7 +1088,8 @@ function findConfig() {
974
1088
  }
975
1089
  async function loadConfigAndCreateContext(options = {}) {
976
1090
  const hooks = (0, import_hookable.createHooks)();
977
- const { cwd = process.cwd(), config, configPath } = options;
1091
+ const { config, configPath } = options;
1092
+ const cwd = options.cwd ?? options?.config?.cwd ?? process.cwd();
978
1093
  const conf = await (0, import_config.loadConfigFile)({ cwd, file: configPath });
979
1094
  if (config) {
980
1095
  Object.assign(conf.config, config);
@@ -1005,8 +1120,12 @@ async function loadConfigAndCreateContext(options = {}) {
1005
1120
 
1006
1121
  // src/extract.ts
1007
1122
  init_cjs_shims();
1008
- var import_logger3 = require("@pandacss/logger");
1123
+ var import_core2 = require("@pandacss/core");
1124
+ var import_logger4 = require("@pandacss/logger");
1125
+ var import_parser2 = require("@pandacss/parser");
1126
+ var import_promises2 = require("fs/promises");
1009
1127
  var import_lil_fp = require("lil-fp");
1128
+ var import_ts_pattern = require("ts-pattern");
1010
1129
 
1011
1130
  // src/cli-box.ts
1012
1131
  init_cjs_shims();
@@ -2321,10 +2440,6 @@ var createBox = (options) => boxen(options.content, {
2321
2440
  });
2322
2441
 
2323
2442
  // src/extract.ts
2324
- var import_promises2 = require("fs/promises");
2325
- var import_parser2 = require("@pandacss/parser");
2326
- var import_ts_pattern = require("ts-pattern");
2327
- var import_core2 = require("@pandacss/core");
2328
2443
  async function bundleStyleChunksWithImports(ctx) {
2329
2444
  const files = ctx.chunks.getFiles();
2330
2445
  await ctx.output.write({
@@ -2335,7 +2450,7 @@ async function bundleStyleChunksWithImports(ctx) {
2335
2450
  }
2336
2451
  async function writeFileChunk(ctx, file) {
2337
2452
  const { path: path2 } = ctx.runtime;
2338
- import_logger3.logger.debug("chunk:write", `File: ${path2.relative(ctx.config.cwd, file)}`);
2453
+ import_logger4.logger.debug("chunk:write", `File: ${path2.relative(ctx.config.cwd, file)}`);
2339
2454
  const css = extractFile(ctx, file);
2340
2455
  if (!css)
2341
2456
  return;
@@ -2349,16 +2464,16 @@ function extractFile(ctx, file) {
2349
2464
  } = ctx;
2350
2465
  return (0, import_lil_fp.pipe)(
2351
2466
  { file: path2.abs(cwd, file) },
2352
- (0, import_lil_fp.tap)(() => import_logger3.logger.debug("file:extract", file)),
2353
- import_lil_fp.Obj.bind("measure", () => import_logger3.logger.time.debug(`Extracted ${file}`)),
2467
+ (0, import_lil_fp.tap)(() => import_logger4.logger.debug("file:extract", file)),
2468
+ import_lil_fp.Obj.bind("measure", () => import_logger4.logger.time.debug(`Extracted ${file}`)),
2354
2469
  import_lil_fp.Obj.bind(
2355
2470
  "result",
2356
2471
  (0, import_lil_fp.tryCatch)(
2357
2472
  ({ file: file2 }) => ctx.project.parseSourceFile(file2),
2358
- (error) => import_logger3.logger.error("file:parse", error)
2473
+ (error) => import_logger4.logger.error("file:parse", error)
2359
2474
  )
2360
2475
  ),
2361
- import_lil_fp.Obj.bind("measureCss", () => import_logger3.logger.time.debug(`Parsed ${file}`)),
2476
+ import_lil_fp.Obj.bind("measureCss", () => import_logger4.logger.time.debug(`Parsed ${file}`)),
2362
2477
  import_lil_fp.Obj.bind("css", ({ result }) => result ? ctx.getParserCss(result) : void 0),
2363
2478
  (0, import_lil_fp.tap)(({ measure, measureCss }) => [measureCss(), measure()]),
2364
2479
  import_lil_fp.Obj.get("css")
@@ -2369,10 +2484,12 @@ function writeChunks(ctx) {
2369
2484
  }
2370
2485
  var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
2371
2486
  var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
2487
+ var limit = pLimit(20);
2372
2488
  async function emitArtifacts(ctx) {
2373
2489
  if (ctx.config.clean)
2374
2490
  ctx.output.empty();
2375
- await Promise.allSettled(ctx.getArtifacts().map(ctx.output.write));
2491
+ const promises = ctx.getArtifacts().map((artifact) => limit(() => ctx.output.write(artifact)));
2492
+ await Promise.allSettled(promises);
2376
2493
  void ctx.hooks.callHook("generator:done");
2377
2494
  return {
2378
2495
  box: createBox({
@@ -2405,7 +2522,7 @@ async function bundleMinimalFilesCss(ctx, outfile) {
2405
2522
  const filesWithCss = [];
2406
2523
  const collector = (0, import_parser2.createParserResult)();
2407
2524
  files.forEach((file) => {
2408
- const measure = import_logger3.logger.time.debug(`Parsed ${file}`);
2525
+ const measure = import_logger4.logger.time.debug(`Parsed ${file}`);
2409
2526
  const result = ctx.project.parseSourceFile(file);
2410
2527
  measure();
2411
2528
  if (!result)
@@ -2481,12 +2598,13 @@ function parseDependency(fileOrGlob) {
2481
2598
  // src/builder.ts
2482
2599
  var configCache = /* @__PURE__ */ new Map();
2483
2600
  var contentFilesCache = /* @__PURE__ */ new WeakMap();
2484
- var setupCount = 0;
2601
+ var limit2 = pLimit(20);
2485
2602
  var Builder = class {
2486
2603
  /**
2487
2604
  * The current panda context
2488
2605
  */
2489
2606
  context;
2607
+ hasEmitted = false;
2490
2608
  configDependencies = /* @__PURE__ */ new Set();
2491
2609
  writeFileCss = (file, css) => {
2492
2610
  const oldCss = this.fileCssMap?.get(file) ?? "";
@@ -2513,9 +2631,6 @@ var Builder = class {
2513
2631
  for (const file of deps) {
2514
2632
  delete require.cache[file];
2515
2633
  }
2516
- if (setupCount > 0) {
2517
- import_logger4.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
2518
- }
2519
2634
  return { isModified: true, modifiedMap: newModified };
2520
2635
  };
2521
2636
  getConfigPath = () => {
@@ -2525,8 +2640,9 @@ var Builder = class {
2525
2640
  }
2526
2641
  return configPath;
2527
2642
  };
2643
+ hasConfigChanged = false;
2528
2644
  setup = async (options = {}) => {
2529
- import_logger4.logger.debug("builder", "\u{1F6A7} Setup");
2645
+ import_logger5.logger.debug("builder", "\u{1F6A7} Setup");
2530
2646
  const configPath = options.configPath ?? this.getConfigPath();
2531
2647
  const tsOptions = this.context?.tsOptions ?? { baseUrl: void 0, pathMappings: [] };
2532
2648
  const compilerOptions = this.context?.tsconfig?.compilerOptions ?? {};
@@ -2535,12 +2651,14 @@ var Builder = class {
2535
2651
  const configDeps = /* @__PURE__ */ new Set([...foundDeps, ...(this.context?.dependencies ?? []).map((file) => (0, import_path2.resolve)(cwd, file))]);
2536
2652
  this.configDependencies = configDeps;
2537
2653
  const deps = this.checkConfigDeps(configPath, configDeps);
2654
+ this.hasConfigChanged = deps.isModified;
2538
2655
  if (deps.isModified) {
2539
2656
  await this.setupContext({
2540
2657
  configPath,
2541
2658
  depsModifiedMap: deps.modifiedMap
2542
2659
  });
2543
- const ctx = this.context;
2660
+ const ctx = this.getContextOrThrow();
2661
+ import_logger5.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
2544
2662
  await ctx.hooks.callHook("config:change", ctx.config);
2545
2663
  }
2546
2664
  const cache = configCache.get(configPath);
@@ -2553,14 +2671,16 @@ var Builder = class {
2553
2671
  depsModifiedMap: deps.modifiedMap
2554
2672
  });
2555
2673
  }
2556
- setupCount++;
2557
2674
  };
2675
+ emit() {
2676
+ if (this.hasEmitted && this.hasConfigChanged) {
2677
+ emitArtifacts(this.getContextOrThrow());
2678
+ }
2679
+ this.hasEmitted = true;
2680
+ }
2558
2681
  setupContext = async (options) => {
2559
2682
  const { configPath, depsModifiedMap } = options;
2560
2683
  this.context = await loadConfigAndCreateContext({ configPath });
2561
- if (setupCount > 0) {
2562
- emitArtifacts(this.context);
2563
- }
2564
2684
  configCache.set(configPath, {
2565
2685
  context: this.context,
2566
2686
  deps: new Set(this.context.dependencies ?? []),
@@ -2599,8 +2719,9 @@ var Builder = class {
2599
2719
  };
2600
2720
  extract = async () => {
2601
2721
  const ctx = this.getContextOrThrow();
2602
- const done = import_logger4.logger.time.info("Extracted in");
2603
- await Promise.allSettled(ctx.getFiles().map((file) => this.extractFile(ctx, file)));
2722
+ const done = import_logger5.logger.time.info("Extracted in");
2723
+ const promises = ctx.getFiles().map((file) => limit2(() => this.extractFile(ctx, file)));
2724
+ await Promise.allSettled(promises);
2604
2725
  done();
2605
2726
  };
2606
2727
  toString = () => {
@@ -2649,24 +2770,24 @@ var Builder = class {
2649
2770
 
2650
2771
  // src/debug-files.ts
2651
2772
  init_cjs_shims();
2652
- var import_logger5 = require("@pandacss/logger");
2773
+ var import_logger6 = require("@pandacss/logger");
2653
2774
  var nodePath = __toESM(require("path"));
2654
2775
  async function debugFiles(ctx, options) {
2655
2776
  const files = ctx.getFiles();
2656
- const measureTotal = import_logger5.logger.time.debug(`Done parsing ${files.length} files`);
2777
+ const measureTotal = import_logger6.logger.time.debug(`Done parsing ${files.length} files`);
2657
2778
  ctx.config.minify = false;
2658
2779
  ctx.config.optimize = true;
2659
2780
  const { fs, path: path2 } = ctx.runtime;
2660
2781
  const outdir = options.outdir;
2661
2782
  if (!options.dry && outdir) {
2662
2783
  fs.ensureDirSync(outdir);
2663
- import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/config.json`)}`);
2784
+ import_logger6.logger.info("cli", `Writing ${import_logger6.colors.bold(`${outdir}/config.json`)}`);
2664
2785
  await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2665
2786
  }
2666
2787
  const filesWithCss = [];
2667
2788
  await Promise.allSettled(
2668
2789
  files.map(async (file) => {
2669
- const measure = import_logger5.logger.time.debug(`Parsed ${file}`);
2790
+ const measure = import_logger6.logger.time.debug(`Parsed ${file}`);
2670
2791
  const result = ctx.project.parseSourceFile(file);
2671
2792
  measure();
2672
2793
  if (!result)
@@ -2684,8 +2805,8 @@ async function debugFiles(ctx, options) {
2684
2805
  const relative3 = path2.relative(ctx.config.cwd, parsedPath.dir);
2685
2806
  const astJsonPath = `${relative3}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
2686
2807
  const cssPath = `${relative3}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
2687
- import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/${astJsonPath}`)}`);
2688
- import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${outdir}/${cssPath}`)}`);
2808
+ import_logger6.logger.info("cli", `Writing ${import_logger6.colors.bold(`${outdir}/${astJsonPath}`)}`);
2809
+ import_logger6.logger.info("cli", `Writing ${import_logger6.colors.bold(`${outdir}/${cssPath}`)}`);
2689
2810
  return Promise.allSettled([
2690
2811
  fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2691
2812
  fs.writeFile(`${outdir}/${cssPath}`, css)
@@ -2693,13 +2814,13 @@ async function debugFiles(ctx, options) {
2693
2814
  }
2694
2815
  })
2695
2816
  );
2696
- import_logger5.logger.info("cli", `Found ${import_logger5.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2817
+ import_logger6.logger.info("cli", `Found ${import_logger6.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2697
2818
  measureTotal();
2698
2819
  }
2699
2820
 
2700
2821
  // src/exec-command.ts
2701
2822
  init_cjs_shims();
2702
- var import_logger6 = require("@pandacss/logger");
2823
+ var import_logger7 = require("@pandacss/logger");
2703
2824
  var import_child_process = require("child_process");
2704
2825
  var import_preferred_pm = __toESM(require("preferred-pm"));
2705
2826
  async function execCommand(cmd, cwd) {
@@ -2711,13 +2832,13 @@ async function execCommand(cmd, cwd) {
2711
2832
  }
2712
2833
  const check = (0, import_child_process.spawnSync)(pm, args, { cwd, stdio: "pipe" });
2713
2834
  if (check.status !== 0) {
2714
- import_logger6.logger.error("exec", check.stderr.toString());
2835
+ import_logger7.logger.error("exec", check.stderr.toString());
2715
2836
  }
2716
2837
  }
2717
2838
 
2718
2839
  // src/generate.ts
2719
2840
  init_cjs_shims();
2720
- var import_logger7 = require("@pandacss/logger");
2841
+ var import_logger8 = require("@pandacss/logger");
2721
2842
  var import_ts_pattern2 = require("ts-pattern");
2722
2843
 
2723
2844
  // src/load-context.ts
@@ -2735,7 +2856,7 @@ var loadContext = async (config, configPath) => {
2735
2856
  // src/generate.ts
2736
2857
  async function build(ctx) {
2737
2858
  const { msg } = await emitArtfifactsAndCssChunks(ctx);
2738
- import_logger7.logger.info("css:emit", msg);
2859
+ import_logger8.logger.info("css:emit", msg);
2739
2860
  }
2740
2861
  async function generate(config, configPath) {
2741
2862
  const [ctxRef, loadCtx] = await loadContext(config, configPath);
@@ -2749,14 +2870,14 @@ async function generate(config, configPath) {
2749
2870
  if (ctx.config.watch) {
2750
2871
  const configWatcher = fs.watch({ include: dependencies });
2751
2872
  configWatcher.on("change", async () => {
2752
- import_logger7.logger.info("config:change", "Config changed, restarting...");
2873
+ import_logger8.logger.info("config:change", "Config changed, restarting...");
2753
2874
  await loadCtx();
2754
2875
  await ctxRef.current.hooks.callHook("config:change", ctxRef.current.config);
2755
2876
  return build(ctxRef.current);
2756
2877
  });
2757
2878
  const contentWatcher = fs.watch(ctx.config);
2758
2879
  contentWatcher.on("all", async (event, file) => {
2759
- import_logger7.logger.info(`file:${event}`, file);
2880
+ import_logger8.logger.info(`file:${event}`, file);
2760
2881
  (0, import_ts_pattern2.match)(event).with("unlink", () => {
2761
2882
  ctx.project.removeSourceFile(path2.abs(cwd, file));
2762
2883
  ctx.chunks.rm(file);
@@ -2770,7 +2891,7 @@ async function generate(config, configPath) {
2770
2891
  }).otherwise(() => {
2771
2892
  });
2772
2893
  });
2773
- import_logger7.logger.info("ctx:watch", ctx.messages.watch());
2894
+ import_logger8.logger.info("ctx:watch", ctx.messages.watch());
2774
2895
  }
2775
2896
  }
2776
2897
 
@@ -2802,7 +2923,7 @@ function setupGitIgnore(ctx) {
2802
2923
  // src/setup-config.ts
2803
2924
  init_cjs_shims();
2804
2925
  var import_generator2 = require("@pandacss/generator");
2805
- var import_logger8 = require("@pandacss/logger");
2926
+ var import_logger9 = require("@pandacss/logger");
2806
2927
  var import_fs_extra3 = require("fs-extra");
2807
2928
  var import_look_it_up3 = require("look-it-up");
2808
2929
  var import_outdent2 = require("outdent");
@@ -2816,9 +2937,9 @@ async function setupConfig(cwd, opts = {}) {
2816
2937
  const cmd = pm === "npm" ? "npm run" : pm;
2817
2938
  const isTs = (0, import_look_it_up3.lookItUpSync)("tsconfig.json", cwd);
2818
2939
  const file = isTs ? "panda.config.ts" : "panda.config.mjs";
2819
- import_logger8.logger.info("init:config", `creating panda config file: ${(0, import_logger8.quote)(file)}`);
2940
+ import_logger9.logger.info("init:config", `creating panda config file: ${(0, import_logger9.quote)(file)}`);
2820
2941
  if (!force && configFile) {
2821
- import_logger8.logger.warn("init:config", import_generator2.messages.configExists(cmd));
2942
+ import_logger9.logger.warn("init:config", import_generator2.messages.configExists(cmd));
2822
2943
  } else {
2823
2944
  const content = import_outdent2.outdent`
2824
2945
  import { defineConfig } from "@pandacss/dev"
@@ -2851,11 +2972,11 @@ syntax: '${syntax}'` : ""}
2851
2972
  })
2852
2973
  `;
2853
2974
  await (0, import_fs_extra3.writeFile)((0, import_path3.join)(cwd, file), content);
2854
- import_logger8.logger.log(import_generator2.messages.thankYou());
2975
+ import_logger9.logger.log(import_generator2.messages.thankYou());
2855
2976
  }
2856
2977
  }
2857
2978
  async function setupPostcss(cwd) {
2858
- import_logger8.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger8.quote)("postcss.config.cjs")}`);
2979
+ import_logger9.logger.info("init:postcss", `creating postcss config file: ${(0, import_logger9.quote)("postcss.config.cjs")}`);
2859
2980
  const content = import_outdent2.outdent`
2860
2981
  module.exports = {
2861
2982
  plugins: {
@@ -2868,7 +2989,7 @@ module.exports = {
2868
2989
 
2869
2990
  // src/ship-files.ts
2870
2991
  init_cjs_shims();
2871
- var import_logger9 = require("@pandacss/logger");
2992
+ var import_logger10 = require("@pandacss/logger");
2872
2993
  var import_parser3 = require("@pandacss/parser");
2873
2994
  var import_promises3 = require("fs/promises");
2874
2995
  var path = __toESM(require("path"));
@@ -2886,12 +3007,12 @@ async function shipFiles(ctx, outfile) {
2886
3007
  extractResult.merge(result);
2887
3008
  filesWithCss.push(path.relative(ctx.config.cwd, file));
2888
3009
  });
2889
- import_logger9.logger.info("cli", `Found ${import_logger9.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
3010
+ import_logger10.logger.info("cli", `Found ${import_logger10.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2890
3011
  const minify = ctx.config.minify;
2891
- import_logger9.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger9.colors.bold(outfile)}`);
3012
+ import_logger10.logger.info("cli", `Writing ${minify ? "[min] " : " "}${import_logger10.colors.bold(outfile)}`);
2892
3013
  const output = JSON.stringify(extractResult.toJSON(), null, minify ? 0 : 2);
2893
3014
  await (0, import_promises3.writeFile)(outfile, output);
2894
- import_logger9.logger.info("cli", "Done!");
3015
+ import_logger10.logger.info("cli", "Done!");
2895
3016
  }
2896
3017
  // Annotate the CommonJS export names for ESM import in node:
2897
3018
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  mod
35
35
  ));
36
36
 
37
- // ../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.27_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js
37
+ // ../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.31_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js
38
38
  var init_esm_shims = __esm({
39
- "../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.27_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js"() {
39
+ "../../node_modules/.pnpm/tsup@7.1.0_postcss@8.4.31_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js"() {
40
40
  "use strict";
41
41
  }
42
42
  });
@@ -758,11 +758,118 @@ init_esm_shims();
758
758
  import { getConfigDependencies } from "@pandacss/config";
759
759
  import { optimizeCss as optimizeCss2, mergeCss as mergeCss2 } from "@pandacss/core";
760
760
  import { ConfigNotFoundError } from "@pandacss/error";
761
- import { logger as logger4 } from "@pandacss/logger";
761
+ import { logger as logger5 } from "@pandacss/logger";
762
762
  import { existsSync as existsSync2 } from "fs";
763
763
  import { statSync } from "fs-extra";
764
764
  import { resolve as resolve2 } from "path";
765
765
 
766
+ // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
767
+ init_esm_shims();
768
+
769
+ // ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
770
+ init_esm_shims();
771
+ var Node = class {
772
+ value;
773
+ next;
774
+ constructor(value) {
775
+ this.value = value;
776
+ }
777
+ };
778
+ var Queue = class {
779
+ #head;
780
+ #tail;
781
+ #size;
782
+ constructor() {
783
+ this.clear();
784
+ }
785
+ enqueue(value) {
786
+ const node = new Node(value);
787
+ if (this.#head) {
788
+ this.#tail.next = node;
789
+ this.#tail = node;
790
+ } else {
791
+ this.#head = node;
792
+ this.#tail = node;
793
+ }
794
+ this.#size++;
795
+ }
796
+ dequeue() {
797
+ const current = this.#head;
798
+ if (!current) {
799
+ return;
800
+ }
801
+ this.#head = this.#head.next;
802
+ this.#size--;
803
+ return current.value;
804
+ }
805
+ clear() {
806
+ this.#head = void 0;
807
+ this.#tail = void 0;
808
+ this.#size = 0;
809
+ }
810
+ get size() {
811
+ return this.#size;
812
+ }
813
+ *[Symbol.iterator]() {
814
+ let current = this.#head;
815
+ while (current) {
816
+ yield current.value;
817
+ current = current.next;
818
+ }
819
+ }
820
+ };
821
+
822
+ // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
823
+ function pLimit(concurrency) {
824
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
825
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
826
+ }
827
+ const queue = new Queue();
828
+ let activeCount = 0;
829
+ const next = () => {
830
+ activeCount--;
831
+ if (queue.size > 0) {
832
+ queue.dequeue()();
833
+ }
834
+ };
835
+ const run = async (fn, resolve3, args) => {
836
+ activeCount++;
837
+ const result = (async () => fn(...args))();
838
+ resolve3(result);
839
+ try {
840
+ await result;
841
+ } catch {
842
+ }
843
+ next();
844
+ };
845
+ const enqueue = (fn, resolve3, args) => {
846
+ queue.enqueue(run.bind(void 0, fn, resolve3, args));
847
+ (async () => {
848
+ await Promise.resolve();
849
+ if (activeCount < concurrency && queue.size > 0) {
850
+ queue.dequeue()();
851
+ }
852
+ })();
853
+ };
854
+ const generator = (fn, ...args) => new Promise((resolve3) => {
855
+ enqueue(fn, resolve3, args);
856
+ });
857
+ Object.defineProperties(generator, {
858
+ activeCount: {
859
+ get: () => activeCount
860
+ },
861
+ pendingCount: {
862
+ get: () => queue.size
863
+ },
864
+ clearQueue: {
865
+ value: () => {
866
+ queue.clear();
867
+ }
868
+ }
869
+ });
870
+ return generator;
871
+ }
872
+
766
873
  // src/config.ts
767
874
  init_esm_shims();
768
875
  import { convertTsPathsToRegexes, loadConfigFile } from "@pandacss/config";
@@ -773,6 +880,7 @@ import { parse } from "tsconfck";
773
880
  // src/create-context.ts
774
881
  init_esm_shims();
775
882
  import { createGenerator } from "@pandacss/generator";
883
+ import { logger as logger3 } from "@pandacss/logger";
776
884
  import { createProject } from "@pandacss/parser";
777
885
 
778
886
  // src/chunk-engine.ts
@@ -912,11 +1020,14 @@ var getOutputEngine = ({
912
1020
  const { dir = paths.root, files } = output;
913
1021
  fs.ensureDirSync(path2.join(...dir));
914
1022
  return Promise.allSettled(
915
- files.map(async ({ file, code }) => {
1023
+ files.map(async (artifact) => {
1024
+ if (!artifact)
1025
+ return;
1026
+ const { file, code } = artifact;
916
1027
  const absPath = path2.join(...dir, file);
917
- if (code) {
918
- return fs.writeFile(absPath, code);
919
- }
1028
+ if (!code)
1029
+ return;
1030
+ return fs.writeFile(absPath, code);
920
1031
  })
921
1032
  );
922
1033
  }
@@ -928,6 +1039,9 @@ var createContext = (conf) => {
928
1039
  const config = conf.config;
929
1040
  const runtime = nodeRuntime;
930
1041
  config.cwd ||= runtime.cwd();
1042
+ if (config.logLevel) {
1043
+ logger3.level = config.logLevel;
1044
+ }
931
1045
  const { include, exclude, cwd } = config;
932
1046
  const getFiles = () => runtime.fs.glob({ include, exclude, cwd });
933
1047
  const ctx = {
@@ -959,7 +1073,8 @@ function findConfig() {
959
1073
  }
960
1074
  async function loadConfigAndCreateContext(options = {}) {
961
1075
  const hooks = createHooks();
962
- const { cwd = process.cwd(), config, configPath } = options;
1076
+ const { config, configPath } = options;
1077
+ const cwd = options.cwd ?? options?.config?.cwd ?? process.cwd();
963
1078
  const conf = await loadConfigFile({ cwd, file: configPath });
964
1079
  if (config) {
965
1080
  Object.assign(conf.config, config);
@@ -990,8 +1105,12 @@ async function loadConfigAndCreateContext(options = {}) {
990
1105
 
991
1106
  // src/extract.ts
992
1107
  init_esm_shims();
993
- import { logger as logger3 } from "@pandacss/logger";
1108
+ import { optimizeCss } from "@pandacss/core";
1109
+ import { logger as logger4 } from "@pandacss/logger";
1110
+ import { createParserResult } from "@pandacss/parser";
1111
+ import { writeFile as writeFile3 } from "fs/promises";
994
1112
  import { Obj, pipe, tap, tryCatch } from "lil-fp";
1113
+ import { match } from "ts-pattern";
995
1114
 
996
1115
  // src/cli-box.ts
997
1116
  init_esm_shims();
@@ -2306,10 +2425,6 @@ var createBox = (options) => boxen(options.content, {
2306
2425
  });
2307
2426
 
2308
2427
  // src/extract.ts
2309
- import { writeFile as writeFile3 } from "fs/promises";
2310
- import { createParserResult } from "@pandacss/parser";
2311
- import { match } from "ts-pattern";
2312
- import { optimizeCss } from "@pandacss/core";
2313
2428
  async function bundleStyleChunksWithImports(ctx) {
2314
2429
  const files = ctx.chunks.getFiles();
2315
2430
  await ctx.output.write({
@@ -2320,7 +2435,7 @@ async function bundleStyleChunksWithImports(ctx) {
2320
2435
  }
2321
2436
  async function writeFileChunk(ctx, file) {
2322
2437
  const { path: path2 } = ctx.runtime;
2323
- logger3.debug("chunk:write", `File: ${path2.relative(ctx.config.cwd, file)}`);
2438
+ logger4.debug("chunk:write", `File: ${path2.relative(ctx.config.cwd, file)}`);
2324
2439
  const css = extractFile(ctx, file);
2325
2440
  if (!css)
2326
2441
  return;
@@ -2334,16 +2449,16 @@ function extractFile(ctx, file) {
2334
2449
  } = ctx;
2335
2450
  return pipe(
2336
2451
  { file: path2.abs(cwd, file) },
2337
- tap(() => logger3.debug("file:extract", file)),
2338
- Obj.bind("measure", () => logger3.time.debug(`Extracted ${file}`)),
2452
+ tap(() => logger4.debug("file:extract", file)),
2453
+ Obj.bind("measure", () => logger4.time.debug(`Extracted ${file}`)),
2339
2454
  Obj.bind(
2340
2455
  "result",
2341
2456
  tryCatch(
2342
2457
  ({ file: file2 }) => ctx.project.parseSourceFile(file2),
2343
- (error) => logger3.error("file:parse", error)
2458
+ (error) => logger4.error("file:parse", error)
2344
2459
  )
2345
2460
  ),
2346
- Obj.bind("measureCss", () => logger3.time.debug(`Parsed ${file}`)),
2461
+ Obj.bind("measureCss", () => logger4.time.debug(`Parsed ${file}`)),
2347
2462
  Obj.bind("css", ({ result }) => result ? ctx.getParserCss(result) : void 0),
2348
2463
  tap(({ measure, measureCss }) => [measureCss(), measure()]),
2349
2464
  Obj.get("css")
@@ -2354,10 +2469,12 @@ function writeChunks(ctx) {
2354
2469
  }
2355
2470
  var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
2356
2471
  var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
2472
+ var limit = pLimit(20);
2357
2473
  async function emitArtifacts(ctx) {
2358
2474
  if (ctx.config.clean)
2359
2475
  ctx.output.empty();
2360
- await Promise.allSettled(ctx.getArtifacts().map(ctx.output.write));
2476
+ const promises = ctx.getArtifacts().map((artifact) => limit(() => ctx.output.write(artifact)));
2477
+ await Promise.allSettled(promises);
2361
2478
  void ctx.hooks.callHook("generator:done");
2362
2479
  return {
2363
2480
  box: createBox({
@@ -2390,7 +2507,7 @@ async function bundleMinimalFilesCss(ctx, outfile) {
2390
2507
  const filesWithCss = [];
2391
2508
  const collector = createParserResult();
2392
2509
  files.forEach((file) => {
2393
- const measure = logger3.time.debug(`Parsed ${file}`);
2510
+ const measure = logger4.time.debug(`Parsed ${file}`);
2394
2511
  const result = ctx.project.parseSourceFile(file);
2395
2512
  measure();
2396
2513
  if (!result)
@@ -2466,12 +2583,13 @@ function parseDependency(fileOrGlob) {
2466
2583
  // src/builder.ts
2467
2584
  var configCache = /* @__PURE__ */ new Map();
2468
2585
  var contentFilesCache = /* @__PURE__ */ new WeakMap();
2469
- var setupCount = 0;
2586
+ var limit2 = pLimit(20);
2470
2587
  var Builder = class {
2471
2588
  /**
2472
2589
  * The current panda context
2473
2590
  */
2474
2591
  context;
2592
+ hasEmitted = false;
2475
2593
  configDependencies = /* @__PURE__ */ new Set();
2476
2594
  writeFileCss = (file, css) => {
2477
2595
  const oldCss = this.fileCssMap?.get(file) ?? "";
@@ -2498,9 +2616,6 @@ var Builder = class {
2498
2616
  for (const file of deps) {
2499
2617
  delete __require.cache[file];
2500
2618
  }
2501
- if (setupCount > 0) {
2502
- logger4.debug("builder", "\u2699\uFE0F Config changed, reloading");
2503
- }
2504
2619
  return { isModified: true, modifiedMap: newModified };
2505
2620
  };
2506
2621
  getConfigPath = () => {
@@ -2510,8 +2625,9 @@ var Builder = class {
2510
2625
  }
2511
2626
  return configPath;
2512
2627
  };
2628
+ hasConfigChanged = false;
2513
2629
  setup = async (options = {}) => {
2514
- logger4.debug("builder", "\u{1F6A7} Setup");
2630
+ logger5.debug("builder", "\u{1F6A7} Setup");
2515
2631
  const configPath = options.configPath ?? this.getConfigPath();
2516
2632
  const tsOptions = this.context?.tsOptions ?? { baseUrl: void 0, pathMappings: [] };
2517
2633
  const compilerOptions = this.context?.tsconfig?.compilerOptions ?? {};
@@ -2520,12 +2636,14 @@ var Builder = class {
2520
2636
  const configDeps = /* @__PURE__ */ new Set([...foundDeps, ...(this.context?.dependencies ?? []).map((file) => resolve2(cwd, file))]);
2521
2637
  this.configDependencies = configDeps;
2522
2638
  const deps = this.checkConfigDeps(configPath, configDeps);
2639
+ this.hasConfigChanged = deps.isModified;
2523
2640
  if (deps.isModified) {
2524
2641
  await this.setupContext({
2525
2642
  configPath,
2526
2643
  depsModifiedMap: deps.modifiedMap
2527
2644
  });
2528
- const ctx = this.context;
2645
+ const ctx = this.getContextOrThrow();
2646
+ logger5.debug("builder", "\u2699\uFE0F Config changed, reloading");
2529
2647
  await ctx.hooks.callHook("config:change", ctx.config);
2530
2648
  }
2531
2649
  const cache = configCache.get(configPath);
@@ -2538,14 +2656,16 @@ var Builder = class {
2538
2656
  depsModifiedMap: deps.modifiedMap
2539
2657
  });
2540
2658
  }
2541
- setupCount++;
2542
2659
  };
2660
+ emit() {
2661
+ if (this.hasEmitted && this.hasConfigChanged) {
2662
+ emitArtifacts(this.getContextOrThrow());
2663
+ }
2664
+ this.hasEmitted = true;
2665
+ }
2543
2666
  setupContext = async (options) => {
2544
2667
  const { configPath, depsModifiedMap } = options;
2545
2668
  this.context = await loadConfigAndCreateContext({ configPath });
2546
- if (setupCount > 0) {
2547
- emitArtifacts(this.context);
2548
- }
2549
2669
  configCache.set(configPath, {
2550
2670
  context: this.context,
2551
2671
  deps: new Set(this.context.dependencies ?? []),
@@ -2584,8 +2704,9 @@ var Builder = class {
2584
2704
  };
2585
2705
  extract = async () => {
2586
2706
  const ctx = this.getContextOrThrow();
2587
- const done = logger4.time.info("Extracted in");
2588
- await Promise.allSettled(ctx.getFiles().map((file) => this.extractFile(ctx, file)));
2707
+ const done = logger5.time.info("Extracted in");
2708
+ const promises = ctx.getFiles().map((file) => limit2(() => this.extractFile(ctx, file)));
2709
+ await Promise.allSettled(promises);
2589
2710
  done();
2590
2711
  };
2591
2712
  toString = () => {
@@ -2634,24 +2755,24 @@ var Builder = class {
2634
2755
 
2635
2756
  // src/debug-files.ts
2636
2757
  init_esm_shims();
2637
- import { colors, logger as logger5 } from "@pandacss/logger";
2758
+ import { colors, logger as logger6 } from "@pandacss/logger";
2638
2759
  import * as nodePath from "path";
2639
2760
  async function debugFiles(ctx, options) {
2640
2761
  const files = ctx.getFiles();
2641
- const measureTotal = logger5.time.debug(`Done parsing ${files.length} files`);
2762
+ const measureTotal = logger6.time.debug(`Done parsing ${files.length} files`);
2642
2763
  ctx.config.minify = false;
2643
2764
  ctx.config.optimize = true;
2644
2765
  const { fs, path: path2 } = ctx.runtime;
2645
2766
  const outdir = options.outdir;
2646
2767
  if (!options.dry && outdir) {
2647
2768
  fs.ensureDirSync(outdir);
2648
- logger5.info("cli", `Writing ${colors.bold(`${outdir}/config.json`)}`);
2769
+ logger6.info("cli", `Writing ${colors.bold(`${outdir}/config.json`)}`);
2649
2770
  await fs.writeFile(`${outdir}/config.json`, JSON.stringify(ctx.config, null, 2));
2650
2771
  }
2651
2772
  const filesWithCss = [];
2652
2773
  await Promise.allSettled(
2653
2774
  files.map(async (file) => {
2654
- const measure = logger5.time.debug(`Parsed ${file}`);
2775
+ const measure = logger6.time.debug(`Parsed ${file}`);
2655
2776
  const result = ctx.project.parseSourceFile(file);
2656
2777
  measure();
2657
2778
  if (!result)
@@ -2669,8 +2790,8 @@ async function debugFiles(ctx, options) {
2669
2790
  const relative3 = path2.relative(ctx.config.cwd, parsedPath.dir);
2670
2791
  const astJsonPath = `${relative3}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
2671
2792
  const cssPath = `${relative3}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
2672
- logger5.info("cli", `Writing ${colors.bold(`${outdir}/${astJsonPath}`)}`);
2673
- logger5.info("cli", `Writing ${colors.bold(`${outdir}/${cssPath}`)}`);
2793
+ logger6.info("cli", `Writing ${colors.bold(`${outdir}/${astJsonPath}`)}`);
2794
+ logger6.info("cli", `Writing ${colors.bold(`${outdir}/${cssPath}`)}`);
2674
2795
  return Promise.allSettled([
2675
2796
  fs.writeFile(`${outdir}/${astJsonPath}`, JSON.stringify(result.toJSON(), null, 2)),
2676
2797
  fs.writeFile(`${outdir}/${cssPath}`, css)
@@ -2678,13 +2799,13 @@ async function debugFiles(ctx, options) {
2678
2799
  }
2679
2800
  })
2680
2801
  );
2681
- logger5.info("cli", `Found ${colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2802
+ logger6.info("cli", `Found ${colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2682
2803
  measureTotal();
2683
2804
  }
2684
2805
 
2685
2806
  // src/exec-command.ts
2686
2807
  init_esm_shims();
2687
- import { logger as logger6 } from "@pandacss/logger";
2808
+ import { logger as logger7 } from "@pandacss/logger";
2688
2809
  import { spawnSync } from "child_process";
2689
2810
  import getPackageManager from "preferred-pm";
2690
2811
  async function execCommand(cmd, cwd) {
@@ -2696,13 +2817,13 @@ async function execCommand(cmd, cwd) {
2696
2817
  }
2697
2818
  const check = spawnSync(pm, args, { cwd, stdio: "pipe" });
2698
2819
  if (check.status !== 0) {
2699
- logger6.error("exec", check.stderr.toString());
2820
+ logger7.error("exec", check.stderr.toString());
2700
2821
  }
2701
2822
  }
2702
2823
 
2703
2824
  // src/generate.ts
2704
2825
  init_esm_shims();
2705
- import { logger as logger7 } from "@pandacss/logger";
2826
+ import { logger as logger8 } from "@pandacss/logger";
2706
2827
  import { match as match2 } from "ts-pattern";
2707
2828
 
2708
2829
  // src/load-context.ts
@@ -2720,7 +2841,7 @@ var loadContext = async (config, configPath) => {
2720
2841
  // src/generate.ts
2721
2842
  async function build(ctx) {
2722
2843
  const { msg } = await emitArtfifactsAndCssChunks(ctx);
2723
- logger7.info("css:emit", msg);
2844
+ logger8.info("css:emit", msg);
2724
2845
  }
2725
2846
  async function generate(config, configPath) {
2726
2847
  const [ctxRef, loadCtx] = await loadContext(config, configPath);
@@ -2734,14 +2855,14 @@ async function generate(config, configPath) {
2734
2855
  if (ctx.config.watch) {
2735
2856
  const configWatcher = fs.watch({ include: dependencies });
2736
2857
  configWatcher.on("change", async () => {
2737
- logger7.info("config:change", "Config changed, restarting...");
2858
+ logger8.info("config:change", "Config changed, restarting...");
2738
2859
  await loadCtx();
2739
2860
  await ctxRef.current.hooks.callHook("config:change", ctxRef.current.config);
2740
2861
  return build(ctxRef.current);
2741
2862
  });
2742
2863
  const contentWatcher = fs.watch(ctx.config);
2743
2864
  contentWatcher.on("all", async (event, file) => {
2744
- logger7.info(`file:${event}`, file);
2865
+ logger8.info(`file:${event}`, file);
2745
2866
  match2(event).with("unlink", () => {
2746
2867
  ctx.project.removeSourceFile(path2.abs(cwd, file));
2747
2868
  ctx.chunks.rm(file);
@@ -2755,7 +2876,7 @@ async function generate(config, configPath) {
2755
2876
  }).otherwise(() => {
2756
2877
  });
2757
2878
  });
2758
- logger7.info("ctx:watch", ctx.messages.watch());
2879
+ logger8.info("ctx:watch", ctx.messages.watch());
2759
2880
  }
2760
2881
  }
2761
2882
 
@@ -2787,7 +2908,7 @@ function setupGitIgnore(ctx) {
2787
2908
  // src/setup-config.ts
2788
2909
  init_esm_shims();
2789
2910
  import { messages } from "@pandacss/generator";
2790
- import { logger as logger8, quote } from "@pandacss/logger";
2911
+ import { logger as logger9, quote } from "@pandacss/logger";
2791
2912
  import { writeFile as writeFile4 } from "fs-extra";
2792
2913
  import { lookItUpSync as lookItUpSync3 } from "look-it-up";
2793
2914
  import { outdent as outdent2 } from "outdent";
@@ -2801,9 +2922,9 @@ async function setupConfig(cwd, opts = {}) {
2801
2922
  const cmd = pm === "npm" ? "npm run" : pm;
2802
2923
  const isTs = lookItUpSync3("tsconfig.json", cwd);
2803
2924
  const file = isTs ? "panda.config.ts" : "panda.config.mjs";
2804
- logger8.info("init:config", `creating panda config file: ${quote(file)}`);
2925
+ logger9.info("init:config", `creating panda config file: ${quote(file)}`);
2805
2926
  if (!force && configFile) {
2806
- logger8.warn("init:config", messages.configExists(cmd));
2927
+ logger9.warn("init:config", messages.configExists(cmd));
2807
2928
  } else {
2808
2929
  const content = outdent2`
2809
2930
  import { defineConfig } from "@pandacss/dev"
@@ -2836,11 +2957,11 @@ syntax: '${syntax}'` : ""}
2836
2957
  })
2837
2958
  `;
2838
2959
  await writeFile4(join2(cwd, file), content);
2839
- logger8.log(messages.thankYou());
2960
+ logger9.log(messages.thankYou());
2840
2961
  }
2841
2962
  }
2842
2963
  async function setupPostcss(cwd) {
2843
- logger8.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
2964
+ logger9.info("init:postcss", `creating postcss config file: ${quote("postcss.config.cjs")}`);
2844
2965
  const content = outdent2`
2845
2966
  module.exports = {
2846
2967
  plugins: {
@@ -2853,7 +2974,7 @@ module.exports = {
2853
2974
 
2854
2975
  // src/ship-files.ts
2855
2976
  init_esm_shims();
2856
- import { colors as colors2, logger as logger9 } from "@pandacss/logger";
2977
+ import { colors as colors2, logger as logger10 } from "@pandacss/logger";
2857
2978
  import { createParserResult as createParserResult2 } from "@pandacss/parser";
2858
2979
  import { writeFile as writeFile5 } from "fs/promises";
2859
2980
  import * as path from "path";
@@ -2871,12 +2992,12 @@ async function shipFiles(ctx, outfile) {
2871
2992
  extractResult.merge(result);
2872
2993
  filesWithCss.push(path.relative(ctx.config.cwd, file));
2873
2994
  });
2874
- logger9.info("cli", `Found ${colors2.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2995
+ logger10.info("cli", `Found ${colors2.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2875
2996
  const minify = ctx.config.minify;
2876
- logger9.info("cli", `Writing ${minify ? "[min] " : " "}${colors2.bold(outfile)}`);
2997
+ logger10.info("cli", `Writing ${minify ? "[min] " : " "}${colors2.bold(outfile)}`);
2877
2998
  const output = JSON.stringify(extractResult.toJSON(), null, minify ? 0 : 2);
2878
2999
  await writeFile5(outfile, output);
2879
- logger9.info("cli", "Done!");
3000
+ logger10.info("cli", "Done!");
2880
3001
  }
2881
3002
  export {
2882
3003
  Builder,
package/package.json CHANGED
@@ -1,11 +1,23 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.16.0",
3
+ "version": "0.17.1",
4
4
  "description": "The core css panda library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "author": "Segun Adebayo <joseshegs@gmail.com>",
9
+ "exports": {
10
+ ".": {
11
+ "source": "./src/index.ts",
12
+ "types": "./dist/index.d.ts",
13
+ "require": "./dist/index.js",
14
+ "import": {
15
+ "types": "./dist/index.d.mts",
16
+ "default": "./dist/index.mjs"
17
+ }
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
9
21
  "files": [
10
22
  "dist"
11
23
  ],
@@ -29,31 +41,32 @@
29
41
  "pathe": "^1.1.1",
30
42
  "pkg-types": "1.0.3",
31
43
  "pluralize": "8.0.0",
32
- "postcss": "8.4.27",
44
+ "postcss": "^8.4.31",
33
45
  "preferred-pm": "^3.0.3",
34
46
  "ts-morph": "19.0.0",
35
47
  "ts-pattern": "5.0.5",
36
48
  "tsconfck": "^2.1.2",
37
- "@pandacss/config": "0.16.0",
38
- "@pandacss/core": "0.16.0",
39
- "@pandacss/error": "0.16.0",
40
- "@pandacss/extractor": "0.16.0",
41
- "@pandacss/generator": "0.16.0",
42
- "@pandacss/is-valid-prop": "0.16.0",
43
- "@pandacss/logger": "0.16.0",
44
- "@pandacss/parser": "0.16.0",
45
- "@pandacss/shared": "0.16.0",
46
- "@pandacss/token-dictionary": "0.16.0",
47
- "@pandacss/types": "0.16.0"
49
+ "@pandacss/error": "0.17.1",
50
+ "@pandacss/is-valid-prop": "0.17.1",
51
+ "@pandacss/core": "0.17.1",
52
+ "@pandacss/extractor": "0.17.1",
53
+ "@pandacss/logger": "0.17.1",
54
+ "@pandacss/shared": "0.17.1",
55
+ "@pandacss/parser": "0.17.1",
56
+ "@pandacss/token-dictionary": "0.17.1",
57
+ "@pandacss/types": "0.17.1",
58
+ "@pandacss/generator": "0.17.1",
59
+ "@pandacss/config": "0.17.1"
48
60
  },
49
61
  "devDependencies": {
50
- "@types/fs-extra": "11.0.2",
62
+ "@types/fs-extra": "11.0.3",
51
63
  "@types/glob-parent": "^5.1.1",
52
64
  "@types/is-glob": "^4.0.2",
53
- "@types/lodash.merge": "4.6.7",
65
+ "@types/lodash.merge": "4.6.8",
54
66
  "@types/pluralize": "0.0.30",
55
67
  "boxen": "^7.1.1",
56
- "@pandacss/fixture": "0.16.0"
68
+ "p-limit": "^4.0.0",
69
+ "@pandacss/fixture": "0.17.1"
57
70
  },
58
71
  "scripts": {
59
72
  "build": "tsup src/index.ts --format=cjs,esm --shims --dts",