remotion 3.3.51 → 3.3.52

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 (198) hide show
  1. package/dist/AbsoluteFill.d.ts +6 -0
  2. package/dist/AbsoluteFill.js +28 -0
  3. package/dist/CanUseRemotionHooks.d.ts +5 -0
  4. package/dist/CanUseRemotionHooks.js +10 -0
  5. package/dist/Clipper.d.ts +7 -0
  6. package/dist/Clipper.js +24 -0
  7. package/dist/Composition.d.ts +23 -0
  8. package/dist/Composition.js +113 -0
  9. package/dist/CompositionManager.d.ts +82 -0
  10. package/dist/CompositionManager.js +164 -0
  11. package/dist/Folder.d.ts +15 -0
  12. package/dist/Folder.js +33 -0
  13. package/dist/IFrame.d.ts +2 -0
  14. package/dist/IFrame.js +24 -0
  15. package/dist/Img.d.ts +2 -0
  16. package/dist/Img.js +52 -0
  17. package/dist/NativeLayers.d.ts +13 -0
  18. package/dist/NativeLayers.js +29 -0
  19. package/dist/Null.d.ts +2 -0
  20. package/dist/Null.js +25 -0
  21. package/dist/RemotionRoot.d.ts +5 -0
  22. package/dist/RemotionRoot.js +73 -0
  23. package/dist/Sequence.d.ts +29 -0
  24. package/dist/Sequence.js +131 -0
  25. package/dist/Still.d.ts +2 -0
  26. package/dist/Still.js +9 -0
  27. package/dist/absolute-src.d.ts +1 -0
  28. package/dist/absolute-src.js +7 -0
  29. package/dist/asset-types.d.ts +50 -0
  30. package/dist/asset-types.js +1 -0
  31. package/dist/audio/Audio.d.ts +8 -0
  32. package/dist/audio/Audio.js +52 -0
  33. package/dist/audio/AudioForDevelopment.d.ts +11 -0
  34. package/dist/audio/AudioForDevelopment.js +94 -0
  35. package/dist/audio/AudioForRendering.d.ts +10 -0
  36. package/dist/audio/AudioForRendering.js +111 -0
  37. package/dist/audio/index.d.ts +2 -0
  38. package/dist/audio/index.js +18 -0
  39. package/dist/audio/props.d.ts +12 -0
  40. package/dist/audio/props.js +2 -0
  41. package/dist/audio/shared-audio-tags.d.ts +37 -0
  42. package/dist/audio/shared-audio-tags.js +222 -0
  43. package/dist/audio/use-audio-frame.d.ts +6 -0
  44. package/dist/audio/use-audio-frame.js +23 -0
  45. package/dist/bezier.d.ts +1 -0
  46. package/dist/bezier.js +114 -0
  47. package/dist/cancel-render.d.ts +1 -0
  48. package/dist/cancel-render.js +43 -0
  49. package/dist/cjs/series/index.js +5 -2
  50. package/dist/cjs/test/series.test.js +32 -27
  51. package/dist/cjs/version.d.ts +1 -1
  52. package/dist/cjs/version.js +1 -1
  53. package/dist/config/input-props.d.ts +1 -0
  54. package/dist/config/input-props.js +31 -0
  55. package/dist/config.d.ts +285 -0
  56. package/dist/config.js +21 -0
  57. package/dist/default-css.d.ts +3 -0
  58. package/dist/default-css.js +49 -0
  59. package/dist/delay-render.d.ts +14 -0
  60. package/dist/delay-render.js +77 -0
  61. package/dist/easing.d.ts +19 -0
  62. package/dist/easing.js +77 -0
  63. package/dist/esm/series/index.js +5 -2
  64. package/dist/esm/test/series.test.js +32 -27
  65. package/dist/esm/version.d.ts +1 -1
  66. package/dist/esm/version.js +1 -1
  67. package/dist/freeze.d.ts +7 -0
  68. package/dist/freeze.js +34 -0
  69. package/dist/get-asset-file-name.d.ts +1 -0
  70. package/dist/get-asset-file-name.js +14 -0
  71. package/dist/get-environment.d.ts +3 -0
  72. package/dist/get-environment.js +34 -0
  73. package/dist/get-preview-dom-element.d.ts +1 -0
  74. package/dist/get-preview-dom-element.js +7 -0
  75. package/dist/get-static-files.d.ts +17 -0
  76. package/dist/get-static-files.js +31 -0
  77. package/dist/get-timeline-clip-name.d.ts +1 -0
  78. package/dist/get-timeline-clip-name.js +25 -0
  79. package/dist/index.d.ts +92 -0
  80. package/dist/index.js +73 -0
  81. package/dist/internals.d.ts +97 -0
  82. package/dist/internals.js +99 -0
  83. package/dist/interpolate-colors.d.ts +5 -0
  84. package/dist/interpolate-colors.js +401 -0
  85. package/dist/interpolate.d.ts +18 -0
  86. package/dist/interpolate.js +123 -0
  87. package/dist/is-approximately-the-same.d.ts +1 -0
  88. package/dist/is-approximately-the-same.js +8 -0
  89. package/dist/is-player.d.ts +3 -0
  90. package/dist/is-player.js +14 -0
  91. package/dist/loading-indicator.d.ts +2 -0
  92. package/dist/loading-indicator.js +35 -0
  93. package/dist/loop/index.d.ts +9 -0
  94. package/dist/loop/index.js +29 -0
  95. package/dist/multiple-versions-warning.d.ts +1 -0
  96. package/dist/multiple-versions-warning.js +32 -0
  97. package/dist/nonce.d.ts +7 -0
  98. package/dist/nonce.js +17 -0
  99. package/dist/play-and-handle-not-allowed-error.d.ts +2 -0
  100. package/dist/play-and-handle-not-allowed-error.js +44 -0
  101. package/dist/portal-node.d.ts +1 -0
  102. package/dist/portal-node.js +23 -0
  103. package/dist/prefetch-state.d.ts +8 -0
  104. package/dist/prefetch-state.js +27 -0
  105. package/dist/prefetch.d.ts +9 -0
  106. package/dist/prefetch.js +108 -0
  107. package/dist/random.d.ts +7 -0
  108. package/dist/random.js +41 -0
  109. package/dist/register-root.d.ts +4 -0
  110. package/dist/register-root.js +33 -0
  111. package/dist/series/flatten-children.d.ts +2 -0
  112. package/dist/series/flatten-children.js +19 -0
  113. package/dist/series/index.d.ts +13 -0
  114. package/dist/series/index.js +60 -0
  115. package/dist/setup-env-variables.d.ts +2 -0
  116. package/dist/setup-env-variables.js +36 -0
  117. package/dist/spring/index.d.ts +27 -0
  118. package/dist/spring/index.js +51 -0
  119. package/dist/spring/measure-spring.d.ts +8 -0
  120. package/dist/spring/measure-spring.js +64 -0
  121. package/dist/spring/spring-utils.d.ts +21 -0
  122. package/dist/spring/spring-utils.js +103 -0
  123. package/dist/static-file.d.ts +5 -0
  124. package/dist/static-file.js +33 -0
  125. package/dist/timeline-position-state.d.ts +29 -0
  126. package/dist/timeline-position-state.js +41 -0
  127. package/dist/truthy.d.ts +3 -0
  128. package/dist/truthy.js +7 -0
  129. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  130. package/dist/use-current-frame.d.ts +6 -0
  131. package/dist/use-current-frame.js +28 -0
  132. package/dist/use-lazy-component.d.ts +7 -0
  133. package/dist/use-lazy-component.js +49 -0
  134. package/dist/use-media-in-timeline.d.ts +10 -0
  135. package/dist/use-media-in-timeline.js +129 -0
  136. package/dist/use-media-playback.d.ts +10 -0
  137. package/dist/use-media-playback.js +77 -0
  138. package/dist/use-media-tag-volume.d.ts +2 -0
  139. package/dist/use-media-tag-volume.js +31 -0
  140. package/dist/use-sync-volume-with-media-tag.d.ts +10 -0
  141. package/dist/use-sync-volume-with-media-tag.js +21 -0
  142. package/dist/use-unsafe-video-config.d.ts +2 -0
  143. package/dist/use-unsafe-video-config.js +27 -0
  144. package/dist/use-video-config.d.ts +7 -0
  145. package/dist/use-video-config.js +29 -0
  146. package/dist/use-video.d.ts +12 -0
  147. package/dist/use-video.js +28 -0
  148. package/dist/validate-media-props.d.ts +4 -0
  149. package/dist/validate-media-props.js +24 -0
  150. package/dist/validate-start-from-props.d.ts +1 -0
  151. package/dist/validate-start-from-props.js +31 -0
  152. package/dist/validation/validate-composition-id.d.ts +3 -0
  153. package/dist/validation/validate-composition-id.js +13 -0
  154. package/dist/validation/validate-dimensions.d.ts +1 -0
  155. package/dist/validation/validate-dimensions.js +21 -0
  156. package/dist/validation/validate-duration-in-frames.d.ts +1 -0
  157. package/dist/validation/validate-duration-in-frames.js +15 -0
  158. package/dist/validation/validate-folder-name.d.ts +3 -0
  159. package/dist/validation/validate-folder-name.js +19 -0
  160. package/dist/validation/validate-fps.d.ts +1 -0
  161. package/dist/validation/validate-fps.js +21 -0
  162. package/dist/validation/validate-offthreadvideo-image-format.d.ts +1 -0
  163. package/dist/validation/validate-offthreadvideo-image-format.js +15 -0
  164. package/dist/validation/validation-spring-duration.d.ts +1 -0
  165. package/dist/validation/validation-spring-duration.js +21 -0
  166. package/dist/version.d.ts +1 -0
  167. package/dist/version.js +5 -0
  168. package/dist/video/OffthreadVideo.d.ts +3 -0
  169. package/dist/video/OffthreadVideo.js +33 -0
  170. package/dist/video/OffthreadVideoForRendering.d.ts +3 -0
  171. package/dist/video/OffthreadVideoForRendering.js +104 -0
  172. package/dist/video/Video.d.ts +8 -0
  173. package/dist/video/Video.js +50 -0
  174. package/dist/video/VideoForDevelopment.d.ts +11 -0
  175. package/dist/video/VideoForDevelopment.js +113 -0
  176. package/dist/video/VideoForRendering.d.ts +10 -0
  177. package/dist/video/VideoForRendering.js +203 -0
  178. package/dist/video/duration-state.d.ts +17 -0
  179. package/dist/video/duration-state.js +34 -0
  180. package/dist/video/get-current-time.d.ts +13 -0
  181. package/dist/video/get-current-time.js +31 -0
  182. package/dist/video/index.d.ts +3 -0
  183. package/dist/video/index.js +7 -0
  184. package/dist/video/props.d.ts +25 -0
  185. package/dist/video/props.js +2 -0
  186. package/dist/video/video-fragment.d.ts +12 -0
  187. package/dist/video/video-fragment.js +60 -0
  188. package/dist/video-config.d.ts +8 -0
  189. package/dist/video-config.js +2 -0
  190. package/dist/volume-position-state.d.ts +19 -0
  191. package/dist/volume-position-state.js +32 -0
  192. package/dist/volume-prop.d.ts +7 -0
  193. package/dist/volume-prop.js +24 -0
  194. package/dist/warn-about-non-seekable-media.d.ts +1 -0
  195. package/dist/warn-about-non-seekable-media.js +34 -0
  196. package/dist/wrap-remotion-context.d.ts +18 -0
  197. package/dist/wrap-remotion-context.js +73 -0
  198. package/package.json +4 -5
