@tenphi/tasty 3.10.0 → 3.11.1
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/README.md +403 -380
- package/dist/{babel-types-C_7kRP38.d.ts → babel-types-BKDTT4--.d.ts} +2 -2
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/{build-config-l2Ys-AJr.js → build-config-5d8WlQbq.js} +5 -5
- package/dist/chunks/{build-config-l2Ys-AJr.js.map → build-config-5d8WlQbq.js.map} +1 -1
- package/dist/chunks/{collector-CaNtsRtn.js → collector-CjCak4iE.js} +4 -4
- package/dist/chunks/{collector-CaNtsRtn.js.map → collector-CjCak4iE.js.map} +1 -1
- package/dist/chunks/{config-engine-CpExZO_T.js → config-engine-uOFYZidB.js} +4 -4
- package/dist/chunks/{config-engine-CpExZO_T.js.map → config-engine-uOFYZidB.js.map} +1 -1
- package/dist/chunks/config-file-DlZXJMj8.js +25 -0
- package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
- package/dist/chunks/{css-definitions-DAIJxzFY.js → css-definitions-ubrHP97m.js} +88 -77
- package/dist/chunks/css-definitions-ubrHP97m.js.map +1 -0
- package/dist/chunks/{debug-CKy49GEr.js → debug-CJ31U_WE.js} +6 -6
- package/dist/chunks/{debug-CKy49GEr.js.map → debug-CJ31U_WE.js.map} +1 -1
- package/dist/chunks/{dsl-DRhFWQzo.js → dsl-DYSJc1-T.js} +11 -6
- package/dist/chunks/dsl-DYSJc1-T.js.map +1 -0
- package/dist/chunks/{react-runtime-oi6i3ELR.js → react-runtime-CyyCI02N.js} +168 -61
- package/dist/chunks/react-runtime-CyyCI02N.js.map +1 -0
- package/dist/chunks/{runtime-engine-DoULyhPt.js → runtime-engine-BQmOu5-W.js} +53 -36
- package/dist/chunks/runtime-engine-BQmOu5-W.js.map +1 -0
- package/dist/chunks/{runtime-state-CZ2J5QiZ.js → runtime-state-DEsyUMU-.js} +14 -3
- package/dist/chunks/runtime-state-DEsyUMU-.js.map +1 -0
- package/dist/chunks/{style-engine-CeKsjtIr.js → style-engine-BX2LshDZ.js} +116 -56
- package/dist/chunks/style-engine-BX2LshDZ.js.map +1 -0
- package/dist/chunks/{zero-engine-fxKu8Jbn.js → zero-engine-Dw0P4yGM.js} +22 -7
- package/dist/chunks/zero-engine-Dw0P4yGM.js.map +1 -0
- package/dist/{collector-w4mBj5gd.d.ts → collector-CTU-nl0g.d.ts} +2 -2
- package/dist/{config-CrZOfNJ5.d.ts → config-CcxqSZI2.d.ts} +28 -9
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +7 -7
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/{index-CYJtAI9a.d.ts → index--GdqCPlp.d.ts} +58 -16
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -8
- package/dist/{merge-styles-VXwJ0Frr.d.ts → merge-styles-DSkVc6CD.d.ts} +2 -2
- package/dist/ssr/astro.js +4 -4
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +3 -22
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +1 -1
- package/dist/ssr/next-config.js +6 -17
- package/dist/ssr/next-config.js.map +1 -1
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +3 -3
- package/dist/static/index.d.ts +2 -2
- package/dist/{types-JEY8PVYP.d.ts → types-DJEM_BOJ.d.ts} +6 -6
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +30 -19
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +24 -6
- package/dist/zero/index.js +4 -4
- package/dist/zero/index.js.map +1 -1
- package/dist/zero/next.d.ts +1 -1
- package/dist/zero/next.js +3 -7
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +4 -1
- package/docs/adoption.md +25 -17
- package/docs/ai-agents.md +39 -34
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +174 -58
- package/docs/debug.md +3 -2
- package/docs/design-system.md +117 -15
- package/docs/dsl.md +145 -81
- package/docs/getting-started.md +81 -24
- package/docs/injector.md +41 -40
- package/docs/methodology.md +46 -21
- package/docs/migration-v3.md +3 -3
- package/docs/pipeline.md +19 -16
- package/docs/plugins.md +21 -41
- package/docs/react-api.md +61 -9
- package/docs/runtime-benchmarks.md +4 -4
- package/docs/ssr.md +92 -66
- package/docs/styles.md +33 -17
- package/docs/tasty-static.md +129 -58
- package/package.json +23 -9
- package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
- package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
- package/dist/chunks/css-definitions-DAIJxzFY.js.map +0 -1
- package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
- package/dist/chunks/react-runtime-oi6i3ELR.js.map +0 -1
- package/dist/chunks/runtime-engine-DoULyhPt.js.map +0 -1
- package/dist/chunks/runtime-state-CZ2J5QiZ.js.map +0 -1
- package/dist/chunks/style-engine-CeKsjtIr.js.map +0 -1
- package/dist/chunks/zero-engine-fxKu8Jbn.js.map +0 -1
package/docs/styles.md
CHANGED
|
@@ -10,6 +10,8 @@ The properties documented below have **custom handlers** with enhanced syntax. T
|
|
|
10
10
|
|
|
11
11
|
Other CSS properties (e.g. `opacity`, `transform`, `cursor`, `position`, `zIndex`) are passed through with standard Tasty value parsing but no special handler logic.
|
|
12
12
|
|
|
13
|
+
[`@tenphi/eslint-plugin-tasty`](getting-started.md#eslint-plugin) reports raw CSS properties that have a handler here (`prefer-shorthand-property`) and modifiers a property does not accept (`valid-directional-modifier`, `valid-radius-shape`).
|
|
14
|
+
|
|
13
15
|
---
|
|
14
16
|
|
|
15
17
|
## Recommended Props
|
|
@@ -64,7 +66,7 @@ Standard CSS display values. Handled together with `hide`, `textOverflow`, `over
|
|
|
64
66
|
| `display` | Any CSS display value | Overridden by `hide` or multi-line `textOverflow` |
|
|
65
67
|
| `hide` | `true` / `false` | Shortcut for `display: none`. Highest priority |
|
|
66
68
|
| `overflow` | Any CSS overflow value | Overridden when `textOverflow` sets `hidden` |
|
|
67
|
-
| `whiteSpace` | Any CSS white-space value |
|
|
69
|
+
| `whiteSpace` | Any CSS white-space value | Explicit value wins over the `nowrap` / `initial` that `textOverflow` sets |
|
|
68
70
|
|
|
69
71
|
### `textOverflow`
|
|
70
72
|
|
|
@@ -78,7 +80,7 @@ Text truncation with optional multi-line clamping.
|
|
|
78
80
|
| `"ellipsis / 3"` | Multi-line clamp (3 lines) with ellipsis, sets `overflow: hidden` and `white-space: initial` |
|
|
79
81
|
| `"clip"` | Single-line truncation without ellipsis, sets `overflow: hidden` and `white-space: nowrap` |
|
|
80
82
|
| `"clip / 2"` | Multi-line clip (2 lines), sets `overflow: hidden` and `white-space: initial` |
|
|
81
|
-
| `
|
|
83
|
+
| `"initial"` | Reset text-overflow to initial |
|
|
82
84
|
|
|
83
85
|
Explicit `whiteSpace` overrides the default white-space set by `textOverflow`.
|
|
84
86
|
|
|
@@ -144,6 +146,8 @@ A group that names *no* direction keeps plain CSS shorthand order, which is unam
|
|
|
144
146
|
|
|
145
147
|
Later comma-separated groups override earlier groups for conflicting directions.
|
|
146
148
|
|
|
149
|
+
A group with directions but no value (`padding: 'top'`) uses `1x`, the same as `padding: true`, so it follows `configure({ units })`.
|
|
150
|
+
|
|
147
151
|
Individual physical props `paddingTop`, `paddingRight`, `paddingBottom`, and `paddingLeft` are supported, but `padding` with modifiers is recommended. Use `blockPadding` or `inlinePadding` for an enhanced logical-axis shorthand; native declarations such as `paddingInlineStart` remain ordinary CSS properties. See [Logical properties](#logical-properties).
|
|
148
152
|
|
|
149
153
|
### `margin`
|
|
@@ -193,12 +197,15 @@ Element width with min/max control. One, two, or three values set `min-width`, `
|
|
|
193
197
|
| `"min 2x"` | `2x` | auto | initial |
|
|
194
198
|
| `"max 100%"` | initial | auto | `100%` |
|
|
195
199
|
| `"fixed 200px"` | `200px` | `200px` | `200px` |
|
|
200
|
+
| `"min"` | `1x` | auto | initial |
|
|
201
|
+
| `"max"` | initial | auto | `100%` |
|
|
202
|
+
| `"fixed"` | `max-content` | `max-content` | `max-content` |
|
|
196
203
|
|
|
197
204
|
**Keywords:** `stretch`, `max-content`, `min-content`, `fit-content`
|
|
198
205
|
|
|
199
206
|
| Value | Effect |
|
|
200
207
|
|-------|--------|
|
|
201
|
-
| `"stretch"` | Fill available space
|
|
208
|
+
| `"stretch"` | Fill the available space, margins included. Emitted with `-webkit-fill-available` and `-moz-available` fallbacks for engines without the standard keyword |
|
|
202
209
|
| `true` | Reset to `auto` / `initial` / `initial` |
|
|
203
210
|
| Number | Converted to `px` |
|
|
204
211
|
|
|
@@ -206,7 +213,7 @@ Separate `minWidth` and `maxWidth` props are supported and override values from
|
|
|
206
213
|
|
|
207
214
|
### `height`
|
|
208
215
|
|
|
209
|
-
Element height. Same syntax, modifiers, and positional patterns as `width`.
|
|
216
|
+
Element height. Same syntax, modifiers, keywords, and positional patterns as `width`, including `stretch`.
|
|
210
217
|
|
|
211
218
|
Separate `minHeight` and `maxHeight` props are supported and override values from the `height` syntax.
|
|
212
219
|
|
|
@@ -305,9 +312,10 @@ Background color with design token support. Preferred over `backgroundColor` and
|
|
|
305
312
|
| `"#surface #primary.10"` | Background `#surface` with `#primary.10` overlay (two colors enable smooth transitions between both) |
|
|
306
313
|
| `"rgb(255 128 0)"` | CSS color value |
|
|
307
314
|
| `"color-mix(in oklab, #primary 50%, #surface)"` | CSS color function — see [CSS Color Functions](dsl.md#css-color-functions) |
|
|
308
|
-
| `true` | Default fill color |
|
|
309
315
|
|
|
310
|
-
When two colors are provided, the first sets the background color and the second is applied as an overlay gradient layer. This enables independent CSS transitions on each color.
|
|
316
|
+
When two colors are provided, the first sets the background color and the second is applied as an overlay gradient layer. This enables independent CSS transitions on each color. With `image` or `backgroundImage` on the same element, the image is layered over the overlay color in one `background-image`.
|
|
317
|
+
|
|
318
|
+
There is no default fill color, so `fill: true` is ignored with a development warning. Use `false` for no fill.
|
|
311
319
|
|
|
312
320
|
**Related deprecated props:** `backgroundColor` (use `fill`), `background` (overrides all background props when set — avoid).
|
|
313
321
|
|
|
@@ -338,6 +346,7 @@ Text color with design token support.
|
|
|
338
346
|
| `"#current.5"` | Current inherited color at 50% opacity |
|
|
339
347
|
| `"(#primary, #secondary)"` | Fallback: use `#primary`, fall back to `#secondary` |
|
|
340
348
|
| `"light-dark(#dark, #light)"` | CSS color function — see [CSS Color Functions](dsl.md#css-color-functions) |
|
|
349
|
+
| `"#ddd"` | Hex literal, read as the `#ddd` token with the literal as fallback: `var(--ddd-color, #ddd)`, as in every color style |
|
|
341
350
|
| `true` | `currentColor` |
|
|
342
351
|
|
|
343
352
|
Also sets `$current-color` to the same color, for anything that needs the
|
|
@@ -368,7 +377,7 @@ Border shorthand with directional and multi-group support. Use **comma-separated
|
|
|
368
377
|
|
|
369
378
|
**Syntax:** `[width] [style] [color] [directions...]` — comma-separated for multiple groups
|
|
370
379
|
|
|
371
|
-
**Defaults:** width = `1bw`, style = `solid`, color = `#border`
|
|
380
|
+
**Defaults:** width = `1bw`, style = `solid`, color = `#border`, which is the text color (`currentColor`) until your tokens define `#border`
|
|
372
381
|
|
|
373
382
|
**Styles:** `none`, `hidden`, `dotted`, `dashed`, `solid`, `double`, `groove`, `ridge`, `inset`, `outset`
|
|
374
383
|
|
|
@@ -388,6 +397,8 @@ Border shorthand with directional and multi-group support. Use **comma-separated
|
|
|
388
397
|
|
|
389
398
|
Later comma-separated groups override earlier groups for conflicting directions.
|
|
390
399
|
|
|
400
|
+
A directional group without a width (`'dotted left'`) uses `1bw`, the same as `border: true`, so it follows `configure({ units })`.
|
|
401
|
+
|
|
391
402
|
### `radius`
|
|
392
403
|
|
|
393
404
|
Border radius with shape presets and directional modifiers.
|
|
@@ -427,13 +438,15 @@ Use these when an edge modifier would round one corner too many. Edge and corner
|
|
|
427
438
|
| `"4px top-left"` | Top-left corner `4px`, every other corner `0` |
|
|
428
439
|
| `"top bottom-right"` | Both top corners and bottom-right `1r`, bottom-left `0` |
|
|
429
440
|
|
|
441
|
+
A value-less corner group (`'top-right'`, `'top bottom-right'`) uses `1r`, the same as `radius: true`, so it follows `configure({ units })`.
|
|
442
|
+
|
|
430
443
|
### `outline`
|
|
431
444
|
|
|
432
445
|
Outline with inline offset support.
|
|
433
446
|
|
|
434
447
|
**Syntax:** `[width] [style] [color] / [offset]`
|
|
435
448
|
|
|
436
|
-
**Defaults:** width = `1ow`, style = `solid`, color = `#outline`
|
|
449
|
+
**Defaults:** width = `1ow`, style = `solid`, color = `#outline`, which is the text color (`currentColor`) until your tokens define `#outline`
|
|
437
450
|
|
|
438
451
|
**Styles:** Same as `border` (`none`, `dotted`, `dashed`, `solid`, etc.)
|
|
439
452
|
|
|
@@ -468,7 +481,7 @@ Multiple shadows: `shadow="1x 1x 2x #dark.20, inset 0 0 4x #dark.10"`
|
|
|
468
481
|
|
|
469
482
|
### `preset`
|
|
470
483
|
|
|
471
|
-
Typography preset that sets font-size, line-height, letter-spacing, font-weight, font-style,
|
|
484
|
+
Typography preset that sets font-size, line-height, letter-spacing, font-weight, font-style, text-transform, and font-family (unless `font` or `fontFamily` is set) from named design tokens. It also sets the `--bold-font-weight` and `--icon-size` variables that `strong` and `icon` read.
|
|
472
485
|
|
|
473
486
|
**Syntax:** `name`, `name / modifier...`, or `modifier...` (shorthand)
|
|
474
487
|
|
|
@@ -480,10 +493,11 @@ Use `/` to separate the preset name from one or more space-separated modifiers.
|
|
|
480
493
|
|
|
481
494
|
| Modifier | Effect |
|
|
482
495
|
|----------|--------|
|
|
483
|
-
| `strong` (or `bold`) | Sets `font-weight` to bold (from `$bold-font-weight` token) |
|
|
496
|
+
| `strong` (or `bold`) | Sets `font-weight` to bold (from `$bold-font-weight` token, `700` until your tokens define it) |
|
|
484
497
|
| `italic` | Sets `font-style: italic` |
|
|
485
498
|
| `icon` | Sets font-size and line-height to icon size |
|
|
486
499
|
| `tight` | Sets line-height equal to font-size |
|
|
500
|
+
| `normal` | Sets `line-height: normal` |
|
|
487
501
|
|
|
488
502
|
```jsx
|
|
489
503
|
preset="h1" // heading 1
|
|
@@ -503,9 +517,9 @@ Font family with design-system fallback. Preferred over `fontFamily`.
|
|
|
503
517
|
|
|
504
518
|
| Value | Effect |
|
|
505
519
|
|-------|--------|
|
|
506
|
-
| `"monospace"` | Monospace
|
|
507
|
-
| `true` | Default
|
|
508
|
-
| `"CustomFont"` | Custom font
|
|
520
|
+
| `"monospace"` | Monospace stack from `$font-mono`, falling back to the built-in `$font-mono-fallback` |
|
|
521
|
+
| `true` | Default sans stack from `$font-sans`, falling back to `$font-sans-fallback` |
|
|
522
|
+
| `"CustomFont"` | Custom font followed by the `$font-sans` stack |
|
|
509
523
|
|
|
510
524
|
`fontFamily` is supported as a direct pass-through without fallback logic.
|
|
511
525
|
|
|
@@ -581,12 +595,14 @@ When easing is provided without a duration, the default timing variable is used
|
|
|
581
595
|
| `width` | `width`, `min-width`, `max-width` |
|
|
582
596
|
| `height` | `height`, `min-height`, `max-height` |
|
|
583
597
|
| `gap` | `gap`, `margin` |
|
|
584
|
-
| `zIndex` | `z-index` |
|
|
598
|
+
| `zIndex` | `z-index` (same as writing `z-index`) |
|
|
585
599
|
| `inset` | `inset`, `top`, `right`, `bottom`, `left` |
|
|
586
600
|
|
|
601
|
+
Any other name passes through as a CSS property.
|
|
602
|
+
|
|
587
603
|
When two entries cover the same property, an entry that names that one property wins over a group such as `theme`, in either order: `opacity 120ms ease-in-out, theme` keeps the opacity timing. Otherwise the later entry wins, as in CSS.
|
|
588
604
|
|
|
589
|
-
Default timing: `$transition` (or `${name}-transition` with `$transition` fallback per semantic name). Prefer omitting the duration or using a duration token instead of repeating raw time values across components. Explicit zero can disable motion.
|
|
605
|
+
Default timing: `$transition` (or `${name}-transition` with `$transition` fallback per semantic name). `$transition` is `80ms` until your tokens define it. Prefer omitting the duration or using a duration token instead of repeating raw time values across components. Explicit zero can disable motion.
|
|
590
606
|
|
|
591
607
|
```jsx
|
|
592
608
|
transition="theme"
|
|
@@ -674,11 +690,11 @@ plain CSS shorthand order, like `padding`. See the [`padding` rule](#padding).
|
|
|
674
690
|
|
|
675
691
|
| Value | Effect |
|
|
676
692
|
|-------|--------|
|
|
677
|
-
| `"top"` | Fade top edge, default width
|
|
693
|
+
| `"top"` | Fade top edge, default width `2x`, all other edges unfaded |
|
|
678
694
|
| `"2x left right"` | Fade left and right edges with `2x` width, top/bottom unfaded |
|
|
679
695
|
| `"3x 1x"` | All edges faded — top/bottom `3x`, left/right `1x` (CSS shorthand order) |
|
|
680
696
|
| `"3x top, 1x bottom"` | Fade top with `3x` width, bottom with `1x` width |
|
|
681
|
-
| `"2x #
|
|
697
|
+
| `"2x #clear #dark"` | All edges faded with `2x` width, from `#clear` to `#dark` |
|
|
682
698
|
| `"top #a #b, bottom #c #d"` | Top fades from `#a` to `#b`, bottom fades from `#c` to `#d` |
|
|
683
699
|
|
|
684
700
|
Colors are optional: first = transparent mask start, second = opaque mask end.
|
package/docs/tasty-static.md
CHANGED
|
@@ -8,30 +8,36 @@ Choose `tastyStatic` specifically when styles must be generated during the build
|
|
|
8
8
|
|
|
9
9
|
## When to Use
|
|
10
10
|
|
|
11
|
-
- **
|
|
12
|
-
- **No
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
11
|
+
- **CSS that must exist before anything renders** — static sites, landing pages, and HTML served from a CDN get one stylesheet generated at build time
|
|
12
|
+
- **No React at runtime** — `tastyStatic` returns class names, so plain DOM code or any templating that sets `class` can use them; the [Programmatic API](#programmatic-api) covers frameworks Babel does not process
|
|
13
|
+
- **Class-name objects instead of components** — extend them with `tastyStatic(base, styles)` and pass them wherever a `className` goes
|
|
14
|
+
- **Self-contained packages** — [inject mode](#inject-mode) embeds the CSS in the JavaScript, so consumers have no stylesheet to wire up
|
|
15
|
+
|
|
16
|
+
If the styles depend on props, keep `tasty()`: rendered only on the server, it also ships no styling runtime (see [Server-Side Rendering](ssr.md)).
|
|
15
17
|
|
|
16
18
|
## Requirements
|
|
17
19
|
|
|
18
20
|
Build-time extraction is part of the main `@tenphi/tasty` package but requires additional peer dependencies depending on your setup:
|
|
19
21
|
|
|
20
|
-
| Dependency | Version | Required for
|
|
21
|
-
| ---------------------------- | ------- |
|
|
22
|
-
| `@babel/core` | >= 7.24 | Babel plugin (`@tenphi/tasty/babel-plugin`)
|
|
23
|
-
| `@babel/helper-plugin-utils` | >= 7.24 | Babel plugin
|
|
24
|
-
| `@babel/types` | >= 7.24 | Babel plugin
|
|
25
|
-
| `jiti` | >= 2.6 |
|
|
22
|
+
| Dependency | Version | Required for |
|
|
23
|
+
| ---------------------------- | ------- | ---------------------------------------------------- |
|
|
24
|
+
| `@babel/core` | >= 7.24 | Babel plugin (`@tenphi/tasty/babel-plugin`) |
|
|
25
|
+
| `@babel/helper-plugin-utils` | >= 7.24 | Babel plugin |
|
|
26
|
+
| `@babel/types` | >= 7.24 | Babel plugin |
|
|
27
|
+
| `jiti` | >= 2.6 | `configFile` only (Babel plugin and Next.js wrapper) |
|
|
28
|
+
| `babel-loader` | any | Next.js wrapper (`@tenphi/tasty/zero/next`) |
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
The Babel packages and `jiti` are optional peer dependencies of `@tenphi/tasty`; `babel-loader` is resolved from your project. `jiti` is loaded only to read a `configFile`, so a setup that passes `config` directly does not need it; without it, `configFile` fails with an error that says to install it. Install what your setup requires:
|
|
28
31
|
|
|
29
32
|
```bash
|
|
30
|
-
#
|
|
33
|
+
# Any Babel-based setup (Vite, custom Babel config, etc.)
|
|
31
34
|
pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types
|
|
32
35
|
|
|
33
|
-
#
|
|
34
|
-
pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types
|
|
36
|
+
# Next.js
|
|
37
|
+
pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types babel-loader
|
|
38
|
+
|
|
39
|
+
# Either, with configFile
|
|
40
|
+
pnpm add -D jiti
|
|
35
41
|
```
|
|
36
42
|
|
|
37
43
|
---
|
|
@@ -52,13 +58,15 @@ const button = tastyStatic({
|
|
|
52
58
|
radius: '1r',
|
|
53
59
|
});
|
|
54
60
|
|
|
55
|
-
// Use in JSX
|
|
56
|
-
<button className={button}>Click me</button
|
|
61
|
+
// Use in JSX
|
|
62
|
+
<button className={button.className}>Click me</button>;
|
|
57
63
|
|
|
58
|
-
//
|
|
59
|
-
|
|
64
|
+
// toString() returns the class name, for template strings and plain JS
|
|
65
|
+
element.className = `${button} is-active`;
|
|
60
66
|
```
|
|
61
67
|
|
|
68
|
+
In TSX, pass `button.className`: React types `className` as `string`, so passing the `StaticStyle` object fails type-checking even though it works at runtime.
|
|
69
|
+
|
|
62
70
|
---
|
|
63
71
|
|
|
64
72
|
## API Reference
|
|
@@ -168,7 +176,7 @@ module.exports = {
|
|
|
168
176
|
| -------------------------- | ------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
169
177
|
| `output` | `string` | `'tasty.css'` | Path for generated CSS file |
|
|
170
178
|
| `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS (see [Inject Mode](#inject-mode)) |
|
|
171
|
-
| `configFile` | `string` | — | Absolute path to a TS/JS module that default-exports a `TastyZeroConfig` object. JSON-serializable alternative to `config` — required for Turbopack.
|
|
179
|
+
| `configFile` | `string` | — | Absolute path to a TS/JS module that default-exports a `TastyZeroConfig` object. JSON-serializable alternative to `config` — required for Turbopack. Loaded with the optional `jiti` peer. |
|
|
172
180
|
| `config` | `TastyZeroConfig \| () => TastyZeroConfig` | `{}` | Inline config object or factory function. Takes precedence over `configFile`. |
|
|
173
181
|
| `configDeps` | `string[]` | `[]` | Absolute file paths that affect config (for cache invalidation) |
|
|
174
182
|
| `injectImport` | `boolean` | `true` | Replace `@tenphi/tasty/static` imports with an import of the generated CSS file. Set to `false` to manage CSS imports manually. |
|
|
@@ -180,7 +188,8 @@ module.exports = {
|
|
|
180
188
|
| `config.keyframes` | `Record<string, KeyframesSteps>` | — | Global `@keyframes` definitions available to all `tastyStatic` calls |
|
|
181
189
|
| `config.fontFaces` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
|
|
182
190
|
| `config.counterStyles` | `Record<string, CounterStyleDescriptors>` | — | Global `@counter-style` definitions |
|
|
183
|
-
| `config.
|
|
191
|
+
| `config.properties` | `Record<string, PropertyDefinition>` | — | Global `@property` definitions, written with Tasty's [default properties](dsl.md#default-properties) |
|
|
192
|
+
| `config.units` | `Record<string, string \| UnitHandler>` | — | Custom units for the style parser (merged with built-ins). E.g. `{ u: 'var(--u)' }` makes `2u` compile to `calc(2 * var(--u))`. Native CSS units need no entry |
|
|
184
193
|
| `config.functions` | `Record<string, FunctionDefinition \| Function>` | — | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
|
|
185
194
|
| `config.polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills. `functions: true` inlines `@function` calls into plain CSS at build time |
|
|
186
195
|
| `config.plugins` | `TastyPlugin[]` | — | Plugins that extend tasty with custom functions, units, states, and handlers |
|
|
@@ -244,7 +253,7 @@ const card = tastyStatic({
|
|
|
244
253
|
color: '#text',
|
|
245
254
|
});
|
|
246
255
|
|
|
247
|
-
<div className={card}>Styled card</div>;
|
|
256
|
+
<div className={card.className}>Styled card</div>;
|
|
248
257
|
```
|
|
249
258
|
|
|
250
259
|
---
|
|
@@ -281,12 +290,12 @@ export default withTastyZero({
|
|
|
281
290
|
|
|
282
291
|
Starting with Next.js 16, Turbopack is the default bundler. `withTastyZero` supports it out of the box by injecting `turbopack.rules` with `babel-loader` and JSON-serializable options.
|
|
283
292
|
|
|
284
|
-
The `configFile` option is key for Turbopack — it passes a file path (JSON-serializable) instead of a function, and the Babel plugin loads the config internally via jiti.
|
|
293
|
+
The `configFile` option is key for Turbopack — it passes a file path (JSON-serializable) instead of a function, and the Babel plugin loads the config internally via `jiti`, which must be installed.
|
|
285
294
|
|
|
286
|
-
**Requirements**: `babel-loader` must be installed in your project:
|
|
295
|
+
**Requirements**: `babel-loader` must be installed in your project (see [Requirements](#requirements)):
|
|
287
296
|
|
|
288
297
|
```bash
|
|
289
|
-
pnpm add babel-loader
|
|
298
|
+
pnpm add -D babel-loader
|
|
290
299
|
```
|
|
291
300
|
|
|
292
301
|
### CSS Injection
|
|
@@ -324,42 +333,72 @@ extractStylesWithChunks({ display: 'flex', gap: '1u' });
|
|
|
324
333
|
// → [{ className: 'ts…', css: '.ts….ts… { … }' }]
|
|
325
334
|
```
|
|
326
335
|
|
|
327
|
-
`configure()` takes the same options as the Babel plugin's `config` (see [Plugin Options](#plugin-options)) and replaces the previous configuration on each call; `resetConfig()` returns to the defaults. Options that shape the extracted rules apply — `states`, `units`, parse `functions`, `handlers`, `replaceTokens`, `recipes`, `plugins`, `namePrefix`. Definitions that become at-rules or global CSS of their own are not emitted: `tokens`, `globalStyles`, `fontFaces`, `counterStyles`, `properties` and `$$` `@function` definitions. Render tokens and global styles with `extractStylesForSelector(':root', tokens)` and `extractStylesForSelector(selector, styles)`.
|
|
336
|
+
`configure()` takes the same options as the Babel plugin's `config` (see [Plugin Options](#plugin-options)) and replaces the previous configuration on each call; `resetConfig()` returns to the defaults. Options that shape the extracted rules apply — `states`, `units`, parse `functions`, `handlers`, `replaceTokens`, `recipes`, `plugins`, `namePrefix`. Definitions that become at-rules or global CSS of their own are not emitted with the rules: `tokens`, `globalStyles`, `fontFaces`, `counterStyles`, `properties` and `$$` `@function` definitions. Render tokens and global styles with `extractStylesForSelector(':root', tokens)` and `extractStylesForSelector(selector, styles)`.
|
|
337
|
+
|
|
338
|
+
`extractConfigProperties()` returns the `@property` rules the Babel plugin writes at the top of its output: Tasty's [default set](dsl.md#default-properties) (`#border`, `#outline`, `$gap`, `$radius`, `$transition`, …) overlaid with the configured `properties`, or with the `properties` map you pass it. Emit them once per stylesheet. Style handlers read several of these tokens with no fallback of their own (`border: true` reads `#border`, `transition` reads `$transition`), so without them those declarations resolve to nothing.
|
|
328
339
|
|
|
329
340
|
The configuration is process-wide and shared with the Babel plugin and the runtime `configure()` from `@tenphi/tasty`. The extractors re-apply their own configuration when the Babel plugin replaced it, but not after a runtime `configure()` — don't mix the runtime and build-time configuration in one process.
|
|
330
341
|
|
|
331
342
|
`extractStylesForSelector()` output starts with the `@keyframes` its rules animate — local `@keyframes` and configured `keyframes` — under hashed names the `animation` declarations are rewritten to. `extractStylesWithChunks()` returns class rules only.
|
|
332
343
|
|
|
344
|
+
To write the results to a file the way the Babel plugin does, use `createCSSWriter()`. It deduplicates blocks by key and prepends the generated-file header:
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
import {
|
|
348
|
+
createCSSWriter,
|
|
349
|
+
extractConfigProperties,
|
|
350
|
+
extractStylesWithChunks,
|
|
351
|
+
} from '@tenphi/tasty/zero';
|
|
352
|
+
|
|
353
|
+
const writer = createCSSWriter('dist/tasty.css', { devMode: true });
|
|
354
|
+
|
|
355
|
+
for (const prop of extractConfigProperties()) {
|
|
356
|
+
writer.add(`@property:${prop.name}`, prop.css);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
for (const chunk of extractStylesWithChunks({ display: 'flex', gap: '1u' })) {
|
|
360
|
+
writer.add(chunk.className, chunk.css, 'src/card.ts'); // source is a devMode comment
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
writer.write(); // also: has(key), getCSS(), clear(), getOutputPath()
|
|
364
|
+
```
|
|
365
|
+
|
|
333
366
|
---
|
|
334
367
|
|
|
335
368
|
## Vite Integration
|
|
336
369
|
|
|
370
|
+
`@vitejs/plugin-react` 6 no longer runs Babel; add it with `@rolldown/plugin-babel` (`pnpm add -D @rolldown/plugin-babel`):
|
|
371
|
+
|
|
337
372
|
```typescript
|
|
338
373
|
// vite.config.ts
|
|
339
374
|
import { defineConfig } from 'vite';
|
|
340
375
|
import react from '@vitejs/plugin-react';
|
|
376
|
+
import babel from '@rolldown/plugin-babel';
|
|
341
377
|
|
|
342
378
|
export default defineConfig({
|
|
343
379
|
plugins: [
|
|
344
|
-
react(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
},
|
|
380
|
+
react(),
|
|
381
|
+
babel({
|
|
382
|
+
plugins: [
|
|
383
|
+
[
|
|
384
|
+
'@tenphi/tasty/babel-plugin',
|
|
385
|
+
{
|
|
386
|
+
output: 'src/tasty.css',
|
|
387
|
+
config: {
|
|
388
|
+
states: { '@mobile': '@media(w < 768px)' },
|
|
354
389
|
},
|
|
355
|
-
|
|
390
|
+
},
|
|
356
391
|
],
|
|
357
|
-
|
|
392
|
+
],
|
|
358
393
|
}),
|
|
359
394
|
],
|
|
360
395
|
});
|
|
361
396
|
```
|
|
362
397
|
|
|
398
|
+
With `@vitejs/plugin-react` 5 or older, pass the same `plugins` array to `react({ babel: { plugins } })` instead.
|
|
399
|
+
|
|
400
|
+
Keep `output` outside `public/`: the plugin replaces each `@tenphi/tasty/static` import with an import of the generated file, and Vite does not let JavaScript import files from `public/`. Vite then bundles the CSS like any other stylesheet.
|
|
401
|
+
|
|
363
402
|
---
|
|
364
403
|
|
|
365
404
|
## Build Transformation
|
|
@@ -377,44 +416,67 @@ const button = tastyStatic({
|
|
|
377
416
|
|
|
378
417
|
tastyStatic('.heading', { preset: 'h1' });
|
|
379
418
|
|
|
380
|
-
export const Button = () => <button className={button}>Click</button>;
|
|
419
|
+
export const Button = () => <button className={button.className}>Click</button>;
|
|
381
420
|
```
|
|
382
421
|
|
|
383
422
|
### After (Production Build)
|
|
384
423
|
|
|
385
424
|
```tsx
|
|
425
|
+
import './tasty.css';
|
|
426
|
+
|
|
386
427
|
const button = {
|
|
387
|
-
className: '
|
|
428
|
+
className: 'ts3f783b ts070801',
|
|
388
429
|
styles: { padding: '2x 4x', fill: '#purple', color: '#white' },
|
|
389
430
|
toString() {
|
|
390
431
|
return this.className;
|
|
391
432
|
},
|
|
392
433
|
};
|
|
393
434
|
|
|
394
|
-
export const Button = () => <button className={button}>Click</button>;
|
|
435
|
+
export const Button = () => <button className={button.className}>Click</button>;
|
|
395
436
|
```
|
|
396
437
|
|
|
438
|
+
The `@tenphi/tasty/static` import becomes an import of the generated file (relative to the source file), and the selector-mode call is removed.
|
|
439
|
+
|
|
397
440
|
### Generated CSS (tasty.css)
|
|
398
441
|
|
|
399
442
|
```css
|
|
400
443
|
/* Generated by @tenphi/tasty/zero - DO NOT EDIT */
|
|
401
444
|
|
|
402
|
-
|
|
403
|
-
|
|
445
|
+
@property --tasty-second-fill-color {
|
|
446
|
+
syntax: '<color>';
|
|
447
|
+
inherits: false;
|
|
448
|
+
initial-value: transparent;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
@property --current-color {
|
|
452
|
+
syntax: '<color>';
|
|
453
|
+
inherits: true;
|
|
454
|
+
initial-value: currentcolor;
|
|
404
455
|
}
|
|
405
456
|
|
|
406
|
-
.
|
|
407
|
-
|
|
408
|
-
|
|
457
|
+
/* …the rest of Tasty's default @property rules (--white-color, --border-color, --gap, --transition, …), then config.properties */
|
|
458
|
+
|
|
459
|
+
.ts3f783b.ts3f783b {
|
|
460
|
+
color: var(--white-color);
|
|
461
|
+
--current-color: var(--white-color);
|
|
409
462
|
}
|
|
410
463
|
|
|
411
|
-
.
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
464
|
+
.ts3f783b.ts3f783b {
|
|
465
|
+
background-color: var(--purple-color);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.ts070801.ts070801 {
|
|
469
|
+
padding: 16px 32px;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.heading {
|
|
473
|
+
font-size: var(--h1-font-size, var(--default-font-size));
|
|
474
|
+
/* …line-height, letter-spacing, font-weight, and the rest of the h1 preset */
|
|
415
475
|
}
|
|
416
476
|
```
|
|
417
477
|
|
|
478
|
+
The file starts with Tasty's [default `@property` rules](dsl.md#default-properties) and your `config.properties`, written once. Styles are split into chunks (here appearance and spacing), each with its own class. Color tokens compile to custom properties: `#purple` becomes `var(--purple-color)`. Define it in `config.tokens` and the plugin writes it to `:root` at the top of the same file. Units are literal (`2x` is `16px`). Selector-mode rules use the selector as written, without the doubled specificity of class rules.
|
|
479
|
+
|
|
418
480
|
---
|
|
419
481
|
|
|
420
482
|
## Inject Mode
|
|
@@ -485,22 +547,29 @@ tastyStatic('.heading', { preset: 'h1' });
|
|
|
485
547
|
```tsx
|
|
486
548
|
import { injectCSS as _$i } from '@tenphi/tasty/static/inject';
|
|
487
549
|
|
|
550
|
+
_$i(
|
|
551
|
+
'@property',
|
|
552
|
+
'@property --tasty-second-fill-color { … }\n@property --current-color { … }\n…',
|
|
553
|
+
);
|
|
554
|
+
|
|
488
555
|
const button =
|
|
489
556
|
(_$i(
|
|
490
|
-
'
|
|
491
|
-
'.
|
|
557
|
+
'tsa903d6 ts070801',
|
|
558
|
+
'.tsa903d6.tsa903d6 { background-color: var(--purple-color); }\n.ts070801.ts070801 { padding: 16px 32px; }',
|
|
492
559
|
),
|
|
493
560
|
{
|
|
494
|
-
className: '
|
|
561
|
+
className: 'tsa903d6 ts070801',
|
|
495
562
|
styles: { padding: '2x 4x', fill: '#purple' },
|
|
496
563
|
toString() {
|
|
497
564
|
return this.className;
|
|
498
565
|
},
|
|
499
566
|
});
|
|
500
567
|
|
|
501
|
-
_$i('.heading', '.heading{font-size:
|
|
568
|
+
_$i('.heading', '.heading { font-size: var(--h1-font-size, …); … }');
|
|
502
569
|
```
|
|
503
570
|
|
|
571
|
+
Each file that calls `tastyStatic()` starts by injecting Tasty's default `@property` rules and your `config.properties` under the `@property` id. `injectCSS()` skips an id it has already injected, so the page gets them once.
|
|
572
|
+
|
|
504
573
|
### Dev Mode / HMR
|
|
505
574
|
|
|
506
575
|
Class names are content-hashed (`ts` + MD5). When styles change, a new hash produces a new `_$i` call that injects fresh CSS. The injector deduplicates by id, so unchanged styles are skipped. Old CSS stays in the DOM but is harmless since no elements reference those class names.
|
|
@@ -558,7 +627,7 @@ const card = tastyStatic({
|
|
|
558
627
|
|
|
559
628
|
## Extending Style Types (TypeScript)
|
|
560
629
|
|
|
561
|
-
If you add custom style properties, use module augmentation so `tastyStatic` recognizes them too. See [
|
|
630
|
+
If you add custom style properties, use module augmentation so `tastyStatic` recognizes them too. See [TypeScript](configuration.md#typescript) in the configuration docs.
|
|
562
631
|
|
|
563
632
|
---
|
|
564
633
|
|
|
@@ -580,10 +649,12 @@ const card = tastyStatic({
|
|
|
580
649
|
});
|
|
581
650
|
|
|
582
651
|
<div
|
|
583
|
-
className={card}
|
|
584
|
-
style={
|
|
585
|
-
|
|
586
|
-
|
|
652
|
+
className={card.className}
|
|
653
|
+
style={
|
|
654
|
+
{
|
|
655
|
+
'--card-bg': isActive ? 'var(--purple-color)' : 'var(--white-color)',
|
|
656
|
+
} as React.CSSProperties
|
|
657
|
+
}
|
|
587
658
|
/>;
|
|
588
659
|
```
|
|
589
660
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenphi/tasty",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "A design-system-integrated styling system and DSL for concise, state-aware UI styling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -62,6 +62,11 @@
|
|
|
62
62
|
"import": "./dist/ssr/astro.js",
|
|
63
63
|
"default": "./dist/ssr/astro.js"
|
|
64
64
|
},
|
|
65
|
+
"./ssr/client": {
|
|
66
|
+
"types": "./dist/ssr/client.d.ts",
|
|
67
|
+
"import": "./dist/ssr/client.js",
|
|
68
|
+
"default": "./dist/ssr/client.js"
|
|
69
|
+
},
|
|
65
70
|
"./ssr/astro-client": {
|
|
66
71
|
"types": "./dist/ssr/astro-client.d.ts",
|
|
67
72
|
"import": "./dist/ssr/astro-client.js",
|
|
@@ -169,7 +174,7 @@
|
|
|
169
174
|
"@eslint/js": "^10.0.1",
|
|
170
175
|
"@size-limit/esbuild": "^14.0.0",
|
|
171
176
|
"@size-limit/file": "^14.0.0",
|
|
172
|
-
"@tenphi/eslint-plugin-tasty": "^1.1
|
|
177
|
+
"@tenphi/eslint-plugin-tasty": "^1.5.1",
|
|
173
178
|
"@testing-library/jest-dom": "^7.0.1",
|
|
174
179
|
"@testing-library/react": "^16.3.3",
|
|
175
180
|
"@types/babel__core": "^7.20.5",
|
|
@@ -200,13 +205,13 @@
|
|
|
200
205
|
"name": "main (import *)",
|
|
201
206
|
"path": "dist/index.js",
|
|
202
207
|
"import": "*",
|
|
203
|
-
"limit": "
|
|
208
|
+
"limit": "59.65 kB"
|
|
204
209
|
},
|
|
205
210
|
{
|
|
206
211
|
"name": "main (tasty)",
|
|
207
212
|
"path": "dist/index.js",
|
|
208
213
|
"import": "{ tasty }",
|
|
209
|
-
"limit": "
|
|
214
|
+
"limit": "52.67 kB"
|
|
210
215
|
},
|
|
211
216
|
{
|
|
212
217
|
"name": "main (StyleParser)",
|
|
@@ -224,7 +229,7 @@
|
|
|
224
229
|
"name": "main (useRawCSS)",
|
|
225
230
|
"path": "dist/index.js",
|
|
226
231
|
"import": "{ useRawCSS }",
|
|
227
|
-
"limit": "
|
|
232
|
+
"limit": "32.48 kB"
|
|
228
233
|
},
|
|
229
234
|
{
|
|
230
235
|
"name": "core (import *)",
|
|
@@ -247,7 +252,7 @@
|
|
|
247
252
|
"path",
|
|
248
253
|
"crypto"
|
|
249
254
|
],
|
|
250
|
-
"limit": "
|
|
255
|
+
"limit": "39.13 kB"
|
|
251
256
|
},
|
|
252
257
|
{
|
|
253
258
|
"name": "babel-plugin",
|
|
@@ -256,9 +261,11 @@
|
|
|
256
261
|
"ignore": [
|
|
257
262
|
"fs",
|
|
258
263
|
"path",
|
|
259
|
-
"crypto"
|
|
264
|
+
"crypto",
|
|
265
|
+
"node:module",
|
|
266
|
+
"node:path"
|
|
260
267
|
],
|
|
261
|
-
"limit": "
|
|
268
|
+
"limit": "43.55 kB"
|
|
262
269
|
},
|
|
263
270
|
{
|
|
264
271
|
"name": "astro client",
|
|
@@ -266,6 +273,12 @@
|
|
|
266
273
|
"import": "*",
|
|
267
274
|
"limit": "0.5 kB"
|
|
268
275
|
},
|
|
276
|
+
{
|
|
277
|
+
"name": "ssr client",
|
|
278
|
+
"path": "dist/ssr/client.js",
|
|
279
|
+
"import": "{ hydrateTastyClasses }",
|
|
280
|
+
"limit": "0.5 kB"
|
|
281
|
+
},
|
|
269
282
|
{
|
|
270
283
|
"name": "Next.js config",
|
|
271
284
|
"path": "dist/ssr/next-config.js",
|
|
@@ -276,7 +289,7 @@
|
|
|
276
289
|
"node:module",
|
|
277
290
|
"node:path"
|
|
278
291
|
],
|
|
279
|
-
"limit": "
|
|
292
|
+
"limit": "40.18 kB"
|
|
280
293
|
}
|
|
281
294
|
],
|
|
282
295
|
"scripts": {
|
|
@@ -298,6 +311,7 @@
|
|
|
298
311
|
"bench:overhead": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-overhead.bench.tsx",
|
|
299
312
|
"bench:injection": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-injection.bench.ts",
|
|
300
313
|
"bench:interaction": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-interaction.bench.tsx",
|
|
314
|
+
"bench:tree": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-tree.bench.tsx",
|
|
301
315
|
"bench:cold-start": "node scripts/cold-start/index.mjs",
|
|
302
316
|
"changeset": "changeset",
|
|
303
317
|
"version": "changeset version",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
//#region src/ssr/async-storage.ts
|
|
3
|
-
const ALS_KEY = "__tasty_ssr_als__";
|
|
4
|
-
function getSharedStorage() {
|
|
5
|
-
const g = globalThis;
|
|
6
|
-
if (!g[ALS_KEY]) g[ALS_KEY] = new AsyncLocalStorage();
|
|
7
|
-
return g[ALS_KEY];
|
|
8
|
-
}
|
|
9
|
-
function runWithCollector(collector, fn) {
|
|
10
|
-
return getSharedStorage().run(collector, fn);
|
|
11
|
-
}
|
|
12
|
-
function getSSRCollector() {
|
|
13
|
-
const storage = getSharedStorage();
|
|
14
|
-
if (typeof storage?.getStore !== "function") return null;
|
|
15
|
-
return storage.getStore() ?? null;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { runWithCollector as n, getSSRCollector as t };
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=async-storage-CG5HnUT5.js.map
|