@remotion/vercel 4.0.525 → 4.0.527

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 +184 -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;
@@ -2750,13 +2825,19 @@ function springCalculation({
2750
2825
  }) {
2751
2826
  const from = 0;
2752
2827
  const to = 1;
2828
+ const resolvedConfig = {
2829
+ damping: config.damping ?? defaultSpringConfig.damping,
2830
+ mass: config.mass ?? defaultSpringConfig.mass,
2831
+ stiffness: config.stiffness ?? defaultSpringConfig.stiffness,
2832
+ overshootClamping: config.overshootClamping ?? defaultSpringConfig.overshootClamping
2833
+ };
2753
2834
  const cacheKey = [
2754
2835
  frame,
2755
2836
  fps,
2756
- config.damping,
2757
- config.mass,
2758
- config.overshootClamping,
2759
- config.stiffness
2837
+ resolvedConfig.damping,
2838
+ resolvedConfig.mass,
2839
+ resolvedConfig.overshootClamping,
2840
+ resolvedConfig.stiffness
2760
2841
  ].join("-");
2761
2842
  if (calculationCache[cacheKey]) {
2762
2843
  return calculationCache[cacheKey];
@@ -2775,20 +2856,14 @@ function springCalculation({
2775
2856
  animation = advance({
2776
2857
  animation,
2777
2858
  now: time,
2778
- config: {
2779
- ...defaultSpringConfig,
2780
- ...config
2781
- }
2859
+ config: resolvedConfig
2782
2860
  });
2783
2861
  }
2784
2862
  if (unevenRest > 0) {
2785
2863
  animation = advance({
2786
2864
  animation,
2787
2865
  now: frameClamped / fps * 1000,
2788
- config: {
2789
- ...defaultSpringConfig,
2790
- ...config
2791
- }
2866
+ config: resolvedConfig
2792
2867
  });
2793
2868
  }
2794
2869
  calculationCache[cacheKey] = animation;
@@ -3253,7 +3328,7 @@ var parseAxisRotationValue = (output) => {
3253
3328
  axisRotation: true
3254
3329
  };
3255
3330
  };
3256
- var parseStringInterpolationValue = (output) => {
3331
+ var parseStringInterpolationValue = (output, outputType) => {
3257
3332
  if (typeof output === "number") {
3258
3333
  if (!Number.isFinite(output)) {
3259
3334
  throw new Error(\`outputRange must contain only finite numbers, but got [\${output}]\`);
@@ -3266,8 +3341,18 @@ var parseStringInterpolationValue = (output) => {
3266
3341
  axisRotation: false
3267
3342
  };
3268
3343
  }
3344
+ if (outputType === "transform-origin") {
3345
+ const transformOriginParts = output.trim().split(/\\s+/);
3346
+ if (transformOriginParts.length < 1 || transformOriginParts.length > 3 || transformOriginParts[0] === "") {
3347
+ throw new TypeError(\`String outputRange values must contain 1 to 3 components, but got "\${output}"\`);
3348
+ }
3349
+ return parseTransformOriginValue(output, transformOriginParts);
3350
+ }
3269
3351
  const axisRotation = parseAxisRotationValue(output);
3270
3352
  if (axisRotation !== null) {
3353
+ if (outputType !== undefined && outputType !== "rotate") {
3354
+ throw new TypeError(\`Cannot interpolate "\${output}" as \${outputType} because it is a rotate value\`);
3355
+ }
3271
3356
  return axisRotation;
3272
3357
  }
3273
3358
  const parts = output.trim().split(/\\s+/);
@@ -3275,6 +3360,9 @@ var parseStringInterpolationValue = (output) => {
3275
3360
  throw new TypeError(\`String outputRange values must contain 1 to 3 components, but got "\${output}"\`);
3276
3361
  }
3277
3362
  if (parts.some((part) => transformOriginKeywords.has(part.toLowerCase()))) {
3363
+ if (outputType !== undefined) {
3364
+ throw new TypeError(\`Cannot interpolate "\${output}" as \${outputType} because it is a transform-origin value\`);
3365
+ }
3278
3366
  return parseTransformOriginValue(output, parts);
3279
3367
  }
3280
3368
  const parsed = parts.map((part) => parseStringInterpolationComponent(part, output));
@@ -3284,6 +3372,9 @@ var parseStringInterpolationValue = (output) => {
3284
3372
  throw new TypeError(\`Cannot interpolate "\${output}" because it mixes \${kind} and \${part.kind} values\`);
3285
3373
  }
3286
3374
  }
3375
+ if (outputType !== undefined && outputType !== kind) {
3376
+ throw new TypeError(\`Cannot interpolate "\${output}" as \${outputType} because it is a \${kind} value\`);
3377
+ }
3287
3378
  if (kind === "scale") {
3288
3379
  const x = parsed[0].value;
3289
3380
  const y = parsed[1]?.value ?? x;
@@ -3484,9 +3575,10 @@ var interpolateString = ({
3484
3575
  input,
3485
3576
  inputRange,
3486
3577
  outputRange,
3487
- options
3578
+ options,
3579
+ outputType
3488
3580
  }) => {
3489
- const initiallyParsedOutputRange = outputRange.map(parseStringInterpolationValue);
3581
+ const initiallyParsedOutputRange = outputRange.map((output) => parseStringInterpolationValue(output, outputType));
3490
3582
  const hasAxisRotation = initiallyParsedOutputRange.some((parsed) => parsed.axisRotation);
3491
3583
  const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
3492
3584
  const segmentIndex = inputRange.length === 1 ? 0 : findRange(posterizedInput, inputRange);
@@ -3566,6 +3658,36 @@ var interpolateString = ({
3566
3658
  axisRotation: hasAxisRotation
3567
3659
  });
3568
3660
  };
3661
+ var interpolateFontWeight = ({
3662
+ input,
3663
+ inputRange,
3664
+ outputRange,
3665
+ options
3666
+ }) => {
3667
+ const normalizedOutputRange = outputRange.map((output) => {
3668
+ if (typeof output === "string") {
3669
+ const lowerCaseOutput = output.toLowerCase();
3670
+ if (lowerCaseOutput === "normal") {
3671
+ return 400;
3672
+ }
3673
+ if (lowerCaseOutput === "bold") {
3674
+ return 700;
3675
+ }
3676
+ }
3677
+ const match = typeof output === "string" ? cssNumberRegex.exec(output) : null;
3678
+ const value = typeof output === "number" ? output : match !== null && match[2] === undefined ? Number(match[1]) : Number.NaN;
3679
+ if (!Number.isFinite(value) || value < 1 || value > 1000) {
3680
+ throw new TypeError(\`Cannot interpolate font weight "\${output}". Expected "normal", "bold", or a number between 1 and 1000\`);
3681
+ }
3682
+ return value;
3683
+ });
3684
+ return interpolateNumber({
3685
+ input,
3686
+ inputRange,
3687
+ outputRange: normalizedOutputRange,
3688
+ options
3689
+ });
3690
+ };
3569
3691
  var interpolateDiscreteString = ({
3570
3692
  input,
3571
3693
  inputRange,
@@ -3697,6 +3819,12 @@ function assertValidInterpolateOutputOption(output) {
3697
3819
  }
3698
3820
  throw new Error(\`output must be "linear" or "perceptual-scale", but got \${String(output)}\`);
3699
3821
  }
3822
+ function assertValidInterpolateOutputType(outputType) {
3823
+ if (outputType === undefined || outputType === "font-weight" || outputType === "scale" || outputType === "translate" || outputType === "rotate" || outputType === "transform-origin") {
3824
+ return;
3825
+ }
3826
+ throw new Error(\`outputType must be "font-weight", "scale", "translate", "rotate", or "transform-origin", but got \${String(outputType)}\`);
3827
+ }
3700
3828
  function interpolate(input, inputRange, outputRange, options) {
3701
3829
  if (typeof input === "undefined") {
3702
3830
  throw new Error("input can not be undefined");
@@ -3715,26 +3843,48 @@ function interpolate(input, inputRange, outputRange, options) {
3715
3843
  assertValidInterpolateEasingOption(options?.easing, inputRange.length);
3716
3844
  assertValidInterpolatePosterizeOption(options?.posterize);
3717
3845
  assertValidInterpolateOutputOption(options?.output);
3846
+ assertValidInterpolateOutputType(options?.outputType);
3718
3847
  if (typeof input !== "number") {
3719
3848
  throw new TypeError("Cannot interpolate an input which is not a number");
3720
3849
  }
3721
3850
  if (!Array.isArray(outputRange)) {
3722
3851
  throw new Error("outputRange must contain only numbers");
3723
3852
  }
3853
+ const outputType = options?.outputType;
3854
+ if (outputType === "font-weight") {
3855
+ if (!outputRange.every((output) => typeof output === "number" || typeof output === "string")) {
3856
+ throw new TypeError("Font weight outputRange must contain only numbers or strings");
3857
+ }
3858
+ return interpolateFontWeight({
3859
+ input,
3860
+ inputRange,
3861
+ outputRange,
3862
+ options
3863
+ });
3864
+ }
3724
3865
  const hasStringOutput = outputRange.some((output) => typeof output === "string");
3866
+ if (outputType !== undefined && outputType !== "scale" && !hasStringOutput) {
3867
+ throw new TypeError(\`\${outputType} outputRange must contain strings with the appropriate CSS units\`);
3868
+ }
3725
3869
  if (hasStringOutput) {
3726
3870
  if (!outputRange.every((output) => typeof output === "string" || typeof output === "number")) {
3727
3871
  throw new TypeError("outputRange must contain only numbers, or supported scale, translate, and rotate strings");
3728
3872
  }
3729
3873
  try {
3730
- return interpolateString({ input, inputRange, outputRange, options });
3874
+ return interpolateString({
3875
+ input,
3876
+ inputRange,
3877
+ outputRange,
3878
+ options,
3879
+ outputType
3880
+ });
3731
3881
  } catch (error) {
3732
3882
  if (!outputRange.every((output) => typeof output === "string")) {
3733
3883
  throw error;
3734
3884
  }
3735
3885
  const hasNonNumericString = outputRange.some((output) => {
3736
3886
  try {
3737
- parseStringInterpolationValue(output);
3887
+ parseStringInterpolationValue(output, outputType);
3738
3888
  return false;
3739
3889
  } catch (parseError) {
3740
3890
  return parseError instanceof UnsupportedStringInterpolationValueError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/vercel",
3
- "version": "4.0.525",
3
+ "version": "4.0.527",
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.525",
27
- "remotion": "4.0.525"
26
+ "@remotion/renderer": "4.0.527",
27
+ "remotion": "4.0.527"
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.525",
41
+ "@remotion/eslint-config-internal": "4.0.527",
42
42
  "@vercel/blob": "2.3.0",
43
43
  "@vercel/sandbox": "1.6.0",
44
44
  "eslint": "9.19.0",