@@ -0,0 +1,2 @@
1
+ export * from './Audio';
2
+ export * from './props';
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Audio"), exports);
18
+ __exportStar(require("./props"), exports);
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { VolumeProp } from '../volume-prop';
3
+ export declare type RemotionMainAudioProps = {
4
+ startFrom?: number;
5
+ endAt?: number;
6
+ };
7
+ export declare type RemotionAudioProps = Omit<React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>, 'autoPlay' | 'controls' | 'onEnded' | 'nonce' | 'onResize' | 'onResizeCapture'> & {
8
+ volume?: VolumeProp;
9
+ playbackRate?: number;
10
+ acceptableTimeShiftInSeconds?: number;
11
+ allowAmplificationDuringRender?: boolean;
12
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import type { RemotionAudioProps } from './props';
3
+ /**
4
+ * This functionality of Remotion will keep a certain amount
5
+ * of <audio> tags pre-mounted and by default filled with an empty audio track.
6
+ * If the user interacts, the empty audio will be played.
7
+ * If one of Remotions <Audio /> tags get mounted, the audio will not be rendered at this location, but into one of the prerendered audio tags.
8
+ *
9
+ * This helps with autoplay issues on iOS Safari and soon other browsers,
10
+ * which only allow audio playback upon user interaction.
11
+ *
12
+ * The behavior can be disabled by passing `0` as the number of shared audio tracks.
13
+ */
14
+ declare type AudioElem = {
15
+ id: number;
16
+ props: RemotionAudioProps;
17
+ el: React.RefObject<HTMLAudioElement>;
18
+ audioId: string;
19
+ };
20
+ declare type SharedContext = {
21
+ registerAudio: (aud: RemotionAudioProps, audioId: string) => AudioElem;
22
+ unregisterAudio: (id: number) => void;
23
+ updateAudio: (options: {
24
+ id: number;
25
+ aud: RemotionAudioProps;
26
+ audioId: string;
27
+ }) => void;
28
+ playAllAudios: () => void;
29
+ numberOfAudioTags: number;
30
+ };
31
+ export declare const SharedAudioContext: React.Context<SharedContext | null>;
32
+ export declare const SharedAudioContextProvider: React.FC<{
33
+ numberOfAudioTags: number;
34
+ children: React.ReactNode;
35
+ }>;
36
+ export declare const useSharedAudio: (aud: RemotionAudioProps, audioId: string) => AudioElem;
37
+ export {};
@@ -0,0 +1,222 @@
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.useSharedAudio = exports.SharedAudioContextProvider = exports.SharedAudioContext = void 0;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const react_1 = __importStar(require("react"));
29
+ const EMPTY_AUDIO = 'data:audio/mp3;base64,/+MYxAAJcAV8AAgAABn//////+/gQ5BAMA+D4Pg+BAQBAEAwD4Pg+D4EBAEAQDAPg++hYBH///hUFQVBUFREDQNHmf///////+MYxBUGkAGIMAAAAP/29Xt6lUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV/+MYxDUAAANIAAAAAFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV';
30
+ const compareProps = (obj1, obj2) => {
31
+ const keysA = Object.keys(obj1).sort();
32
+ const keysB = Object.keys(obj2).sort();
33
+ if (keysA.length !== keysB.length) {
34
+ return false;
35
+ }
36
+ for (let i = 0; i < keysA.length; i++) {
37
+ // Not the same keys
38
+ if (keysA[i] !== keysB[i]) {
39
+ return false;
40
+ }
41
+ // Not the same values
42
+ if (obj1[keysA[i]] !== obj2[keysB[i]]) {
43
+ return false;
44
+ }
45
+ }
46
+ return true;
47
+ };
48
+ const didPropChange = (key, newProp, prevProp) => {
49
+ // /music.mp3 and http://localhost:3000/music.mp3 are the same
50
+ if (key === 'src' &&
51
+ !prevProp.startsWith('data:') &&
52
+ !newProp.startsWith('data:')) {
53
+ return (new URL(prevProp, window.location.origin).toString() !==
54
+ new URL(newProp, window.location.origin).toString());
55
+ }
56
+ if (prevProp === newProp) {
57
+ return false;
58
+ }
59
+ return true;
60
+ };
61
+ exports.SharedAudioContext = (0, react_1.createContext)(null);
62
+ const SharedAudioContextProvider = ({ children, numberOfAudioTags }) => {
63
+ const audios = (0, react_1.useRef)([]);
64
+ const [initialNumberOfAudioTags] = (0, react_1.useState)(numberOfAudioTags);
65
+ if (numberOfAudioTags !== initialNumberOfAudioTags) {
66
+ throw new Error('The number of shared audio tags has changed dynamically. Once you have set this property, you cannot change it afterwards.');
67
+ }
68
+ const refs = (0, react_1.useMemo)(() => {
69
+ return new Array(numberOfAudioTags).fill(true).map(() => {
70
+ return { id: Math.random(), ref: (0, react_1.createRef)() };
71
+ });
72
+ }, [numberOfAudioTags]);
73
+ const takenAudios = (0, react_1.useRef)(new Array(numberOfAudioTags).fill(false));
74
+ const rerenderAudios = (0, react_1.useCallback)(() => {
75
+ refs.forEach(({ ref, id }) => {
76
+ var _a;
77
+ const data = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.find((a) => a.id === id);
78
+ const { current } = ref;
79
+ if (!current) {
80
+ // Whole player has been unmounted, the refs don't exist anymore.
81
+ // It is not an error anymore though
82
+ return;
83
+ }
84
+ if (data === undefined) {
85
+ current.src = EMPTY_AUDIO;
86
+ return;
87
+ }
88
+ if (!data) {
89
+ throw new TypeError('Expected audio data to be there');
90
+ }
91
+ Object.keys(data.props).forEach((key) => {
92
+ // @ts-expect-error
93
+ if (didPropChange(key, data.props[key], current[key])) {
94
+ // @ts-expect-error
95
+ current[key] = data.props[key];
96
+ }
97
+ });
98
+ });
99
+ }, [refs]);
100
+ const registerAudio = (0, react_1.useCallback)((aud, audioId) => {
101
+ var _a, _b;
102
+ const found = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.find((a) => a.audioId === audioId);
103
+ if (found) {
104
+ return found;
105
+ }
106
+ const firstFreeAudio = takenAudios.current.findIndex((a) => a === false);
107
+ if (firstFreeAudio === -1) {
108
+ throw new Error(`Tried to simultaneously mount ${numberOfAudioTags + 1} <Audio /> tags at the same time. With the current settings, the maximum amount of <Audio /> tags is limited to ${numberOfAudioTags} at the same time. Remotion pre-mounts silent audio tags to help avoid browser autoplay restrictions. See https://remotion.dev/docs/player/autoplay#use-the-numberofsharedaudiotags-property for more information on how to increase this limit.`);
109
+ }
110
+ const { id, ref } = refs[firstFreeAudio];
111
+ const cloned = [...takenAudios.current];
112
+ cloned[firstFreeAudio] = id;
113
+ takenAudios.current = cloned;
114
+ const newElem = {
115
+ props: aud,
116
+ id,
117
+ el: ref,
118
+ audioId,
119
+ };
120
+ (_b = audios.current) === null || _b === void 0 ? void 0 : _b.push(newElem);
121
+ rerenderAudios();
122
+ return newElem;
123
+ }, [numberOfAudioTags, refs, rerenderAudios]);
124
+ const unregisterAudio = (0, react_1.useCallback)((id) => {
125
+ var _a;
126
+ const cloned = [...takenAudios.current];
127
+ const index = refs.findIndex((r) => r.id === id);
128
+ if (index === -1) {
129
+ throw new TypeError('Error occured in ');
130
+ }
131
+ cloned[index] = false;
132
+ takenAudios.current = cloned;
133
+ audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.filter((a) => a.id !== id);
134
+ rerenderAudios();
135
+ }, [refs, rerenderAudios]);
136
+ const updateAudio = (0, react_1.useCallback)(({ aud, audioId, id, }) => {
137
+ var _a;
138
+ let changed = false;
139
+ audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.map((prevA) => {
140
+ if (prevA.id === id) {
141
+ const isTheSame = compareProps(aud, prevA.props);
142
+ if (isTheSame) {
143
+ return prevA;
144
+ }
145
+ changed = true;
146
+ return {
147
+ ...prevA,
148
+ props: aud,
149
+ audioId,
150
+ };
151
+ }
152
+ return prevA;
153
+ });
154
+ if (changed) {
155
+ rerenderAudios();
156
+ }
157
+ }, [rerenderAudios]);
158
+ const playAllAudios = (0, react_1.useCallback)(() => {
159
+ refs.forEach((ref) => {
160
+ var _a;
161
+ (_a = ref.ref.current) === null || _a === void 0 ? void 0 : _a.play();
162
+ });
163
+ }, [refs]);
164
+ const value = (0, react_1.useMemo)(() => {
165
+ return {
166
+ registerAudio,
167
+ unregisterAudio,
168
+ updateAudio,
169
+ playAllAudios,
170
+ numberOfAudioTags,
171
+ };
172
+ }, [
173
+ numberOfAudioTags,
174
+ playAllAudios,
175
+ registerAudio,
176
+ unregisterAudio,
177
+ updateAudio,
178
+ ]);
179
+ return ((0, jsx_runtime_1.jsxs)(exports.SharedAudioContext.Provider, { value: value, children: [refs.map(({ id, ref }) => {
180
+ return (0, jsx_runtime_1.jsx)("audio", { ref: ref, src: EMPTY_AUDIO }, id);
181
+ }), children] }));
182
+ };
183
+ exports.SharedAudioContextProvider = SharedAudioContextProvider;
184
+ const useSharedAudio = (aud, audioId) => {
185
+ const ctx = (0, react_1.useContext)(exports.SharedAudioContext);
186
+ /**
187
+ * We work around this in React 18 so an audio tag will only register itself once
188
+ */
189
+ const [elem] = (0, react_1.useState)(() => {
190
+ if (ctx && ctx.numberOfAudioTags > 0) {
191
+ return ctx.registerAudio(aud, audioId);
192
+ }
193
+ return {
194
+ el: react_1.default.createRef(),
195
+ id: Math.random(),
196
+ props: aud,
197
+ audioId,
198
+ };
199
+ });
200
+ /**
201
+ * Effects in React 18 fire twice, and we are looking for a way to only fire it once.
202
+ * - useInsertionEffect only fires once. If it's available we are in React 18.
203
+ * - useLayoutEffect only fires once in React 17.
204
+ */
205
+ const effectToUse = react_1.useInsertionEffect !== null && react_1.useInsertionEffect !== void 0 ? react_1.useInsertionEffect : react_1.useLayoutEffect;
206
+ if (typeof document !== 'undefined') {
207
+ effectToUse(() => {
208
+ if (ctx && ctx.numberOfAudioTags > 0) {
209
+ ctx.updateAudio({ id: elem.id, aud, audioId });
210
+ }
211
+ }, [aud, ctx, elem.id, audioId]);
212
+ effectToUse(() => {
213
+ return () => {
214
+ if (ctx && ctx.numberOfAudioTags > 0) {
215
+ ctx.unregisterAudio(elem.id);
216
+ }
217
+ };
218
+ }, [ctx, elem.id]);
219
+ }
220
+ return elem;
221
+ };
222
+ exports.useSharedAudio = useSharedAudio;
@@ -0,0 +1,6 @@
1
+ export declare const useMediaStartsAt: () => number;
2
+ /**
3
+ * When passing a function as the prop for `volume`,
4
+ * we calculate the way more intuitive value for currentFrame
5
+ */
6
+ export declare const useFrameForVolumeProp: () => number;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFrameForVolumeProp = exports.useMediaStartsAt = void 0;
4
+ const react_1 = require("react");
5
+ const Sequence_1 = require("../Sequence");
6
+ const use_current_frame_1 = require("../use-current-frame");
7
+ const useMediaStartsAt = () => {
8
+ var _a;
9
+ const parentSequence = (0, react_1.useContext)(Sequence_1.SequenceContext);
10
+ const startsAt = Math.min(0, (_a = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.relativeFrom) !== null && _a !== void 0 ? _a : 0);
11
+ return startsAt;
12
+ };
13
+ exports.useMediaStartsAt = useMediaStartsAt;
14
+ /**
15
+ * When passing a function as the prop for `volume`,
16
+ * we calculate the way more intuitive value for currentFrame
17
+ */
18
+ const useFrameForVolumeProp = () => {
19
+ const frame = (0, use_current_frame_1.useCurrentFrame)();
20
+ const startsAt = (0, exports.useMediaStartsAt)();
21
+ return frame + startsAt;
22
+ };
23
+ exports.useFrameForVolumeProp = useFrameForVolumeProp;
@@ -0,0 +1 @@
1
+ export declare function bezier(mX1: number, mY1: number, mX2: number, mY2: number): (x: number) => number;
package/dist/bezier.js ADDED
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ // Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/bezier.js
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.bezier = void 0;
5
+ const NEWTON_ITERATIONS = 4;
6
+ const NEWTON_MIN_SLOPE = 0.001;
7
+ const SUBDIVISION_PRECISION = 0.0000001;
8
+ const SUBDIVISION_MAX_ITERATIONS = 10;
9
+ const kSplineTableSize = 11;
10
+ const kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
11
+ const float32ArraySupported = typeof Float32Array === 'function';
12
+ function a(aA1, aA2) {
13
+ return 1.0 - 3.0 * aA2 + 3.0 * aA1;
14
+ }
15
+ function b(aA1, aA2) {
16
+ return 3.0 * aA2 - 6.0 * aA1;
17
+ }
18
+ function c(aA1) {
19
+ return 3.0 * aA1;
20
+ }
21
+ // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
22
+ function calcBezier(aT, aA1, aA2) {
23
+ return ((a(aA1, aA2) * aT + b(aA1, aA2)) * aT + c(aA1)) * aT;
24
+ }
25
+ // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
26
+ function getSlope(aT, aA1, aA2) {
27
+ return 3.0 * a(aA1, aA2) * aT * aT + 2.0 * b(aA1, aA2) * aT + c(aA1);
28
+ }
29
+ function binarySubdivide({ aX, _aA, _aB, mX1, mX2, }) {
30
+ let currentX;
31
+ let currentT;
32
+ let i = 0;
33
+ let aA = _aA;
34
+ let aB = _aB;
35
+ do {
36
+ currentT = aA + (aB - aA) / 2.0;
37
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
38
+ if (currentX > 0.0) {
39
+ aB = currentT;
40
+ }
41
+ else {
42
+ aA = currentT;
43
+ }
44
+ } while (Math.abs(currentX) > SUBDIVISION_PRECISION &&
45
+ ++i < SUBDIVISION_MAX_ITERATIONS);
46
+ return currentT;
47
+ }
48
+ function newtonRaphsonIterate(aX, _aGuessT, mX1, mX2) {
49
+ let aGuessT = _aGuessT;
50
+ for (let i = 0; i < NEWTON_ITERATIONS; ++i) {
51
+ const currentSlope = getSlope(aGuessT, mX1, mX2);
52
+ if (currentSlope === 0.0) {
53
+ return aGuessT;
54
+ }
55
+ const currentX = calcBezier(aGuessT, mX1, mX2) - aX;
56
+ aGuessT -= currentX / currentSlope;
57
+ }
58
+ return aGuessT;
59
+ }
60
+ function bezier(mX1, mY1, mX2, mY2) {
61
+ if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) {
62
+ throw new Error('bezier x values must be in [0, 1] range');
63
+ }
64
+ // Precompute samples table
65
+ const sampleValues = float32ArraySupported
66
+ ? new Float32Array(kSplineTableSize)
67
+ : new Array(kSplineTableSize);
68
+ if (mX1 !== mY1 || mX2 !== mY2) {
69
+ for (let i = 0; i < kSplineTableSize; ++i) {
70
+ sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
71
+ }
72
+ }
73
+ function getTForX(aX) {
74
+ let intervalStart = 0.0;
75
+ let currentSample = 1;
76
+ const lastSample = kSplineTableSize - 1;
77
+ for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
78
+ intervalStart += kSampleStepSize;
79
+ }
80
+ --currentSample;
81
+ // Interpolate to provide an initial guess for t
82
+ const dist = (aX - sampleValues[currentSample]) /
83
+ (sampleValues[currentSample + 1] - sampleValues[currentSample]);
84
+ const guessForT = intervalStart + dist * kSampleStepSize;
85
+ const initialSlope = getSlope(guessForT, mX1, mX2);
86
+ if (initialSlope >= NEWTON_MIN_SLOPE) {
87
+ return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
88
+ }
89
+ if (initialSlope === 0.0) {
90
+ return guessForT;
91
+ }
92
+ return binarySubdivide({
93
+ aX,
94
+ _aA: intervalStart,
95
+ _aB: intervalStart + kSampleStepSize,
96
+ mX1,
97
+ mX2,
98
+ });
99
+ }
100
+ return function (x) {
101
+ if (mX1 === mY1 && mX2 === mY2) {
102
+ return x; // linear
103
+ }
104
+ // Because JavaScript number are imprecise, we should guarantee the extremes are right.
105
+ if (x === 0) {
106
+ return 0;
107
+ }
108
+ if (x === 1) {
109
+ return 1;
110
+ }
111
+ return calcBezier(getTForX(x), mY1, mY2);
112
+ };
113
+ }
114
+ exports.bezier = bezier;
@@ -0,0 +1 @@
1
+ export declare function cancelRender(err: unknown): never;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cancelRender = void 0;
4
+ const isErrorLike = (err) => {
5
+ if (err === null) {
6
+ return false;
7
+ }
8
+ if (typeof err !== 'object') {
9
+ return false;
10
+ }
11
+ if (!('stack' in err)) {
12
+ return false;
13
+ }
14
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
15
+ // @ts-ignore we just asserted
16
+ if (typeof err.stack !== 'string') {
17
+ return false;
18
+ }
19
+ if (!('message' in err)) {
20
+ return false;
21
+ }
22
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
23
+ // @ts-ignore we just asserted
24
+ if (typeof err.message !== 'string') {
25
+ return false;
26
+ }
27
+ return true;
28
+ };
29
+ function cancelRender(err) {
30
+ let error;
31
+ if (isErrorLike(err)) {
32
+ error = err;
33
+ }
34
+ else if (typeof err === 'string') {
35
+ error = Error(err);
36
+ }
37
+ else {
38
+ error = Error('Rendering was cancelled');
39
+ }
40
+ window.remotion_cancelledError = error.stack;
41
+ throw error;
42
+ }
43
+ exports.cancelRender = cancelRender;
@@ -15,7 +15,8 @@ const SeriesSequence = (0, react_1.forwardRef)(SeriesSequenceRefForwardingFuncti
15
15
  const Series = ({ children }) => {
16
16
  const childrenValue = (0, react_1.useMemo)(() => {
17
17
  let startFrame = 0;
18
- return react_1.Children.map((0, flatten_children_js_1.flattenChildren)(children), (child, i) => {
18
+ const flattenedChildren = (0, flatten_children_js_1.flattenChildren)(children);
19
+ return react_1.Children.map(flattenedChildren, (child, i) => {
19
20
  var _a;
20
21
  const castedChild = child;
21
22
  if (typeof castedChild === 'string') {
@@ -34,7 +35,9 @@ const Series = ({ children }) => {
34
35
  }
35
36
  const durationInFramesProp = castedChild.props.durationInFrames;
36
37
  const { durationInFrames, children: _children, ...passedProps } = castedChild.props;
37
- (0, validate_duration_in_frames_js_1.validateDurationInFrames)(durationInFramesProp, `of a <Series.Sequence /> component`);
38
+ if (i !== flattenedChildren.length - 1 || durationInFramesProp !== Infinity) {
39
+ (0, validate_duration_in_frames_js_1.validateDurationInFrames)(durationInFramesProp, `of a <Series.Sequence /> component`);
40
+ }
38
41
  const offset = (_a = castedChild.props.offset) !== null && _a !== void 0 ? _a : 0;
39
42
  if (Number.isNaN(offset)) {
40
43
  throw new TypeError(`The "offset" property of a <Series.Sequence /> must not be NaN, but got NaN (${debugInfo}).`);
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
- /**
5
- * @vitest-environment jsdom
6
- */
7
- /* eslint-disable react/jsx-no-constructed-context-values */
8
- const react_1 = require("@testing-library/react");
4
+ const server_1 = require("react-dom/server");
9
5
  const vitest_1 = require("vitest");
10
6
  const CanUseRemotionHooks_js_1 = require("../CanUseRemotionHooks.js");
11
7
  const series_1 = require("../series");
@@ -25,7 +21,7 @@ const Third = () => {
25
21
  return (0, jsx_runtime_1.jsx)("div", { children: 'third ' + frame });
26
22
  };
27
23
  const renderForFrame = (frame, markup) => {
28
- return (0, react_1.render)((0, jsx_runtime_1.jsx)(CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: {
24
+ return (0, server_1.renderToString)((0, jsx_runtime_1.jsx)(CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: {
29
25
  rootId: '',
30
26
  frame,
31
27
  playing: false,
@@ -40,27 +36,27 @@ const renderForFrame = (frame, markup) => {
40
36
  }, children: markup }) }));
41
37
  };
42
38
  (0, vitest_1.test)('Basic series test', () => {
43
- const { queryByText } = renderForFrame(10, (0, jsx_runtime_1.jsxs)(wrap_sequence_context_js_1.WrapSequenceContext, { children: [(0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Third, {}) })] }), ' '] }));
44
- (0, vitest_1.expect)(queryByText(/^third\s0$/)).not.toBe(null);
39
+ const outerHTML = renderForFrame(10, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Third, {}) })] }) }));
40
+ (0, vitest_1.expect)(outerHTML).toBe('<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>third 0</div></div>');
45
41
  });
