@remotion/transitions 4.0.53
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.
- package/LICENSE.md +45 -0
- package/dist/TransitionSeries.d.ts +15 -0
- package/dist/TransitionSeries.js +150 -0
- package/dist/cjs/TransitionSeries.d.ts +15 -0
- package/dist/cjs/fade.js +24 -0
- package/dist/cjs/flatten-children.d.ts +2 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +282 -0
- package/dist/cjs/presentations/fade.d.ts +4 -0
- package/dist/cjs/presentations/slide.d.ts +7 -0
- package/dist/cjs/presentations/wipe.d.ts +7 -0
- package/dist/cjs/slide.js +72 -0
- package/dist/cjs/test/transitions.test.d.ts +1 -0
- package/dist/cjs/timings/linear-timing.d.ts +5 -0
- package/dist/cjs/timings/spring-timing.d.ts +7 -0
- package/dist/cjs/types.d.ts +27 -0
- package/dist/cjs/validate.d.ts +2 -0
- package/dist/cjs/wipe.js +158 -0
- package/dist/flatten-children.d.ts +2 -0
- package/dist/flatten-children.js +12 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/presentations/fade.d.ts +4 -0
- package/dist/presentations/fade.js +17 -0
- package/dist/presentations/slide.d.ts +7 -0
- package/dist/presentations/slide.js +65 -0
- package/dist/presentations/wipe.d.ts +7 -0
- package/dist/presentations/wipe.js +151 -0
- package/dist/timings/linear-timing.d.ts +5 -0
- package/dist/timings/linear-timing.js +15 -0
- package/dist/timings/spring-timing.d.ts +7 -0
- package/dist/timings/spring-timing.js +30 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.js +1 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +3 -0
- package/package.json +93 -0
- package/rollup.config.js +77 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Remotion License
|
|
2
|
+
|
|
3
|
+
Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
|
|
4
|
+
|
|
5
|
+
- [Free license](#free-license)
|
|
6
|
+
- [Company license](#company-license)
|
|
7
|
+
|
|
8
|
+
## Free license
|
|
9
|
+
|
|
10
|
+
Copyright © 2023 [Remotion](https://www.remotion.dev)
|
|
11
|
+
|
|
12
|
+
### Eligibility
|
|
13
|
+
|
|
14
|
+
You are eligible to use Remotion for free if you are:
|
|
15
|
+
|
|
16
|
+
- an individual
|
|
17
|
+
- a for-profit organization with up to 3 employees
|
|
18
|
+
- a non-profit or not-for-profit organization
|
|
19
|
+
- evaluating whether Remotion is a good fit, and are not yet using it in a commercial way
|
|
20
|
+
|
|
21
|
+
### Allowed use cases
|
|
22
|
+
|
|
23
|
+
Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify the software to their own liking, for the purpose of fulfilling their custom use case or to contribute bug fixes or improvements back to Remotion.
|
|
24
|
+
|
|
25
|
+
### Disallowed use cases
|
|
26
|
+
|
|
27
|
+
It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, or sublicensing your own derivate of Remotion.
|
|
28
|
+
|
|
29
|
+
### Warranty notice
|
|
30
|
+
|
|
31
|
+
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
|
|
32
|
+
|
|
33
|
+
### Support
|
|
34
|
+
|
|
35
|
+
Support is provided on a best-we-can-do basis via GitHub Issues and Discord.
|
|
36
|
+
|
|
37
|
+
## Company license
|
|
38
|
+
|
|
39
|
+
You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support (read the [Support Policy](https://www.remotion.dev/docs/support)).
|
|
40
|
+
|
|
41
|
+
Visit [remotion.pro](https://www.remotion.pro/license) for pricing and to buy a license.
|
|
42
|
+
|
|
43
|
+
### FAQs
|
|
44
|
+
|
|
45
|
+
Are you not sure whether you need a company license because of an edge case? Here are some [frequently asked questions](https://www.remotion.pro/faq).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FC, PropsWithChildren } from "react";
|
|
2
|
+
import type { LayoutAndStyle, SequencePropsWithoutDuration } from "remotion";
|
|
3
|
+
import type { TransitionSeriesTransitionProps } from "./types.js";
|
|
4
|
+
declare const TransitionSeriesTransition: <PresentationProps extends Record<string, unknown>>(_props: TransitionSeriesTransitionProps<PresentationProps>) => null;
|
|
5
|
+
type SeriesSequenceProps = PropsWithChildren<{
|
|
6
|
+
durationInFrames: number;
|
|
7
|
+
offset?: number;
|
|
8
|
+
className?: number;
|
|
9
|
+
} & LayoutAndStyle & Pick<SequencePropsWithoutDuration, "name">>;
|
|
10
|
+
declare const SeriesSequence: ({ children }: SeriesSequenceProps) => JSX.Element;
|
|
11
|
+
declare const TransitionSeries: FC<SequencePropsWithoutDuration> & {
|
|
12
|
+
Sequence: typeof SeriesSequence;
|
|
13
|
+
Transition: typeof TransitionSeriesTransition;
|
|
14
|
+
};
|
|
15
|
+
export { TransitionSeries };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Children, useMemo } from "react";
|
|
3
|
+
import { Sequence, useCurrentFrame, useVideoConfig } from "remotion";
|
|
4
|
+
import { slide } from "./presentations/slide.js";
|
|
5
|
+
import { flattenChildren } from "./flatten-children.js";
|
|
6
|
+
import { validateDurationInFrames } from "./validate.js";
|
|
7
|
+
// eslint-disable-next-line react/function-component-definition
|
|
8
|
+
const TransitionSeriesTransition = function (
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
+
_props) {
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
const SeriesSequence = ({ children }) => {
|
|
14
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
15
|
+
return _jsx(_Fragment, { children: children });
|
|
16
|
+
};
|
|
17
|
+
const TransitionSeriesChildren = ({ children, }) => {
|
|
18
|
+
const { fps } = useVideoConfig();
|
|
19
|
+
const frame = useCurrentFrame();
|
|
20
|
+
const childrenValue = useMemo(() => {
|
|
21
|
+
let transitionOffsets = 0;
|
|
22
|
+
let startFrame = 0;
|
|
23
|
+
const flattedChildren = flattenChildren(children);
|
|
24
|
+
return Children.map(flattedChildren, (child, i) => {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
26
|
+
const current = child;
|
|
27
|
+
if (typeof current === "string") {
|
|
28
|
+
// Don't throw if it's just some accidential whitespace
|
|
29
|
+
if (current.trim() === "") {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
throw new TypeError(`The <TransitionSeries /> component only accepts a list of <TransitionSeries.Sequence /> components as its children, but you passed a string "${current}"`);
|
|
33
|
+
}
|
|
34
|
+
const hasPrev = flattedChildren[i - 1];
|
|
35
|
+
const nextPrev = flattedChildren[i + 1];
|
|
36
|
+
const prev = typeof hasPrev === "string" || typeof hasPrev === "undefined"
|
|
37
|
+
? null
|
|
38
|
+
: hasPrev.type === TransitionSeriesTransition
|
|
39
|
+
? hasPrev
|
|
40
|
+
: null;
|
|
41
|
+
const next = typeof nextPrev === "string" || typeof nextPrev === "undefined"
|
|
42
|
+
? null
|
|
43
|
+
: nextPrev.type === TransitionSeriesTransition
|
|
44
|
+
? nextPrev
|
|
45
|
+
: null;
|
|
46
|
+
const prevIsTransition = typeof hasPrev === "string" || typeof hasPrev === "undefined"
|
|
47
|
+
? false
|
|
48
|
+
: hasPrev.type === TransitionSeriesTransition;
|
|
49
|
+
if (current.type === TransitionSeriesTransition) {
|
|
50
|
+
if (prevIsTransition) {
|
|
51
|
+
throw new TypeError(`A <TransitionSeries.Transition /> component must not be followed by another <TransitionSeries.Transition /> component (nth children = ${i - 1} and ${i})`);
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (current.type !== SeriesSequence) {
|
|
56
|
+
throw new TypeError(`The <TransitionSeries /> component only accepts a list of <TransitionSeries.Sequence /> and <TransitionSeries.Transition /> components as its children, but got ${current} instead`);
|
|
57
|
+
}
|
|
58
|
+
const castedChildAgain = current;
|
|
59
|
+
const debugInfo = `index = ${i}, duration = ${castedChildAgain.props.durationInFrames}`;
|
|
60
|
+
if (!(castedChildAgain === null || castedChildAgain === void 0 ? void 0 : castedChildAgain.props.children)) {
|
|
61
|
+
throw new TypeError(`A <TransitionSeries.Sequence /> component (${debugInfo}) was detected to not have any children. Delete it to fix this error.`);
|
|
62
|
+
}
|
|
63
|
+
const durationInFramesProp = castedChildAgain.props.durationInFrames;
|
|
64
|
+
const { durationInFrames, children: _children, ...passedProps } = castedChildAgain.props;
|
|
65
|
+
validateDurationInFrames(durationInFramesProp, {
|
|
66
|
+
component: `of a <TransitionSeries.Sequence /> component`,
|
|
67
|
+
allowFloats: true,
|
|
68
|
+
});
|
|
69
|
+
const offset = (_a = castedChildAgain.props.offset) !== null && _a !== void 0 ? _a : 0;
|
|
70
|
+
if (Number.isNaN(offset)) {
|
|
71
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must not be NaN, but got NaN (${debugInfo}).`);
|
|
72
|
+
}
|
|
73
|
+
if (!Number.isFinite(offset)) {
|
|
74
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
|
75
|
+
}
|
|
76
|
+
if (offset % 1 !== 0) {
|
|
77
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
|
78
|
+
}
|
|
79
|
+
const currentStartFrame = startFrame + offset;
|
|
80
|
+
let duration = 0;
|
|
81
|
+
if (prev) {
|
|
82
|
+
duration = prev.props.timing.getDurationInFrames({
|
|
83
|
+
fps,
|
|
84
|
+
});
|
|
85
|
+
transitionOffsets -= duration;
|
|
86
|
+
}
|
|
87
|
+
const actualStartFrame = currentStartFrame + transitionOffsets;
|
|
88
|
+
startFrame += durationInFramesProp + offset;
|
|
89
|
+
const inner = (_jsx(Sequence, { from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, ...passedProps, children: child }));
|
|
90
|
+
const nextProgress = next
|
|
91
|
+
? next.props.timing.getProgress({
|
|
92
|
+
frame: frame -
|
|
93
|
+
actualStartFrame -
|
|
94
|
+
durationInFrames +
|
|
95
|
+
next.props.timing.getDurationInFrames({ fps }),
|
|
96
|
+
fps,
|
|
97
|
+
})
|
|
98
|
+
: null;
|
|
99
|
+
const prevProgress = prev
|
|
100
|
+
? prev.props.timing.getProgress({
|
|
101
|
+
frame: frame - actualStartFrame,
|
|
102
|
+
fps,
|
|
103
|
+
})
|
|
104
|
+
: null;
|
|
105
|
+
if (next &&
|
|
106
|
+
durationInFramesProp < next.props.timing.getDurationInFrames({ fps })) {
|
|
107
|
+
throw new Error(`The duration of a <TransitionSeries.Sequence /> must not be shorter than the duration of the next <TransitionSeries.Transition />. The transition is ${next.props.timing.getDurationInFrames({ fps })} frames long, but the sequence is only ${durationInFramesProp} frames long (${debugInfo})`);
|
|
108
|
+
}
|
|
109
|
+
if (prev &&
|
|
110
|
+
durationInFramesProp < prev.props.timing.getDurationInFrames({ fps })) {
|
|
111
|
+
throw new Error(`The duration of a <TransitionSeries.Sequence /> must not be shorter than the duration of the previous <TransitionSeries.Transition />. The transition is ${prev.props.timing.getDurationInFrames({ fps })} frames long, but the sequence is only ${durationInFramesProp} frames long (${debugInfo})`);
|
|
112
|
+
}
|
|
113
|
+
if (next && prev && nextProgress !== null && prevProgress !== null) {
|
|
114
|
+
const nextPresentation = (_b = next.props.presentation) !== null && _b !== void 0 ? _b : slide();
|
|
115
|
+
const prevPresentation = (_c = prev.props.presentation) !== null && _c !== void 0 ? _c : slide();
|
|
116
|
+
const UppercaseNextPresentation = nextPresentation.component;
|
|
117
|
+
const UppercasePrevPresentation = prevPresentation.component;
|
|
118
|
+
return (
|
|
119
|
+
// @ts-expect-error
|
|
120
|
+
_jsx(UppercaseNextPresentation, { passedProps: (_d = nextPresentation.props) !== null && _d !== void 0 ? _d : {}, presentationDirection: "exiting", presentationProgress: nextProgress, children: _jsx(UppercasePrevPresentation, { passedProps: (_e = prevPresentation.props) !== null && _e !== void 0 ? _e : {}, presentationDirection: "entering", presentationProgress: prevProgress, children: inner }) }));
|
|
121
|
+
}
|
|
122
|
+
if (prevProgress !== null && prev) {
|
|
123
|
+
const prevPresentation = (_f = prev.props.presentation) !== null && _f !== void 0 ? _f : slide();
|
|
124
|
+
const UppercasePrevPresentation = prevPresentation.component;
|
|
125
|
+
return (
|
|
126
|
+
// @ts-expect-error
|
|
127
|
+
_jsx(UppercasePrevPresentation, { passedProps: (_g = prevPresentation.props) !== null && _g !== void 0 ? _g : {}, presentationDirection: "entering", presentationProgress: prevProgress, children: inner }));
|
|
128
|
+
}
|
|
129
|
+
if (nextProgress !== null && next) {
|
|
130
|
+
const nextPresentation = (_h = next.props.presentation) !== null && _h !== void 0 ? _h : slide();
|
|
131
|
+
const UppercaseNextPresentation = nextPresentation.component;
|
|
132
|
+
return (
|
|
133
|
+
// @ts-expect-error
|
|
134
|
+
_jsx(UppercaseNextPresentation, { passedProps: (_j = nextPresentation.props) !== null && _j !== void 0 ? _j : {}, presentationDirection: "exiting", presentationProgress: nextProgress, children: inner }));
|
|
135
|
+
}
|
|
136
|
+
return inner;
|
|
137
|
+
});
|
|
138
|
+
}, [children, fps, frame]);
|
|
139
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
140
|
+
return _jsx(_Fragment, { children: childrenValue });
|
|
141
|
+
};
|
|
142
|
+
const TransitionSeries = ({ children, ...otherProps }) => {
|
|
143
|
+
var _a;
|
|
144
|
+
const frame = useCurrentFrame();
|
|
145
|
+
const showInTimeline = frame < ((_a = otherProps.from) !== null && _a !== void 0 ? _a : 0);
|
|
146
|
+
return (_jsx(Sequence, { showInTimeline: showInTimeline, ...otherProps, children: _jsx(TransitionSeriesChildren, { children: children }) }));
|
|
147
|
+
};
|
|
148
|
+
TransitionSeries.Sequence = SeriesSequence;
|
|
149
|
+
TransitionSeries.Transition = TransitionSeriesTransition;
|
|
150
|
+
export { TransitionSeries };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FC, PropsWithChildren } from "react";
|
|
2
|
+
import type { LayoutAndStyle, SequencePropsWithoutDuration } from "remotion";
|
|
3
|
+
import type { TransitionSeriesTransitionProps } from "./types.js";
|
|
4
|
+
declare const TransitionSeriesTransition: <PresentationProps extends Record<string, unknown>>(_props: TransitionSeriesTransitionProps<PresentationProps>) => null;
|
|
5
|
+
type SeriesSequenceProps = PropsWithChildren<{
|
|
6
|
+
durationInFrames: number;
|
|
7
|
+
offset?: number;
|
|
8
|
+
className?: number;
|
|
9
|
+
} & LayoutAndStyle & Pick<SequencePropsWithoutDuration, "name">>;
|
|
10
|
+
declare const SeriesSequence: ({ children }: SeriesSequenceProps) => JSX.Element;
|
|
11
|
+
declare const TransitionSeries: FC<SequencePropsWithoutDuration> & {
|
|
12
|
+
Sequence: typeof SeriesSequence;
|
|
13
|
+
Transition: typeof TransitionSeriesTransition;
|
|
14
|
+
};
|
|
15
|
+
export { TransitionSeries };
|
package/dist/cjs/fade.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var remotion = require('remotion');
|
|
8
|
+
|
|
9
|
+
const FadePresentation = ({ children, presentationDirection, presentationProgress }) => {
|
|
10
|
+
const style = react.useMemo(() => {
|
|
11
|
+
return {
|
|
12
|
+
opacity: presentationDirection === "entering" ? presentationProgress : 1,
|
|
13
|
+
};
|
|
14
|
+
}, [presentationDirection, presentationProgress]);
|
|
15
|
+
return (jsxRuntime.jsx(remotion.AbsoluteFill, { children: jsxRuntime.jsx(remotion.AbsoluteFill, { style: style, children: children }) }));
|
|
16
|
+
};
|
|
17
|
+
const fade = (props) => {
|
|
18
|
+
return {
|
|
19
|
+
component: FadePresentation,
|
|
20
|
+
props: props !== null && props !== void 0 ? props : {},
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.fade = fade;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { springTiming } from './timings/spring-timing.js';
|
|
2
|
+
export { linearTiming } from "./timings/linear-timing.js";
|
|
3
|
+
export { TransitionSeries } from "./TransitionSeries.js";
|
|
4
|
+
export { TransitionTiming, TransitionPresentation, TransitionPresentationComponentProps, } from "./types.js";
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var remotion = require('remotion');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
|
|
13
|
+
const springWithInvalidArgumentRejection = (args) => {
|
|
14
|
+
if (args.to || args.from) {
|
|
15
|
+
throw new Error("to / from values are not supported by springWithRoundUpIfThreshold");
|
|
16
|
+
}
|
|
17
|
+
return remotion.spring(args);
|
|
18
|
+
};
|
|
19
|
+
const springTiming = (options = {}) => {
|
|
20
|
+
return {
|
|
21
|
+
getDurationInFrames: ({ fps }) => {
|
|
22
|
+
if (options.durationInFrames) {
|
|
23
|
+
return options.durationInFrames;
|
|
24
|
+
}
|
|
25
|
+
return remotion.measureSpring({
|
|
26
|
+
config: options.config,
|
|
27
|
+
threshold: options.durationRestThreshold,
|
|
28
|
+
fps,
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
getProgress: ({ fps, frame }) => {
|
|
32
|
+
return springWithInvalidArgumentRejection({
|
|
33
|
+
fps,
|
|
34
|
+
frame,
|
|
35
|
+
config: options.config,
|
|
36
|
+
durationInFrames: options.durationInFrames,
|
|
37
|
+
durationRestThreshold: options.durationRestThreshold,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const linearTiming = (options) => {
|
|
44
|
+
return {
|
|
45
|
+
getDurationInFrames: () => {
|
|
46
|
+
return options.durationInFrames;
|
|
47
|
+
},
|
|
48
|
+
getProgress: ({ frame }) => {
|
|
49
|
+
return remotion.interpolate(frame, [0, options.durationInFrames], [0, 1], {
|
|
50
|
+
easing: options.easing,
|
|
51
|
+
extrapolateLeft: 'clamp',
|
|
52
|
+
extrapolateRight: 'clamp',
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const SlidePresentation = ({ children, presentationProgress, presentationDirection, passedProps: { direction = "from-left" }, }) => {
|
|
59
|
+
const directionStyle = React.useMemo(() => {
|
|
60
|
+
if (presentationDirection === "exiting") {
|
|
61
|
+
switch (direction) {
|
|
62
|
+
case "from-left":
|
|
63
|
+
return {
|
|
64
|
+
transform: `translateX(${presentationProgress * 100}%)`,
|
|
65
|
+
};
|
|
66
|
+
case "from-right":
|
|
67
|
+
return {
|
|
68
|
+
transform: `translateX(-${presentationProgress * 100}%)`,
|
|
69
|
+
};
|
|
70
|
+
case "from-top":
|
|
71
|
+
return {
|
|
72
|
+
transform: `translateY(${presentationProgress * 100}%)`,
|
|
73
|
+
};
|
|
74
|
+
case "from-bottom":
|
|
75
|
+
return {
|
|
76
|
+
transform: `translateY(-${presentationProgress * 100}%)`,
|
|
77
|
+
};
|
|
78
|
+
default:
|
|
79
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
switch (direction) {
|
|
83
|
+
case "from-left":
|
|
84
|
+
return {
|
|
85
|
+
transform: `translateX(${-100 + presentationProgress * 100}%)`,
|
|
86
|
+
};
|
|
87
|
+
case "from-right":
|
|
88
|
+
return {
|
|
89
|
+
transform: `translateX(${100 - presentationProgress * 100}%)`,
|
|
90
|
+
};
|
|
91
|
+
case "from-top":
|
|
92
|
+
return {
|
|
93
|
+
transform: `translateY(${-100 + presentationProgress * 100}%)`,
|
|
94
|
+
};
|
|
95
|
+
case "from-bottom":
|
|
96
|
+
return {
|
|
97
|
+
transform: `translateY(${100 - presentationProgress * 100}%)`,
|
|
98
|
+
};
|
|
99
|
+
default:
|
|
100
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
101
|
+
}
|
|
102
|
+
}, [presentationDirection, presentationProgress, direction]);
|
|
103
|
+
const style = React.useMemo(() => {
|
|
104
|
+
return {
|
|
105
|
+
width: "100%",
|
|
106
|
+
height: "100%",
|
|
107
|
+
justifyContent: "center",
|
|
108
|
+
alignItems: "center",
|
|
109
|
+
...directionStyle,
|
|
110
|
+
};
|
|
111
|
+
}, [directionStyle]);
|
|
112
|
+
return (jsxRuntime.jsx(remotion.AbsoluteFill, { children: jsxRuntime.jsx(remotion.AbsoluteFill, { style: style, children: children }) }));
|
|
113
|
+
};
|
|
114
|
+
const slide = (props) => {
|
|
115
|
+
return {
|
|
116
|
+
component: SlidePresentation,
|
|
117
|
+
props: props !== null && props !== void 0 ? props : {},
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const flattenChildren = (children) => {
|
|
122
|
+
const childrenArray = React__default["default"].Children.toArray(children);
|
|
123
|
+
return childrenArray.reduce((flatChildren, child) => {
|
|
124
|
+
if (child.type === React__default["default"].Fragment) {
|
|
125
|
+
return flatChildren.concat(flattenChildren(child.props
|
|
126
|
+
.children));
|
|
127
|
+
}
|
|
128
|
+
flatChildren.push(child);
|
|
129
|
+
return flatChildren;
|
|
130
|
+
}, []);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/* eslint-disable prefer-destructuring */
|
|
134
|
+
const validateDurationInFrames = remotion.Internals.validateDurationInFrames;
|
|
135
|
+
|
|
136
|
+
// eslint-disable-next-line react/function-component-definition
|
|
137
|
+
const TransitionSeriesTransition = function (
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
139
|
+
_props) {
|
|
140
|
+
return null;
|
|
141
|
+
};
|
|
142
|
+
const SeriesSequence = ({ children }) => {
|
|
143
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
144
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
145
|
+
};
|
|
146
|
+
const TransitionSeriesChildren = ({ children, }) => {
|
|
147
|
+
const { fps } = remotion.useVideoConfig();
|
|
148
|
+
const frame = remotion.useCurrentFrame();
|
|
149
|
+
const childrenValue = React.useMemo(() => {
|
|
150
|
+
let transitionOffsets = 0;
|
|
151
|
+
let startFrame = 0;
|
|
152
|
+
const flattedChildren = flattenChildren(children);
|
|
153
|
+
return React.Children.map(flattedChildren, (child, i) => {
|
|
154
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
155
|
+
const current = child;
|
|
156
|
+
if (typeof current === "string") {
|
|
157
|
+
// Don't throw if it's just some accidential whitespace
|
|
158
|
+
if (current.trim() === "") {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
throw new TypeError(`The <TransitionSeries /> component only accepts a list of <TransitionSeries.Sequence /> components as its children, but you passed a string "${current}"`);
|
|
162
|
+
}
|
|
163
|
+
const hasPrev = flattedChildren[i - 1];
|
|
164
|
+
const nextPrev = flattedChildren[i + 1];
|
|
165
|
+
const prev = typeof hasPrev === "string" || typeof hasPrev === "undefined"
|
|
166
|
+
? null
|
|
167
|
+
: hasPrev.type === TransitionSeriesTransition
|
|
168
|
+
? hasPrev
|
|
169
|
+
: null;
|
|
170
|
+
const next = typeof nextPrev === "string" || typeof nextPrev === "undefined"
|
|
171
|
+
? null
|
|
172
|
+
: nextPrev.type === TransitionSeriesTransition
|
|
173
|
+
? nextPrev
|
|
174
|
+
: null;
|
|
175
|
+
const prevIsTransition = typeof hasPrev === "string" || typeof hasPrev === "undefined"
|
|
176
|
+
? false
|
|
177
|
+
: hasPrev.type === TransitionSeriesTransition;
|
|
178
|
+
if (current.type === TransitionSeriesTransition) {
|
|
179
|
+
if (prevIsTransition) {
|
|
180
|
+
throw new TypeError(`A <TransitionSeries.Transition /> component must not be followed by another <TransitionSeries.Transition /> component (nth children = ${i - 1} and ${i})`);
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
if (current.type !== SeriesSequence) {
|
|
185
|
+
throw new TypeError(`The <TransitionSeries /> component only accepts a list of <TransitionSeries.Sequence /> and <TransitionSeries.Transition /> components as its children, but got ${current} instead`);
|
|
186
|
+
}
|
|
187
|
+
const castedChildAgain = current;
|
|
188
|
+
const debugInfo = `index = ${i}, duration = ${castedChildAgain.props.durationInFrames}`;
|
|
189
|
+
if (!(castedChildAgain === null || castedChildAgain === void 0 ? void 0 : castedChildAgain.props.children)) {
|
|
190
|
+
throw new TypeError(`A <TransitionSeries.Sequence /> component (${debugInfo}) was detected to not have any children. Delete it to fix this error.`);
|
|
191
|
+
}
|
|
192
|
+
const durationInFramesProp = castedChildAgain.props.durationInFrames;
|
|
193
|
+
const { durationInFrames, children: _children, ...passedProps } = castedChildAgain.props;
|
|
194
|
+
validateDurationInFrames(durationInFramesProp, {
|
|
195
|
+
component: `of a <TransitionSeries.Sequence /> component`,
|
|
196
|
+
allowFloats: true,
|
|
197
|
+
});
|
|
198
|
+
const offset = (_a = castedChildAgain.props.offset) !== null && _a !== void 0 ? _a : 0;
|
|
199
|
+
if (Number.isNaN(offset)) {
|
|
200
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must not be NaN, but got NaN (${debugInfo}).`);
|
|
201
|
+
}
|
|
202
|
+
if (!Number.isFinite(offset)) {
|
|
203
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
|
204
|
+
}
|
|
205
|
+
if (offset % 1 !== 0) {
|
|
206
|
+
throw new TypeError(`The "offset" property of a <TransitionSeries.Sequence /> must be finite, but got ${offset} (${debugInfo}).`);
|
|
207
|
+
}
|
|
208
|
+
const currentStartFrame = startFrame + offset;
|
|
209
|
+
let duration = 0;
|
|
210
|
+
if (prev) {
|
|
211
|
+
duration = prev.props.timing.getDurationInFrames({
|
|
212
|
+
fps,
|
|
213
|
+
});
|
|
214
|
+
transitionOffsets -= duration;
|
|
215
|
+
}
|
|
216
|
+
const actualStartFrame = currentStartFrame + transitionOffsets;
|
|
217
|
+
startFrame += durationInFramesProp + offset;
|
|
218
|
+
const inner = (jsxRuntime.jsx(remotion.Sequence, { from: Math.floor(actualStartFrame), durationInFrames: durationInFramesProp, ...passedProps, children: child }));
|
|
219
|
+
const nextProgress = next
|
|
220
|
+
? next.props.timing.getProgress({
|
|
221
|
+
frame: frame -
|
|
222
|
+
actualStartFrame -
|
|
223
|
+
durationInFrames +
|
|
224
|
+
next.props.timing.getDurationInFrames({ fps }),
|
|
225
|
+
fps,
|
|
226
|
+
})
|
|
227
|
+
: null;
|
|
228
|
+
const prevProgress = prev
|
|
229
|
+
? prev.props.timing.getProgress({
|
|
230
|
+
frame: frame - actualStartFrame,
|
|
231
|
+
fps,
|
|
232
|
+
})
|
|
233
|
+
: null;
|
|
234
|
+
if (next &&
|
|
235
|
+
durationInFramesProp < next.props.timing.getDurationInFrames({ fps })) {
|
|
236
|
+
throw new Error(`The duration of a <TransitionSeries.Sequence /> must not be shorter than the duration of the next <TransitionSeries.Transition />. The transition is ${next.props.timing.getDurationInFrames({ fps })} frames long, but the sequence is only ${durationInFramesProp} frames long (${debugInfo})`);
|
|
237
|
+
}
|
|
238
|
+
if (prev &&
|
|
239
|
+
durationInFramesProp < prev.props.timing.getDurationInFrames({ fps })) {
|
|
240
|
+
throw new Error(`The duration of a <TransitionSeries.Sequence /> must not be shorter than the duration of the previous <TransitionSeries.Transition />. The transition is ${prev.props.timing.getDurationInFrames({ fps })} frames long, but the sequence is only ${durationInFramesProp} frames long (${debugInfo})`);
|
|
241
|
+
}
|
|
242
|
+
if (next && prev && nextProgress !== null && prevProgress !== null) {
|
|
243
|
+
const nextPresentation = (_b = next.props.presentation) !== null && _b !== void 0 ? _b : slide();
|
|
244
|
+
const prevPresentation = (_c = prev.props.presentation) !== null && _c !== void 0 ? _c : slide();
|
|
245
|
+
const UppercaseNextPresentation = nextPresentation.component;
|
|
246
|
+
const UppercasePrevPresentation = prevPresentation.component;
|
|
247
|
+
return (
|
|
248
|
+
// @ts-expect-error
|
|
249
|
+
jsxRuntime.jsx(UppercaseNextPresentation, { passedProps: (_d = nextPresentation.props) !== null && _d !== void 0 ? _d : {}, presentationDirection: "exiting", presentationProgress: nextProgress, children: jsxRuntime.jsx(UppercasePrevPresentation, { passedProps: (_e = prevPresentation.props) !== null && _e !== void 0 ? _e : {}, presentationDirection: "entering", presentationProgress: prevProgress, children: inner }) }));
|
|
250
|
+
}
|
|
251
|
+
if (prevProgress !== null && prev) {
|
|
252
|
+
const prevPresentation = (_f = prev.props.presentation) !== null && _f !== void 0 ? _f : slide();
|
|
253
|
+
const UppercasePrevPresentation = prevPresentation.component;
|
|
254
|
+
return (
|
|
255
|
+
// @ts-expect-error
|
|
256
|
+
jsxRuntime.jsx(UppercasePrevPresentation, { passedProps: (_g = prevPresentation.props) !== null && _g !== void 0 ? _g : {}, presentationDirection: "entering", presentationProgress: prevProgress, children: inner }));
|
|
257
|
+
}
|
|
258
|
+
if (nextProgress !== null && next) {
|
|
259
|
+
const nextPresentation = (_h = next.props.presentation) !== null && _h !== void 0 ? _h : slide();
|
|
260
|
+
const UppercaseNextPresentation = nextPresentation.component;
|
|
261
|
+
return (
|
|
262
|
+
// @ts-expect-error
|
|
263
|
+
jsxRuntime.jsx(UppercaseNextPresentation, { passedProps: (_j = nextPresentation.props) !== null && _j !== void 0 ? _j : {}, presentationDirection: "exiting", presentationProgress: nextProgress, children: inner }));
|
|
264
|
+
}
|
|
265
|
+
return inner;
|
|
266
|
+
});
|
|
267
|
+
}, [children, fps, frame]);
|
|
268
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
269
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: childrenValue });
|
|
270
|
+
};
|
|
271
|
+
const TransitionSeries = ({ children, ...otherProps }) => {
|
|
272
|
+
var _a;
|
|
273
|
+
const frame = remotion.useCurrentFrame();
|
|
274
|
+
const showInTimeline = frame < ((_a = otherProps.from) !== null && _a !== void 0 ? _a : 0);
|
|
275
|
+
return (jsxRuntime.jsx(remotion.Sequence, { showInTimeline: showInTimeline, ...otherProps, children: jsxRuntime.jsx(TransitionSeriesChildren, { children: children }) }));
|
|
276
|
+
};
|
|
277
|
+
TransitionSeries.Sequence = SeriesSequence;
|
|
278
|
+
TransitionSeries.Transition = TransitionSeriesTransition;
|
|
279
|
+
|
|
280
|
+
exports.TransitionSeries = TransitionSeries;
|
|
281
|
+
exports.linearTiming = linearTiming;
|
|
282
|
+
exports.springTiming = springTiming;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransitionPresentation } from "../types.js";
|
|
2
|
+
export type SlideDirection = "from-left" | "from-top" | "from-right" | "from-bottom";
|
|
3
|
+
type SlideProps = {
|
|
4
|
+
direction?: SlideDirection;
|
|
5
|
+
};
|
|
6
|
+
export declare const slide: (props?: SlideProps) => TransitionPresentation<SlideProps>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransitionPresentation } from "../types.js";
|
|
2
|
+
export type WipeDirection = "from-left" | "from-top-left" | "from-top" | "from-top-right" | "from-right" | "from-bottom-right" | "from-bottom" | "from-bottom-left";
|
|
3
|
+
type WipeProps = {
|
|
4
|
+
direction?: WipeDirection;
|
|
5
|
+
};
|
|
6
|
+
export declare const wipe: (props?: WipeProps) => TransitionPresentation<WipeProps>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var remotion = require('remotion');
|
|
8
|
+
|
|
9
|
+
const SlidePresentation = ({ children, presentationProgress, presentationDirection, passedProps: { direction = "from-left" }, }) => {
|
|
10
|
+
const directionStyle = react.useMemo(() => {
|
|
11
|
+
if (presentationDirection === "exiting") {
|
|
12
|
+
switch (direction) {
|
|
13
|
+
case "from-left":
|
|
14
|
+
return {
|
|
15
|
+
transform: `translateX(${presentationProgress * 100}%)`,
|
|
16
|
+
};
|
|
17
|
+
case "from-right":
|
|
18
|
+
return {
|
|
19
|
+
transform: `translateX(-${presentationProgress * 100}%)`,
|
|
20
|
+
};
|
|
21
|
+
case "from-top":
|
|
22
|
+
return {
|
|
23
|
+
transform: `translateY(${presentationProgress * 100}%)`,
|
|
24
|
+
};
|
|
25
|
+
case "from-bottom":
|
|
26
|
+
return {
|
|
27
|
+
transform: `translateY(-${presentationProgress * 100}%)`,
|
|
28
|
+
};
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
switch (direction) {
|
|
34
|
+
case "from-left":
|
|
35
|
+
return {
|
|
36
|
+
transform: `translateX(${-100 + presentationProgress * 100}%)`,
|
|
37
|
+
};
|
|
38
|
+
case "from-right":
|
|
39
|
+
return {
|
|
40
|
+
transform: `translateX(${100 - presentationProgress * 100}%)`,
|
|
41
|
+
};
|
|
42
|
+
case "from-top":
|
|
43
|
+
return {
|
|
44
|
+
transform: `translateY(${-100 + presentationProgress * 100}%)`,
|
|
45
|
+
};
|
|
46
|
+
case "from-bottom":
|
|
47
|
+
return {
|
|
48
|
+
transform: `translateY(${100 - presentationProgress * 100}%)`,
|
|
49
|
+
};
|
|
50
|
+
default:
|
|
51
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
52
|
+
}
|
|
53
|
+
}, [presentationDirection, presentationProgress, direction]);
|
|
54
|
+
const style = react.useMemo(() => {
|
|
55
|
+
return {
|
|
56
|
+
width: "100%",
|
|
57
|
+
height: "100%",
|
|
58
|
+
justifyContent: "center",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
...directionStyle,
|
|
61
|
+
};
|
|
62
|
+
}, [directionStyle]);
|
|
63
|
+
return (jsxRuntime.jsx(remotion.AbsoluteFill, { children: jsxRuntime.jsx(remotion.AbsoluteFill, { style: style, children: children }) }));
|
|
64
|
+
};
|
|
65
|
+
const slide = (props) => {
|
|
66
|
+
return {
|
|
67
|
+
component: SlidePresentation,
|
|
68
|
+
props: props !== null && props !== void 0 ? props : {},
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.slide = slide;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SpringConfig } from "remotion";
|
|
2
|
+
import type { TransitionTiming } from "../types.js";
|
|
3
|
+
export declare const springTiming: (options?: {
|
|
4
|
+
config?: Partial<SpringConfig>;
|
|
5
|
+
durationInFrames?: number;
|
|
6
|
+
durationRestThreshold?: number;
|
|
7
|
+
}) => TransitionTiming;
|