@bamboocss/config 1.11.1 → 1.11.3
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-Co_3mDXE.cjs +197 -0
- package/dist/diff-config-KDQWMnQN.mjs +163 -0
- package/dist/diff-config.cjs +3 -0
- package/dist/diff-config.d.cts +10 -0
- package/dist/diff-config.d.mts +10 -0
- package/dist/diff-config.mjs +2 -6
- package/dist/index.cjs +575 -0
- package/dist/index.d.cts +84 -0
- package/dist/index.d.mts +84 -0
- package/dist/index.mjs +520 -589
- package/dist/merge-config-CcNpHJit.cjs +312 -0
- package/dist/merge-config-DI__LOWx.mjs +270 -0
- package/dist/merge-config-DVOlBQJY.d.cts +16 -0
- package/dist/merge-config-oEiBYbfB.d.mts +16 -0
- package/dist/merge-config.cjs +4 -0
- package/dist/merge-config.d.cts +2 -0
- package/dist/merge-config.d.mts +2 -0
- package/dist/merge-config.mjs +2 -8
- package/dist/resolve-ts-path-pattern.cjs +21 -0
- package/dist/resolve-ts-path-pattern.d.cts +9 -0
- package/dist/resolve-ts-path-pattern.d.mts +9 -0
- package/dist/resolve-ts-path-pattern.mjs +18 -5
- package/dist/ts-config-paths-CvGId8kq.d.mts +11 -0
- package/dist/ts-config-paths-wVx39QZ0.d.cts +11 -0
- package/package.json +19 -19
- package/dist/chunk-6TQW6KOI.mjs +0 -154
- package/dist/chunk-RIBK22OM.mjs +0 -265
- package/dist/chunk-RPIVZP2I.mjs +0 -22
- package/dist/diff-config.js +0 -188
- package/dist/index.js +0 -1086
- package/dist/merge-config.js +0 -259
- package/dist/resolve-ts-path-pattern.js +0 -46
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { posix, sep } from "path";
|
|
2
|
+
//#region src/resolve-ts-path-pattern.ts
|
|
3
|
+
/**
|
|
4
|
+
* @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/index.ts#LL231C57-L231C57
|
|
5
|
+
*/
|
|
6
|
+
const resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
|
|
7
|
+
for (const mapping of pathMappings) {
|
|
8
|
+
const match = moduleSpecifier.match(mapping.pattern);
|
|
9
|
+
if (!match) continue;
|
|
10
|
+
for (const pathTemplate of mapping.paths) {
|
|
11
|
+
let starCount = 0;
|
|
12
|
+
return pathTemplate.replace(/\*/g, () => {
|
|
13
|
+
return match[Math.min(++starCount, match.length - 1)];
|
|
14
|
+
}).split(sep).join(posix.sep);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
6
17
|
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { resolveTsPathPattern };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/ts-config-paths.d.ts
|
|
2
|
+
interface PathMapping {
|
|
3
|
+
pattern: RegExp;
|
|
4
|
+
paths: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
|
|
8
|
+
*/
|
|
9
|
+
declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { convertTsPathsToRegexes as n, PathMapping as t };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/ts-config-paths.d.ts
|
|
2
|
+
interface PathMapping {
|
|
3
|
+
pattern: RegExp;
|
|
4
|
+
paths: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
|
|
8
|
+
*/
|
|
9
|
+
declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { convertTsPathsToRegexes as n, PathMapping as t };
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/config",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.3",
|
|
4
4
|
"description": "Find and load bamboo config",
|
|
5
5
|
"homepage": "https://bamboo-css.com",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Segun Adebayo <joseshegs@gmail.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/
|
|
10
|
+
"url": "git+https://github.com/bamboocss/bamboo.git",
|
|
11
11
|
"directory": "packages/config"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"sideEffects": false,
|
|
17
|
-
"main": "dist/index.
|
|
17
|
+
"main": "dist/index.cjs",
|
|
18
18
|
"module": "dist/index.mjs",
|
|
19
|
-
"types": "dist/index.d.
|
|
19
|
+
"types": "dist/index.d.cts",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
22
|
"source": "./src/index.ts",
|
|
23
|
-
"types": "./dist/index.d.
|
|
24
|
-
"require": "./dist/index.
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
25
|
"import": {
|
|
26
26
|
"types": "./dist/index.d.mts",
|
|
27
27
|
"default": "./dist/index.mjs"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"./merge": {
|
|
31
31
|
"source": "./src/merge-config.ts",
|
|
32
|
-
"types": "./dist/merge-config.d.
|
|
33
|
-
"require": "./dist/merge-config.
|
|
32
|
+
"types": "./dist/merge-config.d.cts",
|
|
33
|
+
"require": "./dist/merge-config.cjs",
|
|
34
34
|
"import": {
|
|
35
35
|
"types": "./dist/merge-config.d.mts",
|
|
36
36
|
"default": "./dist/merge-config.mjs"
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"./diff": {
|
|
40
40
|
"source": "./src/diff-config.ts",
|
|
41
|
-
"types": "./dist/diff-config.d.
|
|
42
|
-
"require": "./dist/diff-config.
|
|
41
|
+
"types": "./dist/diff-config.d.cts",
|
|
42
|
+
"require": "./dist/diff-config.cjs",
|
|
43
43
|
"import": {
|
|
44
44
|
"types": "./dist/diff-config.d.mts",
|
|
45
45
|
"default": "./dist/diff-config.mjs"
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"./ts-path": {
|
|
49
49
|
"source": "./src/resolve-ts-path-pattern.ts",
|
|
50
|
-
"types": "./dist/resolve-ts-path-pattern.d.
|
|
51
|
-
"require": "./dist/resolve-ts-path-pattern.
|
|
50
|
+
"types": "./dist/resolve-ts-path-pattern.d.cts",
|
|
51
|
+
"require": "./dist/resolve-ts-path-pattern.cjs",
|
|
52
52
|
"import": {
|
|
53
53
|
"types": "./dist/resolve-ts-path-pattern.d.mts",
|
|
54
54
|
"default": "./dist/resolve-ts-path-pattern.mjs"
|
|
@@ -64,18 +64,18 @@
|
|
|
64
64
|
"escalade": "3.2.0",
|
|
65
65
|
"microdiff": "1.5.0",
|
|
66
66
|
"typescript": "6.0.2",
|
|
67
|
-
"@bamboocss/logger": "1.11.
|
|
68
|
-
"@bamboocss/preset-base": "1.11.
|
|
69
|
-
"@bamboocss/
|
|
70
|
-
"@bamboocss/
|
|
71
|
-
"@bamboocss/
|
|
67
|
+
"@bamboocss/logger": "1.11.3",
|
|
68
|
+
"@bamboocss/preset-base": "1.11.3",
|
|
69
|
+
"@bamboocss/shared": "1.11.3",
|
|
70
|
+
"@bamboocss/types": "1.11.3",
|
|
71
|
+
"@bamboocss/preset-bamboo": "1.11.3"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"pkg-types": "2.3.0"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
|
-
"build": "
|
|
78
|
-
"build-fast": "
|
|
77
|
+
"build": "tsdown --tsconfig tsconfig.build.json --dts",
|
|
78
|
+
"build-fast": "tsdown --dts=false",
|
|
79
79
|
"dev": "pnpm build-fast --watch"
|
|
80
80
|
}
|
|
81
81
|
}
|
package/dist/chunk-6TQW6KOI.mjs
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// src/diff-config.ts
|
|
2
|
-
import { dashCase } from "@bamboocss/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-RIBK22OM.mjs
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
// src/merge-config.ts
|
|
2
|
-
import { BAMBOO_CONFIG_NAME, assign, mergeWith, mergeAndConcat, walkObject } from "@bamboocss/shared";
|
|
3
|
-
|
|
4
|
-
// src/merge-hooks.ts
|
|
5
|
-
import { logger } from "@bamboocss/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 "@bamboocss/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: BAMBOO_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
|
-
};
|