@pandacss/config 0.5.0 → 0.5.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.
@@ -0,0 +1,93 @@
1
+ // src/merge-config.ts
2
+ import { mergeAndConcat } from "merge-anything";
3
+
4
+ // src/utils.ts
5
+ var isObject = (value) => {
6
+ return Object.prototype.toString.call(value) === "[object Object]";
7
+ };
8
+ function mergeWith(target, ...sources) {
9
+ const customizer = sources.pop();
10
+ for (const source of sources) {
11
+ for (const key in source) {
12
+ const merged = customizer(target[key], source[key]);
13
+ if (merged === void 0) {
14
+ if (isObject(target[key]) && isObject(source[key])) {
15
+ target[key] = mergeWith({}, target[key], source[key], customizer);
16
+ } else {
17
+ target[key] = source[key];
18
+ }
19
+ } else {
20
+ target[key] = merged;
21
+ }
22
+ }
23
+ }
24
+ return target;
25
+ }
26
+ function assign(target, ...sources) {
27
+ for (const source of sources) {
28
+ for (const key in source) {
29
+ if (!target?.hasOwnProperty?.(key)) {
30
+ target[key] = source[key];
31
+ }
32
+ }
33
+ }
34
+ return target;
35
+ }
36
+
37
+ // src/merge-config.ts
38
+ function getExtends(items) {
39
+ return items.reduce((merged, { extend }) => {
40
+ if (!extend)
41
+ return merged;
42
+ return mergeWith(merged, extend, (originalValue, newValue) => {
43
+ if (newValue === void 0) {
44
+ return originalValue ?? [];
45
+ }
46
+ if (originalValue === void 0) {
47
+ return [newValue];
48
+ }
49
+ if (Array.isArray(originalValue)) {
50
+ return [newValue, ...originalValue];
51
+ }
52
+ return [newValue, originalValue];
53
+ });
54
+ }, {});
55
+ }
56
+ function mergeRecords(records) {
57
+ return {
58
+ ...records.reduce((acc, record) => assign(acc, record), {}),
59
+ extend: getExtends(records)
60
+ };
61
+ }
62
+ function mergeExtensions(records) {
63
+ const { extend = [], ...restProps } = mergeRecords(records);
64
+ return mergeWith(restProps, extend, (obj, extensions) => {
65
+ return mergeAndConcat({}, obj, ...extensions);
66
+ });
67
+ }
68
+ var isEmptyObject = (obj) => typeof obj === "object" && Object.keys(obj).length === 0;
69
+ var compact = (obj) => {
70
+ return Object.keys(obj).reduce((acc, key) => {
71
+ if (obj[key] !== void 0 && !isEmptyObject(obj[key])) {
72
+ acc[key] = obj[key];
73
+ }
74
+ return acc;
75
+ }, {});
76
+ };
77
+ function mergeConfigs(configs) {
78
+ const mergedResult = assign(
79
+ {
80
+ conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})),
81
+ theme: mergeExtensions(configs.map((config) => config.theme ?? {})),
82
+ patterns: mergeExtensions(configs.map((config) => config.patterns ?? {})),
83
+ utilities: mergeExtensions(configs.map((config) => config.utilities ?? {})),
84
+ globalCss: mergeExtensions(configs.map((config) => config.globalCss ?? {}))
85
+ },
86
+ ...configs
87
+ );
88
+ return compact(mergedResult);
89
+ }
90
+
91
+ export {
92
+ mergeConfigs
93
+ };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
- import { LoadConfigResult, Config } from '@pandacss/types';
2
+ import { Config, LoadConfigResult } from '@pandacss/types';
3
+ export { mergeConfigs } from './merge-config.mjs';
3
4
 
