@junwan666/remotion-animation-utils 4.0.448-zh.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ declare const NUMBER = "[-+]?\\d*\\.?\\d+";
2
+ declare const PERCENTAGE: string;
3
+ export { NUMBER, PERCENTAGE };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PERCENTAGE = exports.NUMBER = void 0;
4
+ const NUMBER = '[-+]?\\d*\\.?\\d+';
5
+ exports.NUMBER = NUMBER;
6
+ const PERCENTAGE = NUMBER + '%';
7
+ exports.PERCENTAGE = PERCENTAGE;
@@ -0,0 +1,6 @@
1
+ import type { ExtrapolateType } from 'remotion';
2
+ export declare const interpolateStyles: (input: number, inputRange: number[], outputStylesRange: import("react").CSSProperties[], options?: Partial<{
3
+ easing: import("remotion").EasingFunction;
4
+ extrapolateLeft: ExtrapolateType;
5
+ extrapolateRight: ExtrapolateType;
6
+ }> | undefined) => import("react").CSSProperties;
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.interpolateStyles = void 0;
4
+ const remotion_1 = require("remotion");
5
+ const utils_1 = require("./utils");
6
+ const interpolatedPropertyPart = ({ inputValue, inputRange, initialStylePropertyPart, finalStylePropertyPart, initialStyleProperty, finalStyleProperty, options, }) => {
7
+ var _a;
8
+ if (finalStylePropertyPart === undefined) {
9
+ throw new TypeError(`The start and end values must be of the same type. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`);
10
+ }
11
+ if (initialStylePropertyPart.color) {
12
+ if (!finalStylePropertyPart.color) {
13
+ throw new TypeError(`The start and end values must be of the same type. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`);
14
+ }
15
+ const interpolatedColor = (0, remotion_1.interpolateColors)(inputValue, inputRange, [
16
+ initialStylePropertyPart.color,
17
+ finalStylePropertyPart.color,
18
+ ]);
19
+ return `${interpolatedColor}`;
20
+ }
21
+ if (initialStylePropertyPart.function) {
22
+ if (!(finalStylePropertyPart === null || finalStylePropertyPart === void 0 ? void 0 : finalStylePropertyPart.function) ||
23
+ initialStylePropertyPart.function.name !==
24
+ ((_a = finalStylePropertyPart.function) === null || _a === void 0 ? void 0 : _a.name)) {
25
+ throw new TypeError(`The start and end values must be of the same type. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`);
26
+ }
27
+ const endValuePartFunction = finalStylePropertyPart.function;
28
+ const endValuePartFunctionArgs = endValuePartFunction.values || [];
29
+ const interpolatedFunctionArgs = initialStylePropertyPart.function.values.reduce((acc, startValuePartFunctionArg, index) => {
30
+ const endValuePartFunctionArg = endValuePartFunctionArgs[index];
31
+ const interpolatedArg = interpolatedPropertyPart({
32
+ inputValue,
33
+ inputRange,
34
+ initialStylePropertyPart: startValuePartFunctionArg,
35
+ finalStylePropertyPart: endValuePartFunctionArg,
36
+ initialStyleProperty,
37
+ finalStyleProperty,
38
+ options,
39
+ });
40
+ return `${acc}, ${interpolatedArg}`;
41
+ }, '');
42
+ return `${initialStylePropertyPart.function.name}(${interpolatedFunctionArgs.slice(2)})`;
43
+ }
44
+ if (typeof initialStylePropertyPart.number === 'undefined') {
45
+ if (initialStylePropertyPart.unit !== finalStylePropertyPart.unit) {
46
+ throw new TypeError(`Non-animatable values cannot be interpolated. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`);
47
+ }
48
+ return `${initialStylePropertyPart.unit}`;
49
+ }
50
+ if (initialStylePropertyPart.unit !== finalStylePropertyPart.unit &&
51
+ initialStylePropertyPart.number !== 0 &&
52
+ finalStylePropertyPart.number !== 0) {
53
+ throw new TypeError(`The units of the start and end values must match. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`);
54
+ }
55
+ const startNumber = initialStylePropertyPart.number;
56
+ const endNumber = finalStylePropertyPart.number || 0;
57
+ const interpolatedNumber = (0, remotion_1.interpolate)(inputValue, inputRange, [startNumber, endNumber], options);
58
+ const interpolatedUnit = initialStylePropertyPart.unit || finalStylePropertyPart.unit || '';
59
+ if (!interpolatedUnit) {
60
+ return interpolatedNumber;
61
+ }
62
+ return `${interpolatedNumber}${interpolatedUnit}`;
63
+ };
64
+ const interpolateProperty = ({ inputValue, inputRange, initialStyleProperty, finalStyleProperty, options, }) => {
65
+ if (typeof initialStyleProperty !== typeof finalStyleProperty &&
66
+ initialStyleProperty !== 0 &&
67
+ finalStyleProperty !== 0) {
68
+ throw new TypeError(`The start and end values must be of the same type. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`);
69
+ }
70
+ const initialStylePropertyParts = (0, utils_1.breakDownValueIntoUnitNumberAndFunctions)(initialStyleProperty);
71
+ const finalStylePropertyParts = (0, utils_1.breakDownValueIntoUnitNumberAndFunctions)(finalStyleProperty);
72
+ if (initialStylePropertyParts.length !== finalStylePropertyParts.length) {
73
+ throw new TypeError(`The start and end values must have the same structure. Start value: ${initialStyleProperty}, end value: ${finalStyleProperty}`);
74
+ }
75
+ const interpolatedValue = initialStylePropertyParts.reduce((acc, initialStylePropertyPart, index) => {
76
+ return `${acc} ${interpolatedPropertyPart({
77
+ inputValue,
78
+ inputRange,
79
+ initialStylePropertyPart,
80
+ finalStylePropertyPart: finalStylePropertyParts[index],
81
+ initialStyleProperty,
82
+ finalStyleProperty,
83
+ options,
84
+ })}`;
85
+ }, '');
86
+ return interpolatedValue.slice(1);
87
+ };
88
+ const interpolateStylesFunction = ({ inputValue, inputRange, initialStyle, finalStyle, options, }) => {
89
+ const [startingValue, endingValue] = inputRange;
90
+ return Object.keys(initialStyle).reduce((acc, key) => {
91
+ const value = finalStyle[key];
92
+ if (value === undefined || value === null) {
93
+ return {
94
+ ...acc,
95
+ [key]: initialStyle[key],
96
+ };
97
+ }
98
+ const finalStyleValue = interpolateProperty({
99
+ inputValue,
100
+ inputRange: [startingValue, endingValue],
101
+ initialStyleProperty: initialStyle[key],
102
+ finalStyleProperty: finalStyle[key],
103
+ options,
104
+ });
105
+ // Avoid number to be a string
106
+ if (!isNaN(Number(finalStyleValue))) {
107
+ return {
108
+ ...acc,
109
+ [key]: Number(finalStyleValue),
110
+ };
111
+ }
112
+ return {
113
+ ...acc,
114
+ [key]: finalStyleValue,
115
+ };
116
+ }, {});
117
+ };
118
+ function checkInputRange(arr) {
119
+ if (arr.length < 2) {
120
+ throw new Error('inputRange must have at least 2 elements');
121
+ }
122
+ for (let index = 0; index < arr.length; index++) {
123
+ if (typeof arr[index] !== 'number') {
124
+ throw new Error(`inputRange must contain only numbers`);
125
+ }
126
+ if (arr[index] === -Infinity || arr[index] === Infinity) {
127
+ throw new Error(`inputRange must contain only finite numbers, but got [${arr.join(',')}]`);
128
+ }
129
+ if (index > 0 && !(arr[index] > arr[index - 1])) {
130
+ throw new Error(`inputRange must be strictly monotonically non-decreasing but got [${arr.join(',')}]`);
131
+ }
132
+ }
133
+ }
134
+ function checkStylesRange(arr) {
135
+ if (arr.length < 2) {
136
+ throw new Error('outputStyles must have at least 2 elements');
137
+ }
138
+ for (const index in arr) {
139
+ if (typeof arr[index] !== 'object') {
140
+ throw new Error('outputStyles must contain only objects');
141
+ }
142
+ }
143
+ }
144
+ /*
145
+ * @description A function that interpolates between two styles based on an input range.
146
+ * @see [Documentation](https://remotion.dev/docs/animation-utils/interpolate-styles)
147
+ */
148
+ const interpolateStyles = (input, inputRange, outputStylesRange, options) => {
149
+ var _a, _b, _c;
150
+ if (typeof input === 'undefined') {
151
+ throw new Error('input can not be undefined');
152
+ }
153
+ if (typeof inputRange === 'undefined') {
154
+ throw new Error('inputRange can not be undefined');
155
+ }
156
+ if (typeof outputStylesRange === 'undefined') {
157
+ throw new Error('outputRange can not be undefined');
158
+ }
159
+ if (inputRange.length !== outputStylesRange.length) {
160
+ throw new Error('inputRange (' +
161
+ inputRange.length +
162
+ ') and outputStylesRange (' +
163
+ outputStylesRange.length +
164
+ ') must have the same length');
165
+ }
166
+ checkInputRange(inputRange);
167
+ checkStylesRange(outputStylesRange);
168
+ let startIndex = inputRange.findIndex((step) => input < step) - 1;
169
+ if (startIndex === -1) {
170
+ startIndex = 0;
171
+ }
172
+ if (startIndex === -2) {
173
+ startIndex = inputRange.length - 2;
174
+ }
175
+ const endIndex = startIndex + 1;
176
+ const startingValue = inputRange[startIndex];
177
+ const endingValue = inputRange[endIndex];
178
+ const initialStyle = outputStylesRange[startIndex];
179
+ const finalStyle = outputStylesRange[endIndex];
180
+ const easing = (_a = options === null || options === void 0 ? void 0 : options.easing) !== null && _a !== void 0 ? _a : ((num) => num);
181
+ const extrapolateLeft = (_b = options === null || options === void 0 ? void 0 : options.extrapolateLeft) !== null && _b !== void 0 ? _b : 'extend';
182
+ const extrapolateRight = (_c = options === null || options === void 0 ? void 0 : options.extrapolateRight) !== null && _c !== void 0 ? _c : 'extend';
183
+ return interpolateStylesFunction({
184
+ inputValue: input,
185
+ inputRange: [startingValue, endingValue],
186
+ initialStyle,
187
+ finalStyle,
188
+ options: {
189
+ easing,
190
+ extrapolateLeft,
191
+ extrapolateRight,
192
+ },
193
+ });
194
+ };
195
+ exports.interpolateStyles = interpolateStyles;
@@ -0,0 +1,41 @@
1
+ import type { ColorMatchers, CSSPropertiesValue } from '../../type';
2
+ declare function getColorMatchers(): ColorMatchers;
3
+ declare const breakDownValueIntoUnitNumberAndFunctions: (value: CSSPropertiesValue) => ({
4
+ number?: undefined;
5
+ unit?: undefined;
6
+ color: string;
7
+ function?: undefined;
8
+ } | {
9
+ number?: undefined;
10
+ unit?: undefined;
11
+ color?: undefined;
12
+ function: {
13
+ name: string;
14
+ values: ({
15
+ number: number;
16
+ unit: string;
17
+ } | {
18
+ number: number;
19
+ unit?: undefined;
20
+ } | {
21
+ number?: undefined;
22
+ unit: string;
23
+ })[];
24
+ };
25
+ } | {
26
+ color?: undefined;
27
+ function?: undefined;
28
+ number: number;
29
+ unit: string;
30
+ } | {
31
+ unit?: undefined;
32
+ color?: undefined;
33
+ function?: undefined;
34
+ number: number;
35
+ } | {
36
+ number?: undefined;
37
+ color?: undefined;
38
+ function?: undefined;
39
+ unit: string;
40
+ })[];
41
+ export { breakDownValueIntoUnitNumberAndFunctions, getColorMatchers };
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.breakDownValueIntoUnitNumberAndFunctions = void 0;
4
+ exports.getColorMatchers = getColorMatchers;
5
+ const no_react_1 = require("remotion/no-react");
6
+ const constants_1 = require("./constants");
7
+ function call(...args) {
8
+ return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)';
9
+ }
10
+ const MODERN_VALUE = '(?:none|[-+]?\\d*\\.?\\d+(?:%|deg|rad|grad|turn)?)';
11
+ function modernColorCall(name) {
12
+ return new RegExp(name +
13
+ '\\(\\s*(' +
14
+ MODERN_VALUE +
15
+ ')\\s+(' +
16
+ MODERN_VALUE +
17
+ ')\\s+(' +
18
+ MODERN_VALUE +
19
+ ')(?:\\s*\\/\\s*(' +
20
+ MODERN_VALUE +
21
+ '))?\\s*\\)');
22
+ }
23
+ function getColorMatchers() {
24
+ const cachedMatchers = {
25
+ rgb: undefined,
26
+ rgba: undefined,
27
+ hsl: undefined,
28
+ hsla: undefined,
29
+ hex3: undefined,
30
+ hex4: undefined,
31
+ hex5: undefined,
32
+ hex6: undefined,
33
+ hex8: undefined,
34
+ oklch: undefined,
35
+ oklab: undefined,
36
+ lab: undefined,
37
+ lch: undefined,
38
+ hwb: undefined,
39
+ };
40
+ if (cachedMatchers.rgb === undefined) {
41
+ cachedMatchers.rgb = new RegExp('rgb' + call(constants_1.NUMBER, constants_1.NUMBER, constants_1.NUMBER));
42
+ cachedMatchers.rgba = new RegExp('rgba' + call(constants_1.NUMBER, constants_1.NUMBER, constants_1.NUMBER, constants_1.NUMBER));
43
+ cachedMatchers.hsl = new RegExp('hsl' + call(constants_1.NUMBER, constants_1.PERCENTAGE, constants_1.PERCENTAGE));
44
+ cachedMatchers.hsla = new RegExp('hsla' + call(constants_1.NUMBER, constants_1.PERCENTAGE, constants_1.PERCENTAGE, constants_1.NUMBER));
45
+ cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
46
+ cachedMatchers.hex4 =
47
+ /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
48
+ cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
49
+ cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
50
+ cachedMatchers.oklch = modernColorCall('oklch');
51
+ cachedMatchers.oklab = modernColorCall('oklab');
52
+ cachedMatchers.lab = modernColorCall('lab');
53
+ cachedMatchers.lch = modernColorCall('lch');
54
+ cachedMatchers.hwb = modernColorCall('hwb');
55
+ }
56
+ return cachedMatchers;
57
+ }
58
+ const extractOrderedPartsOfValue = (value) => {
59
+ const parts = [];
60
+ let remainingValue = value;
61
+ while (remainingValue.length > 0) {
62
+ const functionMatch = remainingValue.match(/([a-zA-Z-]+)\(([^)]+)\)/);
63
+ // If there's a function, add it to the parts and remove it from the remaining value
64
+ if (functionMatch) {
65
+ const { index } = functionMatch;
66
+ const matchedFunction = functionMatch[0];
67
+ // Add any parts before the function
68
+ if ((index || 0) > 0) {
69
+ parts.push(...remainingValue.substring(0, index).trim().split(/\s+/));
70
+ }
71
+ parts.push(matchedFunction);
72
+ remainingValue = remainingValue.substring((index || 0) + matchedFunction.length);
73
+ }
74
+ else {
75
+ // If there's no function, add the remaining value to the parts
76
+ parts.push(...remainingValue.trim().split(/\s+/));
77
+ break;
78
+ }
79
+ }
80
+ return parts.filter((part) => part !== ''); // Filter out any empty strings
81
+ };
82
+ const classifyArgsOfFunction = (value) => {
83
+ let nestedLevel = 0;
84
+ const values = [];
85
+ let currentValue = '';
86
+ for (const char of value) {
87
+ if (char === '(')
88
+ nestedLevel++;
89
+ else if (char === ')')
90
+ nestedLevel--;
91
+ if (char === ',' && nestedLevel === 0) {
92
+ values.push(currentValue.trim());
93
+ currentValue = '';
94
+ }
95
+ else {
96
+ currentValue += char;
97
+ }
98
+ }
99
+ if (currentValue)
100
+ values.push(currentValue.trim());
101
+ // Classify each value
102
+ return values.map((val) => {
103
+ const numberUnitMatch = val.match(/^(-?\d+(?:\.\d+)?)([a-zA-Z%]*)$/);
104
+ if (numberUnitMatch) {
105
+ const number = parseFloat(numberUnitMatch[1]);
106
+ const unit = numberUnitMatch[2];
107
+ return unit ? { number, unit } : { number };
108
+ }
109
+ const numberMatch = val.match(/^(\d+(?:\.\d+)?)$/);
110
+ if (numberMatch) {
111
+ const number = parseFloat(numberMatch[1]);
112
+ return { number };
113
+ }
114
+ return { unit: val };
115
+ });
116
+ };
117
+ const isColorValue = (value) => {
118
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
119
+ if (Object.keys(no_react_1.NoReactInternals.colorNames).includes(value)) {
120
+ return true;
121
+ }
122
+ const matchers = getColorMatchers();
123
+ return (((_a = matchers.rgb) === null || _a === void 0 ? void 0 : _a.test(value)) ||
124
+ ((_b = matchers.rgba) === null || _b === void 0 ? void 0 : _b.test(value)) ||
125
+ ((_c = matchers.hsl) === null || _c === void 0 ? void 0 : _c.test(value)) ||
126
+ ((_d = matchers.hsla) === null || _d === void 0 ? void 0 : _d.test(value)) ||
127
+ ((_e = matchers.hex3) === null || _e === void 0 ? void 0 : _e.test(value)) ||
128
+ ((_f = matchers.hex4) === null || _f === void 0 ? void 0 : _f.test(value)) ||
129
+ ((_g = matchers.hex5) === null || _g === void 0 ? void 0 : _g.test(value)) ||
130
+ ((_h = matchers.hex6) === null || _h === void 0 ? void 0 : _h.test(value)) ||
131
+ ((_j = matchers.hex8) === null || _j === void 0 ? void 0 : _j.test(value)) ||
132
+ ((_k = matchers.oklch) === null || _k === void 0 ? void 0 : _k.test(value)) ||
133
+ ((_l = matchers.oklab) === null || _l === void 0 ? void 0 : _l.test(value)) ||
134
+ ((_m = matchers.lab) === null || _m === void 0 ? void 0 : _m.test(value)) ||
135
+ ((_o = matchers.lch) === null || _o === void 0 ? void 0 : _o.test(value)) ||
136
+ ((_p = matchers.hwb) === null || _p === void 0 ? void 0 : _p.test(value)));
137
+ };
138
+ const classifyParts = (parts) => {
139
+ return parts.map((part) => {
140
+ // Check for a color value like 'red', 'rgba(0, 0, 0, 0)', '#fff', etc.
141
+ if (isColorValue(part)) {
142
+ return { color: part };
143
+ }
144
+ // Check for a function like 'translateX(10px)' or 'rotate(90deg)'
145
+ const functionMatch = part.match(/([a-zA-Z-]+)\(([^)]+)\)/);
146
+ if (functionMatch) {
147
+ const functionName = functionMatch[1];
148
+ const functionValues = classifyArgsOfFunction(functionMatch[2]);
149
+ return { function: { name: functionName, values: functionValues } };
150
+ }
151
+ // Check for a number possibly followed by a unit like '10px' or '10' or '-10px'
152
+ const numberUnitMatch = part.match(/^(-?\d+(?:\.\d+)?)([a-zA-Z%]*)$/);
153
+ if (numberUnitMatch) {
154
+ const number = parseFloat(numberUnitMatch[1]);
155
+ const unit = numberUnitMatch[2];
156
+ return unit ? { number, unit } : { number };
157
+ }
158
+ // Check for a number without a unit like '10' or '-10'
159
+ const numberMatch = part.match(/^(-?\d+(?:\.\d+)?)$/);
160
+ if (numberMatch) {
161
+ const number = parseFloat(numberMatch[1]);
162
+ return { number };
163
+ }
164
+ // If neither, treat as a unit (like 'solid', 'none', etc.)
165
+ return { unit: part };
166
+ });
167
+ };
168
+ const breakDownValueIntoUnitNumberAndFunctions = (value) => {
169
+ if (typeof value === 'number') {
170
+ return [{ number: value }];
171
+ }
172
+ if (typeof value !== 'string') {
173
+ return [];
174
+ }
175
+ const valueParts = extractOrderedPartsOfValue(value);
176
+ return classifyParts(valueParts);
177
+ };
178
+ exports.breakDownValueIntoUnitNumberAndFunctions = breakDownValueIntoUnitNumberAndFunctions;
@@ -0,0 +1,3 @@
1
+ import { matrix, matrix3d, perspective, rotate, rotate3d, rotateX, rotateY, rotateZ, scale, scale3d, scaleX, scaleY, scaleZ, skew, skewX, skewY, translate, translate3d, translateX, translateY, translateZ } from './transform-functions';
2
+ export declare const makeTransform: (transforms: string[]) => string;
3
+ export { matrix, matrix3d, perspective, rotate, rotate3d, rotateX, rotateY, rotateZ, scale, scale3d, scaleX, scaleY, scaleZ, skew, skewX, skewY, translate, translate3d, translateX, translateY, translateZ, };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.translateZ = exports.translateY = exports.translateX = exports.translate3d = exports.translate = exports.skewY = exports.skewX = exports.skew = exports.scaleZ = exports.scaleY = exports.scaleX = exports.scale3d = exports.scale = exports.rotateZ = exports.rotateY = exports.rotateX = exports.rotate3d = exports.rotate = exports.perspective = exports.matrix3d = exports.matrix = exports.makeTransform = void 0;
4
+ const transform_functions_1 = require("./transform-functions");
5
+ Object.defineProperty(exports, "matrix", { enumerable: true, get: function () { return transform_functions_1.matrix; } });
6
+ Object.defineProperty(exports, "matrix3d", { enumerable: true, get: function () { return transform_functions_1.matrix3d; } });
7
+ Object.defineProperty(exports, "perspective", { enumerable: true, get: function () { return transform_functions_1.perspective; } });
8
+ Object.defineProperty(exports, "rotate", { enumerable: true, get: function () { return transform_functions_1.rotate; } });
9
+ Object.defineProperty(exports, "rotate3d", { enumerable: true, get: function () { return transform_functions_1.rotate3d; } });
10
+ Object.defineProperty(exports, "rotateX", { enumerable: true, get: function () { return transform_functions_1.rotateX; } });
11
+ Object.defineProperty(exports, "rotateY", { enumerable: true, get: function () { return transform_functions_1.rotateY; } });
12
+ Object.defineProperty(exports, "rotateZ", { enumerable: true, get: function () { return transform_functions_1.rotateZ; } });
13
+ Object.defineProperty(exports, "scale", { enumerable: true, get: function () { return transform_functions_1.scale; } });
14
+ Object.defineProperty(exports, "scale3d", { enumerable: true, get: function () { return transform_functions_1.scale3d; } });
15
+ Object.defineProperty(exports, "scaleX", { enumerable: true, get: function () { return transform_functions_1.scaleX; } });
16
+ Object.defineProperty(exports, "scaleY", { enumerable: true, get: function () { return transform_functions_1.scaleY; } });
17
+ Object.defineProperty(exports, "scaleZ", { enumerable: true, get: function () { return transform_functions_1.scaleZ; } });
18
+ Object.defineProperty(exports, "skew", { enumerable: true, get: function () { return transform_functions_1.skew; } });
19
+ Object.defineProperty(exports, "skewX", { enumerable: true, get: function () { return transform_functions_1.skewX; } });
20
+ Object.defineProperty(exports, "skewY", { enumerable: true, get: function () { return transform_functions_1.skewY; } });
21
+ Object.defineProperty(exports, "translate", { enumerable: true, get: function () { return transform_functions_1.translate; } });
22
+ Object.defineProperty(exports, "translate3d", { enumerable: true, get: function () { return transform_functions_1.translate3d; } });
23
+ Object.defineProperty(exports, "translateX", { enumerable: true, get: function () { return transform_functions_1.translateX; } });
24
+ Object.defineProperty(exports, "translateY", { enumerable: true, get: function () { return transform_functions_1.translateY; } });
25
+ Object.defineProperty(exports, "translateZ", { enumerable: true, get: function () { return transform_functions_1.translateZ; } });
26
+ const makeTransform = (transforms) => {
27
+ return transforms.join(' ');
28
+ };
29
+ exports.makeTransform = makeTransform;
@@ -0,0 +1 @@
1
+ export declare const isUnitWithString: (input: unknown, units: readonly string[]) => boolean;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUnitWithString = void 0;
4
+ const type_1 = require("../../type");
5
+ const isUnitWithString = (input, units) => {
6
+ if (typeof input !== 'string') {
7
+ return false;
8
+ }
9
+ if (!units.find((u) => input.endsWith(u))) {
10
+ throw new Error(`input ${input} does not end with a valid unit. Valid units are: ${units.join(', ')}`);
11
+ }
12
+ const match = input.match(/([0-9.]+)([a-z%]+)/);
13
+ if (!match) {
14
+ throw new Error(`input ${input} is not a valid transform. Must be a number or a string ending in one of the following units: ${type_1.lengthUnits.join(', ')}`);
15
+ }
16
+ return true;
17
+ };
18
+ exports.isUnitWithString = isUnitWithString;
@@ -0,0 +1,46 @@
1
+ import type { AngleUnit, AngleUnitString, LengthPercentageUnit, LengthPercentageUnitString, LengthUnit, LengthUnitString } from '../../type';
2
+ declare function matrix(a: number, b: number, c: number, d: number, tx: number, ty: number): string;
3
+ declare function matrix3d(a1: number, b1: number, c1: number, d1: number, a2: number, b2: number, c2: number, d2: number, a3: number, b3: number, c3: number, d3: number, a4: number, b4: number, c4: number, d4: number): string;
4
+ declare function perspective(length: LengthPercentageUnitString): string;
5
+ declare function perspective(length: number, unit?: LengthUnit): string;
6
+ declare function rotate(angle: AngleUnitString): string;
7
+ declare function rotate(angle: number, unit?: AngleUnit): string;
8
+ declare function rotate3d(x: number, y: number, z: number, angle: number): string;
9
+ declare function rotate3d(x: number, y: number, z: number, angle: AngleUnitString): string;
10
+ declare function rotate3d(x: number, y: number, z: number, angle: number, unit?: AngleUnit): string;
11
+ declare function rotateX(angle: AngleUnitString): string;
12
+ declare function rotateX(angle: number, unit?: AngleUnit): string;
13
+ declare function rotateY(angle: AngleUnitString): string;
14
+ declare function rotateY(angle: number, unit?: AngleUnit): string;
15
+ declare function rotateZ(angle: AngleUnitString): string;
16
+ declare function rotateZ(angle: number, unit?: AngleUnit): string;
17
+ declare function scale(x: number, y?: number): string;
18
+ declare function scale3d(x: number, y: number, z: number): string;
19
+ declare function scaleX(x: number): string;
20
+ declare function scaleY(y: number): string;
21
+ declare function scaleZ(z: number): string;
22
+ declare function skew(angle: number): string;
23
+ declare function skew(angle: AngleUnitString): string;
24
+ declare function skew(angle: AngleUnitString, angle2: AngleUnitString): string;
25
+ declare function skew(angle: number, unit: AngleUnit): string;
26
+ declare function skew(angleX: number, angleY: number): string;
27
+ declare function skew(angleX: number, unitX: AngleUnit, angleY: number, unitY: AngleUnit): string;
28
+ declare function skewX(angle: AngleUnitString): string;
29
+ declare function skewX(angle: number, unit?: AngleUnit): string;
30
+ declare function skewY(angle: AngleUnitString): string;
31
+ declare function skewY(angle: number, unit?: AngleUnit): string;
32
+ declare function translate(x: LengthPercentageUnitString): string;
33
+ declare function translate(x: number): string;
34
+ declare function translate(x: number, y: number): string;
35
+ declare function translate(x: LengthPercentageUnitString, y: LengthPercentageUnitString): string;
36
+ declare function translate(translation: number, unit: LengthPercentageUnit): string;
37
+ declare function translate(x: number, unitX: LengthPercentageUnit, y: number, unitY: LengthPercentageUnit): string;
38
+ declare function translate3d(x: LengthPercentageUnitString | number, y: LengthPercentageUnitString | number, z: LengthPercentageUnitString | number): string;
39
+ declare function translate3d(x: number, unitX: LengthPercentageUnit, y: number, unitY: LengthPercentageUnit, z: number, unitZ: LengthUnit): string;
40
+ declare function translateX(x: LengthPercentageUnitString): string;
41
+ declare function translateX(x: number, unit?: LengthPercentageUnit): string;
42
+ declare function translateY(y: LengthPercentageUnitString): string;
43
+ declare function translateY(y: number, unit?: LengthPercentageUnit): string;
44
+ declare function translateZ(z: LengthUnitString): string;
45
+ declare function translateZ(z: number, unit?: LengthUnit): string;
46
+ export { matrix, matrix3d, perspective, rotate, rotate3d, rotateX, rotateY, rotateZ, scale, scale3d, scaleX, scaleY, scaleZ, skew, skewX, skewY, translate, translate3d, translateX, translateY, translateZ, };