@pandacss/config
Advanced tools
Comparing version 0.0.0-dev-20240720123529 to 0.0.0-dev-20240722083328
@@ -43,5 +43,5 @@ import * as _pandacss_types from '@pandacss/types'; | ||
/** | ||
* Recursively merge all presets into a single config | ||
* Recursively merge all presets into a single config (depth-first using stack) | ||
*/ | ||
declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<_pandacss_types.UserConfig>; | ||
declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>; | ||
@@ -48,0 +48,0 @@ /** |
@@ -580,21 +580,22 @@ "use strict"; | ||
function mergeConfigs(configs) { | ||
const [userConfig] = configs; | ||
const userConfig = configs.at(-1); | ||
const pluginHooks = userConfig.plugins ?? []; | ||
if (userConfig.hooks) { | ||
pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks }); | ||
pluginHooks.push({ name: import_shared5.PANDA_CONFIG_NAME, hooks: userConfig.hooks }); | ||
} | ||
const reversed = Array.from(configs).reverse(); | ||
const mergedResult = (0, import_shared5.assign)( | ||
{ | ||
conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})), | ||
theme: mergeExtensions(configs.map((config) => config.theme ?? {})), | ||
patterns: mergeExtensions(configs.map((config) => config.patterns ?? {})), | ||
utilities: mergeExtensions(configs.map((config) => config.utilities ?? {})), | ||
globalCss: mergeExtensions(configs.map((config) => config.globalCss ?? {})), | ||
globalVars: mergeExtensions(configs.map((config) => config.globalVars ?? {})), | ||
globalFontface: mergeExtensions(configs.map((config) => config.globalFontface ?? {})), | ||
staticCss: mergeExtensions(configs.map((config) => config.staticCss ?? {})), | ||
themes: mergeExtensions(configs.map((config) => config.themes ?? {})), | ||
conditions: mergeExtensions(reversed.map((config) => config.conditions ?? {})), | ||
theme: mergeExtensions(reversed.map((config) => config.theme ?? {})), | ||
patterns: mergeExtensions(reversed.map((config) => config.patterns ?? {})), | ||
utilities: mergeExtensions(reversed.map((config) => config.utilities ?? {})), | ||
globalCss: mergeExtensions(reversed.map((config) => config.globalCss ?? {})), | ||
globalVars: mergeExtensions(reversed.map((config) => config.globalVars ?? {})), | ||
globalFontface: mergeExtensions(reversed.map((config) => config.globalFontface ?? {})), | ||
staticCss: mergeExtensions(reversed.map((config) => config.staticCss ?? {})), | ||
themes: mergeExtensions(reversed.map((config) => config.themes ?? {})), | ||
hooks: mergeHooks(pluginHooks) | ||
}, | ||
...configs | ||
...reversed | ||
); | ||
@@ -628,17 +629,20 @@ const withoutEmpty = compact(mergedResult); | ||
async function getResolvedConfig(config, cwd) { | ||
const presets = config.presets ?? []; | ||
const stack = [config]; | ||
const configs = []; | ||
while (presets.length > 0) { | ||
const preset = await presets.shift(); | ||
if (typeof preset === "string") { | ||
const presetModule = await bundle(preset, cwd); | ||
configs.unshift(await presetModule.config); | ||
presets.unshift(...await presetModule.config.presets ?? []); | ||
} else { | ||
configs.unshift(preset); | ||
presets.unshift(...preset.presets ?? []); | ||
while (stack.length > 0) { | ||
const current = stack.pop(); | ||
const subPresets = current.presets ?? []; | ||
for (const subPreset of subPresets) { | ||
if (typeof subPreset === "string") { | ||
const presetModule = await bundle(subPreset, cwd); | ||
stack.push(presetModule.config); | ||
} else { | ||
stack.push(await subPreset); | ||
} | ||
} | ||
configs.unshift(current); | ||
} | ||
configs.unshift(config); | ||
return mergeConfigs(configs); | ||
const merged = mergeConfigs(configs); | ||
merged.presets = configs.slice(0, -1); | ||
return merged; | ||
} | ||
@@ -978,3 +982,3 @@ | ||
} | ||
const serialized = (0, import_shared10.stringifyJson)(loadConfigResult.config); | ||
const serialized = (0, import_shared10.stringifyJson)(Object.assign({}, loadConfigResult.config, { name: import_shared10.PANDA_CONFIG_NAME, presets: [] })); | ||
const deserialize = () => (0, import_shared10.parseJson)(serialized); | ||
@@ -981,0 +985,0 @@ return { ...loadConfigResult, serialized, deserialize, hooks }; |
@@ -1,2 +0,2 @@ | ||
import { UserConfig, Config } from '@pandacss/types'; | ||
import { Config } from '@pandacss/types'; | ||
@@ -10,4 +10,4 @@ type Extendable<T> = T & { | ||
*/ | ||
declare function mergeConfigs(configs: ExtendableConfig[]): UserConfig; | ||
declare function mergeConfigs(configs: ExtendableConfig[]): any; | ||
export { mergeConfigs }; |
@@ -188,21 +188,22 @@ "use strict"; | ||
function mergeConfigs(configs) { | ||
const [userConfig] = configs; | ||
const userConfig = configs.at(-1); | ||
const pluginHooks = userConfig.plugins ?? []; | ||
if (userConfig.hooks) { | ||
pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks }); | ||
pluginHooks.push({ name: import_shared2.PANDA_CONFIG_NAME, hooks: userConfig.hooks }); | ||
} | ||
const reversed = Array.from(configs).reverse(); | ||
const mergedResult = (0, import_shared2.assign)( | ||
{ | ||
conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})), | ||
theme: mergeExtensions(configs.map((config) => config.theme ?? {})), | ||
patterns: mergeExtensions(configs.map((config) => config.patterns ?? {})), | ||
utilities: mergeExtensions(configs.map((config) => config.utilities ?? {})), | ||
globalCss: mergeExtensions(configs.map((config) => config.globalCss ?? {})), | ||
globalVars: mergeExtensions(configs.map((config) => config.globalVars ?? {})), | ||
globalFontface: mergeExtensions(configs.map((config) => config.globalFontface ?? {})), | ||
staticCss: mergeExtensions(configs.map((config) => config.staticCss ?? {})), | ||
themes: mergeExtensions(configs.map((config) => config.themes ?? {})), | ||
conditions: mergeExtensions(reversed.map((config) => config.conditions ?? {})), | ||
theme: mergeExtensions(reversed.map((config) => config.theme ?? {})), | ||
patterns: mergeExtensions(reversed.map((config) => config.patterns ?? {})), | ||
utilities: mergeExtensions(reversed.map((config) => config.utilities ?? {})), | ||
globalCss: mergeExtensions(reversed.map((config) => config.globalCss ?? {})), | ||
globalVars: mergeExtensions(reversed.map((config) => config.globalVars ?? {})), | ||
globalFontface: mergeExtensions(reversed.map((config) => config.globalFontface ?? {})), | ||
staticCss: mergeExtensions(reversed.map((config) => config.staticCss ?? {})), | ||
themes: mergeExtensions(reversed.map((config) => config.themes ?? {})), | ||
hooks: mergeHooks(pluginHooks) | ||
}, | ||
...configs | ||
...reversed | ||
); | ||
@@ -209,0 +210,0 @@ const withoutEmpty = compact(mergedResult); |
{ | ||
"name": "@pandacss/config", | ||
"version": "0.0.0-dev-20240720123529", | ||
"version": "0.0.0-dev-20240722083328", | ||
"description": "Find and load panda config", | ||
@@ -76,7 +76,7 @@ "main": "dist/index.js", | ||
"typescript": "5.3.3", | ||
"@pandacss/logger": "0.0.0-dev-20240720123529", | ||
"@pandacss/preset-base": "0.0.0-dev-20240720123529", | ||
"@pandacss/preset-panda": "0.0.0-dev-20240720123529", | ||
"@pandacss/shared": "0.0.0-dev-20240720123529", | ||
"@pandacss/types": "0.0.0-dev-20240720123529" | ||
"@pandacss/logger": "0.0.0-dev-20240722083328", | ||
"@pandacss/preset-base": "0.0.0-dev-20240722083328", | ||
"@pandacss/preset-panda": "0.0.0-dev-20240722083328", | ||
"@pandacss/shared": "0.0.0-dev-20240722083328", | ||
"@pandacss/types": "0.0.0-dev-20240722083328" | ||
}, | ||
@@ -83,0 +83,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88262
2468
+ Added@pandacss/logger@0.0.0-dev-20240722083328(transitive)
+ Added@pandacss/preset-base@0.0.0-dev-20240722083328(transitive)
+ Added@pandacss/preset-panda@0.0.0-dev-20240722083328(transitive)
+ Added@pandacss/shared@0.0.0-dev-20240722083328(transitive)
+ Added@pandacss/types@0.0.0-dev-20240722083328(transitive)
- Removed@pandacss/logger@0.0.0-dev-20240720123529(transitive)
- Removed@pandacss/preset-base@0.0.0-dev-20240720123529(transitive)
- Removed@pandacss/preset-panda@0.0.0-dev-20240720123529(transitive)
- Removed@pandacss/shared@0.0.0-dev-20240720123529(transitive)
- Removed@pandacss/types@0.0.0-dev-20240720123529(transitive)