@pandacss/config 0.23.0 → 0.24.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,108 @@
1
+ // src/diff-config.ts
2
+ import { dashCase } from "@pandacss/shared";
3
+ import microdiff from "microdiff";
4
+
5
+ // src/create-matcher.ts
6
+ function createMatcher(id, patterns) {
7
+ if (!patterns?.length)
8
+ return () => void 0;
9
+ const includePatterns = [];
10
+ const excludePatterns = [];
11
+ const deduped = new Set(patterns);
12
+ deduped.forEach((pattern) => {
13
+ const regexString = pattern.replace(/\*/g, ".*");
14
+ if (pattern.startsWith("!")) {
15
+ excludePatterns.push(regexString.slice(1));
16
+ } else {
17
+ includePatterns.push(regexString);
18
+ }
19
+ });
20
+ const include = new RegExp(includePatterns.join("|"));
21
+ const exclude = new RegExp(excludePatterns.join("|"));
22
+ return (path) => {
23
+ if (excludePatterns.length && exclude.test(path))
24
+ return;
25
+ return include.test(path) ? id : void 0;
26
+ };
27
+ }
28
+
29
+ // src/config-deps.ts
30
+ var all = ["outdir", "forceConsistentTypeExtension", "outExtension"];
31
+ var format = ["syntax", "hash", "prefix", "separator"];
32
+ var tokens = ["utilities", "conditions", "theme.tokens", "theme.semanticTokens", "theme.breakpoints"];
33
+ var jsx = ["jsxFramework", "jsxFactory", "jsxStyleProps", "syntax"];
34
+ var css = ["layers", "optimize", "minify"];
35
+ var common = tokens.concat(jsx, format);
36
+ var artifactConfigDeps = {
37
+ helpers: ["syntax", "jsxFramework"],
38
+ keyframes: ["theme.keyframes", "layers"],
39
+ "design-tokens": ["layers", "!utilities.*.className"].concat(tokens),
40
+ types: ["!utilities.*.className"].concat(common),
41
+ "css-fn": common,
42
+ cva: ["syntax"],
43
+ sva: ["syntax"],
44
+ cx: [],
45
+ "create-recipe": ["separator", "prefix", "hash"],
46
+ "recipes-index": ["theme.recipes", "theme.slotRecipes"],
47
+ recipes: ["theme.recipes", "theme.slotRecipes"],
48
+ "patterns-index": ["syntax", "patterns"],
49
+ patterns: ["syntax", "patterns"],
50
+ "jsx-is-valid-prop": common,
51
+ "jsx-factory": jsx,
52
+ "jsx-helpers": jsx,
53
+ "jsx-patterns": jsx.concat("patterns"),
54
+ "jsx-patterns-index": jsx.concat("patterns"),
55
+ "css-index": ["syntax"],
56
+ "reset.css": ["preflight", "layers"],
57
+ "global.css": ["globalCss"].concat(css),
58
+ "static.css": ["staticCss", "theme.breakpoints"].concat(css),
59
+ "styles.css": tokens.concat(format),
60
+ "package.json": ["emitPackage"]
61
+ };
62
+ var artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
63
+ if (!paths.length)
64
+ return () => void 0;
65
+ return createMatcher(key, paths.concat(all));
66
+ });
67
+
68
+ // src/diff-config.ts
69
+ var runIfFn = (fn) => typeof fn === "function" ? fn() : fn;
70
+ function diffConfigs(config, prevConfig) {
71
+ const affected = {
72
+ artifacts: /* @__PURE__ */ new Set(),
73
+ hasConfigChanged: false,
74
+ diffs: []
75
+ };
76
+ if (!prevConfig) {
77
+ affected.hasConfigChanged = true;
78
+ return affected;
79
+ }
80
+ const configDiff = microdiff(prevConfig, runIfFn(config));
81
+ if (!configDiff.length) {
82
+ return affected;
83
+ }
84
+ affected.hasConfigChanged = true;
85
+ affected.diffs = configDiff;
86
+ configDiff.forEach((change) => {
87
+ const changePath = change.path.join(".");
88
+ artifactMatchers.forEach((matcher) => {
89
+ const id = matcher(changePath);
90
+ if (!id)
91
+ return;
92
+ if (id === "recipes") {
93
+ const name = dashCase(change.path.slice(1, 3).join("."));
94
+ affected.artifacts.add(name);
95
+ }
96
+ if (id === "patterns") {
97
+ const name = dashCase(change.path.slice(0, 2).join("."));
98
+ affected.artifacts.add(name);
99
+ }
100
+ affected.artifacts.add(id);
101
+ });
102
+ });
103
+ return affected;
104
+ }
105
+
106
+ export {
107
+ diffConfigs
108
+ };
@@ -2,9 +2,7 @@
2
2
  import { mergeAndConcat } from "merge-anything";
3
3
 
4
4
  // src/utils.ts
