@remotion/vercel 4.0.508 → 4.0.509
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/esm/index.mjs +1178 -132
- package/package.json +4 -4
package/dist/esm/index.mjs
CHANGED
|
@@ -115,6 +115,498 @@ import { statSync } from "fs";
|
|
|
115
115
|
import { RenderInternals } from "@remotion/renderer";
|
|
116
116
|
|
|
117
117
|
// ../core/dist/esm/no-react.mjs
|
|
118
|
+
var NEWTON_ITERATIONS = 4;
|
|
119
|
+
var NEWTON_MIN_SLOPE = 0.001;
|
|
120
|
+
var SUBDIVISION_PRECISION = 0.0000001;
|
|
121
|
+
var SUBDIVISION_MAX_ITERATIONS = 10;
|
|
122
|
+
var kSplineTableSize = 11;
|
|
123
|
+
var kSampleStepSize = 1 / (kSplineTableSize - 1);
|
|
124
|
+
var float32ArraySupported = typeof Float32Array === "function";
|
|
125
|
+
function a(aA1, aA2) {
|
|
126
|
+
return 1 - 3 * aA2 + 3 * aA1;
|
|
127
|
+
}
|
|
128
|
+
function b(aA1, aA2) {
|
|
129
|
+
return 3 * aA2 - 6 * aA1;
|
|
130
|
+
}
|
|
131
|
+
function c(aA1) {
|
|
132
|
+
return 3 * aA1;
|
|
133
|
+
}
|
|
134
|
+
function calcBezier(aT, aA1, aA2) {
|
|
135
|
+
return ((a(aA1, aA2) * aT + b(aA1, aA2)) * aT + c(aA1)) * aT;
|
|
136
|
+
}
|
|
137
|
+
function getSlope(aT, aA1, aA2) {
|
|
138
|
+
return 3 * a(aA1, aA2) * aT * aT + 2 * b(aA1, aA2) * aT + c(aA1);
|
|
139
|
+
}
|
|
140
|
+
function binarySubdivide({
|
|
141
|
+
aX,
|
|
142
|
+
_aA,
|
|
143
|
+
_aB,
|
|
144
|
+
mX1,
|
|
145
|
+
mX2
|
|
146
|
+
}) {
|
|
147
|
+
let currentX;
|
|
148
|
+
let currentT;
|
|
149
|
+
let i = 0;
|
|
150
|
+
let aA = _aA;
|
|
151
|
+
let aB = _aB;
|
|
152
|
+
do {
|
|
153
|
+
currentT = aA + (aB - aA) / 2;
|
|
154
|
+
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
|
155
|
+
if (currentX > 0) {
|
|
156
|
+
aB = currentT;
|
|
157
|
+
} else {
|
|
158
|
+
aA = currentT;
|
|
159
|
+
}
|
|
160
|
+
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
|
|
161
|
+
return currentT;
|
|
162
|
+
}
|
|
163
|
+
function newtonRaphsonIterate(aX, _aGuessT, mX1, mX2) {
|
|
164
|
+
let aGuessT = _aGuessT;
|
|
165
|
+
for (let i = 0;i < NEWTON_ITERATIONS; ++i) {
|
|
166
|
+
const currentSlope = getSlope(aGuessT, mX1, mX2);
|
|
167
|
+
if (currentSlope === 0) {
|
|
168
|
+
return aGuessT;
|
|
169
|
+
}
|
|
170
|
+
const currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
|
171
|
+
aGuessT -= currentX / currentSlope;
|
|
172
|
+
}
|
|
173
|
+
return aGuessT;
|
|
174
|
+
}
|
|
175
|
+
function bezier(mX1, mY1, mX2, mY2) {
|
|
176
|
+
if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) {
|
|
177
|
+
throw new Error("bezier x values must be in [0, 1] range");
|
|
178
|
+
}
|
|
179
|
+
const sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
|
|
180
|
+
if (mX1 !== mY1 || mX2 !== mY2) {
|
|
181
|
+
for (let i = 0;i < kSplineTableSize; ++i) {
|
|
182
|
+
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function getTForX(aX) {
|
|
186
|
+
let intervalStart = 0;
|
|
187
|
+
let currentSample = 1;
|
|
188
|
+
const lastSample = kSplineTableSize - 1;
|
|
189
|
+
for (;currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
|
|
190
|
+
intervalStart += kSampleStepSize;
|
|
191
|
+
}
|
|
192
|
+
--currentSample;
|
|
193
|
+
const dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
|
194
|
+
const guessForT = intervalStart + dist * kSampleStepSize;
|
|
195
|
+
const initialSlope = getSlope(guessForT, mX1, mX2);
|
|
196
|
+
if (initialSlope >= NEWTON_MIN_SLOPE) {
|
|
197
|
+
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
|
198
|
+
}
|
|
199
|
+
if (initialSlope === 0) {
|
|
200
|
+
return guessForT;
|
|
201
|
+
}
|
|
202
|
+
return binarySubdivide({
|
|
203
|
+
aX,
|
|
204
|
+
_aA: intervalStart,
|
|
205
|
+
_aB: intervalStart + kSampleStepSize,
|
|
206
|
+
mX1,
|
|
207
|
+
mX2
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return function(x) {
|
|
211
|
+
const clampedX = Math.min(1, Math.max(0, x));
|
|
212
|
+
if (mX1 === mY1 && mX2 === mY2) {
|
|
213
|
+
return clampedX;
|
|
214
|
+
}
|
|
215
|
+
if (clampedX === 0) {
|
|
216
|
+
return 0;
|
|
217
|
+
}
|
|
218
|
+
if (clampedX === 1) {
|
|
219
|
+
return 1;
|
|
220
|
+
}
|
|
221
|
+
return calcBezier(getTForX(clampedX), mY1, mY2);
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
var validateFrame = ({
|
|
225
|
+
allowFloats,
|
|
226
|
+
durationInFrames,
|
|
227
|
+
frame
|
|
228
|
+
}) => {
|
|
229
|
+
if (typeof frame === "undefined") {
|
|
230
|
+
throw new TypeError(\`Argument missing for parameter "frame"\`);
|
|
231
|
+
}
|
|
232
|
+
if (typeof frame !== "number") {
|
|
233
|
+
throw new TypeError(\`Argument passed for "frame" is not a number: \${frame}\`);
|
|
234
|
+
}
|
|
235
|
+
if (!Number.isFinite(frame)) {
|
|
236
|
+
throw new RangeError(\`Frame \${frame} is not finite\`);
|
|
237
|
+
}
|
|
238
|
+
if (frame % 1 !== 0 && !allowFloats) {
|
|
239
|
+
throw new RangeError(\`Argument for frame must be an integer, but got \${frame}\`);
|
|
240
|
+
}
|
|
241
|
+
if (frame < 0 && frame < -durationInFrames) {
|
|
242
|
+
throw new RangeError(\`Cannot use frame \${frame}: Duration of composition is \${durationInFrames}, therefore the lowest frame that can be rendered is \${-durationInFrames}\`);
|
|
243
|
+
}
|
|
244
|
+
if (frame > durationInFrames - 1) {
|
|
245
|
+
throw new RangeError(\`Cannot use frame \${frame}: Duration of composition is \${durationInFrames}, therefore the highest frame that can be rendered is \${durationInFrames - 1}\`);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
function validateFps(fps, location, isGif) {
|
|
249
|
+
if (typeof fps !== "number") {
|
|
250
|
+
throw new Error(\`"fps" must be a number, but you passed a value of type \${typeof fps} \${location}\`);
|
|
251
|
+
}
|
|
252
|
+
if (!Number.isFinite(fps)) {
|
|
253
|
+
throw new Error(\`"fps" must be a finite, but you passed \${fps} \${location}\`);
|
|
254
|
+
}
|
|
255
|
+
if (isNaN(fps)) {
|
|
256
|
+
throw new Error(\`"fps" must not be NaN, but got \${fps} \${location}\`);
|
|
257
|
+
}
|
|
258
|
+
if (fps <= 0) {
|
|
259
|
+
throw new TypeError(\`"fps" must be positive, but got \${fps} \${location}\`);
|
|
260
|
+
}
|
|
261
|
+
if (isGif && fps > 50) {
|
|
262
|
+
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\`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
var validateSpringDuration = (dur) => {
|
|
266
|
+
if (typeof dur === "undefined") {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (typeof dur !== "number") {
|
|
270
|
+
throw new TypeError(\`A "duration" of a spring must be a "number" but is "\${typeof dur}"\`);
|
|
271
|
+
}
|
|
272
|
+
if (Number.isNaN(dur)) {
|
|
273
|
+
throw new TypeError('A "duration" of a spring is NaN, which it must not be');
|
|
274
|
+
}
|
|
275
|
+
if (!Number.isFinite(dur)) {
|
|
276
|
+
throw new TypeError('A "duration" of a spring must be finite, but is ' + dur);
|
|
277
|
+
}
|
|
278
|
+
if (dur <= 0) {
|
|
279
|
+
throw new TypeError('A "duration" of a spring must be positive, but is ' + dur);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
var defaultSpringConfig = {
|
|
283
|
+
damping: 10,
|
|
284
|
+
mass: 1,
|
|
285
|
+
stiffness: 100,
|
|
286
|
+
overshootClamping: false
|
|
287
|
+
};
|
|
288
|
+
var advanceCache = {};
|
|
289
|
+
function advance({
|
|
290
|
+
animation,
|
|
291
|
+
now,
|
|
292
|
+
config
|
|
293
|
+
}) {
|
|
294
|
+
const { toValue, lastTimestamp, current, velocity } = animation;
|
|
295
|
+
const deltaTime = Math.min(now - lastTimestamp, 64);
|
|
296
|
+
if (config.damping <= 0) {
|
|
297
|
+
throw new Error("Spring damping must be greater than 0, otherwise the spring() animation will never end, causing an infinite loop.");
|
|
298
|
+
}
|
|
299
|
+
const c2 = config.damping;
|
|
300
|
+
const m = config.mass;
|
|
301
|
+
const k = config.stiffness;
|
|
302
|
+
const cacheKey = [
|
|
303
|
+
toValue,
|
|
304
|
+
lastTimestamp,
|
|
305
|
+
current,
|
|
306
|
+
velocity,
|
|
307
|
+
c2,
|
|
308
|
+
m,
|
|
309
|
+
k,
|
|
310
|
+
now
|
|
311
|
+
].join("-");
|
|
312
|
+
if (advanceCache[cacheKey]) {
|
|
313
|
+
return advanceCache[cacheKey];
|
|
314
|
+
}
|
|
315
|
+
const v0 = -velocity;
|
|
316
|
+
const x0 = toValue - current;
|
|
317
|
+
const zeta = c2 / (2 * Math.sqrt(k * m));
|
|
318
|
+
const omega0 = Math.sqrt(k / m);
|
|
319
|
+
const omega1 = omega0 * Math.sqrt(1 - zeta ** 2);
|
|
320
|
+
const t = deltaTime / 1000;
|
|
321
|
+
const sin1 = Math.sin(omega1 * t);
|
|
322
|
+
const cos1 = Math.cos(omega1 * t);
|
|
323
|
+
const underDampedEnvelope = Math.exp(-zeta * omega0 * t);
|
|
324
|
+
const underDampedFrag1 = underDampedEnvelope * (sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);
|
|
325
|
+
const underDampedPosition = toValue - underDampedFrag1;
|
|
326
|
+
const underDampedVelocity = zeta * omega0 * underDampedFrag1 - underDampedEnvelope * (cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);
|
|
327
|
+
const criticallyDampedEnvelope = Math.exp(-omega0 * t);
|
|
328
|
+
const criticallyDampedPosition = toValue - criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);
|
|
329
|
+
const criticallyDampedVelocity = criticallyDampedEnvelope * (v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0);
|
|
330
|
+
const animationNode = {
|
|
331
|
+
toValue,
|
|
332
|
+
prevPosition: current,
|
|
333
|
+
lastTimestamp: now,
|
|
334
|
+
current: zeta < 1 ? underDampedPosition : criticallyDampedPosition,
|
|
335
|
+
velocity: zeta < 1 ? underDampedVelocity : criticallyDampedVelocity
|
|
336
|
+
};
|
|
337
|
+
advanceCache[cacheKey] = animationNode;
|
|
338
|
+
return animationNode;
|
|
339
|
+
}
|
|
340
|
+
var calculationCache = {};
|
|
341
|
+
function springCalculation({
|
|
342
|
+
frame,
|
|
343
|
+
fps,
|
|
344
|
+
config = {}
|
|
345
|
+
}) {
|
|
346
|
+
const from = 0;
|
|
347
|
+
const to = 1;
|
|
348
|
+
const cacheKey = [
|
|
349
|
+
frame,
|
|
350
|
+
fps,
|
|
351
|
+
config.damping,
|
|
352
|
+
config.mass,
|
|
353
|
+
config.overshootClamping,
|
|
354
|
+
config.stiffness
|
|
355
|
+
].join("-");
|
|
356
|
+
if (calculationCache[cacheKey]) {
|
|
357
|
+
return calculationCache[cacheKey];
|
|
358
|
+
}
|
|
359
|
+
let animation = {
|
|
360
|
+
lastTimestamp: 0,
|
|
361
|
+
current: from,
|
|
362
|
+
toValue: to,
|
|
363
|
+
velocity: 0,
|
|
364
|
+
prevPosition: 0
|
|
365
|
+
};
|
|
366
|
+
const frameClamped = Math.max(0, frame);
|
|
367
|
+
const unevenRest = frameClamped % 1;
|
|
368
|
+
for (let f = 0;f <= Math.floor(frameClamped); f++) {
|
|
369
|
+
if (f === Math.floor(frameClamped)) {
|
|
370
|
+
f += unevenRest;
|
|
371
|
+
}
|
|
372
|
+
const time = f / fps * 1000;
|
|
373
|
+
animation = advance({
|
|
374
|
+
animation,
|
|
375
|
+
now: time,
|
|
376
|
+
config: {
|
|
377
|
+
...defaultSpringConfig,
|
|
378
|
+
...config
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
calculationCache[cacheKey] = animation;
|
|
383
|
+
return animation;
|
|
384
|
+
}
|
|
385
|
+
var cache = new Map;
|
|
386
|
+
function measureSpring({
|
|
387
|
+
fps,
|
|
388
|
+
config = {},
|
|
389
|
+
threshold = 0.005
|
|
390
|
+
}) {
|
|
391
|
+
if (typeof threshold !== "number") {
|
|
392
|
+
throw new TypeError(\`threshold must be a number, got \${threshold} of type \${typeof threshold}\`);
|
|
393
|
+
}
|
|
394
|
+
if (threshold === 0) {
|
|
395
|
+
return Infinity;
|
|
396
|
+
}
|
|
397
|
+
if (threshold === 1) {
|
|
398
|
+
return 0;
|
|
399
|
+
}
|
|
400
|
+
if (isNaN(threshold)) {
|
|
401
|
+
throw new TypeError("Threshold is NaN");
|
|
402
|
+
}
|
|
403
|
+
if (!Number.isFinite(threshold)) {
|
|
404
|
+
throw new TypeError("Threshold is not finite");
|
|
405
|
+
}
|
|
406
|
+
if (threshold < 0) {
|
|
407
|
+
throw new TypeError("Threshold is below 0");
|
|
408
|
+
}
|
|
409
|
+
const cacheKey = [
|
|
410
|
+
fps,
|
|
411
|
+
config.damping,
|
|
412
|
+
config.mass,
|
|
413
|
+
config.overshootClamping,
|
|
414
|
+
config.stiffness,
|
|
415
|
+
threshold
|
|
416
|
+
].join("-");
|
|
417
|
+
if (cache.has(cacheKey)) {
|
|
418
|
+
return cache.get(cacheKey);
|
|
419
|
+
}
|
|
420
|
+
validateFps(fps, "to the measureSpring() function", false);
|
|
421
|
+
let frame = 0;
|
|
422
|
+
let finishedFrame = 0;
|
|
423
|
+
const calc = () => {
|
|
424
|
+
return springCalculation({
|
|
425
|
+
fps,
|
|
426
|
+
frame,
|
|
427
|
+
config
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
let animation = calc();
|
|
431
|
+
const calcDifference = () => {
|
|
432
|
+
return Math.abs(animation.current - animation.toValue);
|
|
433
|
+
};
|
|
434
|
+
let difference = calcDifference();
|
|
435
|
+
while (difference >= threshold) {
|
|
436
|
+
frame++;
|
|
437
|
+
animation = calc();
|
|
438
|
+
difference = calcDifference();
|
|
439
|
+
}
|
|
440
|
+
finishedFrame = frame;
|
|
441
|
+
for (let i = 0;i < 20; i++) {
|
|
442
|
+
frame++;
|
|
443
|
+
animation = calc();
|
|
444
|
+
difference = calcDifference();
|
|
445
|
+
if (difference >= threshold) {
|
|
446
|
+
i = 0;
|
|
447
|
+
finishedFrame = frame + 1;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
cache.set(cacheKey, finishedFrame);
|
|
451
|
+
return finishedFrame;
|
|
452
|
+
}
|
|
453
|
+
function spring({
|
|
454
|
+
frame: passedFrame,
|
|
455
|
+
fps,
|
|
456
|
+
config = {},
|
|
457
|
+
from = 0,
|
|
458
|
+
to = 1,
|
|
459
|
+
durationInFrames: passedDurationInFrames,
|
|
460
|
+
durationRestThreshold,
|
|
461
|
+
delay = 0,
|
|
462
|
+
reverse = false
|
|
463
|
+
}) {
|
|
464
|
+
validateSpringDuration(passedDurationInFrames);
|
|
465
|
+
validateFrame({
|
|
466
|
+
frame: passedFrame,
|
|
467
|
+
durationInFrames: Infinity,
|
|
468
|
+
allowFloats: true
|
|
469
|
+
});
|
|
470
|
+
validateFps(fps, "to spring()", false);
|
|
471
|
+
const needsToCalculateNaturalDuration = reverse || typeof passedDurationInFrames !== "undefined";
|
|
472
|
+
const naturalDuration = needsToCalculateNaturalDuration ? measureSpring({
|
|
473
|
+
fps,
|
|
474
|
+
config,
|
|
475
|
+
threshold: durationRestThreshold
|
|
476
|
+
}) : undefined;
|
|
477
|
+
const naturalDurationGetter = needsToCalculateNaturalDuration ? {
|
|
478
|
+
get: () => naturalDuration
|
|
479
|
+
} : {
|
|
480
|
+
get: () => {
|
|
481
|
+
throw new Error("did not calculate natural duration, this is an error with Remotion. Please report");
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
const reverseProcessed = reverse ? (passedDurationInFrames ?? naturalDurationGetter.get()) - passedFrame : passedFrame;
|
|
485
|
+
const delayProcessed = reverseProcessed + (reverse ? delay : -delay);
|
|
486
|
+
const durationProcessed = passedDurationInFrames === undefined ? delayProcessed : delayProcessed / (passedDurationInFrames / naturalDurationGetter.get());
|
|
487
|
+
if (passedDurationInFrames && delayProcessed > passedDurationInFrames) {
|
|
488
|
+
return to;
|
|
489
|
+
}
|
|
490
|
+
const spr = springCalculation({
|
|
491
|
+
fps,
|
|
492
|
+
frame: durationProcessed,
|
|
493
|
+
config
|
|
494
|
+
});
|
|
495
|
+
const inner = config.overshootClamping ? to >= from ? Math.min(spr.current, to) : Math.max(spr.current, to) : spr.current;
|
|
496
|
+
const interpolated = from === 0 && to === 1 ? inner : interpolate(inner, [0, 1], [from, to]);
|
|
497
|
+
return interpolated;
|
|
498
|
+
}
|
|
499
|
+
var clampUnit = (t) => Math.min(1, Math.max(0, t));
|
|
500
|
+
var springEasingDurationInFrames = 30;
|
|
501
|
+
|
|
502
|
+
class Easing {
|
|
503
|
+
static step0(n) {
|
|
504
|
+
return n > 0 ? 1 : 0;
|
|
505
|
+
}
|
|
506
|
+
static step1(n) {
|
|
507
|
+
return n >= 1 ? 1 : 0;
|
|
508
|
+
}
|
|
509
|
+
static linear(t) {
|
|
510
|
+
return t;
|
|
511
|
+
}
|
|
512
|
+
static ease(t) {
|
|
513
|
+
return Easing.bezier(0.42, 0, 1, 1)(t);
|
|
514
|
+
}
|
|
515
|
+
static quad(t) {
|
|
516
|
+
return t * t;
|
|
517
|
+
}
|
|
518
|
+
static cubic(t) {
|
|
519
|
+
return t * t * t;
|
|
520
|
+
}
|
|
521
|
+
static poly(n) {
|
|
522
|
+
return (t) => t ** n;
|
|
523
|
+
}
|
|
524
|
+
static sin(t) {
|
|
525
|
+
return 1 - Math.cos(t * Math.PI / 2);
|
|
526
|
+
}
|
|
527
|
+
static circle(t) {
|
|
528
|
+
const u = clampUnit(t);
|
|
529
|
+
return 1 - Math.sqrt(1 - u * u);
|
|
530
|
+
}
|
|
531
|
+
static exp(t) {
|
|
532
|
+
return 2 ** (10 * (t - 1));
|
|
533
|
+
}
|
|
534
|
+
static elastic(bounciness = 1) {
|
|
535
|
+
const p = bounciness * Math.PI;
|
|
536
|
+
return (t) => 1 - Math.cos(t * Math.PI / 2) ** 3 * Math.cos(t * p);
|
|
537
|
+
}
|
|
538
|
+
static back(s = 1.70158) {
|
|
539
|
+
return (t) => t * t * ((s + 1) * t - s);
|
|
540
|
+
}
|
|
541
|
+
static spring({
|
|
542
|
+
allowTail = false,
|
|
543
|
+
durationRestThreshold,
|
|
544
|
+
...config
|
|
545
|
+
} = {}) {
|
|
546
|
+
const easing = (t) => {
|
|
547
|
+
if (t <= 0) {
|
|
548
|
+
return 0;
|
|
549
|
+
}
|
|
550
|
+
if (!allowTail && t >= 1) {
|
|
551
|
+
return 1;
|
|
552
|
+
}
|
|
553
|
+
if (allowTail) {
|
|
554
|
+
return spring({
|
|
555
|
+
fps: springEasingDurationInFrames,
|
|
556
|
+
frame: t * measureSpring({
|
|
557
|
+
fps: springEasingDurationInFrames,
|
|
558
|
+
config,
|
|
559
|
+
threshold: durationRestThreshold
|
|
560
|
+
}),
|
|
561
|
+
config
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
return spring({
|
|
565
|
+
fps: springEasingDurationInFrames,
|
|
566
|
+
frame: t * springEasingDurationInFrames,
|
|
567
|
+
config,
|
|
568
|
+
durationInFrames: springEasingDurationInFrames,
|
|
569
|
+
durationRestThreshold
|
|
570
|
+
});
|
|
571
|
+
};
|
|
572
|
+
return Object.assign(easing, {
|
|
573
|
+
remotionShouldExtendRight: allowTail
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
static bounce(t) {
|
|
577
|
+
const u = clampUnit(t);
|
|
578
|
+
if (u < 1 / 2.75) {
|
|
579
|
+
return 7.5625 * u * u;
|
|
580
|
+
}
|
|
581
|
+
if (u < 2 / 2.75) {
|
|
582
|
+
const t2_ = u - 1.5 / 2.75;
|
|
583
|
+
return 7.5625 * t2_ * t2_ + 0.75;
|
|
584
|
+
}
|
|
585
|
+
if (u < 2.5 / 2.75) {
|
|
586
|
+
const t2_ = u - 2.25 / 2.75;
|
|
587
|
+
return 7.5625 * t2_ * t2_ + 0.9375;
|
|
588
|
+
}
|
|
589
|
+
const t2 = u - 2.625 / 2.75;
|
|
590
|
+
return 7.5625 * t2 * t2 + 0.984375;
|
|
591
|
+
}
|
|
592
|
+
static bezier(x1, y1, x2, y2) {
|
|
593
|
+
return bezier(x1, y1, x2, y2);
|
|
594
|
+
}
|
|
595
|
+
static in(easing) {
|
|
596
|
+
return easing;
|
|
597
|
+
}
|
|
598
|
+
static out(easing) {
|
|
599
|
+
return (t) => 1 - easing(1 - t);
|
|
600
|
+
}
|
|
601
|
+
static inOut(easing) {
|
|
602
|
+
return (t) => {
|
|
603
|
+
if (t < 0.5) {
|
|
604
|
+
return easing(t * 2) / 2;
|
|
605
|
+
}
|
|
606
|
+
return 1 - easing((1 - t) * 2) / 2;
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
}
|
|
118
610
|
var normalizeNumber = (value) => {
|
|
119
611
|
return Math.round(value * 1e6) / 1e6;
|
|
120
612
|
};
|
|
@@ -185,10 +677,13 @@ var transformOriginCenter = { value: 50, unit: "%" };
|
|
|
185
677
|
var stringifyNumber = (value) => {
|
|
186
678
|
return String(normalizeNumber(value));
|
|
187
679
|
};
|
|
680
|
+
|
|
681
|
+
class UnsupportedStringInterpolationValueError extends TypeError {
|
|
682
|
+
}
|
|
188
683
|
var parseStringInterpolationComponent = (component, value) => {
|
|
189
684
|
const match = cssNumberRegex.exec(component);
|
|
190
685
|
if (match === null) {
|
|
191
|
-
throw new
|
|
686
|
+
throw new UnsupportedStringInterpolationValueError(\`Cannot interpolate "\${value}" because "\${component}" is not a supported scale, translate, or rotate value\`);
|
|
192
687
|
}
|
|
193
688
|
const unit = match[2] ?? null;
|
|
194
689
|
const numberValue = Number(match[1]);
|
|
@@ -655,6 +1150,52 @@ var interpolateString = ({
|
|
|
655
1150
|
axisRotation: hasAxisRotation
|
|
656
1151
|
});
|
|
657
1152
|
};
|
|
1153
|
+
var interpolateDiscreteString = ({
|
|
1154
|
+
input,
|
|
1155
|
+
inputRange,
|
|
1156
|
+
outputRange,
|
|
1157
|
+
options
|
|
1158
|
+
}) => {
|
|
1159
|
+
if (inputRange.length === 1) {
|
|
1160
|
+
return outputRange[0];
|
|
1161
|
+
}
|
|
1162
|
+
for (let segmentIndex = 0;segmentIndex < inputRange.length - 1; segmentIndex++) {
|
|
1163
|
+
if (resolveEasingForSegment({
|
|
1164
|
+
easing: options?.easing,
|
|
1165
|
+
segmentIndex
|
|
1166
|
+
}) !== Easing.step1) {
|
|
1167
|
+
throw new TypeError("Non-numeric strings can only be interpolated using Easing.step1");
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
|
|
1171
|
+
const inputMin = inputRange[0];
|
|
1172
|
+
const inputMax = inputRange[inputRange.length - 1];
|
|
1173
|
+
let resolvedInput = posterizedInput;
|
|
1174
|
+
if (resolvedInput < inputMin) {
|
|
1175
|
+
if (options?.extrapolateLeft === "identity") {
|
|
1176
|
+
throw new TypeError('extrapolateLeft: "identity" is not supported for non-numeric strings');
|
|
1177
|
+
}
|
|
1178
|
+
if (options?.extrapolateLeft === "wrap") {
|
|
1179
|
+
const wrapRange = inputMax - inputMin;
|
|
1180
|
+
resolvedInput = ((resolvedInput - inputMin) % wrapRange + wrapRange) % wrapRange + inputMin;
|
|
1181
|
+
} else {
|
|
1182
|
+
return outputRange[0];
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
if (resolvedInput > inputMax) {
|
|
1186
|
+
if (options?.extrapolateRight === "identity") {
|
|
1187
|
+
throw new TypeError('extrapolateRight: "identity" is not supported for non-numeric strings');
|
|
1188
|
+
}
|
|
1189
|
+
if (options?.extrapolateRight === "wrap") {
|
|
1190
|
+
const wrapRange = inputMax - inputMin;
|
|
1191
|
+
resolvedInput = ((resolvedInput - inputMin) % wrapRange + wrapRange) % wrapRange + inputMin;
|
|
1192
|
+
} else {
|
|
1193
|
+
return outputRange[outputRange.length - 1];
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
const range = findRange(resolvedInput, inputRange);
|
|
1197
|
+
return resolvedInput >= inputRange[range + 1] ? outputRange[range + 1] : outputRange[range];
|
|
1198
|
+
};
|
|
658
1199
|
var validateTupleOutputRange = (outputRange) => {
|
|
659
1200
|
const dimensions = outputRange[0]?.length;
|
|
660
1201
|
if (dimensions === undefined) {
|
|
@@ -769,7 +1310,30 @@ function interpolate(input, inputRange, outputRange, options) {
|
|
|
769
1310
|
if (!outputRange.every((output) => typeof output === "string" || typeof output === "number")) {
|
|
770
1311
|
throw new TypeError("outputRange must contain only numbers, or supported scale, translate, and rotate strings");
|
|
771
1312
|
}
|
|
772
|
-
|
|
1313
|
+
try {
|
|
1314
|
+
return interpolateString({ input, inputRange, outputRange, options });
|
|
1315
|
+
} catch (error) {
|
|
1316
|
+
if (!outputRange.every((output) => typeof output === "string")) {
|
|
1317
|
+
throw error;
|
|
1318
|
+
}
|
|
1319
|
+
const hasNonNumericString = outputRange.some((output) => {
|
|
1320
|
+
try {
|
|
1321
|
+
parseStringInterpolationValue(output);
|
|
1322
|
+
return false;
|
|
1323
|
+
} catch (parseError) {
|
|
1324
|
+
return parseError instanceof UnsupportedStringInterpolationValueError;
|
|
1325
|
+
}
|
|
1326
|
+
});
|
|
1327
|
+
if (!hasNonNumericString) {
|
|
1328
|
+
throw error;
|
|
1329
|
+
}
|
|
1330
|
+
return interpolateDiscreteString({
|
|
1331
|
+
input,
|
|
1332
|
+
inputRange,
|
|
1333
|
+
outputRange,
|
|
1334
|
+
options
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
773
1337
|
}
|
|
774
1338
|
if (outputRange.every((output) => Array.isArray(output))) {
|
|
775
1339
|
return interpolateTuple({ input, inputRange, outputRange, options });
|
|
@@ -1238,8 +1802,8 @@ function hslToRgb(h, s, l) {
|
|
|
1238
1802
|
const p = 2 * l - q;
|
|
1239
1803
|
const r = hue2rgb(p, q, h + 1 / 3);
|
|
1240
1804
|
const g = hue2rgb(p, q, h);
|
|
1241
|
-
const
|
|
1242
|
-
return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(
|
|
1805
|
+
const b2 = hue2rgb(p, q, h - 1 / 3);
|
|
1806
|
+
return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b2 * 255) << 8;
|
|
1243
1807
|
}
|
|
1244
1808
|
function parse255(str) {
|
|
1245
1809
|
const int = Number.parseInt(str, 10);
|
|
@@ -1303,25 +1867,25 @@ function parseModernAlpha(str) {
|
|
|
1303
1867
|
}
|
|
1304
1868
|
return Math.max(0, Math.min(1, Number.parseFloat(str)));
|
|
1305
1869
|
}
|
|
1306
|
-
function linearToSrgb(
|
|
1307
|
-
if (
|
|
1308
|
-
return 12.92 *
|
|
1309
|
-
return 1.055 *
|
|
1870
|
+
function linearToSrgb(c2) {
|
|
1871
|
+
if (c2 <= 0.0031308)
|
|
1872
|
+
return 12.92 * c2;
|
|
1873
|
+
return 1.055 * c2 ** (1 / 2.4) - 0.055;
|
|
1310
1874
|
}
|
|
1311
1875
|
function clamp01(v) {
|
|
1312
1876
|
return Math.max(0, Math.min(1, v));
|
|
1313
1877
|
}
|
|
1314
|
-
function rgbFloatToInt(r, g,
|
|
1878
|
+
function rgbFloatToInt(r, g, b2, alpha) {
|
|
1315
1879
|
const ri = Math.round(clamp01(r) * 255);
|
|
1316
1880
|
const gi = Math.round(clamp01(g) * 255);
|
|
1317
|
-
const bi = Math.round(clamp01(
|
|
1881
|
+
const bi = Math.round(clamp01(b2) * 255);
|
|
1318
1882
|
const ai = Math.round(clamp01(alpha) * 255);
|
|
1319
1883
|
return (ri << 24 | gi << 16 | bi << 8 | ai) >>> 0;
|
|
1320
1884
|
}
|
|
1321
|
-
function oklabToSrgb(L,
|
|
1322
|
-
const l_ = L + 0.3963377774 *
|
|
1323
|
-
const m_ = L - 0.1055613458 *
|
|
1324
|
-
const s_ = L - 0.0894841775 *
|
|
1885
|
+
function oklabToSrgb(L, a2, b2) {
|
|
1886
|
+
const l_ = L + 0.3963377774 * a2 + 0.2158037573 * b2;
|
|
1887
|
+
const m_ = L - 0.1055613458 * a2 - 0.0638541728 * b2;
|
|
1888
|
+
const s_ = L - 0.0894841775 * a2 - 1.291485548 * b2;
|
|
1325
1889
|
const l = l_ * l_ * l_;
|
|
1326
1890
|
const m = m_ * m_ * m_;
|
|
1327
1891
|
const s = s_ * s_ * s_;
|
|
@@ -1330,15 +1894,15 @@ function oklabToSrgb(L, a, b) {
|
|
|
1330
1894
|
const bLin = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;
|
|
1331
1895
|
return [linearToSrgb(rLin), linearToSrgb(gLin), linearToSrgb(bLin)];
|
|
1332
1896
|
}
|
|
1333
|
-
function labToSrgb(L,
|
|
1897
|
+
function labToSrgb(L, a2, b2) {
|
|
1334
1898
|
const epsilon = 216 / 24389;
|
|
1335
1899
|
const kappa = 24389 / 27;
|
|
1336
1900
|
const Xn = 0.95047;
|
|
1337
1901
|
const Yn = 1;
|
|
1338
1902
|
const Zn = 1.08883;
|
|
1339
1903
|
const fy = (L + 16) / 116;
|
|
1340
|
-
const fx =
|
|
1341
|
-
const fz = fy -
|
|
1904
|
+
const fx = a2 / 500 + fy;
|
|
1905
|
+
const fz = fy - b2 / 200;
|
|
1342
1906
|
const fx3 = fx * fx * fx;
|
|
1343
1907
|
const fz3 = fz * fz * fz;
|
|
1344
1908
|
const xr = fx3 > epsilon ? fx3 : (116 * fx - 16) / kappa;
|
|
@@ -1570,27 +2134,27 @@ function normalizeColor(color) {
|
|
|
1570
2134
|
const H = parseHueAngle(match[3]);
|
|
1571
2135
|
const alpha = parseModernAlpha(match[4]);
|
|
1572
2136
|
const hRad = H * Math.PI / 180;
|
|
1573
|
-
const [r, g,
|
|
1574
|
-
return rgbFloatToInt(r, g,
|
|
2137
|
+
const [r, g, b2] = oklabToSrgb(L, C * Math.cos(hRad), C * Math.sin(hRad));
|
|
2138
|
+
return rgbFloatToInt(r, g, b2, alpha);
|
|
1575
2139
|
}
|
|
1576
2140
|
}
|
|
1577
2141
|
if (matchers.oklab) {
|
|
1578
2142
|
if (match = matchers.oklab.exec(color)) {
|
|
1579
2143
|
const L = parseModernComponent(match[1], 1);
|
|
1580
|
-
const
|
|
1581
|
-
const
|
|
2144
|
+
const a2 = parseModernComponent(match[2], 0.4);
|
|
2145
|
+
const b2 = parseModernComponent(match[3], 0.4);
|
|
1582
2146
|
const alpha = parseModernAlpha(match[4]);
|
|
1583
|
-
const [r, g, bl] = oklabToSrgb(L,
|
|
2147
|
+
const [r, g, bl] = oklabToSrgb(L, a2, b2);
|
|
1584
2148
|
return rgbFloatToInt(r, g, bl, alpha);
|
|
1585
2149
|
}
|
|
1586
2150
|
}
|
|
1587
2151
|
if (matchers.lab) {
|
|
1588
2152
|
if (match = matchers.lab.exec(color)) {
|
|
1589
2153
|
const L = parseModernComponent(match[1], 100);
|
|
1590
|
-
const
|
|
1591
|
-
const
|
|
2154
|
+
const a2 = parseModernComponent(match[2], 125);
|
|
2155
|
+
const b2 = parseModernComponent(match[3], 125);
|
|
1592
2156
|
const alpha = parseModernAlpha(match[4]);
|
|
1593
|
-
const [r, g, bl] = labToSrgb(L,
|
|
2157
|
+
const [r, g, bl] = labToSrgb(L, a2, b2);
|
|
1594
2158
|
return rgbFloatToInt(r, g, bl, alpha);
|
|
1595
2159
|
}
|
|
1596
2160
|
}
|
|
@@ -1669,30 +2233,6 @@ var serializeScaleValue = ([x, y, z]) => {
|
|
|
1669
2233
|
return \`\${normalizedX} \${normalizedY} \${normalizedZ}\`;
|
|
1670
2234
|
};
|
|
1671
2235
|
var ENABLE_V5_BREAKING_CHANGES = false;
|
|
1672
|
-
var validateFrame = ({
|
|
1673
|
-
allowFloats,
|
|
1674
|
-
durationInFrames,
|
|
1675
|
-
frame
|
|
1676
|
-
}) => {
|
|
1677
|
-
if (typeof frame === "undefined") {
|
|
1678
|
-
throw new TypeError(\`Argument missing for parameter "frame"\`);
|
|
1679
|
-
}
|
|
1680
|
-
if (typeof frame !== "number") {
|
|
1681
|
-
throw new TypeError(\`Argument passed for "frame" is not a number: \${frame}\`);
|
|
1682
|
-
}
|
|
1683
|
-
if (!Number.isFinite(frame)) {
|
|
1684
|
-
throw new RangeError(\`Frame \${frame} is not finite\`);
|
|
1685
|
-
}
|
|
1686
|
-
if (frame % 1 !== 0 && !allowFloats) {
|
|
1687
|
-
throw new RangeError(\`Argument for frame must be an integer, but got \${frame}\`);
|
|
1688
|
-
}
|
|
1689
|
-
if (frame < 0 && frame < -durationInFrames) {
|
|
1690
|
-
throw new RangeError(\`Cannot use frame \${frame}: Duration of composition is \${durationInFrames}, therefore the lowest frame that can be rendered is \${-durationInFrames}\`);
|
|
1691
|
-
}
|
|
1692
|
-
if (frame > durationInFrames - 1) {
|
|
1693
|
-
throw new RangeError(\`Cannot use frame \${frame}: Duration of composition is \${durationInFrames}, therefore the highest frame that can be rendered is \${durationInFrames - 1}\`);
|
|
1694
|
-
}
|
|
1695
|
-
};
|
|
1696
2236
|
var validCodecs = [
|
|
1697
2237
|
"h264",
|
|
1698
2238
|
"h265",
|
|
@@ -1764,23 +2304,6 @@ function validateDurationInFrames(durationInFrames, options) {
|
|
|
1764
2304
|
throw new TypeError(\`The "durationInFrames" prop \${component} must be finite, but got \${durationInFrames}.\`);
|
|
1765
2305
|
}
|
|
1766
2306
|
}
|
|
1767
|
-
function validateFps(fps, location, isGif) {
|
|
1768
|
-
if (typeof fps !== "number") {
|
|
1769
|
-
throw new Error(\`"fps" must be a number, but you passed a value of type \${typeof fps} \${location}\`);
|
|
1770
|
-
}
|
|
1771
|
-
if (!Number.isFinite(fps)) {
|
|
1772
|
-
throw new Error(\`"fps" must be a finite, but you passed \${fps} \${location}\`);
|
|
1773
|
-
}
|
|
1774
|
-
if (isNaN(fps)) {
|
|
1775
|
-
throw new Error(\`"fps" must not be NaN, but got \${fps} \${location}\`);
|
|
1776
|
-
}
|
|
1777
|
-
if (fps <= 0) {
|
|
1778
|
-
throw new TypeError(\`"fps" must be positive, but got \${fps} \${location}\`);
|
|
1779
|
-
}
|
|
1780
|
-
if (isGif && fps > 50) {
|
|
1781
|
-
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\`);
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
2307
|
var getExpectedMediaFrameUncorrected = ({
|
|
1785
2308
|
frame,
|
|
1786
2309
|
playbackRate,
|
|
@@ -1950,6 +2473,498 @@ import { RenderInternals } from "@remotion/renderer";
|
|
|
1950
2473
|
import { put } from "@vercel/blob";
|
|
1951
2474
|
|
|
1952
2475
|
// ../core/dist/esm/no-react.mjs
|
|
2476
|
+
var NEWTON_ITERATIONS = 4;
|
|
2477
|
+
var NEWTON_MIN_SLOPE = 0.001;
|
|
2478
|
+
var SUBDIVISION_PRECISION = 0.0000001;
|
|
2479
|
+
var SUBDIVISION_MAX_ITERATIONS = 10;
|
|
2480
|
+
var kSplineTableSize = 11;
|
|
2481
|
+
var kSampleStepSize = 1 / (kSplineTableSize - 1);
|
|
2482
|
+
var float32ArraySupported = typeof Float32Array === "function";
|
|
2483
|
+
function a(aA1, aA2) {
|
|
2484
|
+
return 1 - 3 * aA2 + 3 * aA1;
|
|
2485
|
+
}
|
|
2486
|
+
function b(aA1, aA2) {
|
|
2487
|
+
return 3 * aA2 - 6 * aA1;
|
|
2488
|
+
}
|
|
2489
|
+
function c(aA1) {
|
|
2490
|
+
return 3 * aA1;
|
|
2491
|
+
}
|
|
2492
|
+
function calcBezier(aT, aA1, aA2) {
|
|
2493
|
+
return ((a(aA1, aA2) * aT + b(aA1, aA2)) * aT + c(aA1)) * aT;
|
|
2494
|
+
}
|
|
2495
|
+
function getSlope(aT, aA1, aA2) {
|
|
2496
|
+
return 3 * a(aA1, aA2) * aT * aT + 2 * b(aA1, aA2) * aT + c(aA1);
|
|
2497
|
+
}
|
|
2498
|
+
function binarySubdivide({
|
|
2499
|
+
aX,
|
|
2500
|
+
_aA,
|
|
2501
|
+
_aB,
|
|
2502
|
+
mX1,
|
|
2503
|
+
mX2
|
|
2504
|
+
}) {
|
|
2505
|
+
let currentX;
|
|
2506
|
+
let currentT;
|
|
2507
|
+
let i = 0;
|
|
2508
|
+
let aA = _aA;
|
|
2509
|
+
let aB = _aB;
|
|
2510
|
+
do {
|
|
2511
|
+
currentT = aA + (aB - aA) / 2;
|
|
2512
|
+
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
|
2513
|
+
if (currentX > 0) {
|
|
2514
|
+
aB = currentT;
|
|
2515
|
+
} else {
|
|
2516
|
+
aA = currentT;
|
|
2517
|
+
}
|
|
2518
|
+
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
|
|
2519
|
+
return currentT;
|
|
2520
|
+
}
|
|
2521
|
+
function newtonRaphsonIterate(aX, _aGuessT, mX1, mX2) {
|
|
2522
|
+
let aGuessT = _aGuessT;
|
|
2523
|
+
for (let i = 0;i < NEWTON_ITERATIONS; ++i) {
|
|
2524
|
+
const currentSlope = getSlope(aGuessT, mX1, mX2);
|
|
2525
|
+
if (currentSlope === 0) {
|
|
2526
|
+
return aGuessT;
|
|
2527
|
+
}
|
|
2528
|
+
const currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
|
2529
|
+
aGuessT -= currentX / currentSlope;
|
|
2530
|
+
}
|
|
2531
|
+
return aGuessT;
|
|
2532
|
+
}
|
|
2533
|
+
function bezier(mX1, mY1, mX2, mY2) {
|
|
2534
|
+
if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) {
|
|
2535
|
+
throw new Error("bezier x values must be in [0, 1] range");
|
|
2536
|
+
}
|
|
2537
|
+
const sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
|
|
2538
|
+
if (mX1 !== mY1 || mX2 !== mY2) {
|
|
2539
|
+
for (let i = 0;i < kSplineTableSize; ++i) {
|
|
2540
|
+
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
function getTForX(aX) {
|
|
2544
|
+
let intervalStart = 0;
|
|
2545
|
+
let currentSample = 1;
|
|
2546
|
+
const lastSample = kSplineTableSize - 1;
|
|
2547
|
+
for (;currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
|
|
2548
|
+
intervalStart += kSampleStepSize;
|
|
2549
|
+
}
|
|
2550
|
+
--currentSample;
|
|
2551
|
+
const dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
|
2552
|
+
const guessForT = intervalStart + dist * kSampleStepSize;
|
|
2553
|
+
const initialSlope = getSlope(guessForT, mX1, mX2);
|
|
2554
|
+
if (initialSlope >= NEWTON_MIN_SLOPE) {
|
|
2555
|
+
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
|
2556
|
+
}
|
|
2557
|
+
if (initialSlope === 0) {
|
|
2558
|
+
return guessForT;
|
|
2559
|
+
}
|
|
2560
|
+
return binarySubdivide({
|
|
2561
|
+
aX,
|
|
2562
|
+
_aA: intervalStart,
|
|
2563
|
+
_aB: intervalStart + kSampleStepSize,
|
|
2564
|
+
mX1,
|
|
2565
|
+
mX2
|
|
2566
|
+
});
|
|
2567
|
+
}
|
|
2568
|
+
return function(x) {
|
|
2569
|
+
const clampedX = Math.min(1, Math.max(0, x));
|
|
2570
|
+
if (mX1 === mY1 && mX2 === mY2) {
|
|
2571
|
+
return clampedX;
|
|
2572
|
+
}
|
|
2573
|
+
if (clampedX === 0) {
|
|
2574
|
+
return 0;
|
|
2575
|
+
}
|
|
2576
|
+
if (clampedX === 1) {
|
|
2577
|
+
return 1;
|
|
2578
|
+
}
|
|
2579
|
+
return calcBezier(getTForX(clampedX), mY1, mY2);
|
|
2580
|
+
};
|
|
2581
|
+
}
|
|
2582
|
+
var validateFrame = ({
|
|
2583
|
+
allowFloats,
|
|
2584
|
+
durationInFrames,
|
|
2585
|
+
frame
|
|
2586
|
+
}) => {
|
|
2587
|
+
if (typeof frame === "undefined") {
|
|
2588
|
+
throw new TypeError(\`Argument missing for parameter "frame"\`);
|
|
2589
|
+
}
|
|
2590
|
+
if (typeof frame !== "number") {
|
|
2591
|
+
throw new TypeError(\`Argument passed for "frame" is not a number: \${frame}\`);
|
|
2592
|
+
}
|
|
2593
|
+
if (!Number.isFinite(frame)) {
|
|
2594
|
+
throw new RangeError(\`Frame \${frame} is not finite\`);
|
|
2595
|
+
}
|
|
2596
|
+
if (frame % 1 !== 0 && !allowFloats) {
|
|
2597
|
+
throw new RangeError(\`Argument for frame must be an integer, but got \${frame}\`);
|
|
2598
|
+
}
|
|
2599
|
+
if (frame < 0 && frame < -durationInFrames) {
|
|
2600
|
+
throw new RangeError(\`Cannot use frame \${frame}: Duration of composition is \${durationInFrames}, therefore the lowest frame that can be rendered is \${-durationInFrames}\`);
|
|
2601
|
+
}
|
|
2602
|
+
if (frame > durationInFrames - 1) {
|
|
2603
|
+
throw new RangeError(\`Cannot use frame \${frame}: Duration of composition is \${durationInFrames}, therefore the highest frame that can be rendered is \${durationInFrames - 1}\`);
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
function validateFps(fps, location, isGif) {
|
|
2607
|
+
if (typeof fps !== "number") {
|
|
2608
|
+
throw new Error(\`"fps" must be a number, but you passed a value of type \${typeof fps} \${location}\`);
|
|
2609
|
+
}
|
|
2610
|
+
if (!Number.isFinite(fps)) {
|
|
2611
|
+
throw new Error(\`"fps" must be a finite, but you passed \${fps} \${location}\`);
|
|
2612
|
+
}
|
|
2613
|
+
if (isNaN(fps)) {
|
|
2614
|
+
throw new Error(\`"fps" must not be NaN, but got \${fps} \${location}\`);
|
|
2615
|
+
}
|
|
2616
|
+
if (fps <= 0) {
|
|
2617
|
+
throw new TypeError(\`"fps" must be positive, but got \${fps} \${location}\`);
|
|
2618
|
+
}
|
|
2619
|
+
if (isGif && fps > 50) {
|
|
2620
|
+
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\`);
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
var validateSpringDuration = (dur) => {
|
|
2624
|
+
if (typeof dur === "undefined") {
|
|
2625
|
+
return;
|
|
2626
|
+
}
|
|
2627
|
+
if (typeof dur !== "number") {
|
|
2628
|
+
throw new TypeError(\`A "duration" of a spring must be a "number" but is "\${typeof dur}"\`);
|
|
2629
|
+
}
|
|
2630
|
+
if (Number.isNaN(dur)) {
|
|
2631
|
+
throw new TypeError('A "duration" of a spring is NaN, which it must not be');
|
|
2632
|
+
}
|
|
2633
|
+
if (!Number.isFinite(dur)) {
|
|
2634
|
+
throw new TypeError('A "duration" of a spring must be finite, but is ' + dur);
|
|
2635
|
+
}
|
|
2636
|
+
if (dur <= 0) {
|
|
2637
|
+
throw new TypeError('A "duration" of a spring must be positive, but is ' + dur);
|
|
2638
|
+
}
|
|
2639
|
+
};
|
|
2640
|
+
var defaultSpringConfig = {
|
|
2641
|
+
damping: 10,
|
|
2642
|
+
mass: 1,
|
|
2643
|
+
stiffness: 100,
|
|
2644
|
+
overshootClamping: false
|
|
2645
|
+
};
|
|
2646
|
+
var advanceCache = {};
|
|
2647
|
+
function advance({
|
|
2648
|
+
animation,
|
|
2649
|
+
now,
|
|
2650
|
+
config
|
|
2651
|
+
}) {
|
|
2652
|
+
const { toValue, lastTimestamp, current, velocity } = animation;
|
|
2653
|
+
const deltaTime = Math.min(now - lastTimestamp, 64);
|
|
2654
|
+
if (config.damping <= 0) {
|
|
2655
|
+
throw new Error("Spring damping must be greater than 0, otherwise the spring() animation will never end, causing an infinite loop.");
|
|
2656
|
+
}
|
|
2657
|
+
const c2 = config.damping;
|
|
2658
|
+
const m = config.mass;
|
|
2659
|
+
const k = config.stiffness;
|
|
2660
|
+
const cacheKey = [
|
|
2661
|
+
toValue,
|
|
2662
|
+
lastTimestamp,
|
|
2663
|
+
current,
|
|
2664
|
+
velocity,
|
|
2665
|
+
c2,
|
|
2666
|
+
m,
|
|
2667
|
+
k,
|
|
2668
|
+
now
|
|
2669
|
+
].join("-");
|
|
2670
|
+
if (advanceCache[cacheKey]) {
|
|
2671
|
+
return advanceCache[cacheKey];
|
|
2672
|
+
}
|
|
2673
|
+
const v0 = -velocity;
|
|
2674
|
+
const x0 = toValue - current;
|
|
2675
|
+
const zeta = c2 / (2 * Math.sqrt(k * m));
|
|
2676
|
+
const omega0 = Math.sqrt(k / m);
|
|
2677
|
+
const omega1 = omega0 * Math.sqrt(1 - zeta ** 2);
|
|
2678
|
+
const t = deltaTime / 1000;
|
|
2679
|
+
const sin1 = Math.sin(omega1 * t);
|
|
2680
|
+
const cos1 = Math.cos(omega1 * t);
|
|
2681
|
+
const underDampedEnvelope = Math.exp(-zeta * omega0 * t);
|
|
2682
|
+
const underDampedFrag1 = underDampedEnvelope * (sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);
|
|
2683
|
+
const underDampedPosition = toValue - underDampedFrag1;
|
|
2684
|
+
const underDampedVelocity = zeta * omega0 * underDampedFrag1 - underDampedEnvelope * (cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);
|
|
2685
|
+
const criticallyDampedEnvelope = Math.exp(-omega0 * t);
|
|
2686
|
+
const criticallyDampedPosition = toValue - criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);
|
|
2687
|
+
const criticallyDampedVelocity = criticallyDampedEnvelope * (v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0);
|
|
2688
|
+
const animationNode = {
|
|
2689
|
+
toValue,
|
|
2690
|
+
prevPosition: current,
|
|
2691
|
+
lastTimestamp: now,
|
|
2692
|
+
current: zeta < 1 ? underDampedPosition : criticallyDampedPosition,
|
|
2693
|
+
velocity: zeta < 1 ? underDampedVelocity : criticallyDampedVelocity
|
|
2694
|
+
};
|
|
2695
|
+
advanceCache[cacheKey] = animationNode;
|
|
2696
|
+
return animationNode;
|
|
2697
|
+
}
|
|
2698
|
+
var calculationCache = {};
|
|
2699
|
+
function springCalculation({
|
|
2700
|
+
frame,
|
|
2701
|
+
fps,
|
|
2702
|
+
config = {}
|
|
2703
|
+
}) {
|
|
2704
|
+
const from = 0;
|
|
2705
|
+
const to = 1;
|
|
2706
|
+
const cacheKey = [
|
|
2707
|
+
frame,
|
|
2708
|
+
fps,
|
|
2709
|
+
config.damping,
|
|
2710
|
+
config.mass,
|
|
2711
|
+
config.overshootClamping,
|
|
2712
|
+
config.stiffness
|
|
2713
|
+
].join("-");
|
|
2714
|
+
if (calculationCache[cacheKey]) {
|
|
2715
|
+
return calculationCache[cacheKey];
|
|
2716
|
+
}
|
|
2717
|
+
let animation = {
|
|
2718
|
+
lastTimestamp: 0,
|
|
2719
|
+
current: from,
|
|
2720
|
+
toValue: to,
|
|
2721
|
+
velocity: 0,
|
|
2722
|
+
prevPosition: 0
|
|
2723
|
+
};
|
|
2724
|
+
const frameClamped = Math.max(0, frame);
|
|
2725
|
+
const unevenRest = frameClamped % 1;
|
|
2726
|
+
for (let f = 0;f <= Math.floor(frameClamped); f++) {
|
|
2727
|
+
if (f === Math.floor(frameClamped)) {
|
|
2728
|
+
f += unevenRest;
|
|
2729
|
+
}
|
|
2730
|
+
const time = f / fps * 1000;
|
|
2731
|
+
animation = advance({
|
|
2732
|
+
animation,
|
|
2733
|
+
now: time,
|
|
2734
|
+
config: {
|
|
2735
|
+
...defaultSpringConfig,
|
|
2736
|
+
...config
|
|
2737
|
+
}
|
|
2738
|
+
});
|
|
2739
|
+
}
|
|
2740
|
+
calculationCache[cacheKey] = animation;
|
|
2741
|
+
return animation;
|
|
2742
|
+
}
|
|
2743
|
+
var cache = new Map;
|
|
2744
|
+
function measureSpring({
|
|
2745
|
+
fps,
|
|
2746
|
+
config = {},
|
|
2747
|
+
threshold = 0.005
|
|
2748
|
+
}) {
|
|
2749
|
+
if (typeof threshold !== "number") {
|
|
2750
|
+
throw new TypeError(\`threshold must be a number, got \${threshold} of type \${typeof threshold}\`);
|
|
2751
|
+
}
|
|
2752
|
+
if (threshold === 0) {
|
|
2753
|
+
return Infinity;
|
|
2754
|
+
}
|
|
2755
|
+
if (threshold === 1) {
|
|
2756
|
+
return 0;
|
|
2757
|
+
}
|
|
2758
|
+
if (isNaN(threshold)) {
|
|
2759
|
+
throw new TypeError("Threshold is NaN");
|
|
2760
|
+
}
|
|
2761
|
+
if (!Number.isFinite(threshold)) {
|
|
2762
|
+
throw new TypeError("Threshold is not finite");
|
|
2763
|
+
}
|
|
2764
|
+
if (threshold < 0) {
|
|
2765
|
+
throw new TypeError("Threshold is below 0");
|
|
2766
|
+
}
|
|
2767
|
+
const cacheKey = [
|
|
2768
|
+
fps,
|
|
2769
|
+
config.damping,
|
|
2770
|
+
config.mass,
|
|
2771
|
+
config.overshootClamping,
|
|
2772
|
+
config.stiffness,
|
|
2773
|
+
threshold
|
|
2774
|
+
].join("-");
|
|
2775
|
+
if (cache.has(cacheKey)) {
|
|
2776
|
+
return cache.get(cacheKey);
|
|
2777
|
+
}
|
|
2778
|
+
validateFps(fps, "to the measureSpring() function", false);
|
|
2779
|
+
let frame = 0;
|
|
2780
|
+
let finishedFrame = 0;
|
|
2781
|
+
const calc = () => {
|
|
2782
|
+
return springCalculation({
|
|
2783
|
+
fps,
|
|
2784
|
+
frame,
|
|
2785
|
+
config
|
|
2786
|
+
});
|
|
2787
|
+
};
|
|
2788
|
+
let animation = calc();
|
|
2789
|
+
const calcDifference = () => {
|
|
2790
|
+
return Math.abs(animation.current - animation.toValue);
|
|
2791
|
+
};
|
|
2792
|
+
let difference = calcDifference();
|
|
2793
|
+
while (difference >= threshold) {
|
|
2794
|
+
frame++;
|
|
2795
|
+
animation = calc();
|
|
2796
|
+
difference = calcDifference();
|
|
2797
|
+
}
|
|
2798
|
+
finishedFrame = frame;
|
|
2799
|
+
for (let i = 0;i < 20; i++) {
|
|
2800
|
+
frame++;
|
|
2801
|
+
animation = calc();
|
|
2802
|
+
difference = calcDifference();
|
|
2803
|
+
if (difference >= threshold) {
|
|
2804
|
+
i = 0;
|
|
2805
|
+
finishedFrame = frame + 1;
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
cache.set(cacheKey, finishedFrame);
|
|
2809
|
+
return finishedFrame;
|
|
2810
|
+
}
|
|
2811
|
+
function spring({
|
|
2812
|
+
frame: passedFrame,
|
|
2813
|
+
fps,
|
|
2814
|
+
config = {},
|
|
2815
|
+
from = 0,
|
|
2816
|
+
to = 1,
|
|
2817
|
+
durationInFrames: passedDurationInFrames,
|
|
2818
|
+
durationRestThreshold,
|
|
2819
|
+
delay = 0,
|
|
2820
|
+
reverse = false
|
|
2821
|
+
}) {
|
|
2822
|
+
validateSpringDuration(passedDurationInFrames);
|
|
2823
|
+
validateFrame({
|
|
2824
|
+
frame: passedFrame,
|
|
2825
|
+
durationInFrames: Infinity,
|
|
2826
|
+
allowFloats: true
|
|
2827
|
+
});
|
|
2828
|
+
validateFps(fps, "to spring()", false);
|
|
2829
|
+
const needsToCalculateNaturalDuration = reverse || typeof passedDurationInFrames !== "undefined";
|
|
2830
|
+
const naturalDuration = needsToCalculateNaturalDuration ? measureSpring({
|
|
2831
|
+
fps,
|
|
2832
|
+
config,
|
|
2833
|
+
threshold: durationRestThreshold
|
|
2834
|
+
}) : undefined;
|
|
2835
|
+
const naturalDurationGetter = needsToCalculateNaturalDuration ? {
|
|
2836
|
+
get: () => naturalDuration
|
|
2837
|
+
} : {
|
|
2838
|
+
get: () => {
|
|
2839
|
+
throw new Error("did not calculate natural duration, this is an error with Remotion. Please report");
|
|
2840
|
+
}
|
|
2841
|
+
};
|
|
2842
|
+
const reverseProcessed = reverse ? (passedDurationInFrames ?? naturalDurationGetter.get()) - passedFrame : passedFrame;
|
|
2843
|
+
const delayProcessed = reverseProcessed + (reverse ? delay : -delay);
|
|
2844
|
+
const durationProcessed = passedDurationInFrames === undefined ? delayProcessed : delayProcessed / (passedDurationInFrames / naturalDurationGetter.get());
|
|
2845
|
+
if (passedDurationInFrames && delayProcessed > passedDurationInFrames) {
|
|
2846
|
+
return to;
|
|
2847
|
+
}
|
|
2848
|
+
const spr = springCalculation({
|
|
2849
|
+
fps,
|
|
2850
|
+
frame: durationProcessed,
|
|
2851
|
+
config
|
|
2852
|
+
});
|
|
2853
|
+
const inner = config.overshootClamping ? to >= from ? Math.min(spr.current, to) : Math.max(spr.current, to) : spr.current;
|
|
2854
|
+
const interpolated = from === 0 && to === 1 ? inner : interpolate(inner, [0, 1], [from, to]);
|
|
2855
|
+
return interpolated;
|
|
2856
|
+
}
|
|
2857
|
+
var clampUnit = (t) => Math.min(1, Math.max(0, t));
|
|
2858
|
+
var springEasingDurationInFrames = 30;
|
|
2859
|
+
|
|
2860
|
+
class Easing {
|
|
2861
|
+
static step0(n) {
|
|
2862
|
+
return n > 0 ? 1 : 0;
|
|
2863
|
+
}
|
|
2864
|
+
static step1(n) {
|
|
2865
|
+
return n >= 1 ? 1 : 0;
|
|
2866
|
+
}
|
|
2867
|
+
static linear(t) {
|
|
2868
|
+
return t;
|
|
2869
|
+
}
|
|
2870
|
+
static ease(t) {
|
|
2871
|
+
return Easing.bezier(0.42, 0, 1, 1)(t);
|
|
2872
|
+
}
|
|
2873
|
+
static quad(t) {
|
|
2874
|
+
return t * t;
|
|
2875
|
+
}
|
|
2876
|
+
static cubic(t) {
|
|
2877
|
+
return t * t * t;
|
|
2878
|
+
}
|
|
2879
|
+
static poly(n) {
|
|
2880
|
+
return (t) => t ** n;
|
|
2881
|
+
}
|
|
2882
|
+
static sin(t) {
|
|
2883
|
+
return 1 - Math.cos(t * Math.PI / 2);
|
|
2884
|
+
}
|
|
2885
|
+
static circle(t) {
|
|
2886
|
+
const u = clampUnit(t);
|
|
2887
|
+
return 1 - Math.sqrt(1 - u * u);
|
|
2888
|
+
}
|
|
2889
|
+
static exp(t) {
|
|
2890
|
+
return 2 ** (10 * (t - 1));
|
|
2891
|
+
}
|
|
2892
|
+
static elastic(bounciness = 1) {
|
|
2893
|
+
const p = bounciness * Math.PI;
|
|
2894
|
+
return (t) => 1 - Math.cos(t * Math.PI / 2) ** 3 * Math.cos(t * p);
|
|
2895
|
+
}
|
|
2896
|
+
static back(s = 1.70158) {
|
|
2897
|
+
return (t) => t * t * ((s + 1) * t - s);
|
|
2898
|
+
}
|
|
2899
|
+
static spring({
|
|
2900
|
+
allowTail = false,
|
|
2901
|
+
durationRestThreshold,
|
|
2902
|
+
...config
|
|
2903
|
+
} = {}) {
|
|
2904
|
+
const easing = (t) => {
|
|
2905
|
+
if (t <= 0) {
|
|
2906
|
+
return 0;
|
|
2907
|
+
}
|
|
2908
|
+
if (!allowTail && t >= 1) {
|
|
2909
|
+
return 1;
|
|
2910
|
+
}
|
|
2911
|
+
if (allowTail) {
|
|
2912
|
+
return spring({
|
|
2913
|
+
fps: springEasingDurationInFrames,
|
|
2914
|
+
frame: t * measureSpring({
|
|
2915
|
+
fps: springEasingDurationInFrames,
|
|
2916
|
+
config,
|
|
2917
|
+
threshold: durationRestThreshold
|
|
2918
|
+
}),
|
|
2919
|
+
config
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
return spring({
|
|
2923
|
+
fps: springEasingDurationInFrames,
|
|
2924
|
+
frame: t * springEasingDurationInFrames,
|
|
2925
|
+
config,
|
|
2926
|
+
durationInFrames: springEasingDurationInFrames,
|
|
2927
|
+
durationRestThreshold
|
|
2928
|
+
});
|
|
2929
|
+
};
|
|
2930
|
+
return Object.assign(easing, {
|
|
2931
|
+
remotionShouldExtendRight: allowTail
|
|
2932
|
+
});
|
|
2933
|
+
}
|
|
2934
|
+
static bounce(t) {
|
|
2935
|
+
const u = clampUnit(t);
|
|
2936
|
+
if (u < 1 / 2.75) {
|
|
2937
|
+
return 7.5625 * u * u;
|
|
2938
|
+
}
|
|
2939
|
+
if (u < 2 / 2.75) {
|
|
2940
|
+
const t2_ = u - 1.5 / 2.75;
|
|
2941
|
+
return 7.5625 * t2_ * t2_ + 0.75;
|
|
2942
|
+
}
|
|
2943
|
+
if (u < 2.5 / 2.75) {
|
|
2944
|
+
const t2_ = u - 2.25 / 2.75;
|
|
2945
|
+
return 7.5625 * t2_ * t2_ + 0.9375;
|
|
2946
|
+
}
|
|
2947
|
+
const t2 = u - 2.625 / 2.75;
|
|
2948
|
+
return 7.5625 * t2 * t2 + 0.984375;
|
|
2949
|
+
}
|
|
2950
|
+
static bezier(x1, y1, x2, y2) {
|
|
2951
|
+
return bezier(x1, y1, x2, y2);
|
|
2952
|
+
}
|
|
2953
|
+
static in(easing) {
|
|
2954
|
+
return easing;
|
|
2955
|
+
}
|
|
2956
|
+
static out(easing) {
|
|
2957
|
+
return (t) => 1 - easing(1 - t);
|
|
2958
|
+
}
|
|
2959
|
+
static inOut(easing) {
|
|
2960
|
+
return (t) => {
|
|
2961
|
+
if (t < 0.5) {
|
|
2962
|
+
return easing(t * 2) / 2;
|
|
2963
|
+
}
|
|
2964
|
+
return 1 - easing((1 - t) * 2) / 2;
|
|
2965
|
+
};
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
1953
2968
|
var normalizeNumber = (value) => {
|
|
1954
2969
|
return Math.round(value * 1e6) / 1e6;
|
|
1955
2970
|
};
|
|
@@ -2020,10 +3035,13 @@ var transformOriginCenter = { value: 50, unit: "%" };
|
|
|
2020
3035
|
var stringifyNumber = (value) => {
|
|
2021
3036
|
return String(normalizeNumber(value));
|
|
2022
3037
|
};
|
|
3038
|
+
|
|
3039
|
+
class UnsupportedStringInterpolationValueError extends TypeError {
|
|
3040
|
+
}
|
|
2023
3041
|
var parseStringInterpolationComponent = (component, value) => {
|
|
2024
3042
|
const match = cssNumberRegex.exec(component);
|
|
2025
3043
|
if (match === null) {
|
|
2026
|
-
throw new
|
|
3044
|
+
throw new UnsupportedStringInterpolationValueError(\`Cannot interpolate "\${value}" because "\${component}" is not a supported scale, translate, or rotate value\`);
|
|
2027
3045
|
}
|
|
2028
3046
|
const unit = match[2] ?? null;
|
|
2029
3047
|
const numberValue = Number(match[1]);
|
|
@@ -2490,6 +3508,52 @@ var interpolateString = ({
|
|
|
2490
3508
|
axisRotation: hasAxisRotation
|
|
2491
3509
|
});
|
|
2492
3510
|
};
|
|
3511
|
+
var interpolateDiscreteString = ({
|
|
3512
|
+
input,
|
|
3513
|
+
inputRange,
|
|
3514
|
+
outputRange,
|
|
3515
|
+
options
|
|
3516
|
+
}) => {
|
|
3517
|
+
if (inputRange.length === 1) {
|
|
3518
|
+
return outputRange[0];
|
|
3519
|
+
}
|
|
3520
|
+
for (let segmentIndex = 0;segmentIndex < inputRange.length - 1; segmentIndex++) {
|
|
3521
|
+
if (resolveEasingForSegment({
|
|
3522
|
+
easing: options?.easing,
|
|
3523
|
+
segmentIndex
|
|
3524
|
+
}) !== Easing.step1) {
|
|
3525
|
+
throw new TypeError("Non-numeric strings can only be interpolated using Easing.step1");
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
|
|
3529
|
+
const inputMin = inputRange[0];
|
|
3530
|
+
const inputMax = inputRange[inputRange.length - 1];
|
|
3531
|
+
let resolvedInput = posterizedInput;
|
|
3532
|
+
if (resolvedInput < inputMin) {
|
|
3533
|
+
if (options?.extrapolateLeft === "identity") {
|
|
3534
|
+
throw new TypeError('extrapolateLeft: "identity" is not supported for non-numeric strings');
|
|
3535
|
+
}
|
|
3536
|
+
if (options?.extrapolateLeft === "wrap") {
|
|
3537
|
+
const wrapRange = inputMax - inputMin;
|
|
3538
|
+
resolvedInput = ((resolvedInput - inputMin) % wrapRange + wrapRange) % wrapRange + inputMin;
|
|
3539
|
+
} else {
|
|
3540
|
+
return outputRange[0];
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
if (resolvedInput > inputMax) {
|
|
3544
|
+
if (options?.extrapolateRight === "identity") {
|
|
3545
|
+
throw new TypeError('extrapolateRight: "identity" is not supported for non-numeric strings');
|
|
3546
|
+
}
|
|
3547
|
+
if (options?.extrapolateRight === "wrap") {
|
|
3548
|
+
const wrapRange = inputMax - inputMin;
|
|
3549
|
+
resolvedInput = ((resolvedInput - inputMin) % wrapRange + wrapRange) % wrapRange + inputMin;
|
|
3550
|
+
} else {
|
|
3551
|
+
return outputRange[outputRange.length - 1];
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
const range = findRange(resolvedInput, inputRange);
|
|
3555
|
+
return resolvedInput >= inputRange[range + 1] ? outputRange[range + 1] : outputRange[range];
|
|
3556
|
+
};
|
|
2493
3557
|
var validateTupleOutputRange = (outputRange) => {
|
|
2494
3558
|
const dimensions = outputRange[0]?.length;
|
|
2495
3559
|
if (dimensions === undefined) {
|
|
@@ -2604,7 +3668,30 @@ function interpolate(input, inputRange, outputRange, options) {
|
|
|
2604
3668
|
if (!outputRange.every((output) => typeof output === "string" || typeof output === "number")) {
|
|
2605
3669
|
throw new TypeError("outputRange must contain only numbers, or supported scale, translate, and rotate strings");
|
|
2606
3670
|
}
|
|
2607
|
-
|
|
3671
|
+
try {
|
|
3672
|
+
return interpolateString({ input, inputRange, outputRange, options });
|
|
3673
|
+
} catch (error) {
|
|
3674
|
+
if (!outputRange.every((output) => typeof output === "string")) {
|
|
3675
|
+
throw error;
|
|
3676
|
+
}
|
|
3677
|
+
const hasNonNumericString = outputRange.some((output) => {
|
|
3678
|
+
try {
|
|
3679
|
+
parseStringInterpolationValue(output);
|
|
3680
|
+
return false;
|
|
3681
|
+
} catch (parseError) {
|
|
3682
|
+
return parseError instanceof UnsupportedStringInterpolationValueError;
|
|
3683
|
+
}
|
|
3684
|
+
});
|
|
3685
|
+
if (!hasNonNumericString) {
|
|
3686
|
+
throw error;
|
|
3687
|
+
}
|
|
3688
|
+
return interpolateDiscreteString({
|
|
3689
|
+
input,
|
|
3690
|
+
inputRange,
|
|
3691
|
+
outputRange,
|
|
3692
|
+
options
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
2608
3695
|
}
|
|
2609
3696
|
if (outputRange.every((output) => Array.isArray(output))) {
|
|
2610
3697
|
return interpolateTuple({ input, inputRange, outputRange, options });
|
|
@@ -3073,8 +4160,8 @@ function hslToRgb(h, s, l) {
|
|
|
3073
4160
|
const p = 2 * l - q;
|
|
3074
4161
|
const r = hue2rgb(p, q, h + 1 / 3);
|
|
3075
4162
|
const g = hue2rgb(p, q, h);
|
|
3076
|
-
const
|
|
3077
|
-
return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(
|
|
4163
|
+
const b2 = hue2rgb(p, q, h - 1 / 3);
|
|
4164
|
+
return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b2 * 255) << 8;
|
|
3078
4165
|
}
|
|
3079
4166
|
function parse255(str) {
|
|
3080
4167
|
const int = Number.parseInt(str, 10);
|
|
@@ -3138,25 +4225,25 @@ function parseModernAlpha(str) {
|
|
|
3138
4225
|
}
|
|
3139
4226
|
return Math.max(0, Math.min(1, Number.parseFloat(str)));
|
|
3140
4227
|
}
|
|
3141
|
-
function linearToSrgb(
|
|
3142
|
-
if (
|
|
3143
|
-
return 12.92 *
|
|
3144
|
-
return 1.055 *
|
|
4228
|
+
function linearToSrgb(c2) {
|
|
4229
|
+
if (c2 <= 0.0031308)
|
|
4230
|
+
return 12.92 * c2;
|
|
4231
|
+
return 1.055 * c2 ** (1 / 2.4) - 0.055;
|
|
3145
4232
|
}
|
|
3146
4233
|
function clamp01(v) {
|
|
3147
4234
|
return Math.max(0, Math.min(1, v));
|
|
3148
4235
|
}
|
|
3149
|
-
function rgbFloatToInt(r, g,
|
|
4236
|
+
function rgbFloatToInt(r, g, b2, alpha) {
|
|
3150
4237
|
const ri = Math.round(clamp01(r) * 255);
|
|
3151
4238
|
const gi = Math.round(clamp01(g) * 255);
|
|
3152
|
-
const bi = Math.round(clamp01(
|
|
4239
|
+
const bi = Math.round(clamp01(b2) * 255);
|
|
3153
4240
|
const ai = Math.round(clamp01(alpha) * 255);
|
|
3154
4241
|
return (ri << 24 | gi << 16 | bi << 8 | ai) >>> 0;
|
|
3155
4242
|
}
|
|
3156
|
-
function oklabToSrgb(L,
|
|
3157
|
-
const l_ = L + 0.3963377774 *
|
|
3158
|
-
const m_ = L - 0.1055613458 *
|
|
3159
|
-
const s_ = L - 0.0894841775 *
|
|
4243
|
+
function oklabToSrgb(L, a2, b2) {
|
|
4244
|
+
const l_ = L + 0.3963377774 * a2 + 0.2158037573 * b2;
|
|
4245
|
+
const m_ = L - 0.1055613458 * a2 - 0.0638541728 * b2;
|
|
4246
|
+
const s_ = L - 0.0894841775 * a2 - 1.291485548 * b2;
|
|
3160
4247
|
const l = l_ * l_ * l_;
|
|
3161
4248
|
const m = m_ * m_ * m_;
|
|
3162
4249
|
const s = s_ * s_ * s_;
|
|
@@ -3165,15 +4252,15 @@ function oklabToSrgb(L, a, b) {
|
|
|
3165
4252
|
const bLin = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;
|
|
3166
4253
|
return [linearToSrgb(rLin), linearToSrgb(gLin), linearToSrgb(bLin)];
|
|
3167
4254
|
}
|
|
3168
|
-
function labToSrgb(L,
|
|
4255
|
+
function labToSrgb(L, a2, b2) {
|
|
3169
4256
|
const epsilon = 216 / 24389;
|
|
3170
4257
|
const kappa = 24389 / 27;
|
|
3171
4258
|
const Xn = 0.95047;
|
|
3172
4259
|
const Yn = 1;
|
|
3173
4260
|
const Zn = 1.08883;
|
|
3174
4261
|
const fy = (L + 16) / 116;
|
|
3175
|
-
const fx =
|
|
3176
|
-
const fz = fy -
|
|
4262
|
+
const fx = a2 / 500 + fy;
|
|
4263
|
+
const fz = fy - b2 / 200;
|
|
3177
4264
|
const fx3 = fx * fx * fx;
|
|
3178
4265
|
const fz3 = fz * fz * fz;
|
|
3179
4266
|
const xr = fx3 > epsilon ? fx3 : (116 * fx - 16) / kappa;
|
|
@@ -3405,27 +4492,27 @@ function normalizeColor(color) {
|
|
|
3405
4492
|
const H = parseHueAngle(match[3]);
|
|
3406
4493
|
const alpha = parseModernAlpha(match[4]);
|
|
3407
4494
|
const hRad = H * Math.PI / 180;
|
|
3408
|
-
const [r, g,
|
|
3409
|
-
return rgbFloatToInt(r, g,
|
|
4495
|
+
const [r, g, b2] = oklabToSrgb(L, C * Math.cos(hRad), C * Math.sin(hRad));
|
|
4496
|
+
return rgbFloatToInt(r, g, b2, alpha);
|
|
3410
4497
|
}
|
|
3411
4498
|
}
|
|
3412
4499
|
if (matchers.oklab) {
|
|
3413
4500
|
if (match = matchers.oklab.exec(color)) {
|
|
3414
4501
|
const L = parseModernComponent(match[1], 1);
|
|
3415
|
-
const
|
|
3416
|
-
const
|
|
4502
|
+
const a2 = parseModernComponent(match[2], 0.4);
|
|
4503
|
+
const b2 = parseModernComponent(match[3], 0.4);
|
|
3417
4504
|
const alpha = parseModernAlpha(match[4]);
|
|
3418
|
-
const [r, g, bl] = oklabToSrgb(L,
|
|
4505
|
+
const [r, g, bl] = oklabToSrgb(L, a2, b2);
|
|
3419
4506
|
return rgbFloatToInt(r, g, bl, alpha);
|
|
3420
4507
|
}
|
|
3421
4508
|
}
|
|
3422
4509
|
if (matchers.lab) {
|
|
3423
4510
|
if (match = matchers.lab.exec(color)) {
|
|
3424
4511
|
const L = parseModernComponent(match[1], 100);
|
|
3425
|
-
const
|
|
3426
|
-
const
|
|
4512
|
+
const a2 = parseModernComponent(match[2], 125);
|
|
4513
|
+
const b2 = parseModernComponent(match[3], 125);
|
|
3427
4514
|
const alpha = parseModernAlpha(match[4]);
|
|
3428
|
-
const [r, g, bl] = labToSrgb(L,
|
|
4515
|
+
const [r, g, bl] = labToSrgb(L, a2, b2);
|
|
3429
4516
|
return rgbFloatToInt(r, g, bl, alpha);
|
|
3430
4517
|
}
|
|
3431
4518
|
}
|
|
@@ -3504,30 +4591,6 @@ var serializeScaleValue = ([x, y, z]) => {
|
|
|
3504
4591
|
return \`\${normalizedX} \${normalizedY} \${normalizedZ}\`;
|
|
3505
4592
|
};
|
|
3506
4593
|
var ENABLE_V5_BREAKING_CHANGES = false;
|
|
3507
|
-
var validateFrame = ({
|
|
3508
|
-
allowFloats,
|
|
3509
|
-
durationInFrames,
|
|
3510
|
-
frame
|
|
3511
|
-
}) => {
|
|
3512
|
-
if (typeof frame === "undefined") {
|
|
3513
|
-
throw new TypeError(\`Argument missing for parameter "frame"\`);
|
|
3514
|
-
}
|
|
3515
|
-
if (typeof frame !== "number") {
|
|
3516
|
-
throw new TypeError(\`Argument passed for "frame" is not a number: \${frame}\`);
|
|
3517
|
-
}
|
|
3518
|
-
if (!Number.isFinite(frame)) {
|
|
3519
|
-
throw new RangeError(\`Frame \${frame} is not finite\`);
|
|
3520
|
-
}
|
|
3521
|
-
if (frame % 1 !== 0 && !allowFloats) {
|
|
3522
|
-
throw new RangeError(\`Argument for frame must be an integer, but got \${frame}\`);
|
|
3523
|
-
}
|
|
3524
|
-
if (frame < 0 && frame < -durationInFrames) {
|
|
3525
|
-
throw new RangeError(\`Cannot use frame \${frame}: Duration of composition is \${durationInFrames}, therefore the lowest frame that can be rendered is \${-durationInFrames}\`);
|
|
3526
|
-
}
|
|
3527
|
-
if (frame > durationInFrames - 1) {
|
|
3528
|
-
throw new RangeError(\`Cannot use frame \${frame}: Duration of composition is \${durationInFrames}, therefore the highest frame that can be rendered is \${durationInFrames - 1}\`);
|
|
3529
|
-
}
|
|
3530
|
-
};
|
|
3531
4594
|
var validCodecs = [
|
|
3532
4595
|
"h264",
|
|
3533
4596
|
"h265",
|
|
@@ -3599,23 +4662,6 @@ function validateDurationInFrames(durationInFrames, options) {
|
|
|
3599
4662
|
throw new TypeError(\`The "durationInFrames" prop \${component} must be finite, but got \${durationInFrames}.\`);
|
|
3600
4663
|
}
|
|
3601
4664
|
}
|
|
3602
|
-
function validateFps(fps, location, isGif) {
|
|
3603
|
-
if (typeof fps !== "number") {
|
|
3604
|
-
throw new Error(\`"fps" must be a number, but you passed a value of type \${typeof fps} \${location}\`);
|
|
3605
|
-
}
|
|
3606
|
-
if (!Number.isFinite(fps)) {
|
|
3607
|
-
throw new Error(\`"fps" must be a finite, but you passed \${fps} \${location}\`);
|
|
3608
|
-
}
|
|
3609
|
-
if (isNaN(fps)) {
|
|
3610
|
-
throw new Error(\`"fps" must not be NaN, but got \${fps} \${location}\`);
|
|
3611
|
-
}
|
|
3612
|
-
if (fps <= 0) {
|
|
3613
|
-
throw new TypeError(\`"fps" must be positive, but got \${fps} \${location}\`);
|
|
3614
|
-
}
|
|
3615
|
-
if (isGif && fps > 50) {
|
|
3616
|
-
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\`);
|
|
3617
|
-
}
|
|
3618
|
-
}
|
|
3619
4665
|
var getExpectedMediaFrameUncorrected = ({
|
|
3620
4666
|
frame,
|
|
3621
4667
|
playbackRate,
|