remotion 4.0.0-prefetch.7 → 4.0.0-prefetchapi.16

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 (179) hide show
  1. package/.turbo/turbo-build.log +5 -5
  2. package/dist/AbsoluteFill.d.ts +0 -0
  3. package/dist/AbsoluteFill.js +0 -0
  4. package/dist/CanUseRemotionHooks.d.ts +0 -0
  5. package/dist/CanUseRemotionHooks.js +0 -0
  6. package/dist/Composition.d.ts +0 -0
  7. package/dist/Composition.js +0 -0
  8. package/dist/CompositionManager.d.ts +0 -0
  9. package/dist/CompositionManager.js +0 -0
  10. package/dist/Folder.d.ts +0 -0
  11. package/dist/Folder.js +0 -0
  12. package/dist/IFrame.d.ts +0 -0
  13. package/dist/IFrame.js +0 -0
  14. package/dist/Img.d.ts +0 -0
  15. package/dist/Img.js +2 -2
  16. package/dist/RemotionRoot.d.ts +0 -0
  17. package/dist/RemotionRoot.js +5 -4
  18. package/dist/Sequence.d.ts +0 -0
  19. package/dist/Sequence.js +0 -0
  20. package/dist/Still.d.ts +0 -0
  21. package/dist/Still.js +0 -0
  22. package/dist/absolute-src.d.ts +0 -0
  23. package/dist/absolute-src.js +0 -0
  24. package/dist/asset-types.d.ts +0 -0
  25. package/dist/asset-types.js +0 -0
  26. package/dist/audio/Audio.d.ts +0 -0
  27. package/dist/audio/Audio.js +0 -0
  28. package/dist/audio/AudioForDevelopment.d.ts +0 -0
  29. package/dist/audio/AudioForDevelopment.js +2 -2
  30. package/dist/audio/AudioForRendering.d.ts +0 -0
  31. package/dist/audio/AudioForRendering.js +0 -0
  32. package/dist/audio/index.d.ts +0 -0
  33. package/dist/audio/index.js +0 -0
  34. package/dist/audio/props.d.ts +0 -0
  35. package/dist/audio/props.js +0 -0
  36. package/dist/audio/shared-audio-tags.d.ts +0 -0
  37. package/dist/audio/shared-audio-tags.js +0 -0
  38. package/dist/audio/use-audio-frame.d.ts +0 -0
  39. package/dist/audio/use-audio-frame.js +0 -0
  40. package/dist/bezier.d.ts +0 -0
  41. package/dist/bezier.js +0 -0
  42. package/dist/config/input-props.d.ts +0 -0
  43. package/dist/config/input-props.js +0 -0
  44. package/dist/config.d.ts +0 -0
  45. package/dist/config.js +0 -0
  46. package/dist/default-css.d.ts +0 -0
  47. package/dist/default-css.js +0 -0
  48. package/dist/delay-render.d.ts +0 -0
  49. package/dist/delay-render.js +0 -0
  50. package/dist/easing.d.ts +0 -0
  51. package/dist/easing.js +0 -0
  52. package/dist/freeze.d.ts +0 -0
  53. package/dist/freeze.js +0 -0
  54. package/dist/get-asset-file-name.d.ts +0 -0
  55. package/dist/get-asset-file-name.js +0 -0
  56. package/dist/get-environment.d.ts +0 -0
  57. package/dist/get-environment.js +2 -2
  58. package/dist/get-preview-dom-element.d.ts +0 -0
  59. package/dist/get-preview-dom-element.js +0 -0
  60. package/dist/get-timeline-clip-name.d.ts +0 -0
  61. package/dist/get-timeline-clip-name.js +0 -0
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.js +3 -3
  64. package/dist/internals.d.ts +3 -0
  65. package/dist/internals.js +2 -0
  66. package/dist/interpolate-colors.d.ts +0 -0
  67. package/dist/interpolate-colors.js +0 -0
  68. package/dist/interpolate.d.ts +0 -0
  69. package/dist/interpolate.js +0 -0
  70. package/dist/is-approximately-the-same.d.ts +0 -0
  71. package/dist/is-approximately-the-same.js +0 -0
  72. package/dist/loading-indicator.d.ts +0 -0
  73. package/dist/loading-indicator.js +0 -0
  74. package/dist/loop/index.d.ts +0 -0
  75. package/dist/loop/index.js +0 -0
  76. package/dist/multiple-versions-warning.d.ts +0 -0
  77. package/dist/multiple-versions-warning.js +0 -0
  78. package/dist/nonce.d.ts +0 -0
  79. package/dist/nonce.js +0 -0
  80. package/dist/play-and-handle-not-allowed-error.d.ts +0 -0
  81. package/dist/play-and-handle-not-allowed-error.js +0 -0
  82. package/dist/portal-node.d.ts +0 -0
  83. package/dist/portal-node.js +0 -0
  84. package/dist/prefetch.d.ts +7 -0
  85. package/dist/prefetch.js +86 -0
  86. package/dist/preload-state.d.ts +13 -0
  87. package/dist/preload-state.js +26 -0
  88. package/dist/preload.js +16 -13
  89. package/dist/random.d.ts +0 -0
  90. package/dist/random.js +0 -0
  91. package/dist/register-root.d.ts +0 -0
  92. package/dist/register-root.js +0 -0
  93. package/dist/series/flatten-children.d.ts +0 -0
  94. package/dist/series/flatten-children.js +0 -0
  95. package/dist/series/index.d.ts +0 -0
  96. package/dist/series/index.js +0 -0
  97. package/dist/setup-env-variables.d.ts +0 -0
  98. package/dist/setup-env-variables.js +0 -0
  99. package/dist/spring/index.d.ts +0 -0
  100. package/dist/spring/index.js +0 -0
  101. package/dist/spring/measure-spring.d.ts +0 -0
  102. package/dist/spring/measure-spring.js +0 -0
  103. package/dist/spring/spring-utils.d.ts +0 -0
  104. package/dist/spring/spring-utils.js +0 -0
  105. package/dist/static-file.d.ts +0 -0
  106. package/dist/static-file.js +0 -0
  107. package/dist/timeline-position-state.d.ts +0 -0
  108. package/dist/timeline-position-state.js +0 -0
  109. package/dist/truthy.d.ts +0 -0
  110. package/dist/truthy.js +0 -0
  111. package/dist/use-current-frame.d.ts +0 -0
  112. package/dist/use-current-frame.js +0 -0
  113. package/dist/use-lazy-component.d.ts +0 -0
  114. package/dist/use-lazy-component.js +0 -0
  115. package/dist/use-media-in-timeline.d.ts +0 -0
  116. package/dist/use-media-in-timeline.js +0 -0
  117. package/dist/use-media-playback.d.ts +0 -0
  118. package/dist/use-media-playback.js +0 -0
  119. package/dist/use-media-tag-volume.d.ts +0 -0
  120. package/dist/use-media-tag-volume.js +0 -0
  121. package/dist/use-sync-volume-with-media-tag.d.ts +0 -0
  122. package/dist/use-sync-volume-with-media-tag.js +0 -0
  123. package/dist/use-unsafe-video-config.d.ts +0 -0
  124. package/dist/use-unsafe-video-config.js +0 -0
  125. package/dist/use-video-config.d.ts +0 -0
  126. package/dist/use-video-config.js +0 -0
  127. package/dist/use-video.d.ts +0 -0
  128. package/dist/use-video.js +0 -0
  129. package/dist/validate-media-props.d.ts +0 -0
  130. package/dist/validate-media-props.js +0 -0
  131. package/dist/validate-start-from-props.d.ts +0 -0
  132. package/dist/validate-start-from-props.js +0 -0
  133. package/dist/validation/validate-composition-id.d.ts +0 -0
  134. package/dist/validation/validate-composition-id.js +0 -0
  135. package/dist/validation/validate-dimensions.d.ts +0 -0
  136. package/dist/validation/validate-dimensions.js +0 -0
  137. package/dist/validation/validate-duration-in-frames.d.ts +0 -0
  138. package/dist/validation/validate-duration-in-frames.js +0 -0
  139. package/dist/validation/validate-folder-name.d.ts +0 -0
  140. package/dist/validation/validate-folder-name.js +0 -0
  141. package/dist/validation/validate-fps.d.ts +0 -0
  142. package/dist/validation/validate-fps.js +0 -0
  143. package/dist/validation/validate-offthreadvideo-image-format.d.ts +0 -0
  144. package/dist/validation/validate-offthreadvideo-image-format.js +0 -0
  145. package/dist/validation/validation-spring-duration.d.ts +0 -0
  146. package/dist/validation/validation-spring-duration.js +0 -0
  147. package/dist/version.d.ts +1 -1
  148. package/dist/version.js +1 -1
  149. package/dist/video/OffthreadVideo.d.ts +0 -0
  150. package/dist/video/OffthreadVideo.js +0 -0
  151. package/dist/video/OffthreadVideoForRendering.d.ts +0 -0
  152. package/dist/video/OffthreadVideoForRendering.js +0 -0
  153. package/dist/video/Video.d.ts +0 -0
  154. package/dist/video/Video.js +0 -0
  155. package/dist/video/VideoForDevelopment.d.ts +0 -0
  156. package/dist/video/VideoForDevelopment.js +2 -2
  157. package/dist/video/VideoForRendering.d.ts +0 -0
  158. package/dist/video/VideoForRendering.js +0 -0
  159. package/dist/video/get-current-time.d.ts +0 -0
  160. package/dist/video/get-current-time.js +0 -0
  161. package/dist/video/index.d.ts +0 -0
  162. package/dist/video/index.js +0 -0
  163. package/dist/video/props.d.ts +0 -0
  164. package/dist/video/props.js +0 -0
  165. package/dist/video-config.d.ts +0 -0
  166. package/dist/video-config.js +0 -0
  167. package/dist/volume-position-state.d.ts +0 -0
  168. package/dist/volume-position-state.js +0 -0
  169. package/dist/volume-prop.d.ts +0 -0
  170. package/dist/volume-prop.js +0 -0
  171. package/dist/warn-about-non-seekable-media.d.ts +0 -0
  172. package/dist/warn-about-non-seekable-media.js +0 -0
  173. package/dist/wrap-remotion-context.d.ts +0 -0
  174. package/dist/wrap-remotion-context.js +0 -0
  175. package/package.json +2 -2
  176. package/dist/config/bundle-out-dir.d.ts +0 -2
  177. package/dist/config/bundle-out-dir.js +0 -12
  178. package/dist/config/public-path.d.ts +0 -2
  179. package/dist/config/public-path.js +0 -12
