@pandacss/node 0.17.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
@@ -787,6 +787,113 @@ 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
@@ -941,7 +1049,6 @@ var getOutputEngine = ({
941
1049
  });
942
1050
 
943
1051
  // src/create-context.ts
944
- var import_logger3 = require("@pandacss/logger");
945
1052
  var createContext = (conf) => {
946
1053
  const generator = (0, import_generator.createGenerator)(conf);
947
1054
  const config = conf.config;
@@ -981,7 +1088,8 @@ function findConfig() {
981
1088
  }
982
1089
  async function loadConfigAndCreateContext(options = {}) {
983
1090
  const hooks = (0, import_hookable.createHooks)();
984
- const { cwd = process.cwd(), config, configPath } = options;
1091
+ const { config, configPath } = options;
1092
+ const cwd = options.cwd ?? options?.config?.cwd ?? process.cwd();
985
1093
  const conf = await (0, import_config.loadConfigFile)({ cwd, file: configPath });
986
1094
  if (config) {
987
1095
  Object.assign(conf.config, config);
@@ -1012,8 +1120,12 @@ async function loadConfigAndCreateContext(options = {}) {
1012
1120
 
1013
1121
  // src/extract.ts
1014
1122
  init_cjs_shims();
1123
+ var import_core2 = require("@pandacss/core");
1015
1124
  var import_logger4 = require("@pandacss/logger");
1125
+ var import_parser2 = require("@pandacss/parser");
1126
+ var import_promises2 = require("fs/promises");
1016
1127
  var import_lil_fp = require("lil-fp");
1128
+ var import_ts_pattern = require("ts-pattern");
1017
1129
 
1018
1130
  // src/cli-box.ts
1019
1131
  init_cjs_shims();
@@ -2328,10 +2440,6 @@ var createBox = (options) => boxen(options.content, {
2328
2440
  });
2329
2441
 
2330
2442
  // src/extract.ts
2331
- var import_promises2 = require("fs/promises");
2332
- var import_parser2 = require("@pandacss/parser");
2333
- var import_ts_pattern = require("ts-pattern");
2334
- var import_core2 = require("@pandacss/core");
2335
2443
  async function bundleStyleChunksWithImports(ctx) {
2336
2444
  const files = ctx.chunks.getFiles();
2337
2445
  await ctx.output.write({
@@ -2376,10 +2484,12 @@ function writeChunks(ctx) {
2376
2484
  }
2377
2485
  var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
2378
2486
  var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
2487
+ var limit = pLimit(20);
2379
2488
  async function emitArtifacts(ctx) {
2380
2489
  if (ctx.config.clean)
2381
2490
  ctx.output.empty();
2382
- 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);
2383
2493
  void ctx.hooks.callHook("generator:done");
2384
2494
  return {
2385
2495
  box: createBox({
@@ -2488,12 +2598,13 @@ function parseDependency(fileOrGlob) {
2488
2598
  // src/builder.ts
2489
2599
  var configCache = /* @__PURE__ */ new Map();
2490
2600
  var contentFilesCache = /* @__PURE__ */ new WeakMap();
2491
- var setupCount = 0;
2601
+ var limit2 = pLimit(20);
2492
2602
  var Builder = class {
2493
2603
  /**
2494
2604
  * The current panda context
2495
2605
  */
2496
2606
  context;
2607
+ hasEmitted = false;
2497
2608
  configDependencies = /* @__PURE__ */ new Set();
2498
2609
  writeFileCss = (file, css) => {
2499
2610
  const oldCss = this.fileCssMap?.get(file) ?? "";
@@ -2520,9 +2631,6 @@ var Builder = class {
2520
2631
  for (const file of deps) {
2521
2632
  delete require.cache[file];
2522
2633
  }
2523
- if (setupCount > 0) {
2524
- import_logger5.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
2525
- }
2526
2634
  return { isModified: true, modifiedMap: newModified };
2527
2635
  };
2528
2636
  getConfigPath = () => {
@@ -2532,6 +2640,7 @@ var Builder = class {
2532
2640
  }
2533
2641
  return configPath;
2534
2642
  };
2643
+ hasConfigChanged = false;
2535
2644
  setup = async (options = {}) => {
2536
2645
  import_logger5.logger.debug("builder", "\u{1F6A7} Setup");
2537
2646
  const configPath = options.configPath ?? this.getConfigPath();
@@ -2542,12 +2651,14 @@ var Builder = class {
2542
2651
  const configDeps = /* @__PURE__ */ new Set([...foundDeps, ...(this.context?.dependencies ?? []).map((file) => (0, import_path2.resolve)(cwd, file))]);
2543
2652
  this.configDependencies = configDeps;
2544
2653
  const deps = this.checkConfigDeps(configPath, configDeps);
2654
+ this.hasConfigChanged = deps.isModified;
2545
2655
  if (deps.isModified) {
2546
2656
  await this.setupContext({
2547
2657
  configPath,
2548
2658
  depsModifiedMap: deps.modifiedMap
2549
2659
  });
2550
- const ctx = this.context;
2660
+ const ctx = this.getContextOrThrow();
2661
+ import_logger5.logger.debug("builder", "\u2699\uFE0F Config changed, reloading");
2551
2662
  await ctx.hooks.callHook("config:change", ctx.config);
2552
2663
  }
2553
2664
  const cache = configCache.get(configPath);
@@ -2560,14 +2671,16 @@ var Builder = class {
2560
2671
  depsModifiedMap: deps.modifiedMap
2561
2672
  });
2562
2673
  }
2563
- setupCount++;
2564
2674
  };
2675
+ emit() {
2676
+ if (this.hasEmitted && this.hasConfigChanged) {
2677
+ emitArtifacts(this.getContextOrThrow());
2678
+ }
2679
+ this.hasEmitted = true;
2680
+ }
2565
2681
  setupContext = async (options) => {
2566
2682
  const { configPath, depsModifiedMap } = options;
2567
2683
  this.context = await loadConfigAndCreateContext({ configPath });
2568
- if (setupCount > 0) {
2569
- emitArtifacts(this.context);
2570
- }
2571
2684
  configCache.set(configPath, {
2572
2685
  context: this.context,
2573
2686
  deps: new Set(this.context.dependencies ?? []),
@@ -2607,7 +2720,8 @@ var Builder = class {
2607
2720
  extract = async () => {
2608
2721
  const ctx = this.getContextOrThrow();
2609
2722
  const done = import_logger5.logger.time.info("Extracted in");
2610
- await Promise.allSettled(ctx.getFiles().map((file) => this.extractFile(ctx, file)));
2723
+ const promises = ctx.getFiles().map((file) => limit2(() => this.extractFile(ctx, file)));
2724
+ await Promise.allSettled(promises);
2611
2725
  done();
2612
2726
  };
2613
2727
  toString = () => {
package/dist/index.mjs CHANGED
@@ -763,6 +763,113 @@ 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
@@ -926,7 +1034,6 @@ var getOutputEngine = ({
926
1034
  });
927
1035
 
928
1036
  // src/create-context.ts
929
- import { logger as logger3 } from "@pandacss/logger";
930
1037
  var createContext = (conf) => {
931
1038
  const generator = createGenerator(conf);
932
1039
  const config = conf.config;
@@ -966,7 +1073,8 @@ function findConfig() {
966
1073
  }
967
1074
  async function loadConfigAndCreateContext(options = {}) {
968
1075
  const hooks = createHooks();
969
- const { cwd = process.cwd(), config, configPath } = options;
1076
+ const { config, configPath } = options;
1077
+ const cwd = options.cwd ?? options?.config?.cwd ?? process.cwd();
970
1078
  const conf = await loadConfigFile({ cwd, file: configPath });
971
1079
  if (config) {
972
1080
  Object.assign(conf.config, config);
@@ -997,8 +1105,12 @@ async function loadConfigAndCreateContext(options = {}) {
997
1105
 
998
1106
  // src/extract.ts
999
1107
  init_esm_shims();
1108
+ import { optimizeCss } from "@pandacss/core";
1000
1109
  import { logger as logger4 } from "@pandacss/logger";
1110
+ import { createParserResult } from "@pandacss/parser";
1111
+ import { writeFile as writeFile3 } from "fs/promises";
1001
1112
  import { Obj, pipe, tap, tryCatch } from "lil-fp";
1113
+ import { match } from "ts-pattern";
1002
1114
 
1003
1115
  // src/cli-box.ts
1004
1116
  init_esm_shims();
@@ -2313,10 +2425,6 @@ var createBox = (options) => boxen(options.content, {
2313
2425
  });
2314
2426
 
2315
2427
  // src/extract.ts
2316
- import { writeFile as writeFile3 } from "fs/promises";
2317
- import { createParserResult } from "@pandacss/parser";
2318
- import { match } from "ts-pattern";
2319
- import { optimizeCss } from "@pandacss/core";
2320
2428
  async function bundleStyleChunksWithImports(ctx) {
2321
2429
  const files = ctx.chunks.getFiles();
2322
2430
  await ctx.output.write({
@@ -2361,10 +2469,12 @@ function writeChunks(ctx) {
2361
2469
  }
2362
2470
  var randomWords = ["Sweet", "Divine", "Pandalicious", "Super"];
2363
2471
  var pickRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
2472
+ var limit = pLimit(20);
2364
2473
  async function emitArtifacts(ctx) {
2365
2474
  if (ctx.config.clean)
2366
2475
  ctx.output.empty();
2367
- 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);
2368
2478
  void ctx.hooks.callHook("generator:done");
2369
2479
  return {
2370
2480
  box: createBox({
@@ -2473,12 +2583,13 @@ function parseDependency(fileOrGlob) {
2473
2583
  // src/builder.ts
2474
2584
  var configCache = /* @__PURE__ */ new Map();
2475
2585
  var contentFilesCache = /* @__PURE__ */ new WeakMap();
2476
- var setupCount = 0;
2586
+ var limit2 = pLimit(20);
2477
2587
  var Builder = class {
2478
2588
  /**
2479
2589
  * The current panda context
2480
2590
  */
2481
2591
  context;
2592
+ hasEmitted = false;
2482
2593
  configDependencies = /* @__PURE__ */ new Set();
2483
2594
  writeFileCss = (file, css) => {
2484
2595
  const oldCss = this.fileCssMap?.get(file) ?? "";
@@ -2505,9 +2616,6 @@ var Builder = class {
2505
2616
  for (const file of deps) {
2506
2617
  delete __require.cache[file];
2507
2618
  }
2508
- if (setupCount > 0) {
2509
- logger5.debug("builder", "\u2699\uFE0F Config changed, reloading");
2510
- }
2511
2619
  return { isModified: true, modifiedMap: newModified };
2512
2620
  };
2513
2621
  getConfigPath = () => {
@@ -2517,6 +2625,7 @@ var Builder = class {
2517
2625
  }
2518
2626
  return configPath;
2519
2627
  };
2628
+ hasConfigChanged = false;
2520
2629
  setup = async (options = {}) => {
2521
2630
  logger5.debug("builder", "\u{1F6A7} Setup");
2522
2631
  const configPath = options.configPath ?? this.getConfigPath();
@@ -2527,12 +2636,14 @@ var Builder = class {
2527
2636
  const configDeps = /* @__PURE__ */ new Set([...foundDeps, ...(this.context?.dependencies ?? []).map((file) => resolve2(cwd, file))]);
2528
2637
  this.configDependencies = configDeps;
2529
2638
  const deps = this.checkConfigDeps(configPath, configDeps);
2639
+ this.hasConfigChanged = deps.isModified;
2530
2640
  if (deps.isModified) {
2531
2641
  await this.setupContext({
2532
2642
  configPath,
2533
2643
  depsModifiedMap: deps.modifiedMap
2534
2644
  });
2535
- const ctx = this.context;
2645
+ const ctx = this.getContextOrThrow();
2646
+ logger5.debug("builder", "\u2699\uFE0F Config changed, reloading");
2536
2647
  await ctx.hooks.callHook("config:change", ctx.config);
2537
2648
  }
2538
2649
  const cache = configCache.get(configPath);
@@ -2545,14 +2656,16 @@ var Builder = class {
2545
2656
  depsModifiedMap: deps.modifiedMap
2546
2657
  });
2547
2658
  }
2548
- setupCount++;
2549
2659
  };
2660
+ emit() {
2661
+ if (this.hasEmitted && this.hasConfigChanged) {
2662
+ emitArtifacts(this.getContextOrThrow());
2663
+ }
2664
+ this.hasEmitted = true;
2665
+ }
2550
2666
  setupContext = async (options) => {
2551
2667
  const { configPath, depsModifiedMap } = options;
2552
2668
  this.context = await loadConfigAndCreateContext({ configPath });
2553
- if (setupCount > 0) {
2554
- emitArtifacts(this.context);
2555
- }
2556
2669
  configCache.set(configPath, {
2557
2670
  context: this.context,
2558
2671
  deps: new Set(this.context.dependencies ?? []),
@@ -2592,7 +2705,8 @@ var Builder = class {
2592
2705
  extract = async () => {
2593
2706
  const ctx = this.getContextOrThrow();
2594
2707
  const done = logger5.time.info("Extracted in");
2595
- await Promise.allSettled(ctx.getFiles().map((file) => this.extractFile(ctx, file)));
2708
+ const promises = ctx.getFiles().map((file) => limit2(() => this.extractFile(ctx, file)));
2709
+ await Promise.allSettled(promises);
2596
2710
  done();
2597
2711
  };
2598
2712
  toString = () => {
package/package.json CHANGED
@@ -1,11 +1,23 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.17.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
  ],
@@ -34,26 +46,27 @@
34
46
  "ts-morph": "19.0.0",
35
47
  "ts-pattern": "5.0.5",
36
48
  "tsconfck": "^2.1.2",
37
- "@pandacss/config": "0.17.0",
38
- "@pandacss/core": "0.17.0",
39
- "@pandacss/error": "0.17.0",
40
- "@pandacss/extractor": "0.17.0",
41
- "@pandacss/generator": "0.17.0",
42
- "@pandacss/is-valid-prop": "0.17.0",
43
- "@pandacss/logger": "0.17.0",
44
- "@pandacss/parser": "0.17.0",
45
- "@pandacss/shared": "0.17.0",
46
- "@pandacss/token-dictionary": "0.17.0",
47
- "@pandacss/types": "0.17.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.17.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",