Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pandacss/config

Package Overview
Dependencies
Maintainers
1
Versions
1144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pandacss/config - npm Package Compare versions

Comparing version 0.0.0-dev-20221220033401 to 0.0.0-dev-20221220144042

18

dist/index.d.ts

@@ -8,4 +8,4 @@ import { UserConfig } from '@pandacss/types';

declare function loadConfigFile(options: ConfigFileOptions): Promise<{
config: any;
path: string;
config: UserConfig;
dependencies: string[];

@@ -19,2 +19,16 @@ }>;

export { LoadConfigResult, loadConfigFile };
type Extendable<T> = T & {
extend?: T;
};
type Dict = Record<string, any>;
type ExtendableRecord = Extendable<Dict>;
/**
* Merge all configs into a single config
*/
declare function mergeConfigs(configs: ExtendableRecord[]): any;
/**
* Recursively merge all presets into a single config
*/
declare function getResolvedConfig(config: ExtendableRecord, cwd: string): Promise<any>;
export { LoadConfigResult, getResolvedConfig, loadConfigFile, mergeConfigs };

@@ -29,3 +29,5 @@ "use strict";

__export(src_exports, {
loadConfigFile: () => loadConfigFile
getResolvedConfig: () => getResolvedConfig,
loadConfigFile: () => loadConfigFile,
mergeConfigs: () => mergeConfigs
});

@@ -37,3 +39,2 @@ module.exports = __toCommonJS(src_exports);

var import_logger2 = require("@pandacss/logger");
var import_merge_anything = require("merge-anything");

@@ -129,2 +130,87 @@ // src/bundle-require.ts

// src/merge-config.ts
var import_merge_anything = require("merge-anything");
// src/utils.ts
var isObject = (value) => {
return Object.prototype.toString.call(value) === "[object Object]";
};
function mergeWith(target, ...sources) {
const customizer = sources.pop();
for (const source of sources) {
for (const key in source) {
const merged = customizer(target[key], source[key]);
if (merged === void 0) {
if (isObject(target[key]) && isObject(source[key])) {
target[key] = mergeWith({}, target[key], source[key], customizer);
} else {
target[key] = source[key];
}
} else {
target[key] = merged;
}
}
}
return target;
}
function assign(target, ...sources) {
for (const source of sources) {
for (const key in source) {
if (!target?.hasOwnProperty?.(key)) {
target[key] = source[key];
}
}
}
return target;
}
// src/merge-config.ts
function getExtends(items) {
return items.reduce((merged, { extend }) => {
return mergeWith(merged, extend, (originalValue, newValue) => {
if (originalValue === void 0) {
return [newValue];
}
if (Array.isArray(originalValue)) {
return [newValue, ...originalValue];
}
return [newValue, originalValue];
});
}, {});
}
function mergeRecords(records) {
return {
...records.reduce((acc, record) => assign(acc, record), {}),
extend: getExtends(records)
};
}
function mergeExtensions(records) {
const { extend = [], ...restProps } = mergeRecords(records);
return mergeWith(restProps, extend, (obj, extensions) => {
return (0, import_merge_anything.mergeAndConcat)({}, obj, ...extensions);
});
}
function mergeConfigs(configs2) {
return assign(
{
conditions: mergeExtensions(configs2.map((config) => config.conditions ?? {})),
theme: mergeExtensions(configs2.map((config) => config.theme ?? {})),
patterns: mergeExtensions(configs2.map((config) => config.patterns ?? {})),
utilities: mergeExtensions(configs2.map((config) => config.utilities ?? {}))
},
...configs2
);
}
async function getResolvedConfig(config, cwd) {
const presets = config.presets ?? [];
const configs2 = await Promise.all(
presets.slice().reverse().map(async (preset) => {
const presetModule = await bundleAndRequire(preset, cwd);
return getResolvedConfig(presetModule.config, cwd);
})
);
delete config.presets;
return mergeConfigs([config, ...configs2]);
}
// src/load-config.ts

@@ -142,10 +228,7 @@ async function loadConfigFile(options) {

}
const presets = result.config.presets ?? [];
for (const preset of presets) {
const presetResult = await bundleAndRequire(preset, cwd);
result.config = (0, import_merge_anything.merge)({}, presetResult.config, result.config);
}
delete result.config.presets;
result.config.presets ||= ["css-panda/presets"];
const mergedConfig = await getResolvedConfig(result.config, cwd);
return {
...result,
config: mergedConfig,
path: filePath

@@ -156,3 +239,5 @@ };

0 && (module.exports = {
loadConfigFile
getResolvedConfig,
loadConfigFile,
mergeConfigs
});

8

package.json
{
"name": "@pandacss/config",
"version": "0.0.0-dev-20221220033401",
"version": "0.0.0-dev-20221220144042",
"description": "Find and load panda config",

@@ -21,5 +21,5 @@ "main": "dist/index.js",

"node-eval": "2.0.0",
"@pandacss/logger": "0.0.0-dev-20221220033401",
"@pandacss/error": "0.0.0-dev-20221220033401",
"@pandacss/types": "0.0.0-dev-20221220033401"
"@pandacss/logger": "0.0.0-dev-20221220144042",
"@pandacss/error": "0.0.0-dev-20221220144042",
"@pandacss/types": "0.0.0-dev-20221220144042"
},

@@ -26,0 +26,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc