@bamboocss/types 1.28.0 → 1.29.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 CHANGED
@@ -215,7 +215,7 @@ interface FileSystemOptions {
215
215
  * css: 'styled-system/css',
216
216
  * recipes: 'styled-system/recipes',
217
217
  * patterns: 'styled-system/patterns',
218
- * jsx: 'styled-system/jsx',
218
+ * tokens: 'styled-system/tokens',
219
219
  * }
220
220
  * ```
221
221
  */
@@ -301,36 +301,36 @@ interface CssgenOptions {
301
301
  * the app draws, so an app using none of them carries all of it for nothing. Registrations
302
302
  * declared through `globalVars` are yours and are never removed.
303
303
  *
304
- * It is opt-in because reachability cannot be proven for every reference. `token()` and
305
- * `token.var()` calls are read out of the source, as is any literal `var(--x)` written
306
- * by hand. Three things stay invisible: a token named by a path the source does not
307
- * spell out as a string literal, one referenced only from a stylesheet outside
308
- * `include`, and one used by a separate package consuming the output as design tokens.
309
- * Use `staticCss` to keep those.
304
+ * It is opt-in because reachability cannot be proven for every reference. `token()`,
305
+ * `token.var()` and `token.value()` calls are read out of the source, as is any literal
306
+ * `var(--x)` written by hand and each form is resolved through a constant or a template
307
+ * literal the extractor can follow, not only through a path spelled out at the call. Three
308
+ * things stay invisible: a token named by a path assembled from a value that only exists at
309
+ * runtime, one referenced only from a stylesheet outside `include`, and one used by a
310
+ * separate package consuming the output as design tokens. Use `staticCss` to keep those.
310
311
  *
311
- * Only the *second* form of the first case is a risk. `token(key)` is safe for any path,
312
- * because javascript receives a literal for a plain token rather than a reference. It is
313
- * `token.var(key)` the form that hands back `var(--x)` that needs the declaration to
314
- * still be there, so that is the one to hold with `staticCss`.
312
+ * Every form is a risk, which is a change. `token()` used to hand javascript a literal for
313
+ * a plain token, so a path it could not resolve cost nothing; it now returns `var(--x)` for
314
+ * *every* token, and so does its `token.var()` alias. Only `token.value()` still returns a
315
+ * literal, and only for a token carrying no condition. So a path this pass cannot read is a
316
+ * declaration that has to survive whichever form asked for it.
315
317
  *
316
318
  * A custom property declared by `globalCss` or `globalVars` is not one of these cases:
317
319
  * the declaration ships whether or not anything in the stylesheet reads it, so whatever
318
320
  * it references is kept alongside it.
319
321
  *
320
- * Tokens that javascript receives as a `var()` rather than a literal are always kept, so
321
- * that `token()` answers correctly for any path at runtime. That covers virtual tokens
322
- * and any token carrying a condition, and it has one cost worth knowing about: a
323
- * negative token resolves to `calc(var(--spacing-4) * -1)`, so every token with a
324
- * negative counterpart pins its own declaration. Spacing scales generate one per entry,
325
- * which keeps the whole scale whether or not the app uses it — on the default preset
326
- * that is roughly a third of what survives pruning.
322
+ * The cost of that is bluntness. Because `token()` can name any token, a project that
323
+ * reaches for one from javascript keeps *every* token declaration on the default preset
324
+ * that is 468 names against the 68 the old, narrower exemption kept, and a token layer of
325
+ * 442 declarations rather than 2. It used to cover only virtual tokens, tokens carrying a
326
+ * condition, and the positive counterpart each negative token pins through
327
+ * `calc(var(--spacing-4) * -1)`.
327
328
  *
328
- * That exemption is now skipped entirely for a project that never reaches for a token from
329
+ * The exemption is skipped entirely for a project that never reaches for a token from
329
330
  * javascript. The tokens artifact is generated into the project rather than installed, so
330
331
  * the import is written in your own source and a scan of `include` finds it — a call, or an
331
- * import of any module the artifact could be. On the example apps here that is worth up to
332
- * 20% of the stylesheet raw and 13% gzipped, and nothing at all on the one that does call
333
- * `token()`, which is the point: a project with a caller keeps every declaration.
332
+ * import of any module the artifact could be. That is the whole saving, and it is
333
+ * all-or-nothing: a project with one caller keeps every declaration.
334
334
  *
335
335
  * The scan reads `include`, which scopes style extraction rather than everything that may
336
336
  * import — so a script, a config, or a sibling workspace package that calls `token()` is
@@ -347,7 +347,7 @@ interface CssgenOptions {
347
347
  *
348
348
  * @default true
349
349
  */
350
- pruneUnusedTokens?: boolean
350
+ pruneUnusedTokens?: boolean | 'strict'
351
351
  /**
352
352
  * Drop `@keyframes` rules nothing can reach.
353
353
  *
@@ -397,7 +397,7 @@ interface CssgenOptions {
397
397
  prunePreflight?: boolean
398
398
  /**
399
399
  * The root selector for the css variables.
400
- * @default ':where(:host, :root)'
400
+ * @default ':where(:root, :host)'
401
401
  */
402
402
  cssVarRoot?: string
403
403
  /**
package/dist/parser.d.ts CHANGED
@@ -3,7 +3,15 @@ import type { BoxNodeArray, BoxNodeLiteral, BoxNodeMap, Unboxed } from '@bambooc
3
3
  export interface ResultItem {
4
4
  name?: string
5
5
  data: Array<Unboxed['raw']>
6
- type?: 'css' | 'cva' | 'sva' | 'token' | 'pattern' | 'recipe' | 'jsx-recipe' | 'cva-call'
6
+ /**
7
+ * `token` covers `token(path)` and `token.var(path)`, which resolve identically to the
8
+ * variable reference. `tokenValue` is `token.value(path)`, the literal — distinct because
9
+ * inlining one as the other swaps a themeable reference for a fixed value.
10
+ *
11
+ * Both live in `ParserResult.token`, since every consumer that reads a token *path* out of
12
+ * a result wants both.
13
+ */
14
+ type?: 'css' | 'cva' | 'sva' | 'token' | 'tokenValue' | 'pattern' | 'recipe' | 'jsx-recipe' | 'cva-call'
7
15
  box?: BoxNodeMap | BoxNodeLiteral | BoxNodeArray
8
16
  /**
9
17
  * For a `cva-call`, the module the recipe was declared in when that is not this one.
@@ -32,7 +40,7 @@ export interface ParserResultInterface {
32
40
  setCss: (result: ResultItem) => void
33
41
  setCva: (result: ResultItem) => void
34
42
  setSva: (result: ResultItem) => void
35
- setToken: (result: ResultItem) => void
43
+ setToken: (result: ResultItem, kind?: 'token' | 'tokenValue') => void
36
44
  setViewTransition: (result: ResultItem) => void
37
45
  setPattern: (name: string, result: ResultItem) => void
38
46
  setRecipe: (name: string, result: ResultItem) => void
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/types",
3
- "version": "1.28.0",
3
+ "version": "1.29.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.28.0"
35
+ "@bamboocss/extractor": "1.29.0"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "tsx scripts/watch.ts",