@pandacss/config 0.42.0 → 0.44.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.
@@ -1,5 +1,5 @@
1
1
  // src/merge-config.ts
2
- import { assign, mergeWith, walkObject } from "@pandacss/shared";
2
+ import { PANDA_CONFIG_NAME, assign, mergeWith, walkObject } from "@pandacss/shared";
3
3
  import { mergeAndConcat } from "merge-anything";
4
4
 
5
5
  // src/merge-hooks.ts
@@ -188,24 +188,26 @@ var compact = (obj) => {
188
188
  };
189
189
  var tokenKeys = ["description", "extensions", "type", "value", "deprecated"];
190
190
  function mergeConfigs(configs) {
191
- const [userConfig] = configs;
191
+ const userConfig = configs.at(-1);
192
192
  const pluginHooks = userConfig.plugins ?? [];
193
193
  if (userConfig.hooks) {
194
- pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks });
194
+ pluginHooks.push({ name: PANDA_CONFIG_NAME, hooks: userConfig.hooks });
195
195
  }
196
+ const reversed = Array.from(configs).reverse();
196
197
  const mergedResult = assign(
197
198
  {
198
- conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})),
199
- theme: mergeExtensions(configs.map((config) => config.theme ?? {})),
200
- patterns: mergeExtensions(configs.map((config) => config.patterns ?? {})),
201
- utilities: mergeExtensions(configs.map((config) => config.utilities ?? {})),
202
- globalCss: mergeExtensions(configs.map((config) => config.globalCss ?? {})),
203
- globalVars: mergeExtensions(configs.map((config) => config.globalVars ?? {})),
204
- staticCss: mergeExtensions(configs.map((config) => config.staticCss ?? {})),
205
- themes: mergeExtensions(configs.map((config) => config.themes ?? {})),
199
+ conditions: mergeExtensions(reversed.map((config) => config.conditions ?? {})),
200
+ theme: mergeExtensions(reversed.map((config) => config.theme ?? {})),
201
+ patterns: mergeExtensions(reversed.map((config) => config.patterns ?? {})),
202
+ utilities: mergeExtensions(reversed.map((config) => config.utilities ?? {})),
203
+ globalCss: mergeExtensions(reversed.map((config) => config.globalCss ?? {})),
204
+ globalVars: mergeExtensions(reversed.map((config) => config.globalVars ?? {})),
205
+ globalFontface: mergeExtensions(reversed.map((config) => config.globalFontface ?? {})),
206
+ staticCss: mergeExtensions(reversed.map((config) => config.staticCss ?? {})),
207
+ themes: mergeExtensions(reversed.map((config) => config.themes ?? {})),
206
208
  hooks: mergeHooks(pluginHooks)
207
209
  },
208
- ...configs
210
+ ...reversed
209
211
  );
210
212
  const withoutEmpty = compact(mergedResult);
