remotion 4.0.84 → 4.0.85

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.
@@ -14,7 +14,7 @@ const timeline_position_state_js_1 = require("./timeline-position-state.js");
14
14
  const duration_state_js_1 = require("./video/duration-state.js");
15
15
  const RemotionRoot = ({ children, numberOfAudioTags }) => {
16
16
  const [remotionRootId] = (0, react_1.useState)(() => String((0, random_js_1.random)(null)));
17
- const [frame, setFrame] = (0, react_1.useState)({});
17
+ const [frame, setFrame] = (0, react_1.useState)(() => (0, timeline_position_state_js_1.getInitialFrameState)());
18
18
  const [playing, setPlaying] = (0, react_1.useState)(false);
19
19
  const imperativePlaying = (0, react_1.useRef)(false);
20
20
  const [fastRefreshes, setFastRefreshes] = (0, react_1.useState)(0);
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ type Block = {
3
+ id: string;
4
+ };
5
+ type OnBufferingCallback = () => void;
6
+ type OnResumeCallback = () => void;
7
+ type ListenForBuffering = (callback: OnBufferingCallback) => {
8
+ remove: () => void;
9
+ };
10
+ type ListenForResume = (callback: OnResumeCallback) => {
11
+ remove: () => void;
12
+ };
13
+ type AddBlock = (block: Block) => {
14
+ unblock: () => void;
15
+ };
16
+ type BufferManager = {
17
+ blocks: Block[];
18
+ addBlock: AddBlock;
19
+ listenForBuffering: ListenForBuffering;
20
+ listenForResume: ListenForResume;
21
+ };
22
+ export declare const BufferingContextReact: React.Context<BufferManager | null>;
23
+ export declare const BufferingProvider: React.FC<{
24
+ children: React.ReactNode;
25
+ }>;
26
+ export {};
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.BufferingProvider = exports.BufferingContextReact = void 0;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const react_1 = __importStar(require("react"));
29
+ const createBufferManager = () => {
30
+ let blocks = [];
31
+ let onBufferingCallback = [];
32
+ let onResumeCallback = [];
33
+ const addBlock = (block) => {
34
+ blocks.push(block);
35
+ onBufferingCallback.forEach((callback) => callback());
36
+ return {
37
+ unblock: () => {
38
+ blocks = blocks.filter((b) => b !== block);
39
+ },
40
+ };
41
+ };
42
+ const listenForBuffering = (callback) => {
43
+ onBufferingCallback.push(callback);
44
+ return {
45
+ remove: () => {
46
+ onBufferingCallback = onBufferingCallback.filter((c) => c !== callback);
47
+ },
48
+ };
49
+ };
50
+ const listenForResume = (callback) => {
51
+ onResumeCallback.push(callback);
52
+ return {
53
+ remove: () => {
54
+ onResumeCallback = onResumeCallback.filter((c) => c !== callback);
55
+ },
56
+ };
57
+ };
58
+ return {
59
+ blocks,
60
+ addBlock,
61
+ listenForBuffering,
62
+ listenForResume,
63
+ };
64
+ };
65
+ exports.BufferingContextReact = react_1.default.createContext(null);
66
+ const BufferingProvider = ({ children }) => {
67
+ const [bufferManager] = (0, react_1.useState)(() => {
68
+ return createBufferManager();
69
+ });
70
+ return ((0, jsx_runtime_1.jsx)(exports.BufferingContextReact.Provider, { value: bufferManager, children: children }));
71
+ };
72
+ exports.BufferingProvider = BufferingProvider;
@@ -84,7 +84,7 @@ export { interpolateColors } from './interpolate-colors.js';
84
84
  export { Loop } from './loop/index.js';
85
85
  export { ClipRegion } from './NativeLayers.js';
86
86
  export { EasingFunction, ExtrapolateType, interpolate, InterpolateOptions, random, RandomSeed, } from './no-react';
87
- export { prefetch } from './prefetch.js';
87
+ export { prefetch, PrefetchOnProgress } from './prefetch.js';
88
88
  export { registerRoot } from './register-root.js';
89
89
  export { LayoutAndStyle, Sequence, SequenceProps, SequencePropsWithoutDuration, } from './Sequence.js';
90
90
  export { Series } from './series/index.js';
@@ -112,7 +112,9 @@ export declare const Internals: {
112
112
  }>>;
113
113
  readonly REMOTION_STUDIO_CONTAINER_ELEMENT: "__remotion-studio-container";
114
114
  readonly RenderAssetManager: import("react").Context<import("./RenderAssetManager.js").RenderAssetManagerContext>;
115
- readonly persistCurrentFrame: (frame: number, composition: string) => void;
115
+ readonly persistCurrentFrame: (time: {
116
+ [x: string]: number;
117
+ }) => void;
116
118
  readonly useTimelineSetFrame: () => (u: import("react").SetStateAction<Record<string, number>>) => void;
117
119
  readonly FILE_TOKEN: "remotion-file:";
118
120
  readonly DATE_TOKEN: "remotion-date:";
@@ -3,6 +3,10 @@ type FetchAndPreload = {
3
3
  free: () => void;
4
4
  waitUntilDone: () => Promise<string>;
5
5
  };
6
+ export type PrefetchOnProgress = (options: {
7
+ totalBytes: number | null;
8
+ loadedBytes: number;
9
+ }) => void;
6
10
  /**
7
11
  * @description When you call the preFetch() function, an asset will be fetched and kept in memory so it is ready when you want to play it in a <Player>.
8
12
  * @see [Documentation](https://www.remotion.dev/docs/prefetch)
@@ -10,5 +14,6 @@ type FetchAndPreload = {
10
14
  export declare const prefetch: (src: string, options?: {
11
15
  method?: 'blob-url' | 'base64';
12
16
  contentType?: string;
17
+ onProgress?: PrefetchOnProgress;
13
18
  }) => FetchAndPreload;
14
19
  export {};
@@ -23,6 +23,31 @@ const blobToBase64 = function (blob) {
23
23
  reader.readAsDataURL(blob);
24
24
  });
25
25
  };
26
+ const getBlobFromReader = async ({ reader, contentType, contentLength, onProgress, }) => {
27
+ let receivedLength = 0;
28
+ const chunks = [];
29
+ // eslint-disable-next-line no-constant-condition
30
+ while (true) {
31
+ const { done, value } = await reader.read();
32
+ if (done) {
33
+ break;
34
+ }
35
+ chunks.push(value);
36
+ receivedLength += value.length;
37
+ if (onProgress) {
38
+ onProgress({ loadedBytes: receivedLength, totalBytes: contentLength });
39
+ }
40
+ }
41
+ const chunksAll = new Uint8Array(receivedLength);
42
+ let position = 0;
43
+ for (const chunk of chunks) {
44
+ chunksAll.set(chunk, position);
45
+ position += chunk.length;
46
+ }
47
+ return new Blob([chunksAll], {
48
+ type: contentType !== null && contentType !== void 0 ? contentType : undefined,
49
+ });
50
+ };
26
51
  /**
27
52
  * @description When you call the preFetch() function, an asset will be fetched and kept in memory so it is ready when you want to play it in a <Player>.
28
53
  * @see [Documentation](https://www.remotion.dev/docs/prefetch)
@@ -50,6 +75,7 @@ const prefetch = (src, options) => {
50
75
  signal: controller.signal,
51
76
  })
52
77
  .then((res) => {
78
+ var _a, _b, _c;
53
79
  canBeAborted = false;
54
80
  if (canceled) {
55
81
  return null;
@@ -57,19 +83,33 @@ const prefetch = (src, options) => {
57
83
  if (!res.ok) {
58
84
  throw new Error(`HTTP error, status = ${res.status}`);
59
85
  }
60
- return res.blob();
86
+ const headerContentType = res.headers.get('Content-Type');
87
+ const contentType = (_a = options === null || options === void 0 ? void 0 : options.contentType) !== null && _a !== void 0 ? _a : headerContentType;
88
+ const hasProperContentType = contentType &&
89
+ (contentType.startsWith('video/') ||
90
+ contentType.startsWith('audio/') ||
91
+ contentType.startsWith('image/'));
92
+ if (!hasProperContentType) {
93
+ // eslint-disable-next-line no-console
94
+ console.warn(`Called prefetch() on ${src} which returned a "Content-Type" of ${headerContentType}. Prefetched content should have a proper content type (video/... or audio/...) or a contentType passed the options of prefetch(). Otherwise, prefetching will not work properly in all browsers.`);
95
+ }
96
+ if (!res.body) {
97
+ throw new Error(`HTTP response of ${src} has no body`);
98
+ }
99
+ const reader = res.body.getReader();
100
+ return getBlobFromReader({
101
+ reader,
102
+ contentType: (_c = (_b = options === null || options === void 0 ? void 0 : options.contentType) !== null && _b !== void 0 ? _b : headerContentType) !== null && _c !== void 0 ? _c : null,
103
+ contentLength: res.headers.get('Content-Length')
104
+ ? parseInt(res.headers.get('Content-Length'), 10)
105
+ : null,
106
+ onProgress: options === null || options === void 0 ? void 0 : options.onProgress,
107
+ });
61
108
  })
62
109
  .then((buf) => {
63
110
  if (!buf) {
64
111
  return;
65
112
  }
66
- if (!buf.type.startsWith('video/') &&
67
- !buf.type.startsWith('audio/') &&
68
- !buf.type.startsWith('image/') &&
69
- !(options === null || options === void 0 ? void 0 : options.contentType)) {
70
- // eslint-disable-next-line no-console
71
- console.warn(`Called prefetch() on ${src} which returned a "Content-Type" of ${buf.type}. Prefetched content should have a proper content type (video/... or audio/...) or a contentType passed the options of prefetch(). Otherwise, prefetching will not work properly in all browsers.`);
72
- }
73
113
  const actualBlob = (options === null || options === void 0 ? void 0 : options.contentType)
74
114
  ? new Blob([buf], { type: options.contentType })
75
115
  : buf;
@@ -18,7 +18,9 @@ export type SetTimelineContextValue = {
18
18
  };
19
19
  export declare const TimelineContext: import("react").Context<TimelineContextValue>;
20
20
  export declare const SetTimelineContext: import("react").Context<SetTimelineContextValue>;
21
- export declare const persistCurrentFrame: (frame: number, composition: string) => void;
21
+ type CurrentTimePerComposition = Record<string, number>;
22
+ export declare const persistCurrentFrame: (time: CurrentTimePerComposition) => void;
23
+ export declare const getInitialFrameState: () => CurrentTimePerComposition;
22
24
  export declare const getFrameForComposition: (composition: string) => number;
23
25
  export declare const useTimelinePosition: () => number;
24
26
  export declare const useTimelineSetFrame: () => (u: React.SetStateAction<Record<string, number>>) => void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usePlayingState = exports.useTimelineSetFrame = exports.useTimelinePosition = exports.getFrameForComposition = exports.persistCurrentFrame = exports.SetTimelineContext = exports.TimelineContext = void 0;
3
+ exports.usePlayingState = exports.useTimelineSetFrame = exports.useTimelinePosition = exports.getFrameForComposition = exports.getInitialFrameState = exports.persistCurrentFrame = exports.SetTimelineContext = exports.TimelineContext = void 0;
4
4
  const react_1 = require("react");
5
5
  const use_video_js_1 = require("./use-video.js");
6
6
  exports.TimelineContext = (0, react_1.createContext)({
@@ -24,19 +24,27 @@ exports.SetTimelineContext = (0, react_1.createContext)({
24
24
  throw new Error('default');
25
25
  },
26
26
  });
27
- const makeKey = (composition) => {
28
- return `remotion.time.${composition}`;
27
+ const makeKey = () => {
28
+ return `remotion.time-all`;
29
29
  };
30
- const persistCurrentFrame = (frame, composition) => {
31
- localStorage.setItem(makeKey(composition), String(frame));
30
+ const persistCurrentFrame = (time) => {
31
+ localStorage.setItem(makeKey(), JSON.stringify(time));
32
32
  };
33
33
  exports.persistCurrentFrame = persistCurrentFrame;
34
+ const getInitialFrameState = () => {
35
+ var _a;
36
+ const item = (_a = localStorage.getItem(makeKey())) !== null && _a !== void 0 ? _a : '{}';
37
+ const obj = JSON.parse(item);
38
+ return obj;
39
+ };
40
+ exports.getInitialFrameState = getInitialFrameState;
34
41
  const getFrameForComposition = (composition) => {
35
- var _a, _b;
36
- const frame = localStorage.getItem(makeKey(composition));
37
- return frame
38
- ? Number(frame)
39
- : (_b = (typeof window === 'undefined' ? 0 : (_a = window.remotion_initialFrame) !== null && _a !== void 0 ? _a : 0)) !== null && _b !== void 0 ? _b : 0;
42
+ var _a, _b, _c;
43
+ const item = (_a = localStorage.getItem(makeKey())) !== null && _a !== void 0 ? _a : '{}';
44
+ const obj = JSON.parse(item);
45
+ return obj[composition]
46
+ ? Number(obj[composition])
47
+ : (_c = (typeof window === 'undefined' ? 0 : (_b = window.remotion_initialFrame) !== null && _b !== void 0 ? _b : 0)) !== null && _c !== void 0 ? _c : 0;
40
48
  };
41
49
  exports.getFrameForComposition = getFrameForComposition;
42
50
  const useTimelinePosition = () => {
@@ -0,0 +1,5 @@
1
+ export declare const useBuffer: () => {
2
+ delayPlayback: () => {
3
+ unblock: () => void;
4
+ };
5
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useBuffer = void 0;
4
+ const react_1 = require("react");
5
+ const buffering_1 = require("./buffering");
6
+ const useBuffer = () => {
7
+ const buffer = (0, react_1.useContext)(buffering_1.BufferingContextReact);
8
+ if (!buffer) {
9
+ throw new TypeError('Can only use useBuffer() inside a Remotion composition');
10
+ }
11
+ return {
12
+ delayPlayback: () => {
13
+ const { unblock } = buffer.addBlock({
14
+ id: String(Math.random()),
15
+ });
16
+ return { unblock };
17
+ },
18
+ };
19
+ };
20
+ exports.useBuffer = useBuffer;
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.84";
1
+ export declare const VERSION = "4.0.85";
@@ -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.84';
5
+ exports.VERSION = '4.0.85';
@@ -18,7 +18,13 @@ const warnAboutNonSeekableMedia = (ref, type) => {
18
18
  }
19
19
  const range = { start: ref.seekable.start(0), end: ref.seekable.end(0) };
20
20
  if (range.start === 0 && range.end === 0) {
21
- const msg = `The media ${ref.src} cannot be seeked. This could be one of two reasons: 1) The media resource was replaced while the video is playing but it was not loaded yet. 2) The media does not support seeking. Please see https://remotion.dev/docs/non-seekable-media for assistance.`;
21
+ const msg = [
22
+ `The media ${ref.src} cannot be seeked. This could be one of few reasons:`,
23
+ '1) The media resource was replaced while the video is playing but it was not loaded yet.',
24
+ '2) The media does not support seeking.',
25
+ '3) The media was loaded with security headers prventing it from being included.',
26
+ 'Please see https://remotion.dev/docs/non-seekable-media for assistance.',
27
+ ].join('\n');
22
28
  if (type === 'console-error') {
23
29
  // eslint-disable-next-line no-console
24
30
  console.error(msg);
@@ -132,7 +132,7 @@ function truthy(value) {
132
132
  }
133
133
 
134
134
  // Automatically generated on publish
135
- const VERSION = '4.0.84';
135
+ const VERSION = '4.0.85';
136
136
 
137
137
  const checkMultipleRemotionVersions = () => {
138
138
  if (typeof globalThis === 'undefined') {
@@ -864,18 +864,25 @@ const SetTimelineContext = createContext({
864
864
  throw new Error('default');
865
865
  },
866
866
  });
867
- const makeKey = (composition) => {
868
- return `remotion.time.${composition}`;
867
+ const makeKey = () => {
868
+ return `remotion.time-all`;
869
869
  };
870
- const persistCurrentFrame = (frame, composition) => {
871
- localStorage.setItem(makeKey(composition), String(frame));
870
+ const persistCurrentFrame = (time) => {
871
+ localStorage.setItem(makeKey(), JSON.stringify(time));
872
+ };
873
+ const getInitialFrameState = () => {
874
+ var _a;
875
+ const item = (_a = localStorage.getItem(makeKey())) !== null && _a !== void 0 ? _a : '{}';
876
+ const obj = JSON.parse(item);
877
+ return obj;
872
878
  };
873
879
  const getFrameForComposition = (composition) => {
874
- var _a, _b;
875
- const frame = localStorage.getItem(makeKey(composition));
876
- return frame
877
- ? Number(frame)
878
- : (_b = (typeof window === 'undefined' ? 0 : (_a = window.remotion_initialFrame) !== null && _a !== void 0 ? _a : 0)) !== null && _b !== void 0 ? _b : 0;
880
+ var _a, _b, _c;
881
+ const item = (_a = localStorage.getItem(makeKey())) !== null && _a !== void 0 ? _a : '{}';
882
+ const obj = JSON.parse(item);
883
+ return obj[composition]
884
+ ? Number(obj[composition])
885
+ : (_c = (typeof window === 'undefined' ? 0 : (_b = window.remotion_initialFrame) !== null && _b !== void 0 ? _b : 0)) !== null && _c !== void 0 ? _c : 0;
879
886
  };
880
887
  const useTimelinePosition = () => {
881
888
  var _a, _b;
@@ -906,6 +913,7 @@ var TimelinePosition = /*#__PURE__*/Object.freeze({
906
913
  TimelineContext: TimelineContext,
907
914
  SetTimelineContext: SetTimelineContext,
908
915
  persistCurrentFrame: persistCurrentFrame,
916
+ getInitialFrameState: getInitialFrameState,
909
917
  getFrameForComposition: getFrameForComposition,
910
918
  useTimelinePosition: useTimelinePosition,
911
919
  useTimelineSetFrame: useTimelineSetFrame,
@@ -1258,6 +1266,31 @@ const blobToBase64 = function (blob) {
1258
1266
  reader.readAsDataURL(blob);
1259
1267
  });
1260
1268
  };
1269
+ const getBlobFromReader = async ({ reader, contentType, contentLength, onProgress, }) => {
1270
+ let receivedLength = 0;
1271
+ const chunks = [];
1272
+ // eslint-disable-next-line no-constant-condition
1273
+ while (true) {
1274
+ const { done, value } = await reader.read();
1275
+ if (done) {
1276
+ break;
1277
+ }
1278
+ chunks.push(value);
1279
+ receivedLength += value.length;
1280
+ if (onProgress) {
1281
+ onProgress({ loadedBytes: receivedLength, totalBytes: contentLength });
1282
+ }
1283
+ }
1284
+ const chunksAll = new Uint8Array(receivedLength);
1285
+ let position = 0;
1286
+ for (const chunk of chunks) {
1287
+ chunksAll.set(chunk, position);
1288
+ position += chunk.length;
1289
+ }
1290
+ return new Blob([chunksAll], {
1291
+ type: contentType !== null && contentType !== void 0 ? contentType : undefined,
1292
+ });
1293
+ };
1261
1294
  /**
1262
1295
  * @description When you call the preFetch() function, an asset will be fetched and kept in memory so it is ready when you want to play it in a <Player>.
1263
1296
  * @see [Documentation](https://www.remotion.dev/docs/prefetch)
@@ -1285,6 +1318,7 @@ const prefetch = (src, options) => {
1285
1318
  signal: controller.signal,
1286
1319
  })
1287
1320
  .then((res) => {
1321
+ var _a, _b, _c;
1288
1322
  canBeAborted = false;
1289
1323
  if (canceled) {
1290
1324
  return null;
@@ -1292,19 +1326,33 @@ const prefetch = (src, options) => {
1292
1326
  if (!res.ok) {
1293
1327
  throw new Error(`HTTP error, status = ${res.status}`);
1294
1328
  }
1295
- return res.blob();
1329
+ const headerContentType = res.headers.get('Content-Type');
1330
+ const contentType = (_a = options === null || options === void 0 ? void 0 : options.contentType) !== null && _a !== void 0 ? _a : headerContentType;
1331
+ const hasProperContentType = contentType &&
1332
+ (contentType.startsWith('video/') ||
1333
+ contentType.startsWith('audio/') ||
1334
+ contentType.startsWith('image/'));
1335
+ if (!hasProperContentType) {
1336
+ // eslint-disable-next-line no-console
1337
+ console.warn(`Called prefetch() on ${src} which returned a "Content-Type" of ${headerContentType}. Prefetched content should have a proper content type (video/... or audio/...) or a contentType passed the options of prefetch(). Otherwise, prefetching will not work properly in all browsers.`);
1338
+ }
1339
+ if (!res.body) {
1340
+ throw new Error(`HTTP response of ${src} has no body`);
1341
+ }
1342
+ const reader = res.body.getReader();
1343
+ return getBlobFromReader({
1344
+ reader,
1345
+ contentType: (_c = (_b = options === null || options === void 0 ? void 0 : options.contentType) !== null && _b !== void 0 ? _b : headerContentType) !== null && _c !== void 0 ? _c : null,
1346
+ contentLength: res.headers.get('Content-Length')
1347
+ ? parseInt(res.headers.get('Content-Length'), 10)
1348
+ : null,
1349
+ onProgress: options === null || options === void 0 ? void 0 : options.onProgress,
1350
+ });
1296
1351
  })
1297
1352
  .then((buf) => {
1298
1353
  if (!buf) {
1299
1354
  return;
1300
1355
  }
1301
- if (!buf.type.startsWith('video/') &&
1302
- !buf.type.startsWith('audio/') &&
1303
- !buf.type.startsWith('image/') &&
1304
- !(options === null || options === void 0 ? void 0 : options.contentType)) {
1305
- // eslint-disable-next-line no-console
1306
- console.warn(`Called prefetch() on ${src} which returned a "Content-Type" of ${buf.type}. Prefetched content should have a proper content type (video/... or audio/...) or a contentType passed the options of prefetch(). Otherwise, prefetching will not work properly in all browsers.`);
1307
- }
1308
1356
  const actualBlob = (options === null || options === void 0 ? void 0 : options.contentType)
1309
1357
  ? new Blob([buf], { type: options.contentType })
1310
1358
  : buf;
@@ -1892,7 +1940,13 @@ const warnAboutNonSeekableMedia = (ref, type) => {
1892
1940
  }
1893
1941
  const range = { start: ref.seekable.start(0), end: ref.seekable.end(0) };
1894
1942
  if (range.start === 0 && range.end === 0) {
1895
- const msg = `The media ${ref.src} cannot be seeked. This could be one of two reasons: 1) The media resource was replaced while the video is playing but it was not loaded yet. 2) The media does not support seeking. Please see https://remotion.dev/docs/non-seekable-media for assistance.`;
1943
+ const msg = [
1944
+ `The media ${ref.src} cannot be seeked. This could be one of few reasons:`,
1945
+ '1) The media resource was replaced while the video is playing but it was not loaded yet.',
1946
+ '2) The media does not support seeking.',
1947
+ '3) The media was loaded with security headers prventing it from being included.',
1948
+ 'Please see https://remotion.dev/docs/non-seekable-media for assistance.',
1949
+ ].join('\n');
1896
1950
  if (type === 'console-error') {
1897
1951
  // eslint-disable-next-line no-console
1898
1952
  console.error(msg);
@@ -3472,7 +3526,7 @@ const waitForRoot = (fn) => {
3472
3526
 
3473
3527
  const RemotionRoot = ({ children, numberOfAudioTags }) => {
3474
3528
  const [remotionRootId] = useState(() => String(random(null)));
3475
- const [frame, setFrame] = useState({});
3529
+ const [frame, setFrame] = useState(() => getInitialFrameState());
3476
3530
  const [playing, setPlaying] = useState(false);
3477
3531
  const imperativePlaying = useRef(false);
3478
3532
  const [fastRefreshes, setFastRefreshes] = useState(0);
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.84';
2
+ const VERSION = '4.0.85';
3
3
 
4
4
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.84",
3
+ "version": "4.0.85",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- export declare class CatchError extends React.Component {
3
- state: {
4
- hasError: boolean;
5
- };
6
- constructor(props: {
7
- children: React.ReactNode;
8
- });
9
- static getDerivedStateFromError(error: Error): {
10
- hasError: boolean;
11
- };
12
- componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
13
- render(): React.ReactNode;
14
- }
15
- export declare const StackTraceFetcher: () => JSX.Element;
@@ -1,68 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.StackTraceFetcher = exports.CatchError = void 0;
27
- const jsx_runtime_1 = require("react/jsx-runtime");
28
- const react_1 = __importStar(require("react"));
29
- const ErrorThrower = () => {
30
- const [trigger, setTrigger] = react_1.default.useState(false);
31
- (0, react_1.useEffect)(() => {
32
- setTrigger(true);
33
- }, []);
34
- if (trigger) {
35
- // throw new Error('lol');
36
- }
37
- return null;
38
- };
39
- class CatchError extends react_1.default.Component {
40
- // eslint-disable-next-line no-useless-constructor
41
- constructor(props) {
42
- super(props);
43
- this.state = { hasError: false };
44
- }
45
- static getDerivedStateFromError(error) {
46
- console.log('DERIVED STATE');
47
- console.error(error);
48
- return { hasError: true };
49
- }
50
- componentDidCatch(error, errorInfo) {
51
- console.log('DID CATCH');
52
- console.error(error, errorInfo);
53
- }
54
- render() {
55
- console.log('state', this);
56
- if (this.state.hasError) {
57
- console.log('null');
58
- return null;
59
- }
60
- // @ts-expect-error
61
- return this.props.children;
62
- }
63
- }
64
- exports.CatchError = CatchError;
65
- const StackTraceFetcher = () => {
66
- return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(CatchError, { children: (0, jsx_runtime_1.jsx)(ErrorThrower, {}) }) }));
67
- };
68
- exports.StackTraceFetcher = StackTraceFetcher;
@@ -1 +0,0 @@
1
- export declare const getTimelineClipName: (children: React.ReactNode) => string;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTimelineClipName = void 0;
4
- const react_1 = require("react");
5
- const HIDDEN_NAMES = ['__WEBPACK_DEFAULT_EXPORT__'];
6
- const getTimelineClipName = (children) => {
7
- var _a;
8
- const tree = (_a = react_1.Children.map(children, (ch) => {
9
- if (!(0, react_1.isValidElement)(ch)) {
10
- return null;
11
- }
12
- // Must be name, not ID
13
- const name = typeof ch.type !== 'string' && ch.type.name;
14
- if (name && !HIDDEN_NAMES.includes(name)) {
15
- return name;
16
- }
17
- if (ch.props.children) {
18
- const chName = (0, exports.getTimelineClipName)(ch.props.children);
19
- return chName;
20
- }
21
- return null;
22
- })) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
23
- return (tree === null || tree === void 0 ? void 0 : tree.length) ? tree[0] : '';
24
- };
25
- exports.getTimelineClipName = getTimelineClipName;
@@ -1,8 +0,0 @@
1
- export declare const seekToTime: (element: HTMLVideoElement, desiredTime: number) => {
2
- wait: Promise<number>;
3
- cancel: () => void;
4
- };
5
- export declare const seekToTimeMultipleUntilRight: (element: HTMLVideoElement, desiredTime: number, fps: number) => {
6
- prom: Promise<void>;
7
- cancel: () => void;
8
- };
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.seekToTimeMultipleUntilRight = exports.seekToTime = void 0;
4
- const seekToTime = (element, desiredTime) => {
5
- element.currentTime = desiredTime;
6
- let cancel;
7
- const prom = new Promise((resolve) => {
8
- cancel = element.requestVideoFrameCallback((_cb, metadata) => {
9
- resolve(metadata.mediaTime);
10
- });
11
- });
12
- return {
13
- wait: prom,
14
- cancel: () => {
15
- element.cancelVideoFrameCallback(cancel);
16
- },
17
- };
18
- };
19
- exports.seekToTime = seekToTime;
20
- const seekToTimeMultipleUntilRight = (element, desiredTime, fps) => {
21
- const threshold = 1 / fps / 2;
22
- let currentCancel = () => undefined;
23
- const prom = new Promise((resolve, reject) => {
24
- const firstSeek = (0, exports.seekToTime)(element, desiredTime + threshold);
25
- firstSeek.wait.then((seekedTo) => {
26
- const difference = Math.abs(desiredTime - seekedTo);
27
- const ident = Math.random();
28
- if (difference < threshold) {
29
- return resolve();
30
- }
31
- const sign = desiredTime > seekedTo ? 1 : -1;
32
- const newSeek = (0, exports.seekToTime)(element, seekedTo + threshold * sign);
33
- currentCancel = newSeek.cancel;
34
- newSeek.wait
35
- .then((newTime) => {
36
- const newDifference = Math.abs(desiredTime - newTime);
37
- console.log(ident, 'before', seekedTo, 'after', newTime, 'desired', desiredTime);
38
- if (newDifference < threshold) {
39
- return resolve();
40
- }
41
- const thirdSeek = (0, exports.seekToTime)(element, desiredTime);
42
- currentCancel = thirdSeek.cancel;
43
- thirdSeek.wait.then(() => {
44
- resolve();
45
- });
46
- })
47
- .catch((err) => {
48
- reject(err);
49
- });
50
- });
51
- currentCancel = firstSeek.cancel;
52
- });
53
- return {
54
- prom,
55
- cancel: () => {
56
- currentCancel();
57
- },
58
- };
59
- };
60
- exports.seekToTimeMultipleUntilRight = seekToTimeMultipleUntilRight;