@pandacss/config 2.0.0-beta.1 → 2.0.0-beta.11

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,13 +1,9 @@
1
- // src/error.ts
2
- var PandaError = class extends Error {
3
- code;
4
- hint;
5
- constructor(code, message, opts) {
6
- super(message, { cause: opts?.cause });
7
- this.code = `ERR_PANDA_${code}`;
8
- this.hint = opts?.hint;
9
- }
10
- };
1
+ import {
2
+ PandaError,
3
+ clone,
4
+ isPlainObject,
5
+ omitKeys
6
+ } from "./chunk-R4R5RHIS.js";
11
7
 
12
8
  // src/sources.ts
13
9
  var sectionKeySet = /* @__PURE__ */ new Set([
@@ -22,7 +18,6 @@ var sectionKeySet = /* @__PURE__ */ new Set([
22
18
  "staticCss",
23
19
  "themes"
24
20
  ]);
25
- var omitKeys = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
26
21
  var tokenKeys = /* @__PURE__ */ new Set(["description", "extensions", "type", "value", "deprecated"]);
27
22
  var directFieldSections = /* @__PURE__ */ new Set(["patterns", "utilities"]);
28
23
  var themeEntryKeys = /* @__PURE__ */ new Set([
@@ -101,30 +96,6 @@ function shouldTrackThemePath(rest, value, current) {
101
96
  if (key === "containerNames" || key === "colorPalette") return rest.length <= 2;
102
97
  return rest.length <= 2;
103
98
  }
104
- function isPlainObject(value) {
105
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
106
- const proto = Object.getPrototypeOf(value);
107
- return proto === Object.prototype || proto === null;
108
- }
109
-
110
- // src/shared.ts
111
- var omitKeys2 = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
112
- function isPlainObject2(value) {
113
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
114
- const proto = Object.getPrototypeOf(value);
115
- return proto === Object.prototype || proto === null;
116
- }
117
- function clone(value) {
118
- if (Array.isArray(value)) return value.map((item) => clone(item));
119
- if (isPlainObject2(value)) {
120
- const result = {};
121
- for (const [key, item] of Object.entries(value)) {
122
- if (item !== void 0 && !omitKeys2.has(key)) result[key] = clone(item);
123
- }
124
- return result;
125
- }
126
- return value;
127
- }
128
99
 
129
100
  // src/merge.ts
130
101
  var sectionKeys = [
@@ -154,13 +125,13 @@ function mergeConfigs(configs, tracker) {
154
125
  const config = tracker ? configs[index].config : configs[index];
155
126
  const context = tracker ? { tracker, sourceId: index, path: [] } : void 0;
156
127
  for (const [key, value] of Object.entries(config)) {
157
- if (value === void 0 || sectionKeySet2.has(key) || runtimeOnlyKeys.has(key) || omitKeys2.has(key)) continue;
128
+ if (value === void 0 || sectionKeySet2.has(key) || runtimeOnlyKeys.has(key) || omitKeys.has(key)) continue;
158
129
  result[key] = clone(value);
159
130
  context?.tracker.record([key], context.sourceId, "replace");
160
131
  }
161
132
  for (const key of sectionKeys) {
162
133
  const section = config[key];
163
- if (isPlainObject2(section)) mergeSectionInto(key, sections[key], section, context);
134
+ if (isPlainObject(section)) mergeSectionInto(key, sections[key], section, context);
164
135
  }
165
136
  }
166
137
  for (const key of sectionKeys) {
@@ -172,15 +143,15 @@ function mergeConfigs(configs, tracker) {
172
143
  function mergeSectionInto(sectionName, target, section, context) {
173
144
  const childContext = context && { ...context, path: [sectionName] };
174
145
  for (const [key, value] of Object.entries(section)) {
175
- if (key === "extend" || value === void 0 || omitKeys2.has(key)) continue;
146
+ if (key === "extend" || value === void 0 || omitKeys.has(key)) continue;
176
147
  mergeValue(target, key, value, "replace", childContext);
177
148
  }
178
149
  if (section.extend === void 0) return;
179
- if (!isPlainObject2(section.extend)) {
150
+ if (!isPlainObject(section.extend)) {
180
151
  throw new PandaError("CONFIG_ERROR", `\u{1F4A5} Config section \`${sectionName}.extend\` must be an object.`);
181
152
  }
182
153
  for (const [key, value] of Object.entries(section.extend)) {
183
- if (value === void 0 || omitKeys2.has(key)) continue;
154
+ if (value === void 0 || omitKeys.has(key)) continue;
184
155
  mergeValue(target, key, value, "concat", childContext);
185
156
  }
186
157
  }
@@ -192,11 +163,11 @@ function mergeValue(target, key, value, arrayMode, context) {
192
163
  recordSource(context, path, value, current, arrayMode === "concat" ? "append" : "replace");
193
164
  return;
194
165
  }
195
- if (isPlainObject2(current) && isPlainObject2(value)) {
166
+ if (isPlainObject(current) && isPlainObject(value)) {
196
167
  recordSource(context, path, value, current, "append");
197
168
  const childContext = context && path ? { ...context, path } : void 0;
198
169
  for (const [childKey, childValue] of Object.entries(value)) {
199
- if (childValue !== void 0 && !omitKeys2.has(childKey))
170
+ if (childValue !== void 0 && !omitKeys.has(childKey))
200
171
  mergeValue(current, childKey, childValue, arrayMode, childContext);
201
172
  }
202
173
  return;
@@ -210,7 +181,7 @@ function normalizeNestedTokens(tokens, tracker) {
210
181
  while (stack.length > 0) {
211
182
  const current = stack.pop();
212
183
  for (const [key, value] of Object.entries(current.value)) {
213
- if (!isPlainObject2(value)) continue;
184
+ if (!isPlainObject(value)) continue;
214
185
  if (isValidToken(value)) {
215
186
  normalizeToken(value, tracker, current.path.concat(key));
216
187
  } else {
@@ -243,8 +214,6 @@ function isValidToken(token) {
243
214
  }
244
215
 
245
216
  export {
246
- PandaError,
247
- isPlainObject2 as isPlainObject,
248
217
  mergeConfigsWithSources,
249
218
  mergeConfigs
250
219
  };
@@ -0,0 +1,73 @@
1
+ // src/error.ts
2
+ var PandaError = class extends Error {
3
+ code;
4
+ hint;
5
+ diagnostics;
6
+ constructor(code, message, opts) {
7
+ super(message, { cause: opts?.cause });
8
+ this.code = `ERR_PANDA_${code}`;
9
+ this.hint = opts?.hint;
10
+ this.diagnostics = opts?.diagnostics;
11
+ }
12
+ };
13
+ function createConfigError(message, diagnostics) {
14
+ return new PandaError("CONFIG_ERROR", `\u{1F4A5} ${message}`, { diagnostics });
15
+ }
16
+ function createConfigDiagnostic(code, message, help) {
17
+ return {
18
+ code,
19
+ message,
20
+ severity: "error",
21
+ category: "config",
22
+ ...help ? { help } : {}
23
+ };
24
+ }
25
+
26
+ // src/shared.ts
27
+ var omitKeys = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
28
+ function isPlainObject(value) {
29
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
30
+ const proto = Object.getPrototypeOf(value);
31
+ return proto === Object.prototype || proto === null;
32
+ }
33
+ function clone(value) {
34
+ if (Array.isArray(value)) {
35
+ const len = value.length;
36
+ const out2 = new Array(len);
37
+ for (let i = 0; i < len; i++) out2[i] = clone(value[i]);
38
+ return out2;
39
+ }
40
+ if (!isPlainObject(value)) return value;
41
+ const source = value;
42
+ const out = {};
43
+ const keys = Object.keys(source);
44
+ for (let i = 0; i < keys.length; i++) {
45
+ const key = keys[i];
46
+ if (omitKeys.has(key)) continue;
47
+ const item = source[key];
48
+ if (item !== void 0) out[key] = clone(item);
49
+ }
50
+ return out;
51
+ }
52
+ function ensureConfigObject(config, name) {
53
+ if (isPlainObject(config)) return config;
54
+ throw new PandaError("CONFIG_ERROR", `\u{1F4A5} Preset ${JSON.stringify(name)} must resolve to an object.`);
55
+ }
56
+ function errorMessage(error) {
57
+ return error instanceof Error ? error.message : String(error);
58
+ }
59
+ function compact(value) {
60
+ return Object.fromEntries(Object.entries(value ?? {}).filter(([, item]) => item !== void 0));
61
+ }
62
+
63
+ export {
64
+ PandaError,
65
+ createConfigError,
66
+ createConfigDiagnostic,
67
+ omitKeys,
68
+ isPlainObject,
69
+ clone,
70
+ ensureConfigObject,
71
+ errorMessage,
72
+ compact
73
+ };
@@ -1,3 +1,7 @@
1
+ import {
2
+ compact
3
+ } from "./chunk-R4R5RHIS.js";
4
+
1
5
  // src/serialize.ts
2
6
  import {
3
7
  normalizeImportMap
@@ -5,7 +9,6 @@ import {
5
9
  import { stringify } from "javascript-stringify";
6
10
 
7
11
  // src/hooks.ts
8
- var compact = (value) => Object.fromEntries(Object.entries(value ?? {}).filter(([, item]) => item !== void 0));
9
12
  function serializeHooks(config, callbacks, sanitize2, hashCallbackSource2) {
10
13
  const parserBefore = collectPluginHookHandlers(config, "parser:before").map((entry, index) => {
11
14
  const hook = normalizeHook(entry.value, "parser:before");
@@ -47,7 +50,6 @@ function normalizeHook(value, name) {
47
50
  }
48
51
 
49
52
  // src/serialize.ts
50
- var compact2 = (value) => Object.fromEntries(Object.entries(value ?? {}).filter(([, item]) => item !== void 0));
51
53
  var runtimeOnlyKeys = /* @__PURE__ */ new Set(["hooks", "plugins", "presets", "name"]);
52
54
  function createConfigSnapshot(config) {
53
55
  const callbacks = {};
@@ -94,7 +96,7 @@ function attachPatternCodegenSource(serialized, config) {
94
96
  if (!patterns || !serializedPatterns) return;
95
97
  for (const [name, pattern] of Object.entries(patterns)) {
96
98
  if (typeof pattern?.transform !== "function") continue;
97
- const source = stringify(compact2({ transform: pattern.transform, defaultValues: pattern.defaultValues })) ?? "";
99
+ const source = stringify(compact({ transform: pattern.transform, defaultValues: pattern.defaultValues })) ?? "";
98
100
  if (serializedPatterns[name]) serializedPatterns[name].codegenSource = source;
99
101
  }
100
102
  }
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { SerializedConfig, ProjectCallbacks, ProjectHooks, ConfigSnapshot, DiffConfigResult } from '@pandacss/compiler-shared';
1
+ import { DesignSystemManifest, CodegenOverlay, Diagnostic, SerializedConfig, ProjectCallbacks, ProjectHooks, ConfigSnapshot, DiffConfigResult, DesignSystemManifestImportMap } from '@pandacss/compiler-shared';
2
2
  export { DiffConfigResult } from '@pandacss/compiler-shared';
3
- import { HookRegistry, Config } from '@pandacss/types';
4
- import { C as ConfigSources } from './merge-Bt4BM1CH.js';
5
- export { a as ConfigSourceEntry, m as mergeConfigs } from './merge-Bt4BM1CH.js';
3
+ import { HookRegistry, Config, UserConfig } from '@pandacss/types';
4
+ import { C as ConfigSources } from './merge-Bbdo_XHY.js';
5
+ export { a as ConfigSourceEntry, m as mergeConfigs } from './merge-Bbdo_XHY.js';
6
6
  export { ConfigSnapshot, createConfigSnapshot } from './serialize.js';
7
7
 
8
8
  interface PluginHookEntry<Name extends keyof HookRegistry> {
@@ -13,8 +13,49 @@ interface PluginHookEntry<Name extends keyof HookRegistry> {
13
13
  type HostHooks = {
14
14
  'codegen:prepare'?: Array<PluginHookEntry<'codegen:prepare'>>;
15
15
  'codegen:done'?: Array<PluginHookEntry<'codegen:done'>>;
16
+ 'cssgen:done'?: Array<PluginHookEntry<'cssgen:done'>>;
16
17
  };
17
18
 
19
+ interface DesignSystemOverlayInput {
20
+ authored: {
21
+ conditions: boolean;
22
+ breakpoints: boolean;
23
+ utilities: boolean;
24
+ tokens: boolean;
25
+ };
26
+ compatible: boolean;
27
+ }
28
+
29
+ interface ResolvedDesignSystem {
30
+ name: string;
31
+ specifier: string;
32
+ manifest: DesignSystemManifest;
33
+ manifestPath: string;
34
+ buildInfoPath: string;
35
+ files: string[];
36
+ tokenPaths: string[];
37
+ recipeNames: string[];
38
+ patternNames: string[];
39
+ importMap?: DesignSystemManifest['importMap'];
40
+ packageExports?: Record<string, unknown>;
41
+ optionMismatch?: string[];
42
+ }
43
+ interface DesignSystemMetadata {
44
+ designSystem?: ResolvedDesignSystem[];
45
+ userRecipeNames?: string[];
46
+ userPatternNames?: string[];
47
+ overlayInput?: DesignSystemOverlayInput;
48
+ }
49
+ declare function buildCodegenOverlay(metadata: DesignSystemMetadata | undefined): CodegenOverlay | undefined;
50
+ interface DesignSystemArtifactConflict {
51
+ name: string;
52
+ recipes: string[];
53
+ patterns: string[];
54
+ }
55
+ declare function collectArtifactConflicts(metadata: DesignSystemMetadata | undefined): DesignSystemArtifactConflict[];
56
+ declare function collectExportMissingDiagnostics(metadata: DesignSystemMetadata | undefined): Diagnostic[];
57
+ declare function collectNameCollisionDiagnostics(metadata: DesignSystemMetadata | undefined): Diagnostic[];
58
+
18
59
  interface LoadConfigOptions {
19
60
  cwd: string;
20
61
  /** Explicit config file path (relative to `cwd`); otherwise discovered upward. */
@@ -37,6 +78,11 @@ interface LoadConfigResult {
37
78
  dependencies: string[];
38
79
  metadata?: {
39
80
  sources?: ConfigSources;
81
+ designSystem?: ResolvedDesignSystem[];
82
+ userTokenPaths?: string[];
83
+ userRecipeNames?: string[];
84
+ userPatternNames?: string[];
85
+ overlayInput?: DesignSystemOverlayInput;
40
86
  };
41
87
  }
42
88
 
@@ -81,4 +127,82 @@ interface BundleConfigResult<T = Config> {
81
127
  */
82
128
  declare function bundleConfig<T extends Config = Config>(filepath: string, cwd: string): Promise<BundleConfigResult<T>>;
83
129
 
84
- export { type BundleConfigResult, ConfigSources, type LoadConfigOptions, type LoadConfigResult, bundleConfig, diffConfig, findConfig, loadConfig };
130
+ declare function readPandaVersion(): string | undefined;
131
+ declare function getPandaMajorRange(): string | undefined;
132
+ declare function isStampablePandaRange(range: string | undefined): range is string;
133
+
134
+ interface CompilePresetResult {
135
+ code: string;
136
+ dependencies: string[];
137
+ }
138
+ interface CompilePresetOptions {
139
+ configPath: string;
140
+ cwd: string;
141
+ }
142
+ declare function compilePreset(options: CompilePresetOptions): Promise<CompilePresetResult>;
143
+
144
+ interface PackageIdentity {
145
+ name: string;
146
+ version?: string;
147
+ pandaPeer?: string;
148
+ packagePath: string;
149
+ /** package.json `"files"` when it's a string array; used for lib fallback publish checks. */
150
+ publishFiles?: string[];
151
+ }
152
+ declare function resolvePublishedPandaRange(range: string | undefined, currentVersion: string | undefined): string;
153
+ declare function readPackageIdentity(cwd: string): PackageIdentity;
154
+ declare function defaultImportMap(name: string): DesignSystemManifestImportMap;
155
+ interface SyncExportsResult {
156
+ changed: boolean;
157
+ json: string;
158
+ /** Existing subpaths whose value differed from the one Panda wrote (overwritten). */
159
+ conflicts: string[];
160
+ }
161
+ interface SyncExportsOptions {
162
+ packageJson: string;
163
+ entries: Record<string, unknown>;
164
+ }
165
+ declare function syncExports(options: SyncExportsOptions): SyncExportsResult;
166
+
167
+ interface FilterPublishableLibFilesOptions {
168
+ /** Fallback paths relative to the lib outdir (same form as manifest `files`). */
169
+ files: string[];
170
+ packageRoot: string;
171
+ /** Lib outdir — resolve `files` entries from here. */
172
+ outRoot: string;
173
+ /** package.json `"files"`; omit when the whole package is packed. */
174
+ publishFiles?: string[];
175
+ }
176
+ interface FilterPublishableLibFilesResult {
177
+ files: string[];
178
+ unpublished: string[];
179
+ }
180
+ /**
181
+ * Drop inferred lib fallback paths that would not ship in the npm tarball when
182
+ * package.json `"files"` is set. Explicit `--files` should skip this filter.
183
+ *
184
+ * Runs once at `panda lib` time (not on consume/cssgen). Patterns are compiled
185
+ * once per call; the common `"files": ["dist"]` case is prefix-only.
186
+ */
187
+ declare function filterPublishableLibFiles(options: FilterPublishableLibFilesOptions): FilterPublishableLibFilesResult;
188
+ /** Read package.json `"files"` when it is a non-empty string array. */
189
+ declare function readPublishFilesField(value: unknown): string[] | undefined;
190
+
191
+ interface SmartIncludeResult {
192
+ include: string[];
193
+ excludes: string[];
194
+ changed: boolean;
195
+ }
196
+ declare function resolveSmartInclude(include: string[], cwd: string, deps: Set<string>): SmartIncludeResult;
197
+ declare function mergeExcludes(existing: string[] | undefined, additions: string[]): string[];
198
+
199
+ declare function collectTokenPaths(config: Pick<UserConfig, 'theme'> | undefined): string[];
200
+
201
+ declare function toPosixPath(path: string): string;
202
+ declare function toPosixRelative(from: string, to: string): string;
203
+ declare function toRelativeKey(key: string, cwd: string): string;
204
+
205
+ declare function collectRecipeNames(config: Pick<UserConfig, 'theme'> | undefined): string[];
206
+ declare function collectPatternNames(config: Pick<UserConfig, 'patterns'> | undefined): string[];
207
+
208
+ export { type BundleConfigResult, type CompilePresetOptions, type CompilePresetResult, ConfigSources, type DesignSystemArtifactConflict, type DesignSystemMetadata, type DesignSystemOverlayInput, type FilterPublishableLibFilesOptions, type FilterPublishableLibFilesResult, type HostHooks, type LoadConfigOptions, type LoadConfigResult, type PackageIdentity, type ResolvedDesignSystem, type SyncExportsOptions, type SyncExportsResult, buildCodegenOverlay, bundleConfig, collectArtifactConflicts, collectExportMissingDiagnostics, collectNameCollisionDiagnostics, collectPatternNames, collectRecipeNames, collectTokenPaths, compilePreset, defaultImportMap, diffConfig, filterPublishableLibFiles, findConfig, getPandaMajorRange, isStampablePandaRange, loadConfig, mergeExcludes, readPackageIdentity, readPandaVersion, readPublishFilesField, resolvePublishedPandaRange, resolveSmartInclude, syncExports, toPosixPath, toPosixRelative, toRelativeKey };