remotion 4.0.66 → 4.0.68

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.
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAbsoluteSrc = void 0;
4
4
  const getAbsoluteSrc = (relativeSrc) => {
5
+ if (typeof window === 'undefined') {
6
+ return relativeSrc;
7
+ }
5
8
  return new URL(relativeSrc, window.location.origin).href;
6
9
  };
7
10
  exports.getAbsoluteSrc = getAbsoluteSrc;
@@ -9,6 +9,7 @@ const calculate_loop_js_1 = require("../calculate-loop.js");
9
9
  const cancel_render_js_1 = require("../cancel-render.js");
10
10
  const get_remotion_environment_js_1 = require("../get-remotion-environment.js");
11
11
  const index_js_1 = require("../loop/index.js");
12
+ const prefetch_js_1 = require("../prefetch.js");
12
13
  const Sequence_js_1 = require("../Sequence.js");
13
14
  const use_video_config_js_1 = require("../use-video-config.js");
14
15
  const validate_media_props_js_1 = require("../validate-media-props.js");
@@ -28,23 +29,24 @@ const AudioRefForwardingFunction = (props, ref) => {
28
29
  if (typeof props.src !== 'string') {
29
30
  throw new TypeError(`The \`<Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
30
31
  }
32
+ const preloadedSrc = (0, prefetch_js_1.usePreload)(props.src);
31
33
  const onError = (0, react_1.useCallback)((e) => {
32
34
  console.log(e.currentTarget.error);
33
35
  // If there is no `loop` property, we don't need to get the duration
34
36
  // and this does not need to be a fatal error
35
- const errMessage = `Could not play audio with src ${otherProps.src}: ${e.currentTarget.error}. See https://remotion.dev/docs/media-playback-error for help.`;
37
+ const errMessage = `Could not play audio with src ${preloadedSrc}: ${e.currentTarget.error}. See https://remotion.dev/docs/media-playback-error for help.`;
36
38
  if (loop) {
37
39
  (0, cancel_render_js_1.cancelRender)(new Error(errMessage));
38
40
  }
39
41
  else {
40
42
  console.warn(errMessage);
41
43
  }
42
- }, [loop, otherProps.src]);
44
+ }, [loop, preloadedSrc]);
43
45
  const onDuration = (0, react_1.useCallback)((src, durationInSeconds) => {
44
46
  setDurations({ type: 'got-duration', durationInSeconds, src });
45
47
  }, [setDurations]);
