Skip to content

Commit

Permalink
fixup ast
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed May 14, 2024
1 parent a4cc024 commit 029c88e
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 68 deletions.
56 changes: 28 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ into_owned = ["static-self", "static-self/smallvec", "parcel_selectors/into_owne
substitute_variables = ["visitor", "into_owned"]

[dependencies]
serde = { version = "1.0.123", features = ["derive"], optional = true }
serde = { version = "1.0.201", features = ["derive"], optional = true }
cssparser = "0.33.0"
cssparser-color = "0.1.0"
parcel_selectors = { version = "0.26.4", path = "./selectors" }
Expand All @@ -71,7 +71,7 @@ rayon = { version = "1.5.1", optional = true }
dashmap = { version = "5.0.0", optional = true }
serde_json = { version = "1.0.78", optional = true }
lightningcss-derive = { version = "=1.0.0-alpha.42", path = "./derive", optional = true }
schemars = { version = "0.8.11", features = ["smallvec"], optional = true }
schemars = { version = "0.8.19", features = ["smallvec"], optional = true }
static-self = { version = "0.1.0", path = "static-self", optional = true }

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ visitor = ["lightningcss/visitor"]
bundler = ["dep:crossbeam-channel", "dep:rayon"]

[dependencies]
serde = { version = "1.0.123", features = ["derive"] }
serde = { version = "1.0.201", features = ["derive"] }
serde_bytes = "0.11.5"
cssparser = "0.33.0"
lightningcss = { version = "1.0.0-alpha.54", path = "../", features = ["nodejs", "serde"] }
Expand Down
62 changes: 29 additions & 33 deletions node/ast.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */
/* tslint:disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
Expand Down Expand Up @@ -5619,44 +5619,40 @@ export type Perspective =
* A value for the [translate](https://drafts.csswg.org/css-transforms-2/#propdef-translate) property.
*/
export type Translate =
| "None"
| "none"
| {
XYZ: {
/**
* The x translation.
*/
x: DimensionPercentageFor_LengthValue;
/**
* The y translation.
*/
y: DimensionPercentageFor_LengthValue;
/**
* The z translation.
*/
z: Length;
};
};
/**
* The x translation.
*/
x: DimensionPercentageFor_LengthValue;
/**
* The y translation.
*/
y: DimensionPercentageFor_LengthValue;
/**
* The z translation.
*/
z: Length;
};
/**
* A value for the [scale](https://drafts.csswg.org/css-transforms-2/#propdef-scale) property.
*/
export type Scale =
| "None"
| "none"
| {
XYZ: {
/**
* Scale on the x axis.
*/
x: NumberOrPercentage;
/**
* Scale on the y axis.
*/
y: NumberOrPercentage;
/**
* Scale on the z axis.
*/
z: NumberOrPercentage;
};
};
/**
* Scale on the x axis.
*/
x: NumberOrPercentage;
/**
* Scale on the y axis.
*/
y: NumberOrPercentage;
/**
* Scale on the z axis.
*/
z: NumberOrPercentage;
};
/**
* 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.
*/
Expand Down
12 changes: 12 additions & 0 deletions scripts/build-ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ compileFromFile('node/ast.json', {
if (path.node.name.startsWith('GenericBorderFor_LineStyleAnd_')) {
path.node.name = 'GenericBorderFor_LineStyle';
}
},
TSTypeAliasDeclaration(path) {
// Workaround for schemars not supporting untagged variants.
// https://github.com/GREsau/schemars/issues/222
if (
(path.node.id.name === 'Translate' || path.node.id.name === 'Scale') &&
path.node.typeAnnotation.type === 'TSUnionType' &&
path.node.typeAnnotation.types[1].type === 'TSTypeLiteral' &&
path.node.typeAnnotation.types[1].members[0].key.name === 'xyz'
) {
path.get('typeAnnotation.types.1').replaceWith(path.node.typeAnnotation.types[1].members[0].typeAnnotation.typeAnnotation);
}
}
});

Expand Down
4 changes: 2 additions & 2 deletions selectors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ log = "0.4"
phf = "0.10"
precomputed-hash = "0.1"
smallvec = "1.0"
serde = { version = "1.0.123", features = ["derive"], optional = true }
schemars = { version = "0.8.11", features = ["smallvec"], optional = true }
serde = { version = "1.0.201", features = ["derive"], optional = true }
schemars = { version = "0.8.19", features = ["smallvec"], optional = true }
static-self = { version = "0.1.0", path = "../static-self", optional = true }

[build-dependencies]
Expand Down
7 changes: 5 additions & 2 deletions src/properties/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::vendor_prefix::VendorPrefix;
use crate::visitor::Visit;
use cssparser::*;
use std::f32::consts::PI;
use crate::serialization::ValueWrapper;

/// A value for the [transform](https://www.w3.org/TR/2019/CR-css-transforms-1-20190214/#propdef-transform) property.
#[derive(Debug, Clone, PartialEq, Default)]
Expand Down Expand Up @@ -1454,14 +1455,15 @@ impl ToCss for Perspective {
/// A value for the [translate](https://drafts.csswg.org/css-transforms-2/#propdef-translate) property.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "visitor", derive(Visit))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "lowercase"))]
#[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "into_owned", derive(static_self::IntoOwned))]
pub enum Translate {
/// The "none" keyword.
None,

/// The x, y, and z translations.
#[cfg_attr(feature = "serde", serde(untagged))]
XYZ {
/// The x translation.
x: LengthPercentage,
Expand Down Expand Up @@ -1622,14 +1624,15 @@ impl Rotate {
/// A value for the [scale](https://drafts.csswg.org/css-transforms-2/#propdef-scale) property.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "visitor", derive(Visit))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "lowercase"))]
#[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "into_owned", derive(static_self::IntoOwned))]
pub enum Scale {
/// The "none" keyword.
None,

/// Scale on the x, y, and z axis.
#[cfg_attr(feature = "serde", serde(untagged))]
XYZ {
/// Scale on the x axis.
x: NumberOrPercentage,
Expand Down

0 comments on commit 029c88e

Please sign in to comment.