@bamboocss/parser 1.28.0 → 1.28.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/dist/index.cjs CHANGED
@@ -65,7 +65,7 @@ function classifyProject(ctx, resultMap) {
65
65
  const { item, kind, filepath, localMaps } = opts;
66
66
  if (!item.box || _bamboocss_extractor.box.isUnresolvable(item.box)) return;
67
67
  if (!item.data) return;
68
- if (item.type === "cva-call") return;
68
+ if (item.type === "cva-call" || item.type === "tokenVar") return;
69
69
  const componentReportItem = {
70
70
  componentIndex: String(componentIndex++),
71
71
  componentName: item.name,
@@ -962,8 +962,14 @@ var ParserResult = class {
962
962
  const unresolved = findUnresolvedRecipeStyles(result);
963
963
  if (unresolved.length) this.unresolved.push(...unresolved);
964
964
  }
965
- setToken(result) {
966
- this.token.add(this.append(Object.assign({ type: "token" }, result)));
965
+ /**
966
+ * `kind` separates `token()` from `token.var()`, which resolve to the value and to the
967
+ * variable reference respectively. They share this set deliberately: everything that reads
968
+ * a result for the token *path* — `collectTokenReferences`, keeping a declaration alive
969
+ * through pruning — wants both, and only the fold cares which half was asked for.
970
+ */
971
+ setToken(result, kind = "token") {
972
+ this.token.add(this.append(Object.assign({ type: kind }, result)));
967
973
  }
968
974
  setViewTransition(result) {
969
975
  this.viewTransition.add(this.append(Object.assign({ type: "viewTransition" }, result)));
@@ -1165,6 +1171,16 @@ function createParser(context) {
1165
1171
  });
1166
1172
  return;
1167
1173
  }
1174
+ if (file.isTokenVarFn(alias)) {
1175
+ result.queryList.forEach((query) => {
1176
+ if (query.kind === "call-expression") parserResult.setToken({
1177
+ name: "token.var",
1178
+ box: query.box.value[0] ?? _bamboocss_extractor.box.fallback(query.box),
1179
+ data: combineResult((0, _bamboocss_extractor.unbox)(query.box.value[0]))
1180
+ }, "tokenVar");
1181
+ });
1182
+ return;
1183
+ }
1168
1184
  (0, ts_pattern.match)(name).when(imports.matchers.css.match, (name) => {
1169
1185
  result.queryList.forEach((query) => {
1170
1186
  if (query.kind === "call-expression") if (query.box.value.length > 1) parserResult.set(name, {
package/dist/index.d.cts CHANGED
@@ -229,7 +229,13 @@ declare class ParserResult implements ParserResultInterface {
229
229
  * hash except an explicit `className`, which is what the message says to reach for.
230
230
  */
231
231
  private reportUnresolvedRecipe;
232
- setToken(result: ResultItem): void;
232
+ /**
233
+ * `kind` separates `token()` from `token.var()`, which resolve to the value and to the
234
+ * variable reference respectively. They share this set deliberately: everything that reads
235
+ * a result for the token *path* — `collectTokenReferences`, keeping a declaration alive
236
+ * through pruning — wants both, and only the fold cares which half was asked for.
237
+ */
238
+ setToken(result: ResultItem, kind?: 'token' | 'tokenVar'): void;
233
239
  setViewTransition(result: ResultItem): void;
234
240
  setPattern(name: string, result: ResultItem): void;
235
241
  setRecipe(recipeName: string, result: ResultItem): void;
package/dist/index.d.mts CHANGED
@@ -229,7 +229,13 @@ declare class ParserResult implements ParserResultInterface {
229
229
  * hash except an explicit `className`, which is what the message says to reach for.
230
230
  */
231
231
  private reportUnresolvedRecipe;
232
- setToken(result: ResultItem): void;
232
+ /**
233
+ * `kind` separates `token()` from `token.var()`, which resolve to the value and to the
234
+ * variable reference respectively. They share this set deliberately: everything that reads
235
+ * a result for the token *path* — `collectTokenReferences`, keeping a declaration alive
236
+ * through pruning — wants both, and only the fold cares which half was asked for.
237
+ */
238
+ setToken(result: ResultItem, kind?: 'token' | 'tokenVar'): void;
233
239
  setViewTransition(result: ResultItem): void;
234
240
  setPattern(name: string, result: ResultItem): void;
235
241
  setRecipe(recipeName: string, result: ResultItem): void;
package/dist/index.mjs CHANGED
@@ -64,7 +64,7 @@ function classifyProject(ctx, resultMap) {
64
64
  const { item, kind, filepath, localMaps } = opts;
65
65
  if (!item.box || box.isUnresolvable(item.box)) return;
66
66
  if (!item.data) return;
67
- if (item.type === "cva-call") return;
67
+ if (item.type === "cva-call" || item.type === "tokenVar") return;
68
68
  const componentReportItem = {
69
69
  componentIndex: String(componentIndex++),
70
70
  componentName: item.name,
@@ -961,8 +961,14 @@ var ParserResult = class {
961
961
  const unresolved = findUnresolvedRecipeStyles(result);
962
962
  if (unresolved.length) this.unresolved.push(...unresolved);
963
963
  }
964
- setToken(result) {
965
- this.token.add(this.append(Object.assign({ type: "token" }, result)));
964
+ /**
965
+ * `kind` separates `token()` from `token.var()`, which resolve to the value and to the
966
+ * variable reference respectively. They share this set deliberately: everything that reads
967
+ * a result for the token *path* — `collectTokenReferences`, keeping a declaration alive
968
+ * through pruning — wants both, and only the fold cares which half was asked for.
969
+ */
970
+ setToken(result, kind = "token") {
971
+ this.token.add(this.append(Object.assign({ type: kind }, result)));
966
972
  }
967
973
  setViewTransition(result) {
968
974
  this.viewTransition.add(this.append(Object.assign({ type: "viewTransition" }, result)));
@@ -1164,6 +1170,16 @@ function createParser(context) {
1164
1170
  });
1165
1171
  return;
1166
1172
  }
1173
+ if (file.isTokenVarFn(alias)) {
1174
+ result.queryList.forEach((query) => {
1175
+ if (query.kind === "call-expression") parserResult.setToken({
1176
+ name: "token.var",
1177
+ box: query.box.value[0] ?? box.fallback(query.box),
1178
+ data: combineResult(unbox(query.box.value[0]))
1179
+ }, "tokenVar");
1180
+ });
1181
+ return;
1182
+ }
1167
1183
  match(name).when(imports.matchers.css.match, (name) => {
1168
1184
  result.queryList.forEach((query) => {
1169
1185
  if (query.kind === "call-expression") if (query.box.value.length > 1) parserResult.set(name, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/parser",
3
- "version": "1.28.0",
3
+ "version": "1.28.1",
4
4
  "description": "The static parser for bamboo css",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -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.28.0",
38
- "@bamboocss/core": "^1.28.0",
39
- "@bamboocss/extractor": "1.28.0",
40
- "@bamboocss/logger": "1.28.0",
41
- "@bamboocss/shared": "1.28.0",
42
- "@bamboocss/types": "1.28.0"
37
+ "@bamboocss/extractor": "1.28.1",
38
+ "@bamboocss/core": "^1.28.1",
39
+ "@bamboocss/config": "^1.28.1",
40
+ "@bamboocss/logger": "1.28.1",
41
+ "@bamboocss/shared": "1.28.1",
42
+ "@bamboocss/types": "1.28.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@bamboocss/generator": "1.28.0",
46
- "@bamboocss/plugin-svelte": "1.28.0",
47
- "@bamboocss/plugin-vue": "1.28.0"
45
+ "@bamboocss/generator": "1.28.1",
46
+ "@bamboocss/plugin-svelte": "1.28.1",
47
+ "@bamboocss/plugin-vue": "1.28.1"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsdown src/index.ts --format=esm,cjs --dts",