Skip to content

Commit 4a168e9

Browse files
committed
fixup ast
1 parent a4cc024 commit 4a168e9

File tree

7 files changed

+78
-68
lines changed

7 files changed

+78
-68
lines changed

Cargo.lock

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ into_owned = ["static-self", "static-self/smallvec", "parcel_selectors/into_owne
4848
substitute_variables = ["visitor", "into_owned"]
4949

5050
[dependencies]
51-
serde = { version = "1.0.123", features = ["derive"], optional = true }
51+
serde = { version = "1.0.201", features = ["derive"], optional = true }
5252
cssparser = "0.33.0"
5353
cssparser-color = "0.1.0"
5454
parcel_selectors = { version = "0.26.4", path = "./selectors" }
@@ -71,7 +71,7 @@ rayon = { version = "1.5.1", optional = true }
7171
dashmap = { version = "5.0.0", optional = true }
7272
serde_json = { version = "1.0.78", optional = true }
7373
lightningcss-derive = { version = "=1.0.0-alpha.42", path = "./derive", optional = true }
74-
schemars = { version = "0.8.11", features = ["smallvec"], optional = true }
74+
schemars = { version = "0.8.19", features = ["smallvec"], optional = true }
7575
static-self = { version = "0.1.0", path = "static-self", optional = true }
7676

7777
[target.'cfg(target_os = "macos")'.dependencies]

napi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ visitor = ["lightningcss/visitor"]
1313
bundler = ["dep:crossbeam-channel", "dep:rayon"]
1414

1515
[dependencies]
16-
serde = { version = "1.0.123", features = ["derive"] }
16+
serde = { version = "1.0.201", features = ["derive"] }
1717
serde_bytes = "0.11.5"
1818
cssparser = "0.33.0"
1919
lightningcss = { version = "1.0.0-alpha.54", path = "../", features = ["nodejs", "serde"] }

node/ast.d.ts

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable */
1+
/* tslint:disable */
22
/**
33
* This file was automatically generated by json-schema-to-typescript.
44
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -5619,44 +5619,40 @@ export type Perspective =
56195619
* A value for the [translate](https://drafts.csswg.org/css-transforms-2/#propdef-translate) property.
56205620
*/
56215621
export type Translate =
5622-
| "None"
5622+
| "none"
56235623
| {
5624-
XYZ: {
5625-
/**
5626-
* The x translation.
5627-
*/
5628-
x: DimensionPercentageFor_LengthValue;
5629-
/**
5630-
* The y translation.
5631-
*/
5632-
y: DimensionPercentageFor_LengthValue;
5633-
/**
5634-
* The z translation.
5635-
*/
5636-
z: Length;
5637-
};
5638-
};
5624+
/**
5625+
* The x translation.
5626+
*/
5627+
x: DimensionPercentageFor_LengthValue;
5628+
/**
5629+
* The y translation.
5630+
*/
5631+
y: DimensionPercentageFor_LengthValue;
5632+
/**
5633+
* The z translation.
5634+
*/
5635+
z: Length;
5636+
};
56395637
/**
56405638
* A value for the [scale](https://drafts.csswg.org/css-transforms-2/#propdef-scale) property.
56415639
*/
56425640
export type Scale =
5643-
| "None"
5641+
| "none"
56445642
| {
5645-
XYZ: {
5646-
/**
5647-
* Scale on the x axis.
5648-
*/
5649-
x: NumberOrPercentage;
5650-
/**
5651-
* Scale on the y axis.
5652-
*/
5653-
y: NumberOrPercentage;
5654-
/**
5655-
* Scale on the z axis.
5656-
*/
5657-
z: NumberOrPercentage;
5658-
};
5659-
};
5643+
/**
5644+
* Scale on the x axis.
5645+
*/
5646+
x: NumberOrPercentage;
5647+
/**
5648+
* Scale on the y axis.
5649+
*/
5650+
y: NumberOrPercentage;
5651+
/**
5652+
* Scale on the z axis.
5653+
*/
5654+
z: NumberOrPercentage;
5655+
};
56605656
/**
56615657
* Defines how text case should be transformed in the [text-transform](https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#text-transform-property) property.
56625658
*/

scripts/build-ast.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ compileFromFile('node/ast.json', {
5555
if (path.node.name.startsWith('GenericBorderFor_LineStyleAnd_')) {
5656
path.node.name = 'GenericBorderFor_LineStyle';
5757
}
58+
},
59+
TSTypeAliasDeclaration(path) {
60+
// Workaround for schemars not supporting untagged variants.
61+
// https://github.com/GREsau/schemars/issues/222
62+
if (
63+
(path.node.id.name === 'Translate' || path.node.id.name === 'Scale') &&
64+
path.node.typeAnnotation.type === 'TSUnionType' &&
65+
path.node.typeAnnotation.types[1].type === 'TSTypeLiteral' &&
66+
path.node.typeAnnotation.types[1].members[0].key.name === 'xyz'
67+
) {
68+
path.get('typeAnnotation.types.1').replaceWith(path.node.typeAnnotation.types[1].members[0].typeAnnotation.typeAnnotation);
69+
}
5870
}
5971
});
6072

selectors/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ log = "0.4"
2929
phf = "0.10"
3030
precomputed-hash = "0.1"
3131
smallvec = "1.0"
32-
serde = { version = "1.0.123", features = ["derive"], optional = true }
33-
schemars = { version = "0.8.11", features = ["smallvec"], optional = true }
32+
serde = { version = "1.0.201", features = ["derive"], optional = true }
33+
schemars = { version = "0.8.19", features = ["smallvec"], optional = true }
3434
static-self = { version = "0.1.0", path = "../static-self", optional = true }
3535

3636
[build-dependencies]

src/properties/transform.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,14 +1454,15 @@ impl ToCss for Perspective {
14541454
/// A value for the [translate](https://drafts.csswg.org/css-transforms-2/#propdef-translate) property.
14551455
#[derive(Debug, Clone, PartialEq)]
14561456
#[cfg_attr(feature = "visitor", derive(Visit))]
1457-
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1457+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "lowercase"))]
14581458
#[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))]
14591459
#[cfg_attr(feature = "into_owned", derive(static_self::IntoOwned))]
14601460
pub enum Translate {
14611461
/// The "none" keyword.
14621462
None,
14631463

14641464
/// The x, y, and z translations.
1465+
#[cfg_attr(feature = "serde", serde(untagged))]
14651466
XYZ {
14661467
/// The x translation.
14671468
x: LengthPercentage,
@@ -1622,14 +1623,15 @@ impl Rotate {
16221623
/// A value for the [scale](https://drafts.csswg.org/css-transforms-2/#propdef-scale) property.
16231624
#[derive(Debug, Clone, PartialEq)]
16241625
#[cfg_attr(feature = "visitor", derive(Visit))]
1625-
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1626+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "lowercase"))]
16261627
#[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))]
16271628
#[cfg_attr(feature = "into_owned", derive(static_self::IntoOwned))]
16281629
pub enum Scale {
16291630
/// The "none" keyword.
16301631
None,
16311632

16321633
/// Scale on the x, y, and z axis.
1634+
#[cfg_attr(feature = "serde", serde(untagged))]
16331635
XYZ {
16341636
/// Scale on the x axis.
16351637
x: NumberOrPercentage,

0 commit comments

Comments
 (0)