@@ -1,5 +1,5 @@
1
- remotion:build: cache hit, replaying output f61b1baa8746d331
2
- remotion:build: 
3
- remotion:build: > remotion@3.2.16 build /Users/jonathanburger/remotion/packages/core
4
- remotion:build: > tsc -d
5
- remotion:build: 
1
+ remotion:build: cache hit, replaying output 28df07482870d016
2
+ remotion:build: 
3
+ remotion:build: > remotion@3.2.16 build /Users/jonathanburger/remotion/packages/core
4
+ remotion:build: > tsc -d
5
+ remotion:build: 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/Folder.d.ts CHANGED
File without changes
package/dist/Folder.js CHANGED
File without changes
package/dist/IFrame.d.ts CHANGED
File without changes
package/dist/IFrame.js CHANGED
File without changes
package/dist/Img.d.ts CHANGED
File without changes
package/dist/Img.js CHANGED
@@ -4,13 +4,13 @@ exports.Img = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const delay_render_1 = require("./delay-render");
7
- const preload_1 = require("./preload");
7
+ const prefetch_1 = require("./prefetch");
8
8
  const ImgRefForwarding = ({ onError, src, ...props }, ref) => {
9
9
  const imageRef = (0, react_1.useRef)(null);
10
10
  (0, react_1.useImperativeHandle)(ref, () => {
11
11
  return imageRef.current;
12
12
  });
13
- const actualSrc = (0, preload_1.usePreload)(src);
13
+ const actualSrc = (0, prefetch_1.usePreload)(src);
14
14
  const didGetError = (0, react_1.useCallback)((e) => {
15
15
  var _a;
16
16
  if (onError) {
File without changes
@@ -7,6 +7,7 @@ const shared_audio_tags_1 = require("./audio/shared-audio-tags");
7
7
  const CompositionManager_1 = require("./CompositionManager");
8
8
  const delay_render_1 = require("./delay-render");
9
9
  const nonce_1 = require("./nonce");
10
+ const preload_state_1 = require("./preload-state");
10
11
  const random_1 = require("./random");
11
12
  const timeline_position_state_1 = require("./timeline-position-state");
12
13
  const RemotionRoot = ({ children }) => {
@@ -61,10 +62,10 @@ const RemotionRoot = ({ children }) => {
61
62
  });
62
63
  }
63
64
  }, []);
64
- return ((0, jsx_runtime_1.jsx)(nonce_1.NonceContext.Provider, { value: nonceContext, children: (0, jsx_runtime_1.jsx)(timeline_position_state_1.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(timeline_position_state_1.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(CompositionManager_1.CompositionManagerProvider, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_1.SharedAudioContextProvider
65
- // In the preview, which is mostly played on Desktop, we opt out of the autoplay policy fix as described in https://github.com/remotion-dev/remotion/pull/554, as it mostly applies to mobile.
66
- , {
65
+ return ((0, jsx_runtime_1.jsx)(nonce_1.NonceContext.Provider, { value: nonceContext, children: (0, jsx_runtime_1.jsx)(timeline_position_state_1.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(timeline_position_state_1.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(preload_state_1.PreloadProvider, { children: (0, jsx_runtime_1.jsx)(CompositionManager_1.CompositionManagerProvider, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_1.SharedAudioContextProvider
67
66
  // In the preview, which is mostly played on Desktop, we opt out of the autoplay policy fix as described in https://github.com/remotion-dev/remotion/pull/554, as it mostly applies to mobile.
68
- numberOfAudioTags: 0, children: children }) }) }) }) }));
67
+ , {
68
+ // In the preview, which is mostly played on Desktop, we opt out of the autoplay policy fix as described in https://github.com/remotion-dev/remotion/pull/554, as it mostly applies to mobile.
69
+ numberOfAudioTags: 0, children: children }) }) }) }) }) }));
69
70
  };
