clava 0.6.2 → 0.6.3
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/CHANGELOG.md +22 -0
- package/README.md +28 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +127 -129
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +243 -202
- package/src/refine-warning.ts +4 -3
- package/src/utils.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# clava
|
|
2
2
|
|
|
3
|
+
## 0.6.3
|
|
4
|
+
|
|
5
|
+
### Improved runtime performance of the `refine` chain
|
|
6
|
+
|
|
7
|
+
Per-render benchmarks improve roughly 15% to 20% for a component that extends nothing and whose [`refine`](https://clava.style/docs/reference/refine) callback does not change variants. A component that does more work per render gains a smaller share of that improvement. The minified bundle is 2.2% smaller. There are no public API or behavior changes.
|
|
8
|
+
|
|
9
|
+
Resolving a component whose chain contains [`refine`](https://clava.style/docs/reference/refine) or a computed `defaultVariants` entry allocated the bookkeeping for a variant change on every call, even when no callback changed one. Each piece of that bookkeeping is now created only when something reads it: the record of assigned variants when a callback assigns one, and the copy of your props when a computed default reads them.
|
|
10
|
+
|
|
11
|
+
### Improved runtime performance of re-running the `refine` chain
|
|
12
|
+
|
|
13
|
+
Per-render benchmarks improve roughly 15% to 20% for a component whose [`refine`](https://clava.style/docs/reference/refine) callback or computed `defaultVariants` entry changes a variant, and the [`getVariants()`](https://clava.style/docs/reference/getVariants) benchmark for such a component is roughly twice as fast, measured on the unbundled `dist` under Node. The minified bundle is 0.3% smaller. There are no public API changes and no change to supported behavior.
|
|
14
|
+
|
|
15
|
+
When a callback changes a variant, Clava re-runs the chain until the variants stop changing, and each extra pass cost far more than the work it repeated. Two things caused that. A development-only check read `process.env.NODE_ENV` on every pass that changed a variant, which in Node is an environment lookup rather than a property load. Separately, the record tracking a callback's assignments was seeded with a full copy of the resolved variants. The check now runs only as a chain approaches its iteration limit, and the record holds only the keys that changed.
|
|
16
|
+
|
|
17
|
+
A bundler that replaces `process.env.NODE_ENV` already removes that check from both versions, so a bundled application gains only from the record change, which applies where a [`refine`](https://clava.style/docs/reference/refine) callback calls `setVariants`.
|
|
18
|
+
|
|
19
|
+
### Ignored inherited property values in variants, props, and configuration
|
|
20
|
+
|
|
21
|
+
[`cv`](https://clava.style/docs/reference/cv) and [`create`](https://clava.style/docs/reference/create) no longer take a class, a style, a variant value, or a configuration setting from a key inherited from `Object.prototype`.
|
|
22
|
+
|
|
23
|
+
A variant named after an `Object.prototype` member, such as `constructor` or `toString`, now resolves like any other variant.
|
|
24
|
+
|
|
3
25
|
## 0.6.2
|
|
4
26
|
|
|
5
27
|
- Fixed `TS2590` and `TS2345` type errors when a framework style value, such as React's `CSSProperties` or Solid's `JSX.CSSProperties`, is passed to a [`cv`](https://clava.style/docs/reference/cv) component.
|
package/README.md
CHANGED
|
@@ -549,7 +549,7 @@ The package also exports `ClassValue`, `StyleValue`, `StyleClassProps`, `StyleCl
|
|
|
549
549
|
|
|
550
550
|
## Comparison
|
|
551
551
|
|
|
552
|
-
This table compares Clava with the packages used by the repository's alternative benchmark: `class-variance-authority@0.7.1`, `cva@1.0.0-beta.
|
|
552
|
+
This table compares Clava with the packages used by the repository's alternative benchmark: `class-variance-authority@0.7.1`, `cva@1.0.0-beta.8`, `tailwind-variants/lite@3.3.1`, and `tailwind-variants@3.3.1`.
|
|
553
553
|
|
|
554
554
|
| Feature | Clava | CVA v0 | CVA v1 beta | TV Lite | TV |
|
|
555
555
|
| ---------------------------------------------------- | -------------- | ------------------ | ------------------ | ------------------ | ------------------ |
|
|
@@ -565,18 +565,35 @@ This table compares Clava with the packages used by the repository's alternative
|
|
|
565
565
|
| Dedicated slots API | No | No | No | Yes | Yes |
|
|
566
566
|
| Built-in Tailwind conflict merging | No | No | No | No | Yes |
|
|
567
567
|
|
|
568
|
-
|
|
568
|
+
Clava has no built-in Tailwind conflict merging. [`create({ transformClass })`](#create-and-cx) routes every generated class string through a merger such as `tailwind-merge` when you need one.
|
|
569
569
|
|
|
570
|
-
|
|
571
|
-
| ------------------------------------ | --------: | ----------------: |
|
|
572
|
-
| `clava@0.6.1` | 1,064,359 | 1.00x |
|
|
573
|
-
| `clava@0.6.1 + tailwind-merge@3.6.0` | 505,454 | 2.11x slower |
|
|
574
|
-
| `class-variance-authority@0.7.1` | 435,382 | 2.44x slower |
|
|
575
|
-
| `tailwind-variants/lite@3.2.2` | 371,763 | 2.86x slower |
|
|
576
|
-
| `cva@1.0.0-beta.6` | 328,566 | 3.24x slower |
|
|
577
|
-
| `tailwind-variants@3.2.2` | 274,351 | 3.88x slower |
|
|
570
|
+
The `pnpm perf-alternatives` benchmark resolves a composed Tailwind-style button with inherited variants and defaults. It runs in two groups so each group compares equivalent work, since cross-variant conditions cost every library something different. On Node v24.18.0, Vitest reported these results, where higher ops/sec is better.
|
|
578
571
|
|
|
579
|
-
|
|
572
|
+
The first group composes three layers with no cross-variant conditions. `class-variance-authority` has no compose helper, so its build merges the three layers into a single config.
|
|
573
|
+
|
|
574
|
+
| Package | Ops/sec | Relative to Clava |
|
|
575
|
+
| -------------------------------- | --------: | ----------------: |
|
|
576
|
+
| `clava@0.6.2` | 2,384,411 | 1.00x |
|
|
577
|
+
| `class-variance-authority@0.7.1` | 1,872,892 | 1.27x slower |
|
|
578
|
+
| `tailwind-variants@3.3.1` | 1,312,965 | 1.82x slower |
|
|
579
|
+
| `tailwind-variants/lite@3.3.1` | 1,308,798 | 1.82x slower |
|
|
580
|
+
| `cva@1.0.0-beta.8` | 408,730 | 5.83x slower |
|
|
581
|
+
|
|
582
|
+
The second group adds the same cross-variant conditions at the interaction and product layers. Clava expresses them with `refine`, and every other library with `compoundVariants`.
|
|
583
|
+
|
|
584
|
+
| Package | Ops/sec | Relative to Clava |
|
|
585
|
+
| -------------------------------- | --------: | ----------------: |
|
|
586
|
+
| `clava@0.6.2` | 1,335,204 | 1.00x |
|
|
587
|
+
| `tailwind-variants/lite@3.3.1` | 568,960 | 2.35x slower |
|
|
588
|
+
| `tailwind-variants@3.3.1` | 563,659 | 2.37x slower |
|
|
589
|
+
| `class-variance-authority@0.7.1` | 500,557 | 2.67x slower |
|
|
590
|
+
| `cva@1.0.0-beta.8` | 313,641 | 4.26x slower |
|
|
591
|
+
|
|
592
|
+
Dividing one table by the other shows what each library charges for cross-variant conditions. `cva` charges the least at 1.30x, Clava sits at 1.79x, both `tailwind-variants` entry points are near 2.31x, and `class-variance-authority` charges the most at 3.74x. The exact ratios move by several percent between runs, so read the ordering rather than the digits, and reach for the group that matches your components rather than reading either table as the whole picture.
|
|
593
|
+
|
|
594
|
+
Benchmark results vary by runtime and hardware, so treat them as a reproducible snapshot of this repository's composed-variant case rather than a universal ranking. Rows within a few percent of each other sit inside run-to-run noise, so their relative order is not meaningful. That covers the two `tailwind-variants` entry points, which land within a few percent in both groups and swap order between runs.
|
|
595
|
+
|
|
596
|
+
Both groups resolve one fixed prop set on every iteration, so every package with an internal cache serves repeated calls from cache after warmup. Both `tailwind-variants` entry points cache the resolved result by variant props. Clava, `cva`, and `class-variance-authority` have no such cache, so those rows recompute on every iteration.
|
|
580
597
|
|
|
581
598
|
## API Summary
|
|
582
599
|
|
package/dist/index.d.ts
CHANGED
|
@@ -316,7 +316,7 @@ export declare const splitProps: SplitPropsFunction;
|
|
|
316
316
|
/**
|
|
317
317
|
* Creates the cv and cx functions.
|
|
318
318
|
*/
|
|
319
|
-
export declare function create(
|
|
319
|
+
export declare function create(params?: CreateParams): {
|
|
320
320
|
cv: <V extends Variants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, E>) => CVComponent<V, E>;
|
|
321
321
|
cx: (...classes: ClassValue$1[]) => string;
|
|
322
322
|
};
|