Commit graph

5219 commits

Author SHA1 Message Date
Robin Malfait
eb7ba4f44a
bump experimental version 2023-06-19 20:20:23 -04:00
Robin Malfait
54ce83bb86
drop detect nesting 2023-06-19 20:20:07 -04:00
Robin Malfait
ad014a2ec4
disableColorOpacityUtilitiesByDefault but true 2023-06-19 20:20:07 -04:00
Robin Malfait
1797de2042
do not alias shadow to box-shadow 2023-06-19 20:20:07 -04:00
Robin Malfait
cb4fd4fcec
hardocde oxide version 2023-06-19 20:20:06 -04:00
Jordan Pittman
d58afc60d2
Support CSS-based config in the CLI 2023-06-19 17:36:14 -04:00
Jordan Pittman
ed7c448441
Push CSS-based theme resolution inside getTailwindConfig 2023-06-19 17:36:14 -04:00
Jordan Pittman
d88fd1e6e7
Do proper CSS unescaping for variables 2023-06-19 17:36:14 -04:00
Jordan Pittman
42699086c3
Fix test 2023-06-19 17:36:14 -04:00
Jordan Pittman
a347719dc8
wip 2023-06-19 17:36:14 -04:00
Jordan Pittman
526276cb97
wip 2023-06-19 17:36:14 -04:00
Jordan Pittman
bf583334a2
wip 2023-06-19 17:36:13 -04:00
Jordan Pittman
e83435295d
Simplify 2023-06-19 17:36:13 -04:00
Jordan Pittman
67fc3c30e5
Refactor 2023-06-19 17:36:13 -04:00
Jordan Pittman
7573cc7d2a
Fix stuff 2023-06-19 17:36:13 -04:00
Jordan Pittman
971253b1cf
wip 2023-06-19 17:36:13 -04:00
Jordan Pittman
b57d3d1bc5
wip 2023-06-19 17:36:13 -04:00
Jordan Pittman
665569d626
Don’t break tools using custom build 2023-06-19 17:36:13 -04:00
Jordan Pittman
dfb0958147
wip 2023-06-19 17:36:13 -04:00
Jordan Pittman
4ae6f06466
Refactor a bit 2023-06-19 17:36:13 -04:00
Jordan Pittman
8809c6a7fb
Work on implementation 2023-06-19 17:36:13 -04:00
Jordan Pittman
3c38f0a391
Expose theme variables to CSS 2023-06-19 17:36:13 -04:00
Jordan Pittman
ba7d3be00e
Refactor 2023-06-19 17:36:13 -04:00
Adam Wathan
a5305aa84e
Super hacky POC 2023-06-19 17:36:13 -04:00
depfu[bot]
776d5bf614 Update rollup to version 3.25.1 2023-06-19 06:30:22 +00:00
depfu[bot]
ac6e8733e9 Update eslint to version 8.42.0 2023-06-16 21:17:40 +00:00
depfu[bot]
a7a1f9347c Update sass to version 1.63.4 2023-06-16 17:58:29 +00:00
Robin Malfait
86f9c6f092
Simplify browserslist setup by relying on defaults (#11412)
* use `defaults` for `browserslist`

+ some features that we require for Tailwind to work.

* simplify Lightning CSS features

Always transpile `Nesting`, never transpile `LogicalProperties`.

* bump caniuse-lite (`npx browserslist@latest --update-db`)

* reflect changes in the tests

* update changelog
2023-06-12 22:07:06 +02:00
cunzaizhuyi
3be258c218
chore: make sentence smooth (#11407)
* chore: make sentence smooth

* chore: everything typo

* chore: its

* feat: e.g.

* chore: a => an; remove repeated `to`

* Update offsets.js

* Update generateRules.js

---------

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2023-06-11 11:06:03 -04:00
Robin Malfait
ef2ebb28d5
Explicitly configure Lightning CSS features, and prefer user browserslist over default browserslist (#11402)
* exclude `Features.LogicalProperties` lightningcss feature

We don't want this to automatically apply since we have dedicated
logical property based utilities already.

We also have a feature flag to toggle some utilities to make use of
logical property based ones.

This feature should be opt-in to prevent backwards compatibility (e.g.:
RTL sites that _did_ use a mr-4 explicitly).

* update default browserslist

* explicitly include/exclude Lightning CSS features

* update tests based on new browserslist and include/exclude features from Lightning CSS

* update integration tests

* prefer user browserslist, fallback to built-in browserslist

* always include Nesting

If a custom browserslist config is used, then we don't explicitly set
the include/exclude features from Lightning CSS (except for nesting, we
always want to process nesting)

* ensure to fallback to the current working directory

* update changelog
2023-06-09 20:37:36 +02:00
Robin Malfait
ea3d9cd57a
compare the correct values in Jest tests 2023-06-09 16:04:24 +02:00
Jordan Pittman
e51b09ca65
Move unknown pseudo elements outside of :is (#11345)
* More pseudo elements outside of `:is` by default

* Update changelog
2023-06-08 15:00:58 -04:00
Robin Malfait
eb8d9294c5
Make the Rust based parser the default (#11394)
* add failling test using array syntax without space delimiter

* add Rust test with candidates in array without spaces

* Fix JS arrays without spaces

* make the `oxideParser` the default

* sync feature flags with reality

* use better example in tests to be more real

* skip failing tests in the RegEx parser

* update changelog

* make `clippy` happy

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2023-06-08 14:13:21 +02:00
Robin Malfait
55daf8e0f5
Ensure the oxide parser has feature parity with the stable RegEx parser (#11389)
* WIP

* use `parse` instead of `defaultExtractor`

* skip `Vue` describe block

* add a few more dedicated arbitrary values/properties tests

* use parallel parsing

* splitup Vue tests

* add some Rust specific tests

* setup parse candidate strings test system

These tests will run against the `Regex` and `Rust` based parsers. We
have groups of classes of various shapes and forms + variants and
rendered in various template situation (plain, html, Vue, ...)

+ enable all skipped tests

* ensure we also validate the classes with variants

The classes with variants are built in the `templateTable` function, so
we get them out again by using the potional arguments of the `test.each`
cb function.

* cleanup test suite

* add "anti-test" tests

To make sure that we are _not_ parsing out certain values given a
certain input.

* Add ParseAction enum

* Restart parsing following an arbitrary parse failure

* Split variants off before validating the uility part

* Collapse candidate from the end when validation fails

* Support `<`, and `>` in variant position

* fix error

* format parser.rs

* Refactor

* Update editorconfig

* wip

* wip

* Refactor

* Refactor

* Simplify

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* run `cargo clippy --fix`

* run `cargo fmt`

* implement `cargo clippy` suggestions

These were not applied using `cargo clippy --fix`

* only allow `.` in the candidate part when surrounded by 0-9

This is only in the candidate part, not the arbitrary part.

* % characters can only appear at the end after digits

* > and < should only be part of variants (start OR end)

It can technically be inside the candidate when we have stacked
variants:
```
dark:<sm:underline
dark:md>:underline
```

* handle parsing utilities within quotes, parans or brackets

* mark `pt-1.5` as an expected value sliced out from `["pt-1.5"]`

* Add cursor abstraction

* wip

* disable the oxideParser if using a custom `prefix` or `separator`

* update tests

* Use cursor abstraction

* Refactor more code toward use of global cursor

* wip

* simplify

* Simplify

* Simplify

* Simplify

* Cleanup

* wip

* Simplify

* wip

* Simplify

* Handle candidates ending with % sign

* Tweak code a bit

* fmt

* Simplify

* Add cursor details to trace

* cargo fmt

* use preferred `zoom-0.5` name instead of `zoom-.5`

* drop over-extracted utilities in oxide parser

The RegEx parser does extract `underline` from

```html
<div class="peer-aria-[labelledby='a_b']:underline"></div>
```
... but that's not needed and is not happening in the oxide parser

This means that we have to make the output check a little bit different
but they are explicit based on the feature flag.

* allow extracting variants+utilities inside `{}` for the oxide parser

* characters in candidates such as `group-${id}` should not be allowed

* do not extract any of the following candidate `w-[foo-bar]w-[bar-baz]`

* ensure we can consume the full candidate and discard it

* Add fast skipping of whitespace

* Use fast skipping whenever possible

* Add fast skipping to benchmark

* Hand-tune to generate more optimized assembly

* Move code around a bit

This makes sure all the fancy SIMD stuff is as early as possible. This results in an extremely minor perf increase.

* Undo tweak

no meaningful perf difference in real world scenarios

* Disable fast skipping for now

It needs to be done in a different spot so it doesn’t affect how things are returned

* Change test names

* Fix normalize config error

* cleanup a bit

* Cleanup

* Extract validation result enum

* Cleanup comments

* Simplify

* Fix formatting

* Run clippy

* wip

* add `md>` under the special characters test set

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2023-06-07 17:44:35 +02:00
Robin Malfait
e572dc645a
Bump lightningcss dependency (#11388)
* bump `lightningcss`

* allow for non-standard selector combinators such as `::deep`

* just use Prettier when comparing CSS results

We were using 2 different engines where the stable one was not using
Lightning CSS and the Oxide one was using Lightning CSS.

To ensure that we didn't have to rewrite every single test expectation,
the `toMatchFormattedCss` parsed both the actual and expected value
using Lightning CSS (to make the result similar), then it used Prettier
to make it... pretty.

Right now we _only_ use Lightning CSS, which means that we can drop the
additional lightningcss format step and just use Prettier on both the
actual and expected values.

Pretty also only prettifies the CSS, it doesn't rewrite it. E.g.:
`@media (min-width: 768px)` will not be optimized to `@media (width >=
768px)`, that's something that Lightning CSS does for us.

This will require some changes in our test output, but it will be
consistent afterwards because there won't be hidden transformation steps
anymore. Because up until now it could be that the actual result was
`color: black` but the tests showed `color: #000` (because it is
shorter).

This change will reflect reality.

* update tests based on previous commit

* only use `toMatchFormattedCss` instead of `toMatchCss`

They both do the exact same thing right now. While `toMatchCss` is
shorter, `toMatchFormattedCss` makes a bit more sense since we are
comparing the Prettier results.

* update integration tests
2023-06-07 15:56:32 +02:00
depfu[bot]
571c27e1f1 Update @swc/core to version 1.3.62 2023-06-06 08:00:26 +00:00
depfu[bot]
fd74f04437 Update vite to version 4.3.9 2023-06-06 04:12:11 +00:00
depfu[bot]
f661c0371c Update browserslist to version 4.21.7 2023-06-04 10:31:31 +00:00
depfu[bot]
729dafeb82 Update postcss to version 8.4.24 2023-06-04 10:00:20 +00:00
Robin Malfait
b05b617601
Bump Rust version to 1.70.0 (#11344)
* `cargo clippy --fix`

* use `map_while` instead of `filter_map`

- `filter_map()` will run forever if the iterator repeatedly produces an `Err`

```
❯ cargo clippy
    Checking tailwindcss-oxide v0.1.0 (/Users/robin/github.com/tailwindlabs/tailwindcss/oxide/crates/cli)
warning: `filter_map()` will run forever if the iterator repeatedly produces an `Err`
   --> crates/cli/src/main.rs:108:14
    |
108 |             .filter_map(Result::ok)
    |              ^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)`
    |
note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error
   --> crates/cli/src/main.rs:106:9
    |
106 | /         read_lines(path)
107 | |             .unwrap()
    | |_____________________^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#lines_filter_map_ok
    = note: `#[warn(clippy::lines_filter_map_ok)]` on by default

warning: `tailwindcss-oxide` (bin "tailwindcss-oxide") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
```

* log used versions of all the tools we are using

* ensure we install Rust
2023-06-02 15:24:40 +02:00
depfu[bot]
9794b83985 Update parcel to version 2.9.1 2023-06-02 08:44:39 +00:00
Robin Malfait
5ddd9c4db6
Fallback to RegEx based parser when using custom transformers or extractors (#11335)
* handle custom `transformer` and `extractor` implementations

Right now the Rust based parser can't work with custom `transfomers` or
`extractors`.

In a perfect world we can implement as many custom parsers/extractors in
Rust such that we don't need this at all. In an almost perfect world we
can pass the transformer and extractor to the Rust based parser and call
the callback functions to handle all of this. This is probably what we
are going to do in the future but this requires more work to make sure
that:

1. It works as expected
2. Doesn't result in (major) performance issues

Since it currently doesn't work with the Rust based parser, we can
implement a fix for this in the meantime before we reach the "perfect"
solution.

One solution to this problem is to check if we do have a custom
transformer or a custom extractor and if we do, then we can bail on the
Rust parser completely and just use the current regex based parser.

An alternative solution, the solution implemented here, is that we group
the `changedContent` into 2 buckets. The bucket where we rely on the
default transformer and extractor and a bucket where a custom
transformer or extractor is used.

Then, the bucket where we use the default transformer and extractor can
still rely on the way faster Rust based parser. For the other bucket we
fallback to the regex based parser.

The nice part about this is that we can use both parsers at the same
time, and the majority of the use cases should use the faster Rust based
parser.

* update changelog
2023-06-01 22:37:12 +02:00
Robin Malfait
5c7a8e98ea
use parseCandidateStrings directly (#11332)
+ drop the `parseCandidateStringsFromFiles` since this can be
  implemented using `parseCandidateStrings` already.
2023-06-01 13:24:53 +02:00
Robin Malfait
352c563d99
Fix source maps issue resulting in a crash (#11319)
* only try to pretty print `err.source` if it exists

* fix small typo

* drop unnecessary path resolving

* add `from` and `to` to `run` test helper

* enable all source map tests

* ensure source maps are generated properly

* update annotation values in tests

* handle `map: true`

* add test for `map: { inline: true }`

* force Lightning CSS to handle an inline source map

* base64 encode the test name

This will get rid of special characters that can cause issues /
confusion when debugging tests.

* ensure utilities and components with variants are pointing to the correct source

Co-authored-by: Jordan Pittman <jordan@cryptica.me>

* update changelog

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2023-05-31 18:28:11 +02:00
Robin Malfait
ecebde1d52
bump napi-rs in Cargo.toml 2023-05-31 15:31:38 +02:00
Robin Malfait
c9138b2e0b
bump napi-rs (#11328) 2023-05-31 13:44:28 +02:00
Adam Wathan
cb1a0e1a95
Add support for text-wrap property (#11320)
Update changelog

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2023-05-30 15:26:27 -04:00
Adam Wathan
e1d4955431 Move entry in changelog 2023-05-30 12:21:51 -04:00
Adam Wathan
69d86873c3
Add has-* variants for :has(...) pseudo-class (#11318)
* Add `has-*` variants for `:has(...)` pseudo-class

* Update changelog

* Fix mistake in test

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2023-05-30 12:21:08 -04:00
Adam Wathan
7248f2121e
Add svh, lvh, and dvh values to default theme (#11317)
* Add svh, lvh, and dvh values to default theme

* Update changelog

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2023-05-30 11:58:16 -04:00