format: prettify entire project

This commit is contained in:
Rim
2025-04-02 06:50:39 -04:00
parent 86f0782a98
commit 7ccc0be712
1711 changed files with 755867 additions and 235931 deletions

View File

@ -7,7 +7,11 @@ function isInheritOnly(values) {
for (var i = 0, l = values.length; i < l; i++) {
var value = values[i][1];
if (value != 'inherit' && value != Marker.COMMA && value != Marker.FORWARD_SLASH)
if (
value != 'inherit' &&
value != Marker.COMMA &&
value != Marker.FORWARD_SLASH
)
return false;
}
@ -27,9 +31,18 @@ function background(property, compactable, lastInMultiplex) {
var descriptor = compactable[component.name];
if (descriptor.doubleValues && descriptor.defaultValue.length == 1) {
return component.value[0][1] == descriptor.defaultValue[0] && (component.value[1] ? component.value[1][1] == descriptor.defaultValue[0] : true);
return (
component.value[0][1] == descriptor.defaultValue[0] &&
(component.value[1] ?
component.value[1][1] == descriptor.defaultValue[0]
: true)
);
} else if (descriptor.doubleValues && descriptor.defaultValue.length != 1) {
return component.value[0][1] == descriptor.defaultValue[0] && (component.value[1] ? component.value[1][1] : component.value[0][1]) == descriptor.defaultValue[1];
return (
component.value[0][1] == descriptor.defaultValue[0] &&
(component.value[1] ? component.value[1][1] : component.value[0][1]) ==
descriptor.defaultValue[1]
);
} else {
return component.value[0][1] == descriptor.defaultValue;
}
@ -45,10 +58,13 @@ function background(property, compactable, lastInMultiplex) {
needsOne = component.value[0][1] == originComponent.value[0][1];
needsBoth = !needsOne && (
(isOriginDefault && !isDefault) ||
(!isOriginDefault && !isDefault) ||
(!isOriginDefault && isDefault && component.value[0][1] != originComponent.value[0][1]));
needsBoth =
!needsOne &&
((isOriginDefault && !isDefault) ||
(!isOriginDefault && !isDefault) ||
(!isOriginDefault &&
isDefault &&
component.value[0][1] != originComponent.value[0][1]));
if (needsOne) {
restoreValue(originComponent);
@ -64,8 +80,10 @@ function background(property, compactable, lastInMultiplex) {
needsOne = !isPositionDefault && isDefault;
needsBoth = !needsOne &&
(isPositionDefault && !isDefault || !isPositionDefault && !isDefault);
needsBoth =
!needsOne &&
((isPositionDefault && !isDefault) ||
(!isPositionDefault && !isDefault));
if (needsOne) {
restoreValue(positionComponent);
@ -79,21 +97,30 @@ function background(property, compactable, lastInMultiplex) {
i--;
} else {
if (isDefault || compactable[component.name].multiplexLastOnly && !lastInMultiplex)
if (
isDefault ||
(compactable[component.name].multiplexLastOnly && !lastInMultiplex)
)
continue;
restoreValue(component);
}
}
if (restored.length === 0 && property.value.length == 1 && property.value[0][1] == '0')
if (
restored.length === 0 &&
property.value.length == 1 &&
property.value[0][1] == '0'
)
restored.push(property.value[0]);
if (restored.length === 0)
restored.push([Token.PROPERTY_VALUE, compactable[property.name].defaultValue]);
restored.push([
Token.PROPERTY_VALUE,
compactable[property.name].defaultValue,
]);
if (isInheritOnly(restored))
return [restored[0]];
if (isInheritOnly(restored)) return [restored[0]];
return restored;
}
@ -121,14 +148,24 @@ function borderRadius(property, compactable) {
var horizontalValues = fourValues(horizontal, compactable);
var verticalValues = fourValues(vertical, compactable);
if (horizontalValues.length == verticalValues.length &&
horizontalValues[0][1] == verticalValues[0][1] &&
(horizontalValues.length > 1 ? horizontalValues[1][1] == verticalValues[1][1] : true) &&
(horizontalValues.length > 2 ? horizontalValues[2][1] == verticalValues[2][1] : true) &&
(horizontalValues.length > 3 ? horizontalValues[3][1] == verticalValues[3][1] : true)) {
if (
horizontalValues.length == verticalValues.length &&
horizontalValues[0][1] == verticalValues[0][1] &&
(horizontalValues.length > 1 ?
horizontalValues[1][1] == verticalValues[1][1]
: true) &&
(horizontalValues.length > 2 ?
horizontalValues[2][1] == verticalValues[2][1]
: true) &&
(horizontalValues.length > 3 ?
horizontalValues[3][1] == verticalValues[3][1]
: true)
) {
return horizontalValues;
} else {
return horizontalValues.concat([[Token.PROPERTY_VALUE, Marker.FORWARD_SLASH]]).concat(verticalValues);
return horizontalValues
.concat([[Token.PROPERTY_VALUE, Marker.FORWARD_SLASH]])
.concat(verticalValues);
}
} else {
return fourValues(property, compactable);
@ -143,7 +180,9 @@ function font(property, compactable) {
var fontFamilyIndex = 0;
if (property.value[0][1].indexOf(Marker.INTERNAL) === 0) {
property.value[0][1] = property.value[0][1].substring(Marker.INTERNAL.length);
property.value[0][1] = property.value[0][1].substring(
Marker.INTERNAL.length
);
return property.value;
}
@ -163,8 +202,13 @@ function font(property, compactable) {
componentIndex++;
// then may come line-height
if (components[componentIndex].value[0][1] != compactable[components[componentIndex].name].defaultValue) {
Array.prototype.push.apply(restored, [[Token.PROPERTY_VALUE, Marker.FORWARD_SLASH]]);
if (
components[componentIndex].value[0][1] !=
compactable[components[componentIndex].name].defaultValue
) {
Array.prototype.push.apply(restored, [
[Token.PROPERTY_VALUE, Marker.FORWARD_SLASH],
]);
Array.prototype.push.apply(restored, components[componentIndex].value);
}
@ -195,7 +239,11 @@ function fourValues(property) {
var value3 = components[2].value[0];
var value4 = components[3].value[0];
if (value1[1] == value2[1] && value1[1] == value3[1] && value1[1] == value4[1]) {
if (
value1[1] == value2[1] &&
value1[1] == value3[1] &&
value1[1] == value4[1]
) {
return [value1];
} else if (value1[1] == value3[1] && value2[1] == value4[1]) {
return [value1, value2];
@ -208,8 +256,7 @@ function fourValues(property) {
function multiplex(restoreWith) {
return function (property, compactable) {
if (!property.multiplex)
return restoreWith(property, compactable, true);
if (!property.multiplex) return restoreWith(property, compactable, true);
var multiplexSize = 0;
var restored = [];
@ -218,8 +265,7 @@ function multiplex(restoreWith) {
// At this point we don't know what's the multiplex size, e.g. how many background layers are there
for (i = 0, l = property.components[0].value.length; i < l; i++) {
if (property.components[0].value[i][1] == Marker.COMMA)
multiplexSize++;
if (property.components[0].value[i][1] == Marker.COMMA) multiplexSize++;
}
for (i = 0; i <= multiplexSize; i++) {
@ -233,7 +279,12 @@ function multiplex(restoreWith) {
// The trick is some properties has more than one value, so we iterate over values looking for
// a multiplex separator - a comma
for (var k = componentMultiplexSoFar[_component.name] || 0, n = componentToClone.value.length; k < n; k++) {
for (
var k = componentMultiplexSoFar[_component.name] || 0,
n = componentToClone.value.length;
k < n;
k++
) {
if (componentToClone.value[k][1] == Marker.COMMA) {
componentMultiplexSoFar[_component.name] = k + 1;
break;
@ -264,16 +315,22 @@ function withoutDefaults(property, compactable) {
var component = components[i];
var descriptor = compactable[component.name];
if (component.value[0][1] != descriptor.defaultValue || ('keepUnlessDefault' in descriptor) && !isDefault(components, compactable, descriptor.keepUnlessDefault)) {
if (
component.value[0][1] != descriptor.defaultValue ||
('keepUnlessDefault' in descriptor &&
!isDefault(components, compactable, descriptor.keepUnlessDefault))
) {
restored.unshift(component.value[0]);
}
}
if (restored.length === 0)
restored.push([Token.PROPERTY_VALUE, compactable[property.name].defaultValue]);
restored.push([
Token.PROPERTY_VALUE,
compactable[property.name].defaultValue,
]);
if (isInheritOnly(restored))
return [restored[0]];
if (isInheritOnly(restored)) return [restored[0]];
return restored;
}
@ -285,7 +342,10 @@ function isDefault(components, compactable, propertyName) {
for (i = 0, l = components.length; i < l; i++) {
component = components[i];
if (component.name == propertyName && component.value[0][1] == compactable[propertyName].defaultValue) {
if (
component.name == propertyName &&
component.value[0][1] == compactable[propertyName].defaultValue
) {
return true;
}
}
@ -299,5 +359,5 @@ module.exports = {
font: font,
fourValues: fourValues,
multiplex: multiplex,
withoutDefaults: withoutDefaults
withoutDefaults: withoutDefaults,
};