46
42
  (0, vitest_1.test)('Should support fragments', () => {
47
- const { container } = renderForFrame(10, (0, jsx_runtime_1.jsxs)(wrap_sequence_context_js_1.WrapSequenceContext, { children: [(0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) }, "0"), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Third, {}) }, "1")] })] }), ' '] }));
48
- (0, vitest_1.expect)(container.outerHTML).not.toBe(null);
43
+ const outerHtml = renderForFrame(10, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) }, "0"), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Third, {}) }, "1")] })] }) }));
44
+ (0, vitest_1.expect)(outerHtml).not.toBe('<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>second 1</div></div>');
49
45
  });
50
46
  (0, vitest_1.test)('Should not allow foreign elements', () => {
51
47
  (0, vitest_1.expect)(() => {
52
- (0, react_1.render)((0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsx)(series_1.Series, { children: (0, jsx_runtime_1.jsx)(First, {}) }) }));
48
+ renderForFrame(0, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsx)(series_1.Series, { children: (0, jsx_runtime_1.jsx)(First, {}) }) }));
53
49
  }).toThrow(/only accepts a/);
54
50
  });
55
51
  (0, vitest_1.test)('Should allow layout prop', () => {
56
- const { container } = renderForFrame(0, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsx)(series_1.Series, { children: (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 1, children: (0, jsx_runtime_1.jsx)(First, {}) }) }) }));
57
- (0, vitest_1.expect)(container.outerHTML).toBe('<div><div style="position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; width: 100%; height: 100%; display: flex;"><div>first 0</div></div></div>');
58
- const { container: withoutLayoutContainer } = renderForFrame(0, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsx)(series_1.Series, { children: (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 1, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }) }) }));
59
- (0, vitest_1.expect)(withoutLayoutContainer.outerHTML).toBe('<div><div>first 0</div></div>');
52
+ const outerHTML = renderForFrame(0, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsx)(series_1.Series, { children: (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 1, children: (0, jsx_runtime_1.jsx)(First, {}) }) }) }));
53
+ (0, vitest_1.expect)(outerHTML).toBe('<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>first 0</div></div>');
54
+ const outerHTML2 = renderForFrame(0, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsx)(series_1.Series, { children: (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 1, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }) }) }));
55
+ (0, vitest_1.expect)(outerHTML2).toBe('<div>first 0</div>');
60
56
  });