70
71
  exports.RemotionRoot = RemotionRoot;
File without changes
package/dist/Sequence.js CHANGED
File without changes
package/dist/Still.d.ts CHANGED
File without changes
package/dist/Still.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AudioForDevelopment = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const preload_1 = require("../preload");
6
+ const prefetch_1 = require("../prefetch");
7
7
  const random_1 = require("../random");
8
8
  const Sequence_1 = require("../Sequence");
9
9
  const use_media_in_timeline_1 = require("../use-media-in-timeline");
@@ -25,7 +25,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
25
25
  if (!src) {
26
26
  throw new TypeError("No 'src' was passed to <Audio>.");
27
27
  }
28
- const preloadedSrc = (0, preload_1.usePreload)(src);
28
+ const preloadedSrc = (0, prefetch_1.usePreload)(src);
29
29
  const propsToPass = (0, react_1.useMemo)(() => {
30
30
  return {
31
31
  muted: muted || mediaMuted,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/bezier.d.ts CHANGED
File without changes
package/dist/bezier.js CHANGED
File without changes
File without changes
File without changes
package/dist/config.d.ts CHANGED
File without changes
package/dist/config.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/easing.d.ts CHANGED
File without changes
package/dist/easing.js CHANGED
File without changes
package/dist/freeze.d.ts CHANGED
File without changes
package/dist/freeze.js CHANGED
File without changes
File without changes
File without changes
File without changes
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRemotionEnvironment = void 0;
4
4
  const getRemotionEnvironment = () => {
5
- if (process.env.NODE_ENV === 'production') {
5
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
6
6
  if (typeof window !== 'undefined' && window.remotion_isPlayer) {
7
7
  return 'player-production';
8
8
  }
@@ -11,7 +11,7 @@ const getRemotionEnvironment = () => {
11
11
  // The Jest framework sets NODE_ENV as test.
12
12
  // Right now we don't need to treat it in a special
13
13
  // way which is good - defaulting to `rendering`.
14
- if (process.env.NODE_ENV === 'test') {
14
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
15
15
  return 'rendering';
16
16
  }
17
17
  if (typeof window !== 'undefined' && window.remotion_isPlayer) {
File without changes
File without changes
File without changes
File without changes
package/dist/index.d.ts CHANGED
@@ -56,7 +56,7 @@ export * from './internals';
56
56
  export * from './interpolate';
57
57
  export { interpolateColors } from './interpolate-colors';
58
58
  export { Loop } from './loop';
59
- export { fetchAndPreload } from './preload';
59
+ export { prefetch } from './prefetch';
60
60
  export * from './random';
61
61
  export { registerRoot } from './register-root';
62
62
  export { Sequence } from './Sequence';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.useCurrentFrame = exports.staticFile = exports.Series = exports.Sequence = exports.registerRoot = exports.fetchAndPreload = exports.Loop = exports.interpolateColors = exports.getInputProps = exports.Config = void 0;
17
+ exports.useCurrentFrame = exports.staticFile = exports.Series = exports.Sequence = exports.registerRoot = exports.prefetch = exports.Loop = exports.interpolateColors = exports.getInputProps = exports.Config = void 0;
18
18
  require("./asset-types");
19
19
  const multiple_versions_warning_1 = require("./multiple-versions-warning");
20
20
  (0, multiple_versions_warning_1.checkMultipleRemotionVersions)();
@@ -37,8 +37,8 @@ var interpolate_colors_1 = require("./interpolate-colors");
37
37
  Object.defineProperty(exports, "interpolateColors", { enumerable: true, get: function () { return interpolate_colors_1.interpolateColors; } });
38
38
  var loop_1 = require("./loop");
39
39
  Object.defineProperty(exports, "Loop", { enumerable: true, get: function () { return loop_1.Loop; } });
40
- var preload_1 = require("./preload");
41
- Object.defineProperty(exports, "fetchAndPreload", { enumerable: true, get: function () { return preload_1.fetchAndPreload; } });
40
+ var prefetch_1 = require("./prefetch");
41
+ Object.defineProperty(exports, "prefetch", { enumerable: true, get: function () { return prefetch_1.prefetch; } });
42
42
  __exportStar(require("./random"), exports);
43
43
  var register_root_1 = require("./register-root");
44
44
  Object.defineProperty(exports, "registerRoot", { enumerable: true, get: function () { return register_root_1.registerRoot; } });
@@ -79,6 +79,9 @@ export declare const Internals: {
79
79
  }>;
80
80
  CanUseRemotionHooks: import("react").Context<boolean>;
81
81
  enableLegacyRemotionConfig: () => void;
82
+ PreloadProvider: import("react").FC<{
83
+ children: import("react").ReactNode;
84
+ }>;
82
85
  };
83
86
  declare type WebpackConfiguration = Configuration;
84
87
  declare type WebpackOverrideFn = (currentConfiguration: WebpackConfiguration) => WebpackConfiguration;
package/dist/internals.js CHANGED
@@ -33,6 +33,7 @@ const delay_render_1 = require("./delay-render");
33
33
  const get_environment_1 = require("./get-environment");
34
34
  const get_preview_dom_element_1 = require("./get-preview-dom-element");
35
35
  const portal_node_1 = require("./portal-node");
36
+ const preload_state_1 = require("./preload-state");
36
37
  const register_root_1 = require("./register-root");
37
38
  const RemotionRoot_1 = require("./RemotionRoot");
38
39
  const Sequence_1 = require("./Sequence");
@@ -88,4 +89,5 @@ exports.Internals = {
88
89
  CanUseRemotionHooksProvider: CanUseRemotionHooks_1.CanUseRemotionHooksProvider,
89
90
  CanUseRemotionHooks: CanUseRemotionHooks_1.CanUseRemotionHooks,
90
91
  enableLegacyRemotionConfig: config_1.enableLegacyRemotionConfig,
92
+ PreloadProvider: preload_state_1.PreloadProvider,
91
93
  };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/nonce.d.ts CHANGED
File without changes
package/dist/nonce.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ export declare const usePreload: (src: string) => string;
2
+ declare type FetchAndPreload = {
3
+ unpreload: () => void;
4
+ waitForDone: () => Promise<string>;
5
+ };
6
+ export declare const prefetch: (src: string) => FetchAndPreload;
7
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prefetch = exports.usePreload = void 0;
4
+ const react_1 = require("react");
5
+ const get_environment_1 = require("./get-environment");
6
+ const preload_state_1 = require("./preload-state");
7
+ const usePreload = (src) => {
8
+ var _a;
9
+ const { preloads } = (0, react_1.useContext)(preload_state_1.PreloadContext);
10
+ return (_a = preloads[src]) !== null && _a !== void 0 ? _a : src;
11
+ };
12
+ exports.usePreload = usePreload;
13
+ const prefetch = (src) => {
14
+ if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
15
+ return {
16
+ unpreload: () => undefined,
17
+ waitForDone: () => Promise.resolve(src),
18
+ };
19
+ }
20
+ let canceled = false;
21
+ let objectUrl = null;
22
+ let resolve = () => undefined;
23
+ let reject = () => undefined;
24
+ const waitUntilDone = new Promise((res, rej) => {
25
+ resolve = res;
26
+ reject = rej;
27
+ });
28
+ const controller = new AbortController();
29
+ let canBeAborted = true;
30
+ fetch(src, {
31
+ signal: controller.signal,
32
+ })
33
+ .then((res) => {
34
+ canBeAborted = false;
35
+ if (canceled) {
36
+ return null;
37
+ }
38
+ if (!res.ok) {
39
+ throw new Error(`HTTP error, status = ${res.status}`);
40
+ }
41
+ return res.blob();
42
+ })
43
+ .then((buf) => {
44
+ var _a;
45
+ if (canceled) {
46
+ return;
47
+ }
48
+ if (buf) {
49
+ objectUrl = URL.createObjectURL(buf);
50
+ (_a = preload_state_1.preloadRef.current) === null || _a === void 0 ? void 0 : _a.setPreloads((p) => ({
51
+ ...p,
52
+ [src]: objectUrl,
53
+ }));
54
+ resolve(objectUrl);
55
+ }
56
+ })
57
+ .catch((err) => {
58
+ reject(err);
59
+ });
60
+ return {
61
+ unpreload: () => {
62
+ var _a;
63
+ if (objectUrl) {
64
+ URL.revokeObjectURL(objectUrl);
65
+ (_a = preload_state_1.preloadRef.current) === null || _a === void 0 ? void 0 : _a.setPreloads((p) => {
66
+ const copy = { ...p };
67
+ delete copy[src];
68
+ return copy;
69
+ });
70
+ }
71
+ else {
72
+ canceled = true;
73
+ if (canBeAborted) {
74
+ try {
75
+ controller.abort();
76
+ }
77
+ catch (e) { }
78
+ }
79
+ }
80
+ },
81
+ waitForDone: () => {
82
+ return waitUntilDone;
83
+ },
84
+ };
85
+ };
86
+ exports.prefetch = prefetch;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ declare type Value = {
3
+ preloads: Record<string, string>;
4
+ setPreloads: React.Dispatch<React.SetStateAction<Record<string, string>>>;
5
+ };
6
+ export declare const preloadRef: React.RefObject<{
7
+ setPreloads: React.Dispatch<React.SetStateAction<Record<string, string>>>;
8
+ }>;
9
+ export declare const PreloadContext: React.Context<Value>;
10
+ export declare const PreloadProvider: React.FC<{
11
+ children: React.ReactNode;
12
+ }>;
13
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PreloadProvider = exports.PreloadContext = exports.preloadRef = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ exports.preloadRef = (0, react_1.createRef)();
7
+ exports.PreloadContext = (0, react_1.createContext)({
8
+ preloads: {},
9
+ setPreloads: () => undefined,
10
+ });
11
+ const PreloadProvider = ({ children }) => {
12
+ const [preloads, setPreloads] = (0, react_1.useState)({});
13
+ const value = (0, react_1.useMemo)(() => {
14
+ return {
15
+ preloads,
16
+ setPreloads,
17
+ };
18
+ }, [preloads]);
19
+ (0, react_1.useImperativeHandle)(exports.preloadRef, () => {
20
+ return {
21
+ setPreloads,
22
+ };
23
+ });
24
+ return ((0, jsx_runtime_1.jsx)(exports.PreloadContext.Provider, { value: value, children: children }));
25
+ };
26
+ exports.PreloadProvider = PreloadProvider;
package/dist/preload.js CHANGED
@@ -3,15 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchAndPreload = exports.usePreload = void 0;
4
4
  const react_1 = require("react");
5
5
  const get_environment_1 = require("./get-environment");
6
- const preloadRef = (0, react_1.createRef)();
6
+ const preload_state_1 = require("./preload-state");
7
7
  const usePreload = (src) => {
8
8
  var _a;
9
- const [preloads, setPreloads] = (0, react_1.useState)({});
10
- (0, react_1.useImperativeHandle)(preloadRef, () => {
11
- return {
12
- setPreloads,
13
- };
14
- });
9
+ const { preloads } = (0, react_1.useContext)(preload_state_1.PreloadContext);
15
10
  return (_a = preloads[src]) !== null && _a !== void 0 ? _a : src;
16
11
  };
17
12
  exports.usePreload = usePreload;
@@ -30,10 +25,14 @@ const fetchAndPreload = (src) => {
30
25
  resolve = res;
31
26
  reject = rej;
32
27
  });
33
- fetch(src)
28
+ const controller = new AbortController();
29
+ let canBeAborted = true;
30
+ fetch(src, {
31
+ signal: controller.signal,
32
+ })
34
33
  .then((res) => {
34
+ canBeAborted = false;
35
35
  if (canceled) {
36
- reject(new Error('Preloading cancelled'));
37
36
  return null;
38
37
  }
39
38
  if (!res.ok) {
@@ -44,12 +43,11 @@ const fetchAndPreload = (src) => {
44
43
  .then((buf) => {
45
44
  var _a;
46
45
  if (canceled) {
47
- reject(new Error('Preloading cancelled'));
48
46
  return;
49
47
  }
50
48
  if (buf) {
51
49
  objectUrl = URL.createObjectURL(buf);
52
- (_a = preloadRef.current) === null || _a === void 0 ? void 0 : _a.setPreloads((p) => ({
50
+ (_a = preload_state_1.preloadRef.current) === null || _a === void 0 ? void 0 : _a.setPreloads((p) => ({
53
51
  ...p,
54
52
  [src]: objectUrl,
55
53
  }));
@@ -64,7 +62,7 @@ const fetchAndPreload = (src) => {
64
62
  var _a;
65
63
  if (objectUrl) {
66
64
  URL.revokeObjectURL(objectUrl);
67
- (_a = preloadRef.current) === null || _a === void 0 ? void 0 : _a.setPreloads((p) => {
65
+ (_a = preload_state_1.preloadRef.current) === null || _a === void 0 ? void 0 : _a.setPreloads((p) => {
68
66
  const copy = { ...p };
69
67
  delete copy[src];
70
68
  return copy;
@@ -72,7 +70,12 @@ const fetchAndPreload = (src) => {
72
70
  }
73
71
  else {
74
72
  canceled = true;
75
- reject(new Error('Preloading cancelled'));
73
+ if (canBeAborted) {
74
+ try {
75
+ controller.abort();
76
+ }
77
+ catch (e) { }
78
+ }
76
79
  }
77
80
  },
78
81
  waitForDone: () => {
package/dist/random.d.ts CHANGED
File without changes
package/dist/random.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/truthy.d.ts CHANGED
File without changes
package/dist/truthy.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/use-video.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.0-prefetch.7+47cce0679";
1
+ export declare const VERSION = "4.0.0-prefetchapi.16+486ce6105";
package/dist/version.js CHANGED
@@ -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.0-prefetch.7+47cce0679';
5
+ exports.VERSION = '4.0.0-prefetchapi.16+486ce6105';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -4,7 +4,7 @@ exports.VideoForDevelopment = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const use_audio_frame_1 = require("../audio/use-audio-frame");
7
- const preload_1 = require("../preload");
7
+ const prefetch_1 = require("../prefetch");
8
8
  const use_media_in_timeline_1 = require("../use-media-in-timeline");
9
9
  const use_media_playback_1 = require("../use-media-playback");
10
10
  const use_media_tag_volume_1 = require("../use-media-tag-volume");
@@ -39,7 +39,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
39
39
  playbackRate: (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1,
40
40
  onlyWarnForMediaSeekingError,
41
41
  });
42
- const actualSrc = (0, preload_1.usePreload)(src);
42
+ const actualSrc = (0, prefetch_1.usePreload)(src);
43
43
  (0, react_1.useImperativeHandle)(ref, () => {
44
44
  return videoRef.current;
45
45
  });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.0-prefetch.7+47cce0679",
3
+ "version": "4.0.0-prefetchapi.16+486ce6105",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "47cce06799563fb244ff25b211ea4055389bd7de"
57
+ "gitHead": "486ce6105d52f9494351e4fbf564f6cfb0b10408"
58
58
  }
@@ -1,2 +0,0 @@
1
- export declare const getBundleOutDir: () => string | null;
2
- export declare const setBundleOutDir: (path: string) => void;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setBundleOutDir = exports.getBundleOutDir = void 0;
4
- let bundleOutDir = null;
5
- const getBundleOutDir = () => {
6
- return bundleOutDir;
7
- };
8
- exports.getBundleOutDir = getBundleOutDir;
9
- const setBundleOutDir = (path) => {
10
- bundleOutDir = path;
11
- };
12
- exports.setBundleOutDir = setBundleOutDir;
@@ -1,2 +0,0 @@
1
- export declare const getPublicPath: () => string | null;
2
- export declare const setPublicPath: (path: string) => void;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setPublicPath = exports.getPublicPath = void 0;
4
- let publicPath = null;
5
- const getPublicPath = () => {
6
- return publicPath;
7
- };
8
- exports.getPublicPath = getPublicPath;
9
- const setPublicPath = (path) => {
10
- publicPath = path;
11
- };
12
- exports.setPublicPath = setPublicPath;