@bamboocss/config 1.11.3 → 1.12.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/diff-config.cjs +186 -2
- package/dist/diff-config.mjs +162 -1
- package/dist/index.cjs +492 -27
- package/dist/index.d.cts +34 -7
- package/dist/index.d.mts +34 -7
- package/dist/index.mjs +447 -5
- package/dist/merge-config.cjs +253 -3
- package/dist/merge-config.d.cts +15 -1
- package/dist/merge-config.d.mts +15 -1
- package/dist/merge-config.mjs +251 -1
- package/dist/resolve-ts-path-pattern.cjs +0 -1
- package/dist/resolve-ts-path-pattern.d.cts +6 -2
- package/dist/resolve-ts-path-pattern.d.mts +6 -2
- package/package.json +6 -6
- package/dist/diff-config-Co_3mDXE.cjs +0 -197
- package/dist/diff-config-KDQWMnQN.mjs +0 -163
- package/dist/merge-config-CcNpHJit.cjs +0 -312
- package/dist/merge-config-DI__LOWx.mjs +0 -270
- package/dist/merge-config-DVOlBQJY.d.cts +0 -16
- package/dist/merge-config-oEiBYbfB.d.mts +0 -16
- package/dist/ts-config-paths-CvGId8kq.d.mts +0 -11
- package/dist/ts-config-paths-wVx39QZ0.d.cts +0 -11
package/dist/diff-config.cjs
CHANGED
|
@@ -1,3 +1,187 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let _bamboocss_shared = require("@bamboocss/shared");
|
|
25
|
+
let microdiff = require("microdiff");
|
|
26
|
+
microdiff = __toESM(microdiff);
|
|
27
|
+
//#region src/create-matcher.ts
|
|
28
|
+
/**
|
|
29
|
+
* Acts like a .gitignore matcher
|
|
30
|
+
* e.g a list of string to search for nested path with glob and exclusion allowed
|
|
31
|
+
* ["outdir", "theme.recipes", '*.css', '!aaa.*.bbb']
|
|
32
|
+
*/
|
|
33
|
+
function createMatcher(id, patterns) {
|
|
34
|
+
if (!patterns?.length) return () => void 0;
|
|
35
|
+
const includePatterns = [];
|
|
36
|
+
const excludePatterns = [];
|
|
37
|
+
new Set(patterns).forEach((pattern) => {
|
|
38
|
+
const regexString = pattern.replace(/\*/g, ".*");
|
|
39
|
+
if (pattern.startsWith("!")) excludePatterns.push(regexString.slice(1));
|
|
40
|
+
else includePatterns.push(regexString);
|
|
41
|
+
});
|
|
42
|
+
const include = new RegExp(includePatterns.join("|"));
|
|
43
|
+
const exclude = new RegExp(excludePatterns.join("|"));
|
|
44
|
+
return (path) => {
|
|
45
|
+
if (excludePatterns.length && exclude.test(path)) return;
|
|
46
|
+
return include.test(path) ? id : void 0;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/config-deps.ts
|
|
51
|
+
const all = [
|
|
52
|
+
"clean",
|
|
53
|
+
"cwd",
|
|
54
|
+
"eject",
|
|
55
|
+
"outdir",
|
|
56
|
+
"forceConsistentTypeExtension",
|
|
57
|
+
"outExtension",
|
|
58
|
+
"emitTokensOnly",
|
|
59
|
+
"presets",
|
|
60
|
+
"plugins",
|
|
61
|
+
"hooks"
|
|
62
|
+
];
|
|
63
|
+
const format = [
|
|
64
|
+
"syntax",
|
|
65
|
+
"hash",
|
|
66
|
+
"prefix",
|
|
67
|
+
"separator",
|
|
68
|
+
"strictTokens",
|
|
69
|
+
"strictPropertyValues",
|
|
70
|
+
"shorthands"
|
|
71
|
+
];
|
|
72
|
+
const tokens = [
|
|
73
|
+
"utilities",
|
|
74
|
+
"conditions",
|
|
75
|
+
"theme.tokens",
|
|
76
|
+
"theme.semanticTokens",
|
|
77
|
+
"theme.breakpoints",
|
|
78
|
+
"theme.containerNames",
|
|
79
|
+
"theme.containerSizes"
|
|
80
|
+
];
|
|
81
|
+
const jsx = [
|
|
82
|
+
"jsxFramework",
|
|
83
|
+
"jsxFactory",
|
|
84
|
+
"jsxStyleProps",
|
|
85
|
+
"syntax"
|
|
86
|
+
];
|
|
87
|
+
const common = tokens.concat(jsx, format);
|
|
88
|
+
const artifactConfigDeps = {
|
|
89
|
+
helpers: ["syntax", "jsxFramework"],
|
|
90
|
+
keyframes: ["theme.keyframes", "layers"],
|
|
91
|
+
"design-tokens": ["layers", "!utilities.*.className"].concat(tokens),
|
|
92
|
+
types: ["!utilities.*.className"].concat(common),
|
|
93
|
+
"css-fn": common,
|
|
94
|
+
cva: ["syntax"],
|
|
95
|
+
sva: ["syntax"],
|
|
96
|
+
cx: [],
|
|
97
|
+
"create-recipe": [
|
|
98
|
+
"separator",
|
|
99
|
+
"prefix",
|
|
100
|
+
"hash"
|
|
101
|
+
],
|
|
102
|
+
"recipes-index": ["theme.recipes", "theme.slotRecipes"],
|
|
103
|
+
recipes: ["theme.recipes", "theme.slotRecipes"],
|
|
104
|
+
"patterns-index": ["syntax", "patterns"],
|
|
105
|
+
patterns: ["syntax", "patterns"],
|
|
106
|
+
"jsx-is-valid-prop": common,
|
|
107
|
+
"jsx-factory": jsx,
|
|
108
|
+
"jsx-helpers": jsx,
|
|
109
|
+
"jsx-patterns": jsx.concat("patterns"),
|
|
110
|
+
"jsx-patterns-index": jsx.concat("patterns"),
|
|
111
|
+
"jsx-create-style-context": jsx,
|
|
112
|
+
"css-index": ["syntax"],
|
|
113
|
+
"package.json": ["forceConsistentTypeExtension", "outExtension"],
|
|
114
|
+
"types-styles": ["shorthands"],
|
|
115
|
+
"types-conditions": ["conditions"],
|
|
116
|
+
"types-jsx": jsx,
|
|
117
|
+
"types-entry": [],
|
|
118
|
+
"types-gen": [],
|
|
119
|
+
"types-gen-system": [],
|
|
120
|
+
themes: ["themes"].concat(tokens),
|
|
121
|
+
"static-css": [
|
|
122
|
+
"staticCss",
|
|
123
|
+
"patterns",
|
|
124
|
+
"theme.recipes",
|
|
125
|
+
"theme.slotRecipes"
|
|
126
|
+
].concat(tokens),
|
|
127
|
+
styles: [],
|
|
128
|
+
"styles.css": []
|
|
129
|
+
};
|
|
130
|
+
const artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
|
|
131
|
+
if (!paths.length) return () => void 0;
|
|
132
|
+
return createMatcher(key, paths.concat(all));
|
|
133
|
+
});
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/diff-config.ts
|
|
136
|
+
const runIfFn = (fn) => typeof fn === "function" ? fn() : fn;
|
|
137
|
+
/**
|
|
138
|
+
* Check if recipes were empty before and non-empty now (or vice versa)
|
|
139
|
+
*/
|
|
140
|
+
const hasRecipeStateTransition = (prevConfig, nextConfig) => {
|
|
141
|
+
const prevRecipes = prevConfig.theme?.recipes ?? {};
|
|
142
|
+
const prevSlotRecipes = prevConfig.theme?.slotRecipes ?? {};
|
|
143
|
+
const prevHasRecipes = Object.keys(prevRecipes).length > 0 || Object.keys(prevSlotRecipes).length > 0;
|
|
144
|
+
const nextRecipes = nextConfig.theme?.recipes ?? {};
|
|
145
|
+
const nextSlotRecipes = nextConfig.theme?.slotRecipes ?? {};
|
|
146
|
+
return prevHasRecipes !== (Object.keys(nextRecipes).length > 0 || Object.keys(nextSlotRecipes).length > 0);
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Diff the two config objects and return the list of affected properties
|
|
150
|
+
*/
|
|
151
|
+
function diffConfigs(config, prevConfig) {
|
|
152
|
+
const affected = {
|
|
153
|
+
artifacts: /* @__PURE__ */ new Set(),
|
|
154
|
+
hasConfigChanged: false,
|
|
155
|
+
diffs: []
|
|
156
|
+
};
|
|
157
|
+
if (!prevConfig) {
|
|
158
|
+
affected.hasConfigChanged = true;
|
|
159
|
+
return affected;
|
|
160
|
+
}
|
|
161
|
+
const configDiff = (0, microdiff.default)(prevConfig, runIfFn(config));
|
|
162
|
+
if (!configDiff.length) return affected;
|
|
163
|
+
affected.hasConfigChanged = true;
|
|
164
|
+
affected.diffs = configDiff;
|
|
165
|
+
configDiff.forEach((change) => {
|
|
166
|
+
const changePath = change.path.join(".");
|
|
167
|
+
artifactMatchers.forEach((matcher) => {
|
|
168
|
+
const id = matcher(changePath);
|
|
169
|
+
if (!id) return;
|
|
170
|
+
if (id === "recipes") {
|
|
171
|
+
const name = (0, _bamboocss_shared.dashCase)(change.path.slice(1, 3).join("."));
|
|
172
|
+
affected.artifacts.add(name);
|
|
173
|
+
}
|
|
174
|
+
if (id === "patterns") {
|
|
175
|
+
const name = (0, _bamboocss_shared.dashCase)(change.path.slice(0, 2).join("."));
|
|
176
|
+
affected.artifacts.add(name);
|
|
177
|
+
}
|
|
178
|
+
affected.artifacts.add(id);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
if (affected.artifacts.has("recipes") || affected.artifacts.has("recipes-index")) {
|
|
182
|
+
if (hasRecipeStateTransition(prevConfig, runIfFn(config))) affected.artifacts.add("create-recipe");
|
|
183
|
+
}
|
|
184
|
+
return affected;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
exports.diffConfigs = diffConfigs;
|
package/dist/diff-config.mjs
CHANGED
|
@@ -1,2 +1,163 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dashCase } from "@bamboocss/shared";
|
|
2
|
+
import microdiff from "microdiff";
|
|
3
|
+
//#region src/create-matcher.ts
|
|
4
|
+
/**
|
|
5
|
+
* Acts like a .gitignore matcher
|
|
6
|
+
* e.g a list of string to search for nested path with glob and exclusion allowed
|
|
7
|
+
* ["outdir", "theme.recipes", '*.css', '!aaa.*.bbb']
|
|
8
|
+
*/
|
|
9
|
+
function createMatcher(id, patterns) {
|
|
10
|
+
if (!patterns?.length) return () => void 0;
|
|
11
|
+
const includePatterns = [];
|
|
12
|
+
const excludePatterns = [];
|
|
13
|
+
new Set(patterns).forEach((pattern) => {
|
|
14
|
+
const regexString = pattern.replace(/\*/g, ".*");
|
|
15
|
+
if (pattern.startsWith("!")) excludePatterns.push(regexString.slice(1));
|
|
16
|
+
else includePatterns.push(regexString);
|
|
17
|
+
});
|
|
18
|
+
const include = new RegExp(includePatterns.join("|"));
|
|
19
|
+
const exclude = new RegExp(excludePatterns.join("|"));
|
|
20
|
+
return (path) => {
|
|
21
|
+
if (excludePatterns.length && exclude.test(path)) return;
|
|
22
|
+
return include.test(path) ? id : void 0;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/config-deps.ts
|
|
27
|
+
const all = [
|
|
28
|
+
"clean",
|
|
29
|
+
"cwd",
|
|
30
|
+
"eject",
|
|
31
|
+
"outdir",
|
|
32
|
+
"forceConsistentTypeExtension",
|
|
33
|
+
"outExtension",
|
|
34
|
+
"emitTokensOnly",
|
|
35
|
+
"presets",
|
|
36
|
+
"plugins",
|
|
37
|
+
"hooks"
|
|
38
|
+
];
|
|
39
|
+
const format = [
|
|
40
|
+
"syntax",
|
|
41
|
+
"hash",
|
|
42
|
+
"prefix",
|
|
43
|
+
"separator",
|
|
44
|
+
"strictTokens",
|
|
45
|
+
"strictPropertyValues",
|
|
46
|
+
"shorthands"
|
|
47
|
+
];
|
|
48
|
+
const tokens = [
|
|
49
|
+
"utilities",
|
|
50
|
+
"conditions",
|
|
51
|
+
"theme.tokens",
|
|
52
|
+
"theme.semanticTokens",
|
|
53
|
+
"theme.breakpoints",
|
|
54
|
+
"theme.containerNames",
|
|
55
|
+
"theme.containerSizes"
|
|
56
|
+
];
|
|
57
|
+
const jsx = [
|
|
58
|
+
"jsxFramework",
|
|
59
|
+
"jsxFactory",
|
|
60
|
+
"jsxStyleProps",
|
|
61
|
+
"syntax"
|
|
62
|
+
];
|
|
63
|
+
const common = tokens.concat(jsx, format);
|
|
64
|
+
const artifactConfigDeps = {
|
|
65
|
+
helpers: ["syntax", "jsxFramework"],
|
|
66
|
+
keyframes: ["theme.keyframes", "layers"],
|
|
67
|
+
"design-tokens": ["layers", "!utilities.*.className"].concat(tokens),
|
|
68
|
+
types: ["!utilities.*.className"].concat(common),
|
|
69
|
+
"css-fn": common,
|
|
70
|
+
cva: ["syntax"],
|
|
71
|
+
sva: ["syntax"],
|
|
72
|
+
cx: [],
|
|
73
|
+
"create-recipe": [
|
|
74
|
+
"separator",
|
|
75
|
+
"prefix",
|
|
76
|
+
"hash"
|
|
77
|
+
],
|
|
78
|
+
"recipes-index": ["theme.recipes", "theme.slotRecipes"],
|
|
79
|
+
recipes: ["theme.recipes", "theme.slotRecipes"],
|
|
80
|
+
"patterns-index": ["syntax", "patterns"],
|
|
81
|
+
patterns: ["syntax", "patterns"],
|
|
82
|
+
"jsx-is-valid-prop": common,
|
|
83
|
+
"jsx-factory": jsx,
|
|
84
|
+
"jsx-helpers": jsx,
|
|
85
|
+
"jsx-patterns": jsx.concat("patterns"),
|
|
86
|
+
"jsx-patterns-index": jsx.concat("patterns"),
|
|
87
|
+
"jsx-create-style-context": jsx,
|
|
88
|
+
"css-index": ["syntax"],
|
|
89
|
+
"package.json": ["forceConsistentTypeExtension", "outExtension"],
|
|
90
|
+
"types-styles": ["shorthands"],
|
|
91
|
+
"types-conditions": ["conditions"],
|
|
92
|
+
"types-jsx": jsx,
|
|
93
|
+
"types-entry": [],
|
|
94
|
+
"types-gen": [],
|
|
95
|
+
"types-gen-system": [],
|
|
96
|
+
themes: ["themes"].concat(tokens),
|
|
97
|
+
"static-css": [
|
|
98
|
+
"staticCss",
|
|
99
|
+
"patterns",
|
|
100
|
+
"theme.recipes",
|
|
101
|
+
"theme.slotRecipes"
|
|
102
|
+
].concat(tokens),
|
|
103
|
+
styles: [],
|
|
104
|
+
"styles.css": []
|
|
105
|
+
};
|
|
106
|
+
const artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
|
|
107
|
+
if (!paths.length) return () => void 0;
|
|
108
|
+
return createMatcher(key, paths.concat(all));
|
|
109
|
+
});
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/diff-config.ts
|
|
112
|
+
const runIfFn = (fn) => typeof fn === "function" ? fn() : fn;
|
|
113
|
+
/**
|
|
114
|
+
* Check if recipes were empty before and non-empty now (or vice versa)
|
|
115
|
+
*/
|
|
116
|
+
const hasRecipeStateTransition = (prevConfig, nextConfig) => {
|
|
117
|
+
const prevRecipes = prevConfig.theme?.recipes ?? {};
|
|
118
|
+
const prevSlotRecipes = prevConfig.theme?.slotRecipes ?? {};
|
|
119
|
+
const prevHasRecipes = Object.keys(prevRecipes).length > 0 || Object.keys(prevSlotRecipes).length > 0;
|
|
120
|
+
const nextRecipes = nextConfig.theme?.recipes ?? {};
|
|
121
|
+
const nextSlotRecipes = nextConfig.theme?.slotRecipes ?? {};
|
|
122
|
+
return prevHasRecipes !== (Object.keys(nextRecipes).length > 0 || Object.keys(nextSlotRecipes).length > 0);
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Diff the two config objects and return the list of affected properties
|
|
126
|
+
*/
|
|
127
|
+
function diffConfigs(config, prevConfig) {
|
|
128
|
+
const affected = {
|
|
129
|
+
artifacts: /* @__PURE__ */ new Set(),
|
|
130
|
+
hasConfigChanged: false,
|
|
131
|
+
diffs: []
|
|
132
|
+
};
|
|
133
|
+
if (!prevConfig) {
|
|
134
|
+
affected.hasConfigChanged = true;
|
|
135
|
+
return affected;
|
|
136
|
+
}
|
|
137
|
+
const configDiff = microdiff(prevConfig, runIfFn(config));
|
|
138
|
+
if (!configDiff.length) return affected;
|
|
139
|
+
affected.hasConfigChanged = true;
|
|
140
|
+
affected.diffs = configDiff;
|
|
141
|
+
configDiff.forEach((change) => {
|
|
142
|
+
const changePath = change.path.join(".");
|
|
143
|
+
artifactMatchers.forEach((matcher) => {
|
|
144
|
+
const id = matcher(changePath);
|
|
145
|
+
if (!id) return;
|
|
146
|
+
if (id === "recipes") {
|
|
147
|
+
const name = dashCase(change.path.slice(1, 3).join("."));
|
|
148
|
+
affected.artifacts.add(name);
|
|
149
|
+
}
|
|
150
|
+
if (id === "patterns") {
|
|
151
|
+
const name = dashCase(change.path.slice(0, 2).join("."));
|
|
152
|
+
affected.artifacts.add(name);
|
|
153
|
+
}
|
|
154
|
+
affected.artifacts.add(id);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
if (affected.artifacts.has("recipes") || affected.artifacts.has("recipes-index")) {
|
|
158
|
+
if (hasRecipeStateTransition(prevConfig, runIfFn(config))) affected.artifacts.add("create-recipe");
|
|
159
|
+
}
|
|
160
|
+
return affected;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
2
163
|
export { diffConfigs };
|