@pandacss/config 2.0.0-beta.9 → 2.0.0

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.
@@ -14,7 +14,6 @@ var sectionKeySet = /* @__PURE__ */ new Set([
14
14
  "globalCss",
15
15
  "globalVars",
16
16
  "globalFontface",
17
- "globalPositionTry",
18
17
  "staticCss",
19
18
  "themes"
20
19
  ]);
@@ -28,7 +27,8 @@ var themeEntryKeys = /* @__PURE__ */ new Set([
28
27
  "layerStyles",
29
28
  "recipes",
30
29
  "slotRecipes",
31
- "textStyles"
30
+ "textStyles",
31
+ "viewTransitions"
32
32
  ]);
33
33
  var SourceTracker = class {
34
34
  sources;
@@ -106,13 +106,24 @@ var sectionKeys = [
106
106
  "globalCss",
107
107
  "globalVars",
108
108
  "globalFontface",
109
- "globalPositionTry",
110
109
  "staticCss",
111
110
  "themes"
112
111
  ];
113
112
  var sectionKeySet2 = new Set(sectionKeys);
114
113
  var runtimeOnlyKeys = /* @__PURE__ */ new Set(["presets", "plugins", "hooks", "name", "extend"]);
115
114
  var tokenKeys2 = /* @__PURE__ */ new Set(["description", "extensions", "type", "value", "deprecated"]);
115
+ var themeRegistryKeys = /* @__PURE__ */ new Set([
116
+ "tokens",
117
+ "semanticTokens",
118
+ "keyframes",
119
+ "recipes",
120
+ "slotRecipes",
121
+ "textStyles",
122
+ "layerStyles",
123
+ "animationStyles",
124
+ "viewTransitions",
125
+ "positionTry"
126
+ ]);
116
127
  function mergeConfigsWithSources(configs) {
117
128
  const tracker = new SourceTracker(configs.map((item) => item.source));
118
129
  const config = mergeConfigs(configs, tracker);
@@ -131,7 +142,9 @@ function mergeConfigs(configs, tracker) {
131
142
  }
132
143
  for (const key of sectionKeys) {
133
144
  const section = config[key];
134
- if (isPlainObject(section)) mergeSectionInto(key, sections[key], section, context);
145
+ if (!isPlainObject(section)) continue;
146
+ applySectionBase(key, sections[key], section, context);
147
+ applySectionExtend(key, sections[key], section, context);
135
148
  }
136
149
  }
137
150
  for (const key of sectionKeys) {
@@ -140,21 +153,45 @@ function mergeConfigs(configs, tracker) {
140
153
  if (result.theme?.tokens) normalizeNestedTokens(result.theme.tokens, tracker);
141
154
  return result;
142
155
  }
143
- function mergeSectionInto(sectionName, target, section, context) {
156
+ function applySectionBase(sectionName, target, section, context) {
144
157
  const childContext = context && { ...context, path: [sectionName] };
145
158
  for (const [key, value] of Object.entries(section)) {
146
159
  if (key === "extend" || value === void 0 || omitKeys.has(key)) continue;
147
- mergeValue(target, key, value, "replace", childContext);
160
+ if (isRegistry(sectionName, key, value)) {
161
+ replaceRegistryEntries(target, key, value, childContext);
162
+ } else {
163
+ replaceValue(target, key, value, childContext);
164
+ }
165
+ }
166
+ }
167
+ function isRegistry(sectionName, key, value) {
168
+ return sectionName === "theme" && themeRegistryKeys.has(key) && isPlainObject(value);
169
+ }
170
+ function replaceRegistryEntries(target, key, registry, context) {
171
+ const entries = isPlainObject(target[key]) ? target[key] : target[key] = {};
172
+ const entryContext = context && { ...context, path: context.path.concat(key) };
173
+ for (const [name, value] of Object.entries(registry)) {
174
+ if (value === void 0 || omitKeys.has(name)) continue;
175
+ replaceValue(entries, name, value, entryContext);
148
176
  }
177
+ }
178
+ function applySectionExtend(sectionName, target, section, context) {
149
179
  if (section.extend === void 0) return;
150
180
  if (!isPlainObject(section.extend)) {
151
181
  throw new PandaError("CONFIG_ERROR", `\u{1F4A5} Config section \`${sectionName}.extend\` must be an object.`);
152
182
  }
183
+ const childContext = context && { ...context, path: [sectionName] };
153
184
  for (const [key, value] of Object.entries(section.extend)) {
154
185
  if (value === void 0 || omitKeys.has(key)) continue;
155
186
  mergeValue(target, key, value, "concat", childContext);
156
187
  }
157
188
  }
189
+ function replaceValue(target, key, value, context) {
190
+ const path = context?.path.concat(key);
191
+ recordSource(context, path, value, target[key], "replace");
192
+ target[key] = clone(value);
193
+ recordNestedSources(context, path, value);
194
+ }
158
195
  function mergeValue(target, key, value, arrayMode, context) {
159
196
  const current = target[key];
160
197
  const path = context?.path.concat(key);
@@ -1,5 +1,7 @@
1
1
  import {
2
- compact
2
+ compact,
3
+ createConfigError,
4
+ isPlainObject
3
5
  } from "./chunk-R4R5RHIS.js";
4
6
 
5
7
  // src/serialize.ts
@@ -49,9 +51,55 @@ function normalizeHook(value, name) {
49
51
  return { filter: record.filter, handler: record.handler };
50
52
  }
51
53
 
54
+ // src/utility-global-vars.ts
55
+ function mergeUtilityGlobalVars(config) {
56
+ const utilities = config.utilities;
57
+ if (!isPlainObject(utilities)) return config;
58
+ const merged = {};
59
+ const owners = /* @__PURE__ */ new Map();
60
+ let found = false;
61
+ const nextUtilities = {};
62
+ for (const [name, utility] of Object.entries(utilities)) {
63
+ if (!isPlainObject(utility) || !isPlainObject(utility.globalVars)) {
64
+ nextUtilities[name] = utility;
65
+ continue;
66
+ }
67
+ found = true;
68
+ const { globalVars, ...rest } = utility;
69
+ nextUtilities[name] = rest;
70
+ for (const [key, definition] of Object.entries(globalVars)) {
71
+ const previous = merged[key];
72
+ if (previous !== void 0 && !isSameDefinition(previous, definition)) {
73
+ throw createConfigError(
74
+ `The \`${owners.get(key)}\` and \`${name}\` utilities both register \`${key}\`, with different definitions.
75
+ A CSS variable has one registration for the whole document, so share one definition between them.`
76
+ );
77
+ }
78
+ merged[key] = definition;
79
+ owners.set(key, name);
80
+ }
81
+ }
82
+ if (!found) return config;
83
+ const configVars = isPlainObject(config.globalVars) ? config.globalVars : {};
84
+ return {
85
+ ...config,
86
+ utilities: nextUtilities,
87
+ globalVars: { ...merged, ...configVars },
88
+ utilityGlobalVars: Object.fromEntries(owners)
89
+ };
90
+ }
91
+ function isSameDefinition(a, b) {
92
+ if (a === b) return true;
93
+ if (!isPlainObject(a) || !isPlainObject(b)) return false;
94
+ const keys = Object.keys(a);
95
+ if (keys.length !== Object.keys(b).length) return false;
96
+ return keys.every((key) => a[key] === b[key]);
97
+ }
98
+
52
99
  // src/serialize.ts
53
100
  var runtimeOnlyKeys = /* @__PURE__ */ new Set(["hooks", "plugins", "presets", "name"]);
54
- function createConfigSnapshot(config) {
101
+ function createConfigSnapshot(input) {
102
+ const config = mergeUtilityGlobalVars(input);
55
103
  const callbacks = {};
56
104
  const hooks = serializeHooks(config, callbacks, sanitize, hashCallbackSource);
57
105
  const serialized = {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { DesignSystemManifest, SerializedConfig, ProjectCallbacks, ProjectHooks, ConfigSnapshot, DiffConfigResult, DesignSystemManifestImportMap } 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
3
  import { HookRegistry, Config, UserConfig } from '@pandacss/types';
4
- import { C as ConfigSources } from './merge-DiBpncUC.js';
5
- export { a as ConfigSourceEntry, m as mergeConfigs } from './merge-DiBpncUC.js';
4
+ import { C as ConfigSources } from './merge-EXcM0jFd.js';
5
+ export { a as ConfigSourceEntry, m as mergeConfigs } from './merge-EXcM0jFd.js';
6
6
  export { ConfigSnapshot, createConfigSnapshot } from './serialize.js';
7
7
 
8
8
  interface PluginHookEntry<Name extends keyof HookRegistry> {
@@ -16,6 +16,16 @@ type HostHooks = {
16
16
  'cssgen:done'?: Array<PluginHookEntry<'cssgen:done'>>;
17
17
  };
18
18
 
19
+ interface DesignSystemOverlayInput {
20
+ authored: {
21
+ conditions: boolean;
22
+ breakpoints: boolean;
23
+ utilities: boolean;
24
+ tokens: boolean;
25
+ };
26
+ compatible: boolean;
27
+ }
28
+
19
29
  interface ResolvedDesignSystem {
20
30
  name: string;
21
31
  specifier: string;
@@ -24,11 +34,27 @@ interface ResolvedDesignSystem {
24
34
  buildInfoPath: string;
25
35
  files: string[];
26
36
  tokenPaths: string[];
37
+ recipeNames: string[];
38
+ patternNames: string[];
27
39
  importMap?: DesignSystemManifest['importMap'];
28
- /** Class-name options (`hash`/`prefix`/`separator`) the consumer overrode away
29
- * from this design system's, which would break its prebuilt class names. */
40
+ packageExports?: Record<string, unknown>;
30
41
  optionMismatch?: string[];
31
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[];
32
58
 
33
59
  interface LoadConfigOptions {
34
60
  cwd: string;
@@ -54,6 +80,9 @@ interface LoadConfigResult {
54
80
  sources?: ConfigSources;
55
81
  designSystem?: ResolvedDesignSystem[];
56
82
  userTokenPaths?: string[];
83
+ userRecipeNames?: string[];
84
+ userPatternNames?: string[];
85
+ overlayInput?: DesignSystemOverlayInput;
57
86
  };
58
87
  }
59
88
 
@@ -99,6 +128,8 @@ interface BundleConfigResult<T = Config> {
99
128
  declare function bundleConfig<T extends Config = Config>(filepath: string, cwd: string): Promise<BundleConfigResult<T>>;
100
129
 
101
130
  declare function readPandaVersion(): string | undefined;
131
+ declare function getPandaMajorRange(): string | undefined;
132
+ declare function isStampablePandaRange(range: string | undefined): range is string;
102
133
 
103
134
  interface CompilePresetResult {
104
135
  code: string;
@@ -129,7 +160,7 @@ interface SyncExportsResult {
129
160
  }
130
161
  interface SyncExportsOptions {
131
162
  packageJson: string;
132
- entries: Record<string, string>;
163
+ entries: Record<string, unknown>;
133
164
  }
134
165
  declare function syncExports(options: SyncExportsOptions): SyncExportsResult;
135
166
 
@@ -137,6 +168,7 @@ interface FilterPublishableLibFilesOptions {
137
168
  /** Fallback paths relative to the lib outdir (same form as manifest `files`). */
138
169
  files: string[];
139
170
  packageRoot: string;
171
+ /** Lib outdir — resolve `files` entries from here. */
140
172
  outRoot: string;
141
173
  /** package.json `"files"`; omit when the whole package is packed. */
142
174
  publishFiles?: string[];
@@ -170,4 +202,7 @@ declare function toPosixPath(path: string): string;
170
202
  declare function toPosixRelative(from: string, to: string): string;
171
203
  declare function toRelativeKey(key: string, cwd: string): string;
172
204
 
173
- export { type BundleConfigResult, type CompilePresetOptions, type CompilePresetResult, ConfigSources, type FilterPublishableLibFilesOptions, type FilterPublishableLibFilesResult, type HostHooks, type LoadConfigOptions, type LoadConfigResult, type PackageIdentity, type SyncExportsOptions, type SyncExportsResult, bundleConfig, collectTokenPaths, compilePreset, defaultImportMap, diffConfig, filterPublishableLibFiles, findConfig, loadConfig, mergeExcludes, readPackageIdentity, readPandaVersion, readPublishFilesField, resolvePublishedPandaRange, resolveSmartInclude, syncExports, toPosixPath, toPosixRelative, toRelativeKey };
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 };