211
213
  if (withoutEmpty.theme?.tokens) {
package/dist/index.d.mts CHANGED
@@ -40,9 +40,9 @@ type Extendable<T> = T & {
40
40
  };
41
41
  type ExtendableConfig = Extendable<Config>;
42
42
  /**
43
- * Recursively merge all presets into a single config
43
+ * Recursively merge all presets into a single config (depth-first using stack)
44
44
  */
45
- declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<_pandacss_types.UserConfig>;
45
+ declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
46
46
 
47
47
  /**
48
48
  * Find, load and resolve the final config (including presets)
package/dist/index.d.ts CHANGED
@@ -40,9 +40,9 @@ type Extendable<T> = T & {
40
40
  };
41
41
  type ExtendableConfig = Extendable<Config>;
42
42
  /**
43
- * Recursively merge all presets into a single config
43
+ * Recursively merge all presets into a single config (depth-first using stack)
44
44
  */
45
- declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<_pandacss_types.UserConfig>;
45
+ declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
46
46
 
47
47
  /**
48
48
  * Find, load and resolve the final config (including presets)
package/dist/index.js CHANGED
@@ -577,24 +577,26 @@ var compact = (obj) => {
577
577
  };
578
578
  var tokenKeys = ["description", "extensions", "type", "value", "deprecated"];
579
579
  function mergeConfigs(configs) {
580
- const [userConfig] = configs;
580
+ const userConfig = configs.at(-1);
581
581
  const pluginHooks = userConfig.plugins ?? [];
582
582
  if (userConfig.hooks) {
583
- pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks });
583
+ pluginHooks.push({ name: import_shared5.PANDA_CONFIG_NAME, hooks: userConfig.hooks });
584
584
  }
585
+ const reversed = Array.from(configs).reverse();
585
586
  const mergedResult = (0, import_shared5.assign)(
586
587
  {
587
- conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})),
588
- theme: mergeExtensions(configs.map((config) => config.theme ?? {})),
589
- patterns: mergeExtensions(configs.map((config) => config.patterns ?? {})),
590
- utilities: mergeExtensions(configs.map((config) => config.utilities ?? {})),
591
- globalCss: mergeExtensions(configs.map((config) => config.globalCss ?? {})),
592
- globalVars: mergeExtensions(configs.map((config) => config.globalVars ?? {})),
593
- staticCss: mergeExtensions(configs.map((config) => config.staticCss ?? {})),
594
- themes: mergeExtensions(configs.map((config) => config.themes ?? {})),
588
+ conditions: mergeExtensions(reversed.map((config) => config.conditions ?? {})),
589
+ theme: mergeExtensions(reversed.map((config) => config.theme ?? {})),
590
+ patterns: mergeExtensions(reversed.map((config) => config.patterns ?? {})),
591
+ utilities: mergeExtensions(reversed.map((config) => config.utilities ?? {})),
592
+ globalCss: mergeExtensions(reversed.map((config) => config.globalCss ?? {})),
593
+ globalVars: mergeExtensions(reversed.map((config) => config.globalVars ?? {})),
594
+ globalFontface: mergeExtensions(reversed.map((config) => config.globalFontface ?? {})),
595
+ staticCss: mergeExtensions(reversed.map((config) => config.staticCss ?? {})),
596
+ themes: mergeExtensions(reversed.map((config) => config.themes ?? {})),
595
597
  hooks: mergeHooks(pluginHooks)
596
598
  },
597
- ...configs
599
+ ...reversed
598
600
  );
599
601
  const withoutEmpty = compact(mergedResult);
600
602
  if (withoutEmpty.theme?.tokens) {
@@ -623,21 +625,24 @@ function mergeConfigs(configs) {
623
625
 
624
626
  // src/get-resolved-config.ts
625
627
  async function getResolvedConfig(config, cwd) {
626
- const presets = config.presets ?? [];
628
+ const stack = [config];
627
629
  const configs = [];
628
- while (presets.length > 0) {
629
- const preset = await presets.shift();
630
- if (typeof preset === "string") {
631
- const presetModule = await bundle(preset, cwd);
632
- configs.unshift(await presetModule.config);
633
- presets.unshift(...await presetModule.config.presets ?? []);
634
- } else {
635
- configs.unshift(preset);
636
- presets.unshift(...preset.presets ?? []);
630
+ while (stack.length > 0) {
631
+ const current = stack.pop();
632
+ const subPresets = current.presets ?? [];
633
+ for (const subPreset of subPresets) {
634
+ if (typeof subPreset === "string") {
635
+ const presetModule = await bundle(subPreset, cwd);
636
+ stack.push(presetModule.config);
637
+ } else {
638
+ stack.push(await subPreset);
639
+ }
637
640
  }
641
+ configs.unshift(current);
638
642
  }
639
- configs.unshift(config);
640
- return mergeConfigs(configs);
643
+ const merged = mergeConfigs(configs);
644
+ merged.presets = configs.slice(0, -1);
645
+ return merged;
641
646
  }
642
647
 
643
648
  // src/resolve-config.ts
@@ -972,7 +977,7 @@ async function resolveConfig(result, cwd) {
972
977
  loadConfigResult.config = result2;
973
978
  }
974
979
  }
975
- const serialized = (0, import_shared10.stringifyJson)(loadConfigResult.config);
980
+ const serialized = (0, import_shared10.stringifyJson)(Object.assign({}, loadConfigResult.config, { name: import_shared10.PANDA_CONFIG_NAME, presets: [] }));
976
981
  const deserialize = () => (0, import_shared10.parseJson)(serialized);
977
982
  return { ...loadConfigResult, serialized, deserialize, hooks };
978
983
  }
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  isValidToken,
7
7
  mergeConfigs,
8
8
  serializeTokenValue
9
- } from "./chunk-F5ESIWB7.mjs";
9
+ } from "./chunk-K5ODX2PU.mjs";
10
10
  import {
11
11
  diffConfigs
12
12
  } from "./chunk-Q2O7DCQS.mjs";
@@ -208,26 +208,29 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compi
208
208
 
209
209
  // src/get-resolved-config.ts
210
210
  async function getResolvedConfig(config, cwd) {
211
- const presets = config.presets ?? [];
211
+ const stack = [config];
212
212
  const configs = [];
213
- while (presets.length > 0) {
214
- const preset = await presets.shift();
215
- if (typeof preset === "string") {
216
- const presetModule = await bundle(preset, cwd);
217
- configs.unshift(await presetModule.config);
218
- presets.unshift(...await presetModule.config.presets ?? []);
219
- } else {
220
- configs.unshift(preset);
221
- presets.unshift(...preset.presets ?? []);
213
+ while (stack.length > 0) {
214
+ const current = stack.pop();
215
+ const subPresets = current.presets ?? [];
216
+ for (const subPreset of subPresets) {
217
+ if (typeof subPreset === "string") {
218
+ const presetModule = await bundle(subPreset, cwd);
219
+ stack.push(presetModule.config);
220
+ } else {
221
+ stack.push(await subPreset);
222
+ }
222
223
  }
224
+ configs.unshift(current);
223
225
  }
224
- configs.unshift(config);
225
- return mergeConfigs(configs);
226
+ const merged = mergeConfigs(configs);
227
+ merged.presets = configs.slice(0, -1);
228
+ return merged;
226
229
  }
227
230
 
228
231
  // src/resolve-config.ts
229
232
  import { logger as logger3 } from "@pandacss/logger";
230
- import { omit, parseJson, stringifyJson, traverse } from "@pandacss/shared";
233
+ import { PANDA_CONFIG_NAME, omit, parseJson, stringifyJson, traverse } from "@pandacss/shared";
231
234
 
232
235
  // src/bundled-preset.ts
233
236
  import { preset as presetBase } from "@pandacss/preset-base";
@@ -557,7 +560,7 @@ async function resolveConfig(result, cwd) {
557
560
  loadConfigResult.config = result2;
558
561
  }
559
562
  }
560
- const serialized = stringifyJson(loadConfigResult.config);
563
+ const serialized = stringifyJson(Object.assign({}, loadConfigResult.config, { name: PANDA_CONFIG_NAME, presets: [] }));
561
564
  const deserialize = () => parseJson(serialized);
562
565
  return { ...loadConfigResult, serialized, deserialize, hooks };
563
566
  }
@@ -1,4 +1,4 @@
1
- import { UserConfig, Config } from '@pandacss/types';
1
+ import { Config } from '@pandacss/types';
2
2
 
3
3
  type Extendable<T> = T & {
4
4
  extend?: T;
@@ -7,6 +7,6 @@ type ExtendableConfig = Extendable<Config>;
7
7
  /**
8
8
  * Merge all configs into a single config
9
9
  */
10
- declare function mergeConfigs(configs: ExtendableConfig[]): UserConfig;
10
+ declare function mergeConfigs(configs: ExtendableConfig[]): any;
11
11
 
12
12
  export { mergeConfigs };
@@ -1,4 +1,4 @@
1
- import { UserConfig, Config } from '@pandacss/types';
1
+ import { Config } from '@pandacss/types';
2
2
 
3
3
  type Extendable<T> = T & {
4
4
  extend?: T;
@@ -7,6 +7,6 @@ type ExtendableConfig = Extendable<Config>;
7
7
  /**
8
8
  * Merge all configs into a single config
9
9
  */
10
- declare function mergeConfigs(configs: ExtendableConfig[]): UserConfig;
10
+ declare function mergeConfigs(configs: ExtendableConfig[]): any;
11
11
 
12
12
  export { mergeConfigs };
@@ -185,24 +185,26 @@ var compact = (obj) => {
185
185
  };
186
186
  var tokenKeys = ["description", "extensions", "type", "value", "deprecated"];
187
187
  function mergeConfigs(configs) {
188
- const [userConfig] = configs;
188
+ const userConfig = configs.at(-1);
189
189
  const pluginHooks = userConfig.plugins ?? [];
190
190
  if (userConfig.hooks) {
191
- pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks });
191
+ pluginHooks.push({ name: import_shared2.PANDA_CONFIG_NAME, hooks: userConfig.hooks });
192
192
  }
193
+ const reversed = Array.from(configs).reverse();
193
194
  const mergedResult = (0, import_shared2.assign)(
194
195
  {
195
- conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})),
196
- theme: mergeExtensions(configs.map((config) => config.theme ?? {})),
197
- patterns: mergeExtensions(configs.map((config) => config.patterns ?? {})),
198
- utilities: mergeExtensions(configs.map((config) => config.utilities ?? {})),
199
- globalCss: mergeExtensions(configs.map((config) => config.globalCss ?? {})),
200
- globalVars: mergeExtensions(configs.map((config) => config.globalVars ?? {})),
201
- staticCss: mergeExtensions(configs.map((config) => config.staticCss ?? {})),
202
- themes: mergeExtensions(configs.map((config) => config.themes ?? {})),
196
+ conditions: mergeExtensions(reversed.map((config) => config.conditions ?? {})),
197
+ theme: mergeExtensions(reversed.map((config) => config.theme ?? {})),
198
+ patterns: mergeExtensions(reversed.map((config) => config.patterns ?? {})),
199
+ utilities: mergeExtensions(reversed.map((config) => config.utilities ?? {})),
200
+ globalCss: mergeExtensions(reversed.map((config) => config.globalCss ?? {})),
201
+ globalVars: mergeExtensions(reversed.map((config) => config.globalVars ?? {})),
202
+ globalFontface: mergeExtensions(reversed.map((config) => config.globalFontface ?? {})),
203
+ staticCss: mergeExtensions(reversed.map((config) => config.staticCss ?? {})),
204
+ themes: mergeExtensions(reversed.map((config) => config.themes ?? {})),
203
205
  hooks: mergeHooks(pluginHooks)
204
206
  },
205
- ...configs
207
+ ...reversed
206
208
  );
207
209
  const withoutEmpty = compact(mergedResult);
208
210
  if (withoutEmpty.theme?.tokens) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mergeConfigs
3
- } from "./chunk-F5ESIWB7.mjs";
3
+ } from "./chunk-K5ODX2PU.mjs";
4
4
  export {
5
5
  mergeConfigs
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "description": "Find and load panda config",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -73,11 +73,11 @@
73
73
  "merge-anything": "5.1.7",
74
74
  "microdiff": "1.3.2",
75
75
  "typescript": "5.3.3",
76
- "@pandacss/logger": "0.42.0",
77
- "@pandacss/preset-base": "0.42.0",
78
- "@pandacss/preset-panda": "0.42.0",
79
- "@pandacss/shared": "0.42.0",
80
- "@pandacss/types": "0.42.0"
76
+ "@pandacss/logger": "0.44.0",
77
+ "@pandacss/preset-base": "0.44.0",
78
+ "@pandacss/preset-panda": "0.44.0",
79
+ "@pandacss/shared": "0.44.0",
80
+ "@pandacss/types": "0.44.0"
81
81
  },
82
82
  "devDependencies": {
83
83
  "pkg-types": "1.0.3"