🎥 Make videos programmatically with React
minor fixes in interpolate-styles
ChetanKarwa0479644668c6
diff --git a/packages/animation-utils/src/test/interpolate-styles.test.ts b/packages/animation-utils/src/test/interpolate-styles.test.tsindex 4854a21828..b0bd0e0000 100644--- a/packages/animation-utils/src/test/interpolate-styles.test.ts+++ b/packages/animation-utils/src/test/interpolate-styles.test.ts@@ -71,7 +71,7 @@ test('Throw error on incompatible shorthands', () => {);});-test.skip('Should throw an error on non-animateable properties', () => {+test('Should throw an error on non-animatable properties', () => {expect(() =>interpolateStyles(0.5,@@ -85,10 +85,12 @@ test.skip('Should throw an error on non-animateable properties', () => {},],),- ).throws(/some good error/);+ ).throws(+ /Non-animatable values cannot be interpolated. Start value: center, end value: left/,+ );});-test.skip('Should be able to interpolate transform strings - edge', () => {+test('Should be able to interpolate transform strings - edge', () => {expect(interpolateStyles(0,@@ -105,7 +107,7 @@ test.skip('Should be able to interpolate transform strings - edge', () => {).toEqual({transform: `scale(0.5)`});});-test.skip('Should be able to interpolate transform strings - middle', () => {+test('Should be able to interpolate transform strings - middle', () => {expect(interpolateStyles(2.5,@@ -162,7 +164,7 @@ test('Should throw on units mismatch', () => {);});-test.skip('Should handle `border`', () => {+test('Should handle `border`', () => {expect(interpolateStyles(0.5,@@ -176,7 +178,7 @@ test.skip('Should handle `border`', () => {},],),- ).toBe({+ ).toEqual({border: '5.5px solid rgba(128, 0, 0, 1)',});@@ -193,5 +195,26 @@ test.skip('Should handle `border`', () => {},],),- ).throws(/some/);+ ).throws(+ /Non-animatable values cannot be interpolated. Start value: 1px solid black, end value: 10px dotted red/,+ );+});++test('Should interpolate between 0 and values with units', () => {+ expect(+ interpolateStyles(+ 0.5,+ [0, 1],+ [+ {+ padding: 0,+ },+ {+ padding: '10px',+ },+ ],+ ),+ ).toEqual({+ padding: '5px',+ });});diff --git a/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx b/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsxindex 4b82673e20..eb10f8f155 100644--- a/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx+++ b/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx@@ -21,7 +21,7 @@ const interpolatedPropertyPart = ({finalStylePropertyPart: UnitNumberAndFunction;initialStyleProperty: CSSPropertiesValue;finalStyleProperty: CSSPropertiesValue;-}): string => {+}): string | number => {if (finalStylePropertyPart === undefined) {throw new TypeError(`The start and end values must be of the same type. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`,@@ -77,10 +77,20 @@ const interpolatedPropertyPart = ({}if (typeof initialStylePropertyPart.number === 'undefined') {+ if (initialStylePropertyPart.unit !== finalStylePropertyPart.unit) {+ throw new TypeError(+ `Non-animatable values cannot be interpolated. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`,+ );+ }+return `${initialStylePropertyPart.unit}`;}- if (initialStylePropertyPart.unit !== finalStylePropertyPart.unit) {+ if (+ initialStylePropertyPart.unit !== finalStylePropertyPart.unit &&+ initialStylePropertyPart.number !== 0 &&+ finalStylePropertyPart.number !== 0+ ) {throw new TypeError(`The units of the start and end values must match. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`,);@@ -92,7 +102,13 @@ const interpolatedPropertyPart = ({startNumber,endNumber,]);- const interpolatedUnit = initialStylePropertyPart.unit;+ const interpolatedUnit =+ initialStylePropertyPart.unit || finalStylePropertyPart.unit || '';++ if (!interpolatedUnit) {+ return interpolatedNumber;+ }+return `${interpolatedNumber}${interpolatedUnit}`;};@@ -102,15 +118,14 @@ const interpolateProperty = (initialStyleProperty: CSSPropertiesValue,finalStyleProperty: CSSPropertiesValue,) => {- if (typeof initialStyleProperty !== typeof finalStyleProperty) {- return initialStyleProperty;- }-- if (typeof initialStyleProperty === 'number') {- return interpolate(inputValue, inputRange, [- initialStyleProperty,- finalStyleProperty as number,- ]);+ if (+ typeof initialStyleProperty !== typeof finalStyleProperty &&+ initialStyleProperty !== 0 &&+ finalStyleProperty !== 0+ ) {+ throw new TypeError(+ `The start and end values must be of the same type. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`,+ );}const initialStylePropertyParts =@@ -118,6 +133,12 @@ const interpolateProperty = (const finalStylePropertyParts =breakDownValueIntoUnitNumberAndFunctions(finalStyleProperty);+ console.log(+ 'initialStylePropertyParts',+ initialStylePropertyParts,+ finalStylePropertyParts,+ );+const interpolatedValue = initialStylePropertyParts.reduce((acc, initialStylePropertyPart, index) => {return `${acc} ${interpolatedPropertyPart({@@ -141,14 +162,31 @@ const interpolateStylesFunction = (finalStyle: Style,): Style => {return Object.keys(initialStyle).reduce((acc, key) => {+ if (!finalStyle[key as CSSPropertiesKey]) {+ return {+ ...acc,+ [key]: initialStyle[key as CSSPropertiesKey],+ };+ }++ const finalStyleValue = interpolateProperty(+ inputValue,+ [startingValue, endingValue],+ initialStyle[key as CSSPropertiesKey],+ finalStyle[key as CSSPropertiesKey],+ );++ // Avoid number to be a string+ if (!isNaN(Number(finalStyleValue))) {+ return {+ ...acc,+ [key]: Number(finalStyleValue),+ };+ }+return {...acc,- [key]: interpolateProperty(- inputValue,- [startingValue, endingValue],- initialStyle[key as CSSPropertiesKey],- finalStyle[key as CSSPropertiesKey],- ),+ [key]: finalStyleValue,};}, {});};diff --git a/packages/animation-utils/src/transformation-helpers/interpolate-styles/utils.ts b/packages/animation-utils/src/transformation-helpers/interpolate-styles/utils.tsindex 6b2286078c..26120c1401 100644--- a/packages/animation-utils/src/transformation-helpers/interpolate-styles/utils.ts+++ b/packages/animation-utils/src/transformation-helpers/interpolate-styles/utils.ts@@ -98,6 +98,12 @@ const classifyArgsOfFunction = (value: string) => {return unit ? {number, unit} : {number};}+ const numberMatch = val.match(/^(\d+(?:\.\d+)?)$/);+ if (numberMatch) {+ const number = parseFloat(numberMatch[1]);+ return {number};+ }+return {unit: val};});};@@ -144,6 +150,13 @@ const classifyParts = (parts: string[]) => {return unit ? {number, unit} : {number};}+ // Check for a number without a unit+ const numberMatch = part.match(/^(\d+(?:\.\d+)?)$/);+ if (numberMatch) {+ const number = parseFloat(numberMatch[1]);+ return {number};+ }+// If neither, treat as a unit (like 'solid', 'none', etc.)return {unit: part};});@@ -152,6 +165,10 @@ const classifyParts = (parts: string[]) => {const breakDownValueIntoUnitNumberAndFunctions = (value: CSSPropertiesValue,) => {+ if (typeof value === 'number') {+ return [{number: value}];+ }+if (typeof value !== 'string') {return [];}diff --git a/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar b/packages/cloudrun/src/gcpInstaller/gcpInstaller.tarindex 2df302f979..c7a86bef89 100644Binary files a/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar and b/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar differ