@bamboocss/parser 1.30.0 → 1.31.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/index.cjs +22 -5
- package/dist/index.d.cts +9 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +23 -6
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -18,6 +18,7 @@ function classifyProject(ctx, resultMap) {
|
|
|
18
18
|
const byComponentInFilepath = /* @__PURE__ */ new Map();
|
|
19
19
|
const globalMaps = createReportMaps();
|
|
20
20
|
const byFilePathMaps = /* @__PURE__ */ new Map();
|
|
21
|
+
const patternHelpers = (0, _bamboocss_shared.createPatternFns)((path, fallback) => ctx.tokens.view.getVar(path) ?? fallback);
|
|
21
22
|
const conditions = new Map(Object.entries(ctx.conditions.values));
|
|
22
23
|
const { groupByProp } = getPropertyGroupMap(ctx);
|
|
23
24
|
let id = 0;
|
|
@@ -46,7 +47,7 @@ function classifyProject(ctx, resultMap) {
|
|
|
46
47
|
const name = item.componentName;
|
|
47
48
|
const pattern = ctx.patterns.details.find((p) => p.baseName === name);
|
|
48
49
|
if (!pattern) return;
|
|
49
|
-
const cssObj = pattern.config.transform?.(data || {},
|
|
50
|
+
const cssObj = pattern.config.transform?.(data || {}, patternHelpers) ?? {};
|
|
50
51
|
const newItem = {
|
|
51
52
|
name: "css",
|
|
52
53
|
type: "css",
|
|
@@ -263,12 +264,12 @@ function classifyProject(ctx, resultMap) {
|
|
|
263
264
|
recipe.compoundVariants?.forEach((v) => functionFn(v.css));
|
|
264
265
|
}
|
|
265
266
|
});
|
|
266
|
-
Object.values(ctx.config.
|
|
267
|
+
Object.values(ctx.config.global?.css ?? {}).forEach((styleObject) => {
|
|
267
268
|
if (!styleObject) return;
|
|
268
269
|
processMap({
|
|
269
270
|
map: _bamboocss_extractor.box.objectToMap(styleObject, null, []),
|
|
270
271
|
current: [],
|
|
271
|
-
filepath: "@config/
|
|
272
|
+
filepath: "@config/global.css",
|
|
272
273
|
skipRange: true,
|
|
273
274
|
localMaps: createReportMaps(),
|
|
274
275
|
componentReportItem: {
|
|
@@ -983,19 +984,35 @@ var ParserResult = class {
|
|
|
983
984
|
}, result)));
|
|
984
985
|
result.data.forEach((obj) => this.encoder.processPattern(name, obj));
|
|
985
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* The variant axes a call site passed and the build could not read.
|
|
989
|
+
*
|
|
990
|
+
* `button({ size })` with a dynamic `size` and `button()` both unbox to `{}`, so the encoder
|
|
991
|
+
* cannot tell "you named an axis I could not resolve" from "you named nothing" — and the
|
|
992
|
+
* difference decides whether a class it is about to emit has a rule behind it. The box still
|
|
993
|
+
* holds the distinction: the key is present, carrying an `unresolvable`.
|
|
994
|
+
*/
|
|
995
|
+
unresolvedVariants(result) {
|
|
996
|
+
const boxNode = result.box;
|
|
997
|
+
if (!boxNode || !_bamboocss_extractor.box.isMap(boxNode)) return void 0;
|
|
998
|
+
const keys = /* @__PURE__ */ new Set();
|
|
999
|
+
for (const [key, value] of boxNode.value.entries()) if (_bamboocss_extractor.box.isUnresolvable(value)) keys.add(key);
|
|
1000
|
+
return keys.size ? keys : void 0;
|
|
1001
|
+
}
|
|
986
1002
|
setRecipe(recipeName, result) {
|
|
987
1003
|
(0, _bamboocss_shared.getOrCreateSet)(this.recipe, recipeName).add(this.append(Object.assign({ type: "recipe" }, result)));
|
|
988
1004
|
const encoder = this.encoder;
|
|
989
1005
|
const recipes = this.context.recipes;
|
|
990
1006
|
if (!recipes.getConfig(recipeName)) return;
|
|
991
1007
|
const recipe = result;
|
|
1008
|
+
const unresolved = this.unresolvedVariants(result);
|
|
992
1009
|
if (result.type) recipe.data.forEach((data) => {
|
|
993
1010
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
994
1011
|
encoder.processStyleProps(styleProps);
|
|
995
|
-
encoder.processRecipe(recipeName, recipeProps);
|
|
1012
|
+
encoder.processRecipe(recipeName, recipeProps, unresolved);
|
|
996
1013
|
});
|
|
997
1014
|
else recipe.data.forEach((data) => {
|
|
998
|
-
encoder.processRecipe(recipeName, data);
|
|
1015
|
+
encoder.processRecipe(recipeName, data, unresolved);
|
|
999
1016
|
});
|
|
1000
1017
|
}
|
|
1001
1018
|
isEmpty() {
|
package/dist/index.d.cts
CHANGED
|
@@ -248,6 +248,15 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
248
248
|
setToken(result: ResultItem, kind?: 'token' | 'tokenValue'): void;
|
|
249
249
|
setViewTransition(result: ResultItem): void;
|
|
250
250
|
setPattern(name: string, result: ResultItem): void;
|
|
251
|
+
/**
|
|
252
|
+
* The variant axes a call site passed and the build could not read.
|
|
253
|
+
*
|
|
254
|
+
* `button({ size })` with a dynamic `size` and `button()` both unbox to `{}`, so the encoder
|
|
255
|
+
* cannot tell "you named an axis I could not resolve" from "you named nothing" — and the
|
|
256
|
+
* difference decides whether a class it is about to emit has a rule behind it. The box still
|
|
257
|
+
* holds the distinction: the key is present, carrying an `unresolvable`.
|
|
258
|
+
*/
|
|
259
|
+
private unresolvedVariants;
|
|
251
260
|
setRecipe(recipeName: string, result: ResultItem): void;
|
|
252
261
|
isEmpty(): boolean;
|
|
253
262
|
setFilePath(filePath: string): this;
|
package/dist/index.d.mts
CHANGED
|
@@ -248,6 +248,15 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
248
248
|
setToken(result: ResultItem, kind?: 'token' | 'tokenValue'): void;
|
|
249
249
|
setViewTransition(result: ResultItem): void;
|
|
250
250
|
setPattern(name: string, result: ResultItem): void;
|
|
251
|
+
/**
|
|
252
|
+
* The variant axes a call site passed and the build could not read.
|
|
253
|
+
*
|
|
254
|
+
* `button({ size })` with a dynamic `size` and `button()` both unbox to `{}`, so the encoder
|
|
255
|
+
* cannot tell "you named an axis I could not resolve" from "you named nothing" — and the
|
|
256
|
+
* difference decides whether a class it is about to emit has a rule behind it. The box still
|
|
257
|
+
* holds the distinction: the key is present, carrying an `unresolvable`.
|
|
258
|
+
*/
|
|
259
|
+
private unresolvedVariants;
|
|
251
260
|
setRecipe(recipeName: string, result: ResultItem): void;
|
|
252
261
|
isEmpty(): boolean;
|
|
253
262
|
setFilePath(filePath: string): this;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, Project as Project$1, ScriptKind, ts } from "ts-morph";
|
|
2
2
|
import { box, clearBoxNodeCache, extract, unbox, unwrapExpression } from "@bamboocss/extractor";
|
|
3
|
-
import { BambooError, compact,
|
|
3
|
+
import { BambooError, compact, createPatternFns, getOrCreateSet } from "@bamboocss/shared";
|
|
4
4
|
import { logger } from "@bamboocss/logger";
|
|
5
5
|
import { match } from "ts-pattern";
|
|
6
6
|
import { resolveTsPathPattern } from "@bamboocss/config/ts-path";
|
|
@@ -17,6 +17,7 @@ function classifyProject(ctx, resultMap) {
|
|
|
17
17
|
const byComponentInFilepath = /* @__PURE__ */ new Map();
|
|
18
18
|
const globalMaps = createReportMaps();
|
|
19
19
|
const byFilePathMaps = /* @__PURE__ */ new Map();
|
|
20
|
+
const patternHelpers = createPatternFns((path, fallback) => ctx.tokens.view.getVar(path) ?? fallback);
|
|
20
21
|
const conditions = new Map(Object.entries(ctx.conditions.values));
|
|
21
22
|
const { groupByProp } = getPropertyGroupMap(ctx);
|
|
22
23
|
let id = 0;
|
|
@@ -45,7 +46,7 @@ function classifyProject(ctx, resultMap) {
|
|
|
45
46
|
const name = item.componentName;
|
|
46
47
|
const pattern = ctx.patterns.details.find((p) => p.baseName === name);
|
|
47
48
|
if (!pattern) return;
|
|
48
|
-
const cssObj = pattern.config.transform?.(data || {},
|
|
49
|
+
const cssObj = pattern.config.transform?.(data || {}, patternHelpers) ?? {};
|
|
49
50
|
const newItem = {
|
|
50
51
|
name: "css",
|
|
51
52
|
type: "css",
|
|
@@ -262,12 +263,12 @@ function classifyProject(ctx, resultMap) {
|
|
|
262
263
|
recipe.compoundVariants?.forEach((v) => functionFn(v.css));
|
|
263
264
|
}
|
|
264
265
|
});
|
|
265
|
-
Object.values(ctx.config.
|
|
266
|
+
Object.values(ctx.config.global?.css ?? {}).forEach((styleObject) => {
|
|
266
267
|
if (!styleObject) return;
|
|
267
268
|
processMap({
|
|
268
269
|
map: box.objectToMap(styleObject, null, []),
|
|
269
270
|
current: [],
|
|
270
|
-
filepath: "@config/
|
|
271
|
+
filepath: "@config/global.css",
|
|
271
272
|
skipRange: true,
|
|
272
273
|
localMaps: createReportMaps(),
|
|
273
274
|
componentReportItem: {
|
|
@@ -982,19 +983,35 @@ var ParserResult = class {
|
|
|
982
983
|
}, result)));
|
|
983
984
|
result.data.forEach((obj) => this.encoder.processPattern(name, obj));
|
|
984
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* The variant axes a call site passed and the build could not read.
|
|
988
|
+
*
|
|
989
|
+
* `button({ size })` with a dynamic `size` and `button()` both unbox to `{}`, so the encoder
|
|
990
|
+
* cannot tell "you named an axis I could not resolve" from "you named nothing" — and the
|
|
991
|
+
* difference decides whether a class it is about to emit has a rule behind it. The box still
|
|
992
|
+
* holds the distinction: the key is present, carrying an `unresolvable`.
|
|
993
|
+
*/
|
|
994
|
+
unresolvedVariants(result) {
|
|
995
|
+
const boxNode = result.box;
|
|
996
|
+
if (!boxNode || !box.isMap(boxNode)) return void 0;
|
|
997
|
+
const keys = /* @__PURE__ */ new Set();
|
|
998
|
+
for (const [key, value] of boxNode.value.entries()) if (box.isUnresolvable(value)) keys.add(key);
|
|
999
|
+
return keys.size ? keys : void 0;
|
|
1000
|
+
}
|
|
985
1001
|
setRecipe(recipeName, result) {
|
|
986
1002
|
getOrCreateSet(this.recipe, recipeName).add(this.append(Object.assign({ type: "recipe" }, result)));
|
|
987
1003
|
const encoder = this.encoder;
|
|
988
1004
|
const recipes = this.context.recipes;
|
|
989
1005
|
if (!recipes.getConfig(recipeName)) return;
|
|
990
1006
|
const recipe = result;
|
|
1007
|
+
const unresolved = this.unresolvedVariants(result);
|
|
991
1008
|
if (result.type) recipe.data.forEach((data) => {
|
|
992
1009
|
const [recipeProps, styleProps] = recipes.splitProps(recipeName, data);
|
|
993
1010
|
encoder.processStyleProps(styleProps);
|
|
994
|
-
encoder.processRecipe(recipeName, recipeProps);
|
|
1011
|
+
encoder.processRecipe(recipeName, recipeProps, unresolved);
|
|
995
1012
|
});
|
|
996
1013
|
else recipe.data.forEach((data) => {
|
|
997
|
-
encoder.processRecipe(recipeName, data);
|
|
1014
|
+
encoder.processRecipe(recipeName, data, unresolved);
|
|
998
1015
|
});
|
|
999
1016
|
}
|
|
1000
1017
|
isEmpty() {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/parser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"description": "The static parser for bamboo css",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Gajus Kuizinas <gajus@gajus.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/bamboocss
|
|
10
|
+
"url": "git+https://github.com/gajus/bamboocss.git",
|
|
11
11
|
"directory": "packages/parser"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"ts-morph": "28.0.0",
|
|
36
36
|
"ts-pattern": "5.9.0",
|
|
37
|
-
"@bamboocss/config": "^1.
|
|
38
|
-
"@bamboocss/core": "^1.
|
|
39
|
-
"@bamboocss/extractor": "1.
|
|
40
|
-
"@bamboocss/logger": "1.
|
|
41
|
-
"@bamboocss/shared": "1.
|
|
42
|
-
"@bamboocss/types": "1.
|
|
37
|
+
"@bamboocss/config": "^1.31.0",
|
|
38
|
+
"@bamboocss/core": "^1.31.0",
|
|
39
|
+
"@bamboocss/extractor": "1.31.0",
|
|
40
|
+
"@bamboocss/logger": "1.31.0",
|
|
41
|
+
"@bamboocss/shared": "1.31.0",
|
|
42
|
+
"@bamboocss/types": "1.31.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@bamboocss/generator": "1.
|
|
46
|
-
"@bamboocss/plugin-svelte": "1.
|
|
47
|
-
"@bamboocss/plugin-vue": "1.
|
|
45
|
+
"@bamboocss/generator": "1.31.0",
|
|
46
|
+
"@bamboocss/plugin-svelte": "1.31.0",
|
|
47
|
+
"@bamboocss/plugin-vue": "1.31.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsdown src/index.ts --format=esm,cjs --dts",
|