5
- var isObject = (value) => {
6
- return Object.prototype.toString.call(value) === "[object Object]";
7
- };
5
+ var isObject = (v) => Object.prototype.toString.call(v) === "[object Object]";
8
6
  function mergeWith(target, ...sources) {
9
7
  const customizer = sources.pop();
10
8
  for (const source of sources) {
@@ -0,0 +1,15 @@
1
+ import { ArtifactId, Config } from '@pandacss/types';
2
+ import { Difference } from 'microdiff';
3
+
4
+ interface DiffConfigResult {
5
+ hasConfigChanged: boolean;
6
+ artifacts: Set<ArtifactId>;
7
+ diffs: Difference[];
8
+ }
9
+ type ConfigOrFn = Config | (() => Config);
10
+ /**
11
+ * Diff the two config objects and return the list of affected properties
12
+ */
13
+ declare function diffConfigs(config: ConfigOrFn, prevConfig: Config | undefined): DiffConfigResult;
14
+
15
+ export { type DiffConfigResult, diffConfigs };
@@ -0,0 +1,15 @@
1
+ import { ArtifactId, Config } from '@pandacss/types';
2
+ import { Difference } from 'microdiff';
3
+
4
+ interface DiffConfigResult {
5
+ hasConfigChanged: boolean;
6
+ artifacts: Set<ArtifactId>;
7
+ diffs: Difference[];
8
+ }
9
+ type ConfigOrFn = Config | (() => Config);
10
+ /**
11
+ * Diff the two config objects and return the list of affected properties
12
+ */
13
+ declare function diffConfigs(config: ConfigOrFn, prevConfig: Config | undefined): DiffConfigResult;
14
+
15
+ export { type DiffConfigResult, diffConfigs };
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all2) => {
9
+ for (var name in all2)
10
+ __defProp(target, name, { get: all2[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/diff-config.ts
31
+ var diff_config_exports = {};
32
+ __export(diff_config_exports, {
33
+ diffConfigs: () => diffConfigs
34
+ });
35
+ module.exports = __toCommonJS(diff_config_exports);
36
+ var import_shared = require("@pandacss/shared");
37
+ var import_microdiff = __toESM(require("microdiff"));
38
+
39
+ // src/create-matcher.ts
40
+ function createMatcher(id, patterns) {
41
+ if (!patterns?.length)
42
+ return () => void 0;
43
+ const includePatterns = [];
44
+ const excludePatterns = [];
45
+ const deduped = new Set(patterns);
46
+ deduped.forEach((pattern) => {
47
+ const regexString = pattern.replace(/\*/g, ".*");
48
+ if (pattern.startsWith("!")) {
49
+ excludePatterns.push(regexString.slice(1));
50
+ } else {
51
+ includePatterns.push(regexString);
52
+ }
53
+ });
54
+ const include = new RegExp(includePatterns.join("|"));
55
+ const exclude = new RegExp(excludePatterns.join("|"));
56
+ return (path) => {
57
+ if (excludePatterns.length && exclude.test(path))
58
+ return;
59
+ return include.test(path) ? id : void 0;
60
+ };
61
+ }
62
+
63
+ // src/config-deps.ts
64
+ var all = ["outdir", "forceConsistentTypeExtension", "outExtension"];
65
+ var format = ["syntax", "hash", "prefix", "separator"];
66
+ var tokens = ["utilities", "conditions", "theme.tokens", "theme.semanticTokens", "theme.breakpoints"];
67
+ var jsx = ["jsxFramework", "jsxFactory", "jsxStyleProps", "syntax"];
68
+ var css = ["layers", "optimize", "minify"];
69
+ var common = tokens.concat(jsx, format);
70
+ var artifactConfigDeps = {
71
+ helpers: ["syntax", "jsxFramework"],
72
+ keyframes: ["theme.keyframes", "layers"],
73
+ "design-tokens": ["layers", "!utilities.*.className"].concat(tokens),
74
+ types: ["!utilities.*.className"].concat(common),
75
+ "css-fn": common,
76
+ cva: ["syntax"],
77
+ sva: ["syntax"],
78
+ cx: [],
79
+ "create-recipe": ["separator", "prefix", "hash"],
80
+ "recipes-index": ["theme.recipes", "theme.slotRecipes"],
81
+ recipes: ["theme.recipes", "theme.slotRecipes"],
82
+ "patterns-index": ["syntax", "patterns"],
83
+ patterns: ["syntax", "patterns"],
84
+ "jsx-is-valid-prop": common,
85
+ "jsx-factory": jsx,
86
+ "jsx-helpers": jsx,
87
+ "jsx-patterns": jsx.concat("patterns"),
88
+ "jsx-patterns-index": jsx.concat("patterns"),
89
+ "css-index": ["syntax"],
90
+ "reset.css": ["preflight", "layers"],
91
+ "global.css": ["globalCss"].concat(css),
92
+ "static.css": ["staticCss", "theme.breakpoints"].concat(css),
93
+ "styles.css": tokens.concat(format),
94
+ "package.json": ["emitPackage"]
95
+ };
96
+ var artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
97
+ if (!paths.length)
98
+ return () => void 0;
99
+ return createMatcher(key, paths.concat(all));
100
+ });
101
+
102
+ // src/diff-config.ts
103
+ var runIfFn = (fn) => typeof fn === "function" ? fn() : fn;
104
+ function diffConfigs(config, prevConfig) {
105
+ const affected = {
106
+ artifacts: /* @__PURE__ */ new Set(),
107
+ hasConfigChanged: false,
108
+ diffs: []
109
+ };
110
+ if (!prevConfig) {
111
+ affected.hasConfigChanged = true;
112
+ return affected;
113
+ }
114
+ const configDiff = (0, import_microdiff.default)(prevConfig, runIfFn(config));
115
+ if (!configDiff.length) {
116
+ return affected;
117
+ }
118
+ affected.hasConfigChanged = true;
119
+ affected.diffs = configDiff;
120
+ configDiff.forEach((change) => {
121
+ const changePath = change.path.join(".");
122
+ artifactMatchers.forEach((matcher) => {
123
+ const id = matcher(changePath);
124
+ if (!id)
125
+ return;
126
+ if (id === "recipes") {
127
+ const name = (0, import_shared.dashCase)(change.path.slice(1, 3).join("."));
128
+ affected.artifacts.add(name);
129
+ }
130
+ if (id === "patterns") {
131
+ const name = (0, import_shared.dashCase)(change.path.slice(0, 2).join("."));
132
+ affected.artifacts.add(name);
133
+ }
134
+ affected.artifacts.add(id);
135
+ });
136
+ });
137
+ return affected;
138
+ }
139
+ // Annotate the CommonJS export names for ESM import in node:
140
+ 0 && (module.exports = {
141
+ diffConfigs
142
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ diffConfigs
3
+ } from "./chunk-DQCK3AP6.mjs";
4
+ export {
5
+ diffConfigs
6
+ };
package/dist/index.d.mts CHANGED
@@ -1,14 +1,25 @@
1
- import { P as PathMapping } from './ts-config-paths-3f58b449.js';
2
- export { c as convertTsPathsToRegexes } from './ts-config-paths-3f58b449.js';
3
1
  import * as _pandacss_types from '@pandacss/types';
4
- import { ConfigTsOptions, Config, LoadConfigResult } from '@pandacss/types';
2
+ import { Config, ConfigTsOptions } from '@pandacss/types';
3
+ export { DiffConfigResult, diffConfigs } from './diff-config.mjs';
4
+ import { P as PathMapping } from './ts-config-paths-2lh9mwzL.mjs';
5
+ export { c as convertTsPathsToRegexes } from './ts-config-paths-2lh9mwzL.mjs';
5
6
  import { TSConfig } from 'pkg-types';
6
7
  export { mergeConfigs } from './merge-config.mjs';
8
+ import 'microdiff';
7
9
 
8
- declare function findConfigFile({ cwd, file }: {
10
+ interface ConfigFileOptions {
9
11
  cwd: string;
10
12
  file?: string;
11
- }): string | void;
13
+ }
14
+
15
+ interface BundleConfigResult<T = Config> {
16
+ config: T;
17
+ dependencies: string[];
18
+ path: string;
19
+ }
20
+ declare function bundleConfig(options: ConfigFileOptions): Promise<BundleConfigResult>;
21
+
22
+ declare function findConfig({ cwd, file }: Partial<ConfigFileOptions>): string | undefined;
12
23
 
13
24
  interface GetDepsOptions {
14
25
  filename: string;
@@ -34,27 +45,9 @@ type ExtendableConfig = Extendable<Config>;
34
45
  */
35
46
  declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
36
47
 
37
- interface ConfigFileOptions {
38
- cwd: string;
39
- file?: string;
40
- }
41
48
  /**
42
49
  * Find, load and resolve the final config (including presets)
43
50
  */
44
- declare function loadConfigFile(options: ConfigFileOptions): Promise<LoadConfigResult>;
45
- /**
46
- * Resolve the final config (including presets)
47
- * @pandacss/preset-base: ALWAYS included if NOT using eject: true
48
- * @pandacss/preset-panda: only included by default if no presets
49
- */
50
- declare function resolveConfigFile(result: Awaited<ReturnType<typeof bundleConfigFile>>, cwd: string): Promise<LoadConfigResult>;
51
- /**
52
- * Find and bundle the config file
53
- */
54
- declare function bundleConfigFile(options: ConfigFileOptions): Promise<{
55
- config: _pandacss_types.Config;
56
- path: string;
57
- dependencies: string[];
58
- }>;
51
+ declare function loadConfig(options: ConfigFileOptions): Promise<_pandacss_types.LoadConfigResult>;
59
52
 
60
- export { GetDepsOptions, bundleConfigFile, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, resolveConfigFile };
53
+ export { type BundleConfigResult, type GetDepsOptions, bundleConfig, findConfig, getConfigDependencies, getResolvedConfig, loadConfig };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,25 @@
1
- import { P as PathMapping } from './ts-config-paths-3f58b449.js';
2
- export { c as convertTsPathsToRegexes } from './ts-config-paths-3f58b449.js';
3
1
  import * as _pandacss_types from '@pandacss/types';
4
- import { ConfigTsOptions, Config, LoadConfigResult } from '@pandacss/types';
2
+ import { Config, ConfigTsOptions } from '@pandacss/types';
3
+ export { DiffConfigResult, diffConfigs } from './diff-config.js';
4
+ import { P as PathMapping } from './ts-config-paths-2lh9mwzL.js';
5
+ export { c as convertTsPathsToRegexes } from './ts-config-paths-2lh9mwzL.js';
5
6
  import { TSConfig } from 'pkg-types';
6
7
  export { mergeConfigs } from './merge-config.js';
8
+ import 'microdiff';
7
9
 
8
- declare function findConfigFile({ cwd, file }: {
10
+ interface ConfigFileOptions {
9
11
  cwd: string;
10
12
  file?: string;
11
- }): string | void;
13
+ }
14
+
15
+ interface BundleConfigResult<T = Config> {
16
+ config: T;
17
+ dependencies: string[];
18
+ path: string;
19
+ }
20
+ declare function bundleConfig(options: ConfigFileOptions): Promise<BundleConfigResult>;
21
+
22
+ declare function findConfig({ cwd, file }: Partial<ConfigFileOptions>): string | undefined;
12
23
 
13
24
  interface GetDepsOptions {
14
25
  filename: string;
@@ -34,27 +45,9 @@ type ExtendableConfig = Extendable<Config>;
34
45
  */
35
46
  declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
36
47
 
37
- interface ConfigFileOptions {
38
- cwd: string;
39
- file?: string;
40
- }
41
48
  /**
42
49
  * Find, load and resolve the final config (including presets)
43
50
  */
44
- declare function loadConfigFile(options: ConfigFileOptions): Promise<LoadConfigResult>;
45
- /**
46
- * Resolve the final config (including presets)
47
- * @pandacss/preset-base: ALWAYS included if NOT using eject: true
48
- * @pandacss/preset-panda: only included by default if no presets
49
- */
50
- declare function resolveConfigFile(result: Awaited<ReturnType<typeof bundleConfigFile>>, cwd: string): Promise<LoadConfigResult>;
51
- /**
52
- * Find and bundle the config file
53
- */
54
- declare function bundleConfigFile(options: ConfigFileOptions): Promise<{
55
- config: _pandacss_types.Config;
56
- path: string;
57
- dependencies: string[];
58
- }>;
51
+ declare function loadConfig(options: ConfigFileOptions): Promise<_pandacss_types.LoadConfigResult>;
59
52
 
60
- export { GetDepsOptions, bundleConfigFile, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, resolveConfigFile };
53
+ export { type BundleConfigResult, type GetDepsOptions, bundleConfig, findConfig, getConfigDependencies, getResolvedConfig, loadConfig };
package/dist/index.js CHANGED
@@ -5,9 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
8
+ var __export = (target, all2) => {
9
+ for (var name in all2)
10
+ __defProp(target, name, { get: all2[name], enumerable: true });
11
11
  };
12
12
  var __copyProps = (to, from, except, desc) => {
13
13
  if (from && typeof from === "object" || typeof from === "function") {
@@ -30,29 +30,168 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- bundleConfigFile: () => bundleConfigFile,
33
+ bundleConfig: () => bundleConfig,
34
34
  convertTsPathsToRegexes: () => convertTsPathsToRegexes,
35
- findConfigFile: () => findConfigFile,
35
+ diffConfigs: () => diffConfigs,
36
+ findConfig: () => findConfig,
36
37
  getConfigDependencies: () => getConfigDependencies,
37
38
  getResolvedConfig: () => getResolvedConfig,
38
- loadConfigFile: () => loadConfigFile,
39
- mergeConfigs: () => mergeConfigs,
40
- resolveConfigFile: () => resolveConfigFile
39
+ loadConfig: () => loadConfig,
40
+ mergeConfigs: () => mergeConfigs
41
41
  });
42
42
  module.exports = __toCommonJS(src_exports);
43
43
 
44
+ // src/bundle-config.ts
45
+ var import_error = require("@pandacss/error");
46
+ var import_logger = require("@pandacss/logger");
47
+ var import_bundle_n_require = require("bundle-n-require");
48
+
44
49
  // src/find-config.ts
45
50
  var import_sync = __toESM(require("escalade/sync"));
46
51
  var import_path = require("path");
47
52
  var configs = [".ts", ".js", ".mts", ".mjs", ".cts", ".cjs"];
48
53
  var pandaConfigRegex = new RegExp(`panda.config(${configs.join("|")})$`);
49
54
  var isPandaConfig = (file) => pandaConfigRegex.test(file);
50
- function findConfigFile({ cwd, file }) {
55
+ function findConfig({ cwd, file }) {
56
+ cwd = cwd ?? process.cwd();
51
57
  if (file)
52
58
  return (0, import_path.resolve)(cwd, file);
53
- return (0, import_sync.default)(cwd, (_dir, paths) => {
54
- return paths.find(isPandaConfig);
59
+ const result = (0, import_sync.default)(cwd, (_dir, paths) => paths.find(isPandaConfig));
60
+ return result ?? void 0;
61
+ }
62
+
63
+ // src/bundle-config.ts
64
+ async function bundle(filepath, cwd) {
65
+ const { mod: config, dependencies } = await (0, import_bundle_n_require.bundleNRequire)(filepath, {
66
+ cwd,
67
+ interopDefault: true
68
+ });
69
+ return {
70
+ config: config?.default ?? config,
71
+ dependencies
72
+ };
73
+ }
74
+ async function bundleConfig(options) {
75
+ const { cwd, file } = options;
76
+ const filePath = findConfig({ cwd, file });
77
+ if (!filePath) {
78
+ throw new import_error.ConfigNotFoundError();
79
+ }
80
+ import_logger.logger.debug("config:path", filePath);
81
+ const result = await bundle(filePath, cwd);
82
+ if (typeof result.config !== "object") {
83
+ throw new import_error.ConfigError(`\u{1F4A5} Config must export or return an object.`);
84
+ }
85
+ return {
86
+ ...result,
87
+ config: result.config,
88
+ path: filePath
89
+ };
90
+ }
91
+
92
+ // src/diff-config.ts
93
+ var import_shared = require("@pandacss/shared");
94
+ var import_microdiff = __toESM(require("microdiff"));
95
+
96
+ // src/create-matcher.ts
97
+ function createMatcher(id, patterns) {
98
+ if (!patterns?.length)
99
+ return () => void 0;
100
+ const includePatterns = [];
101
+ const excludePatterns = [];
102
+ const deduped = new Set(patterns);
103
+ deduped.forEach((pattern) => {
104
+ const regexString = pattern.replace(/\*/g, ".*");
105
+ if (pattern.startsWith("!")) {
106
+ excludePatterns.push(regexString.slice(1));
107
+ } else {
108
+ includePatterns.push(regexString);
109
+ }
55
110
  });
111
+ const include = new RegExp(includePatterns.join("|"));
112
+ const exclude = new RegExp(excludePatterns.join("|"));
113
+ return (path2) => {
114
+ if (excludePatterns.length && exclude.test(path2))
115
+ return;
116
+ return include.test(path2) ? id : void 0;
117
+ };
118
+ }
119
+
120
+ // src/config-deps.ts
121
+ var all = ["outdir", "forceConsistentTypeExtension", "outExtension"];
122
+ var format = ["syntax", "hash", "prefix", "separator"];
123
+ var tokens = ["utilities", "conditions", "theme.tokens", "theme.semanticTokens", "theme.breakpoints"];
124
+ var jsx = ["jsxFramework", "jsxFactory", "jsxStyleProps", "syntax"];
125
+ var css = ["layers", "optimize", "minify"];
126
+ var common = tokens.concat(jsx, format);
127
+ var artifactConfigDeps = {
128
+ helpers: ["syntax", "jsxFramework"],
129
+ keyframes: ["theme.keyframes", "layers"],
130
+ "design-tokens": ["layers", "!utilities.*.className"].concat(tokens),
131
+ types: ["!utilities.*.className"].concat(common),
132
+ "css-fn": common,
133
+ cva: ["syntax"],
134
+ sva: ["syntax"],
135
+ cx: [],
136
+ "create-recipe": ["separator", "prefix", "hash"],
137
+ "recipes-index": ["theme.recipes", "theme.slotRecipes"],
138
+ recipes: ["theme.recipes", "theme.slotRecipes"],
139
+ "patterns-index": ["syntax", "patterns"],
140
+ patterns: ["syntax", "patterns"],
141
+ "jsx-is-valid-prop": common,
142
+ "jsx-factory": jsx,
143
+ "jsx-helpers": jsx,
144
+ "jsx-patterns": jsx.concat("patterns"),
145
+ "jsx-patterns-index": jsx.concat("patterns"),
146
+ "css-index": ["syntax"],
147
+ "reset.css": ["preflight", "layers"],
148
+ "global.css": ["globalCss"].concat(css),
149
+ "static.css": ["staticCss", "theme.breakpoints"].concat(css),
150
+ "styles.css": tokens.concat(format),
151
+ "package.json": ["emitPackage"]
152
+ };
153
+ var artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
154
+ if (!paths.length)
155
+ return () => void 0;
156
+ return createMatcher(key, paths.concat(all));
157
+ });
158
+
159
+ // src/diff-config.ts
160
+ var runIfFn = (fn) => typeof fn === "function" ? fn() : fn;
161
+ function diffConfigs(config, prevConfig) {
162
+ const affected = {
163
+ artifacts: /* @__PURE__ */ new Set(),
164
+ hasConfigChanged: false,
165
+ diffs: []
166
+ };
167
+ if (!prevConfig) {
168
+ affected.hasConfigChanged = true;
169
+ return affected;
170
+ }
171
+ const configDiff = (0, import_microdiff.default)(prevConfig, runIfFn(config));
172
+ if (!configDiff.length) {
173
+ return affected;
174
+ }
175
+ affected.hasConfigChanged = true;
176
+ affected.diffs = configDiff;
177
+ configDiff.forEach((change) => {
178
+ const changePath = change.path.join(".");
179
+ artifactMatchers.forEach((matcher) => {
180
+ const id = matcher(changePath);
181
+ if (!id)
182
+ return;
183
+ if (id === "recipes") {
184
+ const name = (0, import_shared.dashCase)(change.path.slice(1, 3).join("."));
185
+ affected.artifacts.add(name);
186
+ }
187
+ if (id === "patterns") {
188
+ const name = (0, import_shared.dashCase)(change.path.slice(0, 2).join("."));
189
+ affected.artifacts.add(name);
190
+ }
191
+ affected.artifacts.add(id);
192
+ });
193
+ });
194
+ return affected;
56
195
  }
57
196
 
58
197
  // src/get-mod-deps.ts
@@ -199,23 +338,11 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compi
199
338
  return { deps, aliases: foundModuleAliases };
200
339
  }
201
340
 
202
- // src/bundle.ts
203
- var import_bundle_n_require = require("bundle-n-require");
204
- async function bundle(filepath, cwd) {
205
- const { mod: config, dependencies } = await (0, import_bundle_n_require.bundleNRequire)(filepath, {
206
- cwd,
207
- interopDefault: true
208
- });
209
- return { config: config?.default ?? config, dependencies };
210
- }
211
-
212
341
  // src/merge-config.ts
213
342
  var import_merge_anything = require("merge-anything");
214
343
 
215
344
  // src/utils.ts
216
- var isObject = (value) => {
217
- return Object.prototype.toString.call(value) === "[object Object]";
218
- };
345
+ var isObject = (v) => Object.prototype.toString.call(v) === "[object Object]";
219
346
  function mergeWith(target, ...sources) {
220
347
  const customizer = sources.pop();
221
348
  for (const source of sources) {
@@ -319,10 +446,8 @@ async function getResolvedConfig(config, cwd) {
319
446
  return mergeConfigs(configs2);
320
447
  }
321
448
 
322
- // src/load-config.ts
323
- var import_error = require("@pandacss/error");
324
- var import_logger = require("@pandacss/logger");
325
- var import_shared = require("@pandacss/shared");
449
+ // src/resolve-config.ts
450
+ var import_shared2 = require("@pandacss/shared");
326
451
 
327
452
  // src/bundled-preset.ts
328
453
  var import_preset_base = require("@pandacss/preset-base");
@@ -338,12 +463,8 @@ var getBundledPreset = (preset) => {
338
463
  return typeof preset === "string" && isBundledPreset(preset) ? bundledPresets[preset] : void 0;
339
464
  };
340
465
 
341
- // src/load-config.ts
342
- async function loadConfigFile(options) {
343
- const result = await bundleConfigFile(options);
344
- return resolveConfigFile(result, options.cwd);
345
- }
346
- async function resolveConfigFile(result, cwd) {
466
+ // src/resolve-config.ts
467
+ async function resolveConfig(result, cwd) {
347
468
  const presets = /* @__PURE__ */ new Set();
348
469
  if (!result.config.eject) {
349
470
  presets.add(import_preset_base.preset);
@@ -357,35 +478,29 @@ async function resolveConfigFile(result, cwd) {
357
478
  }
358
479
  result.config.presets = Array.from(presets);
359
480
  const mergedConfig = await getResolvedConfig(result.config, cwd);
360
- const serialized = (0, import_shared.stringifyJson)(mergedConfig);
361
- const deserialize = () => (0, import_shared.parseJson)(serialized);
362
- return { ...result, serialized, deserialize, config: mergedConfig };
363
- }
364
- async function bundleConfigFile(options) {
365
- const { cwd, file } = options;
366
- const filePath = findConfigFile({ cwd, file });
367
- if (!filePath) {
368
- throw new import_error.ConfigNotFoundError();
369
- }
370
- import_logger.logger.debug("config:path", filePath);
371
- const result = await bundle(filePath, cwd);
372
- if (typeof result.config !== "object") {
373
- throw new import_error.ConfigError(`\u{1F4A5} Config must export or return an object.`);
374
- }
481
+ const serialized = (0, import_shared2.stringifyJson)(mergedConfig);
482
+ const deserialize = () => (0, import_shared2.parseJson)(serialized);
375
483
  return {
376
484
  ...result,
377
- config: result.config,
378
- path: filePath
485
+ serialized,
486
+ deserialize,
487
+ config: mergedConfig
379
488
  };
380
489
  }
490
+
491
+ // src/load-config.ts
492
+ async function loadConfig(options) {
493
+ const result = await bundleConfig(options);
494
+ return resolveConfig(result, options.cwd);
495
+ }
381
496
  // Annotate the CommonJS export names for ESM import in node:
382
497
  0 && (module.exports = {
383
- bundleConfigFile,
498
+ bundleConfig,
384
499
  convertTsPathsToRegexes,
385
- findConfigFile,
500
+ diffConfigs,
501
+ findConfig,
386
502
  getConfigDependencies,
387
503
  getResolvedConfig,
388
- loadConfigFile,
389
- mergeConfigs,
390
- resolveConfigFile
504
+ loadConfig,
505
+ mergeConfigs
391
506
  });
package/dist/index.mjs CHANGED
@@ -1,22 +1,59 @@
1
1
  import {
2
2
  mergeConfigs
3
- } from "./chunk-TCZHQ5GD.mjs";
3
+ } from "./chunk-PROY5XLZ.mjs";
4
+ import {
5
+ diffConfigs
6
+ } from "./chunk-DQCK3AP6.mjs";
4
7
  import {
5
8
  resolveTsPathPattern
6
9
  } from "./chunk-RPIVZP2I.mjs";
7
10
 
11
+ // src/bundle-config.ts
12
+ import { ConfigError, ConfigNotFoundError } from "@pandacss/error";
13
+ import { logger } from "@pandacss/logger";
14
+ import { bundleNRequire } from "bundle-n-require";
15
+
8
16
  // src/find-config.ts
9
17
  import findUp from "escalade/sync";
10
18
  import { resolve } from "path";
11
19
  var configs = [".ts", ".js", ".mts", ".mjs", ".cts", ".cjs"];
12
20
  var pandaConfigRegex = new RegExp(`panda.config(${configs.join("|")})$`);
13
21
  var isPandaConfig = (file) => pandaConfigRegex.test(file);
14
- function findConfigFile({ cwd, file }) {
22
+ function findConfig({ cwd, file }) {
23
+ cwd = cwd ?? process.cwd();
15
24
  if (file)
16
25
  return resolve(cwd, file);
17
- return findUp(cwd, (_dir, paths) => {
18
- return paths.find(isPandaConfig);
26
+ const result = findUp(cwd, (_dir, paths) => paths.find(isPandaConfig));
27
+ return result ?? void 0;
28
+ }
29
+
30
+ // src/bundle-config.ts
31
+ async function bundle(filepath, cwd) {
32
+ const { mod: config, dependencies } = await bundleNRequire(filepath, {
33
+ cwd,
34
+ interopDefault: true
19
35
  });
36
+ return {
37
+ config: config?.default ?? config,
38
+ dependencies
39
+ };
40
+ }
41
+ async function bundleConfig(options) {
42
+ const { cwd, file } = options;
43
+ const filePath = findConfig({ cwd, file });
44
+ if (!filePath) {
45
+ throw new ConfigNotFoundError();
46
+ }
47
+ logger.debug("config:path", filePath);
48
+ const result = await bundle(filePath, cwd);
49
+ if (typeof result.config !== "object") {
50
+ throw new ConfigError(`\u{1F4A5} Config must export or return an object.`);
51
+ }
52
+ return {
53
+ ...result,
54
+ config: result.config,
55
+ path: filePath
56
+ };
20
57
  }
21
58
 
22
59
  // src/get-mod-deps.ts
@@ -144,16 +181,6 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compi
144
181
  return { deps, aliases: foundModuleAliases };
145
182
  }
146
183
 
147
- // src/bundle.ts
148
- import { bundleNRequire } from "bundle-n-require";
149
- async function bundle(filepath, cwd) {
150
- const { mod: config, dependencies } = await bundleNRequire(filepath, {
151
- cwd,
152
- interopDefault: true
153
- });
154
- return { config: config?.default ?? config, dependencies };
155
- }
156
-
157
184
  // src/get-resolved-config.ts
158
185
  async function getResolvedConfig(config, cwd) {
159
186
  const presets = config.presets ?? [];
@@ -173,9 +200,7 @@ async function getResolvedConfig(config, cwd) {
173
200
  return mergeConfigs(configs2);
174
201
  }
175
202
 
176
- // src/load-config.ts
177
- import { ConfigError, ConfigNotFoundError } from "@pandacss/error";
178
- import { logger } from "@pandacss/logger";
203
+ // src/resolve-config.ts
179
204
  import { parseJson, stringifyJson } from "@pandacss/shared";
180
205
 
181
206
  // src/bundled-preset.ts
@@ -192,12 +217,8 @@ var getBundledPreset = (preset) => {
192
217
  return typeof preset === "string" && isBundledPreset(preset) ? bundledPresets[preset] : void 0;
193
218
  };
194
219
 
195
- // src/load-config.ts
196
- async function loadConfigFile(options) {
197
- const result = await bundleConfigFile(options);
198
- return resolveConfigFile(result, options.cwd);
199
- }
200
- async function resolveConfigFile(result, cwd) {
220
+ // src/resolve-config.ts
221
+ async function resolveConfig(result, cwd) {
201
222
  const presets = /* @__PURE__ */ new Set();
202
223
  if (!result.config.eject) {
203
224
  presets.add(presetBase);
@@ -213,32 +234,26 @@ async function resolveConfigFile(result, cwd) {
213
234
  const mergedConfig = await getResolvedConfig(result.config, cwd);
214
235
  const serialized = stringifyJson(mergedConfig);
215
236
  const deserialize = () => parseJson(serialized);
216
- return { ...result, serialized, deserialize, config: mergedConfig };
217
- }
218
- async function bundleConfigFile(options) {
219
- const { cwd, file } = options;
220
- const filePath = findConfigFile({ cwd, file });
221
- if (!filePath) {
222
- throw new ConfigNotFoundError();
223
- }
224
- logger.debug("config:path", filePath);
225
- const result = await bundle(filePath, cwd);
226
- if (typeof result.config !== "object") {
227
- throw new ConfigError(`\u{1F4A5} Config must export or return an object.`);
228
- }
229
237
  return {
230
238
  ...result,
231
- config: result.config,
232
- path: filePath
239
+ serialized,
240
+ deserialize,
241
+ config: mergedConfig
233
242
  };
234
243
  }
244
+
245
+ // src/load-config.ts
246
+ async function loadConfig(options) {
247
+ const result = await bundleConfig(options);
248
+ return resolveConfig(result, options.cwd);
249
+ }
235
250
  export {
236
- bundleConfigFile,
251
+ bundleConfig,
237
252
  convertTsPathsToRegexes,
238
- findConfigFile,
253
+ diffConfigs,
254
+ findConfig,
239
255
  getConfigDependencies,
240
256
  getResolvedConfig,
241
- loadConfigFile,
242
- mergeConfigs,
243
- resolveConfigFile
257
+ loadConfig,
258
+ mergeConfigs
244
259
  };
@@ -26,9 +26,7 @@ module.exports = __toCommonJS(merge_config_exports);
26
26
  var import_merge_anything = require("merge-anything");
27
27
 
28
28
  // src/utils.ts
29
- var isObject = (value) => {
30
- return Object.prototype.toString.call(value) === "[object Object]";
31
- };
29
+ var isObject = (v) => Object.prototype.toString.call(v) === "[object Object]";
32
30
  function mergeWith(target, ...sources) {
33
31
  const customizer = sources.pop();
34
32
  for (const source of sources) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mergeConfigs
3
- } from "./chunk-TCZHQ5GD.mjs";
3
+ } from "./chunk-PROY5XLZ.mjs";
4
4
  export {
5
5
  mergeConfigs
6
6
  };
@@ -1,4 +1,4 @@
1
- import { P as PathMapping } from './ts-config-paths-3f58b449.js';
1
+ import { P as PathMapping } from './ts-config-paths-2lh9mwzL.mjs';
2
2
 
3
3
  /**
4
4
  * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/index.ts#LL231C57-L231C57
@@ -1,4 +1,4 @@
1
- import { P as PathMapping } from './ts-config-paths-3f58b449.js';
1
+ import { P as PathMapping } from './ts-config-paths-2lh9mwzL.js';
2
2
 
3
3
  /**
4
4
  * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/index.ts#LL231C57-L231C57
@@ -7,4 +7,4 @@ interface PathMapping {
7
7
  */
8
8
  declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
9
9
 
10
- export { PathMapping as P, convertTsPathsToRegexes as c };
10
+ export { type PathMapping as P, convertTsPathsToRegexes as c };
@@ -0,0 +1,10 @@
1
+ interface PathMapping {
2
+ pattern: RegExp;
3
+ paths: string[];
4
+ }
5
+ /**
6
+ * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
7
+ */
8
+ declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
9
+
10
+ export { type PathMapping as P, convertTsPathsToRegexes as c };
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "0.23.0",
3
+ "version": "0.24.1",
4
4
  "description": "Find and load panda config",
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
9
  "sideEffects": false,
10
+ "homepage": "https://panda-css.com",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/chakra-ui/panda.git",
14
+ "directory": "packages/config"
15
+ },
10
16
  "publishConfig": {
11
17
  "access": "public"
12
18
  },
@@ -29,6 +35,15 @@
29
35
  "default": "./dist/merge-config.mjs"
30
36
  }
31
37
  },
38
+ "./diff": {
39
+ "source": "./src/diff-config.ts",
40
+ "types": "./dist/diff-config.d.ts",
41
+ "require": "./dist/diff-config.js",
42
+ "import": {
43
+ "types": "./dist/diff-config.d.mts",
44
+ "default": "./dist/diff-config.mjs"
45
+ }
46
+ },
32
47
  "./ts-path": {
33
48
  "source": "./src/resolve-ts-path-pattern.ts",
34
49
  "types": "./dist/resolve-ts-path-pattern.d.ts",
@@ -48,20 +63,21 @@
48
63
  "escalade": "3.1.1",
49
64
  "jiti": "^1.19.1",
50
65
  "merge-anything": "^5.1.7",
66
+ "microdiff": "^1.3.2",
51
67
  "typescript": "^5.3.3",
52
- "@pandacss/error": "0.23.0",
53
- "@pandacss/logger": "0.23.0",
54
- "@pandacss/preset-base": "0.23.0",
55
- "@pandacss/preset-panda": "0.23.0",
56
- "@pandacss/shared": "0.23.0",
57
- "@pandacss/types": "0.23.0"
68
+ "@pandacss/error": "0.24.1",
69
+ "@pandacss/logger": "0.24.1",
70
+ "@pandacss/preset-base": "0.24.1",
71
+ "@pandacss/preset-panda": "0.24.1",
72
+ "@pandacss/shared": "0.24.1",
73
+ "@pandacss/types": "0.24.1"
58
74
  },
59
75
  "devDependencies": {
60
76
  "pkg-types": "1.0.3"
61
77
  },
62
78
  "scripts": {
63
- "build": "pnpm tsup src/index.ts src/merge-config.ts src/resolve-ts-path-pattern.ts --format=esm,cjs --shims --dts",
64
- "build-fast": "pnpm tsup src/index.ts src/merge-config.ts src/resolve-ts-path-pattern.ts --format=esm,cjs --shims --no-dts",
79
+ "build": "pnpm tsup --dts",
80
+ "build-fast": "pnpm tsup --no-dts",
65
81
  "dev": "pnpm build-fast --watch"
66
82
  }
67
83
  }