@bamboocss/generator 1.58.1 → 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 +57 -17
- package/dist/index.d.cts +28 -3
- package/dist/index.d.mts +28 -3
- package/dist/index.mjs +58 -18
- package/package.json +7 -7
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);
|
|
@@ -3630,10 +3631,17 @@ var Generator = class extends _bamboocss_core.Context {
|
|
|
3630
3631
|
artifact: "styles.css",
|
|
3631
3632
|
content: css
|
|
3632
3633
|
}) ?? css;
|
|
3633
|
-
this.
|
|
3634
|
+
this.checkSheet(sheet);
|
|
3635
|
+
return css;
|
|
3636
|
+
};
|
|
3637
|
+
/**
|
|
3638
|
+
* What a finished sheet answers to, however it is written out: one file here, or one per layer
|
|
3639
|
+
* by `getSplitCssArtifacts`, which used to skip all three and ship what this refused.
|
|
3640
|
+
*/
|
|
3641
|
+
checkSheet = (sheet) => {
|
|
3642
|
+
this.assertNoUnresolvedTokens(sheet);
|
|
3634
3643
|
this.reportRawValues();
|
|
3635
3644
|
this.reportInvalidDeclarations(sheet);
|
|
3636
|
-
return css;
|
|
3637
3645
|
};
|
|
3638
3646
|
/**
|
|
3639
3647
|
* Fail on a style value shaped like a token path that names no token.
|
|
@@ -3675,6 +3683,12 @@ var Generator = class extends _bamboocss_core.Context {
|
|
|
3675
3683
|
* Both halves key on `property:path` with shorthands resolved, so a value that does reach
|
|
3676
3684
|
* both — every atomic style is transformed once before it is memoized — is one finding.
|
|
3677
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
|
+
*
|
|
3678
3692
|
* Here rather than beside the asserts in `BambooContext` because this is where the sheet
|
|
3679
3693
|
* exists: those all run during extraction, before anything has been decoded. Every path
|
|
3680
3694
|
* that emits css comes through `getCss`.
|
|
@@ -3724,28 +3738,53 @@ var Generator = class extends _bamboocss_core.Context {
|
|
|
3724
3738
|
};
|
|
3725
3739
|
/** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
|
|
3726
3740
|
reportedRawValues = /* @__PURE__ */ new Set();
|
|
3727
|
-
assertNoUnresolvedTokens = () => {
|
|
3741
|
+
assertNoUnresolvedTokens = (sheet) => {
|
|
3728
3742
|
const severity = this.utility.unresolvedToken;
|
|
3729
3743
|
if (severity.token !== "error" && severity.grammar !== "error") return;
|
|
3730
|
-
const found = new Map(this.utility.
|
|
3744
|
+
const found = new Map(this.utility.serializedUnresolvedTokens);
|
|
3745
|
+
if (sheet) for (const [id, ref] of sheet.unresolvedTokens) found.set(id, ref);
|
|
3746
|
+
for (const [id, ref] of this.recipes.inlineUnresolvedTokens()) found.set(id, ref);
|
|
3731
3747
|
for (const atom of this.decoder.atomic) {
|
|
3732
3748
|
const { prop, value } = atom.entry;
|
|
3733
3749
|
if (typeof value !== "string" || typeof prop !== "string") continue;
|
|
3734
|
-
|
|
3735
|
-
const key = this.utility.resolveShorthand(prop);
|
|
3736
|
-
const bare = this.utility.bareTokenPath(key, value);
|
|
3737
|
-
found.set(`${key}:${bare}`, this.utility.unresolvedTokenRef(key, bare));
|
|
3750
|
+
for (const [id, ref] of this.utility.findUnresolvedTokens(prop, value)) found.set(id, ref);
|
|
3738
3751
|
}
|
|
3739
3752
|
for (const [id, ref] of found) if (severity[ref.kind] !== "error") found.delete(id);
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
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"));
|
|
3747
3777
|
};
|
|
3748
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
|
+
/**
|
|
3749
3788
|
* The findings `warn` has already printed, keyed `property:value`.
|
|
3750
3789
|
*
|
|
3751
3790
|
* A dev server emits the sheet on every edit, and extraction is additive within a watch, so
|
|
@@ -3775,8 +3814,7 @@ var Generator = class extends _bamboocss_core.Context {
|
|
|
3775
3814
|
reportInvalidDeclarations = (sheet) => {
|
|
3776
3815
|
const severity = this.utility.invalidDeclaration;
|
|
3777
3816
|
if (severity === "off") return;
|
|
3778
|
-
const owned =
|
|
3779
|
-
for (const ref of this.utility.unresolvedTokens.values()) owned.add(`${this.utility.cssPropertyOf(ref.prop)}:${ref.value}`);
|
|
3817
|
+
const owned = this.utility.ownedDeclarations;
|
|
3780
3818
|
const id = (finding) => `${finding.prop}:${finding.value}`;
|
|
3781
3819
|
const findings = sheet.invalidDeclarations.filter((finding) => !owned.has(id(finding)));
|
|
3782
3820
|
if (!findings.length) return;
|
|
@@ -3813,6 +3851,8 @@ var Generator = class extends _bamboocss_core.Context {
|
|
|
3813
3851
|
* Used when --splitting flag is enabled
|
|
3814
3852
|
*/
|
|
3815
3853
|
getSplitCssArtifacts = (sheet) => {
|
|
3854
|
+
sheet.collectInvalidDeclarations();
|
|
3855
|
+
this.checkSheet(sheet);
|
|
3816
3856
|
const layerNames = this.config.layers;
|
|
3817
3857
|
const layers = [
|
|
3818
3858
|
{
|
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[];
|
|
@@ -139,6 +144,11 @@ declare class Generator extends Context {
|
|
|
139
144
|
*/
|
|
140
145
|
getAtomOrigins: () => Map<string, AtomOrigin>;
|
|
141
146
|
getCss: (stylesheet?: Stylesheet) => string;
|
|
147
|
+
/**
|
|
148
|
+
* What a finished sheet answers to, however it is written out: one file here, or one per layer
|
|
149
|
+
* by `getSplitCssArtifacts`, which used to skip all three and ship what this refused.
|
|
150
|
+
*/
|
|
151
|
+
private checkSheet;
|
|
142
152
|
/**
|
|
143
153
|
* Fail on a style value shaped like a token path that names no token.
|
|
144
154
|
*
|
|
@@ -179,6 +189,12 @@ declare class Generator extends Context {
|
|
|
179
189
|
* Both halves key on `property:path` with shorthands resolved, so a value that does reach
|
|
180
190
|
* both — every atomic style is transformed once before it is memoized — is one finding.
|
|
181
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
|
+
*
|
|
182
198
|
* Here rather than beside the asserts in `BambooContext` because this is where the sheet
|
|
183
199
|
* exists: those all run during extraction, before anything has been decoded. Every path
|
|
184
200
|
* that emits css comes through `getCss`.
|
|
@@ -200,7 +216,16 @@ declare class Generator extends Context {
|
|
|
200
216
|
reportRawValues: () => void;
|
|
201
217
|
/** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
|
|
202
218
|
private reportedRawValues;
|
|
203
|
-
assertNoUnresolvedTokens: () => void;
|
|
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[]>;
|
|
204
229
|
/**
|
|
205
230
|
* The findings `warn` has already printed, keyed `property:value`.
|
|
206
231
|
*
|
|
@@ -277,4 +302,4 @@ declare function getThemeCss(ctx: Context, themeName: string): string;
|
|
|
277
302
|
*/
|
|
278
303
|
declare function generatePackageExports(ctx: Context, base?: string): Record<string, unknown>;
|
|
279
304
|
//#endregion
|
|
280
|
-
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[];
|
|
@@ -139,6 +144,11 @@ declare class Generator extends Context {
|
|
|
139
144
|
*/
|
|
140
145
|
getAtomOrigins: () => Map<string, AtomOrigin>;
|
|
141
146
|
getCss: (stylesheet?: Stylesheet) => string;
|
|
147
|
+
/**
|
|
148
|
+
* What a finished sheet answers to, however it is written out: one file here, or one per layer
|
|
149
|
+
* by `getSplitCssArtifacts`, which used to skip all three and ship what this refused.
|
|
150
|
+
*/
|
|
151
|
+
private checkSheet;
|
|
142
152
|
/**
|
|
143
153
|
* Fail on a style value shaped like a token path that names no token.
|
|
144
154
|
*
|
|
@@ -179,6 +189,12 @@ declare class Generator extends Context {
|
|
|
179
189
|
* Both halves key on `property:path` with shorthands resolved, so a value that does reach
|
|
180
190
|
* both — every atomic style is transformed once before it is memoized — is one finding.
|
|
181
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
|
+
*
|
|
182
198
|
* Here rather than beside the asserts in `BambooContext` because this is where the sheet
|
|
183
199
|
* exists: those all run during extraction, before anything has been decoded. Every path
|
|
184
200
|
* that emits css comes through `getCss`.
|
|
@@ -200,7 +216,16 @@ declare class Generator extends Context {
|
|
|
200
216
|
reportRawValues: () => void;
|
|
201
217
|
/** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
|
|
202
218
|
private reportedRawValues;
|
|
203
|
-
assertNoUnresolvedTokens: () => void;
|
|
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[]>;
|
|
204
229
|
/**
|
|
205
230
|
* The findings `warn` has already printed, keyed `property:value`.
|
|
206
231
|
*
|
|
@@ -277,4 +302,4 @@ declare function getThemeCss(ctx: Context, themeName: string): string;
|
|
|
277
302
|
*/
|
|
278
303
|
declare function generatePackageExports(ctx: Context, base?: string): Record<string, unknown>;
|
|
279
304
|
//#endregion
|
|
280
|
-
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);
|
|
@@ -3604,10 +3605,17 @@ var Generator = class extends Context {
|
|
|
3604
3605
|
artifact: "styles.css",
|
|
3605
3606
|
content: css
|
|
3606
3607
|
}) ?? css;
|
|
3607
|
-
this.
|
|
3608
|
+
this.checkSheet(sheet);
|
|
3609
|
+
return css;
|
|
3610
|
+
};
|
|
3611
|
+
/**
|
|
3612
|
+
* What a finished sheet answers to, however it is written out: one file here, or one per layer
|
|
3613
|
+
* by `getSplitCssArtifacts`, which used to skip all three and ship what this refused.
|
|
3614
|
+
*/
|
|
3615
|
+
checkSheet = (sheet) => {
|
|
3616
|
+
this.assertNoUnresolvedTokens(sheet);
|
|
3608
3617
|
this.reportRawValues();
|
|
3609
3618
|
this.reportInvalidDeclarations(sheet);
|
|
3610
|
-
return css;
|
|
3611
3619
|
};
|
|
3612
3620
|
/**
|
|
3613
3621
|
* Fail on a style value shaped like a token path that names no token.
|
|
@@ -3649,6 +3657,12 @@ var Generator = class extends Context {
|
|
|
3649
3657
|
* Both halves key on `property:path` with shorthands resolved, so a value that does reach
|
|
3650
3658
|
* both — every atomic style is transformed once before it is memoized — is one finding.
|
|
3651
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
|
+
*
|
|
3652
3666
|
* Here rather than beside the asserts in `BambooContext` because this is where the sheet
|
|
3653
3667
|
* exists: those all run during extraction, before anything has been decoded. Every path
|
|
3654
3668
|
* that emits css comes through `getCss`.
|
|
@@ -3698,28 +3712,53 @@ var Generator = class extends Context {
|
|
|
3698
3712
|
};
|
|
3699
3713
|
/** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
|
|
3700
3714
|
reportedRawValues = /* @__PURE__ */ new Set();
|
|
3701
|
-
assertNoUnresolvedTokens = () => {
|
|
3715
|
+
assertNoUnresolvedTokens = (sheet) => {
|
|
3702
3716
|
const severity = this.utility.unresolvedToken;
|
|
3703
3717
|
if (severity.token !== "error" && severity.grammar !== "error") return;
|
|
3704
|
-
const found = new Map(this.utility.
|
|
3718
|
+
const found = new Map(this.utility.serializedUnresolvedTokens);
|
|
3719
|
+
if (sheet) for (const [id, ref] of sheet.unresolvedTokens) found.set(id, ref);
|
|
3720
|
+
for (const [id, ref] of this.recipes.inlineUnresolvedTokens()) found.set(id, ref);
|
|
3705
3721
|
for (const atom of this.decoder.atomic) {
|
|
3706
3722
|
const { prop, value } = atom.entry;
|
|
3707
3723
|
if (typeof value !== "string" || typeof prop !== "string") continue;
|
|
3708
|
-
|
|
3709
|
-
const key = this.utility.resolveShorthand(prop);
|
|
3710
|
-
const bare = this.utility.bareTokenPath(key, value);
|
|
3711
|
-
found.set(`${key}:${bare}`, this.utility.unresolvedTokenRef(key, bare));
|
|
3724
|
+
for (const [id, ref] of this.utility.findUnresolvedTokens(prop, value)) found.set(id, ref);
|
|
3712
3725
|
}
|
|
3713
3726
|
for (const [id, ref] of found) if (severity[ref.kind] !== "error") found.delete(id);
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
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"));
|
|
3721
3751
|
};
|
|
3722
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
|
+
/**
|
|
3723
3762
|
* The findings `warn` has already printed, keyed `property:value`.
|
|
3724
3763
|
*
|
|
3725
3764
|
* A dev server emits the sheet on every edit, and extraction is additive within a watch, so
|
|
@@ -3749,8 +3788,7 @@ var Generator = class extends Context {
|
|
|
3749
3788
|
reportInvalidDeclarations = (sheet) => {
|
|
3750
3789
|
const severity = this.utility.invalidDeclaration;
|
|
3751
3790
|
if (severity === "off") return;
|
|
3752
|
-
const owned =
|
|
3753
|
-
for (const ref of this.utility.unresolvedTokens.values()) owned.add(`${this.utility.cssPropertyOf(ref.prop)}:${ref.value}`);
|
|
3791
|
+
const owned = this.utility.ownedDeclarations;
|
|
3754
3792
|
const id = (finding) => `${finding.prop}:${finding.value}`;
|
|
3755
3793
|
const findings = sheet.invalidDeclarations.filter((finding) => !owned.has(id(finding)));
|
|
3756
3794
|
if (!findings.length) return;
|
|
@@ -3787,6 +3825,8 @@ var Generator = class extends Context {
|
|
|
3787
3825
|
* Used when --splitting flag is enabled
|
|
3788
3826
|
*/
|
|
3789
3827
|
getSplitCssArtifacts = (sheet) => {
|
|
3828
|
+
sheet.collectInvalidDeclarations();
|
|
3829
|
+
this.checkSheet(sheet);
|
|
3790
3830
|
const layerNames = this.config.layers;
|
|
3791
3831
|
const layers = [
|
|
3792
3832
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/generator",
|
|
3
|
-
"version": "1.58.
|
|
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.
|
|
42
|
-
"@bamboocss/is-valid-prop": "^1.58.
|
|
43
|
-
"@bamboocss/logger": "1.58.
|
|
44
|
-
"@bamboocss/shared": "1.58.
|
|
45
|
-
"@bamboocss/token-dictionary": "1.58.
|
|
46
|
-
"@bamboocss/types": "1.58.
|
|
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"
|