remotion 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 (66) hide show
  1. package/dist/cjs/AbsoluteFill.d.ts +29 -3
  2. package/dist/cjs/AbsoluteFill.js +19 -2
  3. package/dist/cjs/CompositionManager.d.ts +2 -0
  4. package/dist/cjs/HtmlInCanvas.d.ts +28 -2
  5. package/dist/cjs/HtmlInCanvas.js +17 -3
  6. package/dist/cjs/Img.d.ts +2 -2
  7. package/dist/cjs/Img.js +1 -1
  8. package/dist/cjs/Interactive.d.ts +20 -2
  9. package/dist/cjs/Interactive.js +30 -8
  10. package/dist/cjs/Sequence.d.ts +1 -0
  11. package/dist/cjs/Sequence.js +49 -18
  12. package/dist/cjs/SequenceContext.d.ts +5 -0
  13. package/dist/cjs/TimelineContext.d.ts +2 -0
  14. package/dist/cjs/TimelineContext.js +8 -1
  15. package/dist/cjs/animated-image/AnimatedImage.d.ts +9 -10
  16. package/dist/cjs/animated-image/AnimatedImage.js +1 -12
  17. package/dist/cjs/audio/AudioForPreview.js +1 -0
  18. package/dist/cjs/audio/AudioForRendering.js +11 -7
  19. package/dist/cjs/audio/html5-audio.js +14 -7
  20. package/dist/cjs/audio/use-audio-frame.d.ts +1 -0
  21. package/dist/cjs/audio/use-audio-frame.js +14 -2
  22. package/dist/cjs/calculate-media-duration.js +1 -2
  23. package/dist/cjs/canvas-image/CanvasImage.d.ts +1 -1
  24. package/dist/cjs/canvas-image/CanvasImage.js +1 -1
  25. package/dist/cjs/canvas-image/props.d.ts +1 -1
  26. package/dist/cjs/effects/Solid.d.ts +28 -2
  27. package/dist/cjs/effects/Solid.js +16 -3
  28. package/dist/cjs/freeze.js +11 -3
  29. package/dist/cjs/get-asset-file-name.js +7 -1
  30. package/dist/cjs/get-sequence-boundary-tolerance.d.ts +7 -0
  31. package/dist/cjs/get-sequence-boundary-tolerance.js +10 -0
  32. package/dist/cjs/index.d.ts +3 -3
  33. package/dist/cjs/interactivity-schema.d.ts +75 -1
  34. package/dist/cjs/interactivity-schema.js +21 -1
  35. package/dist/cjs/internals.d.ts +23 -2
  36. package/dist/cjs/internals.js +2 -0
  37. package/dist/cjs/interpolate.d.ts +5 -0
  38. package/dist/cjs/interpolate.js +85 -5
  39. package/dist/cjs/loop/index.d.ts +7 -1
  40. package/dist/cjs/loop/index.js +35 -9
  41. package/dist/cjs/no-react.d.ts +10 -1
  42. package/dist/cjs/series/index.d.ts +1 -1
  43. package/dist/cjs/series/index.js +1 -0
  44. package/dist/cjs/spring/spring-utils.js +15 -12
  45. package/dist/cjs/timeline-position-state.d.ts +1 -0
  46. package/dist/cjs/timeline-position-state.js +8 -1
  47. package/dist/cjs/use-current-frame.js +2 -1
  48. package/dist/cjs/use-media-in-timeline.d.ts +5 -2
  49. package/dist/cjs/use-media-in-timeline.js +78 -13
  50. package/dist/cjs/use-media-playback.js +8 -3
  51. package/dist/cjs/use-premounting.js +19 -5
  52. package/dist/cjs/use-timeline-seek.d.ts +6 -0
  53. package/dist/cjs/use-timeline-seek.js +18 -0
  54. package/dist/cjs/version.d.ts +1 -1
  55. package/dist/cjs/version.js +1 -1
  56. package/dist/cjs/video/OffthreadVideo.js +7 -1
  57. package/dist/cjs/video/OffthreadVideoForRendering.js +11 -8
  58. package/dist/cjs/video/VideoForPreview.js +1 -0
  59. package/dist/cjs/video/VideoForRendering.js +12 -10
  60. package/dist/cjs/video/html5-video.js +12 -7
  61. package/dist/esm/index.mjs +927 -477
  62. package/dist/esm/no-react.mjs +103 -17
  63. package/dist/esm/version.mjs +1 -1
  64. package/package.json +2 -2
  65. package/dist/cjs/nonce.d.ts +0 -11
  66. package/dist/cjs/nonce.js +0 -42
