@bamboocss/generator 1.58.2 → 1.58.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/index.cjs CHANGED
@@ -3387,6 +3387,7 @@ const generateSemanticTokensSpec = (ctx) => {
3387
3387
  };
3388
3388
  //#endregion
3389
3389
  //#region src/generator.ts
3390
+ const NO_CALLS = [];
3390
3391
  var Generator = class extends _bamboocss_core.Context {
3391
3392
  constructor(conf) {
3392
3393
  super(conf);
@@ -3682,6 +3683,12 @@ var Generator = class extends _bamboocss_core.Context {
3682
3683
  * Both halves key on `property:path` with shorthands resolved, so a value that does reach
3683
3684
  * both — every atomic style is transformed once before it is memoized — is one finding.
3684
3685
  *
3686
+ * **A `token()` call naming no token is in neither.** The build evaluates it to `undefined`, as
3687
+ * the runtime would, so the property it was written into is dropped before anything is encoded
3688
+ * and no atom holds the mistake. Extraction records it by file instead — see
3689
+ * `unresolvedTokenCalls` — and it is reported here, beside the values, so one build names every
3690
+ * missing token however it was asked for.
3691
+ *
3685
3692
  * Here rather than beside the asserts in `BambooContext` because this is where the sheet
3686
3693
  * exists: those all run during extraction, before anything has been decoded. Every path
3687
3694
  * that emits css comes through `getCss`.
@@ -3743,15 +3750,41 @@ var Generator = class extends _bamboocss_core.Context {
3743
3750
  for (const [id, ref] of this.utility.findUnresolvedTokens(prop, value)) found.set(id, ref);
3744
3751
  }
3745
3752
  for (const [id, ref] of found) if (severity[ref.kind] !== "error") found.delete(id);
3746
- if (!found.size) return;
3747
- const detail = (0, _bamboocss_shared.truncateList)(Array.from(found.values(), (ref) => `- ${this.utility.explainUnresolvedToken(ref)}`), {
3748
- limit: 25,
3749
- unit: "value",
3750
- separator: "\n"
3751
- });
3752
- throw new _bamboocss_shared.BambooError("UNRESOLVED_TOKEN", `${found.size} style value(s) name a token that does not exist:\n\n${detail}\n\nEach is emitted as written, which parses — so the stylesheet is valid and nothing downstream objects. The browser drops the declaration at compute time and the style is simply absent from the element, which surfaces as "this never applied" a long way from the typo that caused it. Write \`[value]\` to mark a bare value as a literal, or set \`unresolvedToken: 'warn'\` to report these without failing.`);
3753
+ const calls = severity.token === "error" && this.unresolvedTokenCalls.size ? Array.from(this.unresolvedTokenCalls.values()).flat() : NO_CALLS;
3754
+ if (!found.size && !calls.length) return;
3755
+ const sections = [];
3756
+ if (found.size) {
3757
+ const detail = (0, _bamboocss_shared.truncateList)(Array.from(found.values(), (ref) => `- ${this.utility.explainUnresolvedToken(ref)}`), {
3758
+ limit: 25,
3759
+ unit: "value",
3760
+ separator: "\n"
3761
+ });
3762
+ sections.push(`${found.size} style value(s) name a token that does not exist:\n\n${detail}\n\nEach is emitted as written, which parses — so the stylesheet is valid and nothing downstream objects. The browser drops the declaration at compute time and the style is simply absent from the element, which surfaces as "this never applied" a long way from the typo that caused it. Write \`[value]\` to mark a bare value as a literal, or set \`unresolvedToken: 'warn'\` to report these without failing.`);
3763
+ }
3764
+ if (calls.length) {
3765
+ const detail = (0, _bamboocss_shared.truncateList)(Array.from((0, _bamboocss_shared.groupBy)(calls, ({ call }) => `${call.method}\0${call.path}`), ([, sites]) => {
3766
+ const shown = sites.slice(0, 3).map(({ where }) => where);
3767
+ const rest = sites.length > 3 ? ` and ${sites.length - 3} more` : "";
3768
+ return `- ${this.utility.explainUnresolvedTokenCall(sites[0].call)} At ${shown.join(", ")}${rest}.`;
3769
+ }), {
3770
+ limit: 25,
3771
+ unit: "path",
3772
+ separator: "\n"
3773
+ });
3774
+ sections.push(`${calls.length} \`token()\` call(s) name a token that does not exist:\n\n${detail}\n\nA call naming no token returns \`undefined\`, and the build reads it the same way: a style property it was written into is left out, so no rule is emitted for it and nothing in the browser says why. Set \`unresolvedToken: 'warn'\` to report these without failing.`);
3775
+ }
3776
+ throw new _bamboocss_shared.BambooError("UNRESOLVED_TOKEN", sections.join("\n\n"));
3753
3777
  };
3754
3778
  /**
3779
+ * Every `token()` call extraction found naming no token, by the file it is in.
3780
+ *
3781
+ * Filled by extraction (`BambooContext.parseFile`), which is the only place a call is seen: the
3782
+ * property it was written into is dropped before anything reaches the sheet, so there is no atom
3783
+ * to read the mistake off, and its file is where it lives. Each file's entry is replaced
3784
+ * whenever the file is read again and dropped when it goes, so a fix takes on the next pass.
3785
+ */
3786
+ unresolvedTokenCalls = /* @__PURE__ */ new Map();
3787
+ /**
3755
3788
  * The findings `warn` has already printed, keyed `property:value`.
3756
3789
  *
3757
3790
  * A dev server emits the sheet on every edit, and extraction is additive within a watch, so
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AtomOrigin, Context, StyleDecoder, Stylesheet } from "@bamboocss/core";
1
+ import { AtomOrigin, Context, StyleDecoder, Stylesheet, UnresolvedTokenCall } from "@bamboocss/core";
2
2
  import { ArtifactId, CssArtifactType, LoadConfigResult, SpecFile, SpecType, SpecTypeMap } from "@bamboocss/types";
3
3
 
4
4
  //#region src/generator.d.ts
@@ -18,6 +18,11 @@ interface SplitCssResult {
18
18
  /** Content for main styles.css */
19
19
  index: string;
20
20
  }
21
+ /** A `token()` call naming no token, and where it is as the build prints it: `src/card.tsx:12:5`. */
22
+ interface UnresolvedTokenCallSite {
23
+ call: UnresolvedTokenCall;
24
+ where: string;
25
+ }
21
26
  declare class Generator extends Context {
22
27
  constructor(conf: LoadConfigResult);
23
28
  getArtifacts: (ids?: ArtifactId[] | undefined) => import("@bamboocss/types").Artifact[];
@@ -184,6 +189,12 @@ declare class Generator extends Context {
184
189
  * Both halves key on `property:path` with shorthands resolved, so a value that does reach
185
190
  * both — every atomic style is transformed once before it is memoized — is one finding.
186
191
  *
192
+ * **A `token()` call naming no token is in neither.** The build evaluates it to `undefined`, as
193
+ * the runtime would, so the property it was written into is dropped before anything is encoded
194
+ * and no atom holds the mistake. Extraction records it by file instead — see
195
+ * `unresolvedTokenCalls` — and it is reported here, beside the values, so one build names every
196
+ * missing token however it was asked for.
197
+ *
187
198
  * Here rather than beside the asserts in `BambooContext` because this is where the sheet
188
199
  * exists: those all run during extraction, before anything has been decoded. Every path
189
200
  * that emits css comes through `getCss`.
@@ -206,6 +217,15 @@ declare class Generator extends Context {
206
217
  /** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
207
218
  private reportedRawValues;
208
219
  assertNoUnresolvedTokens: (sheet?: Stylesheet) => void;
220
+ /**
221
+ * Every `token()` call extraction found naming no token, by the file it is in.
222
+ *
223
+ * Filled by extraction (`BambooContext.parseFile`), which is the only place a call is seen: the
224
+ * property it was written into is dropped before anything reaches the sheet, so there is no atom
225
+ * to read the mistake off, and its file is where it lives. Each file's entry is replaced
226
+ * whenever the file is read again and dropped when it goes, so a fix takes on the next pass.
227
+ */
228
+ unresolvedTokenCalls: Map<string, UnresolvedTokenCallSite[]>;
209
229
  /**
210
230
  * The findings `warn` has already printed, keyed `property:value`.
211
231
  *
@@ -282,4 +302,4 @@ declare function getThemeCss(ctx: Context, themeName: string): string;
282
302
  */
283
303
  declare function generatePackageExports(ctx: Context, base?: string): Record<string, unknown>;
284
304
  //#endregion
285
- export { Generator, SplitCssArtifact, SplitCssResult, generatePackageExports, getThemeCss };
305
+ export { Generator, SplitCssArtifact, SplitCssResult, UnresolvedTokenCallSite, generatePackageExports, getThemeCss };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AtomOrigin, Context, StyleDecoder, Stylesheet } from "@bamboocss/core";
1
+ import { AtomOrigin, Context, StyleDecoder, Stylesheet, UnresolvedTokenCall } from "@bamboocss/core";
2
2
  import { ArtifactId, CssArtifactType, LoadConfigResult, SpecFile, SpecType, SpecTypeMap } from "@bamboocss/types";
3
3
 
4
4
  //#region src/generator.d.ts
@@ -18,6 +18,11 @@ interface SplitCssResult {
18
18
  /** Content for main styles.css */
19
19
  index: string;
20
20
  }
21
+ /** A `token()` call naming no token, and where it is as the build prints it: `src/card.tsx:12:5`. */
22
+ interface UnresolvedTokenCallSite {
23
+ call: UnresolvedTokenCall;
24
+ where: string;
25
+ }
21
26
  declare class Generator extends Context {
22
27
  constructor(conf: LoadConfigResult);
23
28
  getArtifacts: (ids?: ArtifactId[] | undefined) => import("@bamboocss/types").Artifact[];
@@ -184,6 +189,12 @@ declare class Generator extends Context {
184
189
  * Both halves key on `property:path` with shorthands resolved, so a value that does reach
185
190
  * both — every atomic style is transformed once before it is memoized — is one finding.
186
191
  *
192
+ * **A `token()` call naming no token is in neither.** The build evaluates it to `undefined`, as
193
+ * the runtime would, so the property it was written into is dropped before anything is encoded
194
+ * and no atom holds the mistake. Extraction records it by file instead — see
195
+ * `unresolvedTokenCalls` — and it is reported here, beside the values, so one build names every
196
+ * missing token however it was asked for.
197
+ *
187
198
  * Here rather than beside the asserts in `BambooContext` because this is where the sheet
188
199
  * exists: those all run during extraction, before anything has been decoded. Every path
189
200
  * that emits css comes through `getCss`.
@@ -206,6 +217,15 @@ declare class Generator extends Context {
206
217
  /** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
207
218
  private reportedRawValues;
208
219
  assertNoUnresolvedTokens: (sheet?: Stylesheet) => void;
220
+ /**
221
+ * Every `token()` call extraction found naming no token, by the file it is in.
222
+ *
223
+ * Filled by extraction (`BambooContext.parseFile`), which is the only place a call is seen: the
224
+ * property it was written into is dropped before anything reaches the sheet, so there is no atom
225
+ * to read the mistake off, and its file is where it lives. Each file's entry is replaced
226
+ * whenever the file is read again and dropped when it goes, so a fix takes on the next pass.
227
+ */
228
+ unresolvedTokenCalls: Map<string, UnresolvedTokenCallSite[]>;
209
229
  /**
210
230
  * The findings `warn` has already printed, keyed `property:value`.
211
231
  *
@@ -282,4 +302,4 @@ declare function getThemeCss(ctx: Context, themeName: string): string;
282
302
  */
283
303
  declare function generatePackageExports(ctx: Context, base?: string): Record<string, unknown>;
284
304
  //#endregion
285
- export { Generator, SplitCssArtifact, SplitCssResult, generatePackageExports, getThemeCss };
305
+ export { Generator, SplitCssArtifact, SplitCssResult, UnresolvedTokenCallSite, generatePackageExports, getThemeCss };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Context, Recipes, expandNestedCss, extractParentSelectors, extractTrailingPseudos, isCompound, nestingParent, pruneKeyframes, prunePreflight, pruneTokenVars, prunesPreflight, splitSelectors, stringify, withoutFirstParent, withoutParents } from "@bamboocss/core";
2
2
  import { logger } from "@bamboocss/logger";
3
- import { BambooError, capitalize, compact, cssVarRefs, dashCase, isBoolean, isObject, mapEntries, truncateList, unionType, walkObject } from "@bamboocss/shared";
3
+ import { BambooError, capitalize, compact, cssVarRefs, dashCase, groupBy, isBoolean, isObject, mapEntries, truncateList, unionType, walkObject } from "@bamboocss/shared";
4
4
  import { match } from "ts-pattern";
5
5
  import outdent$1, { outdent } from "outdent";
6
6
  import { stringify as stringify$1 } from "javascript-stringify";
@@ -3361,6 +3361,7 @@ const generateSemanticTokensSpec = (ctx) => {
3361
3361
  };
3362
3362
  //#endregion
3363
3363
  //#region src/generator.ts
3364
+ const NO_CALLS = [];
3364
3365
  var Generator = class extends Context {
3365
3366
  constructor(conf) {
3366
3367
  super(conf);
@@ -3656,6 +3657,12 @@ var Generator = class extends Context {
3656
3657
  * Both halves key on `property:path` with shorthands resolved, so a value that does reach
3657
3658
  * both — every atomic style is transformed once before it is memoized — is one finding.
3658
3659
  *
3660
+ * **A `token()` call naming no token is in neither.** The build evaluates it to `undefined`, as
3661
+ * the runtime would, so the property it was written into is dropped before anything is encoded
3662
+ * and no atom holds the mistake. Extraction records it by file instead — see
3663
+ * `unresolvedTokenCalls` — and it is reported here, beside the values, so one build names every
3664
+ * missing token however it was asked for.
3665
+ *
3659
3666
  * Here rather than beside the asserts in `BambooContext` because this is where the sheet
3660
3667
  * exists: those all run during extraction, before anything has been decoded. Every path
3661
3668
  * that emits css comes through `getCss`.
@@ -3717,15 +3724,41 @@ var Generator = class extends Context {
3717
3724
  for (const [id, ref] of this.utility.findUnresolvedTokens(prop, value)) found.set(id, ref);
3718
3725
  }
3719
3726
  for (const [id, ref] of found) if (severity[ref.kind] !== "error") found.delete(id);
3720
- if (!found.size) return;
3721
- const detail = truncateList(Array.from(found.values(), (ref) => `- ${this.utility.explainUnresolvedToken(ref)}`), {
3722
- limit: 25,
3723
- unit: "value",
3724
- separator: "\n"
3725
- });
3726
- throw new BambooError("UNRESOLVED_TOKEN", `${found.size} style value(s) name a token that does not exist:\n\n${detail}\n\nEach is emitted as written, which parses — so the stylesheet is valid and nothing downstream objects. The browser drops the declaration at compute time and the style is simply absent from the element, which surfaces as "this never applied" a long way from the typo that caused it. Write \`[value]\` to mark a bare value as a literal, or set \`unresolvedToken: 'warn'\` to report these without failing.`);
3727
+ const calls = severity.token === "error" && this.unresolvedTokenCalls.size ? Array.from(this.unresolvedTokenCalls.values()).flat() : NO_CALLS;
3728
+ if (!found.size && !calls.length) return;
3729
+ const sections = [];
3730
+ if (found.size) {
3731
+ const detail = truncateList(Array.from(found.values(), (ref) => `- ${this.utility.explainUnresolvedToken(ref)}`), {
3732
+ limit: 25,
3733
+ unit: "value",
3734
+ separator: "\n"
3735
+ });
3736
+ sections.push(`${found.size} style value(s) name a token that does not exist:\n\n${detail}\n\nEach is emitted as written, which parses — so the stylesheet is valid and nothing downstream objects. The browser drops the declaration at compute time and the style is simply absent from the element, which surfaces as "this never applied" a long way from the typo that caused it. Write \`[value]\` to mark a bare value as a literal, or set \`unresolvedToken: 'warn'\` to report these without failing.`);
3737
+ }
3738
+ if (calls.length) {
3739
+ const detail = truncateList(Array.from(groupBy(calls, ({ call }) => `${call.method}\0${call.path}`), ([, sites]) => {
3740
+ const shown = sites.slice(0, 3).map(({ where }) => where);
3741
+ const rest = sites.length > 3 ? ` and ${sites.length - 3} more` : "";
3742
+ return `- ${this.utility.explainUnresolvedTokenCall(sites[0].call)} At ${shown.join(", ")}${rest}.`;
3743
+ }), {
3744
+ limit: 25,
3745
+ unit: "path",
3746
+ separator: "\n"
3747
+ });
3748
+ sections.push(`${calls.length} \`token()\` call(s) name a token that does not exist:\n\n${detail}\n\nA call naming no token returns \`undefined\`, and the build reads it the same way: a style property it was written into is left out, so no rule is emitted for it and nothing in the browser says why. Set \`unresolvedToken: 'warn'\` to report these without failing.`);
3749
+ }
3750
+ throw new BambooError("UNRESOLVED_TOKEN", sections.join("\n\n"));
3727
3751
  };
3728
3752
  /**
3753
+ * Every `token()` call extraction found naming no token, by the file it is in.
3754
+ *
3755
+ * Filled by extraction (`BambooContext.parseFile`), which is the only place a call is seen: the
3756
+ * property it was written into is dropped before anything reaches the sheet, so there is no atom
3757
+ * to read the mistake off, and its file is where it lives. Each file's entry is replaced
3758
+ * whenever the file is read again and dropped when it goes, so a fix takes on the next pass.
3759
+ */
3760
+ unresolvedTokenCalls = /* @__PURE__ */ new Map();
3761
+ /**
3729
3762
  * The findings `warn` has already printed, keyed `property:value`.
3730
3763
  *
3731
3764
  * A dev server emits the sheet on every edit, and extraction is additive within a watch, so
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/generator",
3
- "version": "1.58.2",
3
+ "version": "1.58.3",
4
4
  "description": "The css generator for css bamboo",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -38,12 +38,12 @@
38
38
  "pluralize": "8.0.0",
39
39
  "postcss": "8.5.26",
40
40
  "ts-pattern": "5.9.0",
41
- "@bamboocss/core": "1.58.2",
42
- "@bamboocss/is-valid-prop": "^1.58.2",
43
- "@bamboocss/logger": "1.58.2",
44
- "@bamboocss/shared": "1.58.2",
45
- "@bamboocss/token-dictionary": "1.58.2",
46
- "@bamboocss/types": "1.58.2"
41
+ "@bamboocss/core": "1.58.3",
42
+ "@bamboocss/is-valid-prop": "^1.58.3",
43
+ "@bamboocss/logger": "1.58.3",
44
+ "@bamboocss/shared": "1.58.3",
45
+ "@bamboocss/token-dictionary": "1.58.3",
46
+ "@bamboocss/types": "1.58.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/pluralize": "0.0.33"