@bamboocss/types 1.32.0 → 1.34.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/config.d.ts +128 -38
- package/dist/runtime.d.ts +2 -0
- package/package.json +2 -2
package/dist/config.d.ts
CHANGED
|
@@ -267,12 +267,65 @@ interface FileSystemOptions {
|
|
|
267
267
|
logFilter?: string
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
+
export interface PreflightOptions {
|
|
271
|
+
/**
|
|
272
|
+
* A selector the reset is confined to, so it does not style the whole document.
|
|
273
|
+
*/
|
|
274
|
+
scope?: string
|
|
275
|
+
/**
|
|
276
|
+
* Where the scope is written. `parent` gives `.app table`, `element` gives `table.app`.
|
|
277
|
+
* @default 'parent'
|
|
278
|
+
*/
|
|
279
|
+
level?: 'element' | 'parent'
|
|
280
|
+
/**
|
|
281
|
+
* Whether to drop the parts of the reset that style elements your source never renders.
|
|
282
|
+
*
|
|
283
|
+
* Two thirds of the reset is bound to specific elements — 41 of them, covering `table`,
|
|
284
|
+
* `pre`, `kbd`, `optgroup` and the rest of the long tail. The reset is a fixed size, so it
|
|
285
|
+
* dominates a small stylesheet: a third of one sandbox's css here and four fifths of
|
|
286
|
+
* another's, of which 13% and 34% respectively is for elements those projects never render.
|
|
287
|
+
*
|
|
288
|
+
* A selector list loses only the parts naming unrendered elements, so a rule shared between
|
|
289
|
+
* `button` and `::file-selector-button` keeps the half that still applies. `html` and `body`
|
|
290
|
+
* are never removed.
|
|
291
|
+
*
|
|
292
|
+
* Off by default, and it cannot be made safe by default. Unlike the token and keyframe
|
|
293
|
+
* passes there is nothing to prove this against: an element rendered by a dependency's
|
|
294
|
+
* component, by `dangerouslySetInnerHTML`, or by markdown is invisible to a scan of your own
|
|
295
|
+
* source. What you get wrong is an element quietly losing its reset — no error, no warning.
|
|
296
|
+
* Reach for it when you control the markup and have measured that it pays.
|
|
297
|
+
*
|
|
298
|
+
* The blind spot to check first is your own entry template. The scan reads `include`, and
|
|
299
|
+
* `include` conventionally covers components rather than markup — a glob rooted at `./src`
|
|
300
|
+
* does not match `index.html`, so an element appearing only there is dropped. Add the
|
|
301
|
+
* template to `include` to cover it — the scan reads any file listed, not only ones the
|
|
302
|
+
* parser understands, and reads it from disk rather than from the build's parsed copy, so
|
|
303
|
+
* a single-file component's markup survives the transform to tsx.
|
|
304
|
+
*
|
|
305
|
+
* A scoped reset is handled: `preflight: { scope: '.app', prune: true }` writes `.app table`,
|
|
306
|
+
* and the scope is stripped before an element is read out. `bamboo cssgen preflight` prunes
|
|
307
|
+
* too.
|
|
308
|
+
*
|
|
309
|
+
* @default false
|
|
310
|
+
*/
|
|
311
|
+
prune?: boolean
|
|
312
|
+
}
|
|
313
|
+
|
|
270
314
|
interface CssgenOptions {
|
|
271
315
|
/**
|
|
272
|
-
* Whether to include css reset styles in the generated css.
|
|
316
|
+
* Whether to include css reset styles in the generated css, and how.
|
|
317
|
+
*
|
|
318
|
+
* `true` is shorthand for `{}` — on, with the defaults. `false` is the only form that means
|
|
319
|
+
* off, so it has no object spelling.
|
|
320
|
+
*
|
|
321
|
+
* `prune` used to be `prune.preflight`, a second key of the same name one level away, so a
|
|
322
|
+
* config could ask for a reset in one place and reshape it in another. It lives here because
|
|
323
|
+
* everything it needs is here: pruning a scoped reset means stripping `scope` before an
|
|
324
|
+
* element can be read out of a selector.
|
|
325
|
+
*
|
|
273
326
|
* @default false
|
|
274
327
|
*/
|
|
275
|
-
preflight?: boolean |
|
|
328
|
+
preflight?: boolean | PreflightOptions
|
|
276
329
|
/**
|
|
277
330
|
* The namespace prefix for the generated css classes and css variables.
|
|
278
331
|
* @default ''
|
|
@@ -354,6 +407,34 @@ interface CodegenOptions {
|
|
|
354
407
|
* @default 'true'
|
|
355
408
|
*/
|
|
356
409
|
shorthands?: boolean
|
|
410
|
+
/**
|
|
411
|
+
* Whether a lowered style leaf falls back to `css()` for a value that is not a scalar.
|
|
412
|
+
*
|
|
413
|
+
* Only the build-time fold calls the helper this governs. `css({ color: tone })` lowers to
|
|
414
|
+
* `cssLeaf('c_', 'color', tone)`, which builds the class by concatenation — and hands the
|
|
415
|
+
* value to `css()` when it turns out to be a condition object or a responsive array, which
|
|
416
|
+
* no concatenation describes.
|
|
417
|
+
*
|
|
418
|
+
* That fallback is the single edge keeping the css engine in a bundle. It is reachable only
|
|
419
|
+
* for a value the fold could not see the shape of, and it costs the whole prize: on
|
|
420
|
+
* `sandbox/runtime-perf`, one dynamic leaf takes a module from **923 B to 7,542 B gzipped**,
|
|
421
|
+
* because the reference pulls in `createCss`, the merge, the utility and shorthand tables
|
|
422
|
+
* and the conditions. Turned off, the same module keeps 10 top-level bindings instead of 39.
|
|
423
|
+
*
|
|
424
|
+
* Turning it off asserts something about your source: **a style value that varies at runtime
|
|
425
|
+
* is a scalar** — a string, a number, a boolean, or nothing. Write conditions and responsive
|
|
426
|
+
* values as literals at the call site, where the fold reads them and resolves each branch,
|
|
427
|
+
* rather than assembling them into a variable. A value that breaks the assertion throws,
|
|
428
|
+
* naming the property, instead of silently producing a class with no rule behind it.
|
|
429
|
+
*
|
|
430
|
+
* Pairs with `failOnUnfolded` in `@bamboocss/vite`: with the fallback off a lowered leaf no
|
|
431
|
+
* longer keeps the engine, so that option stops reporting one as a survivor. Together they
|
|
432
|
+
* are what makes zero runtime reachable for an app that has any dynamic styling at all —
|
|
433
|
+
* before this, it required an app with none.
|
|
434
|
+
*
|
|
435
|
+
* @default true
|
|
436
|
+
*/
|
|
437
|
+
leafFallback?: boolean
|
|
357
438
|
/**
|
|
358
439
|
* File extension for generated javascript files.
|
|
359
440
|
* @default 'mjs'
|
|
@@ -562,46 +643,24 @@ export interface PruneOptions {
|
|
|
562
643
|
* are dead weight in the stylesheet that blocks first paint. Only keyframes the theme
|
|
563
644
|
* declares are ever removed — one emitted by `global.css` is left alone.
|
|
564
645
|
*
|
|
565
|
-
* A name is kept when any declaration in the generated css names it,
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
* used one breaks the
|
|
646
|
+
* A name is kept when any declaration in the generated css names it, when a token
|
|
647
|
+
* declaration that *survives* `tokens` names it, and when it appears anywhere under
|
|
648
|
+
* `include` — which covers an animation assembled at runtime or applied through an inline
|
|
649
|
+
* `style` rather than through bamboo. That textual fallback is deliberately
|
|
650
|
+
* over-inclusive: keeping an unused keyframe costs bytes, dropping a used one breaks the
|
|
651
|
+
* animation.
|
|
652
|
+
*
|
|
653
|
+
* The middle one is why this cannot be read off the stylesheet alone. `--animations-drawer:
|
|
654
|
+
* slide-in-right 400ms` reaches its keyframe only if something reaches the property, and a
|
|
655
|
+
* property can be reached from outside the css entirely — a `token()` call, a `keepTokens`
|
|
656
|
+
* pattern, a theme, a `globalCss` export. Those are exactly the tokens `tokens` keeps, so
|
|
657
|
+
* this defers to that pass rather than asking again: a keyframe is dropped only when the
|
|
658
|
+
* declarations naming it were dropped too. Under `tokens: 'off'` nothing is removable, so
|
|
659
|
+
* every keyframe a declaration names is kept.
|
|
570
660
|
*
|
|
571
661
|
* @default true
|
|
572
662
|
*/
|
|
573
663
|
keyframes?: boolean
|
|
574
|
-
/**
|
|
575
|
-
* Whether to drop the parts of the reset that style elements your source never renders.
|
|
576
|
-
*
|
|
577
|
-
* Two thirds of the reset is bound to specific elements — 41 of them, covering `table`,
|
|
578
|
-
* `pre`, `kbd`, `optgroup` and the rest of the long tail. The reset is a fixed size, so it
|
|
579
|
-
* dominates a small stylesheet: a third of one sandbox's css here and four fifths of
|
|
580
|
-
* another's, of which 13% and 34% respectively is for elements those projects never render.
|
|
581
|
-
*
|
|
582
|
-
* A selector list loses only the parts naming unrendered elements, so a rule shared between
|
|
583
|
-
* `button` and `::file-selector-button` keeps the half that still applies. `html` and `body`
|
|
584
|
-
* are never removed.
|
|
585
|
-
*
|
|
586
|
-
* Off by default, and it cannot be made safe by default. Unlike the token and keyframe
|
|
587
|
-
* passes there is nothing to prove this against: an element rendered by a dependency's
|
|
588
|
-
* component, by `dangerouslySetInnerHTML`, or by markdown is invisible to a scan of your own
|
|
589
|
-
* source. What you get wrong is an element quietly losing its reset — no error, no warning.
|
|
590
|
-
* Reach for it when you control the markup and have measured that it pays.
|
|
591
|
-
*
|
|
592
|
-
* The blind spot to check first is your own entry template. The scan reads `include`, and
|
|
593
|
-
* `include` conventionally covers components rather than markup — a glob rooted at `./src`
|
|
594
|
-
* does not match `index.html`, so an element appearing only there is dropped. Add the
|
|
595
|
-
* template to `include` to cover it — the scan reads any file listed, not only ones the
|
|
596
|
-
* parser understands, and reads it from disk rather than from the build's parsed copy, so
|
|
597
|
-
* a single-file component's markup survives the transform to tsx.
|
|
598
|
-
*
|
|
599
|
-
* A scoped reset is handled: `preflight: { scope: '.app' }` writes `.app table`, and the
|
|
600
|
-
* scope is stripped before an element is read out. `bamboo cssgen preflight` prunes too.
|
|
601
|
-
*
|
|
602
|
-
* @default false
|
|
603
|
-
*/
|
|
604
|
-
preflight?: boolean
|
|
605
664
|
}
|
|
606
665
|
|
|
607
666
|
export interface Config
|
|
@@ -628,6 +687,37 @@ export interface Config
|
|
|
628
687
|
* @default 'warn'
|
|
629
688
|
*/
|
|
630
689
|
validation?: 'off' | 'warn' | 'error'
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* What to do about a style value shaped like a token path that resolves to no token.
|
|
693
|
+
*
|
|
694
|
+
* - `off` says nothing.
|
|
695
|
+
* - `warn` logs each one as it is transformed.
|
|
696
|
+
* - `error` fails the build, listing every one it found.
|
|
697
|
+
*
|
|
698
|
+
* Every branch of the resolver ends in `|| value`, so an unknown path is emitted as
|
|
699
|
+
* written: `background: 'accent.default'` ships as `background: accent.default`. That
|
|
700
|
+
* parses, so nothing downstream objects and the stylesheet is valid — the browser drops the
|
|
701
|
+
* declaration at compute time and the style is simply absent. It surfaces as "this colour
|
|
702
|
+
* never applied", a long way from the typo that caused it, and a build carrying one warns
|
|
703
|
+
* identically on every run until somebody happens to read the log.
|
|
704
|
+
*
|
|
705
|
+
* `warn` is the default because the test is a *shape*: a dotted value against the set of
|
|
706
|
+
* values the property enumerates. That is right about a mistyped token and cannot be sure
|
|
707
|
+
* about a literal, so escalating it is a choice a project makes once it knows its own
|
|
708
|
+
* source is clean. `[accent.default]` marks a value as literal and is never reported.
|
|
709
|
+
*
|
|
710
|
+
* Not to be confused with {@link PruneOptions.unresolvedPath}, which is about a `token()`
|
|
711
|
+
* *call* whose path the prune scan cannot follow statically — a question about pruning
|
|
712
|
+
* coverage, asked of a token that usually exists. This one is about a token that does not.
|
|
713
|
+
*
|
|
714
|
+
* A binding that does not exist is not graded here and always throws: that is read off an
|
|
715
|
+
* entrypoint's own export list rather than inferred, so there is no setting under which it
|
|
716
|
+
* is what someone meant.
|
|
717
|
+
*
|
|
718
|
+
* @default 'warn'
|
|
719
|
+
*/
|
|
720
|
+
unresolvedToken?: 'off' | 'warn' | 'error'
|
|
631
721
|
}
|
|
632
722
|
|
|
633
723
|
export interface Preset extends ExtendableOptions, PresetOptions {
|
package/dist/runtime.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface WatchOptions extends InputOptions {
|
|
|
19
19
|
interface FileSystem {
|
|
20
20
|
readDirSync(dir: string): string[]
|
|
21
21
|
existsSync(fileLike: string): boolean
|
|
22
|
+
/** False for a path that does not exist, so a caller never has to test twice. */
|
|
23
|
+
isDirSync(path: string): boolean
|
|
22
24
|
glob(opts: InputOptions): string[]
|
|
23
25
|
readFileSync(filePath: string): string
|
|
24
26
|
rmDirSync(dirPath: string): void
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/types",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.0",
|
|
4
4
|
"description": "The types for css bamboo",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"ncp": "2.0.0",
|
|
33
33
|
"pkg-types": "2.3.0",
|
|
34
34
|
"ts-morph": "28.0.0",
|
|
35
|
-
"@bamboocss/extractor": "1.
|
|
35
|
+
"@bamboocss/extractor": "1.34.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"dev": "tsx scripts/watch.ts",
|