4
5
  declare function findConfigFile({ cwd, file }: {
5
6
  cwd: string;
@@ -10,6 +11,10 @@ type PathMapping = {
10
11
  pattern: RegExp;
11
12
  paths: string[];
12
13
  };
14
+ /**
15
+ * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
16
+ */
17
+ declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
13
18
 
14
19
  type GetDepsOptions = {
15
20
  filename: string;
@@ -29,6 +34,15 @@ declare function getConfigDependencies(filePath: string, tsOptions?: GetConfigDe
29
34
  aliases: Map<string, string>;
30
35
  };
31
36
 
37
+ type Extendable<T> = T & {
38
+ extend?: T;
39
+ };
40
+ type ExtendableConfig = Extendable<Config>;
41
+ /**
42
+ * Recursively merge all presets into a single config
43
+ */
44
+ declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
45
+
32
46
  type ConfigFileOptions = {
33
47
  cwd: string;
34
48
  file?: string;
@@ -41,17 +55,4 @@ declare function bundleConfigFile(options: ConfigFileOptions): Promise<{
41
55
  dependencies: string[];
42
56
  }>;
43
57
 
44
- type Extendable<T> = T & {
45
- extend?: T;
46
- };
47
- type ExtendableConfig = Extendable<Config>;
48
- /**
49
- * Merge all configs into a single config
50
- */
51
- declare function mergeConfigs(configs: ExtendableConfig[]): any;
52
- /**
53
- * Recursively merge all presets into a single config
54
- */
55
- declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
56
-
57
- export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, mergeConfigs, resolveConfigFile };
58
+ export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, convertTsPathsToRegexes, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, resolveConfigFile };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
- import { LoadConfigResult, Config } from '@pandacss/types';
2
+ import { Config, LoadConfigResult } from '@pandacss/types';
3
+ export { mergeConfigs } from './merge-config.js';
3
4
 
4
5
  declare function findConfigFile({ cwd, file }: {
5
6
  cwd: string;
@@ -10,6 +11,10 @@ type PathMapping = {
10
11
  pattern: RegExp;
11
12
  paths: string[];
12
13
  };
14
+ /**
15
+ * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
16
+ */
17
+ declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
13
18
 
14
19
  type GetDepsOptions = {
15
20
  filename: string;
@@ -29,6 +34,15 @@ declare function getConfigDependencies(filePath: string, tsOptions?: GetConfigDe
29
34
  aliases: Map<string, string>;
30
35
  };
31
36
 
37
+ type Extendable<T> = T & {
38
+ extend?: T;
39
+ };
40
+ type ExtendableConfig = Extendable<Config>;
41
+ /**
42
+ * Recursively merge all presets into a single config
43
+ */
44
+ declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
45
+
32
46
  type ConfigFileOptions = {
33
47
  cwd: string;
34
48
  file?: string;
@@ -41,17 +55,4 @@ declare function bundleConfigFile(options: ConfigFileOptions): Promise<{
41
55
  dependencies: string[];
42
56
  }>;
43
57
 
44
- type Extendable<T> = T & {
45
- extend?: T;
46
- };
47
- type ExtendableConfig = Extendable<Config>;
48
- /**
49
- * Merge all configs into a single config
50
- */
51
- declare function mergeConfigs(configs: ExtendableConfig[]): any;
52
- /**
53
- * Recursively merge all presets into a single config
54
- */
55
- declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
56
-
57
- export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, mergeConfigs, resolveConfigFile };
58
+ export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, convertTsPathsToRegexes, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, resolveConfigFile };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
33
  bundleConfigFile: () => bundleConfigFile,
34
+ convertTsPathsToRegexes: () => convertTsPathsToRegexes,
34
35
  findConfigFile: () => findConfigFile,
35
36
  getConfigDependencies: () => getConfigDependencies,
36
37
  getResolvedConfig: () => getResolvedConfig,
@@ -56,9 +57,23 @@ function findConfigFile({ cwd, file }) {
56
57
 
57
58
  // src/get-mod-deps.ts
58
59
  var import_fs = __toESM(require("fs"));
59
- var import_path2 = __toESM(require("path"));
60
+ var import_path3 = __toESM(require("path"));
60
61
 
61
- // src/ts-config-paths-mappings.ts
62
+ // src/ts-config-paths.ts
63
+ var import_path2 = require("path");
64
+ function convertTsPathsToRegexes(paths, baseUrl) {
65
+ const sortedPatterns = Object.keys(paths).sort((a, b) => getPrefixLength(b) - getPrefixLength(a));
66
+ const resolved = [];
67
+ for (let pattern of sortedPatterns) {
68
+ const relativePaths = paths[pattern];
69
+ pattern = escapeStringRegexp(pattern).replace(/\*/g, "(.+)");
70
+ resolved.push({
71
+ pattern: new RegExp("^" + pattern + "$"),
72
+ paths: relativePaths.map((relativePath) => (0, import_path2.resolve)(baseUrl, relativePath))
73
+ });
74
+ }
75
+ return resolved;
76
+ }
62
77
  var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
63
78
  for (const mapping of pathMappings) {
64
79
  const match = moduleSpecifier.match(mapping.pattern);
@@ -75,6 +90,13 @@ var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
75
90
  }
76
91
  }
77
92
  };
93
+ function getPrefixLength(pattern) {
94
+ const prefixLength = pattern.indexOf("*");
95
+ return pattern.substr(0, prefixLength).length;
96
+ }
97
+ function escapeStringRegexp(string) {
98
+ return string.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/-/g, "\\x2d");
99
+ }
78
100
 
79
101
  // src/get-mod-deps.ts
80
102
  var jsExtensions = [".js", ".cjs", ".mjs"];
@@ -102,7 +124,7 @@ var exportRegex = /export[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi;
102
124
  function getDeps(opts, fromAlias) {
103
125
  const { filename, seen } = opts;
104
126
  const absoluteFile = resolveWithExtension(
105
- import_path2.default.resolve(opts.cwd, filename),
127
+ import_path3.default.resolve(opts.cwd, filename),
106
128
  jsExtensions.includes(opts.ext) ? jsResolutionOrder : tsResolutionOrder
107
129
  );
108
130
  if (absoluteFile === null)
@@ -110,7 +132,7 @@ function getDeps(opts, fromAlias) {
110
132
  if (fromAlias) {
111
133
  opts.foundModuleAliases.set(fromAlias, absoluteFile);
112
134
  }
113
- if (seen.has(absoluteFile))
135
+ if (seen.size > 1 && seen.has(absoluteFile))
114
136
  return;
115
137
  seen.add(absoluteFile);
116
138
  const contents = import_fs.default.readFileSync(absoluteFile, "utf-8");
@@ -124,8 +146,8 @@ function getDeps(opts, fromAlias) {
124
146
  return;
125
147
  const nextOpts = {
126
148
  // Resolve new base for new imports/requires
127
- cwd: import_path2.default.dirname(absoluteFile),
128
- ext: import_path2.default.extname(absoluteFile),
149
+ cwd: import_path3.default.dirname(absoluteFile),
150
+ ext: import_path3.default.extname(absoluteFile),
129
151
  seen,
130
152
  baseUrl: opts.baseUrl,
131
153
  pathMappings: opts.pathMappings,
@@ -153,8 +175,8 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
153
175
  deps.add(filePath);
154
176
  getDeps({
155
177
  filename: filePath,
156
- ext: import_path2.default.extname(filePath),
157
- cwd: import_path2.default.dirname(filePath),
178
+ ext: import_path3.default.extname(filePath),
179
+ cwd: import_path3.default.dirname(filePath),
158
180
  seen: deps,
159
181
  baseUrl: tsOptions.baseUrl,
160
182
  pathMappings: tsOptions.pathMappings ?? [],
@@ -163,10 +185,6 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
163
185
  return { deps, aliases: foundModuleAliases };
164
186
  }
165
187
 
166
- // src/load-config.ts
167
- var import_error = require("@pandacss/error");
168
- var import_logger = require("@pandacss/logger");
169
-
170
188
  // src/bundle.ts
171
189
  var import_bundle_n_require = require("bundle-n-require");
172
190
  async function bundle(filepath, cwd) {
@@ -263,6 +281,8 @@ function mergeConfigs(configs2) {
263
281
  );
264
282
  return compact(mergedResult);
265
283
  }
284
+
285
+ // src/get-resolved-config.ts
266
286
  async function getResolvedConfig(config, cwd) {
267
287
  const presets = config.presets ?? [];
268
288
  const configs2 = [config];
@@ -281,6 +301,8 @@ async function getResolvedConfig(config, cwd) {
281
301
  }
282
302
 
283
303
  // src/load-config.ts
304
+ var import_error = require("@pandacss/error");
305
+ var import_logger = require("@pandacss/logger");
284
306
  var import_preset_base = require("@pandacss/preset-base");
285
307
  var import_preset_panda = require("@pandacss/preset-panda");
286
308
  var bundledPresets = {
@@ -334,6 +356,7 @@ async function bundleConfigFile(options) {
334
356
  // Annotate the CommonJS export names for ESM import in node:
335
357
  0 && (module.exports = {
336
358
  bundleConfigFile,
359
+ convertTsPathsToRegexes,
337
360
  findConfigFile,
338
361
  getConfigDependencies,
339
362
  getResolvedConfig,
package/dist/index.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ import {
2
+ mergeConfigs
3
+ } from "./chunk-5FP5NJ64.mjs";
4
+
1
5
  // src/find-config.ts
2
6
  import findUp from "escalade/sync";
3
7
  import { resolve } from "path";
@@ -16,7 +20,21 @@ function findConfigFile({ cwd, file }) {
16
20
  import fs from "fs";
17
21
  import path from "path";
18
22
 
19
- // src/ts-config-paths-mappings.ts
23
+ // src/ts-config-paths.ts
24
+ import { resolve as resolve2 } from "path";
25
+ function convertTsPathsToRegexes(paths, baseUrl) {
26
+ const sortedPatterns = Object.keys(paths).sort((a, b) => getPrefixLength(b) - getPrefixLength(a));
27
+ const resolved = [];
28
+ for (let pattern of sortedPatterns) {
29
+ const relativePaths = paths[pattern];
30
+ pattern = escapeStringRegexp(pattern).replace(/\*/g, "(.+)");
31
+ resolved.push({
32
+ pattern: new RegExp("^" + pattern + "$"),
33
+ paths: relativePaths.map((relativePath) => resolve2(baseUrl, relativePath))
34
+ });
35
+ }
36
+ return resolved;
37
+ }
20
38
  var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
21
39
  for (const mapping of pathMappings) {
22
40
  const match = moduleSpecifier.match(mapping.pattern);
@@ -33,6 +51,13 @@ var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
33
51
  }
34
52
  }
35
53
  };
54
+ function getPrefixLength(pattern) {
55
+ const prefixLength = pattern.indexOf("*");
56
+ return pattern.substr(0, prefixLength).length;
57
+ }
58
+ function escapeStringRegexp(string) {
59
+ return string.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/-/g, "\\x2d");
60
+ }
36
61
 
37
62
  // src/get-mod-deps.ts
38
63
  var jsExtensions = [".js", ".cjs", ".mjs"];
@@ -68,7 +93,7 @@ function getDeps(opts, fromAlias) {
68
93
  if (fromAlias) {
69
94
  opts.foundModuleAliases.set(fromAlias, absoluteFile);
70
95
  }
71
- if (seen.has(absoluteFile))
96
+ if (seen.size > 1 && seen.has(absoluteFile))
72
97
  return;
73
98
  seen.add(absoluteFile);
74
99
  const contents = fs.readFileSync(absoluteFile, "utf-8");
@@ -121,10 +146,6 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
121
146
  return { deps, aliases: foundModuleAliases };
122
147
  }
123
148
 
124
- // src/load-config.ts
125
- import { ConfigError, ConfigNotFoundError } from "@pandacss/error";
126
- import { logger } from "@pandacss/logger";
127
-
128
149
  // src/bundle.ts
129
150
  import { bundleNRequire } from "bundle-n-require";
130
151
  async function bundle(filepath, cwd) {
@@ -132,95 +153,7 @@ async function bundle(filepath, cwd) {
132
153
  return { config: config?.default ?? config, dependencies };
133
154
  }
134
155
 
135
- // src/merge-config.ts
136
- import { mergeAndConcat } from "merge-anything";
137
-
138
- // src/utils.ts
139
- var isObject = (value) => {
140
- return Object.prototype.toString.call(value) === "[object Object]";
141
- };
142
- function mergeWith(target, ...sources) {
143
- const customizer = sources.pop();
144
- for (const source of sources) {
145
- for (const key in source) {
146
- const merged = customizer(target[key], source[key]);
147
- if (merged === void 0) {
148
- if (isObject(target[key]) && isObject(source[key])) {
149
- target[key] = mergeWith({}, target[key], source[key], customizer);
150
- } else {
151
- target[key] = source[key];
152
- }
153
- } else {
154
- target[key] = merged;
155
- }
156
- }
157
- }
158
- return target;
159
- }
160
- function assign(target, ...sources) {
161
- for (const source of sources) {
162
- for (const key in source) {
163
- if (!target?.hasOwnProperty?.(key)) {
164
- target[key] = source[key];
165
- }
166
- }
167
- }
168
- return target;
169
- }
170
-
171
- // src/merge-config.ts
172
- function getExtends(items) {
173
- return items.reduce((merged, { extend }) => {
174
- if (!extend)
175
- return merged;
176
- return mergeWith(merged, extend, (originalValue, newValue) => {
177
- if (newValue === void 0) {
178
- return originalValue ?? [];
179
- }
180
- if (originalValue === void 0) {
181
- return [newValue];
182
- }
183
- if (Array.isArray(originalValue)) {
184
- return [newValue, ...originalValue];
185
- }
186
- return [newValue, originalValue];
187
- });
188
- }, {});
189
- }
190
- function mergeRecords(records) {
191
- return {
192
- ...records.reduce((acc, record) => assign(acc, record), {}),
193
- extend: getExtends(records)
194
- };
195
- }
196
- function mergeExtensions(records) {
197
- const { extend = [], ...restProps } = mergeRecords(records);
198
- return mergeWith(restProps, extend, (obj, extensions) => {
199
- return mergeAndConcat({}, obj, ...extensions);
200
- });
201
- }
202
- var isEmptyObject = (obj) => typeof obj === "object" && Object.keys(obj).length === 0;
203
- var compact = (obj) => {
204
- return Object.keys(obj).reduce((acc, key) => {
205
- if (obj[key] !== void 0 && !isEmptyObject(obj[key])) {
206
- acc[key] = obj[key];
207
- }
208
- return acc;
209
- }, {});
210
- };
211
- function mergeConfigs(configs2) {
212
- const mergedResult = assign(
213
- {
214
- conditions: mergeExtensions(configs2.map((config) => config.conditions ?? {})),
215
- theme: mergeExtensions(configs2.map((config) => config.theme ?? {})),
216
- patterns: mergeExtensions(configs2.map((config) => config.patterns ?? {})),
217
- utilities: mergeExtensions(configs2.map((config) => config.utilities ?? {})),
218
- globalCss: mergeExtensions(configs2.map((config) => config.globalCss ?? {}))
219
- },
220
- ...configs2
221
- );
222
- return compact(mergedResult);
223
- }
156
+ // src/get-resolved-config.ts
224
157
  async function getResolvedConfig(config, cwd) {
225
158
  const presets = config.presets ?? [];
226
159
  const configs2 = [config];
@@ -239,6 +172,8 @@ async function getResolvedConfig(config, cwd) {
239
172
  }
240
173
 
241
174
  // src/load-config.ts
175
+ import { ConfigError, ConfigNotFoundError } from "@pandacss/error";
176
+ import { logger } from "@pandacss/logger";
242
177
  import { preset as presetBase } from "@pandacss/preset-base";
243
178
  import { preset as presetPanda } from "@pandacss/preset-panda";
244
179
  var bundledPresets = {
@@ -291,6 +226,7 @@ async function bundleConfigFile(options) {
291
226
  }
292
227
  export {
293
228
  bundleConfigFile,
229
+ convertTsPathsToRegexes,
294
230
  findConfigFile,
295
231
  getConfigDependencies,
296
232
  getResolvedConfig,
@@ -0,0 +1,12 @@
1
+ import { Config } from '@pandacss/types';
2
+
3
+ type Extendable<T> = T & {
4
+ extend?: T;
5
+ };
6
+ type ExtendableConfig = Extendable<Config>;
7
+ /**
8
+ * Merge all configs into a single config
9
+ */
10
+ declare function mergeConfigs(configs: ExtendableConfig[]): any;
11
+
12
+ export { mergeConfigs };
@@ -0,0 +1,12 @@
1
+ import { Config } from '@pandacss/types';
2
+
3
+ type Extendable<T> = T & {
4
+ extend?: T;
5
+ };
6
+ type ExtendableConfig = Extendable<Config>;
7
+ /**
8
+ * Merge all configs into a single config
9
+ */
10
+ declare function mergeConfigs(configs: ExtendableConfig[]): any;
11
+
12
+ export { mergeConfigs };
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/merge-config.ts
21
+ var merge_config_exports = {};
22
+ __export(merge_config_exports, {
23
+ mergeConfigs: () => mergeConfigs
24
+ });
25
+ module.exports = __toCommonJS(merge_config_exports);
26
+ var import_merge_anything = require("merge-anything");
27
+
28
+ // src/utils.ts
29
+ var isObject = (value) => {
30
+ return Object.prototype.toString.call(value) === "[object Object]";
31
+ };
32
+ function mergeWith(target, ...sources) {
33
+ const customizer = sources.pop();
34
+ for (const source of sources) {
35
+ for (const key in source) {
36
+ const merged = customizer(target[key], source[key]);
37
+ if (merged === void 0) {
38
+ if (isObject(target[key]) && isObject(source[key])) {
39
+ target[key] = mergeWith({}, target[key], source[key], customizer);
40
+ } else {
41
+ target[key] = source[key];
42
+ }
43
+ } else {
44
+ target[key] = merged;
45
+ }
46
+ }
47
+ }
48
+ return target;
49
+ }
50
+ function assign(target, ...sources) {
51
+ for (const source of sources) {
52
+ for (const key in source) {
53
+ if (!target?.hasOwnProperty?.(key)) {
54
+ target[key] = source[key];
55
+ }
56
+ }
57
+ }
58
+ return target;
59
+ }
60
+
61
+ // src/merge-config.ts
62
+ function getExtends(items) {
63
+ return items.reduce((merged, { extend }) => {
64
+ if (!extend)
65
+ return merged;
66
+ return mergeWith(merged, extend, (originalValue, newValue) => {
67
+ if (newValue === void 0) {
68
+ return originalValue ?? [];
69
+ }
70
+ if (originalValue === void 0) {
71
+ return [newValue];
72
+ }
73
+ if (Array.isArray(originalValue)) {
74
+ return [newValue, ...originalValue];
75
+ }
76
+ return [newValue, originalValue];
77
+ });
78
+ }, {});
79
+ }
80
+ function mergeRecords(records) {
81
+ return {
82
+ ...records.reduce((acc, record) => assign(acc, record), {}),
83
+ extend: getExtends(records)
84
+ };
85
+ }
86
+ function mergeExtensions(records) {
87
+ const { extend = [], ...restProps } = mergeRecords(records);
88
+ return mergeWith(restProps, extend, (obj, extensions) => {
89
+ return (0, import_merge_anything.mergeAndConcat)({}, obj, ...extensions);
90
+ });
91
+ }
92
+ var isEmptyObject = (obj) => typeof obj === "object" && Object.keys(obj).length === 0;
93
+ var compact = (obj) => {
94
+ return Object.keys(obj).reduce((acc, key) => {
95
+ if (obj[key] !== void 0 && !isEmptyObject(obj[key])) {
96
+ acc[key] = obj[key];
97
+ }
98
+ return acc;
99
+ }, {});
100
+ };
101
+ function mergeConfigs(configs) {
102
+ const mergedResult = assign(
103
+ {
104
+ conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})),
105
+ theme: mergeExtensions(configs.map((config) => config.theme ?? {})),
106
+ patterns: mergeExtensions(configs.map((config) => config.patterns ?? {})),
107
+ utilities: mergeExtensions(configs.map((config) => config.utilities ?? {})),
108
+ globalCss: mergeExtensions(configs.map((config) => config.globalCss ?? {}))
109
+ },
110
+ ...configs
111
+ );
112
+ return compact(mergedResult);
113
+ }
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ mergeConfigs
117
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ mergeConfigs
3
+ } from "./chunk-5FP5NJ64.mjs";
4
+ export {
5
+ mergeConfigs
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Find and load panda config",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -10,6 +10,19 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "require": "./dist/index.js",
17
+ "import": "./dist/index.mjs"
18
+ },
19
+ "./merge": {
20
+ "types": "./dist/merge-config.d.ts",
21
+ "require": "./dist/merge-config.js",
22
+ "import": "./dist/merge-config.mjs"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
13
26
  "files": [
14
27
  "dist"
15
28
  ],
@@ -19,18 +32,18 @@
19
32
  "jiti": "^1.18.2",
20
33
  "merge-anything": "^5.1.7",
21
34
  "tsconfck": "^2.1.1",
22
- "@pandacss/error": "0.5.0",
23
- "@pandacss/logger": "0.5.0",
24
- "@pandacss/preset-base": "0.5.0",
25
- "@pandacss/preset-panda": "0.5.0",
26
- "@pandacss/types": "0.5.0"
35
+ "@pandacss/error": "0.5.1",
36
+ "@pandacss/logger": "0.5.1",
37
+ "@pandacss/preset-base": "0.5.1",
38
+ "@pandacss/preset-panda": "0.5.1",
39
+ "@pandacss/types": "0.5.1"
27
40
  },
28
41
  "devDependencies": {
29
42
  "pkg-types": "1.0.3"
30
43
  },
31
44
  "scripts": {
32
- "build": "pnpm tsup src/index.ts --format=esm,cjs --shims --dts",
33
- "build-fast": "pnpm tsup src/index.ts --format=esm,cjs --shims --no-dts",
45
+ "build": "pnpm tsup src/index.ts src/merge-config.ts --format=esm,cjs --shims --dts",
46
+ "build-fast": "pnpm tsup src/index.ts src/merge-config.ts --format=esm,cjs --shims --no-dts",
34
47
  "dev": "pnpm build-fast --watch"
35
48
  }
36
49
  }