@@ -237,13 +237,19 @@ function springCalculation({
237
237
  }) {
238
238
  const from = 0;
239
239
  const to = 1;
240
+ const resolvedConfig = {
241
+ damping: config.damping ?? defaultSpringConfig.damping,
242
+ mass: config.mass ?? defaultSpringConfig.mass,
243
+ stiffness: config.stiffness ?? defaultSpringConfig.stiffness,
244
+ overshootClamping: config.overshootClamping ?? defaultSpringConfig.overshootClamping
245
+ };
240
246
  const cacheKey = [
241
247
  frame,
242
248
  fps,
243
- config.damping,
244
- config.mass,
245
- config.overshootClamping,
246
- config.stiffness
249
+ resolvedConfig.damping,
250
+ resolvedConfig.mass,
251
+ resolvedConfig.overshootClamping,
252
+ resolvedConfig.stiffness
247
253
  ].join("-");
248
254
  if (calculationCache[cacheKey]) {
249
255
  return calculationCache[cacheKey];
@@ -262,20 +268,14 @@ function springCalculation({
262
268
  animation = advance({
263
269
  animation,
264
270
  now: time,
265
- config: {
266
- ...defaultSpringConfig,
267
- ...config
268
- }
271
+ config: resolvedConfig
269
272
  });
270
273
  }
271
274
  if (unevenRest > 0) {
272
275
  animation = advance({
273
276
  animation,
274
277
  now: frameClamped / fps * 1000,
275
- config: {
276
- ...defaultSpringConfig,
277
- ...config
278
- }
278
+ config: resolvedConfig
279
279
  });
280
280
  }
281
281
  calculationCache[cacheKey] = animation;
@@ -750,7 +750,7 @@ var parseAxisRotationValue = (output) => {
750
750
  axisRotation: true
751
751
  };
752
752
  };
753
- var parseStringInterpolationValue = (output) => {
753
+ var parseStringInterpolationValue = (output, outputType) => {
754
754
  if (typeof output === "number") {
755
755
  if (!Number.isFinite(output)) {
756
756
  throw new Error(`outputRange must contain only finite numbers, but got [${output}]`);
@@ -763,8 +763,18 @@ var parseStringInterpolationValue = (output) => {
763
763
  axisRotation: false
764
764
  };
765
765
  }
766
+ if (outputType === "transform-origin") {
767
+ const transformOriginParts = output.trim().split(/\s+/);
768
+ if (transformOriginParts.length < 1 || transformOriginParts.length > 3 || transformOriginParts[0] === "") {
769
+ throw new TypeError(`String outputRange values must contain 1 to 3 components, but got "${output}"`);
770
+ }
771
+ return parseTransformOriginValue(output, transformOriginParts);
772
+ }
766
773
  const axisRotation = parseAxisRotationValue(output);
767
774
  if (axisRotation !== null) {
775
+ if (outputType !== undefined && outputType !== "rotate") {
776
+ throw new TypeError(`Cannot interpolate "${output}" as ${outputType} because it is a rotate value`);
777
+ }
768
778
  return axisRotation;
769
779
  }
770
780
  const parts = output.trim().split(/\s+/);
@@ -772,6 +782,9 @@ var parseStringInterpolationValue = (output) => {
772
782
  throw new TypeError(`String outputRange values must contain 1 to 3 components, but got "${output}"`);
773
783
  }
774
784
  if (parts.some((part) => transformOriginKeywords.has(part.toLowerCase()))) {
785
+ if (outputType !== undefined) {
786
+ throw new TypeError(`Cannot interpolate "${output}" as ${outputType} because it is a transform-origin value`);
787
+ }
775
788
  return parseTransformOriginValue(output, parts);
776
789
  }
777
790
  const parsed = parts.map((part) => parseStringInterpolationComponent(part, output));
@@ -781,6 +794,9 @@ var parseStringInterpolationValue = (output) => {
781
794
  throw new TypeError(`Cannot interpolate "${output}" because it mixes ${kind} and ${part.kind} values`);
782
795
  }
783
796
  }
797
+ if (outputType !== undefined && outputType !== kind) {
798
+ throw new TypeError(`Cannot interpolate "${output}" as ${outputType} because it is a ${kind} value`);
799
+ }
784
800
  if (kind === "scale") {
785
801
  const x = parsed[0].value;
786
802
  const y = parsed[1]?.value ?? x;
@@ -981,9 +997,10 @@ var interpolateString = ({
981
997
  input,
982
998
  inputRange,
983
999
  outputRange,
984
- options
1000
+ options,
1001
+ outputType
985
1002
  }) => {
986
- const initiallyParsedOutputRange = outputRange.map(parseStringInterpolationValue);
1003
+ const initiallyParsedOutputRange = outputRange.map((output) => parseStringInterpolationValue(output, outputType));
987
1004
  const hasAxisRotation = initiallyParsedOutputRange.some((parsed) => parsed.axisRotation);
988
1005
  const posterizedInput = options?.posterize === undefined ? input : Math.floor(input / options.posterize) * options.posterize;
989
1006
  const segmentIndex = inputRange.length === 1 ? 0 : findRange(posterizedInput, inputRange);
@@ -1063,6 +1080,36 @@ var interpolateString = ({
1063
1080
  axisRotation: hasAxisRotation
1064
1081
  });
1065
1082
  };
1083
+ var interpolateFontWeight = ({
1084
+ input,
1085
+ inputRange,
1086
+ outputRange,
1087
+ options
1088
+ }) => {
1089
+ const normalizedOutputRange = outputRange.map((output) => {
1090
+ if (typeof output === "string") {
1091
+ const lowerCaseOutput = output.toLowerCase();
1092
+ if (lowerCaseOutput === "normal") {
1093
+ return 400;
1094
+ }
1095
+ if (lowerCaseOutput === "bold") {
1096
+ return 700;
1097
+ }
1098
+ }
1099
+ const match = typeof output === "string" ? cssNumberRegex.exec(output) : null;
1100
+ const value = typeof output === "number" ? output : match !== null && match[2] === undefined ? Number(match[1]) : Number.NaN;
1101
+ if (!Number.isFinite(value) || value < 1 || value > 1000) {
1102
+ throw new TypeError(`Cannot interpolate font weight "${output}". Expected "normal", "bold", or a number between 1 and 1000`);
1103
+ }
1104
+ return value;
1105
+ });
1106
+ return interpolateNumber({
1107
+ input,
1108
+ inputRange,
1109
+ outputRange: normalizedOutputRange,
1110
+ options
1111
+ });
1112
+ };
1066
1113
  var interpolateDiscreteString = ({
1067
1114
  input,
1068
1115
  inputRange,
@@ -1194,6 +1241,12 @@ function assertValidInterpolateOutputOption(output) {
1194
1241
  }
1195
1242
  throw new Error(`output must be "linear" or "perceptual-scale", but got ${String(output)}`);
1196
1243
  }
1244
+ function assertValidInterpolateOutputType(outputType) {
1245
+ if (outputType === undefined || outputType === "font-weight" || outputType === "scale" || outputType === "translate" || outputType === "rotate" || outputType === "transform-origin") {
1246
+ return;
1247
+ }
1248
+ throw new Error(`outputType must be "font-weight", "scale", "translate", "rotate", or "transform-origin", but got ${String(outputType)}`);
1249
+ }
1197
1250
  function interpolate(input, inputRange, outputRange, options) {
1198
1251
  if (typeof input === "undefined") {
1199
1252
  throw new Error("input can not be undefined");
@@ -1212,26 +1265,48 @@ function interpolate(input, inputRange, outputRange, options) {
1212
1265
  assertValidInterpolateEasingOption(options?.easing, inputRange.length);
1213
1266
  assertValidInterpolatePosterizeOption(options?.posterize);
1214
1267
  assertValidInterpolateOutputOption(options?.output);
1268
+ assertValidInterpolateOutputType(options?.outputType);
1215
1269
  if (typeof input !== "number") {
1216
1270
  throw new TypeError("Cannot interpolate an input which is not a number");
1217
1271
  }
1218
1272
  if (!Array.isArray(outputRange)) {
1219
1273
  throw new Error("outputRange must contain only numbers");
1220
1274
  }
1275
+ const outputType = options?.outputType;
1276
+ if (outputType === "font-weight") {
1277
+ if (!outputRange.every((output) => typeof output === "number" || typeof output === "string")) {
1278
+ throw new TypeError("Font weight outputRange must contain only numbers or strings");
1279
+ }
1280
+ return interpolateFontWeight({
1281
+ input,
1282
+ inputRange,
1283
+ outputRange,
1284
+ options
1285
+ });
1286
+ }
1221
1287
  const hasStringOutput = outputRange.some((output) => typeof output === "string");
1288
+ if (outputType !== undefined && outputType !== "scale" && !hasStringOutput) {
1289
+ throw new TypeError(`${outputType} outputRange must contain strings with the appropriate CSS units`);
1290
+ }
1222
1291
  if (hasStringOutput) {
1223
1292
  if (!outputRange.every((output) => typeof output === "string" || typeof output === "number")) {
1224
1293
  throw new TypeError("outputRange must contain only numbers, or supported scale, translate, and rotate strings");
1225
1294
  }
1226
1295
  try {
1227
- return interpolateString({ input, inputRange, outputRange, options });
1296
+ return interpolateString({
1297
+ input,
1298
+ inputRange,
1299
+ outputRange,
1300
+ options,
1301
+ outputType
1302
+ });
1228
1303
  } catch (error) {
1229
1304
  if (!outputRange.every((output) => typeof output === "string")) {
1230
1305
  throw error;
1231
1306
  }
1232
1307
  const hasNonNumericString = outputRange.some((output) => {
1233
1308
  try {
1234
- parseStringInterpolationValue(output);
1309
+ parseStringInterpolationValue(output, outputType);
1235
1310
  return false;
1236
1311
  } catch (parseError) {
1237
1312
  return parseError instanceof UnsupportedStringInterpolationValueError;
@@ -1681,10 +1756,20 @@ var freezeField = {
1681
1756
  step: 1,
1682
1757
  hiddenFromList: true
1683
1758
  };
1759
+ var playbackRateField = {
1760
+ type: "number",
1761
+ default: 1,
1762
+ min: 0.01,
1763
+ step: 0.1,
1764
+ description: "Playback rate",
1765
+ hiddenFromList: false,
1766
+ keyframable: false
1767
+ };
1684
1768
  var baseSchema = {
1685
1769
  durationInFrames: durationInFramesField,
1686
1770
  from: fromField,
1687
1771
  trimBefore: trimBeforeField,
1772
+ playbackRate: playbackRateField,
1688
1773
  freeze: freezeField,
1689
1774
  hidden: hiddenField,
1690
1775
  name: sequenceNameField,
@@ -1705,6 +1790,7 @@ var sequenceSchema = {
1705
1790
  var baseSchemaWithoutFrom = {
1706
1791
  durationInFrames: durationInFramesField,
1707
1792
  trimBefore: trimBeforeField,
1793
+ playbackRate: playbackRateField,
1708
1794
  freeze: freezeField,
1709
1795
  hidden: hiddenField,
1710
1796
  name: sequenceNameField,
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.526";
2
+ var VERSION = "4.0.528";
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.526",
6
+ "version": "4.0.528",
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.5.4",
38
- "@remotion/eslint-config-internal": "4.0.526",
38
+ "@remotion/eslint-config-internal": "4.0.528",
39
39
  "eslint": "9.19.0",
40
40
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
41
41
  },
@@ -1,11 +0,0 @@
1
- export type TNonceContext = {
2
- getNonce: () => number;
3
- };
4
- type NonceHistoryItem = [number, number];
5
- export type NonceHistory = NonceHistoryItem[];
6
- export type NonceHistoryContext = {
7
- get: () => NonceHistory;
8
- };
9
- export declare const NonceContext: import("react").Context<TNonceContext>;
10
- export declare const useNonce: () => NonceHistoryContext;
11
- export {};
package/dist/cjs/nonce.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useNonce = exports.NonceContext = void 0;
4
- const react_1 = require("react");
5
- exports.NonceContext = (0, react_1.createContext)({
6
- getNonce: () => 0,
7
- });
8
- let fastRefreshNonce = 0;
9
- try {
10
- if (typeof __webpack_module__ !== 'undefined') {
11
- if (__webpack_module__.hot) {
12
- __webpack_module__.hot.addStatusHandler((status) => {
13
- if (status === 'idle') {
14
- fastRefreshNonce++;
15
- }
16
- });
17
- }
18
- }
19
- }
20
- catch (_a) {
21
- // __webpack_module__ may throw ReferenceError in some environments
22
- }
23
- const useNonce = () => {
24
- const context = (0, react_1.useContext)(exports.NonceContext);
25
- const nonce = context.getNonce();
26
- const nonceRef = (0, react_1.useRef)(nonce);
27
- nonceRef.current = nonce;
28
- const history = (0, react_1.useRef)([[fastRefreshNonce, nonce]]);
29
- const get = (0, react_1.useCallback)(() => {
30
- if (fastRefreshNonce !== history.current[history.current.length - 1][0]) {
31
- history.current = [
32
- ...history.current,
33
- [fastRefreshNonce, nonceRef.current],
34
- ];
35
- }
36
- return history.current;
37
- }, [history]);
38
- return (0, react_1.useMemo)(() => {
39
- return { get };
40
- }, [get]);
41
- };
42
- exports.useNonce = useNonce;