61
57
  (0, vitest_1.test)('Should render nothing after the end', () => {
62
- const { container } = renderForFrame(10, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsx)(series_1.Series, { children: (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 1, children: (0, jsx_runtime_1.jsx)(First, {}) }) }) }));
63
- (0, vitest_1.expect)(container.outerHTML).toBe('<div></div>');
58
+ const outerHTML = renderForFrame(10, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsx)(series_1.Series, { children: (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 1, children: (0, jsx_runtime_1.jsx)(First, {}) }) }) }));
59
+ (0, vitest_1.expect)(outerHTML).toBe('');
64
60
  });
65
61
  (0, vitest_1.test)('Should throw if invalid or no duration provided', () => {
66
62
  (0, vitest_1.expect)(() => {
@@ -71,19 +67,19 @@ const renderForFrame = (frame, markup) => {
71
67
  }).toThrow(/The "durationInFrames" prop of a <Series.Sequence \/> component must be a number, but you passed a value of type undefined/);
72
68
  });
73
69
  (0, vitest_1.test)('Should allow whitespace', () => {
74
- const { queryByText } = renderForFrame(11, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 10, children: (0, jsx_runtime_1.jsx)(First, {}) }), ' ', (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 10, children: (0, jsx_runtime_1.jsx)(Second, {}) })] }) }));
75
- (0, vitest_1.expect)(queryByText(/^second\s1$/g)).not.toBe(null);
70
+ const outerHtml = renderForFrame(11, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 10, children: (0, jsx_runtime_1.jsx)(First, {}) }), ' ', (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 10, children: (0, jsx_runtime_1.jsx)(Second, {}) })] }) }));
71
+ (0, vitest_1.expect)(outerHtml).toBe('<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>second 1</div></div>');
76
72
  });