46
- if (loop && props.src && durations[(0, absolute_src_js_1.getAbsoluteSrc)(props.src)] !== undefined) {
47
- const duration = Math.floor(durations[(0, absolute_src_js_1.getAbsoluteSrc)(props.src)] * fps);
48
+ if (loop && durations[(0, absolute_src_js_1.getAbsoluteSrc)(preloadedSrc)] !== undefined) {
49
+ const duration = Math.floor(durations[(0, absolute_src_js_1.getAbsoluteSrc)(preloadedSrc)] * fps);
48
50
  return ((0, jsx_runtime_1.jsx)(index_js_1.Loop, { layout: "none", durationInFrames: (0, calculate_loop_js_1.calculateLoopDuration)({
49
51
  endAt,
50
52
  mediaDuration: duration,
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.66";
1
+ export declare const VERSION = "4.0.68";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Automatically generated on publish
5
- exports.VERSION = '4.0.66';
5
+ exports.VERSION = '4.0.68';
@@ -8,6 +8,7 @@ const absolute_src_js_1 = require("../absolute-src.js");
8
8
  const calculate_loop_js_1 = require("../calculate-loop.js");
9
9
  const get_remotion_environment_js_1 = require("../get-remotion-environment.js");
10
10
  const index_js_1 = require("../loop/index.js");
11
+ const prefetch_js_1 = require("../prefetch.js");
11
12
  const Sequence_js_1 = require("../Sequence.js");
12
13
  const use_video_config_js_1 = require("../use-video-config.js");
13
14
  const validate_media_props_js_1 = require("../validate-media-props.js");
@@ -28,11 +29,12 @@ const VideoForwardingFunction = (props, ref) => {
28
29
  if (typeof props.src !== 'string') {
29
30
  throw new TypeError(`The \`<Video>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
30
31
  }
32
+ const preloadedSrc = (0, prefetch_js_1.usePreload)(props.src);
31
33
  const onDuration = (0, react_1.useCallback)((src, durationInSeconds) => {
32
34
  setDurations({ type: 'got-duration', durationInSeconds, src });
33
35
  }, [setDurations]);
34
- if (loop && props.src && durations[(0, absolute_src_js_1.getAbsoluteSrc)(props.src)] !== undefined) {
35
- const mediaDuration = durations[(0, absolute_src_js_1.getAbsoluteSrc)(props.src)] * fps;
36
+ if (loop && durations[(0, absolute_src_js_1.getAbsoluteSrc)(preloadedSrc)] !== undefined) {
37
+ const mediaDuration = durations[(0, absolute_src_js_1.getAbsoluteSrc)(preloadedSrc)] * fps;
36
38
  return ((0, jsx_runtime_1.jsx)(index_js_1.Loop, { durationInFrames: (0, calculate_loop_js_1.calculateLoopDuration)({
37
39
  endAt,
38
40
  mediaDuration,
@@ -59,7 +59,7 @@ function truthy(value) {
59
59
  }
60
60
 
61
61
  // Automatically generated on publish
62
- const VERSION = '4.0.66';
62
+ const VERSION = '4.0.68';
63
63
 
64
64
  const checkMultipleRemotionVersions = () => {
65
65
  if (typeof globalThis === 'undefined') {
@@ -133,6 +133,9 @@ const AbsoluteFillRefForwarding = (props, ref) => {
133
133
  const AbsoluteFill = forwardRef(AbsoluteFillRefForwarding);
134
134
 
135
135
  const getAbsoluteSrc = (relativeSrc) => {
136
+ if (typeof window === 'undefined') {
137
+ return relativeSrc;
138
+ }
136
139
  return new URL(relativeSrc, window.location.origin).href;
137
140
  };
138
141
 
@@ -1203,83 +1206,6 @@ const Loop = ({ durationInFrames, times = Infinity, children, name, ...props })
1203
1206
  return (jsx(Sequence, { durationInFrames: durationInFrames, from: from, name: name, loopDisplay: loopDisplay, layout: props.layout, style: style, children: children }));
1204
1207
  };
1205
1208
 
1206
- const validateMediaProps = (props, component) => {
1207
- if (typeof props.volume !== 'number' &&
1208
- typeof props.volume !== 'function' &&
1209
- typeof props.volume !== 'undefined') {
1210
- throw new TypeError(`You have passed a volume of type ${typeof props.volume} to your <${component} /> component. Volume must be a number or a function with the signature '(frame: number) => number' undefined.`);
1211
- }
1212
- if (typeof props.volume === 'number' && props.volume < 0) {
1213
- throw new TypeError(`You have passed a volume below 0 to your <${component} /> component. Volume must be between 0 and 1`);
1214
- }
1215
- if (typeof props.playbackRate !== 'number' &&
1216
- typeof props.playbackRate !== 'undefined') {
1217
- throw new TypeError(`You have passed a playbackRate of type ${typeof props.playbackRate} to your <${component} /> component. Playback rate must a real number or undefined.`);
1218
- }
1219
- if (typeof props.playbackRate === 'number' &&
1220
- (isNaN(props.playbackRate) ||
1221
- !Number.isFinite(props.playbackRate) ||
1222
- props.playbackRate <= 0)) {
1223
- throw new TypeError(`You have passed a playbackRate of ${props.playbackRate} to your <${component} /> component. Playback rate must be a real number above 0.`);
1224
- }
1225
- };
1226
-
1227
- const validateStartFromProps = (startFrom, endAt) => {
1228
- if (typeof startFrom !== 'undefined') {
1229
- if (typeof startFrom !== 'number') {
1230
- throw new TypeError(`type of startFrom prop must be a number, instead got type ${typeof startFrom}.`);
1231
- }
1232
- if (isNaN(startFrom) || startFrom === Infinity) {
1233
- throw new TypeError('startFrom prop can not be NaN or Infinity.');
1234
- }
1235
- if (startFrom < 0) {
1236
- throw new TypeError(`startFrom must be greater than equal to 0 instead got ${startFrom}.`);
1237
- }
1238
- }
1239
- if (typeof endAt !== 'undefined') {
1240
- if (typeof endAt !== 'number') {
1241
- throw new TypeError(`type of endAt prop must be a number, instead got type ${typeof endAt}.`);
1242
- }
1243
- if (isNaN(endAt)) {
1244
- throw new TypeError('endAt prop can not be NaN.');
1245
- }
1246
- if (endAt <= 0) {
1247
- throw new TypeError(`endAt must be a positive number, instead got ${endAt}.`);
1248
- }
1249
- }
1250
- if (endAt < startFrom) {
1251
- throw new TypeError('endAt prop must be greater than startFrom prop.');
1252
- }
1253
- };
1254
-
1255
- const durationReducer = (state, action) => {
1256
- switch (action.type) {
1257
- case 'got-duration':
1258
- return {
1259
- ...state,
1260
- [getAbsoluteSrc(action.src)]: action.durationInSeconds,
1261
- };
1262
- default:
1263
- return state;
1264
- }
1265
- };
1266
- const DurationsContext = createContext({
1267
- durations: {},
1268
- setDurations: () => {
1269
- throw new Error('context missing');
1270
- },
1271
- });
1272
- const DurationsContextProvider = ({ children }) => {
1273
- const [durations, setDurations] = useReducer(durationReducer, {});
1274
- const value = useMemo(() => {
1275
- return {
1276
- durations,
1277
- setDurations,
1278
- };
1279
- }, [durations]);
1280
- return (jsx(DurationsContext.Provider, { value: value, children: children }));
1281
- };
1282
-
1283
1209
  const PreloadContext = createContext({});
1284
1210
  let preloads = {};
1285
1211
  let updaters = [];
@@ -1414,6 +1340,83 @@ const prefetch = (src, options) => {
1414
1340
  };
1415
1341
  };
1416
1342
 
1343
+ const validateMediaProps = (props, component) => {
1344
+ if (typeof props.volume !== 'number' &&
1345
+ typeof props.volume !== 'function' &&
1346
+ typeof props.volume !== 'undefined') {
1347
+ throw new TypeError(`You have passed a volume of type ${typeof props.volume} to your <${component} /> component. Volume must be a number or a function with the signature '(frame: number) => number' undefined.`);
1348
+ }
1349
+ if (typeof props.volume === 'number' && props.volume < 0) {
1350
+ throw new TypeError(`You have passed a volume below 0 to your <${component} /> component. Volume must be between 0 and 1`);
1351
+ }
1352
+ if (typeof props.playbackRate !== 'number' &&
1353
+ typeof props.playbackRate !== 'undefined') {
1354
+ throw new TypeError(`You have passed a playbackRate of type ${typeof props.playbackRate} to your <${component} /> component. Playback rate must a real number or undefined.`);
1355
+ }
1356
+ if (typeof props.playbackRate === 'number' &&
1357
+ (isNaN(props.playbackRate) ||
1358
+ !Number.isFinite(props.playbackRate) ||
1359
+ props.playbackRate <= 0)) {
1360
+ throw new TypeError(`You have passed a playbackRate of ${props.playbackRate} to your <${component} /> component. Playback rate must be a real number above 0.`);
1361
+ }
1362
+ };
1363
+
1364
+ const validateStartFromProps = (startFrom, endAt) => {
1365
+ if (typeof startFrom !== 'undefined') {
1366
+ if (typeof startFrom !== 'number') {
1367
+ throw new TypeError(`type of startFrom prop must be a number, instead got type ${typeof startFrom}.`);
1368
+ }
1369
+ if (isNaN(startFrom) || startFrom === Infinity) {
1370
+ throw new TypeError('startFrom prop can not be NaN or Infinity.');
1371
+ }
1372
+ if (startFrom < 0) {
1373
+ throw new TypeError(`startFrom must be greater than equal to 0 instead got ${startFrom}.`);
1374
+ }
1375
+ }
1376
+ if (typeof endAt !== 'undefined') {
1377
+ if (typeof endAt !== 'number') {
1378
+ throw new TypeError(`type of endAt prop must be a number, instead got type ${typeof endAt}.`);
1379
+ }
1380
+ if (isNaN(endAt)) {
1381
+ throw new TypeError('endAt prop can not be NaN.');
1382
+ }
1383
+ if (endAt <= 0) {
1384
+ throw new TypeError(`endAt must be a positive number, instead got ${endAt}.`);
1385
+ }
1386
+ }
1387
+ if (endAt < startFrom) {
1388
+ throw new TypeError('endAt prop must be greater than startFrom prop.');
1389
+ }
1390
+ };
1391
+
1392
+ const durationReducer = (state, action) => {
1393
+ switch (action.type) {
1394
+ case 'got-duration':
1395
+ return {
1396
+ ...state,
1397
+ [getAbsoluteSrc(action.src)]: action.durationInSeconds,
1398
+ };
1399
+ default:
1400
+ return state;
1401
+ }
1402
+ };
1403
+ const DurationsContext = createContext({
1404
+ durations: {},
1405
+ setDurations: () => {
1406
+ throw new Error('context missing');
1407
+ },
1408
+ });
1409
+ const DurationsContextProvider = ({ children }) => {
1410
+ const [durations, setDurations] = useReducer(durationReducer, {});
1411
+ const value = useMemo(() => {
1412
+ return {
1413
+ durations,
1414
+ setDurations,
1415
+ };
1416
+ }, [durations]);
1417
+ return (jsx(DurationsContext.Provider, { value: value, children: children }));
1418
+ };
1419
+
1417
1420
  /* eslint-disable no-bitwise */
1418
1421
  function mulberry32(a) {
1419
1422
  let t = a + 0x6d2b79f5;
@@ -2593,23 +2596,24 @@ const AudioRefForwardingFunction = (props, ref) => {
2593
2596
  if (typeof props.src !== 'string') {
2594
2597
  throw new TypeError(`The \`<Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
2595
2598
  }
2599
+ const preloadedSrc = usePreload(props.src);
2596
2600
  const onError = useCallback((e) => {
2597
2601
  console.log(e.currentTarget.error);
2598
2602
  // If there is no `loop` property, we don't need to get the duration
2599
2603
  // and this does not need to be a fatal error
2600
- const errMessage = `Could not play audio with src ${otherProps.src}: ${e.currentTarget.error}. See https://remotion.dev/docs/media-playback-error for help.`;
2604
+ const errMessage = `Could not play audio with src ${preloadedSrc}: ${e.currentTarget.error}. See https://remotion.dev/docs/media-playback-error for help.`;
2601
2605
  if (loop) {
2602
2606
  cancelRender(new Error(errMessage));
2603
2607
  }
2604
2608
  else {
2605
2609
  console.warn(errMessage);
2606
2610
  }
2607
- }, [loop, otherProps.src]);
2611
+ }, [loop, preloadedSrc]);
2608
2612
  const onDuration = useCallback((src, durationInSeconds) => {
2609
2613
  setDurations({ type: 'got-duration', durationInSeconds, src });
2610
2614
  }, [setDurations]);
2611
- if (loop && props.src && durations[getAbsoluteSrc(props.src)] !== undefined) {
2612
- const duration = Math.floor(durations[getAbsoluteSrc(props.src)] * fps);
2615
+ if (loop && durations[getAbsoluteSrc(preloadedSrc)] !== undefined) {
2616
+ const duration = Math.floor(durations[getAbsoluteSrc(preloadedSrc)] * fps);
2613
2617
  return (jsx(Loop, { layout: "none", durationInFrames: calculateLoopDuration({
2614
2618
  endAt,
2615
2619
  mediaDuration: duration,
@@ -4858,11 +4862,12 @@ const VideoForwardingFunction = (props, ref) => {
4858
4862
  if (typeof props.src !== 'string') {
4859
4863
  throw new TypeError(`The \`<Video>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
4860
4864
  }
4865
+ const preloadedSrc = usePreload(props.src);
4861
4866
  const onDuration = useCallback((src, durationInSeconds) => {
4862
4867
  setDurations({ type: 'got-duration', durationInSeconds, src });
4863
4868
  }, [setDurations]);
4864
- if (loop && props.src && durations[getAbsoluteSrc(props.src)] !== undefined) {
4865
- const mediaDuration = durations[getAbsoluteSrc(props.src)] * fps;
4869
+ if (loop && durations[getAbsoluteSrc(preloadedSrc)] !== undefined) {
4870
+ const mediaDuration = durations[getAbsoluteSrc(preloadedSrc)] * fps;
4866
4871
  return (jsx(Loop, { durationInFrames: calculateLoopDuration({
4867
4872
  endAt,
4868
4873
  mediaDuration,
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.66';
2
+ const VERSION = '4.0.68';
3
3
 
4
4
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.66",
3
+ "version": "4.0.68",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",