@bamboocss/config 1.11.4 → 1.12.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.
@@ -1,197 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
23
- let _bamboocss_shared = require("@bamboocss/shared");
24
- let microdiff = require("microdiff");
25
- microdiff = __toESM(microdiff);
26
- //#region src/create-matcher.ts
27
- /**
28
- * Acts like a .gitignore matcher
29
- * e.g a list of string to search for nested path with glob and exclusion allowed
30
- * ["outdir", "theme.recipes", '*.css', '!aaa.*.bbb']
31
- */
32
- function createMatcher(id, patterns) {
33
- if (!patterns?.length) return () => void 0;
34
- const includePatterns = [];
35
- const excludePatterns = [];
36
- new Set(patterns).forEach((pattern) => {
37
- const regexString = pattern.replace(/\*/g, ".*");
38
- if (pattern.startsWith("!")) excludePatterns.push(regexString.slice(1));
39
- else includePatterns.push(regexString);
40
- });
41
- const include = new RegExp(includePatterns.join("|"));
42
- const exclude = new RegExp(excludePatterns.join("|"));
43
- return (path) => {
44
- if (excludePatterns.length && exclude.test(path)) return;
45
- return include.test(path) ? id : void 0;
46
- };
47
- }
48
- //#endregion
49
- //#region src/config-deps.ts
50
- const all = [
51
- "clean",
52
- "cwd",
53
- "eject",
54
- "outdir",
55
- "forceConsistentTypeExtension",
56
- "outExtension",
57
- "emitTokensOnly",
58
- "presets",
59
- "plugins",
60
- "hooks"
61
- ];
62
- const format = [
63
- "syntax",
64
- "hash",
65
- "prefix",
66
- "separator",
67
- "strictTokens",
68
- "strictPropertyValues",
69
- "shorthands"
70
- ];
71
- const tokens = [
72
- "utilities",
73
- "conditions",
74
- "theme.tokens",
75
- "theme.semanticTokens",
76
- "theme.breakpoints",
77
- "theme.containerNames",
78
- "theme.containerSizes"
79
- ];
80
- const jsx = [
81
- "jsxFramework",
82
- "jsxFactory",
83
- "jsxStyleProps",
84
- "syntax"
85
- ];
86
- const common = tokens.concat(jsx, format);
87
- const artifactConfigDeps = {
88
- helpers: ["syntax", "jsxFramework"],
89
- keyframes: ["theme.keyframes", "layers"],
90
- "design-tokens": ["layers", "!utilities.*.className"].concat(tokens),
91
- types: ["!utilities.*.className"].concat(common),
92
- "css-fn": common,
93
- cva: ["syntax"],
94
- sva: ["syntax"],
95
- cx: [],
96
- "create-recipe": [
97
- "separator",
98
- "prefix",
99
- "hash"
100
- ],
101
- "recipes-index": ["theme.recipes", "theme.slotRecipes"],
102
- recipes: ["theme.recipes", "theme.slotRecipes"],
103
- "patterns-index": ["syntax", "patterns"],
104
- patterns: ["syntax", "patterns"],
105
- "jsx-is-valid-prop": common,
106
- "jsx-factory": jsx,
107
- "jsx-helpers": jsx,
108
- "jsx-patterns": jsx.concat("patterns"),
109
- "jsx-patterns-index": jsx.concat("patterns"),
110
- "jsx-create-style-context": jsx,
111
- "css-index": ["syntax"],
112
- "package.json": ["forceConsistentTypeExtension", "outExtension"],
113
- "types-styles": ["shorthands"],
114
- "types-conditions": ["conditions"],
115
- "types-jsx": jsx,
116
- "types-entry": [],
117
- "types-gen": [],
118
- "types-gen-system": [],
119
- themes: ["themes"].concat(tokens),
120
- "static-css": [
121
- "staticCss",
122
- "patterns",
123
- "theme.recipes",
124
- "theme.slotRecipes"
125
- ].concat(tokens),
126
- styles: [],
127
- "styles.css": []
128
- };
129
- const artifactMatchers = Object.entries(artifactConfigDeps).map(([key, paths]) => {
130
- if (!paths.length) return () => void 0;
131
- return createMatcher(key, paths.concat(all));
132
- });
133
- //#endregion
134
- //#region src/diff-config.ts
135
- const runIfFn = (fn) => typeof fn === "function" ? fn() : fn;
136
- /**
137
- * Check if recipes were empty before and non-empty now (or vice versa)
138
- */
139
- const hasRecipeStateTransition = (prevConfig, nextConfig) => {
140
- const prevRecipes = prevConfig.theme?.recipes ?? {};
141
- const prevSlotRecipes = prevConfig.theme?.slotRecipes ?? {};
142
- const prevHasRecipes = Object.keys(prevRecipes).length > 0 || Object.keys(prevSlotRecipes).length > 0;
143
- const nextRecipes = nextConfig.theme?.recipes ?? {};
144
- const nextSlotRecipes = nextConfig.theme?.slotRecipes ?? {};
145
- return prevHasRecipes !== (Object.keys(nextRecipes).length > 0 || Object.keys(nextSlotRecipes).length > 0);
146
- };
147
- /**
148
- * Diff the two config objects and return the list of affected properties
149
- */
150
- function diffConfigs(config, prevConfig) {
151
- const affected = {
152
- artifacts: /* @__PURE__ */ new Set(),
153
- hasConfigChanged: false,
154
- diffs: []
155
- };
156
- if (!prevConfig) {
157
- affected.hasConfigChanged = true;
158
- return affected;
159
- }
160
- const configDiff = (0, microdiff.default)(prevConfig, runIfFn(config));
161
- if (!configDiff.length) return affected;
162
- affected.hasConfigChanged = true;
163
- affected.diffs = configDiff;
164
- configDiff.forEach((change) => {
165
- const changePath = change.path.join(".");
166
- artifactMatchers.forEach((matcher) => {
167
- const id = matcher(changePath);
168
- if (!id) return;
169
- if (id === "recipes") {
170
- const name = (0, _bamboocss_shared.dashCase)(change.path.slice(1, 3).join("."));
171
- affected.artifacts.add(name);
172
- }
173
- if (id === "patterns") {
174
- const name = (0, _bamboocss_shared.dashCase)(change.path.slice(0, 2).join("."));
175
- affected.artifacts.add(name);
176
- }
177
- affected.artifacts.add(id);
178
- });
179
- });
180
- if (affected.artifacts.has("recipes") || affected.artifacts.has("recipes-index")) {
181
- if (hasRecipeStateTransition(prevConfig, runIfFn(config))) affected.artifacts.add("create-recipe");
182
- }
183
- return affected;
184
- }
185
- //#endregion
186
- Object.defineProperty(exports, "__toESM", {
187
- enumerable: true,
188
- get: function() {
189
- return __toESM;
190
- }
191
- });
192
- Object.defineProperty(exports, "diffConfigs", {
193
- enumerable: true,
194
- get: function() {
195
- return diffConfigs;
196
- }
197
- });
@@ -1,163 +0,0 @@
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
163
- export { diffConfigs as t };
@@ -1,10 +0,0 @@
1
- import { Config, DiffConfigResult } from "@bamboocss/types";
2
-
3
- //#region src/diff-config.d.ts
4
- type ConfigOrFn = Config | (() => Config);
5
- /**
6
- * Diff the two config objects and return the list of affected properties
7
- */
8
- declare function diffConfigs(config: ConfigOrFn, prevConfig: Config | undefined): DiffConfigResult;
9
- //#endregion
10
- export { diffConfigs };
@@ -1,10 +0,0 @@
1
- import { Config, DiffConfigResult } from "@bamboocss/types";
2
-
3
- //#region src/diff-config.d.ts
4
- type ConfigOrFn = Config | (() => Config);
5
- /**
6
- * Diff the two config objects and return the list of affected properties
7
- */
8
- declare function diffConfigs(config: ConfigOrFn, prevConfig: Config | undefined): DiffConfigResult;
9
- //#endregion
10
- export { diffConfigs };
package/dist/index.d.cts DELETED
@@ -1,84 +0,0 @@
1
- import { diffConfigs } from "./diff-config.cjs";
2
- import { n as convertTsPathsToRegexes, t as PathMapping } from "./ts-config-paths-wVx39QZ0.cjs";
3
- import { n as mergeHooks, t as mergeConfigs } from "./merge-config-DVOlBQJY.cjs";
4
- import { BambooHooks, Config, ConfigTsOptions, LoadConfigResult as LoadConfigResult$1 } from "@bamboocss/types";
5
- import { CompilerOptions, TypeAcquisition } from "typescript";
6
-
7
- //#region src/types.d.ts
8
- interface ConfigFileOptions {
9
- cwd: string;
10
- file?: string;
11
- }
12
- interface BundleConfigResult<T = Config> {
13
- config: T;
14
- dependencies: string[];
15
- path: string;
16
- }
17
- //#endregion
18
- //#region src/bundle-config.d.ts
19
- declare function bundleConfig(options: ConfigFileOptions): Promise<BundleConfigResult>;
20
- //#endregion
21
- //#region src/find-config.d.ts
22
- declare function findConfig(options: Partial<ConfigFileOptions>): string;
23
- //#endregion
24
- //#region ../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.d.mts
25
- type StripEnums<T extends Record<string, any>> = { [K in keyof T]: T[K] extends boolean ? T[K] : T[K] extends string ? T[K] : T[K] extends object ? T[K] : T[K] extends Array<any> ? T[K] : T[K] extends undefined ? undefined : any };
26
- interface TSConfig {
27
- compilerOptions?: StripEnums<CompilerOptions>;
28
- exclude?: string[];
29
- compileOnSave?: boolean;
30
- extends?: string | string[];
31
- files?: string[];
32
- include?: string[];
33
- typeAcquisition?: TypeAcquisition;
34
- references?: {
35
- path: string;
36
- }[];
37
- }
38
- /**
39
- * Defines a TSConfig structure.
40
- * @param tsconfig - The contents of `tsconfig.json` as an object. See {@link TSConfig}.
41
- * @returns the same `tsconfig.json` object.
42
- */
43
- //#endregion
44
- //#region src/get-mod-deps.d.ts
45
- interface GetDepsOptions {
46
- filename: string;
47
- ext: string;
48
- cwd: string;
49
- seen: Set<string>;
50
- baseUrl: string | undefined;
51
- pathMappings: PathMapping[];
52
- foundModuleAliases: Map<string, string>;
53
- compilerOptions?: TSConfig['compilerOptions'];
54
- }
55
- declare function getConfigDependencies(filePath: string, tsOptions?: ConfigTsOptions, compilerOptions?: TSConfig['compilerOptions']): {
56
- deps: Set<string>;
57
- aliases: Map<string, string>;
58
- };
59
- //#endregion
60
- //#region src/get-resolved-config.d.ts
61
- type Extendable<T> = T & {
62
- extend?: T;
63
- };
64
- type ExtendableConfig = Extendable<Config>;
65
- /**
66
- * Recursively merge all presets into a single config (depth-first using stack)
67
- */
68
- declare function getResolvedConfig(config: ExtendableConfig, cwd: string, hooks?: Partial<BambooHooks>): Promise<Config>;
69
- //#endregion
70
- //#region src/load-config.d.ts
71
- /**
72
- * Find, load and resolve the final config (including presets)
73
- */
74
- declare function loadConfig(options: ConfigFileOptions): Promise<LoadConfigResult>;
75
- //#endregion
76
- //#region src/resolve-config.d.ts
77
- /**
78
- * Resolve the final config (including presets)
79
- * @bamboocss/preset-base: ALWAYS included if NOT using eject: true
80
- * @bamboocss/preset-bamboo: only included by default if no presets
81
- */
82
- declare function resolveConfig(result: BundleConfigResult, cwd: string): Promise<LoadConfigResult$1>;
83
- //#endregion
84
- export { type BundleConfigResult, type GetDepsOptions, bundleConfig, convertTsPathsToRegexes, diffConfigs, findConfig, getConfigDependencies, getResolvedConfig, loadConfig, mergeConfigs, mergeHooks, resolveConfig };
package/dist/index.d.mts DELETED
@@ -1,84 +0,0 @@
1
- import { diffConfigs } from "./diff-config.mjs";
2
- import { n as convertTsPathsToRegexes, t as PathMapping } from "./ts-config-paths-CvGId8kq.mjs";
3
- import { n as mergeHooks, t as mergeConfigs } from "./merge-config-oEiBYbfB.mjs";
4
- import { CompilerOptions, TypeAcquisition } from "typescript";
5
- import { BambooHooks, Config, ConfigTsOptions, LoadConfigResult as LoadConfigResult$1 } from "@bamboocss/types";
6
-
7
- //#region src/types.d.ts
8
- interface ConfigFileOptions {
9
- cwd: string;
10
- file?: string;
11
- }
12
- interface BundleConfigResult<T = Config> {
13
- config: T;
14
- dependencies: string[];
15
- path: string;
16
- }
17
- //#endregion
18
- //#region src/bundle-config.d.ts
19
- declare function bundleConfig(options: ConfigFileOptions): Promise<BundleConfigResult>;
20
- //#endregion
21
- //#region src/find-config.d.ts
22
- declare function findConfig(options: Partial<ConfigFileOptions>): string;
23
- //#endregion
24
- //#region ../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.d.mts
25
- type StripEnums<T extends Record<string, any>> = { [K in keyof T]: T[K] extends boolean ? T[K] : T[K] extends string ? T[K] : T[K] extends object ? T[K] : T[K] extends Array<any> ? T[K] : T[K] extends undefined ? undefined : any };
26
- interface TSConfig {
27
- compilerOptions?: StripEnums<CompilerOptions>;
28
- exclude?: string[];
29
- compileOnSave?: boolean;
30
- extends?: string | string[];
31
- files?: string[];
32
- include?: string[];
33
- typeAcquisition?: TypeAcquisition;
34
- references?: {
35
- path: string;
36
- }[];
37
- }
38
- /**
39
- * Defines a TSConfig structure.
40
- * @param tsconfig - The contents of `tsconfig.json` as an object. See {@link TSConfig}.
41
- * @returns the same `tsconfig.json` object.
42
- */
43
- //#endregion
44
- //#region src/get-mod-deps.d.ts
45
- interface GetDepsOptions {
46
- filename: string;
47
- ext: string;
48
- cwd: string;
49
- seen: Set<string>;
50
- baseUrl: string | undefined;
51
- pathMappings: PathMapping[];
52
- foundModuleAliases: Map<string, string>;
53
- compilerOptions?: TSConfig['compilerOptions'];
54
- }
55
- declare function getConfigDependencies(filePath: string, tsOptions?: ConfigTsOptions, compilerOptions?: TSConfig['compilerOptions']): {
56
- deps: Set<string>;
57
- aliases: Map<string, string>;
58
- };
59
- //#endregion
60
- //#region src/get-resolved-config.d.ts
61
- type Extendable<T> = T & {
62
- extend?: T;
63
- };
64
- type ExtendableConfig = Extendable<Config>;
65
- /**
66
- * Recursively merge all presets into a single config (depth-first using stack)
67
- */
68
- declare function getResolvedConfig(config: ExtendableConfig, cwd: string, hooks?: Partial<BambooHooks>): Promise<Config>;
69
- //#endregion
70
- //#region src/load-config.d.ts
71
- /**
72
- * Find, load and resolve the final config (including presets)
73
- */
74
- declare function loadConfig(options: ConfigFileOptions): Promise<LoadConfigResult>;
75
- //#endregion
76
- //#region src/resolve-config.d.ts
77
- /**
78
- * Resolve the final config (including presets)
79
- * @bamboocss/preset-base: ALWAYS included if NOT using eject: true
80
- * @bamboocss/preset-bamboo: only included by default if no presets
81
- */
82
- declare function resolveConfig(result: BundleConfigResult, cwd: string): Promise<LoadConfigResult$1>;
83
- //#endregion
84
- export { type BundleConfigResult, type GetDepsOptions, bundleConfig, convertTsPathsToRegexes, diffConfigs, findConfig, getConfigDependencies, getResolvedConfig, loadConfig, mergeConfigs, mergeHooks, resolveConfig };