77
73
  (0, vitest_1.test)('Handle empty Series.Sequence', () => {
78
74
  (0, vitest_1.expect)(() => renderForFrame(11, (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 10, children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 10 })] }))).toThrow(/A <Series.Sequence \/> component \(index = 1, duration = 10\) was detected to not have any children\. Delete it to fix this error\./);
79
75
  });
80
76
  (0, vitest_1.test)('Should allow negative overlap prop', () => {
81
- const { container } = renderForFrame(4, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { offset: -1, layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) })] }) }));
82
- (0, vitest_1.expect)(container.outerHTML).toBe('<div><div>first 4</div><div>second 0</div></div>');
77
+ const outerHTML = renderForFrame(4, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { offset: -1, layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) })] }) }));
78
+ (0, vitest_1.expect)(outerHTML).toBe('<div>first 4</div><div>second 0</div>');
83
79
  });
84
80
  (0, vitest_1.test)('Should allow positive overlap prop', () => {
85
- const { container } = renderForFrame(5, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { offset: 1, layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) })] }) }));
86
- (0, vitest_1.expect)(container.outerHTML).toBe('<div></div>');
81
+ const outerHTML = renderForFrame(5, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { offset: 1, layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) })] }) }));
82
+ (0, vitest_1.expect)(outerHTML).toBe('');
87
83
  });
