@bamboocss/node 1.58.2 → 1.58.4
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 +65 -2
- package/dist/index.d.cts +44 -1
- package/dist/index.d.mts +44 -1
- package/dist/index.mjs +65 -2
- package/dist/native/darwin-arm64.node +0 -0
- package/dist/native/darwin-x64.node +0 -0
- package/dist/native/linux-arm64-gnu.node +0 -0
- package/dist/native/linux-x64-gnu.node +0 -0
- package/dist/native/win32-x64-msvc.node +0 -0
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -3021,6 +3021,14 @@ var ParserResult = class {
|
|
|
3021
3021
|
*/
|
|
3022
3022
|
deadCalls = [];
|
|
3023
3023
|
/**
|
|
3024
|
+
* `token()` and `token.value()` calls naming no token.
|
|
3025
|
+
*
|
|
3026
|
+
* Each returns `undefined`, so a property it was written into never reaches the encoder and
|
|
3027
|
+
* nothing else records it. Graded by the token half of `unresolvedToken` — see
|
|
3028
|
+
* `Generator.unresolvedTokenCalls` for where they are reported.
|
|
3029
|
+
*/
|
|
3030
|
+
unresolvedTokenCalls = [];
|
|
3031
|
+
/**
|
|
3024
3032
|
* Whether each result item is attributed to its call site, for a source map.
|
|
3025
3033
|
*
|
|
3026
3034
|
* Off for a source a `parser:before` hook rewrote: its positions are the hook's output's,
|
|
@@ -4341,6 +4349,7 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
4341
4349
|
this.nativeConfigurationFiles.delete(file);
|
|
4342
4350
|
this.nativeExtractions.delete(file);
|
|
4343
4351
|
this.nativeSourceMetadata.delete(file);
|
|
4352
|
+
this.unresolvedTokenCalls.delete(this.runtime.path.abs(this.config.cwd, filePath));
|
|
4344
4353
|
};
|
|
4345
4354
|
parseNativeFile = (filePath, native, encoder) => {
|
|
4346
4355
|
if (native.errors.length) throw new _bamboocss_shared.BambooError("NATIVE_EXTRACTION", `Native extraction failed for ${filePath}:\n${native.errors.join("\n")}`);
|
|
@@ -4351,6 +4360,7 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
4351
4360
|
for (const dependency of native.dependencies) result.addDependency(dependency);
|
|
4352
4361
|
const metadata = this.nativeSourceMetadata.get(filePath.replaceAll("\\", "/"));
|
|
4353
4362
|
result.origins = metadata?.origins ?? true;
|
|
4363
|
+
let tokenTable;
|
|
4354
4364
|
for (const call of native.calls) {
|
|
4355
4365
|
const atomOrigin = encoder.recordOrigins && result.origins ? {
|
|
4356
4366
|
filePath,
|
|
@@ -4409,8 +4419,24 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
4409
4419
|
});
|
|
4410
4420
|
else if (call.kind === "pattern") result.setPattern(call.importedName, item);
|
|
4411
4421
|
else if (call.kind === "recipe") result.setRecipe(call.importedName, item, new Set(call.unresolvedKeys));
|
|
4412
|
-
else if (call.kind === "token" || call.kind === "tokenValue")
|
|
4413
|
-
|
|
4422
|
+
else if (call.kind === "token" || call.kind === "tokenValue") {
|
|
4423
|
+
result.setToken(item, call.kind);
|
|
4424
|
+
if (call.complete && !call.guarded) {
|
|
4425
|
+
tokenTable ??= this.tokens.view.values;
|
|
4426
|
+
for (let index = 0; index < call.arguments.length; index++) {
|
|
4427
|
+
const path = call.arguments[index];
|
|
4428
|
+
if (typeof path !== "string" || tokenTable.has(path)) continue;
|
|
4429
|
+
if (call.arguments.indexOf(path) !== index) continue;
|
|
4430
|
+
const unresolved = this.utility.unresolvedTokenCall(call.kind === "token" ? "token" : "token.value", path);
|
|
4431
|
+
if (unresolved) result.unresolvedTokenCalls.push({
|
|
4432
|
+
call: unresolved,
|
|
4433
|
+
filePath,
|
|
4434
|
+
line: call.line,
|
|
4435
|
+
column: call.column
|
|
4436
|
+
});
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4439
|
+
} else if (call.kind === "dead") result.deadCalls.push({
|
|
4414
4440
|
name: call.importedName,
|
|
4415
4441
|
alias: call.name,
|
|
4416
4442
|
mod: call.module,
|
|
@@ -4439,6 +4465,7 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
4439
4465
|
encoder.releaseFile(file);
|
|
4440
4466
|
this.parseFailures.delete(file);
|
|
4441
4467
|
this.deadCalls.delete(file);
|
|
4468
|
+
this.unresolvedTokenCalls.delete(file);
|
|
4442
4469
|
measure();
|
|
4443
4470
|
return;
|
|
4444
4471
|
}
|
|
@@ -4458,11 +4485,45 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
4458
4485
|
this.reportUnresolvedStyles(result);
|
|
4459
4486
|
if (result.deadCalls.length) this.deadCalls.set(file, result.deadCalls);
|
|
4460
4487
|
else this.deadCalls.delete(file);
|
|
4488
|
+
this.recordUnresolvedTokenCalls(file, result);
|
|
4461
4489
|
}
|
|
4462
4490
|
measure();
|
|
4463
4491
|
return result;
|
|
4464
4492
|
};
|
|
4465
4493
|
/**
|
|
4494
|
+
* Keep a file's `token()` calls naming no token for the sheet's check, and warn about them when
|
|
4495
|
+
* the token half of `unresolvedToken` is `warn`.
|
|
4496
|
+
*
|
|
4497
|
+
* Set or deleted on every parse, like `deadCalls` and for the same reason: a file read again
|
|
4498
|
+
* without them has fixed them, and an entry outliving the fix would fail every later build. A
|
|
4499
|
+
* file under `outdir` is left out, as `reportUnresolvedStyles` leaves it: nothing there is the
|
|
4500
|
+
* author's to rewrite.
|
|
4501
|
+
*/
|
|
4502
|
+
recordUnresolvedTokenCalls = (file, result) => {
|
|
4503
|
+
const found = this.isGenerated(file) ? [] : result.unresolvedTokenCalls;
|
|
4504
|
+
if (!found.length) {
|
|
4505
|
+
this.unresolvedTokenCalls.delete(file);
|
|
4506
|
+
return;
|
|
4507
|
+
}
|
|
4508
|
+
const sites = found.map(({ call, line, column }) => ({
|
|
4509
|
+
call,
|
|
4510
|
+
where: `${this.relative(file)}:${line}:${column}`
|
|
4511
|
+
}));
|
|
4512
|
+
this.unresolvedTokenCalls.set(file, sites);
|
|
4513
|
+
if (this.utility.unresolvedToken.token !== "warn") return;
|
|
4514
|
+
for (const { call, where } of sites) _bamboocss_logger.logger.warn("token", `${where} — ${this.utility.explainUnresolvedTokenCall(call)}`);
|
|
4515
|
+
};
|
|
4516
|
+
/**
|
|
4517
|
+
* Drop the `token()` call findings of every file outside `files`, as `assertNoDeadCalls` drops
|
|
4518
|
+
* its own: one deleted or taken out of `include` is not parsed again, so its entry would fail
|
|
4519
|
+
* every later sheet, naming a file that is no longer part of the build.
|
|
4520
|
+
*/
|
|
4521
|
+
forgetUnresolvedTokenCallsOutside = (files) => {
|
|
4522
|
+
if (!this.unresolvedTokenCalls.size) return;
|
|
4523
|
+
const inScope = new Set(Array.from(files, (file) => this.runtime.path.abs(this.config.cwd, file)));
|
|
4524
|
+
for (const file of this.unresolvedTokenCalls.keys()) if (!inScope.has(file)) this.unresolvedTokenCalls.delete(file);
|
|
4525
|
+
};
|
|
4526
|
+
/**
|
|
4466
4527
|
* Extract every file in one pass, and fail on the ones that could not be read.
|
|
4467
4528
|
*
|
|
4468
4529
|
* Routed through `parseFile` rather than parsing directly, so the two entry points cannot
|
|
@@ -4531,6 +4592,7 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
4531
4592
|
if (encoder.isEmpty()) return;
|
|
4532
4593
|
filesWithCss.push(file);
|
|
4533
4594
|
});
|
|
4595
|
+
this.forgetUnresolvedTokenCallsOutside(files);
|
|
4534
4596
|
this.assertExtracted(files);
|
|
4535
4597
|
this.assertNoDeadCalls(files);
|
|
4536
4598
|
return {
|
|
@@ -6045,6 +6107,7 @@ var Builder = class {
|
|
|
6045
6107
|
this.snapshotResolutionConfigurations();
|
|
6046
6108
|
this.affectedFiles = void 0;
|
|
6047
6109
|
this.extractionOrder = void 0;
|
|
6110
|
+
ctx.forgetUnresolvedTokenCallsOutside(files);
|
|
6048
6111
|
ctx.assertExtracted(files);
|
|
6049
6112
|
ctx.assertNoDeadCalls(files);
|
|
6050
6113
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as markStaticCompilerActive, t as isStaticCompilerActive } from "./static-compiler-C1QNL5nu.cjs";
|
|
2
2
|
import { ReportFormat } from "@bamboocss/reporter";
|
|
3
3
|
import { AnalysisOptions, Artifact, ArtifactId, BambooHooks, Config, CssArtifactType, DiffConfigResult, LoadConfigResult, ParserResultInterface, ResultItem, Runtime, SpecFile, WatchOptions, WatcherEventType } from "@bamboocss/types";
|
|
4
|
-
import { DeadImport, ParserOptions, StyleEncoder, Stylesheet } from "@bamboocss/core";
|
|
4
|
+
import { DeadImport, ParserOptions, StyleEncoder, Stylesheet, UnresolvedTokenCall } from "@bamboocss/core";
|
|
5
5
|
import { Generator, generatePackageExports } from "@bamboocss/generator";
|
|
6
6
|
|
|
7
7
|
//#region ../native-extractor/index.d.ts
|
|
@@ -74,6 +74,17 @@ interface FoldCall {
|
|
|
74
74
|
cxArguments: FoldCxArgument[];
|
|
75
75
|
/** For an exact `keyframes()` call: the name it returns, which the fold writes in its place. */
|
|
76
76
|
value?: string;
|
|
77
|
+
/**
|
|
78
|
+
* A `token()` call whose result is tested or defaulted rather than used as it is,
|
|
79
|
+
* `token('colors.brand') ?? '#fff'`: a path naming no token is a case its author handled, and
|
|
80
|
+
* the call is compiled to the `undefined` it returns.
|
|
81
|
+
*/
|
|
82
|
+
guarded: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* A `token.value()` call written first in an expression statement. What replaces it there cannot
|
|
85
|
+
* open with `(` or `-`, which would continue the line before it where that line has no semicolon.
|
|
86
|
+
*/
|
|
87
|
+
statementStart: boolean;
|
|
77
88
|
}
|
|
78
89
|
/**
|
|
79
90
|
* Code the evaluator does not run. `statement`: a helper's body uses one — `subject` is its
|
|
@@ -209,6 +220,14 @@ interface UnresolvedStyle {
|
|
|
209
220
|
*/
|
|
210
221
|
reason: 'unresolvable-value' | 'missing-property' | 'unenumerable-keys' | 'unresolved-raw';
|
|
211
222
|
}
|
|
223
|
+
/** A `token()` call naming no token, and where it is. @see UnresolvedTokenCall */
|
|
224
|
+
interface UnresolvedTokenCallFinding {
|
|
225
|
+
call: UnresolvedTokenCall;
|
|
226
|
+
filePath: string;
|
|
227
|
+
/** One-based, as the native analysis reports the call's start. */
|
|
228
|
+
line: number;
|
|
229
|
+
column: number;
|
|
230
|
+
}
|
|
212
231
|
/**
|
|
213
232
|
* What extraction found in one file, and the encoder calls that turn it into rules.
|
|
214
233
|
*
|
|
@@ -241,6 +260,14 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
241
260
|
* `assertNoDeadCalls` rather than warned about, for that reason.
|
|
242
261
|
*/
|
|
243
262
|
deadCalls: DeadImport[];
|
|
263
|
+
/**
|
|
264
|
+
* `token()` and `token.value()` calls naming no token.
|
|
265
|
+
*
|
|
266
|
+
* Each returns `undefined`, so a property it was written into never reaches the encoder and
|
|
267
|
+
* nothing else records it. Graded by the token half of `unresolvedToken` — see
|
|
268
|
+
* `Generator.unresolvedTokenCalls` for where they are reported.
|
|
269
|
+
*/
|
|
270
|
+
unresolvedTokenCalls: UnresolvedTokenCallFinding[];
|
|
244
271
|
/**
|
|
245
272
|
* Whether each result item is attributed to its call site, for a source map.
|
|
246
273
|
*
|
|
@@ -660,6 +687,22 @@ declare class BambooContext extends Generator {
|
|
|
660
687
|
forgetNativeFile: (filePath: string) => void;
|
|
661
688
|
private parseNativeFile;
|
|
662
689
|
parseFile: (filePath: string, styleEncoder?: StyleEncoder) => ParserResult | undefined;
|
|
690
|
+
/**
|
|
691
|
+
* Keep a file's `token()` calls naming no token for the sheet's check, and warn about them when
|
|
692
|
+
* the token half of `unresolvedToken` is `warn`.
|
|
693
|
+
*
|
|
694
|
+
* Set or deleted on every parse, like `deadCalls` and for the same reason: a file read again
|
|
695
|
+
* without them has fixed them, and an entry outliving the fix would fail every later build. A
|
|
696
|
+
* file under `outdir` is left out, as `reportUnresolvedStyles` leaves it: nothing there is the
|
|
697
|
+
* author's to rewrite.
|
|
698
|
+
*/
|
|
699
|
+
private recordUnresolvedTokenCalls;
|
|
700
|
+
/**
|
|
701
|
+
* Drop the `token()` call findings of every file outside `files`, as `assertNoDeadCalls` drops
|
|
702
|
+
* its own: one deleted or taken out of `include` is not parsed again, so its entry would fail
|
|
703
|
+
* every later sheet, naming a file that is no longer part of the build.
|
|
704
|
+
*/
|
|
705
|
+
forgetUnresolvedTokenCallsOutside: (files: Iterable<string>) => void;
|
|
663
706
|
/**
|
|
664
707
|
* Extract every file in one pass, and fail on the ones that could not be read.
|
|
665
708
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as markStaticCompilerActive, t as isStaticCompilerActive } from "./static-compiler-CvT9iHM_.mjs";
|
|
2
|
-
import { DeadImport, ParserOptions, StyleEncoder, Stylesheet } from "@bamboocss/core";
|
|
2
|
+
import { DeadImport, ParserOptions, StyleEncoder, Stylesheet, UnresolvedTokenCall } from "@bamboocss/core";
|
|
3
3
|
import { Generator, generatePackageExports } from "@bamboocss/generator";
|
|
4
4
|
import { ReportFormat } from "@bamboocss/reporter";
|
|
5
5
|
import { AnalysisOptions, Artifact, ArtifactId, BambooHooks, Config, CssArtifactType, DiffConfigResult, LoadConfigResult, ParserResultInterface, ResultItem, Runtime, SpecFile, WatchOptions, WatcherEventType } from "@bamboocss/types";
|
|
@@ -74,6 +74,17 @@ interface FoldCall {
|
|
|
74
74
|
cxArguments: FoldCxArgument[];
|
|
75
75
|
/** For an exact `keyframes()` call: the name it returns, which the fold writes in its place. */
|
|
76
76
|
value?: string;
|
|
77
|
+
/**
|
|
78
|
+
* A `token()` call whose result is tested or defaulted rather than used as it is,
|
|
79
|
+
* `token('colors.brand') ?? '#fff'`: a path naming no token is a case its author handled, and
|
|
80
|
+
* the call is compiled to the `undefined` it returns.
|
|
81
|
+
*/
|
|
82
|
+
guarded: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* A `token.value()` call written first in an expression statement. What replaces it there cannot
|
|
85
|
+
* open with `(` or `-`, which would continue the line before it where that line has no semicolon.
|
|
86
|
+
*/
|
|
87
|
+
statementStart: boolean;
|
|
77
88
|
}
|
|
78
89
|
/**
|
|
79
90
|
* Code the evaluator does not run. `statement`: a helper's body uses one — `subject` is its
|
|
@@ -209,6 +220,14 @@ interface UnresolvedStyle {
|
|
|
209
220
|
*/
|
|
210
221
|
reason: 'unresolvable-value' | 'missing-property' | 'unenumerable-keys' | 'unresolved-raw';
|
|
211
222
|
}
|
|
223
|
+
/** A `token()` call naming no token, and where it is. @see UnresolvedTokenCall */
|
|
224
|
+
interface UnresolvedTokenCallFinding {
|
|
225
|
+
call: UnresolvedTokenCall;
|
|
226
|
+
filePath: string;
|
|
227
|
+
/** One-based, as the native analysis reports the call's start. */
|
|
228
|
+
line: number;
|
|
229
|
+
column: number;
|
|
230
|
+
}
|
|
212
231
|
/**
|
|
213
232
|
* What extraction found in one file, and the encoder calls that turn it into rules.
|
|
214
233
|
*
|
|
@@ -241,6 +260,14 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
241
260
|
* `assertNoDeadCalls` rather than warned about, for that reason.
|
|
242
261
|
*/
|
|
243
262
|
deadCalls: DeadImport[];
|
|
263
|
+
/**
|
|
264
|
+
* `token()` and `token.value()` calls naming no token.
|
|
265
|
+
*
|
|
266
|
+
* Each returns `undefined`, so a property it was written into never reaches the encoder and
|
|
267
|
+
* nothing else records it. Graded by the token half of `unresolvedToken` — see
|
|
268
|
+
* `Generator.unresolvedTokenCalls` for where they are reported.
|
|
269
|
+
*/
|
|
270
|
+
unresolvedTokenCalls: UnresolvedTokenCallFinding[];
|
|
244
271
|
/**
|
|
245
272
|
* Whether each result item is attributed to its call site, for a source map.
|
|
246
273
|
*
|
|
@@ -660,6 +687,22 @@ declare class BambooContext extends Generator {
|
|
|
660
687
|
forgetNativeFile: (filePath: string) => void;
|
|
661
688
|
private parseNativeFile;
|
|
662
689
|
parseFile: (filePath: string, styleEncoder?: StyleEncoder) => ParserResult | undefined;
|
|
690
|
+
/**
|
|
691
|
+
* Keep a file's `token()` calls naming no token for the sheet's check, and warn about them when
|
|
692
|
+
* the token half of `unresolvedToken` is `warn`.
|
|
693
|
+
*
|
|
694
|
+
* Set or deleted on every parse, like `deadCalls` and for the same reason: a file read again
|
|
695
|
+
* without them has fixed them, and an entry outliving the fix would fail every later build. A
|
|
696
|
+
* file under `outdir` is left out, as `reportUnresolvedStyles` leaves it: nothing there is the
|
|
697
|
+
* author's to rewrite.
|
|
698
|
+
*/
|
|
699
|
+
private recordUnresolvedTokenCalls;
|
|
700
|
+
/**
|
|
701
|
+
* Drop the `token()` call findings of every file outside `files`, as `assertNoDeadCalls` drops
|
|
702
|
+
* its own: one deleted or taken out of `include` is not parsed again, so its entry would fail
|
|
703
|
+
* every later sheet, naming a file that is no longer part of the build.
|
|
704
|
+
*/
|
|
705
|
+
forgetUnresolvedTokenCallsOutside: (files: Iterable<string>) => void;
|
|
663
706
|
/**
|
|
664
707
|
* Extract every file in one pass, and fail on the ones that could not be read.
|
|
665
708
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -3009,6 +3009,14 @@ var ParserResult = class {
|
|
|
3009
3009
|
*/
|
|
3010
3010
|
deadCalls = [];
|
|
3011
3011
|
/**
|
|
3012
|
+
* `token()` and `token.value()` calls naming no token.
|
|
3013
|
+
*
|
|
3014
|
+
* Each returns `undefined`, so a property it was written into never reaches the encoder and
|
|
3015
|
+
* nothing else records it. Graded by the token half of `unresolvedToken` — see
|
|
3016
|
+
* `Generator.unresolvedTokenCalls` for where they are reported.
|
|
3017
|
+
*/
|
|
3018
|
+
unresolvedTokenCalls = [];
|
|
3019
|
+
/**
|
|
3012
3020
|
* Whether each result item is attributed to its call site, for a source map.
|
|
3013
3021
|
*
|
|
3014
3022
|
* Off for a source a `parser:before` hook rewrote: its positions are the hook's output's,
|
|
@@ -4329,6 +4337,7 @@ var BambooContext = class extends Generator {
|
|
|
4329
4337
|
this.nativeConfigurationFiles.delete(file);
|
|
4330
4338
|
this.nativeExtractions.delete(file);
|
|
4331
4339
|
this.nativeSourceMetadata.delete(file);
|
|
4340
|
+
this.unresolvedTokenCalls.delete(this.runtime.path.abs(this.config.cwd, filePath));
|
|
4332
4341
|
};
|
|
4333
4342
|
parseNativeFile = (filePath, native, encoder) => {
|
|
4334
4343
|
if (native.errors.length) throw new BambooError("NATIVE_EXTRACTION", `Native extraction failed for ${filePath}:\n${native.errors.join("\n")}`);
|
|
@@ -4339,6 +4348,7 @@ var BambooContext = class extends Generator {
|
|
|
4339
4348
|
for (const dependency of native.dependencies) result.addDependency(dependency);
|
|
4340
4349
|
const metadata = this.nativeSourceMetadata.get(filePath.replaceAll("\\", "/"));
|
|
4341
4350
|
result.origins = metadata?.origins ?? true;
|
|
4351
|
+
let tokenTable;
|
|
4342
4352
|
for (const call of native.calls) {
|
|
4343
4353
|
const atomOrigin = encoder.recordOrigins && result.origins ? {
|
|
4344
4354
|
filePath,
|
|
@@ -4397,8 +4407,24 @@ var BambooContext = class extends Generator {
|
|
|
4397
4407
|
});
|
|
4398
4408
|
else if (call.kind === "pattern") result.setPattern(call.importedName, item);
|
|
4399
4409
|
else if (call.kind === "recipe") result.setRecipe(call.importedName, item, new Set(call.unresolvedKeys));
|
|
4400
|
-
else if (call.kind === "token" || call.kind === "tokenValue")
|
|
4401
|
-
|
|
4410
|
+
else if (call.kind === "token" || call.kind === "tokenValue") {
|
|
4411
|
+
result.setToken(item, call.kind);
|
|
4412
|
+
if (call.complete && !call.guarded) {
|
|
4413
|
+
tokenTable ??= this.tokens.view.values;
|
|
4414
|
+
for (let index = 0; index < call.arguments.length; index++) {
|
|
4415
|
+
const path = call.arguments[index];
|
|
4416
|
+
if (typeof path !== "string" || tokenTable.has(path)) continue;
|
|
4417
|
+
if (call.arguments.indexOf(path) !== index) continue;
|
|
4418
|
+
const unresolved = this.utility.unresolvedTokenCall(call.kind === "token" ? "token" : "token.value", path);
|
|
4419
|
+
if (unresolved) result.unresolvedTokenCalls.push({
|
|
4420
|
+
call: unresolved,
|
|
4421
|
+
filePath,
|
|
4422
|
+
line: call.line,
|
|
4423
|
+
column: call.column
|
|
4424
|
+
});
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
} else if (call.kind === "dead") result.deadCalls.push({
|
|
4402
4428
|
name: call.importedName,
|
|
4403
4429
|
alias: call.name,
|
|
4404
4430
|
mod: call.module,
|
|
@@ -4427,6 +4453,7 @@ var BambooContext = class extends Generator {
|
|
|
4427
4453
|
encoder.releaseFile(file);
|
|
4428
4454
|
this.parseFailures.delete(file);
|
|
4429
4455
|
this.deadCalls.delete(file);
|
|
4456
|
+
this.unresolvedTokenCalls.delete(file);
|
|
4430
4457
|
measure();
|
|
4431
4458
|
return;
|
|
4432
4459
|
}
|
|
@@ -4446,11 +4473,45 @@ var BambooContext = class extends Generator {
|
|
|
4446
4473
|
this.reportUnresolvedStyles(result);
|
|
4447
4474
|
if (result.deadCalls.length) this.deadCalls.set(file, result.deadCalls);
|
|
4448
4475
|
else this.deadCalls.delete(file);
|
|
4476
|
+
this.recordUnresolvedTokenCalls(file, result);
|
|
4449
4477
|
}
|
|
4450
4478
|
measure();
|
|
4451
4479
|
return result;
|
|
4452
4480
|
};
|
|
4453
4481
|
/**
|
|
4482
|
+
* Keep a file's `token()` calls naming no token for the sheet's check, and warn about them when
|
|
4483
|
+
* the token half of `unresolvedToken` is `warn`.
|
|
4484
|
+
*
|
|
4485
|
+
* Set or deleted on every parse, like `deadCalls` and for the same reason: a file read again
|
|
4486
|
+
* without them has fixed them, and an entry outliving the fix would fail every later build. A
|
|
4487
|
+
* file under `outdir` is left out, as `reportUnresolvedStyles` leaves it: nothing there is the
|
|
4488
|
+
* author's to rewrite.
|
|
4489
|
+
*/
|
|
4490
|
+
recordUnresolvedTokenCalls = (file, result) => {
|
|
4491
|
+
const found = this.isGenerated(file) ? [] : result.unresolvedTokenCalls;
|
|
4492
|
+
if (!found.length) {
|
|
4493
|
+
this.unresolvedTokenCalls.delete(file);
|
|
4494
|
+
return;
|
|
4495
|
+
}
|
|
4496
|
+
const sites = found.map(({ call, line, column }) => ({
|
|
4497
|
+
call,
|
|
4498
|
+
where: `${this.relative(file)}:${line}:${column}`
|
|
4499
|
+
}));
|
|
4500
|
+
this.unresolvedTokenCalls.set(file, sites);
|
|
4501
|
+
if (this.utility.unresolvedToken.token !== "warn") return;
|
|
4502
|
+
for (const { call, where } of sites) logger.warn("token", `${where} — ${this.utility.explainUnresolvedTokenCall(call)}`);
|
|
4503
|
+
};
|
|
4504
|
+
/**
|
|
4505
|
+
* Drop the `token()` call findings of every file outside `files`, as `assertNoDeadCalls` drops
|
|
4506
|
+
* its own: one deleted or taken out of `include` is not parsed again, so its entry would fail
|
|
4507
|
+
* every later sheet, naming a file that is no longer part of the build.
|
|
4508
|
+
*/
|
|
4509
|
+
forgetUnresolvedTokenCallsOutside = (files) => {
|
|
4510
|
+
if (!this.unresolvedTokenCalls.size) return;
|
|
4511
|
+
const inScope = new Set(Array.from(files, (file) => this.runtime.path.abs(this.config.cwd, file)));
|
|
4512
|
+
for (const file of this.unresolvedTokenCalls.keys()) if (!inScope.has(file)) this.unresolvedTokenCalls.delete(file);
|
|
4513
|
+
};
|
|
4514
|
+
/**
|
|
4454
4515
|
* Extract every file in one pass, and fail on the ones that could not be read.
|
|
4455
4516
|
*
|
|
4456
4517
|
* Routed through `parseFile` rather than parsing directly, so the two entry points cannot
|
|
@@ -4519,6 +4580,7 @@ var BambooContext = class extends Generator {
|
|
|
4519
4580
|
if (encoder.isEmpty()) return;
|
|
4520
4581
|
filesWithCss.push(file);
|
|
4521
4582
|
});
|
|
4583
|
+
this.forgetUnresolvedTokenCallsOutside(files);
|
|
4522
4584
|
this.assertExtracted(files);
|
|
4523
4585
|
this.assertNoDeadCalls(files);
|
|
4524
4586
|
return {
|
|
@@ -6033,6 +6095,7 @@ var Builder = class {
|
|
|
6033
6095
|
this.snapshotResolutionConfigurations();
|
|
6034
6096
|
this.affectedFiles = void 0;
|
|
6035
6097
|
this.extractionOrder = void 0;
|
|
6098
|
+
ctx.forgetUnresolvedTokenCallsOutside(files);
|
|
6036
6099
|
ctx.assertExtracted(files);
|
|
6037
6100
|
ctx.assertNoDeadCalls(files);
|
|
6038
6101
|
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/node",
|
|
3
|
-
"version": "1.58.
|
|
3
|
+
"version": "1.58.4",
|
|
4
4
|
"description": "The core css bamboo library",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
"pkg-types": "2.3.0",
|
|
61
61
|
"pluralize": "8.0.0",
|
|
62
62
|
"ts-pattern": "5.9.0",
|
|
63
|
-
"@bamboocss/config": "1.58.
|
|
64
|
-
"@bamboocss/core": "1.58.
|
|
65
|
-
"@bamboocss/generator": "1.58.
|
|
66
|
-
"@bamboocss/logger": "1.58.
|
|
67
|
-
"@bamboocss/plugin-svelte": "1.58.
|
|
68
|
-
"@bamboocss/plugin-vue": "1.58.
|
|
69
|
-
"@bamboocss/reporter": "1.58.
|
|
70
|
-
"@bamboocss/shared": "1.58.
|
|
71
|
-
"@bamboocss/token-dictionary": "1.58.
|
|
72
|
-
"@bamboocss/types": "1.58.
|
|
63
|
+
"@bamboocss/config": "1.58.4",
|
|
64
|
+
"@bamboocss/core": "1.58.4",
|
|
65
|
+
"@bamboocss/generator": "1.58.4",
|
|
66
|
+
"@bamboocss/logger": "1.58.4",
|
|
67
|
+
"@bamboocss/plugin-svelte": "1.58.4",
|
|
68
|
+
"@bamboocss/plugin-vue": "1.58.4",
|
|
69
|
+
"@bamboocss/reporter": "1.58.4",
|
|
70
|
+
"@bamboocss/shared": "1.58.4",
|
|
71
|
+
"@bamboocss/token-dictionary": "1.58.4",
|
|
72
|
+
"@bamboocss/types": "1.58.4"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@astrojs/compiler": "3.0.1",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@types/fs-extra": "11.0.4",
|
|
78
78
|
"@types/picomatch": "4.0.2",
|
|
79
79
|
"boxen": "8.0.1",
|
|
80
|
-
"@bamboocss/native-extractor": "1.58.
|
|
80
|
+
"@bamboocss/native-extractor": "1.58.4"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@astrojs/compiler": ">=2",
|