@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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Config } from '@pandacss/types';
|
|
2
|
+
|
|
3
|
+
interface ConfigSourceEntry {
|
|
4
|
+
kind: 'config' | 'preset';
|
|
5
|
+
name?: string;
|
|
6
|
+
specifier?: string;
|
|
7
|
+
file?: string;
|
|
8
|
+
}
|
|
9
|
+
interface ConfigSources {
|
|
10
|
+
entries: ConfigSourceEntry[];
|
|
11
|
+
paths: Record<string, number | number[]>;
|
|
12
|
+
}
|
|
13
|
+
type SourceRecordMode = 'replace' | 'append';
|
|
14
|
+
declare class SourceTracker {
|
|
15
|
+
sources: ConfigSources;
|
|
16
|
+
constructor(entries: ConfigSourceEntry[]);
|
|
17
|
+
record(path: string[], sourceId: number, mode: SourceRecordMode): void;
|
|
18
|
+
moveIfMissing(from: string[], to: string[]): void;
|
|
19
|
+
delete(path: string[]): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Dict = Record<string, any>;
|
|
23
|
+
type Extendable<T> = T & {
|
|
24
|
+
extend?: T;
|
|
25
|
+
};
|
|
26
|
+
type ExtendableConfig = Extendable<Config>;
|
|
27
|
+
|
|
28
|
+
interface SourcedConfig {
|
|
29
|
+
config: ExtendableConfig;
|
|
30
|
+
source: ConfigSourceEntry;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Same merge, but also records which config contributed each value
|
|
34
|
+
* so the result can be traced back to its preset/config of origin.
|
|
35
|
+
*/
|
|
36
|
+
declare function mergeConfigsWithSources(configs: SourcedConfig[]): {
|
|
37
|
+
config: Dict;
|
|
38
|
+
sources: ConfigSources;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Merges an ordered list of configs (presets first, user config last) into one flat config.
|
|
42
|
+
* Top-level keys replace; section keys deep-merge, with `extend` appending instead of replacing.
|
|
43
|
+
*/
|
|
44
|
+
declare function mergeConfigs(configs: ExtendableConfig[]): Dict;
|
|
45
|
+
declare function mergeConfigs(configs: SourcedConfig[], tracker: SourceTracker): Dict;
|
|
46
|
+
|
|
47
|
+
export { type ConfigSources as C, type SourcedConfig as S, type ConfigSourceEntry as a, mergeConfigsWithSources as b, mergeConfigs as m };
|
package/dist/merge.d.ts
ADDED
package/dist/merge.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SerializedConfig, ProjectCallbacks, ProjectHooks } from '@pandacss/compiler-shared';
|
|
2
|
+
import { UserConfig } from '@pandacss/types';
|
|
3
|
+
|
|
4
|
+
interface ConfigSnapshot {
|
|
5
|
+
config: SerializedConfig;
|
|
6
|
+
callbacks: ProjectCallbacks;
|
|
7
|
+
hooks?: ProjectHooks;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Lower a resolved config to a JSON-safe `SerializedConfig` (functions → callback
|
|
11
|
+
* refs, RegExp → `{ kind:'regex' }`) plus the live `callbacks`, and embed each
|
|
12
|
+
* pattern's `transform`/`defaultValues` source as `codegenSource` for the Rust
|
|
13
|
+
* pattern generator.
|
|
14
|
+
*/
|
|
15
|
+
declare function createConfigSnapshot(config: UserConfig): ConfigSnapshot;
|
|
16
|
+
|
|
17
|
+
export { type ConfigSnapshot, createConfigSnapshot };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/config",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
|
+
"description": "Self-contained loader that bundles and serializes a Panda config for the Rust compiler",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"author": "Segun Adebayo <joseshegs@gmail.com>",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"sideEffects": false,
|
|
@@ -21,47 +21,17 @@
|
|
|
21
21
|
".": {
|
|
22
22
|
"source": "./src/index.ts",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
|
-
"
|
|
25
|
-
"import": {
|
|
26
|
-
"types": "./dist/index.d.mts",
|
|
27
|
-
"default": "./dist/index.mjs"
|
|
28
|
-
}
|
|
24
|
+
"default": "./dist/index.js"
|
|
29
25
|
},
|
|
30
|
-
"./
|
|
31
|
-
"source": "./src/
|
|
32
|
-
"types": "./dist/
|
|
33
|
-
"
|
|
34
|
-
"import": {
|
|
35
|
-
"types": "./dist/merge-config.d.mts",
|
|
36
|
-
"default": "./dist/merge-config.mjs"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"./diff": {
|
|
40
|
-
"source": "./src/diff-config.ts",
|
|
41
|
-
"types": "./dist/diff-config.d.ts",
|
|
42
|
-
"require": "./dist/diff-config.js",
|
|
43
|
-
"import": {
|
|
44
|
-
"types": "./dist/diff-config.d.mts",
|
|
45
|
-
"default": "./dist/diff-config.mjs"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"./ts-path": {
|
|
49
|
-
"source": "./src/resolve-ts-path-pattern.ts",
|
|
50
|
-
"types": "./dist/resolve-ts-path-pattern.d.ts",
|
|
51
|
-
"require": "./dist/resolve-ts-path-pattern.js",
|
|
52
|
-
"import": {
|
|
53
|
-
"types": "./dist/resolve-ts-path-pattern.d.mts",
|
|
54
|
-
"default": "./dist/resolve-ts-path-pattern.mjs"
|
|
55
|
-
}
|
|
26
|
+
"./serialize": {
|
|
27
|
+
"source": "./src/serialize.ts",
|
|
28
|
+
"types": "./dist/serialize.d.ts",
|
|
29
|
+
"default": "./dist/serialize.js"
|
|
56
30
|
},
|
|
57
|
-
"./
|
|
58
|
-
"source": "./src/
|
|
59
|
-
"types": "./dist/
|
|
60
|
-
"
|
|
61
|
-
"import": {
|
|
62
|
-
"types": "./dist/utils.d.mts",
|
|
63
|
-
"default": "./dist/utils.mjs"
|
|
64
|
-
}
|
|
31
|
+
"./merge": {
|
|
32
|
+
"source": "./src/merge.ts",
|
|
33
|
+
"types": "./dist/merge.d.ts",
|
|
34
|
+
"default": "./dist/merge.js"
|
|
65
35
|
},
|
|
66
36
|
"./package.json": "./package.json"
|
|
67
37
|
},
|
|
@@ -69,25 +39,19 @@
|
|
|
69
39
|
"dist"
|
|
70
40
|
],
|
|
71
41
|
"dependencies": {
|
|
72
|
-
"
|
|
73
|
-
"
|
|
42
|
+
"acorn": "^8.17.0",
|
|
43
|
+
"acorn-walk": "^8.3.5",
|
|
44
|
+
"javascript-stringify": "2.1.0",
|
|
45
|
+
"magic-string": "^0.30.21",
|
|
74
46
|
"microdiff": "1.5.0",
|
|
75
|
-
"
|
|
76
|
-
"@pandacss/
|
|
77
|
-
"@pandacss/
|
|
78
|
-
"@pandacss/preset-panda": "1.11.3",
|
|
79
|
-
"@pandacss/shared": "1.11.3",
|
|
80
|
-
"@pandacss/types": "1.11.3"
|
|
81
|
-
},
|
|
82
|
-
"devDependencies": {
|
|
83
|
-
"pkg-types": "2.3.0"
|
|
84
|
-
},
|
|
85
|
-
"engines": {
|
|
86
|
-
"node": ">=20"
|
|
47
|
+
"rolldown": "1.0.0-rc.17",
|
|
48
|
+
"@pandacss/compiler-shared": "2.0.0-beta.1",
|
|
49
|
+
"@pandacss/types": "2.0.0-beta.1"
|
|
87
50
|
},
|
|
88
51
|
"scripts": {
|
|
89
|
-
"build": "tsup --
|
|
90
|
-
"build
|
|
91
|
-
"dev": "pnpm build
|
|
52
|
+
"build": "tsup --dts",
|
|
53
|
+
"build:fast": "tsup --no-dts",
|
|
54
|
+
"dev": "pnpm build:fast --watch",
|
|
55
|
+
"test": "vitest run"
|
|
92
56
|
}
|
|
93
57
|
}
|
package/dist/chunk-BJRWQ6BQ.mjs
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// src/diff-config.ts
|
|
2
|
-
import { dashCase } from "@pandacss/shared";
|
|
3
|
-
import microdiff from "microdiff";
|
|
4
|
-
|
|
5
|
-
// src/create-matcher.ts
|
|
6
|
-
function createMatcher(id, patterns) {
|
|
7
|
-
if (!patterns?.length) return () => void 0;
|
|
8
|
-
const includePatterns = [];
|
|
9
|
-
const excludePatterns = [];
|
|
10
|
-
const deduped = new Set(patterns);
|
|
11
|
-
deduped.forEach((pattern) => {
|
|
12
|
-
const regexString = pattern.replace(/\*/g, ".*");
|
|
13
|
-
if (pattern.startsWith("!")) {
|
|
14
|
-
excludePatterns.push(regexString.slice(1));
|
|
15
|
-
} else {
|
|
16
|
-
includePatterns.push(regexString);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const include = new RegExp(includePatterns.join("|"));
|
|
20
|
-
const exclude = new RegExp(excludePatterns.join("|"));
|
|
21
|
-
return (path) => {
|
|
22
|
-
if (excludePatterns.length && exclude.test(path)) return;
|
|
23
|
-
return include.test(path) ? id : void 0;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// src/config-deps.ts
|
|
28
|
-
var all = [
|
|
29
|
-
"clean",
|
|
30
|
-
"cwd",
|
|
31
|
-
"eject",
|
|
32
|
-
"outdir",
|
|
33
|
-
"forceConsistentTypeExtension",
|
|
34
|
-
"outExtension",
|
|
35
|
-
"emitTokensOnly",
|
|
36
|
-
"presets",
|
|
37
|
-
"plugins",
|
|
38
|
-
"hooks"
|
|
39
|
-
];
|
|
40
|
-
var format = [
|
|
41
|
-
"syntax",
|
|
42
|
-
"hash",
|
|
43
|
-
"prefix",
|
|
44
|
-
"separator",
|
|
45
|
-
"strictTokens",
|
|
46
|
-
"strictPropertyValues",
|
|
47
|
-
"shorthands"
|
|
48
|
-
];
|
|
49
|
-
var tokens = [
|
|
50
|
-
"utilities",
|
|
51
|
-
"conditions",
|
|
52
|
-
"theme.tokens",
|
|
53
|
-
"theme.semanticTokens",
|
|
54
|
-
"theme.breakpoints",
|
|
55
|
-
"theme.containerNames",
|
|
56
|
-
"theme.containerSizes"
|
|
57
|
-
];
|
|
58
|
-
var jsx = ["jsxFramework", "jsxFactory", "jsxStyleProps", "syntax"];
|
|
59
|
-
var common = tokens.concat(jsx, format);
|
|
60
|
-
var artifactConfigDeps = {
|
|
61
|
-
helpers: ["syntax", "jsxFramework"],
|
|
62
|
-
keyframes: ["theme.keyframes", "layers"],
|
|
63
|
-
"design-tokens": ["layers", "!utilities.*.className"].concat(tokens),
|
|
64
|
-
types: ["!utilities.*.className"].concat(common),
|
|
65
|
-
"css-fn": common,
|
|
66
|
-
cva: ["syntax"],
|
|
67
|
-
sva: ["syntax"],
|
|
68
|
-
cx: [],
|
|
69
|
-
"create-recipe": ["separator", "prefix", "hash"],
|
|
70
|
-
"recipes-index": ["theme.recipes", "theme.slotRecipes"],
|
|
71
|
-
recipes: ["theme.recipes", "theme.slotRecipes"],
|
|
72
|
-
"patterns-index": ["syntax", "patterns"],
|
|
73
|
-
patterns: ["syntax", "patterns"],
|
|
74
|
-
"jsx-is-valid-prop": common,
|
|
75
|
-
"jsx-factory": jsx,
|
|
76
|
-
"jsx-helpers": jsx,
|
|
77
|
-
"jsx-patterns": jsx.concat("patterns"),
|
|
78
|
-
"jsx-patterns-index": jsx.concat("patterns"),
|
|
79
|
-
"jsx-create-style-context": jsx,
|
|
80
|
-
"css-index": ["syntax"],
|
|
81
|
-
"package.json": ["forceConsistentTypeExtension", "outExtension"],
|
|
82
|
-
"types-styles": ["shorthands"],
|
|
83
|
-
"types-conditions": ["conditions"],
|
|
84
|
-
"types-jsx": jsx,
|
|
85
|
-
"types-entry": [],
|
|
86
|
-
"types-gen": [],
|
|
87
|
-
"types-gen-system": [],
|
|
88
|
-
themes: ["themes"].concat(tokens),
|
|
89
|
-
// staticCss depends on tokens (for wildcards) and recipes (for recipe rules)
|
|
90
|
-
"static-css": ["staticCss", "patterns", "theme.recipes", "theme.slotRecipes"].concat(tokens),
|
|
91
|
-
// Split CSS artifacts (generated via cssgen --splitting)
|
|
92
|
-
styles: [],
|
|
93
|
-
"styles.css": []
|
|
94
|
-
};
|
|
95
|
-
var artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
|
|
96
|
-
if (!paths.length) return () => void 0;
|
|
97
|
-
return createMatcher(key, paths.concat(all));
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// src/diff-config.ts
|
|
101
|
-
var runIfFn = (fn) => typeof fn === "function" ? fn() : fn;
|
|
102
|
-
var hasRecipeStateTransition = (prevConfig, nextConfig) => {
|
|
103
|
-
const prevRecipes = prevConfig.theme?.recipes ?? {};
|
|
104
|
-
const prevSlotRecipes = prevConfig.theme?.slotRecipes ?? {};
|
|
105
|
-
const prevHasRecipes = Object.keys(prevRecipes).length > 0 || Object.keys(prevSlotRecipes).length > 0;
|
|
106
|
-
const nextRecipes = nextConfig.theme?.recipes ?? {};
|
|
107
|
-
const nextSlotRecipes = nextConfig.theme?.slotRecipes ?? {};
|
|
108
|
-
const nextHasRecipes = Object.keys(nextRecipes).length > 0 || Object.keys(nextSlotRecipes).length > 0;
|
|
109
|
-
return prevHasRecipes !== nextHasRecipes;
|
|
110
|
-
};
|
|
111
|
-
function diffConfigs(config, prevConfig) {
|
|
112
|
-
const affected = {
|
|
113
|
-
artifacts: /* @__PURE__ */ new Set(),
|
|
114
|
-
hasConfigChanged: false,
|
|
115
|
-
diffs: []
|
|
116
|
-
};
|
|
117
|
-
if (!prevConfig) {
|
|
118
|
-
affected.hasConfigChanged = true;
|
|
119
|
-
return affected;
|
|
120
|
-
}
|
|
121
|
-
const configDiff = microdiff(prevConfig, runIfFn(config));
|
|
122
|
-
if (!configDiff.length) {
|
|
123
|
-
return affected;
|
|
124
|
-
}
|
|
125
|
-
affected.hasConfigChanged = true;
|
|
126
|
-
affected.diffs = configDiff;
|
|
127
|
-
configDiff.forEach((change) => {
|
|
128
|
-
const changePath = change.path.join(".");
|
|
129
|
-
artifactMatchers.forEach((matcher) => {
|
|
130
|
-
const id = matcher(changePath);
|
|
131
|
-
if (!id) return;
|
|
132
|
-
if (id === "recipes") {
|
|
133
|
-
const name = dashCase(change.path.slice(1, 3).join("."));
|
|
134
|
-
affected.artifacts.add(name);
|
|
135
|
-
}
|
|
136
|
-
if (id === "patterns") {
|
|
137
|
-
const name = dashCase(change.path.slice(0, 2).join("."));
|
|
138
|
-
affected.artifacts.add(name);
|
|
139
|
-
}
|
|
140
|
-
affected.artifacts.add(id);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
if (affected.artifacts.has("recipes") || affected.artifacts.has("recipes-index")) {
|
|
144
|
-
const nextConfig = runIfFn(config);
|
|
145
|
-
if (hasRecipeStateTransition(prevConfig, nextConfig)) {
|
|
146
|
-
affected.artifacts.add("create-recipe");
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return affected;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export {
|
|
153
|
-
diffConfigs
|
|
154
|
-
};
|
package/dist/chunk-FQ7G6ORY.mjs
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
// src/merge-config.ts
|
|
2
|
-
import { PANDA_CONFIG_NAME, assign, mergeWith, mergeAndConcat, walkObject } from "@pandacss/shared";
|
|
3
|
-
|
|
4
|
-
// src/merge-hooks.ts
|
|
5
|
-
import { logger } from "@pandacss/logger";
|
|
6
|
-
var mergeHooks = (plugins) => {
|
|
7
|
-
const hooksFns = {};
|
|
8
|
-
plugins.forEach(({ name, hooks }) => {
|
|
9
|
-
Object.entries(hooks ?? {}).forEach(([key, value]) => {
|
|
10
|
-
if (!hooksFns[key]) {
|
|
11
|
-
hooksFns[key] = [];
|
|
12
|
-
}
|
|
13
|
-
hooksFns[key].push([name, value]);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
const mergedHooks = Object.fromEntries(
|
|
17
|
-
Object.entries(hooksFns).map(([key, entries]) => {
|
|
18
|
-
const fns = entries.map(([name, fn]) => tryCatch(name, fn));
|
|
19
|
-
const reducer = key in reducers ? reducers[key] : void 0;
|
|
20
|
-
if (reducer) {
|
|
21
|
-
return [key, reducer(fns)];
|
|
22
|
-
}
|
|
23
|
-
return [key, syncHooks.includes(key) ? callAll(...fns) : callAllAsync(...fns)];
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
return mergedHooks;
|
|
27
|
-
};
|
|
28
|
-
var createReducer = (reducer) => reducer;
|
|
29
|
-
var reducers = {
|
|
30
|
-
"config:resolved": createReducer((fns) => async (_args) => {
|
|
31
|
-
const args = Object.assign({}, _args);
|
|
32
|
-
const original = _args.config;
|
|
33
|
-
let config = args.config;
|
|
34
|
-
for (const hookFn of fns) {
|
|
35
|
-
const result = await hookFn(Object.assign(args, { config, original }));
|
|
36
|
-
if (result !== void 0) {
|
|
37
|
-
config = result;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return config;
|
|
41
|
-
}),
|
|
42
|
-
"parser:before": createReducer((fns) => (_args) => {
|
|
43
|
-
const args = Object.assign({}, _args);
|
|
44
|
-
const original = _args.content;
|
|
45
|
-
let content = args.content;
|
|
46
|
-
for (const hookFn of fns) {
|
|
47
|
-
const result = hookFn(Object.assign(args, { content, original }));
|
|
48
|
-
if (result !== void 0) {
|
|
49
|
-
content = result;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return content;
|
|
53
|
-
}),
|
|
54
|
-
"parser:preprocess": createReducer((fns) => (_args) => {
|
|
55
|
-
const args = Object.assign({}, _args);
|
|
56
|
-
const original = _args.data;
|
|
57
|
-
let data = args.data;
|
|
58
|
-
for (const hookFn of fns) {
|
|
59
|
-
const result = hookFn(Object.assign(args, { data, original }));
|
|
60
|
-
if (result !== void 0) {
|
|
61
|
-
data = result;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return data;
|
|
65
|
-
}),
|
|
66
|
-
"cssgen:done": createReducer((fns) => (_args) => {
|
|
67
|
-
const args = Object.assign({}, _args);
|
|
68
|
-
const original = _args.content;
|
|
69
|
-
let content = args.content;
|
|
70
|
-
for (const hookFn of fns) {
|
|
71
|
-
const result = hookFn(Object.assign(args, { content, original }));
|
|
72
|
-
if (result !== void 0) {
|
|
73
|
-
content = result;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return content;
|
|
77
|
-
}),
|
|
78
|
-
"codegen:prepare": createReducer((fns) => async (_args) => {
|
|
79
|
-
const args = Object.assign({}, _args);
|
|
80
|
-
const original = _args.artifacts;
|
|
81
|
-
let artifacts = args.artifacts;
|
|
82
|
-
for (const hookFn of fns) {
|
|
83
|
-
const result = await hookFn(Object.assign(args, { artifacts, original }));
|
|
84
|
-
if (result) {
|
|
85
|
-
artifacts = result;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return artifacts;
|
|
89
|
-
}),
|
|
90
|
-
"preset:resolved": createReducer((fns) => async (_args) => {
|
|
91
|
-
const args = Object.assign({}, _args);
|
|
92
|
-
const original = _args.preset;
|
|
93
|
-
let preset = args.preset;
|
|
94
|
-
for (const hookFn of fns) {
|
|
95
|
-
const result = await hookFn(Object.assign(args, { preset, original }));
|
|
96
|
-
if (result !== void 0) {
|
|
97
|
-
preset = result;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return preset;
|
|
101
|
-
}),
|
|
102
|
-
"css:optimize": createReducer((fns) => (_args) => {
|
|
103
|
-
const args = Object.assign({}, _args);
|
|
104
|
-
const original = _args.css;
|
|
105
|
-
let css = args.css;
|
|
106
|
-
for (const hookFn of fns) {
|
|
107
|
-
const result = hookFn(Object.assign(args, { css, original }));
|
|
108
|
-
if (result !== void 0) {
|
|
109
|
-
css = result;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return css;
|
|
113
|
-
})
|
|
114
|
-
};
|
|
115
|
-
var syncHooks = [
|
|
116
|
-
"context:created",
|
|
117
|
-
"parser:before",
|
|
118
|
-
"parser:preprocess",
|
|
119
|
-
"parser:after",
|
|
120
|
-
"cssgen:done",
|
|
121
|
-
"css:optimize"
|
|
122
|
-
];
|
|
123
|
-
var callAllAsync = (...fns) => async (...a) => {
|
|
124
|
-
for (const fn of fns) {
|
|
125
|
-
await fn?.(...a);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
var callAll = (...fns) => (...a) => {
|
|
129
|
-
fns.forEach((fn) => fn?.(...a));
|
|
130
|
-
};
|
|
131
|
-
var tryCatch = (name, fn) => {
|
|
132
|
-
return (...args) => {
|
|
133
|
-
try {
|
|
134
|
-
return fn(...args);
|
|
135
|
-
} catch (e) {
|
|
136
|
-
logger.caughtError("hooks", `Error in plugin "${name}"`, e);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// src/validation/utils.ts
|
|
142
|
-
import { isObject, isString } from "@pandacss/shared";
|
|
143
|
-
var REFERENCE_REGEX = /({([^}]*)})/g;
|
|
144
|
-
var curlyBracketRegex = /[{}]/g;
|
|
145
|
-
var isValidToken = (token) => isObject(token) && Object.hasOwnProperty.call(token, "value");
|
|
146
|
-
var isTokenReference = (value) => typeof value === "string" && REFERENCE_REGEX.test(value);
|
|
147
|
-
var formatPath = (path) => path;
|
|
148
|
-
var SEP = ".";
|
|
149
|
-
function getReferences(value) {
|
|
150
|
-
if (typeof value !== "string") return [];
|
|
151
|
-
const matches = value.match(REFERENCE_REGEX);
|
|
152
|
-
if (!matches) return [];
|
|
153
|
-
return matches.map((match) => match.replace(curlyBracketRegex, "")).map((value2) => {
|
|
154
|
-
return value2.trim().split("/")[0];
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
var serializeTokenValue = (value) => {
|
|
158
|
-
if (isString(value)) {
|
|
159
|
-
return value;
|
|
160
|
-
}
|
|
161
|
-
if (isObject(value)) {
|
|
162
|
-
return Object.values(value).map((v) => serializeTokenValue(v)).join(" ");
|
|
163
|
-
}
|
|
164
|
-
if (Array.isArray(value)) {
|
|
165
|
-
return value.map((v) => serializeTokenValue(v)).join(" ");
|
|
166
|
-
}
|
|
167
|
-
return value.toString();
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// src/merge-config.ts
|
|
171
|
-
function getExtends(items) {
|
|
172
|
-
return items.reduce((merged, { extend }) => {
|
|
173
|
-
if (!extend) return merged;
|
|
174
|
-
return mergeWith(merged, extend, (originalValue, newValue) => {
|
|
175
|
-
if (newValue === void 0) {
|
|
176
|
-
return originalValue ?? [];
|
|
177
|
-
}
|
|
178
|
-
if (originalValue === void 0) {
|
|
179
|
-
return [newValue];
|
|
180
|
-
}
|
|
181
|
-
if (Array.isArray(originalValue)) {
|
|
182
|
-
return [newValue, ...originalValue];
|
|
183
|
-
}
|
|
184
|
-
return [newValue, originalValue];
|
|
185
|
-
});
|
|
186
|
-
}, {});
|
|
187
|
-
}
|
|
188
|
-
function mergeRecords(records) {
|
|
189
|
-
return {
|
|
190
|
-
...records.reduce((acc, record) => assign(acc, record), {}),
|
|
191
|
-
extend: getExtends(records)
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
function mergeExtensions(records) {
|
|
195
|
-
const { extend = [], ...restProps } = mergeRecords(records);
|
|
196
|
-
return mergeWith(restProps, extend, (obj, extensions) => {
|
|
197
|
-
return mergeAndConcat({}, obj, ...extensions);
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
var isEmptyObject = (obj) => typeof obj === "object" && Object.keys(obj).length === 0;
|
|
201
|
-
var compact = (obj) => {
|
|
202
|
-
return Object.keys(obj).reduce((acc, key) => {
|
|
203
|
-
if (obj[key] !== void 0 && !isEmptyObject(obj[key])) {
|
|
204
|
-
acc[key] = obj[key];
|
|
205
|
-
}
|
|
206
|
-
return acc;
|
|
207
|
-
}, {});
|
|
208
|
-
};
|
|
209
|
-
var tokenKeys = ["description", "extensions", "type", "value", "deprecated"];
|
|
210
|
-
function mergeConfigs(configs) {
|
|
211
|
-
const userConfig = configs.at(-1);
|
|
212
|
-
const pluginHooks = userConfig.plugins ?? [];
|
|
213
|
-
if (userConfig.hooks) {
|
|
214
|
-
pluginHooks.push({ name: PANDA_CONFIG_NAME, hooks: userConfig.hooks });
|
|
215
|
-
}
|
|
216
|
-
const reversed = Array.from(configs).reverse();
|
|
217
|
-
const mergedResult = assign(
|
|
218
|
-
{
|
|
219
|
-
conditions: mergeExtensions(reversed.map((config) => config.conditions ?? {})),
|
|
220
|
-
theme: mergeExtensions(reversed.map((config) => config.theme ?? {})),
|
|
221
|
-
patterns: mergeExtensions(reversed.map((config) => config.patterns ?? {})),
|
|
222
|
-
utilities: mergeExtensions(reversed.map((config) => config.utilities ?? {})),
|
|
223
|
-
globalCss: mergeExtensions(reversed.map((config) => config.globalCss ?? {})),
|
|
224
|
-
globalVars: mergeExtensions(reversed.map((config) => config.globalVars ?? {})),
|
|
225
|
-
globalFontface: mergeExtensions(reversed.map((config) => config.globalFontface ?? {})),
|
|
226
|
-
globalPositionTry: mergeExtensions(reversed.map((config) => config.globalPositionTry ?? {})),
|
|
227
|
-
staticCss: mergeExtensions(reversed.map((config) => config.staticCss ?? {})),
|
|
228
|
-
themes: mergeExtensions(reversed.map((config) => config.themes ?? {})),
|
|
229
|
-
hooks: mergeHooks(pluginHooks)
|
|
230
|
-
},
|
|
231
|
-
...reversed
|
|
232
|
-
);
|
|
233
|
-
const withoutEmpty = compact(mergedResult);
|
|
234
|
-
if (withoutEmpty.theme?.tokens) {
|
|
235
|
-
walkObject(withoutEmpty.theme.tokens, (args) => args, {
|
|
236
|
-
stop(token) {
|
|
237
|
-
if (!isValidToken(token)) return false;
|
|
238
|
-
const keys = Object.keys(token);
|
|
239
|
-
const nestedKeys = keys.filter((k) => !tokenKeys.includes(k));
|
|
240
|
-
const nested = nestedKeys.length > 0;
|
|
241
|
-
if (nested) {
|
|
242
|
-
token.DEFAULT ||= {};
|
|
243
|
-
tokenKeys.forEach((key) => {
|
|
244
|
-
if (token[key] == null) return;
|
|
245
|
-
token.DEFAULT[key] ||= token[key];
|
|
246
|
-
delete token[key];
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
return true;
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
return withoutEmpty;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export {
|
|
257
|
-
mergeHooks,
|
|
258
|
-
isValidToken,
|
|
259
|
-
isTokenReference,
|
|
260
|
-
formatPath,
|
|
261
|
-
SEP,
|
|
262
|
-
getReferences,
|
|
263
|
-
serializeTokenValue,
|
|
264
|
-
mergeConfigs
|
|
265
|
-
};
|
package/dist/chunk-RPIVZP2I.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/resolve-ts-path-pattern.ts
|
|
2
|
-
import { posix, sep } from "path";
|
|
3
|
-
var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
|
|
4
|
-
for (const mapping of pathMappings) {
|
|
5
|
-
const match = moduleSpecifier.match(mapping.pattern);
|
|
6
|
-
if (!match) {
|
|
7
|
-
continue;
|
|
8
|
-
}
|
|
9
|
-
for (const pathTemplate of mapping.paths) {
|
|
10
|
-
let starCount = 0;
|
|
11
|
-
const mappedId = pathTemplate.replace(/\*/g, () => {
|
|
12
|
-
const matchIndex = Math.min(++starCount, match.length - 1);
|
|
13
|
-
return match[matchIndex];
|
|
14
|
-
});
|
|
15
|
-
return mappedId.split(sep).join(posix.sep);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
resolveTsPathPattern
|
|
22
|
-
};
|
package/dist/diff-config.d.mts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Config, DiffConfigResult } from '@pandacss/types';
|
|
2
|
-
|
|
3
|
-
type ConfigOrFn = Config | (() => Config);
|
|
4
|
-
/**
|
|
5
|
-
* Diff the two config objects and return the list of affected properties
|
|
6
|
-
*/
|
|
7
|
-
declare function diffConfigs(config: ConfigOrFn, prevConfig: Config | undefined): DiffConfigResult;
|
|
8
|
-
|
|
9
|
-
export { diffConfigs };
|
package/dist/diff-config.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Config, DiffConfigResult } from '@pandacss/types';
|
|
2
|
-
|
|
3
|
-
type ConfigOrFn = Config | (() => Config);
|
|
4
|
-
/**
|
|
5
|
-
* Diff the two config objects and return the list of affected properties
|
|
6
|
-
*/
|
|
7
|
-
declare function diffConfigs(config: ConfigOrFn, prevConfig: Config | undefined): DiffConfigResult;
|
|
8
|
-
|
|
9
|
-
export { diffConfigs };
|