88
84
  (0, vitest_1.test)('Should disallow NaN as offset prop', () => {
89
85
  (0, vitest_1.expect)(() => {
@@ -101,10 +97,19 @@ const renderForFrame = (frame, markup) => {
101
97
  }).toThrow(/The "offset" property of a <Series.Sequence \/> must be finite, but got 3.141592653589793 \(index = 0, duration = 5\)\./);
102
98
  });
103
99
  (0, vitest_1.test)('Should cascade negative offset props', () => {
104
- const { container } = renderForFrame(9, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { offset: -1, layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Third, {}) })] }) }));
105
- (0, vitest_1.expect)(container.outerHTML).toBe('<div><div>third 0</div></div>');
100
+ const outerHTML = renderForFrame(9, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { offset: -1, layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Third, {}) })] }) }));
101
+ (0, vitest_1.expect)(outerHTML).toBe('<div>third 0</div>');
106
102
  });
107
103
  (0, vitest_1.test)('Should cascade positive offset props', () => {
108
- const { container } = renderForFrame(11, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { offset: 1, layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Third, {}) })] }) }));
109
- (0, vitest_1.expect)(container.outerHTML).toBe('<div><div>third 0</div></div>');
104
+ const outerHTML = renderForFrame(11, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, layout: "none", children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { offset: 1, layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { layout: "none", durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Third, {}) })] }) }));
105
+ (0, vitest_1.expect)(outerHTML).toBe('<div>third 0</div>');
106
+ });
107
+ (0, vitest_1.test)('Allow durationInFrames as Infinity for last Series.Sequence', () => {
108
+ const outerHTML = renderForFrame(10, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Second, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: Infinity, children: (0, jsx_runtime_1.jsx)(Third, {}) })] }) }));
109
+ (0, vitest_1.expect)(outerHTML).toBe('<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>third 0</div></div>');
110
+ });
111
+ (0, vitest_1.test)('Disallow durationInFrames as Infinity for first n-1 Series.Sequence', () => {
112
+ (0, vitest_1.expect)(() => {
113
+ renderForFrame(10, (0, jsx_runtime_1.jsx)(wrap_sequence_context_js_1.WrapSequenceContext, { children: (0, jsx_runtime_1.jsxs)(series_1.Series, { children: [(0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(First, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: Infinity, children: (0, jsx_runtime_1.jsx)(Second, {}) }), (0, jsx_runtime_1.jsx)(series_1.Series.Sequence, { durationInFrames: 5, children: (0, jsx_runtime_1.jsx)(Third, {}) })] }) }));
114
+ }).toThrow(/The "durationInFrames" prop of a <Series.Sequence \/> component must be an integer, but got Infinity\./);
110
115
  });
@@ -1 +1 @@
1
- export declare const VERSION = "3.3.51";
1
+ export declare const VERSION = "3.3.52";