@bamboocss/types 1.41.1 → 1.43.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.
Files changed (2) hide show
  1. package/dist/config.d.ts +55 -30
  2. package/package.json +2 -2
package/dist/config.d.ts CHANGED
@@ -377,6 +377,11 @@ interface CssgenOptions {
377
377
  polyfill?: boolean
378
378
  }
379
379
 
380
+ export type UnresolvedTokenSeverity = 'off' | 'warn' | 'error'
381
+
382
+ /** `'auto'` hashes in production and leaves names readable in development. */
383
+ export type HashSetting = boolean | 'auto'
384
+
380
385
  interface CodegenOptions {
381
386
  /**
382
387
  * Whether to only emit the `tokens` directory
@@ -385,45 +390,51 @@ interface CodegenOptions {
385
390
  emitTokensOnly?: boolean
386
391
  /**
387
392
  * Whether to hash the generated class names / css variables.
388
- * This is useful if want to shorten the class names or css variables.
393
+ *
394
+ * Readable names cost nothing for most of what a project writes — `fs_14px` and `c_accent`
395
+ * gzip to within a rounding error of a hash, because they repeat. What does cost is an
396
+ * *arbitrary* value, which is escaped into the name whole: one measured project carried a
397
+ * complete `linear-gradient(…)` as a 105-character class, and escaped names were 20% of all
398
+ * class-attribute bytes. Those do not compress away, because the redundancy is inside one long
399
+ * token rather than across repeated short ones.
400
+ *
401
+ * `'auto'` is the answer to both: readable while you are looking at them, hashed when nobody
402
+ * is. The mode comes from the integration — the Vite plugin's dev server is development and
403
+ * everything else is production — and is fixed for the life of a context, so the emitted CSS
404
+ * and the compiled class literals cannot disagree about a name.
405
+ *
389
406
  * @default false
390
407
  */
391
- hash?: boolean | { cssVar?: boolean; className?: boolean }
408
+ hash?: HashSetting | { cssVar?: HashSetting; className?: HashSetting }
392
409
  /**
393
- * Change generated typescript definitions to be more strict for property having a token or utility.
410
+ * Whether this context is serving a development build.
394
411
  *
395
- * Three settings, not two:
412
+ * Set by the integration rather than by a project — the Vite plugin's dev server is the only
413
+ * thing that knows — and read by `hash: 'auto'`. It is deliberately not a mode switch for
414
+ * anything else: a class name that differs between dev and prod is one thing, and CSS that
415
+ * differs is another.
396
416
  *
397
- * - `false` — every property also accepts `string`, so nothing about a value is checked. A
398
- * misspelled token is a value the browser drops at compute time: the declaration ships, the
399
- * style is simply absent, and it surfaces as "this colour never applied" a long way from the
400
- * typo.
401
- * - `'unknown-tokens'` a value must be a token, a keyword the property actually enumerates,
402
- * or *shaped* like a CSS value: it starts with a digit or `#` or `-`, or it contains a space,
403
- * a comma or a function call. `'14px'`, `'100vh'`, `'1px solid red'` and `'rgb(0 0 0)'` all
404
- * pass; `'mutedd'`, `'accnt'` and `'colors.acent'` do not, because a bare identifier that is
405
- * neither a token nor a keyword is nothing else.
406
- * - `true` — only tokens, and every raw value has to be written as `'[14px]'`.
417
+ * @default false
418
+ */
419
+ dev?: boolean
420
+ /**
421
+ * Require every style value to be a token, so a raw CSS value has to be written `'[14px]'`.
407
422
  *
408
- * The middle setting exists because the other two are a day-one decision. Turning `true` on
409
- * later reports every raw value in the codebase 468 errors on one otherwise-correct app, of
410
- * which 3 were the typo it was turned on for so a project that did not start with it is
411
- * realistically stuck with the unchecked default forever. `'unknown-tokens'` costs no
412
- * migration and catches that class of mistake.
423
+ * A design-system policy rather than a correctness check: it is how a team says "everything
424
+ * goes through the theme", and the brackets are what make reaching outside it visible in the
425
+ * source. On one otherwise-correct five-page app it reports 468 values, which is what makes
426
+ * it a day-one decision.
413
427
  *
414
- * Properties whose values *are* identifiers you invent `animationName`, `gridArea`,
415
- * `counterReset`, `containerName`, `fontFamily`, `content` and the rest are left out of
416
- * it: there is nothing to check them against, and a `@keyframes` name declared in CSS is an
417
- * ordinary thing to write.
428
+ * A *keyword* is not a raw value. `display: 'flex'` is the only way to say that, so it is
429
+ * left alone a distinction the type-level version of this could not draw, which is why it
430
+ * did not narrow `display` at all and let `display: 'abc'` through with it.
418
431
  *
419
- * Two costs follow from the rule being about shape. A typo that is *also* a plausible value
420
- * passes — `'2xll'` starts with a digit like `'2rem'` does. And a value typed `string` is
421
- * rejected, since nothing distinguishes it from a misspelled token; write `` `[${value}]` ``,
422
- * the same as under `true`, and note the Vite compiler rejects an open runtime value anyway.
432
+ * Reported by the build, graded by `validation`, and it is not what catches a misspelled
433
+ * tokensee `unresolvedToken`, which is on by default and needs no setting.
423
434
  *
424
435
  * @default false
425
436
  */
426
- strictTokens?: boolean | 'unknown-tokens'
437
+ strictValues?: boolean
427
438
  /**
428
439
  * Change generated typescript definitions to be more strict for built-in CSS properties to only allow valid CSS values.
429
440
  */
@@ -718,9 +729,23 @@ export interface Config
718
729
  * entrypoint's own export list rather than inferred, so there is no setting under which it
719
730
  * is what someone meant.
720
731
  *
721
- * @default 'warn'
732
+ * Two halves, graded apart, because they are not equally certain.
733
+ *
734
+ * A property that draws from a token category — `color` from `colors`, `top` from `spacing` —
735
+ * makes a name that is not a token bamboo's own bookkeeping, and there is no third party to be
736
+ * wrong about it. That half defaults to `'error'`.
737
+ *
738
+ * Everywhere else the judge is the CSS grammar, whose data lags the spec: `containerType:
739
+ * 'scroll-state'` is valid CSS that the grammar has not caught up with. Sweeping every keyword
740
+ * csstype enumerates through it found 8 such disagreements in 10,128 pairs — 0.08%, and all 8
741
+ * on properties with no token category. That half defaults to `'warn'`, so a build is never
742
+ * failed by how fresh a grammar is.
743
+ *
744
+ * A single severity applies to both.
745
+ *
746
+ * @default { token: 'error', grammar: 'warn' }
722
747
  */
723
- unresolvedToken?: 'off' | 'warn' | 'error'
748
+ unresolvedToken?: UnresolvedTokenSeverity | { token?: UnresolvedTokenSeverity; grammar?: UnresolvedTokenSeverity }
724
749
  }
725
750
 
726
751
  export interface Preset extends ExtendableOptions, PresetOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/types",
3
- "version": "1.41.1",
3
+ "version": "1.43.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.41.1"
35
+ "@bamboocss/extractor": "1.43.0"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "tsx scripts/watch.ts",