@bamboocss/parser 1.25.0 → 1.26.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 CHANGED
@@ -882,6 +882,27 @@ function createParser(context) {
882
882
  file.addLocalRecipe(declaration.name.text);
883
883
  }
884
884
  }
885
+ /**
886
+ * `css(recipe.raw(props), …)` loses what the recipe would have contributed.
887
+ *
888
+ * `.raw` on a recipe or pattern takes props and returns styles; the build reads it as the
889
+ * identity `css.raw` means. Resolving it properly would mean running the recipe here, and
890
+ * emitting the wrong styles is worse than emitting none — so this says so rather than
891
+ * guessing.
892
+ *
893
+ * Defined out here rather than inside `getEvaluateOptions`, which runs per call node.
894
+ */
895
+ const reportUnresolvedRaw = (base, at) => {
896
+ const { line, column } = sourceFile.getLineAndColumnAtPos(at.getStart());
897
+ parserResult.unresolved.push({
898
+ kind: "atomic",
899
+ prop: base,
900
+ filePath,
901
+ line,
902
+ column,
903
+ reason: "unresolved-raw"
904
+ });
905
+ };
885
906
  (0, _bamboocss_extractor.extract)({
886
907
  ast: sourceFile,
887
908
  tokens: context.tokens ? {
@@ -920,8 +941,14 @@ function createParser(context) {
920
941
  }
921
942
  if (!ts_morph.Node.isPropertyAccessExpression(propAccessExpr)) return evaluateOptions;
922
943
  let name = propAccessExpr.getText();
944
+ const rawBase = name.endsWith(".raw") ? name.slice(0, -4) : void 0;
945
+ if (rawBase && file.isLocalRecipe(rawBase)) {
946
+ reportUnresolvedRaw(rawBase, node);
947
+ return evaluateOptions;
948
+ }
923
949
  if (!file.isRawFn(name)) return evaluateOptions;
924
950
  name = name.replace(".raw", "");
951
+ if (file.isValidRecipe(name) || file.isValidPattern(name)) reportUnresolvedRaw(name, node);
925
952
  return { environment: Object.assign({}, defaultEnv, { extra: { [name]: { raw: (v) => v } } }) };
926
953
  },
927
954
  flags: { skipTraverseFiles: false }
package/dist/index.d.cts CHANGED
@@ -162,7 +162,17 @@ interface UnresolvedStyle {
162
162
  * pair of alternatives.
163
163
  * - `too-many-combinations` — more ternary branches than it will enumerate.
164
164
  */
165
- reason: 'unresolvable-value' | 'missing-property' | 'unenumerable-keys';
165
+ reason: 'unresolvable-value' | 'missing-property' | 'unenumerable-keys'
166
+ /**
167
+ * `css(recipe.raw(props), …)` — the build reads `.raw` as returning what it was passed.
168
+ *
169
+ * True of `css.raw`, which is the identity it was written for. A recipe or pattern's
170
+ * `.raw` takes *props* and returns *styles*, so the build composes the props instead: the
171
+ * recipe's own declarations never reach the stylesheet, and its variant names are handed
172
+ * to the encoder as if they were properties. The browser then asks for classes no rule
173
+ * backs, and the element renders without them.
174
+ */
175
+ | 'unresolved-raw';
166
176
  }
167
177
  declare const findUnresolvedStyles: (item: ResultItem, kind: "atomic") => UnresolvedStyle[];
168
178
  //#endregion
package/dist/index.d.mts CHANGED
@@ -162,7 +162,17 @@ interface UnresolvedStyle {
162
162
  * pair of alternatives.
163
163
  * - `too-many-combinations` — more ternary branches than it will enumerate.
164
164
  */
165
- reason: 'unresolvable-value' | 'missing-property' | 'unenumerable-keys';
165
+ reason: 'unresolvable-value' | 'missing-property' | 'unenumerable-keys'
166
+ /**
167
+ * `css(recipe.raw(props), …)` — the build reads `.raw` as returning what it was passed.
168
+ *
169
+ * True of `css.raw`, which is the identity it was written for. A recipe or pattern's
170
+ * `.raw` takes *props* and returns *styles*, so the build composes the props instead: the
171
+ * recipe's own declarations never reach the stylesheet, and its variant names are handed
172
+ * to the encoder as if they were properties. The browser then asks for classes no rule
173
+ * backs, and the element renders without them.
174
+ */
175
+ | 'unresolved-raw';
166
176
  }
167
177
  declare const findUnresolvedStyles: (item: ResultItem, kind: "atomic") => UnresolvedStyle[];
168
178
  //#endregion
package/dist/index.mjs CHANGED
@@ -881,6 +881,27 @@ function createParser(context) {
881
881
  file.addLocalRecipe(declaration.name.text);
882
882
  }
883
883
  }
884
+ /**
885
+ * `css(recipe.raw(props), …)` loses what the recipe would have contributed.
886
+ *
887
+ * `.raw` on a recipe or pattern takes props and returns styles; the build reads it as the
888
+ * identity `css.raw` means. Resolving it properly would mean running the recipe here, and
889
+ * emitting the wrong styles is worse than emitting none — so this says so rather than
890
+ * guessing.
891
+ *
892
+ * Defined out here rather than inside `getEvaluateOptions`, which runs per call node.
893
+ */
894
+ const reportUnresolvedRaw = (base, at) => {
895
+ const { line, column } = sourceFile.getLineAndColumnAtPos(at.getStart());
896
+ parserResult.unresolved.push({
897
+ kind: "atomic",
898
+ prop: base,
899
+ filePath,
900
+ line,
901
+ column,
902
+ reason: "unresolved-raw"
903
+ });
904
+ };
884
905
  extract({
885
906
  ast: sourceFile,
886
907
  tokens: context.tokens ? {
@@ -919,8 +940,14 @@ function createParser(context) {
919
940
  }
920
941
  if (!Node.isPropertyAccessExpression(propAccessExpr)) return evaluateOptions;
921
942
  let name = propAccessExpr.getText();
943
+ const rawBase = name.endsWith(".raw") ? name.slice(0, -4) : void 0;
944
+ if (rawBase && file.isLocalRecipe(rawBase)) {
945
+ reportUnresolvedRaw(rawBase, node);
946
+ return evaluateOptions;
947
+ }
922
948
  if (!file.isRawFn(name)) return evaluateOptions;
923
949
  name = name.replace(".raw", "");
950
+ if (file.isValidRecipe(name) || file.isValidPattern(name)) reportUnresolvedRaw(name, node);
924
951
  return { environment: Object.assign({}, defaultEnv, { extra: { [name]: { raw: (v) => v } } }) };
925
952
  },
926
953
  flags: { skipTraverseFiles: false }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/parser",
3
- "version": "1.25.0",
3
+ "version": "1.26.0",
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.25.0",
38
- "@bamboocss/core": "^1.25.0",
39
- "@bamboocss/extractor": "1.25.0",
40
- "@bamboocss/logger": "1.25.0",
41
- "@bamboocss/shared": "1.25.0",
42
- "@bamboocss/types": "1.25.0"
37
+ "@bamboocss/config": "^1.26.0",
38
+ "@bamboocss/core": "^1.26.0",
39
+ "@bamboocss/extractor": "1.26.0",
40
+ "@bamboocss/logger": "1.26.0",
41
+ "@bamboocss/shared": "1.26.0",
42
+ "@bamboocss/types": "1.26.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@bamboocss/generator": "1.25.0",
46
- "@bamboocss/plugin-svelte": "1.25.0",
47
- "@bamboocss/plugin-vue": "1.25.0"
45
+ "@bamboocss/generator": "1.26.0",
46
+ "@bamboocss/plugin-svelte": "1.26.0",
47
+ "@bamboocss/plugin-vue": "1.26.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsdown src/index.ts --format=esm,cjs --dts",