@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.
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  mergeConfigs,
3
3
  mergeConfigsWithSources
4
- } from "./chunk-PER4IFQZ.js";
4
+ } from "./chunk-LDC4ZCDS.js";
5
5
  import {
6
6
  collectPluginHookHandlers,
7
7
  createConfigSnapshot,
8
8
  normalizeHook
9
- } from "./chunk-U6KCSKCU.js";
9
+ } from "./chunk-Y642H6DU.js";
10
10
  import {
11
11
  PandaError,
12
12
  clone,
@@ -18,22 +18,22 @@ import {
18
18
  } from "./chunk-R4R5RHIS.js";
19
19
 
20
20
  // src/load.ts
21
- import { applyConfigDefaults } from "@pandacss/compiler-shared";
21
+ import { applyConfigDefaults as applyConfigDefaults2 } from "@pandacss/compiler-shared";
22
22
 
23
23
  // src/bundle.ts
24
- import { existsSync, realpathSync } from "fs";
25
- import { mkdir, unlink, writeFile } from "fs/promises";
26
- import { builtinModules } from "module";
27
- import { tmpdir } from "os";
28
- import { dirname, isAbsolute as isAbsolute2, join, normalize, relative } from "path";
29
- import { pathToFileURL as pathToFileURL2 } from "url";
24
+ import { existsSync, realpathSync } from "node:fs";
25
+ import { mkdir, unlink, writeFile } from "node:fs/promises";
26
+ import { builtinModules } from "node:module";
27
+ import { tmpdir } from "node:os";
28
+ import { basename, dirname, isAbsolute as isAbsolute2, join, normalize, relative } from "node:path";
29
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
30
30
 
31
31
  // src/bundle-plugins.ts
32
32
  import { parse } from "acorn";
33
33
  import { simple } from "acorn-walk";
34
34
  import MagicString from "magic-string";
35
- import { isAbsolute } from "path";
36
- import { pathToFileURL } from "url";
35
+ import { isAbsolute } from "node:path";
36
+ import { pathToFileURL } from "node:url";
37
37
  function importMetaUrlPlugin() {
38
38
  return {
39
39
  name: "panda-import-meta-url",
@@ -105,6 +105,7 @@ async function bundleConfig(filepath, cwd) {
105
105
  }
106
106
  async function loadBundledModule(filepath, code) {
107
107
  const target = tempTargetFor(filepath);
108
+ let evalError;
108
109
  if (target) {
109
110
  try {
110
111
  await mkdir(dirname(target), { recursive: true });
@@ -117,14 +118,23 @@ async function loadBundledModule(filepath, code) {
117
118
  } finally {
118
119
  void unlink(target).catch(() => void 0);
119
120
  }
120
- } catch {
121
+ } catch (error) {
122
+ if (!isUnresolvedTempModule(error, target)) evalError = error;
121
123
  }
122
124
  }
123
125
  const dataUrl = `data:text/javascript;base64,${Buffer.from(code).toString("base64")}`;
124
- return await import(
125
- /* @vite-ignore */
126
- dataUrl
127
- );
126
+ try {
127
+ return await import(
128
+ /* @vite-ignore */
129
+ dataUrl
130
+ );
131
+ } catch (error) {
132
+ throw evalError ?? error;
133
+ }
134
+ }
135
+ function isUnresolvedTempModule(error, target) {
136
+ const message = error instanceof Error ? error.message : "";
137
+ return message.includes("Cannot find module") && message.includes(basename(target));
128
138
  }
129
139
  function tempTargetFor(filepath) {
130
140
  const unique = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
@@ -168,8 +178,8 @@ function canonical(filepath) {
168
178
  }
169
179
 
170
180
  // src/find.ts
171
- import { readdirSync } from "fs";
172
- import { dirname as dirname2, resolve } from "path";
181
+ import { readdirSync } from "node:fs";
182
+ import { dirname as dirname2, resolve } from "node:path";
173
183
  var configFiles = /* @__PURE__ */ new Set([
174
184
  "panda.config.ts",
175
185
  "panda.config.js",
@@ -323,6 +333,9 @@ function attachRuntimeHooks(config, configs) {
323
333
  return config;
324
334
  }
325
335
 
336
+ // src/design-system/overlay-input.ts
337
+ import { applyConfigDefaults } from "@pandacss/compiler-shared";
338
+
326
339
  // src/normalize.ts
327
340
  var CLASS_NAME_OPTION_KEYS = ["hash", "prefix", "separator"];
328
341
  function normalizeClassNameOptions(config) {
@@ -363,20 +376,78 @@ function normalizePrefix(value) {
363
376
  return { cssVar: "", className: "" };
364
377
  }
365
378
 
379
+ // src/design-system/overlay-input.ts
380
+ var CLASS_NAME_OPTION_KEYS2 = ["hash", "prefix", "separator"];
381
+ var RUNTIME_OPTION_KEYS = [
382
+ ...CLASS_NAME_OPTION_KEYS2,
383
+ "jsxFramework",
384
+ "jsxFactory",
385
+ "jsxStyleProps",
386
+ "strictTokens",
387
+ "strictPropertyValues",
388
+ "shorthands"
389
+ ];
390
+ function designSystemSourceIds(chain) {
391
+ const ids = /* @__PURE__ */ new Set();
392
+ for (const ds of chain) {
393
+ ids.add(ds.name);
394
+ ids.add(ds.specifier);
395
+ }
396
+ return ids;
397
+ }
398
+ function authoredByApp(sources, prefix, dsIds) {
399
+ return Object.entries(sources.paths).some(([path, ids]) => {
400
+ if (path !== prefix && !path.startsWith(`${prefix}.`)) return false;
401
+ const idList = Array.isArray(ids) ? ids : [ids];
402
+ return idList.some((id) => isAppSource(sources.entries[id], dsIds));
403
+ });
404
+ }
405
+ function isAppSource(entry, dsIds) {
406
+ if (!entry) return false;
407
+ if (entry.kind === "config") return true;
408
+ if (entry.kind !== "preset") return false;
409
+ return entry.specifier === void 0 || !dsIds.has(entry.specifier);
410
+ }
411
+ function buildOverlayInput(sources, appConfig, chain, leafPreset, cwd) {
412
+ const dsIds = designSystemSourceIds(chain);
413
+ const authored = {
414
+ conditions: authoredByApp(sources, "conditions", dsIds),
415
+ breakpoints: authoredByApp(sources, "theme.breakpoints", dsIds),
416
+ utilities: authoredByApp(sources, "utilities", dsIds),
417
+ tokens: authoredByApp(sources, "theme.tokens", dsIds) || authoredByApp(sources, "theme.semanticTokens", dsIds)
418
+ };
419
+ const mismatches = diffRuntimeOptions(appConfig, leafPreset, sources, dsIds, cwd);
420
+ return { authored, compatible: mismatches.length === 0 };
421
+ }
422
+ function diffRuntimeOptions(appConfig, leafPreset, sources, dsIds, cwd) {
423
+ const app = applyConfigDefaults({ ...appConfig }, cwd);
424
+ const ds = applyConfigDefaults({ ...leafPreset }, cwd);
425
+ const appClass = normalizeClassNameOptions(app);
426
+ const dsClass = normalizeClassNameOptions(ds);
427
+ return RUNTIME_OPTION_KEYS.filter((key) => {
428
+ if (!authoredByApp(sources, key, dsIds)) return false;
429
+ if (key === "hash" || key === "prefix" || key === "separator") {
430
+ if (key === "separator") return appClass.separator !== dsClass.separator;
431
+ return appClass[key].cssVar !== dsClass[key].cssVar || appClass[key].className !== dsClass[key].className;
432
+ }
433
+ return JSON.stringify(app[key]) !== JSON.stringify(ds[key]);
434
+ });
435
+ }
436
+
366
437
  // src/preset.ts
367
- import { normalize as normalize2, relative as relative4 } from "path";
438
+ import { normalize as normalize2, relative as relative5 } from "node:path";
368
439
 
369
440
  // src/design-system/chain.ts
370
441
  import {
371
442
  outdirBasename
372
443
  } from "@pandacss/compiler-shared";
373
- import { readFileSync, statSync } from "fs";
374
- import { dirname as dirname3, resolve as resolve3 } from "path";
375
- import { pathToFileURL as pathToFileURL3 } from "url";
444
+ import { readFileSync as readFileSync2, statSync } from "node:fs";
445
+ import { dirname as dirname4, resolve as resolve4 } from "node:path";
446
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
376
447
 
377
448
  // src/resolve.ts
378
- import { createRequire } from "module";
379
- import { resolve as resolve2 } from "path";
449
+ import { createRequire } from "node:module";
450
+ import { resolve as resolve2 } from "node:path";
380
451
  function tryResolveFrom(request, fromDir) {
381
452
  try {
382
453
  return createRequire(resolve2(fromDir, "noop.js")).resolve(request, { paths: [fromDir] });
@@ -403,6 +474,195 @@ function errorCode(error) {
403
474
  return typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
404
475
  }
405
476
 
477
+ // src/design-system/package.ts
478
+ import { existsSync as existsSync2, readFileSync } from "node:fs";
479
+ import { dirname as dirname3, join as join2 } from "node:path";
480
+
481
+ // src/design-system/publishable-files.ts
482
+ import { relative as relative3, resolve as resolve3 } from "node:path";
483
+
484
+ // src/paths.ts
485
+ import { isAbsolute as isAbsolute3, relative as relative2 } from "node:path";
486
+ function toPosixPath(path) {
487
+ return path.includes("\\") ? path.split("\\").join("/") : path;
488
+ }
489
+ function toPosixRelative(from, to) {
490
+ const rel = toPosixPath(relative2(from, to));
491
+ return rel.startsWith(".") ? rel : `./${rel}`;
492
+ }
493
+ function toRelativeKey(key, cwd) {
494
+ return toPosixPath(isAbsolute3(key) ? relative2(cwd, key) : key);
495
+ }
496
+
497
+ // src/design-system/publishable-files.ts
498
+ var GLOB_START = /[*?{]/;
499
+ var HAS_WILDCARD = /[*?]/;
500
+ var TRAILING_SLASH = /\/$/;
501
+ var REGEX_META = /[.+^${}()|[\]\\]/g;
502
+ var GLOBSTAR = /\*\*/g;
503
+ var GLOB_STAR = /\*/g;
504
+ var GLOB_QMARK = /\?/g;
505
+ var GLOBSTAR_TOKEN = /<<<DS>>>/g;
506
+ function filterPublishableLibFiles(options) {
507
+ const { files, packageRoot, outRoot, publishFiles } = options;
508
+ if (!publishFiles?.length) {
509
+ return { files, unpublished: [] };
510
+ }
511
+ const rules = compilePackageFilesRules(publishFiles);
512
+ const kept = [];
513
+ const unpublished = [];
514
+ for (const file of files) {
515
+ const packageRelative = libFileToPackageRelative(file, packageRoot, outRoot);
516
+ if (packageRelative !== void 0 && matchesCompiledRules(packageRelative, rules)) {
517
+ kept.push(file);
518
+ } else {
519
+ unpublished.push(file);
520
+ }
521
+ }
522
+ return { files: kept, unpublished };
523
+ }
524
+ function readPublishFilesField(value) {
525
+ if (!Array.isArray(value) || value.length === 0) return void 0;
526
+ for (const entry of value) {
527
+ if (typeof entry !== "string") return void 0;
528
+ }
529
+ return value;
530
+ }
531
+ function libFileToPackageRelative(file, packageRoot, outRoot) {
532
+ const normalized = toPosixPath(file);
533
+ const withoutDot = normalized.startsWith("./") ? normalized.slice(2) : normalized;
534
+ const globAt = withoutDot.search(GLOB_START);
535
+ const literalPrefix = globAt === -1 ? withoutDot : withoutDot.slice(0, globAt);
536
+ const abs = resolve3(outRoot, literalPrefix || ".");
537
+ const rel = toPosixPath(relative3(packageRoot, abs));
538
+ if (rel === "") return "";
539
+ if (rel.startsWith("..")) return void 0;
540
+ return rel;
541
+ }
542
+ function compilePackageFilesRules(patterns) {
543
+ const rules = [];
544
+ for (const raw of patterns) {
545
+ const negated = raw.startsWith("!");
546
+ const pattern = toPosixPath(negated ? raw.slice(1) : raw);
547
+ const normalized = pattern.startsWith("./") ? pattern.slice(2) : pattern;
548
+ if (!normalized) continue;
549
+ if (!HAS_WILDCARD.test(normalized)) {
550
+ rules.push({ kind: "prefix", negated, value: normalized.replace(TRAILING_SLASH, "") });
551
+ continue;
552
+ }
553
+ const escaped = normalized.replace(REGEX_META, "\\$&").replace(GLOBSTAR, "<<<DS>>>").replace(GLOB_STAR, "[^/]*").replace(GLOB_QMARK, "[^/]").replace(GLOBSTAR_TOKEN, ".*");
554
+ rules.push({ kind: "regex", negated, value: new RegExp(`^${escaped}(?:/.*)?$`) });
555
+ }
556
+ return rules;
557
+ }
558
+ function matchesCompiledRules(packageRelativePath, rules) {
559
+ const path = packageRelativePath.startsWith("./") ? packageRelativePath.slice(2) : packageRelativePath;
560
+ let included = false;
561
+ for (const rule of rules) {
562
+ const hit = rule.kind === "prefix" ? path === rule.value || path.startsWith(`${rule.value}/`) : rule.value.test(path);
563
+ if (!hit) continue;
564
+ included = !rule.negated;
565
+ }
566
+ return included;
567
+ }
568
+
569
+ // src/design-system/package.ts
570
+ var PACKAGE_MANAGER_RANGE_PATTERN = /^(?:workspace|catalog):/;
571
+ var PORTABLE_WORKSPACE_RANGE_PATTERN = /^[~^]?\d/;
572
+ var VERSION_CORE_PATTERN = /^(\d+)\.(\d+)\.(\d+)/;
573
+ function resolvePublishedPandaRange(range, currentVersion) {
574
+ const authored = range?.trim();
575
+ if (!authored) return "*";
576
+ if (authored.startsWith("npm:")) {
577
+ return resolveNpmAliasRange(authored) ?? portableRangeFromInstalled(currentVersion, "^");
578
+ }
579
+ if (!PACKAGE_MANAGER_RANGE_PATTERN.test(authored)) return authored;
580
+ if (authored.startsWith("workspace:")) {
581
+ const workspaceRange = authored.slice("workspace:".length);
582
+ if (PORTABLE_WORKSPACE_RANGE_PATTERN.test(workspaceRange)) return workspaceRange;
583
+ }
584
+ const operator = authored === "workspace:~" ? "~" : "^";
585
+ return portableRangeFromInstalled(currentVersion, operator);
586
+ }
587
+ function resolveNpmAliasRange(spec) {
588
+ const at = spec.lastIndexOf("@");
589
+ if (at <= "npm:".length) return void 0;
590
+ return spec.slice(at + 1);
591
+ }
592
+ function portableRangeFromInstalled(currentVersion, operator) {
593
+ const core = currentVersion?.match(VERSION_CORE_PATTERN)?.[0];
594
+ return core ? `${operator}${core}` : "*";
595
+ }
596
+ function readPackageIdentity(cwd) {
597
+ const packagePath = nearestPackageJson(cwd);
598
+ if (packagePath === void 0) {
599
+ throw new Error(`Could not find a package.json from ${JSON.stringify(cwd)} to build the design system manifest.`);
600
+ }
601
+ const pkg = JSON.parse(readFileSync(packagePath, "utf8"));
602
+ const name = pkg.name;
603
+ if (typeof name !== "string" || name.length === 0) {
604
+ throw new Error(`${JSON.stringify(packagePath)} has no "name"; a design system must be a named package.`);
605
+ }
606
+ const peer = pkg.peerDependencies?.["@pandacss/dev"];
607
+ return {
608
+ name,
609
+ version: typeof pkg.version === "string" ? pkg.version : void 0,
610
+ pandaPeer: typeof peer === "string" ? peer : void 0,
611
+ packagePath,
612
+ publishFiles: readPublishFilesField(pkg.files)
613
+ };
614
+ }
615
+ function defaultImportMap(name) {
616
+ return {
617
+ css: `${name}/css`,
618
+ recipes: `${name}/recipes`,
619
+ patterns: `${name}/patterns`,
620
+ jsx: `${name}/jsx`,
621
+ tokens: `${name}/tokens`
622
+ };
623
+ }
624
+ function syncExports(options) {
625
+ const { packageJson, entries } = options;
626
+ const pkg = JSON.parse(packageJson);
627
+ const existing = normalizeExports(pkg.exports);
628
+ const merged = { ...existing };
629
+ const conflicts = [];
630
+ for (const [key, value] of Object.entries(entries)) {
631
+ if (key in merged && !exportsValueEqual(merged[key], value)) {
632
+ conflicts.push(key);
633
+ }
634
+ merged[key] = value;
635
+ }
636
+ const changed = JSON.stringify(pkg.exports) !== JSON.stringify(merged);
637
+ const out = { ...pkg, exports: merged };
638
+ return { changed, json: `${JSON.stringify(out, null, 2)}
639
+ `, conflicts };
640
+ }
641
+ function exportsValueEqual(left, right) {
642
+ return JSON.stringify(left) === JSON.stringify(right);
643
+ }
644
+ function normalizeExports(exports) {
645
+ if (exports === void 0) return {};
646
+ if (typeof exports === "string") return { ".": exports };
647
+ if (Array.isArray(exports)) return { ".": exports };
648
+ if (!isPlainObject(exports)) return {};
649
+ if (isSubpathExportMap(exports)) return exports;
650
+ return { ".": exports };
651
+ }
652
+ function isSubpathExportMap(exports) {
653
+ return Object.keys(exports).some((key) => key === "." || key.startsWith("./"));
654
+ }
655
+ function nearestPackageJson(start) {
656
+ let current = start;
657
+ while (true) {
658
+ const candidate = join2(current, "package.json");
659
+ if (existsSync2(candidate)) return candidate;
660
+ const parent = dirname3(current);
661
+ if (parent === current) return void 0;
662
+ current = parent;
663
+ }
664
+ }
665
+
406
666
  // src/design-system/chain.ts
407
667
  var SPECIFIER_PROTOCOL = /^([a-z][a-z0-9+.-]*):/i;
408
668
  async function loadDesignSystemChain(spec, cwd, deps) {
@@ -432,7 +692,7 @@ async function loadDesignSystemChain(spec, cwd, deps) {
432
692
  levels.push(level);
433
693
  if (parent === void 0) break;
434
694
  declaredBy = level.info.name;
435
- fromDir = dirname3(manifestPath);
695
+ fromDir = dirname4(manifestPath);
436
696
  currentSpec = parent;
437
697
  }
438
698
  return levels.reverse();
@@ -444,12 +704,126 @@ function withDesignSystemImportMap(config, infos) {
444
704
  );
445
705
  return { ...config, importMap: [...roots, outdirBasename(config.outdir ?? "styled-system"), ...existing] };
446
706
  }
707
+ function buildCodegenOverlay(metadata) {
708
+ const chain = metadata?.designSystem;
709
+ if (!chain || chain.length !== 1) return void 0;
710
+ if (metadata?.overlayInput && !metadata.overlayInput.compatible) return void 0;
711
+ const [ds] = chain;
712
+ const appRecipes = new Set(metadata?.userRecipeNames ?? []);
713
+ const appPatterns = new Set(metadata?.userPatternNames ?? []);
714
+ const authored = metadata?.overlayInput?.authored;
715
+ const runtimeDirty = !!(authored?.conditions || authored?.breakpoints || authored?.utilities || authored?.tokens);
716
+ return {
717
+ ...overlayRoots(ds),
718
+ ownedRecipes: ds.recipeNames.filter((name) => !appRecipes.has(name)),
719
+ ownedPatterns: ds.patternNames.filter((name) => !appPatterns.has(name)),
720
+ virtualizeHelpers: true,
721
+ virtualizeCss: !runtimeDirty
722
+ };
723
+ }
724
+ function collectArtifactConflicts(metadata) {
725
+ const appRecipes = new Set(metadata?.userRecipeNames ?? []);
726
+ const appPatterns = new Set(metadata?.userPatternNames ?? []);
727
+ return (metadata?.designSystem ?? []).map((ds) => ({
728
+ name: ds.name,
729
+ recipes: ds.recipeNames.filter((name) => appRecipes.has(name)),
730
+ patterns: ds.patternNames.filter((name) => appPatterns.has(name))
731
+ })).filter((entry) => entry.recipes.length > 0 || entry.patterns.length > 0);
732
+ }
733
+ function collectExportMissingDiagnostics(metadata) {
734
+ const overlay = buildCodegenOverlay(metadata);
735
+ if (!overlay) return [];
736
+ const [ds] = metadata.designSystem;
737
+ const required = [];
738
+ if (overlay.virtualizeHelpers) required.push("./helpers");
739
+ if (overlay.virtualizeCss) {
740
+ required.push("./css", "./css/*");
741
+ }
742
+ if (overlay.ownedRecipes.length > 0) {
743
+ required.push("./recipes", "./recipes/*");
744
+ }
745
+ if (overlay.ownedPatterns.length > 0) {
746
+ required.push("./patterns", "./patterns/*");
747
+ }
748
+ const appPatterns = metadata?.userPatternNames?.length ?? 0;
749
+ const dsPatterns = ds.patternNames?.length ?? 0;
750
+ if (overlay.ownedPatterns.length > 0 || overlay.virtualizeCss && (appPatterns > 0 || dsPatterns > 0)) {
751
+ required.push("./jsx", "./jsx/*");
752
+ }
753
+ return required.filter((subpath) => !hasExport(ds.packageExports, subpath)).map((subpath) => exportMissingDiagnostic(ds.name, subpath));
754
+ }
755
+ function collectNameCollisionDiagnostics(metadata) {
756
+ const overlay = buildCodegenOverlay(metadata);
757
+ if (!overlay) return [];
758
+ return [
759
+ ...identCollisions("recipe", [...overlay.ownedRecipes, ...metadata?.userRecipeNames ?? []]),
760
+ ...identCollisions("pattern", [...overlay.ownedPatterns, ...metadata?.userPatternNames ?? []])
761
+ ];
762
+ }
763
+ function jsIdent(value) {
764
+ let out = "";
765
+ for (let i = 0; i < value.length; i++) {
766
+ const code = value.charCodeAt(i);
767
+ const isIdent = code === 36 || // $
768
+ code === 95 || // _
769
+ code >= 48 && code <= 57 || // 0-9
770
+ code >= 65 && code <= 90 || // A-Z
771
+ code >= 97 && code <= 122;
772
+ if (isIdent) {
773
+ if (i === 0 && code >= 48 && code <= 57) out += "_";
774
+ out += value[i];
775
+ } else {
776
+ out += "_";
777
+ }
778
+ }
779
+ return out === "" ? "_" : out;
780
+ }
781
+ function identCollisions(kind, names) {
782
+ const byIdent = /* @__PURE__ */ new Map();
783
+ for (const name of names) {
784
+ const ident = jsIdent(name);
785
+ const set = byIdent.get(ident) ?? /* @__PURE__ */ new Set();
786
+ set.add(name);
787
+ byIdent.set(ident, set);
788
+ }
789
+ const collisions = [];
790
+ for (const [ident, raw] of byIdent) {
791
+ if (raw.size < 2) continue;
792
+ const list = [...raw].map((name) => JSON.stringify(name)).join(", ");
793
+ const message = `${kind} names ${list} both generate the export ${JSON.stringify(ident)}; one would overwrite the other in the generated barrel. Rename one so they produce distinct identifiers.`;
794
+ collisions.push(createConfigDiagnostic("design_system_name_collision", message));
795
+ }
796
+ return collisions;
797
+ }
798
+ function hasExport(packageExports, subpath) {
799
+ return packageExports != null && Object.prototype.hasOwnProperty.call(packageExports, subpath);
800
+ }
801
+ function exportMissingDiagnostic(dsName, subpath) {
802
+ const message = `designSystem ${JSON.stringify(dsName)} doesn't export ${JSON.stringify(subpath)}, which this app's codegen needs. Rebuild it with \`panda lib\`.`;
803
+ return createConfigDiagnostic("design_system_export_missing", message, [
804
+ `Rebuild ${JSON.stringify(dsName)} with \`panda lib\` to add the ${JSON.stringify(subpath)} export.`
805
+ ]);
806
+ }
807
+ function overlayRoots(ds) {
808
+ const map = ds.importMap;
809
+ const root = (value, subpath) => {
810
+ const resolved = Array.isArray(value) ? value[0] : value;
811
+ return resolved ?? `${ds.specifier}/${subpath}`;
812
+ };
813
+ return {
814
+ jsx: root(map?.jsx, "jsx"),
815
+ recipes: root(map?.recipes, "recipes"),
816
+ patterns: root(map?.patterns, "patterns"),
817
+ css: root(map?.css, "css"),
818
+ helpers: `${ds.specifier}/helpers`
819
+ };
820
+ }
447
821
  function resolveManifestPath(spec, fromDir) {
448
822
  const protocol = specifierProtocol(spec);
449
823
  if (protocol) throw unsupportedSpecifierError(spec, protocol);
450
824
  let outcome;
451
825
  try {
452
- outcome = resolveFrom(`${spec}/panda.lib.json`, fromDir);
826
+ outcome = resolveFrom(`${spec}/panda/lib.json`, fromDir);
453
827
  } catch (error) {
454
828
  const message = `Failed to resolve designSystem ${JSON.stringify(spec)} from ${JSON.stringify(fromDir)}: ${errorMessage(error)}`;
455
829
  throw createConfigError(message, [createConfigDiagnostic("design_system_resolve_failed", message)]);
@@ -459,17 +833,17 @@ function resolveManifestPath(spec, fromDir) {
459
833
  return void 0;
460
834
  }
461
835
  function manifestNotExportedError(spec) {
462
- const message = `designSystem ${JSON.stringify(spec)} is installed but doesn't expose \`./panda.lib.json\`. If it's a Panda design system, rebuild it with \`panda lib\`; otherwise it can't be consumed as a design system.`;
836
+ const message = `designSystem ${JSON.stringify(spec)} is installed but doesn't expose \`./panda/*\` (missing \`panda/lib.json\`). If it's a Panda design system, rebuild it with \`panda lib\`; otherwise it can't be consumed as a design system.`;
463
837
  return createConfigError(message, [
464
838
  createConfigDiagnostic("design_system_manifest_not_exported", message, [
465
- `Rebuild ${JSON.stringify(spec)} with \`panda lib\`, or check its package.json \`exports\` includes \`./panda.lib.json\`.`
839
+ `Rebuild ${JSON.stringify(spec)} with \`panda lib\`, or check its package.json \`exports\` includes \`./panda/*\`.`
466
840
  ])
467
841
  ]);
468
842
  }
469
843
  async function loadManifestLevel(spec, manifestPath, deps) {
470
844
  let parsed;
471
845
  try {
472
- parsed = JSON.parse(readFileSync(manifestPath, "utf8"));
846
+ parsed = JSON.parse(readFileSync2(manifestPath, "utf8"));
473
847
  } catch (error) {
474
848
  const message = `Failed to parse ${JSON.stringify(manifestPath)} as JSON: ${errorMessage(error)}. This file must be generated by \`panda lib\`, not hand-written or added to \`include\`.`;
475
849
  throw createConfigError(message, [
@@ -477,8 +851,8 @@ async function loadManifestLevel(spec, manifestPath, deps) {
477
851
  ]);
478
852
  }
479
853
  const manifest = validateManifest(spec, manifestPath, parsed);
480
- const presetPath = resolve3(dirname3(manifestPath), manifest.preset);
481
- const buildInfoPath = resolve3(dirname3(manifestPath), manifest.buildInfo);
854
+ const presetPath = resolve4(dirname4(manifestPath), manifest.preset);
855
+ const buildInfoPath = resolve4(dirname4(manifestPath), manifest.buildInfo);
482
856
  deps.add(presetPath);
483
857
  deps.add(buildInfoPath);
484
858
  let preset;
@@ -495,6 +869,7 @@ async function loadManifestLevel(spec, manifestPath, deps) {
495
869
  ]);
496
870
  }
497
871
  const parent = typeof manifest.designSystem === "string" && manifest.designSystem.length > 0 ? manifest.designSystem : void 0;
872
+ const packageExports = readPackageExports(manifestPath);
498
873
  return {
499
874
  parent,
500
875
  level: {
@@ -507,11 +882,27 @@ async function loadManifestLevel(spec, manifestPath, deps) {
507
882
  buildInfoPath,
508
883
  files: manifest.files ?? [],
509
884
  tokenPaths: [],
510
- ...manifest.importMap ? { importMap: manifest.importMap } : {}
885
+ recipeNames: [],
886
+ patternNames: [],
887
+ ...manifest.importMap ? { importMap: manifest.importMap } : {},
888
+ ...packageExports ? { packageExports } : {}
511
889
  }
512
890
  }
513
891
  };
514
892
  }
893
+ function readPackageExports(manifestPath) {
894
+ try {
895
+ const packageJsonPath = nearestPackageJson(dirname4(manifestPath));
896
+ if (packageJsonPath === void 0) return void 0;
897
+ const pkg = JSON.parse(readFileSync2(packageJsonPath, "utf8"));
898
+ return isExportsMap(pkg.exports) ? pkg.exports : void 0;
899
+ } catch {
900
+ return void 0;
901
+ }
902
+ }
903
+ function isExportsMap(value) {
904
+ return typeof value === "object" && value !== null && !Array.isArray(value);
905
+ }
515
906
  function presetImportUrl(path) {
516
907
  const url = pathToFileURL3(path);
517
908
  url.searchParams.set("mtime", String(statSync(path).mtimeMs));
@@ -613,30 +1004,15 @@ function specifierProtocol(spec) {
613
1004
  return match ? match[1] : void 0;
614
1005
  }
615
1006
  function unsupportedSpecifierError(spec, protocol) {
616
- const message = `designSystem ${JSON.stringify(spec)} uses the "${protocol}:" protocol, which isn't supported. Use the published package name (e.g. "@acme/design-system") that resolves to its \`panda.lib.json\`.`;
1007
+ const message = `designSystem ${JSON.stringify(spec)} uses the "${protocol}:" protocol, which isn't supported. Use the published package name (e.g. "@acme/design-system") that resolves to its \`panda/lib.json\`.`;
617
1008
  return createConfigError(message, [createConfigDiagnostic("design_system_unsupported_specifier", message)]);
618
1009
  }
619
1010
 
620
1011
  // src/design-system/smart-include.ts
621
- import { existsSync as existsSync2 } from "fs";
622
- import { dirname as dirname4, isAbsolute as isAbsolute4, join as join2, relative as relative3, resolve as resolve4, sep } from "path";
623
-
624
- // src/paths.ts
625
- import { isAbsolute as isAbsolute3, relative as relative2 } from "path";
626
- function toPosixPath(path) {
627
- return path.includes("\\") ? path.split("\\").join("/") : path;
628
- }
629
- function toPosixRelative(from, to) {
630
- const rel = toPosixPath(relative2(from, to));
631
- return rel.startsWith(".") ? rel : `./${rel}`;
632
- }
633
- function toRelativeKey(key, cwd) {
634
- return toPosixPath(isAbsolute3(key) ? relative2(cwd, key) : key);
635
- }
636
-
637
- // src/design-system/smart-include.ts
1012
+ import { existsSync as existsSync3 } from "node:fs";
1013
+ import { dirname as dirname5, isAbsolute as isAbsolute4, join as join3, relative as relative4, resolve as resolve5, sep } from "node:path";
638
1014
  var SMART_INCLUDE_EXTENSIONS = ["js", "mjs", "cjs", "jsx", "ts", "cts", "mts", "tsx", "vue", "svelte", "astro"];
639
- var MANIFEST = "panda.lib.json";
1015
+ var MANIFEST_SUBPATH = "panda/lib.json";
640
1016
  var PACKAGE_SPECIFIER = /^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/i;
641
1017
  function resolveSmartInclude(include, cwd, deps) {
642
1018
  const offenders = [];
@@ -652,7 +1028,7 @@ function resolveSmartInclude(include, cwd, deps) {
652
1028
  next.push(entry);
653
1029
  continue;
654
1030
  }
655
- if (tryResolveFrom(`${entry}/${MANIFEST}`, cwd) !== void 0) {
1031
+ if (tryResolveFrom(`${entry}/${MANIFEST_SUBPATH}`, cwd) !== void 0) {
656
1032
  offenders.push(entry);
657
1033
  continue;
658
1034
  }
@@ -661,11 +1037,11 @@ function resolveSmartInclude(include, cwd, deps) {
661
1037
  next.push(entry);
662
1038
  continue;
663
1039
  }
664
- if (existsSync2(join2(packageDir, MANIFEST))) {
1040
+ if (existsSync3(join3(packageDir, ...MANIFEST_SUBPATH.split("/")))) {
665
1041
  offenders.push(entry);
666
1042
  continue;
667
1043
  }
668
- deps.add(join2(packageDir, "package.json"));
1044
+ deps.add(join3(packageDir, "package.json"));
669
1045
  const base = globBase(packageDir, cwd);
670
1046
  next.push(`${base}/**/*.{${SMART_INCLUDE_EXTENSIONS.join(",")}}`);
671
1047
  excludes.push(`${base}/**/node_modules/**`);
@@ -684,11 +1060,11 @@ function mergeExcludes(existing, additions) {
684
1060
  return [...existing ?? [], ...additions];
685
1061
  }
686
1062
  function isLocalPath(entry, cwd) {
687
- return existsSync2(isAbsolute4(entry) ? entry : resolve4(cwd, entry));
1063
+ return existsSync3(isAbsolute4(entry) ? entry : resolve5(cwd, entry));
688
1064
  }
689
1065
  function resolvePackageDir(spec, cwd) {
690
1066
  const fromPackageJson = tryResolve(`${spec}/package.json`, cwd);
691
- if (fromPackageJson !== void 0) return dirname4(fromPackageJson);
1067
+ if (fromPackageJson !== void 0) return dirname5(fromPackageJson);
692
1068
  const fromEntry = tryResolve(spec, cwd);
693
1069
  return fromEntry === void 0 ? void 0 : nearestPackageDir(fromEntry);
694
1070
  }
@@ -706,23 +1082,23 @@ function isInsideCwd(relativePath) {
706
1082
  return !relativePath.startsWith(`..${sep}`);
707
1083
  }
708
1084
  function nearestPackageDir(from) {
709
- let dir = dirname4(from);
1085
+ let dir = dirname5(from);
710
1086
  while (true) {
711
- if (existsSync2(join2(dir, "package.json"))) return dir;
712
- const parent = dirname4(dir);
1087
+ if (existsSync3(join3(dir, "package.json"))) return dir;
1088
+ const parent = dirname5(dir);
713
1089
  if (parent === dir) return void 0;
714
1090
  dir = parent;
715
1091
  }
716
1092
  }
717
1093
  function globBase(packageDir, cwd) {
718
- const rel = relative3(cwd, packageDir);
1094
+ const rel = relative4(cwd, packageDir);
719
1095
  const base = isInsideCwd(rel) ? rel : packageDir;
720
1096
  return toPosixPath(base);
721
1097
  }
722
1098
  function inIncludeError(specs) {
723
1099
  const list = specs.map((spec) => JSON.stringify(spec)).join(", ");
724
1100
  const plural = specs.length > 1;
725
- const message = `Design system${plural ? "s" : ""} in \`include\`: ${list}. ${plural ? "They each ship" : "It ships"} a ${MANIFEST}, so ${plural ? "they belong" : "it belongs"} in \`designSystem\`, not \`include\`. \`include\` is for files, not design systems.`;
1101
+ const message = `Design system${plural ? "s" : ""} in \`include\`: ${list}. ${plural ? "They each ship" : "It ships"} a ${MANIFEST_SUBPATH}, so ${plural ? "they belong" : "it belongs"} in \`designSystem\`, not \`include\`. \`include\` is for files, not design systems.`;
726
1102
  return createConfigError(
727
1103
  message,
728
1104
  specs.map(
@@ -736,7 +1112,7 @@ function inIncludeError(specs) {
736
1112
  }
737
1113
 
738
1114
  // src/design-system/token-paths.ts
739
- import { isDeepStrictEqual } from "util";
1115
+ import { isDeepStrictEqual } from "node:util";
740
1116
  function collectTokenPaths(config) {
741
1117
  return [...collectTokenEntries(config).keys()].sort();
742
1118
  }
@@ -782,41 +1158,57 @@ function collect(node, trail, out) {
782
1158
  }
783
1159
  }
784
1160
 
1161
+ // src/artifact-names.ts
1162
+ function collectRecipeNames(config) {
1163
+ const theme = config?.theme;
1164
+ if (!theme) return [];
1165
+ const names = /* @__PURE__ */ new Set([...Object.keys(theme.recipes ?? {}), ...Object.keys(theme.slotRecipes ?? {})]);
1166
+ return [...names].sort();
1167
+ }
1168
+ function collectPatternNames(config) {
1169
+ return Object.keys(config?.patterns ?? {}).sort();
1170
+ }
1171
+
785
1172
  // src/preset.ts
786
1173
  async function resolveAuthoredPresetsForLoad(config, cwd, options = {}) {
1174
+ const designSystem = config.designSystem;
1175
+ const hasDesignSystem = typeof designSystem === "string" && designSystem.length > 0;
1176
+ const trackSources = options.trackSources ?? hasDesignSystem;
787
1177
  const ctx = {
788
1178
  cwd,
789
1179
  configs: [],
790
1180
  dependencies: /* @__PURE__ */ new Set(),
791
1181
  presetResolvedHooks: [],
792
- ...options.trackSources ? { sourcedConfigs: [] } : {}
1182
+ ...trackSources ? { sourcedConfigs: [] } : {}
793
1183
  };
794
1184
  const rootSource = { kind: "config" };
795
1185
  if (options.configFile) {
796
- rootSource.file = normalize2(relative4(cwd, options.configFile));
1186
+ rootSource.file = normalize2(relative5(cwd, options.configFile));
797
1187
  }
798
- const designSystem = config.designSystem;
799
1188
  let dsChain = [];
800
1189
  const designSystemCompatibility = [];
801
- if (typeof designSystem === "string" && designSystem.length > 0) {
1190
+ if (hasDesignSystem) {
802
1191
  dsChain = await loadDesignSystemChain(designSystem, cwd, ctx.dependencies);
803
1192
  for (const level of dsChain) {
804
- const resolution = await resolveConfigEntry(
805
- level.preset,
806
- { kind: "preset", specifier: level.info.name },
807
- cwd,
808
- ctx.dependencies,
809
- options.trackSources
810
- );
1193
+ const dsSource = { kind: "preset", specifier: level.info.name, name: level.info.name };
1194
+ const resolution = await resolveConfigEntry(level.preset, dsSource, cwd, ctx.dependencies, trackSources);
1195
+ if (resolution.sourcedConfigs) {
1196
+ for (const sourced of resolution.sourcedConfigs) {
1197
+ sourced.source = dsSource;
1198
+ }
1199
+ }
811
1200
  level.info.tokenPaths = collectTokenPaths(resolution.config);
1201
+ level.info.recipeNames = collectRecipeNames(resolution.config);
1202
+ level.info.patternNames = collectPatternNames(resolution.config);
812
1203
  appendConfigResolution(ctx, resolution);
813
1204
  designSystemCompatibility.push({
814
1205
  designSystem: level.info,
815
- classNameOptions: normalizeClassNameOptions(mergeConfigs(ctx.configs))
1206
+ classNameOptions: normalizeClassNameOptions(mergeConfigs(ctx.configs)),
1207
+ presetConfig: resolution.config
816
1208
  });
817
1209
  }
818
1210
  }
819
- const rootResolution = await resolveConfigEntry(config, rootSource, cwd, ctx.dependencies, options.trackSources);
1211
+ const rootResolution = await resolveConfigEntry(config, rootSource, cwd, ctx.dependencies, trackSources);
820
1212
  appendConfigResolution(ctx, rootResolution);
821
1213
  for (const { designSystem: designSystem2, classNameOptions } of designSystemCompatibility) {
822
1214
  const mismatch = diffClassNameOptions(rootResolution.config, classNameOptions, "explicit");
@@ -829,23 +1221,46 @@ async function resolveAuthoredPresetsForLoad(config, cwd, options = {}) {
829
1221
  const withImportMap = dsInfos.length > 0 ? withDesignSystemImportMap(resolved, dsInfos) : resolved;
830
1222
  return expandSmartInclude(withImportMap, cwd, ctx.dependencies);
831
1223
  };
832
- const dsMetadata = dsInfos.length > 0 ? { designSystem: dsInfos, userTokenPaths: collectTokenPaths(rootResolution.config) } : void 0;
1224
+ const leafCompatibility = designSystemCompatibility[designSystemCompatibility.length - 1];
833
1225
  if (ctx.sourcedConfigs) {
834
1226
  const merged = mergeConfigsWithSources(ctx.sourcedConfigs);
835
1227
  if (options.preserveRuntimeHooks) {
836
1228
  attachRuntimeHooks(merged.config, ctx.configs);
837
1229
  }
1230
+ const finalized2 = finalize(merged.config);
1231
+ let overlayInput;
1232
+ if (leafCompatibility) {
1233
+ const input = buildOverlayInput(merged.sources, finalized2, dsInfos, leafCompatibility.presetConfig, cwd);
1234
+ const leafClassMismatch = leafCompatibility.designSystem.optionMismatch ?? [];
1235
+ overlayInput = {
1236
+ authored: input.authored,
1237
+ compatible: input.compatible && leafClassMismatch.length === 0
1238
+ };
1239
+ }
1240
+ const dsMetadata2 = dsInfos.length > 0 ? {
1241
+ designSystem: dsInfos,
1242
+ userTokenPaths: collectTokenPaths(rootResolution.config),
1243
+ userRecipeNames: collectRecipeNames(rootResolution.config),
1244
+ userPatternNames: collectPatternNames(rootResolution.config),
1245
+ ...overlayInput ? { overlayInput } : {}
1246
+ } : void 0;
838
1247
  return {
839
- config: finalize(merged.config),
1248
+ config: finalized2,
840
1249
  dependencies: Array.from(ctx.dependencies),
841
- metadata: { sources: merged.sources, ...dsMetadata },
1250
+ metadata: { sources: merged.sources, ...dsMetadata2 },
842
1251
  designSystemCompatibility
843
1252
  };
844
1253
  }
1254
+ const mergedConfig = options.preserveRuntimeHooks ? attachRuntimeHooks(mergeConfigs(ctx.configs), ctx.configs) : mergeConfigs(ctx.configs);
1255
+ const finalized = finalize(mergedConfig);
1256
+ const dsMetadata = dsInfos.length > 0 ? {
1257
+ designSystem: dsInfos,
1258
+ userTokenPaths: collectTokenPaths(rootResolution.config),
1259
+ userRecipeNames: collectRecipeNames(rootResolution.config),
1260
+ userPatternNames: collectPatternNames(rootResolution.config)
1261
+ } : void 0;
845
1262
  return {
846
- config: finalize(
847
- options.preserveRuntimeHooks ? attachRuntimeHooks(mergeConfigs(ctx.configs), ctx.configs) : mergeConfigs(ctx.configs)
848
- ),
1263
+ config: finalized,
849
1264
  dependencies: Array.from(ctx.dependencies),
850
1265
  ...dsMetadata ? { metadata: dsMetadata } : {},
851
1266
  designSystemCompatibility
@@ -965,13 +1380,14 @@ async function loadConfig(options) {
965
1380
  );
966
1381
  const tokenEntriesBeforeHooks = collectTokenEntries(authored.config);
967
1382
  const userConfig = await runConfigResolvedHooks(authored.config, path, authoredDependencies);
1383
+ const resolved = applyConfigDefaults2(userConfig, cwd);
968
1384
  refreshDesignSystemMetadata(
969
1385
  authored.metadata,
970
1386
  authored.designSystemCompatibility,
971
- userConfig,
972
- tokenEntriesBeforeHooks
1387
+ resolved,
1388
+ tokenEntriesBeforeHooks,
1389
+ cwd
973
1390
  );
974
- const resolved = applyConfigDefaults(userConfig, cwd);
975
1391
  const dependencyList = Array.from(
976
1392
  /* @__PURE__ */ new Set([...dependencies, ...authored.dependencies, ...resolved.dependencies ?? []])
977
1393
  );
@@ -990,13 +1406,16 @@ async function loadConfig(options) {
990
1406
  ...authored.metadata ? { metadata: authored.metadata } : {}
991
1407
  };
992
1408
  }
993
- function refreshDesignSystemMetadata(metadata, designSystemCompatibility, config, tokenEntriesBeforeHooks) {
1409
+ function refreshDesignSystemMetadata(metadata, designSystemCompatibility, config, tokenEntriesBeforeHooks, cwd) {
994
1410
  if (!metadata?.designSystem?.length) return;
995
1411
  metadata.userTokenPaths = resolveUserTokenPathsAfterHooks(
996
1412
  metadata.userTokenPaths ?? [],
997
1413
  tokenEntriesBeforeHooks,
998
1414
  config
999
1415
  );
1416
+ const chain = metadata.designSystem;
1417
+ const sources = metadata.sources;
1418
+ const leaf = designSystemCompatibility[designSystemCompatibility.length - 1];
1000
1419
  for (const { designSystem, classNameOptions } of designSystemCompatibility) {
1001
1420
  const mismatch = diffClassNameOptions(config, classNameOptions, "effective");
1002
1421
  if (mismatch.length > 0) {
@@ -1005,6 +1424,14 @@ function refreshDesignSystemMetadata(metadata, designSystemCompatibility, config
1005
1424
  delete designSystem.optionMismatch;
1006
1425
  }
1007
1426
  }
1427
+ if (sources && leaf) {
1428
+ const input = buildOverlayInput(sources, config, chain, leaf.presetConfig, cwd);
1429
+ const leafClassMismatch = leaf.designSystem.optionMismatch ?? [];
1430
+ metadata.overlayInput = {
1431
+ authored: input.authored,
1432
+ compatible: input.compatible && leafClassMismatch.length === 0
1433
+ };
1434
+ }
1008
1435
  }
1009
1436
  async function runConfigResolvedHooks(config, path, dependencies) {
1010
1437
  let current = config;
@@ -1035,7 +1462,6 @@ var ALL_DEPENDENCIES = [
1035
1462
  "prefix",
1036
1463
  "recipes",
1037
1464
  "separator",
1038
- "syntax",
1039
1465
  "themes",
1040
1466
  "tokens",
1041
1467
  "utilities"
@@ -1089,8 +1515,6 @@ function classify(path) {
1089
1515
  return { deps: ["patterns"], pattern: second };
1090
1516
  case "themes":
1091
1517
  return { deps: ["themes"] };
1092
- case "syntax":
1093
- return { deps: ["syntax"] };
1094
1518
  case "hash":
1095
1519
  return { deps: ["hash"] };
1096
1520
  case "prefix":
@@ -1127,20 +1551,29 @@ function isConfigSnapshot(input) {
1127
1551
  }
1128
1552
 
1129
1553
  // src/version.ts
1130
- import { readFileSync as readFileSync2 } from "fs";
1131
- import { dirname as dirname5, join as join3 } from "path";
1132
- import { fileURLToPath } from "url";
1554
+ import { readFileSync as readFileSync3 } from "node:fs";
1555
+ import { dirname as dirname6, join as join4 } from "node:path";
1556
+ import { fileURLToPath } from "node:url";
1557
+ var MAJOR_VERSION_RE = /\d+/;
1558
+ var STAMPABLE_PANDA_RANGE_RE = /^[v=><~^]|^\d/;
1133
1559
  function readPandaVersion() {
1134
1560
  try {
1135
- const pkgPath = join3(dirname5(fileURLToPath(import.meta.url)), "../package.json");
1136
- return JSON.parse(readFileSync2(pkgPath, "utf8")).version;
1561
+ const pkgPath = join4(dirname6(fileURLToPath(import.meta.url)), "../package.json");
1562
+ return JSON.parse(readFileSync3(pkgPath, "utf8")).version;
1137
1563
  } catch {
1138
1564
  return void 0;
1139
1565
  }
1140
1566
  }
1567
+ function getPandaMajorRange() {
1568
+ const match = readPandaVersion()?.match(MAJOR_VERSION_RE);
1569
+ return match ? `^${match[0]}.0.0` : void 0;
1570
+ }
1571
+ function isStampablePandaRange(range) {
1572
+ return range !== void 0 && STAMPABLE_PANDA_RANGE_RE.test(range.trim());
1573
+ }
1141
1574
 
1142
1575
  // src/design-system/compile-preset.ts
1143
- import { builtinModules as builtinModules2 } from "module";
1576
+ import { builtinModules as builtinModules2 } from "node:module";
1144
1577
  var APP_FIELDS = ["designSystem", "include", "exclude", "outdir", "cwd", "watch", "clean", "gitignore", "importMap"];
1145
1578
  var VIRTUAL_ENTRY = "\0panda-lib-preset-entry";
1146
1579
  var nodeBuiltins2 = /* @__PURE__ */ new Set([...builtinModules2, ...builtinModules2.map((mod) => `node:${mod}`)]);
@@ -1201,179 +1634,14 @@ async function validatePreset(code) {
1201
1634
  throw new PandaError("CONFIG_ERROR", `\u{1F4A5} Failed to compile design system preset: ${errorMessage(error)}`);
1202
1635
  }
1203
1636
  }
1204
-
1205
- // src/design-system/package.ts
1206
- import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
1207
- import { dirname as dirname6, join as join4 } from "path";
1208
-
1209
- // src/design-system/publishable-files.ts
1210
- import { relative as relative5, resolve as resolve5 } from "path";
1211
- var GLOB_START = /[*?{]/;
1212
- var HAS_WILDCARD = /[*?]/;
1213
- var TRAILING_SLASH = /\/$/;
1214
- var REGEX_META = /[.+^${}()|[\]\\]/g;
1215
- var GLOBSTAR = /\*\*/g;
1216
- var GLOB_STAR = /\*/g;
1217
- var GLOB_QMARK = /\?/g;
1218
- var GLOBSTAR_TOKEN = /<<<DS>>>/g;
1219
- function filterPublishableLibFiles(options) {
1220
- const { files, packageRoot, outRoot, publishFiles } = options;
1221
- if (!publishFiles?.length) {
1222
- return { files, unpublished: [] };
1223
- }
1224
- const rules = compilePackageFilesRules(publishFiles);
1225
- const kept = [];
1226
- const unpublished = [];
1227
- for (const file of files) {
1228
- const packageRelative = libFileToPackageRelative(file, packageRoot, outRoot);
1229
- if (packageRelative !== void 0 && matchesCompiledRules(packageRelative, rules)) {
1230
- kept.push(file);
1231
- } else {
1232
- unpublished.push(file);
1233
- }
1234
- }
1235
- return { files: kept, unpublished };
1236
- }
1237
- function readPublishFilesField(value) {
1238
- if (!Array.isArray(value) || value.length === 0) return void 0;
1239
- for (const entry of value) {
1240
- if (typeof entry !== "string") return void 0;
1241
- }
1242
- return value;
1243
- }
1244
- function libFileToPackageRelative(file, packageRoot, outRoot) {
1245
- const normalized = toPosixPath(file);
1246
- const withoutDot = normalized.startsWith("./") ? normalized.slice(2) : normalized;
1247
- const globAt = withoutDot.search(GLOB_START);
1248
- const literalPrefix = globAt === -1 ? withoutDot : withoutDot.slice(0, globAt);
1249
- const abs = resolve5(outRoot, literalPrefix || ".");
1250
- const rel = toPosixPath(relative5(packageRoot, abs));
1251
- if (rel === "") return "";
1252
- if (rel.startsWith("..")) return void 0;
1253
- return rel;
1254
- }
1255
- function compilePackageFilesRules(patterns) {
1256
- const rules = [];
1257
- for (const raw of patterns) {
1258
- const negated = raw.startsWith("!");
1259
- const pattern = toPosixPath(negated ? raw.slice(1) : raw);
1260
- const normalized = pattern.startsWith("./") ? pattern.slice(2) : pattern;
1261
- if (!normalized) continue;
1262
- if (!HAS_WILDCARD.test(normalized)) {
1263
- rules.push({ kind: "prefix", negated, value: normalized.replace(TRAILING_SLASH, "") });
1264
- continue;
1265
- }
1266
- const escaped = normalized.replace(REGEX_META, "\\$&").replace(GLOBSTAR, "<<<DS>>>").replace(GLOB_STAR, "[^/]*").replace(GLOB_QMARK, "[^/]").replace(GLOBSTAR_TOKEN, ".*");
1267
- rules.push({ kind: "regex", negated, value: new RegExp(`^${escaped}(?:/.*)?$`) });
1268
- }
1269
- return rules;
1270
- }
1271
- function matchesCompiledRules(packageRelativePath, rules) {
1272
- const path = packageRelativePath.startsWith("./") ? packageRelativePath.slice(2) : packageRelativePath;
1273
- let included = false;
1274
- for (const rule of rules) {
1275
- const hit = rule.kind === "prefix" ? path === rule.value || path.startsWith(`${rule.value}/`) : rule.value.test(path);
1276
- if (!hit) continue;
1277
- included = !rule.negated;
1278
- }
1279
- return included;
1280
- }
1281
-
1282
- // src/design-system/package.ts
1283
- var PACKAGE_MANAGER_RANGE_PATTERN = /^(?:workspace|catalog):/;
1284
- var PORTABLE_WORKSPACE_RANGE_PATTERN = /^[~^]?\d/;
1285
- var VERSION_CORE_PATTERN = /^(\d+)\.(\d+)\.(\d+)/;
1286
- function resolvePublishedPandaRange(range, currentVersion) {
1287
- const authored = range?.trim();
1288
- if (!authored) return "*";
1289
- if (authored.startsWith("npm:")) {
1290
- return resolveNpmAliasRange(authored) ?? portableRangeFromInstalled(currentVersion, "^");
1291
- }
1292
- if (!PACKAGE_MANAGER_RANGE_PATTERN.test(authored)) return authored;
1293
- if (authored.startsWith("workspace:")) {
1294
- const workspaceRange = authored.slice("workspace:".length);
1295
- if (PORTABLE_WORKSPACE_RANGE_PATTERN.test(workspaceRange)) return workspaceRange;
1296
- }
1297
- const operator = authored === "workspace:~" ? "~" : "^";
1298
- return portableRangeFromInstalled(currentVersion, operator);
1299
- }
1300
- function resolveNpmAliasRange(spec) {
1301
- const at = spec.lastIndexOf("@");
1302
- if (at <= "npm:".length) return void 0;
1303
- return spec.slice(at + 1);
1304
- }
1305
- function portableRangeFromInstalled(currentVersion, operator) {
1306
- const core = currentVersion?.match(VERSION_CORE_PATTERN)?.[0];
1307
- return core ? `${operator}${core}` : "*";
1308
- }
1309
- function readPackageIdentity(cwd) {
1310
- const packagePath = nearestPackageJson(cwd);
1311
- if (packagePath === void 0) {
1312
- throw new Error(`Could not find a package.json from ${JSON.stringify(cwd)} to build the design system manifest.`);
1313
- }
1314
- const pkg = JSON.parse(readFileSync3(packagePath, "utf8"));
1315
- const name = pkg.name;
1316
- if (typeof name !== "string" || name.length === 0) {
1317
- throw new Error(`${JSON.stringify(packagePath)} has no "name"; a design system must be a named package.`);
1318
- }
1319
- const peer = pkg.peerDependencies?.["@pandacss/dev"];
1320
- return {
1321
- name,
1322
- version: typeof pkg.version === "string" ? pkg.version : void 0,
1323
- pandaPeer: typeof peer === "string" ? peer : void 0,
1324
- packagePath,
1325
- publishFiles: readPublishFilesField(pkg.files)
1326
- };
1327
- }
1328
- function defaultImportMap(name) {
1329
- return {
1330
- css: `${name}/css`,
1331
- recipes: `${name}/recipes`,
1332
- patterns: `${name}/patterns`,
1333
- jsx: `${name}/jsx`,
1334
- tokens: `${name}/tokens`
1335
- };
1336
- }
1337
- function syncExports(options) {
1338
- const { packageJson, entries } = options;
1339
- const pkg = JSON.parse(packageJson);
1340
- const existing = normalizeExports(pkg.exports);
1341
- const merged = { ...existing };
1342
- const conflicts = [];
1343
- for (const [key, value] of Object.entries(entries)) {
1344
- if (key in existing && existing[key] !== value) {
1345
- conflicts.push(key);
1346
- }
1347
- merged[key] = value;
1348
- }
1349
- const changed = JSON.stringify(pkg.exports) !== JSON.stringify(merged);
1350
- const out = { ...pkg, exports: merged };
1351
- return { changed, json: `${JSON.stringify(out, null, 2)}
1352
- `, conflicts };
1353
- }
1354
- function normalizeExports(exports) {
1355
- if (exports === void 0) return {};
1356
- if (typeof exports === "string") return { ".": exports };
1357
- if (Array.isArray(exports)) return { ".": exports };
1358
- if (!isPlainObject(exports)) return {};
1359
- if (isSubpathExportMap(exports)) return exports;
1360
- return { ".": exports };
1361
- }
1362
- function isSubpathExportMap(exports) {
1363
- return Object.keys(exports).some((key) => key === "." || key.startsWith("./"));
1364
- }
1365
- function nearestPackageJson(start) {
1366
- let current = start;
1367
- while (true) {
1368
- const candidate = join4(current, "package.json");
1369
- if (existsSync3(candidate)) return candidate;
1370
- const parent = dirname6(current);
1371
- if (parent === current) return void 0;
1372
- current = parent;
1373
- }
1374
- }
1375
1637
  export {
1638
+ buildCodegenOverlay,
1376
1639
  bundleConfig,
1640
+ collectArtifactConflicts,
1641
+ collectExportMissingDiagnostics,
1642
+ collectNameCollisionDiagnostics,
1643
+ collectPatternNames,
1644
+ collectRecipeNames,
1377
1645
  collectTokenPaths,
1378
1646
  compilePreset,
1379
1647
  createConfigSnapshot,
@@ -1381,6 +1649,8 @@ export {
1381
1649
  diffConfig,
1382
1650
  filterPublishableLibFiles,
1383
1651
  findConfig,
1652
+ getPandaMajorRange,
1653
+ isStampablePandaRange,
1384
1654
  loadConfig,
1385
1655
  mergeConfigs,
1386
1656
  mergeExcludes,