remotion 4.0.489 → 4.0.491

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.
@@ -251,8 +251,20 @@ var serializeStringInterpolationValue = ({
251
251
  }
252
252
  return values.slice(0, dimensions).map((value, index) => `${stringifyNumber(value)}${units[index]}`).join(" ");
253
253
  };
254
+ var toSignedArea = (scale) => {
255
+ if (scale === 0) {
256
+ return 0;
257
+ }
258
+ return Math.sign(scale) * scale * scale;
259
+ };
260
+ var fromSignedArea = (area) => {
261
+ if (area === 0) {
262
+ return 0;
263
+ }
264
+ return Math.sign(area) * Math.sqrt(Math.abs(area));
265
+ };
254
266
  function interpolateFunction(input, inputRange, outputRange, options) {
255
- const { extrapolateLeft, extrapolateRight, easing } = options;
267
+ const { extrapolateLeft, extrapolateRight, easing, output } = options;
256
268
  let result = input;
257
269
  const [inputMin, inputMax] = inputRange;
258
270
  const [outputMin, outputMax] = outputRange;
@@ -283,7 +295,13 @@ function interpolateFunction(input, inputRange, outputRange, options) {
283
295
  }
284
296
  result = (result - inputMin) / (inputMax - inputMin);
285
297
  result = easing(result);
286
- result = result * (outputMax - outputMin) + outputMin;
298
+ if (output === "perceptual-scale") {
299
+ const signedAreaMin = toSignedArea(outputMin);
300
+ const signedAreaMax = toSignedArea(outputMax);
301
+ result = fromSignedArea(result * (signedAreaMax - signedAreaMin) + signedAreaMin);
302
+ } else {
303
+ result = result * (outputMax - outputMin) + outputMin;
304
+ }
287
305
  return result;
288
306
  }
289
307
  function findRange(input, inputRange) {
@@ -296,6 +314,9 @@ function findRange(input, inputRange) {
296
314
  return i - 1;
297
315
  }
298
316
  var defaultEasing = (num) => num;
317
+ var resolveOutputOption = (output) => {
318
+ return output ?? "linear";
319
+ };
299
320
  var shouldExtendRightForEasing = (easing) => {
300
321
  return easing.remotionShouldExtendRight === true;
301
322
  };
@@ -317,12 +338,14 @@ var interpolateSegment = ({
317
338
  outputRange,
318
339
  easing,
319
340
  extrapolateLeft,
320
- extrapolateRight
341
+ extrapolateRight,
342
+ output
321
343
  }) => {
322
344
  return interpolateFunction(input, inputRange, outputRange, {
323
345
  easing,
324
346
  extrapolateLeft,
325
- extrapolateRight: input > inputRange[1] && extrapolateRight === "clamp" && shouldExtendRightForEasing(easing) ? "extend" : extrapolateRight
347
+ extrapolateRight: input > inputRange[1] && extrapolateRight === "clamp" && shouldExtendRightForEasing(easing) ? "extend" : extrapolateRight,
348
+ output
326
349
  });
327
350
  };
328
351
  var interpolateNumber = ({
@@ -331,6 +354,7 @@ var interpolateNumber = ({
331
354
  outputRange,
332
355
  options
333
356
  }) => {
357
+ const output = resolveOutputOption(options?.output);
334
358
  if (inputRange.length === 1) {
335
359
  return outputRange[0];
336
360
  }
@@ -355,7 +379,8 @@ var interpolateNumber = ({
355
379
  outputRange: [outputRange[range], outputRange[range + 1]],
356
380
  easing,
357
381
  extrapolateLeft,
358
- extrapolateRight
382
+ extrapolateRight,
383
+ output
359
384
  });
360
385
  for (let segmentIndex = 0;segmentIndex < range; segmentIndex++) {
361
386
  const previousEasing = resolveEasingForSegment({
@@ -375,7 +400,8 @@ var interpolateNumber = ({
375
400
  outputRange: [outputRange[segmentIndex], outputRange[segmentIndex + 1]],
376
401
  easing: previousEasing,
377
402
  extrapolateLeft,
378
- extrapolateRight: "extend"
403
+ extrapolateRight: "extend",
404
+ output
379
405
  });
380
406
  result += continuedSegmentValue - outputRange[segmentIndex + 1];
381
407
  }
@@ -423,14 +449,18 @@ var interpolateString = ({
423
449
  }
424
450
  }
425
451
  }
426
- return serializeStringInterpolationValue({
427
- kind,
428
- values: [0, 0, 0].map((_, axis) => interpolateNumber({
452
+ const values = [0, 0, 0];
453
+ for (let axis = 0;axis < dimensions; axis++) {
454
+ values[axis] = interpolateNumber({
429
455
  input,
430
456
  inputRange,
431
457
  outputRange: parsedOutputRange.map((parsed) => parsed.values[axis]),
432
458
  options
433
- })),
459
+ });
460
+ }
461
+ return serializeStringInterpolationValue({
462
+ kind,
463
+ values,
434
464
  units,
435
465
  dimensions
436
466
  });
@@ -514,6 +544,12 @@ function assertValidInterpolatePosterizeOption(posterize) {
514
544
  throw new Error(`posterize must be a positive finite number, but got ${posterize}`);
515
545
  }
516
546
  }
547
+ function assertValidInterpolateOutputOption(output) {
548
+ if (output === undefined || output === "linear" || output === "perceptual-scale") {
549
+ return;
550
+ }
551
+ throw new Error(`output must be "linear" or "perceptual-scale", but got ${String(output)}`);
552
+ }
517
553
  function interpolate(input, inputRange, outputRange, options) {
518
554
  if (typeof input === "undefined") {
519
555
  throw new Error("input can not be undefined");
@@ -531,6 +567,7 @@ function interpolate(input, inputRange, outputRange, options) {
531
567
  checkValidInputRange(inputRange);
532
568
  assertValidInterpolateEasingOption(options?.easing, inputRange.length);
533
569
  assertValidInterpolatePosterizeOption(options?.posterize);
570
+ assertValidInterpolateOutputOption(options?.output);
534
571
  if (typeof input !== "number") {
535
572
  throw new TypeError("Cannot interpolate an input which is not a number");
536
573
  }
@@ -705,7 +742,8 @@ var transformSchema = {
705
742
  max: 100,
706
743
  step: 0.01,
707
744
  default: 1,
708
- description: "Scale"
745
+ description: "Scale",
746
+ defaultKeyframeOutput: "perceptual-scale"
709
747
  },
710
748
  "style.rotate": {
711
749
  type: "rotation-css",
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.489";
2
+ var VERSION = "4.0.491";
3
3
  export {
4
4
  VERSION
5
5
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/core"
4
4
  },
5
5
  "name": "remotion",
6
- "version": "4.0.489",
6
+ "version": "4.0.491",
7
7
  "description": "Make videos programmatically",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "react-dom": "19.2.3",
36
36
  "webpack": "5.105.0",
37
37
  "zod": "4.3.6",
38
- "@remotion/eslint-config-internal": "4.0.489",
38
+ "@remotion/eslint-config-internal": "4.0.491",
39
39
  "eslint": "9.19.0",
40
40
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
41
41
  },