@pandacss/config 1.11.3 → 2.0.0-beta.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.
- package/LICENSE.md +1 -1
- package/README.md +12 -0
- package/dist/chunk-LUSBBUHX.js +250 -0
- package/dist/chunk-VYX3JX5J.js +106 -0
- package/dist/index.d.ts +68 -43
- package/dist/index.js +532 -1078
- package/dist/merge-Bt4BM1CH.d.ts +47 -0
- package/dist/merge.d.ts +2 -0
- package/dist/merge.js +8 -0
- package/dist/serialize.d.ts +17 -0
- package/dist/serialize.js +6 -0
- package/package.json +25 -61
- package/dist/chunk-BJRWQ6BQ.mjs +0 -154
- package/dist/chunk-FQ7G6ORY.mjs +0 -265
- package/dist/chunk-RPIVZP2I.mjs +0 -22
- package/dist/diff-config.d.mts +0 -9
- package/dist/diff-config.d.ts +0 -9
- package/dist/diff-config.js +0 -188
- package/dist/diff-config.mjs +0 -6
- package/dist/index.d.mts +0 -59
- package/dist/index.mjs +0 -693
- package/dist/merge-config.d.mts +0 -14
- package/dist/merge-config.d.ts +0 -14
- package/dist/merge-config.js +0 -259
- package/dist/merge-config.mjs +0 -8
- package/dist/resolve-ts-path-pattern.d.mts +0 -8
- package/dist/resolve-ts-path-pattern.d.ts +0 -8
- package/dist/resolve-ts-path-pattern.js +0 -46
- package/dist/resolve-ts-path-pattern.mjs +0 -6
- package/dist/ts-config-paths-qwrwgu2Q.d.mts +0 -10
- package/dist/ts-config-paths-qwrwgu2Q.d.ts +0 -10
package/dist/index.js
CHANGED
|
@@ -1,1149 +1,603 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
bundleConfig: () => bundleConfig,
|
|
34
|
-
convertTsPathsToRegexes: () => convertTsPathsToRegexes,
|
|
35
|
-
diffConfigs: () => diffConfigs,
|
|
36
|
-
findConfig: () => findConfig,
|
|
37
|
-
getConfigDependencies: () => getConfigDependencies,
|
|
38
|
-
getResolvedConfig: () => getResolvedConfig,
|
|
39
|
-
loadConfig: () => loadConfig,
|
|
40
|
-
mergeConfigs: () => mergeConfigs,
|
|
41
|
-
mergeHooks: () => mergeHooks,
|
|
42
|
-
resolveConfig: () => resolveConfig
|
|
43
|
-
});
|
|
44
|
-
module.exports = __toCommonJS(index_exports);
|
|
45
|
-
|
|
46
|
-
// src/bundle-config.ts
|
|
47
|
-
var import_logger = require("@pandacss/logger");
|
|
48
|
-
var import_shared2 = require("@pandacss/shared");
|
|
49
|
-
|
|
50
|
-
// src/bundle-n-require.ts
|
|
51
|
-
var import_node_fs = require("fs");
|
|
52
|
-
var import_node_module = require("module");
|
|
53
|
-
var import_node_path = require("path");
|
|
54
|
-
var import_esbuild = require("esbuild");
|
|
55
|
-
var ModuleInternals = import_node_module.Module;
|
|
56
|
-
async function bundleConfigFile(file, cwd, options) {
|
|
57
|
-
const result = await (0, import_esbuild.build)({
|
|
58
|
-
platform: "node",
|
|
59
|
-
format: "cjs",
|
|
60
|
-
mainFields: ["module", "main"],
|
|
61
|
-
...options,
|
|
62
|
-
absWorkingDir: cwd,
|
|
63
|
-
entryPoints: [file],
|
|
64
|
-
outfile: "out.js",
|
|
65
|
-
write: false,
|
|
66
|
-
bundle: true,
|
|
67
|
-
sourcemap: false,
|
|
68
|
-
metafile: true
|
|
69
|
-
});
|
|
70
|
-
const { text } = result.outputFiles[0];
|
|
1
|
+
import {
|
|
2
|
+
PandaError,
|
|
3
|
+
isPlainObject,
|
|
4
|
+
mergeConfigs,
|
|
5
|
+
mergeConfigsWithSources
|
|
6
|
+
} from "./chunk-LUSBBUHX.js";
|
|
7
|
+
import {
|
|
8
|
+
collectPluginHookHandlers,
|
|
9
|
+
createConfigSnapshot,
|
|
10
|
+
normalizeHook
|
|
11
|
+
} from "./chunk-VYX3JX5J.js";
|
|
12
|
+
|
|
13
|
+
// src/load.ts
|
|
14
|
+
import { applyConfigDefaults } from "@pandacss/compiler-shared";
|
|
15
|
+
|
|
16
|
+
// src/bundle.ts
|
|
17
|
+
import { existsSync, realpathSync } from "fs";
|
|
18
|
+
import { mkdir, unlink, writeFile } from "fs/promises";
|
|
19
|
+
import { builtinModules } from "module";
|
|
20
|
+
import { tmpdir } from "os";
|
|
21
|
+
import { dirname, isAbsolute as isAbsolute2, join, normalize, relative } from "path";
|
|
22
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
23
|
+
import { rolldown } from "rolldown";
|
|
24
|
+
|
|
25
|
+
// src/bundle-plugins.ts
|
|
26
|
+
import { parse } from "acorn";
|
|
27
|
+
import { simple } from "acorn-walk";
|
|
28
|
+
import MagicString from "magic-string";
|
|
29
|
+
import { isAbsolute } from "path";
|
|
30
|
+
import { pathToFileURL } from "url";
|
|
31
|
+
function importMetaUrlPlugin() {
|
|
71
32
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
33
|
+
name: "panda-import-meta-url",
|
|
34
|
+
transform(code, id) {
|
|
35
|
+
if (!isAbsolute(id) || !code.includes("import.meta.url")) return;
|
|
36
|
+
const replacement = JSON.stringify(pathToFileURL(id).href);
|
|
37
|
+
const patched = replaceImportMetaUrl(code, replacement);
|
|
38
|
+
if (patched === code) return;
|
|
39
|
+
return { code: patched, map: null };
|
|
40
|
+
}
|
|
74
41
|
};
|
|
75
42
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
43
|
+
function replaceImportMetaUrl(code, replacement) {
|
|
44
|
+
const ast = parse(code, {
|
|
45
|
+
ecmaVersion: "latest",
|
|
46
|
+
sourceType: "module"
|
|
47
|
+
});
|
|
48
|
+
const output = new MagicString(code);
|
|
49
|
+
let changed = false;
|
|
50
|
+
simple(ast, {
|
|
51
|
+
MemberExpression(node) {
|
|
52
|
+
if (!isImportMetaUrl(node)) return;
|
|
53
|
+
output.overwrite(node.start, node.end, replacement);
|
|
54
|
+
changed = true;
|
|
86
55
|
}
|
|
87
|
-
};
|
|
56
|
+
});
|
|
57
|
+
return changed ? output.toString() : code;
|
|
58
|
+
}
|
|
59
|
+
function isImportMetaUrl(node) {
|
|
60
|
+
if (node.computed || !isIdentifier(node.property, "url")) return false;
|
|
61
|
+
const object = node.object;
|
|
62
|
+
return isNode(object, "MetaProperty") && isIdentifier(object.meta, "import") && isIdentifier(object.property, "meta");
|
|
63
|
+
}
|
|
64
|
+
function isIdentifier(value, name) {
|
|
65
|
+
return isNode(value, "Identifier") && value.name === name;
|
|
66
|
+
}
|
|
67
|
+
function isNode(value, type) {
|
|
68
|
+
return !!value && typeof value === "object" && value.type === type;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/bundle.ts
|
|
72
|
+
var nodeBuiltins = /* @__PURE__ */ new Set([...builtinModules, ...builtinModules.map((mod) => `node:${mod}`)]);
|
|
73
|
+
async function bundleConfig(filepath, cwd) {
|
|
74
|
+
const build = await rolldown({
|
|
75
|
+
input: filepath,
|
|
76
|
+
cwd,
|
|
77
|
+
platform: "node",
|
|
78
|
+
external: (id) => nodeBuiltins.has(id),
|
|
79
|
+
treeshake: false,
|
|
80
|
+
plugins: [importMetaUrlPlugin()]
|
|
81
|
+
});
|
|
82
|
+
let chunks;
|
|
88
83
|
try {
|
|
89
|
-
|
|
90
|
-
const raw = req(file);
|
|
91
|
-
return raw?.default ?? raw;
|
|
84
|
+
chunks = await build.generate({ format: "esm", exports: "named", codeSplitting: false });
|
|
92
85
|
} finally {
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
await build.close?.();
|
|
87
|
+
}
|
|
88
|
+
const output = chunks.output.find((item) => item.type === "chunk");
|
|
89
|
+
if (!output || output.type !== "chunk") {
|
|
90
|
+
throw new PandaError("CONFIG_ERROR", "\u{1F4A5} Config bundle did not produce an executable module.");
|
|
91
|
+
}
|
|
92
|
+
const dependencies = collectDependencies(chunks.output, filepath, cwd);
|
|
93
|
+
const mod = await loadBundledModule(filepath, output.code);
|
|
94
|
+
const hasDefaultExport = Object.prototype.hasOwnProperty.call(mod ?? {}, "default");
|
|
95
|
+
const exported = hasDefaultExport ? mod.default : mod;
|
|
96
|
+
const config = hasDefaultExport && isPromiseLike(exported) ? await exported : exported;
|
|
97
|
+
return { config, dependencies };
|
|
98
|
+
}
|
|
99
|
+
async function loadBundledModule(filepath, code) {
|
|
100
|
+
const target = tempTargetFor(filepath);
|
|
101
|
+
if (target) {
|
|
102
|
+
try {
|
|
103
|
+
await mkdir(dirname(target), { recursive: true });
|
|
104
|
+
await writeFile(target, code);
|
|
105
|
+
try {
|
|
106
|
+
return await import(
|
|
107
|
+
/* @vite-ignore */
|
|
108
|
+
pathToFileURL2(target).href
|
|
109
|
+
);
|
|
110
|
+
} finally {
|
|
111
|
+
void unlink(target).catch(() => void 0);
|
|
112
|
+
}
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const dataUrl = `data:text/javascript;base64,${Buffer.from(code).toString("base64")}`;
|
|
117
|
+
return await import(
|
|
118
|
+
/* @vite-ignore */
|
|
119
|
+
dataUrl
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
function tempTargetFor(filepath) {
|
|
123
|
+
const unique = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
124
|
+
const name = `panda.config.bundled.${unique}.mjs`;
|
|
125
|
+
const nodeModules = nearestNodeModules(dirname(filepath));
|
|
126
|
+
const base = nodeModules ? join(nodeModules, ".panda") : join(tmpdir(), "panda-config");
|
|
127
|
+
return join(base, name);
|
|
128
|
+
}
|
|
129
|
+
function nearestNodeModules(start) {
|
|
130
|
+
let current = start;
|
|
131
|
+
while (true) {
|
|
132
|
+
const candidate = join(current, "node_modules");
|
|
133
|
+
if (existsSync(candidate)) return candidate;
|
|
134
|
+
const parent = dirname(current);
|
|
135
|
+
if (parent === current) return void 0;
|
|
136
|
+
current = parent;
|
|
95
137
|
}
|
|
96
138
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
mod.filename = file;
|
|
100
|
-
mod.paths = ModuleInternals._nodeModulePaths((0, import_node_path.dirname)(file));
|
|
101
|
-
mod._compile(code, file);
|
|
102
|
-
const raw = mod.exports;
|
|
103
|
-
return raw?.default ?? raw;
|
|
139
|
+
function isPromiseLike(value) {
|
|
140
|
+
return value != null && typeof value === "object" && typeof value.then === "function";
|
|
104
141
|
}
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
|
|
142
|
+
function collectDependencies(output, entry, cwd) {
|
|
143
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
144
|
+
const base = canonical(cwd);
|
|
145
|
+
const add = (id) => dependencies.add(normalize(relative(base, canonical(id))));
|
|
146
|
+
for (const item of output) {
|
|
147
|
+
if (item.type !== "chunk") continue;
|
|
148
|
+
Object.keys(item.modules ?? {}).forEach((id) => {
|
|
149
|
+
if (isAbsolute2(id)) add(id);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (isAbsolute2(entry)) add(entry);
|
|
153
|
+
return Array.from(dependencies);
|
|
154
|
+
}
|
|
155
|
+
function canonical(filepath) {
|
|
111
156
|
try {
|
|
112
|
-
|
|
157
|
+
return realpathSync(filepath);
|
|
113
158
|
} catch {
|
|
114
|
-
|
|
159
|
+
return filepath;
|
|
115
160
|
}
|
|
116
|
-
return { mod, code, dependencies };
|
|
117
161
|
}
|
|
118
162
|
|
|
119
|
-
// src/find
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
`${configName}.config.mts`,
|
|
130
|
-
`${configName}.config.mjs`,
|
|
131
|
-
`${configName}.config.cts`,
|
|
132
|
-
`${configName}.config.cjs`
|
|
163
|
+
// src/find.ts
|
|
164
|
+
import { readdirSync } from "fs";
|
|
165
|
+
import { dirname as dirname2, resolve } from "path";
|
|
166
|
+
var configFiles = /* @__PURE__ */ new Set([
|
|
167
|
+
"panda.config.ts",
|
|
168
|
+
"panda.config.js",
|
|
169
|
+
"panda.config.mts",
|
|
170
|
+
"panda.config.mjs",
|
|
171
|
+
"panda.config.cts",
|
|
172
|
+
"panda.config.cjs"
|
|
133
173
|
]);
|
|
134
|
-
var isPandaConfig = (file) =>
|
|
135
|
-
|
|
136
|
-
|
|
174
|
+
var isPandaConfig = (file) => configFiles.has(file);
|
|
175
|
+
function findUp(cwd) {
|
|
176
|
+
let dir = resolve(cwd);
|
|
177
|
+
while (true) {
|
|
178
|
+
let entries;
|
|
179
|
+
try {
|
|
180
|
+
entries = readdirSync(dir);
|
|
181
|
+
} catch {
|
|
182
|
+
entries = [];
|
|
183
|
+
}
|
|
184
|
+
const match = entries.find(isPandaConfig);
|
|
185
|
+
if (match) return resolve(dir, match);
|
|
186
|
+
const parent = dirname2(dir);
|
|
187
|
+
if (parent === dir) return void 0;
|
|
188
|
+
dir = parent;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
137
191
|
function findConfig(options) {
|
|
138
|
-
const { cwd
|
|
192
|
+
const { cwd, file } = options;
|
|
139
193
|
if (file) {
|
|
140
|
-
return
|
|
194
|
+
return resolve(cwd, file);
|
|
141
195
|
}
|
|
142
|
-
const configPath = (
|
|
196
|
+
const configPath = findUp(cwd);
|
|
143
197
|
if (!configPath) {
|
|
144
|
-
throw new
|
|
198
|
+
throw new PandaError(
|
|
145
199
|
"CONFIG_NOT_FOUND",
|
|
146
|
-
|
|
200
|
+
"Cannot find config file `panda.config.{ts,js,mjs,mts}`. Did you forget to run `panda init`?"
|
|
147
201
|
);
|
|
148
202
|
}
|
|
149
203
|
return configPath;
|
|
150
204
|
}
|
|
151
205
|
|
|
152
|
-
// src/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
throw new import_shared2.PandaError("CONFIG_ERROR", `\u{1F4A5} Config must export or return an object.`);
|
|
168
|
-
}
|
|
169
|
-
result.config.outdir ??= "styled-system";
|
|
170
|
-
result.config.validation ??= "warn";
|
|
171
|
-
return {
|
|
172
|
-
...result,
|
|
173
|
-
config: result.config,
|
|
174
|
-
path: filePath
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// src/diff-config.ts
|
|
179
|
-
var import_shared3 = require("@pandacss/shared");
|
|
180
|
-
var import_microdiff = __toESM(require("microdiff"));
|
|
181
|
-
|
|
182
|
-
// src/create-matcher.ts
|
|
183
|
-
function createMatcher(id, patterns) {
|
|
184
|
-
if (!patterns?.length) return () => void 0;
|
|
185
|
-
const includePatterns = [];
|
|
186
|
-
const excludePatterns = [];
|
|
187
|
-
const deduped = new Set(patterns);
|
|
188
|
-
deduped.forEach((pattern) => {
|
|
189
|
-
const regexString = pattern.replace(/\*/g, ".*");
|
|
190
|
-
if (pattern.startsWith("!")) {
|
|
191
|
-
excludePatterns.push(regexString.slice(1));
|
|
192
|
-
} else {
|
|
193
|
-
includePatterns.push(regexString);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
const include = new RegExp(includePatterns.join("|"));
|
|
197
|
-
const exclude = new RegExp(excludePatterns.join("|"));
|
|
198
|
-
return (path2) => {
|
|
199
|
-
if (excludePatterns.length && exclude.test(path2)) return;
|
|
200
|
-
return include.test(path2) ? id : void 0;
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// src/config-deps.ts
|
|
205
|
-
var all = [
|
|
206
|
-
"clean",
|
|
207
|
-
"cwd",
|
|
208
|
-
"eject",
|
|
209
|
-
"outdir",
|
|
210
|
-
"forceConsistentTypeExtension",
|
|
211
|
-
"outExtension",
|
|
212
|
-
"emitTokensOnly",
|
|
213
|
-
"presets",
|
|
214
|
-
"plugins",
|
|
215
|
-
"hooks"
|
|
216
|
-
];
|
|
217
|
-
var format = [
|
|
218
|
-
"syntax",
|
|
219
|
-
"hash",
|
|
220
|
-
"prefix",
|
|
221
|
-
"separator",
|
|
222
|
-
"strictTokens",
|
|
223
|
-
"strictPropertyValues",
|
|
224
|
-
"shorthands"
|
|
225
|
-
];
|
|
226
|
-
var tokens = [
|
|
227
|
-
"utilities",
|
|
228
|
-
"conditions",
|
|
229
|
-
"theme.tokens",
|
|
230
|
-
"theme.semanticTokens",
|
|
231
|
-
"theme.breakpoints",
|
|
232
|
-
"theme.containerNames",
|
|
233
|
-
"theme.containerSizes"
|
|
234
|
-
];
|
|
235
|
-
var jsx = ["jsxFramework", "jsxFactory", "jsxStyleProps", "syntax"];
|
|
236
|
-
var common = tokens.concat(jsx, format);
|
|
237
|
-
var artifactConfigDeps = {
|
|
238
|
-
helpers: ["syntax", "jsxFramework"],
|
|
239
|
-
keyframes: ["theme.keyframes", "layers"],
|
|
240
|
-
"design-tokens": ["layers", "!utilities.*.className"].concat(tokens),
|
|
241
|
-
types: ["!utilities.*.className"].concat(common),
|
|
242
|
-
"css-fn": common,
|
|
243
|
-
cva: ["syntax"],
|
|
244
|
-
sva: ["syntax"],
|
|
245
|
-
cx: [],
|
|
246
|
-
"create-recipe": ["separator", "prefix", "hash"],
|
|
247
|
-
"recipes-index": ["theme.recipes", "theme.slotRecipes"],
|
|
248
|
-
recipes: ["theme.recipes", "theme.slotRecipes"],
|
|
249
|
-
"patterns-index": ["syntax", "patterns"],
|
|
250
|
-
patterns: ["syntax", "patterns"],
|
|
251
|
-
"jsx-is-valid-prop": common,
|
|
252
|
-
"jsx-factory": jsx,
|
|
253
|
-
"jsx-helpers": jsx,
|
|
254
|
-
"jsx-patterns": jsx.concat("patterns"),
|
|
255
|
-
"jsx-patterns-index": jsx.concat("patterns"),
|
|
256
|
-
"jsx-create-style-context": jsx,
|
|
257
|
-
"css-index": ["syntax"],
|
|
258
|
-
"package.json": ["forceConsistentTypeExtension", "outExtension"],
|
|
259
|
-
"types-styles": ["shorthands"],
|
|
260
|
-
"types-conditions": ["conditions"],
|
|
261
|
-
"types-jsx": jsx,
|
|
262
|
-
"types-entry": [],
|
|
263
|
-
"types-gen": [],
|
|
264
|
-
"types-gen-system": [],
|
|
265
|
-
themes: ["themes"].concat(tokens),
|
|
266
|
-
// staticCss depends on tokens (for wildcards) and recipes (for recipe rules)
|
|
267
|
-
"static-css": ["staticCss", "patterns", "theme.recipes", "theme.slotRecipes"].concat(tokens),
|
|
268
|
-
// Split CSS artifacts (generated via cssgen --splitting)
|
|
269
|
-
styles: [],
|
|
270
|
-
"styles.css": []
|
|
271
|
-
};
|
|
272
|
-
var artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
|
|
273
|
-
if (!paths.length) return () => void 0;
|
|
274
|
-
return createMatcher(key, paths.concat(all));
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
// src/diff-config.ts
|
|
278
|
-
var runIfFn = (fn) => typeof fn === "function" ? fn() : fn;
|
|
279
|
-
var hasRecipeStateTransition = (prevConfig, nextConfig) => {
|
|
280
|
-
const prevRecipes = prevConfig.theme?.recipes ?? {};
|
|
281
|
-
const prevSlotRecipes = prevConfig.theme?.slotRecipes ?? {};
|
|
282
|
-
const prevHasRecipes = Object.keys(prevRecipes).length > 0 || Object.keys(prevSlotRecipes).length > 0;
|
|
283
|
-
const nextRecipes = nextConfig.theme?.recipes ?? {};
|
|
284
|
-
const nextSlotRecipes = nextConfig.theme?.slotRecipes ?? {};
|
|
285
|
-
const nextHasRecipes = Object.keys(nextRecipes).length > 0 || Object.keys(nextSlotRecipes).length > 0;
|
|
286
|
-
return prevHasRecipes !== nextHasRecipes;
|
|
287
|
-
};
|
|
288
|
-
function diffConfigs(config, prevConfig) {
|
|
289
|
-
const affected = {
|
|
290
|
-
artifacts: /* @__PURE__ */ new Set(),
|
|
291
|
-
hasConfigChanged: false,
|
|
292
|
-
diffs: []
|
|
293
|
-
};
|
|
294
|
-
if (!prevConfig) {
|
|
295
|
-
affected.hasConfigChanged = true;
|
|
296
|
-
return affected;
|
|
297
|
-
}
|
|
298
|
-
const configDiff = (0, import_microdiff.default)(prevConfig, runIfFn(config));
|
|
299
|
-
if (!configDiff.length) {
|
|
300
|
-
return affected;
|
|
301
|
-
}
|
|
302
|
-
affected.hasConfigChanged = true;
|
|
303
|
-
affected.diffs = configDiff;
|
|
304
|
-
configDiff.forEach((change) => {
|
|
305
|
-
const changePath = change.path.join(".");
|
|
306
|
-
artifactMatchers.forEach((matcher) => {
|
|
307
|
-
const id = matcher(changePath);
|
|
308
|
-
if (!id) return;
|
|
309
|
-
if (id === "recipes") {
|
|
310
|
-
const name = (0, import_shared3.dashCase)(change.path.slice(1, 3).join("."));
|
|
311
|
-
affected.artifacts.add(name);
|
|
312
|
-
}
|
|
313
|
-
if (id === "patterns") {
|
|
314
|
-
const name = (0, import_shared3.dashCase)(change.path.slice(0, 2).join("."));
|
|
315
|
-
affected.artifacts.add(name);
|
|
206
|
+
// src/hook-utils.ts
|
|
207
|
+
var configResolvedUtils = {
|
|
208
|
+
omit(obj, paths) {
|
|
209
|
+
const clone = cloneValue(obj);
|
|
210
|
+
for (const path of paths) {
|
|
211
|
+
deleteAtPath(clone, path);
|
|
212
|
+
}
|
|
213
|
+
return clone;
|
|
214
|
+
},
|
|
215
|
+
pick(obj, paths) {
|
|
216
|
+
const result = {};
|
|
217
|
+
for (const path of paths) {
|
|
218
|
+
const value = getAtPath(obj, path);
|
|
219
|
+
if (value !== void 0) {
|
|
220
|
+
setAtPath(result, path, value);
|
|
316
221
|
}
|
|
317
|
-
affected.artifacts.add(id);
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
if (affected.artifacts.has("recipes") || affected.artifacts.has("recipes-index")) {
|
|
321
|
-
const nextConfig = runIfFn(config);
|
|
322
|
-
if (hasRecipeStateTransition(prevConfig, nextConfig)) {
|
|
323
|
-
affected.artifacts.add("create-recipe");
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return affected;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// src/get-mod-deps.ts
|
|
330
|
-
var import_fs = __toESM(require("fs"));
|
|
331
|
-
var import_path4 = __toESM(require("path"));
|
|
332
|
-
var import_typescript = __toESM(require("typescript"));
|
|
333
|
-
|
|
334
|
-
// src/resolve-ts-path-pattern.ts
|
|
335
|
-
var import_path2 = require("path");
|
|
336
|
-
var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
|
|
337
|
-
for (const mapping of pathMappings) {
|
|
338
|
-
const match = moduleSpecifier.match(mapping.pattern);
|
|
339
|
-
if (!match) {
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
for (const pathTemplate of mapping.paths) {
|
|
343
|
-
let starCount = 0;
|
|
344
|
-
const mappedId = pathTemplate.replace(/\*/g, () => {
|
|
345
|
-
const matchIndex = Math.min(++starCount, match.length - 1);
|
|
346
|
-
return match[matchIndex];
|
|
347
|
-
});
|
|
348
|
-
return mappedId.split(import_path2.sep).join(import_path2.posix.sep);
|
|
349
222
|
}
|
|
223
|
+
return result;
|
|
224
|
+
},
|
|
225
|
+
traverse(obj, callback, options = {}) {
|
|
226
|
+
traverseValue(obj, callback, options);
|
|
350
227
|
}
|
|
351
228
|
};
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
function getPrefixLength(pattern) {
|
|
369
|
-
const prefixLength = pattern.indexOf("*");
|
|
370
|
-
return pattern.substr(0, prefixLength).length;
|
|
229
|
+
function cloneValue(value) {
|
|
230
|
+
if (Array.isArray(value)) {
|
|
231
|
+
const len = value.length;
|
|
232
|
+
const out2 = new Array(len);
|
|
233
|
+
for (let i = 0; i < len; i++) out2[i] = cloneValue(value[i]);
|
|
234
|
+
return out2;
|
|
235
|
+
}
|
|
236
|
+
if (!isPlainObject(value)) return value;
|
|
237
|
+
const source = value;
|
|
238
|
+
const out = {};
|
|
239
|
+
const keys = Object.keys(source);
|
|
240
|
+
for (let i = 0; i < keys.length; i++) {
|
|
241
|
+
const key = keys[i];
|
|
242
|
+
out[key] = cloneValue(source[key]);
|
|
243
|
+
}
|
|
244
|
+
return out;
|
|
371
245
|
}
|
|
372
|
-
function
|
|
373
|
-
return
|
|
246
|
+
function pathParts(path) {
|
|
247
|
+
return path.split(".").filter(Boolean);
|
|
374
248
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
function resolveWithExtension(file, extensions) {
|
|
381
|
-
for (const ext of extensions) {
|
|
382
|
-
const full = `${file}${ext}`;
|
|
383
|
-
if (import_fs.default.existsSync(full) && import_fs.default.statSync(full).isFile()) {
|
|
384
|
-
return full;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
for (const ext of extensions) {
|
|
388
|
-
const full = `${file}/index${ext}`;
|
|
389
|
-
if (import_fs.default.existsSync(full)) {
|
|
390
|
-
return full;
|
|
391
|
-
}
|
|
249
|
+
function getAtPath(value, path) {
|
|
250
|
+
let current = value;
|
|
251
|
+
for (const part of pathParts(path)) {
|
|
252
|
+
if (!isPlainObject(current) && !Array.isArray(current)) return void 0;
|
|
253
|
+
current = current[part];
|
|
392
254
|
}
|
|
393
|
-
return
|
|
255
|
+
return current;
|
|
394
256
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
const { moduleResolution: _, ...compilerOptions } = opts.compilerOptions ?? {};
|
|
402
|
-
const absoluteFile = resolveWithExtension(
|
|
403
|
-
import_path4.default.resolve(opts.cwd, filename),
|
|
404
|
-
jsExtensions.includes(opts.ext) ? jsResolutionOrder : tsResolutionOrder
|
|
405
|
-
);
|
|
406
|
-
if (absoluteFile === null) return;
|
|
407
|
-
if (fromAlias) {
|
|
408
|
-
opts.foundModuleAliases.set(fromAlias, absoluteFile);
|
|
409
|
-
}
|
|
410
|
-
if (seen.size > 1 && seen.has(absoluteFile)) return;
|
|
411
|
-
seen.add(absoluteFile);
|
|
412
|
-
const contents = import_fs.default.readFileSync(absoluteFile, "utf-8");
|
|
413
|
-
const fileDeps = [
|
|
414
|
-
...contents.matchAll(importRegex),
|
|
415
|
-
...contents.matchAll(importFromRegex),
|
|
416
|
-
...contents.matchAll(requireRegex),
|
|
417
|
-
...contents.matchAll(exportRegex)
|
|
418
|
-
];
|
|
419
|
-
if (!fileDeps.length) return;
|
|
420
|
-
const nextOpts = {
|
|
421
|
-
// Resolve new base for new imports/requires
|
|
422
|
-
cwd: import_path4.default.dirname(absoluteFile),
|
|
423
|
-
ext: import_path4.default.extname(absoluteFile),
|
|
424
|
-
seen,
|
|
425
|
-
baseUrl: opts.baseUrl,
|
|
426
|
-
pathMappings: opts.pathMappings,
|
|
427
|
-
foundModuleAliases: opts.foundModuleAliases
|
|
428
|
-
};
|
|
429
|
-
fileDeps.forEach((match) => {
|
|
430
|
-
const mod = match[1];
|
|
431
|
-
if (mod[0] === ".") {
|
|
432
|
-
getDeps(Object.assign({}, nextOpts, { filename: mod }));
|
|
257
|
+
function setAtPath(target, path, value) {
|
|
258
|
+
const parts = pathParts(path);
|
|
259
|
+
let current = target;
|
|
260
|
+
parts.forEach((part, index) => {
|
|
261
|
+
if (index === parts.length - 1) {
|
|
262
|
+
current[part] = cloneValue(value);
|
|
433
263
|
return;
|
|
434
264
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
getDeps(Object.assign({}, nextOpts, { filename: found.resolvedFileName }));
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
if (!opts.pathMappings) return;
|
|
442
|
-
const filename2 = resolveTsPathPattern(opts.pathMappings, mod);
|
|
443
|
-
if (!filename2) return;
|
|
444
|
-
getDeps(Object.assign({}, nextOpts, { filename: filename2 }), mod);
|
|
445
|
-
} catch {
|
|
265
|
+
const next = current[part];
|
|
266
|
+
if (!isPlainObject(next)) {
|
|
267
|
+
current[part] = {};
|
|
446
268
|
}
|
|
269
|
+
current = current[part];
|
|
447
270
|
});
|
|
448
271
|
}
|
|
449
|
-
function
|
|
450
|
-
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
pathMappings: tsOptions.pathMappings ?? [],
|
|
461
|
-
foundModuleAliases,
|
|
462
|
-
compilerOptions
|
|
463
|
-
});
|
|
464
|
-
return { deps, aliases: foundModuleAliases };
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// src/get-resolved-config.ts
|
|
468
|
-
var import_shared6 = require("@pandacss/shared");
|
|
469
|
-
|
|
470
|
-
// src/merge-config.ts
|
|
471
|
-
var import_shared5 = require("@pandacss/shared");
|
|
472
|
-
|
|
473
|
-
// src/merge-hooks.ts
|
|
474
|
-
var import_logger2 = require("@pandacss/logger");
|
|
475
|
-
var mergeHooks = (plugins) => {
|
|
476
|
-
const hooksFns = {};
|
|
477
|
-
plugins.forEach(({ name, hooks }) => {
|
|
478
|
-
Object.entries(hooks ?? {}).forEach(([key, value]) => {
|
|
479
|
-
if (!hooksFns[key]) {
|
|
480
|
-
hooksFns[key] = [];
|
|
481
|
-
}
|
|
482
|
-
hooksFns[key].push([name, value]);
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
const mergedHooks = Object.fromEntries(
|
|
486
|
-
Object.entries(hooksFns).map(([key, entries]) => {
|
|
487
|
-
const fns = entries.map(([name, fn]) => tryCatch(name, fn));
|
|
488
|
-
const reducer = key in reducers ? reducers[key] : void 0;
|
|
489
|
-
if (reducer) {
|
|
490
|
-
return [key, reducer(fns)];
|
|
491
|
-
}
|
|
492
|
-
return [key, syncHooks.includes(key) ? callAll(...fns) : callAllAsync(...fns)];
|
|
493
|
-
})
|
|
494
|
-
);
|
|
495
|
-
return mergedHooks;
|
|
496
|
-
};
|
|
497
|
-
var createReducer = (reducer) => reducer;
|
|
498
|
-
var reducers = {
|
|
499
|
-
"config:resolved": createReducer((fns) => async (_args) => {
|
|
500
|
-
const args = Object.assign({}, _args);
|
|
501
|
-
const original = _args.config;
|
|
502
|
-
let config = args.config;
|
|
503
|
-
for (const hookFn of fns) {
|
|
504
|
-
const result = await hookFn(Object.assign(args, { config, original }));
|
|
505
|
-
if (result !== void 0) {
|
|
506
|
-
config = result;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
return config;
|
|
510
|
-
}),
|
|
511
|
-
"parser:before": createReducer((fns) => (_args) => {
|
|
512
|
-
const args = Object.assign({}, _args);
|
|
513
|
-
const original = _args.content;
|
|
514
|
-
let content = args.content;
|
|
515
|
-
for (const hookFn of fns) {
|
|
516
|
-
const result = hookFn(Object.assign(args, { content, original }));
|
|
517
|
-
if (result !== void 0) {
|
|
518
|
-
content = result;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
return content;
|
|
522
|
-
}),
|
|
523
|
-
"parser:preprocess": createReducer((fns) => (_args) => {
|
|
524
|
-
const args = Object.assign({}, _args);
|
|
525
|
-
const original = _args.data;
|
|
526
|
-
let data = args.data;
|
|
527
|
-
for (const hookFn of fns) {
|
|
528
|
-
const result = hookFn(Object.assign(args, { data, original }));
|
|
529
|
-
if (result !== void 0) {
|
|
530
|
-
data = result;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
return data;
|
|
534
|
-
}),
|
|
535
|
-
"cssgen:done": createReducer((fns) => (_args) => {
|
|
536
|
-
const args = Object.assign({}, _args);
|
|
537
|
-
const original = _args.content;
|
|
538
|
-
let content = args.content;
|
|
539
|
-
for (const hookFn of fns) {
|
|
540
|
-
const result = hookFn(Object.assign(args, { content, original }));
|
|
541
|
-
if (result !== void 0) {
|
|
542
|
-
content = result;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
return content;
|
|
546
|
-
}),
|
|
547
|
-
"codegen:prepare": createReducer((fns) => async (_args) => {
|
|
548
|
-
const args = Object.assign({}, _args);
|
|
549
|
-
const original = _args.artifacts;
|
|
550
|
-
let artifacts = args.artifacts;
|
|
551
|
-
for (const hookFn of fns) {
|
|
552
|
-
const result = await hookFn(Object.assign(args, { artifacts, original }));
|
|
553
|
-
if (result) {
|
|
554
|
-
artifacts = result;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return artifacts;
|
|
558
|
-
}),
|
|
559
|
-
"preset:resolved": createReducer((fns) => async (_args) => {
|
|
560
|
-
const args = Object.assign({}, _args);
|
|
561
|
-
const original = _args.preset;
|
|
562
|
-
let preset = args.preset;
|
|
563
|
-
for (const hookFn of fns) {
|
|
564
|
-
const result = await hookFn(Object.assign(args, { preset, original }));
|
|
565
|
-
if (result !== void 0) {
|
|
566
|
-
preset = result;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
return preset;
|
|
570
|
-
}),
|
|
571
|
-
"css:optimize": createReducer((fns) => (_args) => {
|
|
572
|
-
const args = Object.assign({}, _args);
|
|
573
|
-
const original = _args.css;
|
|
574
|
-
let css = args.css;
|
|
575
|
-
for (const hookFn of fns) {
|
|
576
|
-
const result = hookFn(Object.assign(args, { css, original }));
|
|
577
|
-
if (result !== void 0) {
|
|
578
|
-
css = result;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return css;
|
|
582
|
-
})
|
|
583
|
-
};
|
|
584
|
-
var syncHooks = [
|
|
585
|
-
"context:created",
|
|
586
|
-
"parser:before",
|
|
587
|
-
"parser:preprocess",
|
|
588
|
-
"parser:after",
|
|
589
|
-
"cssgen:done",
|
|
590
|
-
"css:optimize"
|
|
591
|
-
];
|
|
592
|
-
var callAllAsync = (...fns) => async (...a) => {
|
|
593
|
-
for (const fn of fns) {
|
|
594
|
-
await fn?.(...a);
|
|
272
|
+
function deleteAtPath(target, path) {
|
|
273
|
+
const parts = pathParts(path);
|
|
274
|
+
const key = parts.pop();
|
|
275
|
+
if (!key) return;
|
|
276
|
+
let current = target;
|
|
277
|
+
for (const part of parts) {
|
|
278
|
+
if (!isPlainObject(current) && !Array.isArray(current)) return;
|
|
279
|
+
current = current[part];
|
|
280
|
+
}
|
|
281
|
+
if (isPlainObject(current) || Array.isArray(current)) {
|
|
282
|
+
delete current[key];
|
|
595
283
|
}
|
|
596
|
-
};
|
|
597
|
-
var callAll = (...fns) => (...a) => {
|
|
598
|
-
fns.forEach((fn) => fn?.(...a));
|
|
599
|
-
};
|
|
600
|
-
var tryCatch = (name, fn) => {
|
|
601
|
-
return (...args) => {
|
|
602
|
-
try {
|
|
603
|
-
return fn(...args);
|
|
604
|
-
} catch (e) {
|
|
605
|
-
import_logger2.logger.caughtError("hooks", `Error in plugin "${name}"`, e);
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
// src/validation/utils.ts
|
|
611
|
-
var import_shared4 = require("@pandacss/shared");
|
|
612
|
-
var REFERENCE_REGEX = /({([^}]*)})/g;
|
|
613
|
-
var curlyBracketRegex = /[{}]/g;
|
|
614
|
-
var isValidToken = (token) => (0, import_shared4.isObject)(token) && Object.hasOwnProperty.call(token, "value");
|
|
615
|
-
var isTokenReference = (value) => typeof value === "string" && REFERENCE_REGEX.test(value);
|
|
616
|
-
var formatPath = (path2) => path2;
|
|
617
|
-
var SEP = ".";
|
|
618
|
-
function getReferences(value) {
|
|
619
|
-
if (typeof value !== "string") return [];
|
|
620
|
-
const matches = value.match(REFERENCE_REGEX);
|
|
621
|
-
if (!matches) return [];
|
|
622
|
-
return matches.map((match) => match.replace(curlyBracketRegex, "")).map((value2) => {
|
|
623
|
-
return value2.trim().split("/")[0];
|
|
624
|
-
});
|
|
625
284
|
}
|
|
626
|
-
|
|
627
|
-
if (
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
if (
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
285
|
+
function traverseValue(value, callback, options, parent, key, path = "", depth = 0) {
|
|
286
|
+
if (parent && key !== void 0) {
|
|
287
|
+
callback({ value, path, depth, parent, key });
|
|
288
|
+
}
|
|
289
|
+
if (options.maxDepth !== void 0 && depth >= options.maxDepth) return;
|
|
290
|
+
if (!isPlainObject(value) && !Array.isArray(value)) return;
|
|
291
|
+
const separator = options.separator ?? ".";
|
|
292
|
+
const container = value;
|
|
293
|
+
const keys = Object.keys(container);
|
|
294
|
+
for (let i = 0; i < keys.length; i++) {
|
|
295
|
+
const childKey = keys[i];
|
|
296
|
+
traverseValue(
|
|
297
|
+
container[childKey],
|
|
298
|
+
callback,
|
|
299
|
+
options,
|
|
300
|
+
container,
|
|
301
|
+
childKey,
|
|
302
|
+
joinPath(path, childKey, separator),
|
|
303
|
+
depth + 1
|
|
304
|
+
);
|
|
635
305
|
}
|
|
636
|
-
return value.toString();
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
// src/merge-config.ts
|
|
640
|
-
function getExtends(items) {
|
|
641
|
-
return items.reduce((merged, { extend }) => {
|
|
642
|
-
if (!extend) return merged;
|
|
643
|
-
return (0, import_shared5.mergeWith)(merged, extend, (originalValue, newValue) => {
|
|
644
|
-
if (newValue === void 0) {
|
|
645
|
-
return originalValue ?? [];
|
|
646
|
-
}
|
|
647
|
-
if (originalValue === void 0) {
|
|
648
|
-
return [newValue];
|
|
649
|
-
}
|
|
650
|
-
if (Array.isArray(originalValue)) {
|
|
651
|
-
return [newValue, ...originalValue];
|
|
652
|
-
}
|
|
653
|
-
return [newValue, originalValue];
|
|
654
|
-
});
|
|
655
|
-
}, {});
|
|
656
306
|
}
|
|
657
|
-
function
|
|
307
|
+
function joinPath(parent, key, separator) {
|
|
308
|
+
return parent ? `${parent}${separator}${key}` : key;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// src/preset.ts
|
|
312
|
+
import { normalize as normalize2, relative as relative2 } from "path";
|
|
313
|
+
async function resolveAuthoredPresets(config, cwd, options = {}) {
|
|
314
|
+
const ctx = {
|
|
315
|
+
cwd,
|
|
316
|
+
configs: [],
|
|
317
|
+
dependencies: /* @__PURE__ */ new Set(),
|
|
318
|
+
presetResolvedHooks: [],
|
|
319
|
+
...options.trackSources ? { sourcedConfigs: [] } : {}
|
|
320
|
+
};
|
|
321
|
+
const rootSource = { kind: "config" };
|
|
322
|
+
if (options.configFile) rootSource.file = normalize2(relative2(cwd, options.configFile));
|
|
323
|
+
await collectConfigs(config, rootSource, ctx, /* @__PURE__ */ new WeakSet());
|
|
324
|
+
if (ctx.sourcedConfigs) {
|
|
325
|
+
const merged = mergeConfigsWithSources(ctx.sourcedConfigs);
|
|
326
|
+
if (options.preserveRuntimeHooks) attachRuntimeHooks(merged.config, ctx.configs);
|
|
327
|
+
return {
|
|
328
|
+
config: merged.config,
|
|
329
|
+
dependencies: Array.from(ctx.dependencies),
|
|
330
|
+
metadata: { sources: merged.sources }
|
|
331
|
+
};
|
|
332
|
+
}
|
|
658
333
|
return {
|
|
659
|
-
|
|
660
|
-
|
|
334
|
+
config: options.preserveRuntimeHooks ? attachRuntimeHooks(mergeConfigs(ctx.configs), ctx.configs) : mergeConfigs(ctx.configs),
|
|
335
|
+
dependencies: Array.from(ctx.dependencies)
|
|
661
336
|
};
|
|
662
337
|
}
|
|
663
|
-
function
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
338
|
+
function attachRuntimeHooks(config, configs) {
|
|
339
|
+
const plugins = configs.flatMap((item) => {
|
|
340
|
+
if ("hooks" in item && item.hooks != null) {
|
|
341
|
+
throw new PandaError(
|
|
342
|
+
"CONFIG_ERROR",
|
|
343
|
+
'\u{1F4A5} `config.hooks` was removed in v2. Use `plugins: [{ name: "local", hooks: { ... } }]` instead.'
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
return [...item.plugins ?? [], ...item.extend?.plugins ?? []];
|
|
667
347
|
});
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
348
|
+
for (const plugin of plugins) {
|
|
349
|
+
if (!isPlainObject(plugin) || typeof plugin.name !== "string" || plugin.name.length === 0) {
|
|
350
|
+
throw new PandaError(
|
|
351
|
+
"CONFIG_ERROR",
|
|
352
|
+
"\u{1F4A5} Every plugin in `config.plugins` must be an object with a non-empty `name`."
|
|
353
|
+
);
|
|
674
354
|
}
|
|
675
|
-
return acc;
|
|
676
|
-
}, {});
|
|
677
|
-
};
|
|
678
|
-
var tokenKeys = ["description", "extensions", "type", "value", "deprecated"];
|
|
679
|
-
function mergeConfigs(configs) {
|
|
680
|
-
const userConfig = configs.at(-1);
|
|
681
|
-
const pluginHooks = userConfig.plugins ?? [];
|
|
682
|
-
if (userConfig.hooks) {
|
|
683
|
-
pluginHooks.push({ name: import_shared5.PANDA_CONFIG_NAME, hooks: userConfig.hooks });
|
|
684
355
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
{
|
|
688
|
-
conditions: mergeExtensions(reversed.map((config) => config.conditions ?? {})),
|
|
689
|
-
theme: mergeExtensions(reversed.map((config) => config.theme ?? {})),
|
|
690
|
-
patterns: mergeExtensions(reversed.map((config) => config.patterns ?? {})),
|
|
691
|
-
utilities: mergeExtensions(reversed.map((config) => config.utilities ?? {})),
|
|
692
|
-
globalCss: mergeExtensions(reversed.map((config) => config.globalCss ?? {})),
|
|
693
|
-
globalVars: mergeExtensions(reversed.map((config) => config.globalVars ?? {})),
|
|
694
|
-
globalFontface: mergeExtensions(reversed.map((config) => config.globalFontface ?? {})),
|
|
695
|
-
globalPositionTry: mergeExtensions(reversed.map((config) => config.globalPositionTry ?? {})),
|
|
696
|
-
staticCss: mergeExtensions(reversed.map((config) => config.staticCss ?? {})),
|
|
697
|
-
themes: mergeExtensions(reversed.map((config) => config.themes ?? {})),
|
|
698
|
-
hooks: mergeHooks(pluginHooks)
|
|
699
|
-
},
|
|
700
|
-
...reversed
|
|
701
|
-
);
|
|
702
|
-
const withoutEmpty = compact(mergedResult);
|
|
703
|
-
if (withoutEmpty.theme?.tokens) {
|
|
704
|
-
(0, import_shared5.walkObject)(withoutEmpty.theme.tokens, (args) => args, {
|
|
705
|
-
stop(token) {
|
|
706
|
-
if (!isValidToken(token)) return false;
|
|
707
|
-
const keys = Object.keys(token);
|
|
708
|
-
const nestedKeys = keys.filter((k) => !tokenKeys.includes(k));
|
|
709
|
-
const nested = nestedKeys.length > 0;
|
|
710
|
-
if (nested) {
|
|
711
|
-
token.DEFAULT ||= {};
|
|
712
|
-
tokenKeys.forEach((key) => {
|
|
713
|
-
if (token[key] == null) return;
|
|
714
|
-
token.DEFAULT[key] ||= token[key];
|
|
715
|
-
delete token[key];
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
return true;
|
|
719
|
-
}
|
|
720
|
-
});
|
|
356
|
+
if (plugins.length > 0) {
|
|
357
|
+
config.plugins = plugins;
|
|
721
358
|
}
|
|
722
|
-
return
|
|
359
|
+
return config;
|
|
723
360
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
const presetModule = await bundle(subPreset, cwd);
|
|
742
|
-
presetConfig = presetModule.config;
|
|
743
|
-
presetName = subPreset;
|
|
744
|
-
} else {
|
|
745
|
-
presetConfig = await subPreset;
|
|
746
|
-
presetName = presetConfig.name || "unknown-preset";
|
|
747
|
-
}
|
|
748
|
-
if (hooks?.["preset:resolved"]) {
|
|
749
|
-
const resolvedPreset = await hooks["preset:resolved"]({
|
|
750
|
-
preset: presetConfig,
|
|
751
|
-
name: presetName,
|
|
752
|
-
utils: hookUtils
|
|
753
|
-
});
|
|
754
|
-
if (resolvedPreset !== void 0) {
|
|
755
|
-
presetConfig = resolvedPreset;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
stack.push(presetConfig);
|
|
759
|
-
}
|
|
760
|
-
configs.unshift(current);
|
|
761
|
-
}
|
|
762
|
-
const merged = mergeConfigs(configs);
|
|
763
|
-
merged.presets = configs.slice(0, -1);
|
|
764
|
-
return merged;
|
|
361
|
+
async function collectConfigs(config, source, ctx, active) {
|
|
362
|
+
if (active.has(config)) {
|
|
363
|
+
throw new PandaError("CONFIG_ERROR", "\u{1F4A5} Circular preset dependency detected.");
|
|
364
|
+
}
|
|
365
|
+
active.add(config);
|
|
366
|
+
const hookCount = ctx.presetResolvedHooks.length;
|
|
367
|
+
ctx.presetResolvedHooks.push(...collectPresetResolvedHooks(config));
|
|
368
|
+
for (const preset of config.presets ?? []) {
|
|
369
|
+
const resolved = await resolvePreset(preset, ctx.cwd);
|
|
370
|
+
resolved.dependencies.forEach((dependency) => ctx.dependencies.add(dependency));
|
|
371
|
+
const config2 = await runPresetResolvedHooks(resolved.config, resolved.source, ctx.presetResolvedHooks);
|
|
372
|
+
await collectConfigs(config2, resolved.source, ctx, active);
|
|
373
|
+
}
|
|
374
|
+
ctx.configs.push(config);
|
|
375
|
+
ctx.sourcedConfigs?.push({ config, source });
|
|
376
|
+
ctx.presetResolvedHooks.length = hookCount;
|
|
377
|
+
active.delete(config);
|
|
765
378
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
"@pandacss/dev/presets": import_preset_panda.preset
|
|
778
|
-
};
|
|
779
|
-
var bundledPresetsNames = Object.keys(bundledPresets);
|
|
780
|
-
var isBundledPreset = (preset) => bundledPresetsNames.includes(preset);
|
|
781
|
-
var getBundledPreset = (preset) => {
|
|
782
|
-
return typeof preset === "string" && isBundledPreset(preset) ? bundledPresets[preset] : void 0;
|
|
783
|
-
};
|
|
784
|
-
|
|
785
|
-
// src/validate-config.ts
|
|
786
|
-
var import_logger3 = require("@pandacss/logger");
|
|
787
|
-
var import_shared10 = require("@pandacss/shared");
|
|
788
|
-
|
|
789
|
-
// src/validation/validate-artifact.ts
|
|
790
|
-
var validateArtifactNames = (names, addError) => {
|
|
791
|
-
names.recipes.forEach((recipeName) => {
|
|
792
|
-
if (names.slotRecipes.has(recipeName)) {
|
|
793
|
-
addError("recipes", `This recipe name is already used in \`theme.slotRecipes\`: ${recipeName}`);
|
|
794
|
-
}
|
|
795
|
-
if (names.patterns.has(recipeName)) {
|
|
796
|
-
addError("recipes", `This recipe name is already used in \`patterns\`: \`${recipeName}\``);
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
names.slotRecipes.forEach((recipeName) => {
|
|
800
|
-
if (names.patterns.has(recipeName)) {
|
|
801
|
-
addError("recipes", `This recipe name is already used in \`patterns\`: ${recipeName}`);
|
|
379
|
+
function collectPresetResolvedHooks(config) {
|
|
380
|
+
return collectPluginHookHandlers(config, "preset:resolved");
|
|
381
|
+
}
|
|
382
|
+
async function runPresetResolvedHooks(preset, source, hooks) {
|
|
383
|
+
let current = preset;
|
|
384
|
+
const name = source.name ?? source.specifier ?? presetName(current) ?? "unknown-preset";
|
|
385
|
+
for (const entry of hooks) {
|
|
386
|
+
const hook = normalizeHook(entry.value, "preset:resolved");
|
|
387
|
+
const next = await hook.handler({ preset: current, name, utils: configResolvedUtils });
|
|
388
|
+
if (next !== void 0) {
|
|
389
|
+
current = ensureConfigObject(next, name);
|
|
802
390
|
}
|
|
803
|
-
});
|
|
804
|
-
};
|
|
805
|
-
|
|
806
|
-
// src/validation/validate-breakpoints.ts
|
|
807
|
-
var import_shared7 = require("@pandacss/shared");
|
|
808
|
-
var validateBreakpoints = (breakpoints, addError) => {
|
|
809
|
-
if (!breakpoints) return;
|
|
810
|
-
const units = /* @__PURE__ */ new Set();
|
|
811
|
-
const values = Object.values(breakpoints);
|
|
812
|
-
for (const value of values) {
|
|
813
|
-
const unit = (0, import_shared7.getUnit)(value) ?? "px";
|
|
814
|
-
units.add(unit);
|
|
815
|
-
}
|
|
816
|
-
if (units.size > 1) {
|
|
817
|
-
addError("breakpoints", `All breakpoints must use the same unit: \`${values.join(", ")}\``);
|
|
818
391
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
"conditions",
|
|
836
|
-
`Object condition leaves must be the literal string \`'@slot'\`, got \`${JSON.stringify(value)}\` at \`${key}\``
|
|
392
|
+
return current;
|
|
393
|
+
}
|
|
394
|
+
async function resolvePreset(preset, cwd) {
|
|
395
|
+
if (typeof preset === "string") {
|
|
396
|
+
try {
|
|
397
|
+
const result = await bundleConfig(preset, cwd);
|
|
398
|
+
return {
|
|
399
|
+
config: ensureConfigObject(result.config, preset),
|
|
400
|
+
dependencies: result.dependencies,
|
|
401
|
+
source: presetSource(result.config, preset, result.dependencies[0])
|
|
402
|
+
};
|
|
403
|
+
} catch (error) {
|
|
404
|
+
if (error instanceof PandaError) throw error;
|
|
405
|
+
throw new PandaError(
|
|
406
|
+
"CONFIG_ERROR",
|
|
407
|
+
`\u{1F4A5} Failed to resolve preset ${JSON.stringify(preset)}: ${errorMessage(error)}`
|
|
837
408
|
);
|
|
838
|
-
continue;
|
|
839
|
-
}
|
|
840
|
-
if (typeof value === "object" && value !== null) {
|
|
841
|
-
const nested = validateObjectCondition(value, addError);
|
|
842
|
-
if (nested.hasSlot) hasSlot = true;
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
return { hasSlot };
|
|
846
|
-
};
|
|
847
|
-
var validateConditions = (conditions, addError) => {
|
|
848
|
-
if (!conditions) return;
|
|
849
|
-
Object.values(conditions).forEach((condition) => {
|
|
850
|
-
if ((0, import_shared8.isString)(condition)) {
|
|
851
|
-
if (!condition.startsWith("@") && !condition.includes("&")) {
|
|
852
|
-
addError("conditions", `Selectors should contain the \`&\` character: \`${condition}\``);
|
|
853
|
-
}
|
|
854
|
-
return;
|
|
855
409
|
}
|
|
856
|
-
if (Array.isArray(condition)) {
|
|
857
|
-
condition.forEach((c) => {
|
|
858
|
-
if (!c.startsWith("@") && !c.includes("&")) {
|
|
859
|
-
addError("conditions", `Selectors should contain the \`&\` character: \`${c}\``);
|
|
860
|
-
}
|
|
861
|
-
});
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
864
|
-
const { hasSlot } = validateObjectCondition(condition, addError);
|
|
865
|
-
if (!hasSlot) {
|
|
866
|
-
addError("conditions", `Object conditions must contain at least one \`'@slot'\` marker`);
|
|
867
|
-
}
|
|
868
|
-
});
|
|
869
|
-
};
|
|
870
|
-
|
|
871
|
-
// src/validation/validate-patterns.ts
|
|
872
|
-
var validatePatterns = (patterns, names) => {
|
|
873
|
-
if (!patterns) return;
|
|
874
|
-
Object.keys(patterns).forEach((patternName) => {
|
|
875
|
-
names.patterns.add(patternName);
|
|
876
|
-
});
|
|
877
|
-
};
|
|
878
|
-
|
|
879
|
-
// src/validation/validate-recipes.ts
|
|
880
|
-
var validateRecipes = (options) => {
|
|
881
|
-
const {
|
|
882
|
-
config: { theme },
|
|
883
|
-
artifacts
|
|
884
|
-
} = options;
|
|
885
|
-
if (!theme) return;
|
|
886
|
-
if (theme.recipes) {
|
|
887
|
-
Object.keys(theme.recipes).forEach((recipeName) => {
|
|
888
|
-
artifacts.recipes.add(recipeName);
|
|
889
|
-
});
|
|
890
410
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
411
|
+
try {
|
|
412
|
+
const config = await preset;
|
|
413
|
+
return {
|
|
414
|
+
config: ensureConfigObject(config, config?.name ?? "unknown-preset"),
|
|
415
|
+
dependencies: [],
|
|
416
|
+
source: presetSource(config)
|
|
417
|
+
};
|
|
418
|
+
} catch (error) {
|
|
419
|
+
if (error instanceof PandaError) throw error;
|
|
420
|
+
throw new PandaError("CONFIG_ERROR", `\u{1F4A5} Failed to resolve preset "unknown-preset": ${errorMessage(error)}`);
|
|
895
421
|
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
422
|
+
}
|
|
423
|
+
function ensureConfigObject(config, name) {
|
|
424
|
+
if (isPlainObject(config)) return config;
|
|
425
|
+
throw new PandaError("CONFIG_ERROR", `\u{1F4A5} Preset ${JSON.stringify(name)} must resolve to an object.`);
|
|
426
|
+
}
|
|
427
|
+
function presetName(config) {
|
|
428
|
+
return isPlainObject(config) && typeof config.name === "string" ? config.name : void 0;
|
|
429
|
+
}
|
|
430
|
+
function presetSource(config, specifier, file) {
|
|
431
|
+
const source = { kind: "preset" };
|
|
432
|
+
const name = presetName(config);
|
|
433
|
+
if (name) source.name = name;
|
|
434
|
+
if (specifier) source.specifier = specifier;
|
|
435
|
+
if (file) source.file = file;
|
|
436
|
+
return source;
|
|
437
|
+
}
|
|
438
|
+
function errorMessage(error) {
|
|
439
|
+
return error instanceof Error ? error.message : String(error);
|
|
440
|
+
}
|
|
901
441
|
|
|
902
|
-
// src/
|
|
903
|
-
|
|
904
|
-
const {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
currentPath = tokenPath;
|
|
915
|
-
}
|
|
916
|
-
const value = valueAtPath.get(currentPath);
|
|
917
|
-
if (!value) {
|
|
918
|
-
const configKey = typeByPath.get(path2);
|
|
919
|
-
addError("tokens", `Missing token: \`${currentPath}\` used in \`theme.${configKey}.${path2}\``);
|
|
920
|
-
}
|
|
921
|
-
if (isTokenReference(value) && !refsByPath.has(value)) {
|
|
922
|
-
addError("tokens", `Unknown token reference: \`${currentPath}\` used in \`${value}\``);
|
|
923
|
-
}
|
|
924
|
-
const deps = refsByPath.get(currentPath);
|
|
925
|
-
if (!deps) continue;
|
|
926
|
-
for (const transitiveDep of deps) {
|
|
927
|
-
if (path2 === transitiveDep) {
|
|
928
|
-
addError(
|
|
929
|
-
"tokens",
|
|
930
|
-
`Circular token reference: \`${transitiveDep}\` -> \`${currentPath}\` -> ... -> \`${path2}\``
|
|
931
|
-
);
|
|
932
|
-
break;
|
|
933
|
-
}
|
|
934
|
-
stack.push(transitiveDep);
|
|
935
|
-
}
|
|
936
|
-
}
|
|
442
|
+
// src/load.ts
|
|
443
|
+
async function loadConfig(options) {
|
|
444
|
+
const { cwd, file } = options;
|
|
445
|
+
const path = findConfig({ cwd, file });
|
|
446
|
+
const { config, dependencies } = await bundleConfig(path, cwd);
|
|
447
|
+
if (!isPlainObject(config)) {
|
|
448
|
+
throw new PandaError("CONFIG_ERROR", "\u{1F4A5} Config must export or return an object.");
|
|
449
|
+
}
|
|
450
|
+
const authored = await resolveAuthoredPresets(config, cwd, {
|
|
451
|
+
configFile: path,
|
|
452
|
+
trackSources: options.trackSources,
|
|
453
|
+
preserveRuntimeHooks: true
|
|
937
454
|
});
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
const
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
(
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
if (path2.includes("DEFAULT")) {
|
|
959
|
-
valueAtPath.set(path2.replace(SEP + "DEFAULT", ""), value);
|
|
960
|
-
}
|
|
961
|
-
},
|
|
962
|
-
{
|
|
963
|
-
stop: isValidToken
|
|
964
|
-
}
|
|
965
|
-
);
|
|
966
|
-
tokenPaths.forEach((path2) => {
|
|
967
|
-
const itemValue = valueAtPath.get(path2);
|
|
968
|
-
const formattedPath = formatPath(path2);
|
|
969
|
-
typeByPath.set(formattedPath, "tokens");
|
|
970
|
-
if (!isValidToken(itemValue)) {
|
|
971
|
-
addError("tokens", `Token must contain 'value': \`theme.tokens.${formattedPath}\``);
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
if (path2.includes(" ")) {
|
|
975
|
-
addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
|
|
976
|
-
return;
|
|
977
|
-
}
|
|
978
|
-
const valueStr = serializeTokenValue(itemValue.value || itemValue);
|
|
979
|
-
if (isTokenReference(valueStr)) {
|
|
980
|
-
refsByPath.set(formattedPath, /* @__PURE__ */ new Set([]));
|
|
981
|
-
}
|
|
982
|
-
const references = refsByPath.get(formattedPath);
|
|
983
|
-
if (!references) return;
|
|
984
|
-
getReferences(valueStr).forEach((reference) => {
|
|
985
|
-
references.add(reference);
|
|
986
|
-
});
|
|
987
|
-
});
|
|
988
|
-
}
|
|
989
|
-
if (theme.semanticTokens) {
|
|
990
|
-
const tokenPaths = /* @__PURE__ */ new Set();
|
|
991
|
-
(0, import_shared9.walkObject)(
|
|
992
|
-
theme.semanticTokens,
|
|
993
|
-
(value, paths) => {
|
|
994
|
-
const path2 = paths.join(SEP);
|
|
995
|
-
semanticTokenNames.add(path2);
|
|
996
|
-
valueAtPath.set(path2, value);
|
|
997
|
-
tokenPaths.add(path2);
|
|
998
|
-
if (path2.includes("DEFAULT")) {
|
|
999
|
-
valueAtPath.set(path2.replace(SEP + "DEFAULT", ""), value);
|
|
1000
|
-
}
|
|
1001
|
-
if (!isValidToken(value)) return;
|
|
1002
|
-
(0, import_shared9.walkObject)(value, (itemValue, paths2) => {
|
|
1003
|
-
const valuePath = paths2.join(SEP);
|
|
1004
|
-
const formattedPath = formatPath(path2);
|
|
1005
|
-
typeByPath.set(formattedPath, "semanticTokens");
|
|
1006
|
-
const fullPath = formattedPath + "." + paths2.join(SEP);
|
|
1007
|
-
if (valuePath.includes("value" + SEP + "value")) {
|
|
1008
|
-
addError("tokens", `You used \`value\` twice resulting in an invalid token \`theme.tokens.${fullPath}\``);
|
|
1009
|
-
}
|
|
1010
|
-
const valueStr = serializeTokenValue(itemValue.value || itemValue);
|
|
1011
|
-
if (isTokenReference(valueStr)) {
|
|
1012
|
-
if (!refsByPath.has(formattedPath)) {
|
|
1013
|
-
refsByPath.set(formattedPath, /* @__PURE__ */ new Set());
|
|
1014
|
-
}
|
|
1015
|
-
const references = refsByPath.get(formattedPath);
|
|
1016
|
-
if (!references) return;
|
|
1017
|
-
getReferences(valueStr).forEach((reference) => {
|
|
1018
|
-
references.add(reference);
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
1022
|
-
},
|
|
1023
|
-
{
|
|
1024
|
-
stop: isValidToken
|
|
1025
|
-
}
|
|
1026
|
-
);
|
|
1027
|
-
tokenPaths.forEach((path2) => {
|
|
1028
|
-
const formattedPath = formatPath(path2);
|
|
1029
|
-
const value = valueAtPath.get(path2);
|
|
1030
|
-
if (path2.includes(" ")) {
|
|
1031
|
-
addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
|
|
1032
|
-
return;
|
|
1033
|
-
}
|
|
1034
|
-
if (!(0, import_shared9.isObject)(value) && !path2.includes("value")) {
|
|
1035
|
-
addError("tokens", `Token must contain 'value': \`theme.semanticTokens.${formattedPath}\``);
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
validateTokenReferences({ valueAtPath, refsByPath, addError, typeByPath });
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
// src/validate-config.ts
|
|
1043
|
-
var validateConfig = (config) => {
|
|
1044
|
-
if (config.validation === "none") return;
|
|
1045
|
-
const warnings = /* @__PURE__ */ new Set();
|
|
1046
|
-
const addError = (scope, message) => {
|
|
1047
|
-
warnings.add(`[${scope}] ` + message);
|
|
1048
|
-
};
|
|
1049
|
-
validateBreakpoints(config.theme?.breakpoints, addError);
|
|
1050
|
-
validateConditions(config.conditions, addError);
|
|
1051
|
-
const artifacts = {
|
|
1052
|
-
recipes: /* @__PURE__ */ new Set(),
|
|
1053
|
-
slotRecipes: /* @__PURE__ */ new Set(),
|
|
1054
|
-
patterns: /* @__PURE__ */ new Set()
|
|
1055
|
-
};
|
|
1056
|
-
const tokens2 = {
|
|
1057
|
-
tokenNames: /* @__PURE__ */ new Set(),
|
|
1058
|
-
semanticTokenNames: /* @__PURE__ */ new Set(),
|
|
1059
|
-
valueAtPath: /* @__PURE__ */ new Map(),
|
|
1060
|
-
refsByPath: /* @__PURE__ */ new Map(),
|
|
1061
|
-
typeByPath: /* @__PURE__ */ new Map()
|
|
455
|
+
const authoredDependencies = Array.from(
|
|
456
|
+
/* @__PURE__ */ new Set([...dependencies, ...authored.dependencies, ...authored.config.dependencies ?? []])
|
|
457
|
+
);
|
|
458
|
+
const userConfig = await runConfigResolvedHooks(authored.config, path, authoredDependencies);
|
|
459
|
+
const resolved = applyConfigDefaults(userConfig, cwd);
|
|
460
|
+
const dependencyList = Array.from(
|
|
461
|
+
/* @__PURE__ */ new Set([...dependencies, ...authored.dependencies, ...resolved.dependencies ?? []])
|
|
462
|
+
);
|
|
463
|
+
const snapshot = createConfigSnapshot(resolved);
|
|
464
|
+
return {
|
|
465
|
+
path,
|
|
466
|
+
config: snapshot.config,
|
|
467
|
+
callbacks: snapshot.callbacks,
|
|
468
|
+
...snapshot.hooks ? { hooks: snapshot.hooks } : {},
|
|
469
|
+
hostHooks: {
|
|
470
|
+
"codegen:prepare": collectPluginHookHandlers(resolved, "codegen:prepare"),
|
|
471
|
+
"codegen:done": collectPluginHookHandlers(resolved, "codegen:done")
|
|
472
|
+
},
|
|
473
|
+
dependencies: dependencyList,
|
|
474
|
+
...authored.metadata ? { metadata: authored.metadata } : {}
|
|
1062
475
|
};
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
throw new import_shared10.PandaError("CONFIG_ERROR", errors);
|
|
476
|
+
}
|
|
477
|
+
async function runConfigResolvedHooks(config, path, dependencies) {
|
|
478
|
+
let current = config;
|
|
479
|
+
for (const entry of collectPluginHookHandlers(current, "config:resolved")) {
|
|
480
|
+
const hook = normalizeHook(entry.value, "config:resolved");
|
|
481
|
+
const next = await hook.handler({ config: current, path, dependencies, utils: configResolvedUtils });
|
|
482
|
+
if (next !== void 0) {
|
|
483
|
+
if (!isPlainObject(next)) {
|
|
484
|
+
throw new PandaError("CONFIG_ERROR", "\u{1F4A5} config:resolved hook must return a config object or undefined.");
|
|
485
|
+
}
|
|
486
|
+
current = next;
|
|
1075
487
|
}
|
|
1076
|
-
import_logger3.logger.warn("config", errors);
|
|
1077
|
-
return warnings;
|
|
1078
488
|
}
|
|
1079
|
-
|
|
489
|
+
return current;
|
|
490
|
+
}
|
|
1080
491
|
|
|
1081
|
-
// src/
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
const
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
492
|
+
// src/diff.ts
|
|
493
|
+
import diff from "microdiff";
|
|
494
|
+
var ALL_DEPENDENCIES = [
|
|
495
|
+
"outExtension",
|
|
496
|
+
"forceImportExtension",
|
|
497
|
+
"conditions",
|
|
498
|
+
"hash",
|
|
499
|
+
"jsxFactory",
|
|
500
|
+
"jsxFramework",
|
|
501
|
+
"jsxStyleProps",
|
|
502
|
+
"patterns",
|
|
503
|
+
"prefix",
|
|
504
|
+
"recipes",
|
|
505
|
+
"separator",
|
|
506
|
+
"syntax",
|
|
507
|
+
"themes",
|
|
508
|
+
"tokens",
|
|
509
|
+
"utilities"
|
|
510
|
+
];
|
|
511
|
+
function diffConfig(prev, next) {
|
|
512
|
+
if (!prev) {
|
|
513
|
+
return { hasChanged: true, dependencies: [...ALL_DEPENDENCIES], recipes: [], patterns: [], changes: [] };
|
|
514
|
+
}
|
|
515
|
+
const prevInput = diffInput(prev);
|
|
516
|
+
const nextInput = diffInput(next);
|
|
517
|
+
const changes = diff(prevInput, nextInput);
|
|
518
|
+
if (changes.length === 0) {
|
|
519
|
+
return { hasChanged: false, dependencies: [], recipes: [], patterns: [], changes };
|
|
520
|
+
}
|
|
521
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
522
|
+
const recipes = /* @__PURE__ */ new Set();
|
|
523
|
+
const patterns = /* @__PURE__ */ new Set();
|
|
524
|
+
for (const change of changes) {
|
|
525
|
+
const classified = classify(change.path.map(String));
|
|
526
|
+
classified.deps.forEach((dep) => dependencies.add(dep));
|
|
527
|
+
if (classified.recipe) recipes.add(classified.recipe);
|
|
528
|
+
if (classified.pattern) patterns.add(classified.pattern);
|
|
1110
529
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
...
|
|
1114
|
-
|
|
530
|
+
return {
|
|
531
|
+
hasChanged: true,
|
|
532
|
+
dependencies: [...dependencies],
|
|
533
|
+
recipes: [...recipes],
|
|
534
|
+
patterns: [...patterns],
|
|
535
|
+
changes
|
|
1115
536
|
};
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
537
|
+
}
|
|
538
|
+
function classify(path) {
|
|
539
|
+
const [head, second, third] = path;
|
|
540
|
+
if (head === "config") return classify(path.slice(1));
|
|
541
|
+
if (head === "hooks") return { deps: [] };
|
|
542
|
+
if (head === "theme") {
|
|
543
|
+
if (second === "recipes" || second === "slotRecipes") {
|
|
544
|
+
return { deps: ["recipes"], recipe: third };
|
|
545
|
+
}
|
|
546
|
+
if (second === "containers" || second === "containerNames") {
|
|
547
|
+
return { deps: ["tokens", "conditions"] };
|
|
548
|
+
}
|
|
549
|
+
return { deps: ["tokens"] };
|
|
550
|
+
}
|
|
551
|
+
switch (head) {
|
|
552
|
+
case "conditions":
|
|
553
|
+
return { deps: ["conditions"] };
|
|
554
|
+
case "utilities":
|
|
555
|
+
return { deps: ["utilities"] };
|
|
556
|
+
case "patterns":
|
|
557
|
+
return { deps: ["patterns"], pattern: second };
|
|
558
|
+
case "themes":
|
|
559
|
+
return { deps: ["themes"] };
|
|
560
|
+
case "syntax":
|
|
561
|
+
return { deps: ["syntax"] };
|
|
562
|
+
case "hash":
|
|
563
|
+
return { deps: ["hash"] };
|
|
564
|
+
case "prefix":
|
|
565
|
+
return { deps: ["prefix"] };
|
|
566
|
+
case "separator":
|
|
567
|
+
return { deps: ["separator"] };
|
|
568
|
+
case "jsxFramework":
|
|
569
|
+
return { deps: ["jsxFramework"] };
|
|
570
|
+
case "jsxFactory":
|
|
571
|
+
return { deps: ["jsxFactory"] };
|
|
572
|
+
case "jsxStyleProps":
|
|
573
|
+
return { deps: ["jsxStyleProps"] };
|
|
574
|
+
case "outExtension":
|
|
575
|
+
return { deps: ["outExtension"] };
|
|
576
|
+
case "forceImportExtension":
|
|
577
|
+
return { deps: ["forceImportExtension"] };
|
|
578
|
+
case "shorthands":
|
|
579
|
+
return { deps: ["utilities"] };
|
|
580
|
+
case "strictTokens":
|
|
581
|
+
case "strictPropertyValues":
|
|
582
|
+
return { deps: ["outExtension"] };
|
|
583
|
+
default:
|
|
584
|
+
return { deps: [] };
|
|
1126
585
|
}
|
|
1127
|
-
const serialized = (0, import_shared11.stringifyJson)(Object.assign({}, loadConfigResult.config, { name: import_shared11.PANDA_CONFIG_NAME, presets: [] }));
|
|
1128
|
-
const deserialize = () => (0, import_shared11.parseJson)(serialized);
|
|
1129
|
-
return { ...loadConfigResult, serialized, deserialize, hooks };
|
|
1130
586
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
return
|
|
587
|
+
function diffInput(input) {
|
|
588
|
+
if (isConfigSnapshot(input)) {
|
|
589
|
+
return { config: input.config, ...input.hooks ? { hooks: input.hooks } : {} };
|
|
590
|
+
}
|
|
591
|
+
return { config: input };
|
|
592
|
+
}
|
|
593
|
+
function isConfigSnapshot(input) {
|
|
594
|
+
return !!input && typeof input === "object" && !Array.isArray(input) && ("callbacks" in input || "hooks" in input) && "config" in input && !!input.config && typeof input.config === "object" && !Array.isArray(input.config);
|
|
1136
595
|
}
|
|
1137
|
-
|
|
1138
|
-
0 && (module.exports = {
|
|
596
|
+
export {
|
|
1139
597
|
bundleConfig,
|
|
1140
|
-
|
|
1141
|
-
|
|
598
|
+
createConfigSnapshot,
|
|
599
|
+
diffConfig,
|
|
1142
600
|
findConfig,
|
|
1143
|
-
getConfigDependencies,
|
|
1144
|
-
getResolvedConfig,
|
|
1145
601
|
loadConfig,
|
|
1146
|
-
mergeConfigs
|
|
1147
|
-
|
|
1148
|
-
resolveConfig
|
|
1149
|
-
});
|
|
602
|
+
mergeConfigs
|
|
603
|
+
};
|