remotion 4.0.71 → 4.0.73
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.
- package/dist/cjs/audio/Audio.d.ts +2 -1
- package/dist/cjs/audio/Audio.js +3 -3
- package/dist/cjs/audio/AudioForDevelopment.d.ts +2 -0
- package/dist/cjs/audio/AudioForDevelopment.js +9 -2
- package/dist/cjs/audio/AudioForRendering.d.ts +1 -0
- package/dist/cjs/audio/AudioForRendering.js +1 -1
- package/dist/cjs/audio/props.d.ts +1 -0
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +4 -5
- package/dist/cjs/internals.d.ts +0 -23
- package/dist/cjs/internals.js +0 -18
- package/dist/cjs/no-react.d.ts +32 -0
- package/dist/cjs/no-react.js +30 -0
- package/dist/cjs/use-media-playback.js +10 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/OffthreadVideo.js +1 -1
- package/dist/cjs/video/Video.js +3 -3
- package/dist/cjs/video/VideoForDevelopment.d.ts +1 -0
- package/dist/cjs/video/VideoForDevelopment.js +2 -2
- package/dist/cjs/video/VideoForRendering.js +1 -1
- package/dist/cjs/video/props.d.ts +4 -0
- package/dist/esm/index.mjs +510 -522
- package/dist/esm/no-react.mjs +748 -0
- package/dist/esm/version.mjs +1 -1
- package/no-react.js +2 -0
- package/package.json +11 -2
- package/rollup-no-react.config.js +22 -0
|
@@ -0,0 +1,748 @@
|
|
|
1
|
+
// Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/nodes/AnimatedInterpolation.js
|
|
2
|
+
function interpolateFunction(input, inputRange, outputRange, options) {
|
|
3
|
+
const { extrapolateLeft, extrapolateRight, easing } = options;
|
|
4
|
+
let result = input;
|
|
5
|
+
const [inputMin, inputMax] = inputRange;
|
|
6
|
+
const [outputMin, outputMax] = outputRange;
|
|
7
|
+
if (result < inputMin) {
|
|
8
|
+
if (extrapolateLeft === 'identity') {
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
if (extrapolateLeft === 'clamp') {
|
|
12
|
+
result = inputMin;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (result > inputMax) {
|
|
16
|
+
if (extrapolateRight === 'identity') {
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
if (extrapolateRight === 'clamp') {
|
|
20
|
+
result = inputMax;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (outputMin === outputMax) {
|
|
24
|
+
return outputMin;
|
|
25
|
+
}
|
|
26
|
+
// Input Range
|
|
27
|
+
result = (result - inputMin) / (inputMax - inputMin);
|
|
28
|
+
// Easing
|
|
29
|
+
result = easing(result);
|
|
30
|
+
// Output Range
|
|
31
|
+
result = result * (outputMax - outputMin) + outputMin;
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function findRange(input, inputRange) {
|
|
35
|
+
let i;
|
|
36
|
+
for (i = 1; i < inputRange.length - 1; ++i) {
|
|
37
|
+
if (inputRange[i] >= input) {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return i - 1;
|
|
42
|
+
}
|
|
43
|
+
function checkValidInputRange(arr) {
|
|
44
|
+
for (let i = 1; i < arr.length; ++i) {
|
|
45
|
+
if (!(arr[i] > arr[i - 1])) {
|
|
46
|
+
throw new Error(`inputRange must be strictly monotonically non-decreasing but got [${arr.join(',')}]`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function checkInfiniteRange(name, arr) {
|
|
51
|
+
if (arr.length < 2) {
|
|
52
|
+
throw new Error(name + ' must have at least 2 elements');
|
|
53
|
+
}
|
|
54
|
+
for (const index in arr) {
|
|
55
|
+
if (typeof arr[index] !== 'number') {
|
|
56
|
+
throw new Error(`${name} must contain only numbers`);
|
|
57
|
+
}
|
|
58
|
+
if (arr[index] === -Infinity || arr[index] === Infinity) {
|
|
59
|
+
throw new Error(`${name} must contain only finite numbers, but got [${arr.join(',')}]`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Map a value from an input range to an output range.
|
|
65
|
+
* @link https://www.remotion.dev/docs/interpolate
|
|
66
|
+
* @param {!number} input value to interpolate
|
|
67
|
+
* @param {!number[]} inputRange range of values that you expect the input to assume.
|
|
68
|
+
* @param {!number[]} outputRange range of output values that you want the input to map to.
|
|
69
|
+
* @param {?object} options
|
|
70
|
+
* @param {?Function} options.easing easing function which allows you to customize the input, for example to apply a certain easing function. By default, the input is left unmodified, resulting in a pure linear interpolation {@link https://www.remotion.dev/docs/easing}
|
|
71
|
+
* @param {string=} [options.extrapolateLeft="extend"] What should happen if the input value is outside left the input range, default: "extend" {@link https://www.remotion.dev/docs/interpolate#extrapolateleft}
|
|
72
|
+
* @param {string=} [options.extrapolateRight="extend"] Same as extrapolateLeft, except for values outside right the input range {@link https://www.remotion.dev/docs/interpolate#extrapolateright}
|
|
73
|
+
*/
|
|
74
|
+
function interpolate(input, inputRange, outputRange, options) {
|
|
75
|
+
var _a;
|
|
76
|
+
if (typeof input === 'undefined') {
|
|
77
|
+
throw new Error('input can not be undefined');
|
|
78
|
+
}
|
|
79
|
+
if (typeof inputRange === 'undefined') {
|
|
80
|
+
throw new Error('inputRange can not be undefined');
|
|
81
|
+
}
|
|
82
|
+
if (typeof outputRange === 'undefined') {
|
|
83
|
+
throw new Error('outputRange can not be undefined');
|
|
84
|
+
}
|
|
85
|
+
if (inputRange.length !== outputRange.length) {
|
|
86
|
+
throw new Error('inputRange (' +
|
|
87
|
+
inputRange.length +
|
|
88
|
+
') and outputRange (' +
|
|
89
|
+
outputRange.length +
|
|
90
|
+
') must have the same length');
|
|
91
|
+
}
|
|
92
|
+
checkInfiniteRange('inputRange', inputRange);
|
|
93
|
+
checkInfiniteRange('outputRange', outputRange);
|
|
94
|
+
checkValidInputRange(inputRange);
|
|
95
|
+
const easing = (_a = options === null || options === void 0 ? void 0 : options.easing) !== null && _a !== void 0 ? _a : ((num) => num);
|
|
96
|
+
let extrapolateLeft = 'extend';
|
|
97
|
+
if ((options === null || options === void 0 ? void 0 : options.extrapolateLeft) !== undefined) {
|
|
98
|
+
extrapolateLeft = options.extrapolateLeft;
|
|
99
|
+
}
|
|
100
|
+
let extrapolateRight = 'extend';
|
|
101
|
+
if ((options === null || options === void 0 ? void 0 : options.extrapolateRight) !== undefined) {
|
|
102
|
+
extrapolateRight = options.extrapolateRight;
|
|
103
|
+
}
|
|
104
|
+
if (typeof input !== 'number') {
|
|
105
|
+
throw new TypeError('Cannot interpolate an input which is not a number');
|
|
106
|
+
}
|
|
107
|
+
const range = findRange(input, inputRange);
|
|
108
|
+
return interpolateFunction(input, [inputRange[range], inputRange[range + 1]], [outputRange[range], outputRange[range + 1]], {
|
|
109
|
+
easing,
|
|
110
|
+
extrapolateLeft,
|
|
111
|
+
extrapolateRight,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* eslint-disable no-bitwise */
|
|
116
|
+
function mulberry32(a) {
|
|
117
|
+
let t = a + 0x6d2b79f5;
|
|
118
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
119
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
120
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
121
|
+
}
|
|
122
|
+
function hashCode(str) {
|
|
123
|
+
let i = 0;
|
|
124
|
+
let chr = 0;
|
|
125
|
+
let hash = 0;
|
|
126
|
+
for (i = 0; i < str.length; i++) {
|
|
127
|
+
chr = str.charCodeAt(i);
|
|
128
|
+
hash = (hash << 5) - hash + chr;
|
|
129
|
+
hash |= 0; // Convert to 32bit integer
|
|
130
|
+
}
|
|
131
|
+
return hash;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @description A deterministic pseudo-random number generator. Pass in the same seed and get the same pseudorandom number.
|
|
135
|
+
* @see [Documentation](https://remotion.dev/docs/random)
|
|
136
|
+
*/
|
|
137
|
+
const random = (seed, dummy) => {
|
|
138
|
+
if (dummy !== undefined) {
|
|
139
|
+
throw new TypeError('random() takes only one argument');
|
|
140
|
+
}
|
|
141
|
+
if (seed === null) {
|
|
142
|
+
return Math.random();
|
|
143
|
+
}
|
|
144
|
+
if (typeof seed === 'string') {
|
|
145
|
+
return mulberry32(hashCode(seed));
|
|
146
|
+
}
|
|
147
|
+
if (typeof seed === 'number') {
|
|
148
|
+
return mulberry32(seed * 10000000000);
|
|
149
|
+
}
|
|
150
|
+
throw new Error('random() argument must be a number or a string');
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
function truthy(value) {
|
|
154
|
+
return Boolean(value);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (typeof window !== 'undefined') {
|
|
158
|
+
window.remotion_renderReady = false;
|
|
159
|
+
}
|
|
160
|
+
if (typeof window !== 'undefined') {
|
|
161
|
+
window.remotion_delayRenderTimeouts = {};
|
|
162
|
+
}
|
|
163
|
+
const DELAY_RENDER_CALLSTACK_TOKEN = 'The delayRender was called:';
|
|
164
|
+
|
|
165
|
+
const problematicCharacters = {
|
|
166
|
+
'%3A': ':',
|
|
167
|
+
'%2F': '/',
|
|
168
|
+
'%3F': '?',
|
|
169
|
+
'%23': '#',
|
|
170
|
+
'%5B': '[',
|
|
171
|
+
'%5D': ']',
|
|
172
|
+
'%40': '@',
|
|
173
|
+
'%21': '!',
|
|
174
|
+
'%24': '$',
|
|
175
|
+
'%26': '&',
|
|
176
|
+
'%27': "'",
|
|
177
|
+
'%28': '(',
|
|
178
|
+
'%29': ')',
|
|
179
|
+
'%2A': '*',
|
|
180
|
+
'%2B': '+',
|
|
181
|
+
'%2C': ',',
|
|
182
|
+
'%3B': ';',
|
|
183
|
+
};
|
|
184
|
+
const didWarn = {};
|
|
185
|
+
const warnOnce = (message) => {
|
|
186
|
+
if (didWarn[message]) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
console.warn(message);
|
|
190
|
+
didWarn[message] = true;
|
|
191
|
+
};
|
|
192
|
+
const includesHexOfUnsafeChar = (path) => {
|
|
193
|
+
for (const key of Object.keys(problematicCharacters)) {
|
|
194
|
+
if (path.includes(key)) {
|
|
195
|
+
return { containsHex: true, hexCode: key };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return { containsHex: false };
|
|
199
|
+
};
|
|
200
|
+
const trimLeadingSlash = (path) => {
|
|
201
|
+
if (path.startsWith('/')) {
|
|
202
|
+
return trimLeadingSlash(path.substring(1));
|
|
203
|
+
}
|
|
204
|
+
return path;
|
|
205
|
+
};
|
|
206
|
+
const inner = (path) => {
|
|
207
|
+
if (typeof window !== 'undefined' && window.remotion_staticBase) {
|
|
208
|
+
if (path.startsWith(window.remotion_staticBase)) {
|
|
209
|
+
throw new Error(`The value "${path}" is already prefixed with the static base ${window.remotion_staticBase}. You don't need to call staticFile() on it.`);
|
|
210
|
+
}
|
|
211
|
+
return `${window.remotion_staticBase}/${trimLeadingSlash(path)}`;
|
|
212
|
+
}
|
|
213
|
+
return `/${trimLeadingSlash(path)}`;
|
|
214
|
+
};
|
|
215
|
+
const encodeBySplitting = (path) => {
|
|
216
|
+
const splitBySlash = path.split('/');
|
|
217
|
+
const encodedArray = splitBySlash.map((element) => {
|
|
218
|
+
return encodeURIComponent(element);
|
|
219
|
+
});
|
|
220
|
+
const merged = encodedArray.join('/');
|
|
221
|
+
return merged;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* @description Reference a file from the public/ folder. If the file does not appear in the autocomplete, type the path manually.
|
|
225
|
+
* @see [Documentation](https://www.remotion.dev/docs/staticfile)
|
|
226
|
+
*/
|
|
227
|
+
const staticFile = (path) => {
|
|
228
|
+
if (path.startsWith('http://') || path.startsWith('https://')) {
|
|
229
|
+
throw new TypeError(`staticFile() does not support remote URLs - got "${path}". Instead, pass the URL without wrapping it in staticFile(). See: https://remotion.dev/docs/staticfile-remote-urls`);
|
|
230
|
+
}
|
|
231
|
+
if (path.startsWith('..') || path.startsWith('./')) {
|
|
232
|
+
throw new TypeError(`staticFile() does not support relative paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
233
|
+
}
|
|
234
|
+
if (path.startsWith('/Users') ||
|
|
235
|
+
path.startsWith('/home') ||
|
|
236
|
+
path.startsWith('/tmp') ||
|
|
237
|
+
path.startsWith('/etc') ||
|
|
238
|
+
path.startsWith('/opt') ||
|
|
239
|
+
path.startsWith('/var') ||
|
|
240
|
+
path.startsWith('C:') ||
|
|
241
|
+
path.startsWith('D:') ||
|
|
242
|
+
path.startsWith('E:')) {
|
|
243
|
+
throw new TypeError(`staticFile() does not support absolute paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
244
|
+
}
|
|
245
|
+
if (path.startsWith('public/')) {
|
|
246
|
+
throw new TypeError(`Do not include the public/ prefix when using staticFile() - got "${path}". See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
247
|
+
}
|
|
248
|
+
const includesHex = includesHexOfUnsafeChar(path);
|
|
249
|
+
if (includesHex.containsHex) {
|
|
250
|
+
warnOnce(`WARNING: You seem to pass an already encoded path (path contains ${includesHex.hexCode}). Since Remotion 4.0, the encoding is done by staticFile() itself. You may want to remove a encodeURIComponent() wrapping.`);
|
|
251
|
+
}
|
|
252
|
+
const preprocessed = encodeBySplitting(path);
|
|
253
|
+
const preparsed = inner(preprocessed);
|
|
254
|
+
if (!preparsed.startsWith('/')) {
|
|
255
|
+
return `/${preparsed}`;
|
|
256
|
+
}
|
|
257
|
+
return preparsed;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// Must keep this file in sync with the one in packages/lambda/src/shared/serialize-props.ts!
|
|
261
|
+
const DATE_TOKEN = 'remotion-date:';
|
|
262
|
+
const FILE_TOKEN = 'remotion-file:';
|
|
263
|
+
const serializeJSONWithDate = ({ data, indent, staticBase, }) => {
|
|
264
|
+
let customDateUsed = false;
|
|
265
|
+
let customFileUsed = false;
|
|
266
|
+
let mapUsed = false;
|
|
267
|
+
let setUsed = false;
|
|
268
|
+
const serializedString = JSON.stringify(data, function (key, value) {
|
|
269
|
+
const item = this[key];
|
|
270
|
+
if (item instanceof Date) {
|
|
271
|
+
customDateUsed = true;
|
|
272
|
+
return `${DATE_TOKEN}${item.toISOString()}`;
|
|
273
|
+
}
|
|
274
|
+
if (item instanceof Map) {
|
|
275
|
+
mapUsed = true;
|
|
276
|
+
return value;
|
|
277
|
+
}
|
|
278
|
+
if (item instanceof Set) {
|
|
279
|
+
setUsed = true;
|
|
280
|
+
return value;
|
|
281
|
+
}
|
|
282
|
+
if (typeof item === 'string' &&
|
|
283
|
+
staticBase !== null &&
|
|
284
|
+
item.startsWith(staticBase)) {
|
|
285
|
+
customFileUsed = true;
|
|
286
|
+
return `${FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
|
|
287
|
+
}
|
|
288
|
+
return value;
|
|
289
|
+
}, indent);
|
|
290
|
+
return { serializedString, customDateUsed, customFileUsed, mapUsed, setUsed };
|
|
291
|
+
};
|
|
292
|
+
const deserializeJSONWithCustomFields = (data) => {
|
|
293
|
+
return JSON.parse(data, (_, value) => {
|
|
294
|
+
if (typeof value === 'string' && value.startsWith(DATE_TOKEN)) {
|
|
295
|
+
return new Date(value.replace(DATE_TOKEN, ''));
|
|
296
|
+
}
|
|
297
|
+
if (typeof value === 'string' && value.startsWith(FILE_TOKEN)) {
|
|
298
|
+
return staticFile(value.replace(FILE_TOKEN, ''));
|
|
299
|
+
}
|
|
300
|
+
return value;
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Copied from:
|
|
306
|
+
* https://github.com/software-mansion/react-native-reanimated/blob/master/src/reanimated2/Colors.ts
|
|
307
|
+
*/
|
|
308
|
+
// var INTEGER = '[-+]?\\d+';
|
|
309
|
+
const NUMBER = '[-+]?\\d*\\.?\\d+';
|
|
310
|
+
const PERCENTAGE = NUMBER + '%';
|
|
311
|
+
function call(...args) {
|
|
312
|
+
return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)';
|
|
313
|
+
}
|
|
314
|
+
function getMatchers() {
|
|
315
|
+
const cachedMatchers = {
|
|
316
|
+
rgb: undefined,
|
|
317
|
+
rgba: undefined,
|
|
318
|
+
hsl: undefined,
|
|
319
|
+
hsla: undefined,
|
|
320
|
+
hex3: undefined,
|
|
321
|
+
hex4: undefined,
|
|
322
|
+
hex5: undefined,
|
|
323
|
+
hex6: undefined,
|
|
324
|
+
hex8: undefined,
|
|
325
|
+
};
|
|
326
|
+
if (cachedMatchers.rgb === undefined) {
|
|
327
|
+
cachedMatchers.rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
|
|
328
|
+
cachedMatchers.rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER));
|
|
329
|
+
cachedMatchers.hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
|
|
330
|
+
cachedMatchers.hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
|
|
331
|
+
cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
|
332
|
+
cachedMatchers.hex4 =
|
|
333
|
+
/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
|
334
|
+
cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
|
|
335
|
+
cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
|
|
336
|
+
}
|
|
337
|
+
return cachedMatchers;
|
|
338
|
+
}
|
|
339
|
+
function hue2rgb(p, q, t) {
|
|
340
|
+
if (t < 0) {
|
|
341
|
+
t += 1;
|
|
342
|
+
}
|
|
343
|
+
if (t > 1) {
|
|
344
|
+
t -= 1;
|
|
345
|
+
}
|
|
346
|
+
if (t < 1 / 6) {
|
|
347
|
+
return p + (q - p) * 6 * t;
|
|
348
|
+
}
|
|
349
|
+
if (t < 1 / 2) {
|
|
350
|
+
return q;
|
|
351
|
+
}
|
|
352
|
+
if (t < 2 / 3) {
|
|
353
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
354
|
+
}
|
|
355
|
+
return p;
|
|
356
|
+
}
|
|
357
|
+
function hslToRgb(h, s, l) {
|
|
358
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
359
|
+
const p = 2 * l - q;
|
|
360
|
+
const r = hue2rgb(p, q, h + 1 / 3);
|
|
361
|
+
const g = hue2rgb(p, q, h);
|
|
362
|
+
const b = hue2rgb(p, q, h - 1 / 3);
|
|
363
|
+
return ((Math.round(r * 255) << 24) |
|
|
364
|
+
(Math.round(g * 255) << 16) |
|
|
365
|
+
(Math.round(b * 255) << 8));
|
|
366
|
+
}
|
|
367
|
+
function parse255(str) {
|
|
368
|
+
const int = Number.parseInt(str, 10);
|
|
369
|
+
if (int < 0) {
|
|
370
|
+
return 0;
|
|
371
|
+
}
|
|
372
|
+
if (int > 255) {
|
|
373
|
+
return 255;
|
|
374
|
+
}
|
|
375
|
+
return int;
|
|
376
|
+
}
|
|
377
|
+
function parse360(str) {
|
|
378
|
+
const int = Number.parseFloat(str);
|
|
379
|
+
return (((int % 360) + 360) % 360) / 360;
|
|
380
|
+
}
|
|
381
|
+
function parse1(str) {
|
|
382
|
+
const num = Number.parseFloat(str);
|
|
383
|
+
if (num < 0) {
|
|
384
|
+
return 0;
|
|
385
|
+
}
|
|
386
|
+
if (num > 1) {
|
|
387
|
+
return 255;
|
|
388
|
+
}
|
|
389
|
+
return Math.round(num * 255);
|
|
390
|
+
}
|
|
391
|
+
function parsePercentage(str) {
|
|
392
|
+
// parseFloat conveniently ignores the final %
|
|
393
|
+
const int = Number.parseFloat(str);
|
|
394
|
+
if (int < 0) {
|
|
395
|
+
return 0;
|
|
396
|
+
}
|
|
397
|
+
if (int > 100) {
|
|
398
|
+
return 1;
|
|
399
|
+
}
|
|
400
|
+
return int / 100;
|
|
401
|
+
}
|
|
402
|
+
const names = {
|
|
403
|
+
transparent: 0x00000000,
|
|
404
|
+
// http://www.w3.org/TR/css3-color/#svg-color
|
|
405
|
+
aliceblue: 0xf0f8ffff,
|
|
406
|
+
antiquewhite: 0xfaebd7ff,
|
|
407
|
+
aqua: 0x00ffffff,
|
|
408
|
+
aquamarine: 0x7fffd4ff,
|
|
409
|
+
azure: 0xf0ffffff,
|
|
410
|
+
beige: 0xf5f5dcff,
|
|
411
|
+
bisque: 0xffe4c4ff,
|
|
412
|
+
black: 0x000000ff,
|
|
413
|
+
blanchedalmond: 0xffebcdff,
|
|
414
|
+
blue: 0x0000ffff,
|
|
415
|
+
blueviolet: 0x8a2be2ff,
|
|
416
|
+
brown: 0xa52a2aff,
|
|
417
|
+
burlywood: 0xdeb887ff,
|
|
418
|
+
burntsienna: 0xea7e5dff,
|
|
419
|
+
cadetblue: 0x5f9ea0ff,
|
|
420
|
+
chartreuse: 0x7fff00ff,
|
|
421
|
+
chocolate: 0xd2691eff,
|
|
422
|
+
coral: 0xff7f50ff,
|
|
423
|
+
cornflowerblue: 0x6495edff,
|
|
424
|
+
cornsilk: 0xfff8dcff,
|
|
425
|
+
crimson: 0xdc143cff,
|
|
426
|
+
cyan: 0x00ffffff,
|
|
427
|
+
darkblue: 0x00008bff,
|
|
428
|
+
darkcyan: 0x008b8bff,
|
|
429
|
+
darkgoldenrod: 0xb8860bff,
|
|
430
|
+
darkgray: 0xa9a9a9ff,
|
|
431
|
+
darkgreen: 0x006400ff,
|
|
432
|
+
darkgrey: 0xa9a9a9ff,
|
|
433
|
+
darkkhaki: 0xbdb76bff,
|
|
434
|
+
darkmagenta: 0x8b008bff,
|
|
435
|
+
darkolivegreen: 0x556b2fff,
|
|
436
|
+
darkorange: 0xff8c00ff,
|
|
437
|
+
darkorchid: 0x9932ccff,
|
|
438
|
+
darkred: 0x8b0000ff,
|
|
439
|
+
darksalmon: 0xe9967aff,
|
|
440
|
+
darkseagreen: 0x8fbc8fff,
|
|
441
|
+
darkslateblue: 0x483d8bff,
|
|
442
|
+
darkslategray: 0x2f4f4fff,
|
|
443
|
+
darkslategrey: 0x2f4f4fff,
|
|
444
|
+
darkturquoise: 0x00ced1ff,
|
|
445
|
+
darkviolet: 0x9400d3ff,
|
|
446
|
+
deeppink: 0xff1493ff,
|
|
447
|
+
deepskyblue: 0x00bfffff,
|
|
448
|
+
dimgray: 0x696969ff,
|
|
449
|
+
dimgrey: 0x696969ff,
|
|
450
|
+
dodgerblue: 0x1e90ffff,
|
|
451
|
+
firebrick: 0xb22222ff,
|
|
452
|
+
floralwhite: 0xfffaf0ff,
|
|
453
|
+
forestgreen: 0x228b22ff,
|
|
454
|
+
fuchsia: 0xff00ffff,
|
|
455
|
+
gainsboro: 0xdcdcdcff,
|
|
456
|
+
ghostwhite: 0xf8f8ffff,
|
|
457
|
+
gold: 0xffd700ff,
|
|
458
|
+
goldenrod: 0xdaa520ff,
|
|
459
|
+
gray: 0x808080ff,
|
|
460
|
+
green: 0x008000ff,
|
|
461
|
+
greenyellow: 0xadff2fff,
|
|
462
|
+
grey: 0x808080ff,
|
|
463
|
+
honeydew: 0xf0fff0ff,
|
|
464
|
+
hotpink: 0xff69b4ff,
|
|
465
|
+
indianred: 0xcd5c5cff,
|
|
466
|
+
indigo: 0x4b0082ff,
|
|
467
|
+
ivory: 0xfffff0ff,
|
|
468
|
+
khaki: 0xf0e68cff,
|
|
469
|
+
lavender: 0xe6e6faff,
|
|
470
|
+
lavenderblush: 0xfff0f5ff,
|
|
471
|
+
lawngreen: 0x7cfc00ff,
|
|
472
|
+
lemonchiffon: 0xfffacdff,
|
|
473
|
+
lightblue: 0xadd8e6ff,
|
|
474
|
+
lightcoral: 0xf08080ff,
|
|
475
|
+
lightcyan: 0xe0ffffff,
|
|
476
|
+
lightgoldenrodyellow: 0xfafad2ff,
|
|
477
|
+
lightgray: 0xd3d3d3ff,
|
|
478
|
+
lightgreen: 0x90ee90ff,
|
|
479
|
+
lightgrey: 0xd3d3d3ff,
|
|
480
|
+
lightpink: 0xffb6c1ff,
|
|
481
|
+
lightsalmon: 0xffa07aff,
|
|
482
|
+
lightseagreen: 0x20b2aaff,
|
|
483
|
+
lightskyblue: 0x87cefaff,
|
|
484
|
+
lightslategray: 0x778899ff,
|
|
485
|
+
lightslategrey: 0x778899ff,
|
|
486
|
+
lightsteelblue: 0xb0c4deff,
|
|
487
|
+
lightyellow: 0xffffe0ff,
|
|
488
|
+
lime: 0x00ff00ff,
|
|
489
|
+
limegreen: 0x32cd32ff,
|
|
490
|
+
linen: 0xfaf0e6ff,
|
|
491
|
+
magenta: 0xff00ffff,
|
|
492
|
+
maroon: 0x800000ff,
|
|
493
|
+
mediumaquamarine: 0x66cdaaff,
|
|
494
|
+
mediumblue: 0x0000cdff,
|
|
495
|
+
mediumorchid: 0xba55d3ff,
|
|
496
|
+
mediumpurple: 0x9370dbff,
|
|
497
|
+
mediumseagreen: 0x3cb371ff,
|
|
498
|
+
mediumslateblue: 0x7b68eeff,
|
|
499
|
+
mediumspringgreen: 0x00fa9aff,
|
|
500
|
+
mediumturquoise: 0x48d1ccff,
|
|
501
|
+
mediumvioletred: 0xc71585ff,
|
|
502
|
+
midnightblue: 0x191970ff,
|
|
503
|
+
mintcream: 0xf5fffaff,
|
|
504
|
+
mistyrose: 0xffe4e1ff,
|
|
505
|
+
moccasin: 0xffe4b5ff,
|
|
506
|
+
navajowhite: 0xffdeadff,
|
|
507
|
+
navy: 0x000080ff,
|
|
508
|
+
oldlace: 0xfdf5e6ff,
|
|
509
|
+
olive: 0x808000ff,
|
|
510
|
+
olivedrab: 0x6b8e23ff,
|
|
511
|
+
orange: 0xffa500ff,
|
|
512
|
+
orangered: 0xff4500ff,
|
|
513
|
+
orchid: 0xda70d6ff,
|
|
514
|
+
palegoldenrod: 0xeee8aaff,
|
|
515
|
+
palegreen: 0x98fb98ff,
|
|
516
|
+
paleturquoise: 0xafeeeeff,
|
|
517
|
+
palevioletred: 0xdb7093ff,
|
|
518
|
+
papayawhip: 0xffefd5ff,
|
|
519
|
+
peachpuff: 0xffdab9ff,
|
|
520
|
+
peru: 0xcd853fff,
|
|
521
|
+
pink: 0xffc0cbff,
|
|
522
|
+
plum: 0xdda0ddff,
|
|
523
|
+
powderblue: 0xb0e0e6ff,
|
|
524
|
+
purple: 0x800080ff,
|
|
525
|
+
rebeccapurple: 0x663399ff,
|
|
526
|
+
red: 0xff0000ff,
|
|
527
|
+
rosybrown: 0xbc8f8fff,
|
|
528
|
+
royalblue: 0x4169e1ff,
|
|
529
|
+
saddlebrown: 0x8b4513ff,
|
|
530
|
+
salmon: 0xfa8072ff,
|
|
531
|
+
sandybrown: 0xf4a460ff,
|
|
532
|
+
seagreen: 0x2e8b57ff,
|
|
533
|
+
seashell: 0xfff5eeff,
|
|
534
|
+
sienna: 0xa0522dff,
|
|
535
|
+
silver: 0xc0c0c0ff,
|
|
536
|
+
skyblue: 0x87ceebff,
|
|
537
|
+
slateblue: 0x6a5acdff,
|
|
538
|
+
slategray: 0x708090ff,
|
|
539
|
+
slategrey: 0x708090ff,
|
|
540
|
+
snow: 0xfffafaff,
|
|
541
|
+
springgreen: 0x00ff7fff,
|
|
542
|
+
steelblue: 0x4682b4ff,
|
|
543
|
+
tan: 0xd2b48cff,
|
|
544
|
+
teal: 0x008080ff,
|
|
545
|
+
thistle: 0xd8bfd8ff,
|
|
546
|
+
tomato: 0xff6347ff,
|
|
547
|
+
turquoise: 0x40e0d0ff,
|
|
548
|
+
violet: 0xee82eeff,
|
|
549
|
+
wheat: 0xf5deb3ff,
|
|
550
|
+
white: 0xffffffff,
|
|
551
|
+
whitesmoke: 0xf5f5f5ff,
|
|
552
|
+
yellow: 0xffff00ff,
|
|
553
|
+
yellowgreen: 0x9acd32ff,
|
|
554
|
+
};
|
|
555
|
+
function normalizeColor(color) {
|
|
556
|
+
const matchers = getMatchers();
|
|
557
|
+
let match;
|
|
558
|
+
// Ordered based on occurrences on Facebook codebase
|
|
559
|
+
if (matchers.hex6) {
|
|
560
|
+
if ((match = matchers.hex6.exec(color))) {
|
|
561
|
+
return Number.parseInt(match[1] + 'ff', 16) >>> 0;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (names[color] !== undefined) {
|
|
565
|
+
return names[color];
|
|
566
|
+
}
|
|
567
|
+
if (matchers.rgb) {
|
|
568
|
+
if ((match = matchers.rgb.exec(color))) {
|
|
569
|
+
return (
|
|
570
|
+
// b
|
|
571
|
+
((parse255(match[1]) << 24) | // r
|
|
572
|
+
(parse255(match[2]) << 16) | // g
|
|
573
|
+
(parse255(match[3]) << 8) |
|
|
574
|
+
0x000000ff) >>> // a
|
|
575
|
+
0);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (matchers.rgba) {
|
|
579
|
+
if ((match = matchers.rgba.exec(color))) {
|
|
580
|
+
return (
|
|
581
|
+
// b
|
|
582
|
+
((parse255(match[1]) << 24) | // r
|
|
583
|
+
(parse255(match[2]) << 16) | // g
|
|
584
|
+
(parse255(match[3]) << 8) |
|
|
585
|
+
parse1(match[4])) >>> // a
|
|
586
|
+
0);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (matchers.hex3) {
|
|
590
|
+
if ((match = matchers.hex3.exec(color))) {
|
|
591
|
+
return (Number.parseInt(match[1] +
|
|
592
|
+
match[1] + // r
|
|
593
|
+
match[2] +
|
|
594
|
+
match[2] + // g
|
|
595
|
+
match[3] +
|
|
596
|
+
match[3] + // b
|
|
597
|
+
'ff', // a
|
|
598
|
+
16) >>> 0);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
// https://drafts.csswg.org/css-color-4/#hex-notation
|
|
602
|
+
if (matchers.hex8) {
|
|
603
|
+
if ((match = matchers.hex8.exec(color))) {
|
|
604
|
+
return Number.parseInt(match[1], 16) >>> 0;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (matchers.hex4) {
|
|
608
|
+
if ((match = matchers.hex4.exec(color))) {
|
|
609
|
+
return (Number.parseInt(match[1] +
|
|
610
|
+
match[1] + // r
|
|
611
|
+
match[2] +
|
|
612
|
+
match[2] + // g
|
|
613
|
+
match[3] +
|
|
614
|
+
match[3] + // b
|
|
615
|
+
match[4] +
|
|
616
|
+
match[4], // a
|
|
617
|
+
16) >>> 0);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
if (matchers.hsl) {
|
|
621
|
+
if ((match = matchers.hsl.exec(color))) {
|
|
622
|
+
return ((hslToRgb(parse360(match[1]), // h
|
|
623
|
+
parsePercentage(match[2]), // s
|
|
624
|
+
parsePercentage(match[3])) |
|
|
625
|
+
0x000000ff) >>> // a
|
|
626
|
+
0);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (matchers.hsla) {
|
|
630
|
+
if ((match = matchers.hsla.exec(color))) {
|
|
631
|
+
return ((hslToRgb(parse360(match[1]), // h
|
|
632
|
+
parsePercentage(match[2]), // s
|
|
633
|
+
parsePercentage(match[3])) |
|
|
634
|
+
parse1(match[4])) >>> // a
|
|
635
|
+
0);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
throw new Error(`invalid color string ${color} provided`);
|
|
639
|
+
}
|
|
640
|
+
function processColor(color) {
|
|
641
|
+
const normalizedColor = normalizeColor(color);
|
|
642
|
+
return ((normalizedColor << 24) | (normalizedColor >>> 8)) >>> 0; // argb
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
const validateFrame = ({ allowFloats, durationInFrames, frame, }) => {
|
|
646
|
+
if (typeof frame === 'undefined') {
|
|
647
|
+
throw new TypeError(`Argument missing for parameter "frame"`);
|
|
648
|
+
}
|
|
649
|
+
if (typeof frame !== 'number') {
|
|
650
|
+
throw new TypeError(`Argument passed for "frame" is not a number: ${frame}`);
|
|
651
|
+
}
|
|
652
|
+
if (!Number.isFinite(frame)) {
|
|
653
|
+
throw new RangeError(`Frame ${frame} is not finite`);
|
|
654
|
+
}
|
|
655
|
+
if (frame % 1 !== 0 && !allowFloats) {
|
|
656
|
+
throw new RangeError(`Argument for frame must be an integer, but got ${frame}`);
|
|
657
|
+
}
|
|
658
|
+
if (frame < 0 && frame < -durationInFrames) {
|
|
659
|
+
throw new RangeError(`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the lowest frame that can be rendered is ${-durationInFrames}`);
|
|
660
|
+
}
|
|
661
|
+
if (frame > durationInFrames - 1) {
|
|
662
|
+
throw new RangeError(`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the highest frame that can be rendered is ${durationInFrames - 1}`);
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
const validateDefaultAndInputProps = (defaultProps, name, compositionId) => {
|
|
667
|
+
if (!defaultProps) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
if (typeof defaultProps !== 'object') {
|
|
671
|
+
throw new Error(`"${name}" must be an object, but you passed a value of type ${typeof defaultProps}`);
|
|
672
|
+
}
|
|
673
|
+
if (Array.isArray(defaultProps)) {
|
|
674
|
+
throw new Error(`"${name}" must be an object, an array was passed ${compositionId ? `for composition "${compositionId}"` : ''}`);
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
function validateDimension(amount, nameOfProp, location) {
|
|
679
|
+
if (typeof amount !== 'number') {
|
|
680
|
+
throw new Error(`The "${nameOfProp}" prop ${location} must be a number, but you passed a value of type ${typeof amount}`);
|
|
681
|
+
}
|
|
682
|
+
if (isNaN(amount)) {
|
|
683
|
+
throw new TypeError(`The "${nameOfProp}" prop ${location} must not be NaN, but is NaN.`);
|
|
684
|
+
}
|
|
685
|
+
if (!Number.isFinite(amount)) {
|
|
686
|
+
throw new TypeError(`The "${nameOfProp}" prop ${location} must be finite, but is ${amount}.`);
|
|
687
|
+
}
|
|
688
|
+
if (amount % 1 !== 0) {
|
|
689
|
+
throw new TypeError(`The "${nameOfProp}" prop ${location} must be an integer, but is ${amount}.`);
|
|
690
|
+
}
|
|
691
|
+
if (amount <= 0) {
|
|
692
|
+
throw new TypeError(`The "${nameOfProp}" prop ${location} must be positive, but got ${amount}.`);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
function validateDurationInFrames(durationInFrames, options) {
|
|
697
|
+
const { allowFloats, component } = options;
|
|
698
|
+
if (typeof durationInFrames === 'undefined') {
|
|
699
|
+
throw new Error(`The "durationInFrames" prop ${component} is missing.`);
|
|
700
|
+
}
|
|
701
|
+
if (typeof durationInFrames !== 'number') {
|
|
702
|
+
throw new Error(`The "durationInFrames" prop ${component} must be a number, but you passed a value of type ${typeof durationInFrames}`);
|
|
703
|
+
}
|
|
704
|
+
if (durationInFrames <= 0) {
|
|
705
|
+
throw new TypeError(`The "durationInFrames" prop ${component} must be positive, but got ${durationInFrames}.`);
|
|
706
|
+
}
|
|
707
|
+
if (!allowFloats && durationInFrames % 1 !== 0) {
|
|
708
|
+
throw new TypeError(`The "durationInFrames" prop ${component} must be an integer, but got ${durationInFrames}.`);
|
|
709
|
+
}
|
|
710
|
+
if (!Number.isFinite(durationInFrames)) {
|
|
711
|
+
throw new TypeError(`The "durationInFrames" prop ${component} must be finite, but got ${durationInFrames}.`);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function validateFps(fps, location, isGif) {
|
|
716
|
+
if (typeof fps !== 'number') {
|
|
717
|
+
throw new Error(`"fps" must be a number, but you passed a value of type ${typeof fps} ${location}`);
|
|
718
|
+
}
|
|
719
|
+
if (!Number.isFinite(fps)) {
|
|
720
|
+
throw new Error(`"fps" must be a finite, but you passed ${fps} ${location}`);
|
|
721
|
+
}
|
|
722
|
+
if (isNaN(fps)) {
|
|
723
|
+
throw new Error(`"fps" must not be NaN, but got ${fps} ${location}`);
|
|
724
|
+
}
|
|
725
|
+
if (fps <= 0) {
|
|
726
|
+
throw new TypeError(`"fps" must be positive, but got ${fps} ${location}`);
|
|
727
|
+
}
|
|
728
|
+
if (isGif && fps > 50) {
|
|
729
|
+
throw new TypeError(`The FPS for a GIF cannot be higher than 50. Use the --every-nth-frame option to lower the FPS: https://remotion.dev/docs/render-as-gif`);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const NoReactInternals = {
|
|
734
|
+
processColor,
|
|
735
|
+
truthy,
|
|
736
|
+
validateFps,
|
|
737
|
+
validateDimension,
|
|
738
|
+
validateDurationInFrames,
|
|
739
|
+
validateDefaultAndInputProps,
|
|
740
|
+
validateFrame,
|
|
741
|
+
serializeJSONWithDate,
|
|
742
|
+
bundleName: 'bundle.js',
|
|
743
|
+
bundleMapName: 'bundle.js.map',
|
|
744
|
+
deserializeJSONWithCustomFields,
|
|
745
|
+
DELAY_RENDER_CALLSTACK_TOKEN,
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
export { NoReactInternals, interpolate, random };
|