@remotion/vercel 4.0.526 → 4.0.528

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.
Files changed (2) hide show
  1. package/dist/esm/index.mjs +206 -34
  2. package/package.json +4 -4
@@ -345,13 +345,19 @@ function springCalculation({
345
345
  }) {
346
346
  const from = 0;
347
347
  const to = 1;
348
+ const resolvedConfig = {
349
+ damping: config.damping ?? defaultSpringConfig.damping,
350
+ mass: config.mass ?? defaultSpringConfig.mass,
351
+ stiffness: config.stiffness ?? defaultSpringConfig.stiffness,
352
+ overshootClamping: config.overshootClamping ?? defaultSpringConfig.overshootClamping
353
+ };
348
354
  const cacheKey = [
349
355
  frame,
350
356
  fps,
351
- config.damping,
352
- config.mass,
353
- config.overshootClamping,
354
- config.stiffness
357
+ resolvedConfig.damping,
358
+ resolvedConfig.mass,
359
+ resolvedConfig.overshootClamping,
360
+ resolvedConfig.stiffness
355
361
  ].join("-");
356
362
  if (calculationCache[cacheKey]) {
357
363
  return calculationCache[cacheKey];
@@ -370,20 +376,14 @@ function springCalculation({
370
376
  animation = advance({
371
377
  animation,
372
378
  now: time,
373
- config: {
374
- ...defaultSpringConfig,
375
- ...config
376
- }
379
+ config: resolvedConfig
377
380
  });
378
381
  }
379
382
  if (unevenRest > 0) {
380
383
  animation = advance({
381
384
  animation,
382
385
  now: frameClamped / fps * 1000,
383
- config: {
384
- ...defaultSpringConfig,
385
- ...config
386
- }
386
+ config: resolvedConfig
387
387
  });
388
388
  }
389
389
  calculationCache[cacheKey] = animation;
@@ -848,7 +848,7 @@ var parseAxisRotationValue = (output) => {
848
848
  axisRotation: true
849
849
  };
850
850
  };
851
- var parseStringInterpolationValue = (output) => {
851
+ var parseStringInterpolationValue = (output, outputType) => {
852
852
  if (typeof output === "number") {
853
853
  if (!Number.isFinite(output)) {
854
854
  throw new Error(\`outputRange must contain only finite numbers, but got [\${output}]\`);
@@ -861,8 +861,18 @@ var parseStringInterpolationValue = (output) => {
861
861
  axisRotation: false
862
862
  };
863
863
  }
864
+ if (outputType === "transform-origin") {
865
+ const transformOriginParts = output.trim().split(/\\s+/);
866
+ if (transformOriginParts.length < 1 || transformOriginParts.length > 3 || transformOriginParts[0] === "") {
867
+ throw new TypeError(\`String outputRange values must contain 1 to 3 components, but got "\${output}"\`);
868
+ }
869
+ return parseTransformOriginValue(output, transformOriginParts);
870
+ }
864
871
  const axisRotation = parseAxisRotationValue(output);
865
872
  if (axisRotation !== null) {
873
+ if (outputType !== undefined && outputType !== "rotate") {
874
+ throw new TypeError(\`Cannot interpolate "\${output}" as \${outputType} because it is a rotate value\`);
875
+ }
866
876
  return axisRotation;
867
877
  }
868
878
  const parts = output.trim().split(/\\s+/);
@@ -870,6 +880,9 @@ var parseStringInterpolationValue = (output) => {
870
880
  throw new TypeError(\`String outputRange values must contain 1 to 3 components, but got "\${output}"\`);
871
881
  }
872
882
  if (parts.some((part) => transformOriginKeywords.has(part.toLowerCase()))) {
883
+ if (outputType !== undefined) {
884
+ throw new TypeError(\`Cannot interpolate "\${output}" as \${outputType} because it is a transform-origin value\`);
885
+ }
873
886
  return parseTransformOriginValue(output, parts);
874
887
  }
875
888
  const parsed = parts.map((part) => parseStringInterpolationComponent(part, output));
@@ -879,6 +892,9 @@ var parseStringInterpolationValue = (output) => {
879
892
  throw new TypeError(\`Cannot interpolate "\${output}" because it mixes \${kind} and \${part.kind} values\`);
880
893
  }
881
894
  }
895
+ if (outputType !== undefined && outputType !== kind) {
896
+ throw new TypeError(\`Cannot interpolate "\${output}" as \${outputType} because it is a \${kind} value\`);
897
+ }
882
898
  if (kind === "scale") {
883
899
  const x = parsed[0].value;
884
900
  const y = parsed[1]?.value ?? x;
@@ -1079,9 +1095,10 @@ var interpolateString = ({
1079
1095
  input,
1080
1096
  inputRange,
1081
1097
  outputRange,
1082
- options
1098
+ options,
1099
+ outputType
1083
1100
  }) => {
1084
- const initiallyParsedOutputRange = outputRange.map(parseStringInterpolationValue);
1101
+ const initiallyParsedOutputRange = outputRange.map((output) => parseStringInterpolationValue(output, outputType));
1085
1102
  const hasAxisRotation = initiallyParsedOutputRange.some((parsed) => parsed.axisRotation);
1086
1103
  const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
1087
1104
  const segmentIndex = inputRange.length === 1 ? 0 : findRange(posterizedInput, inputRange);
@@ -1161,6 +1178,36 @@ var interpolateString = ({
1161
1178
  axisRotation: hasAxisRotation
1162
1179
  });
1163
1180
  };
1181
+ var interpolateFontWeight = ({
1182
+ input,
1183
+ inputRange,
1184
+ outputRange,
1185
+ options
1186
+ }) => {
1187
+ const normalizedOutputRange = outputRange.map((output) => {
1188
+ if (typeof output === "string") {
1189
+ const lowerCaseOutput = output.toLowerCase();
1190
+ if (lowerCaseOutput === "normal") {
1191
+ return 400;
1192
+ }
1193
+ if (lowerCaseOutput === "bold") {
1194
+ return 700;
1195
+ }
1196
+ }
1197
+ const match = typeof output === "string" ? cssNumberRegex.exec(output) : null;
1198
+ const value = typeof output === "number" ? output : match !== null && match[2] === undefined ? Number(match[1]) : Number.NaN;
1199
+ if (!Number.isFinite(value) || value < 1 || value > 1000) {
1200
+ throw new TypeError(\`Cannot interpolate font weight "\${output}". Expected "normal", "bold", or a number between 1 and 1000\`);
1201
+ }
1202
+ return value;
1203
+ });
1204
+ return interpolateNumber({
1205
+ input,
1206
+ inputRange,
1207
+ outputRange: normalizedOutputRange,
1208
+ options
1209
+ });
1210
+ };
1164
1211
  var interpolateDiscreteString = ({
1165
1212
  input,
1166
1213
  inputRange,
@@ -1292,6 +1339,12 @@ function assertValidInterpolateOutputOption(output) {
1292
1339
  }
1293
1340
  throw new Error(\`output must be "linear" or "perceptual-scale", but got \${String(output)}\`);
1294
1341
  }
1342
+ function assertValidInterpolateOutputType(outputType) {
1343
+ if (outputType === undefined || outputType === "font-weight" || outputType === "scale" || outputType === "translate" || outputType === "rotate" || outputType === "transform-origin") {
1344
+ return;
1345
+ }
1346
+ throw new Error(\`outputType must be "font-weight", "scale", "translate", "rotate", or "transform-origin", but got \${String(outputType)}\`);
1347
+ }
1295
1348
  function interpolate(input, inputRange, outputRange, options) {
1296
1349
  if (typeof input === "undefined") {
1297
1350
  throw new Error("input can not be undefined");
@@ -1310,26 +1363,48 @@ function interpolate(input, inputRange, outputRange, options) {
1310
1363
  assertValidInterpolateEasingOption(options?.easing, inputRange.length);
1311
1364
  assertValidInterpolatePosterizeOption(options?.posterize);
1312
1365
  assertValidInterpolateOutputOption(options?.output);
1366
+ assertValidInterpolateOutputType(options?.outputType);
1313
1367
  if (typeof input !== "number") {
1314
1368
  throw new TypeError("Cannot interpolate an input which is not a number");
1315
1369
  }
1316
1370
  if (!Array.isArray(outputRange)) {
1317
1371
  throw new Error("outputRange must contain only numbers");
1318
1372
  }
1373
+ const outputType = options?.outputType;
1374
+ if (outputType === "font-weight") {
1375
+ if (!outputRange.every((output) => typeof output === "number" || typeof output === "string")) {
1376
+ throw new TypeError("Font weight outputRange must contain only numbers or strings");
1377
+ }
1378
+ return interpolateFontWeight({
1379
+ input,
1380
+ inputRange,
1381
+ outputRange,
1382
+ options
1383
+ });
1384
+ }
1319
1385
  const hasStringOutput = outputRange.some((output) => typeof output === "string");
1386
+ if (outputType !== undefined && outputType !== "scale" && !hasStringOutput) {
1387
+ throw new TypeError(\`\${outputType} outputRange must contain strings with the appropriate CSS units\`);
1388
+ }
1320
1389
  if (hasStringOutput) {
1321
1390
  if (!outputRange.every((output) => typeof output === "string" || typeof output === "number")) {
1322
1391
  throw new TypeError("outputRange must contain only numbers, or supported scale, translate, and rotate strings");
1323
1392
  }
1324
1393
  try {
1325
- return interpolateString({ input, inputRange, outputRange, options });
1394
+ return interpolateString({
1395
+ input,
1396
+ inputRange,
1397
+ outputRange,
1398
+ options,
1399
+ outputType
1400
+ });
1326
1401
  } catch (error) {
1327
1402
  if (!outputRange.every((output) => typeof output === "string")) {
1328
1403
  throw error;
1329
1404
  }
1330
1405
  const hasNonNumericString = outputRange.some((output) => {
1331
1406
  try {
1332
- parseStringInterpolationValue(output);
1407
+ parseStringInterpolationValue(output, outputType);
1333
1408
  return false;
1334
1409
  } catch (parseError) {
1335
1410
  return parseError instanceof UnsupportedStringInterpolationValueError;
@@ -1737,10 +1812,20 @@ var freezeField = {
1737
1812
  step: 1,
1738
1813
  hiddenFromList: true
1739
1814
  };
1815
+ var playbackRateField = {
1816
+ type: "number",
1817
+ default: 1,
1818
+ min: 0.01,
1819
+ step: 0.1,
1820
+ description: "Playback rate",
1821
+ hiddenFromList: false,
1822
+ keyframable: false
1823
+ };
1740
1824
  var baseSchema = {
1741
1825
  durationInFrames: durationInFramesField,
1742
1826
  from: fromField,
1743
1827
  trimBefore: trimBeforeField,
1828
+ playbackRate: playbackRateField,
1744
1829
  freeze: freezeField,
1745
1830
  hidden: hiddenField,
1746
1831
  name: sequenceNameField,
@@ -1761,6 +1846,7 @@ var sequenceSchema = {
1761
1846
  var baseSchemaWithoutFrom = {
1762
1847
  durationInFrames: durationInFramesField,
1763
1848
  trimBefore: trimBeforeField,
1849
+ playbackRate: playbackRateField,
1764
1850
  freeze: freezeField,
1765
1851
  hidden: hiddenField,
1766
1852
  name: sequenceNameField,
@@ -2750,13 +2836,19 @@ function springCalculation({
2750
2836
  }) {
2751
2837
  const from = 0;
2752
2838
  const to = 1;
2839
+ const resolvedConfig = {
2840
+ damping: config.damping ?? defaultSpringConfig.damping,
2841
+ mass: config.mass ?? defaultSpringConfig.mass,
2842
+ stiffness: config.stiffness ?? defaultSpringConfig.stiffness,
2843
+ overshootClamping: config.overshootClamping ?? defaultSpringConfig.overshootClamping
2844
+ };
2753
2845
  const cacheKey = [
2754
2846
  frame,
2755
2847
  fps,
2756
- config.damping,
2757
- config.mass,
2758
- config.overshootClamping,
2759
- config.stiffness
2848
+ resolvedConfig.damping,
2849
+ resolvedConfig.mass,
2850
+ resolvedConfig.overshootClamping,
2851
+ resolvedConfig.stiffness
2760
2852
  ].join("-");
2761
2853
  if (calculationCache[cacheKey]) {
2762
2854
  return calculationCache[cacheKey];
@@ -2775,20 +2867,14 @@ function springCalculation({
2775
2867
  animation = advance({
2776
2868
  animation,
2777
2869
  now: time,
2778
- config: {
2779
- ...defaultSpringConfig,
2780
- ...config
2781
- }
2870
+ config: resolvedConfig
2782
2871
  });
2783
2872
  }
2784
2873
  if (unevenRest > 0) {
2785
2874
  animation = advance({
2786
2875
  animation,
2787
2876
  now: frameClamped / fps * 1000,
2788
- config: {
2789
- ...defaultSpringConfig,
2790
- ...config
2791
- }
2877
+ config: resolvedConfig
2792
2878
  });
2793
2879
  }
2794
2880
  calculationCache[cacheKey] = animation;
@@ -3253,7 +3339,7 @@ var parseAxisRotationValue = (output) => {
3253
3339
  axisRotation: true
3254
3340
  };
3255
3341
  };
3256
- var parseStringInterpolationValue = (output) => {
3342
+ var parseStringInterpolationValue = (output, outputType) => {
3257
3343
  if (typeof output === "number") {
3258
3344
  if (!Number.isFinite(output)) {
3259
3345
  throw new Error(\`outputRange must contain only finite numbers, but got [\${output}]\`);
@@ -3266,8 +3352,18 @@ var parseStringInterpolationValue = (output) => {
3266
3352
  axisRotation: false
3267
3353
  };
3268
3354
  }
3355
+ if (outputType === "transform-origin") {
3356
+ const transformOriginParts = output.trim().split(/\\s+/);
3357
+ if (transformOriginParts.length < 1 || transformOriginParts.length > 3 || transformOriginParts[0] === "") {
3358
+ throw new TypeError(\`String outputRange values must contain 1 to 3 components, but got "\${output}"\`);
3359
+ }
3360
+ return parseTransformOriginValue(output, transformOriginParts);
3361
+ }
3269
3362
  const axisRotation = parseAxisRotationValue(output);
3270
3363
  if (axisRotation !== null) {
3364
+ if (outputType !== undefined && outputType !== "rotate") {
3365
+ throw new TypeError(\`Cannot interpolate "\${output}" as \${outputType} because it is a rotate value\`);
3366
+ }
3271
3367
  return axisRotation;
3272
3368
  }
3273
3369
  const parts = output.trim().split(/\\s+/);
@@ -3275,6 +3371,9 @@ var parseStringInterpolationValue = (output) => {
3275
3371
  throw new TypeError(\`String outputRange values must contain 1 to 3 components, but got "\${output}"\`);
3276
3372
  }
3277
3373
  if (parts.some((part) => transformOriginKeywords.has(part.toLowerCase()))) {
3374
+ if (outputType !== undefined) {
3375
+ throw new TypeError(\`Cannot interpolate "\${output}" as \${outputType} because it is a transform-origin value\`);
3376
+ }
3278
3377
  return parseTransformOriginValue(output, parts);
3279
3378
  }
3280
3379
  const parsed = parts.map((part) => parseStringInterpolationComponent(part, output));
@@ -3284,6 +3383,9 @@ var parseStringInterpolationValue = (output) => {
3284
3383
  throw new TypeError(\`Cannot interpolate "\${output}" because it mixes \${kind} and \${part.kind} values\`);
3285
3384
  }
3286
3385
  }
3386
+ if (outputType !== undefined && outputType !== kind) {
3387
+ throw new TypeError(\`Cannot interpolate "\${output}" as \${outputType} because it is a \${kind} value\`);
3388
+ }
3287
3389
  if (kind === "scale") {
3288
3390
  const x = parsed[0].value;
3289
3391
  const y = parsed[1]?.value ?? x;
@@ -3484,9 +3586,10 @@ var interpolateString = ({
3484
3586
  input,
3485
3587
  inputRange,
3486
3588
  outputRange,
3487
- options
3589
+ options,
3590
+ outputType
3488
3591
  }) => {
3489
- const initiallyParsedOutputRange = outputRange.map(parseStringInterpolationValue);
3592
+ const initiallyParsedOutputRange = outputRange.map((output) => parseStringInterpolationValue(output, outputType));
3490
3593
  const hasAxisRotation = initiallyParsedOutputRange.some((parsed) => parsed.axisRotation);
3491
3594
  const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
3492
3595
  const segmentIndex = inputRange.length === 1 ? 0 : findRange(posterizedInput, inputRange);
@@ -3566,6 +3669,36 @@ var interpolateString = ({
3566
3669
  axisRotation: hasAxisRotation
3567
3670
  });
3568
3671
  };
3672
+ var interpolateFontWeight = ({
3673
+ input,
3674
+ inputRange,
3675
+ outputRange,
3676
+ options
3677
+ }) => {
3678
+ const normalizedOutputRange = outputRange.map((output) => {
3679
+ if (typeof output === "string") {
3680
+ const lowerCaseOutput = output.toLowerCase();
3681
+ if (lowerCaseOutput === "normal") {
3682
+ return 400;
3683
+ }
3684
+ if (lowerCaseOutput === "bold") {
3685
+ return 700;
3686
+ }
3687
+ }
3688
+ const match = typeof output === "string" ? cssNumberRegex.exec(output) : null;
3689
+ const value = typeof output === "number" ? output : match !== null && match[2] === undefined ? Number(match[1]) : Number.NaN;
3690
+ if (!Number.isFinite(value) || value < 1 || value > 1000) {
3691
+ throw new TypeError(\`Cannot interpolate font weight "\${output}". Expected "normal", "bold", or a number between 1 and 1000\`);
3692
+ }
3693
+ return value;
3694
+ });
3695
+ return interpolateNumber({
3696
+ input,
3697
+ inputRange,
3698
+ outputRange: normalizedOutputRange,
3699
+ options
3700
+ });
3701
+ };
3569
3702
  var interpolateDiscreteString = ({
3570
3703
  input,
3571
3704
  inputRange,
@@ -3697,6 +3830,12 @@ function assertValidInterpolateOutputOption(output) {
3697
3830
  }
3698
3831
  throw new Error(\`output must be "linear" or "perceptual-scale", but got \${String(output)}\`);
3699
3832
  }
3833
+ function assertValidInterpolateOutputType(outputType) {
3834
+ if (outputType === undefined || outputType === "font-weight" || outputType === "scale" || outputType === "translate" || outputType === "rotate" || outputType === "transform-origin") {
3835
+ return;
3836
+ }
3837
+ throw new Error(\`outputType must be "font-weight", "scale", "translate", "rotate", or "transform-origin", but got \${String(outputType)}\`);
3838
+ }
3700
3839
  function interpolate(input, inputRange, outputRange, options) {
3701
3840
  if (typeof input === "undefined") {
3702
3841
  throw new Error("input can not be undefined");
@@ -3715,26 +3854,48 @@ function interpolate(input, inputRange, outputRange, options) {
3715
3854
  assertValidInterpolateEasingOption(options?.easing, inputRange.length);
3716
3855
  assertValidInterpolatePosterizeOption(options?.posterize);
3717
3856
  assertValidInterpolateOutputOption(options?.output);
3857
+ assertValidInterpolateOutputType(options?.outputType);
3718
3858
  if (typeof input !== "number") {
3719
3859
  throw new TypeError("Cannot interpolate an input which is not a number");
3720
3860
  }
3721
3861
  if (!Array.isArray(outputRange)) {
3722
3862
  throw new Error("outputRange must contain only numbers");
3723
3863
  }
3864
+ const outputType = options?.outputType;
3865
+ if (outputType === "font-weight") {
3866
+ if (!outputRange.every((output) => typeof output === "number" || typeof output === "string")) {
3867
+ throw new TypeError("Font weight outputRange must contain only numbers or strings");
3868
+ }
3869
+ return interpolateFontWeight({
3870
+ input,
3871
+ inputRange,
3872
+ outputRange,
3873
+ options
3874
+ });
3875
+ }
3724
3876
  const hasStringOutput = outputRange.some((output) => typeof output === "string");
3877
+ if (outputType !== undefined && outputType !== "scale" && !hasStringOutput) {
3878
+ throw new TypeError(\`\${outputType} outputRange must contain strings with the appropriate CSS units\`);
3879
+ }
3725
3880
  if (hasStringOutput) {
3726
3881
  if (!outputRange.every((output) => typeof output === "string" || typeof output === "number")) {
3727
3882
  throw new TypeError("outputRange must contain only numbers, or supported scale, translate, and rotate strings");
3728
3883
  }
3729
3884
  try {
3730
- return interpolateString({ input, inputRange, outputRange, options });
3885
+ return interpolateString({
3886
+ input,
3887
+ inputRange,
3888
+ outputRange,
3889
+ options,
3890
+ outputType
3891
+ });
3731
3892
  } catch (error) {
3732
3893
  if (!outputRange.every((output) => typeof output === "string")) {
3733
3894
  throw error;
3734
3895
  }
3735
3896
  const hasNonNumericString = outputRange.some((output) => {
3736
3897
  try {
3737
- parseStringInterpolationValue(output);
3898
+ parseStringInterpolationValue(output, outputType);
3738
3899
  return false;
3739
3900
  } catch (parseError) {
3740
3901
  return parseError instanceof UnsupportedStringInterpolationValueError;
@@ -4142,10 +4303,20 @@ var freezeField = {
4142
4303
  step: 1,
4143
4304
  hiddenFromList: true
4144
4305
  };
4306
+ var playbackRateField = {
4307
+ type: "number",
4308
+ default: 1,
4309
+ min: 0.01,
4310
+ step: 0.1,
4311
+ description: "Playback rate",
4312
+ hiddenFromList: false,
4313
+ keyframable: false
4314
+ };
4145
4315
  var baseSchema = {
4146
4316
  durationInFrames: durationInFramesField,
4147
4317
  from: fromField,
4148
4318
  trimBefore: trimBeforeField,
4319
+ playbackRate: playbackRateField,
4149
4320
  freeze: freezeField,
4150
4321
  hidden: hiddenField,
4151
4322
  name: sequenceNameField,
@@ -4166,6 +4337,7 @@ var sequenceSchema = {
4166
4337
  var baseSchemaWithoutFrom = {
4167
4338
  durationInFrames: durationInFramesField,
4168
4339
  trimBefore: trimBeforeField,
4340
+ playbackRate: playbackRateField,
4169
4341
  freeze: freezeField,
4170
4342
  hidden: hiddenField,
4171
4343
  name: sequenceNameField,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/vercel",
3
- "version": "4.0.526",
3
+ "version": "4.0.528",
4
4
  "description": "Render Remotion videos on Vercel Sandbox",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  "url": "https://github.com/remotion-dev/remotion/issues"
24
24
  },
25
25
  "dependencies": {
26
- "@remotion/renderer": "4.0.526",
27
- "remotion": "4.0.526"
26
+ "@remotion/renderer": "4.0.528",
27
+ "remotion": "4.0.528"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@vercel/sandbox": ">=1.0.0"
@@ -38,7 +38,7 @@
38
38
  "./package.json": "./package.json"
39
39
  },
40
40
  "devDependencies": {
41
- "@remotion/eslint-config-internal": "4.0.526",
41
+ "@remotion/eslint-config-internal": "4.0.528",
42
42
  "@vercel/blob": "2.3.0",
43
43
  "@vercel/sandbox": "1.6.0",
44
44
  "eslint": "9.19.0",