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.
- package/dist/AbsoluteFill.d.ts +6 -0
- package/dist/AbsoluteFill.js +28 -0
- package/dist/CanUseRemotionHooks.d.ts +5 -0
- package/dist/CanUseRemotionHooks.js +10 -0
- package/dist/Clipper.d.ts +7 -0
- package/dist/Clipper.js +24 -0
- package/dist/Composition.d.ts +23 -0
- package/dist/Composition.js +113 -0
- package/dist/CompositionManager.d.ts +82 -0
- package/dist/CompositionManager.js +164 -0
- package/dist/Folder.d.ts +15 -0
- package/dist/Folder.js +33 -0
- package/dist/IFrame.d.ts +2 -0
- package/dist/IFrame.js +24 -0
- package/dist/Img.d.ts +2 -0
- package/dist/Img.js +52 -0
- package/dist/NativeLayers.d.ts +13 -0
- package/dist/NativeLayers.js +29 -0
- package/dist/Null.d.ts +2 -0
- package/dist/Null.js +25 -0
- package/dist/RemotionRoot.d.ts +5 -0
- package/dist/RemotionRoot.js +73 -0
- package/dist/Sequence.d.ts +29 -0
- package/dist/Sequence.js +131 -0
- package/dist/Still.d.ts +2 -0
- package/dist/Still.js +9 -0
- package/dist/absolute-src.d.ts +1 -0
- package/dist/absolute-src.js +7 -0
- package/dist/asset-types.d.ts +50 -0
- package/dist/asset-types.js +1 -0
- package/dist/audio/Audio.d.ts +8 -0
- package/dist/audio/Audio.js +52 -0
- package/dist/audio/AudioForDevelopment.d.ts +11 -0
- package/dist/audio/AudioForDevelopment.js +94 -0
- package/dist/audio/AudioForRendering.d.ts +10 -0
- package/dist/audio/AudioForRendering.js +111 -0
- package/dist/audio/index.d.ts +2 -0
- package/dist/audio/index.js +18 -0
- package/dist/audio/props.d.ts +12 -0
- package/dist/audio/props.js +2 -0
- package/dist/audio/shared-audio-tags.d.ts +37 -0
- package/dist/audio/shared-audio-tags.js +222 -0
- package/dist/audio/use-audio-frame.d.ts +6 -0
- package/dist/audio/use-audio-frame.js +23 -0
- package/dist/bezier.d.ts +1 -0
- package/dist/bezier.js +114 -0
- package/dist/cancel-render.d.ts +1 -0
- package/dist/cancel-render.js +43 -0
- package/dist/cjs/series/index.js +5 -2
- package/dist/cjs/test/series.test.js +32 -27
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/config/input-props.d.ts +1 -0
- package/dist/config/input-props.js +31 -0
- package/dist/config.d.ts +285 -0
- package/dist/config.js +21 -0
- package/dist/default-css.d.ts +3 -0
- package/dist/default-css.js +49 -0
- package/dist/delay-render.d.ts +14 -0
- package/dist/delay-render.js +77 -0
- package/dist/easing.d.ts +19 -0
- package/dist/easing.js +77 -0
- package/dist/esm/series/index.js +5 -2
- package/dist/esm/test/series.test.js +32 -27
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/freeze.d.ts +7 -0
- package/dist/freeze.js +34 -0
- package/dist/get-asset-file-name.d.ts +1 -0
- package/dist/get-asset-file-name.js +14 -0
- package/dist/get-environment.d.ts +3 -0
- package/dist/get-environment.js +34 -0
- package/dist/get-preview-dom-element.d.ts +1 -0
- package/dist/get-preview-dom-element.js +7 -0
- package/dist/get-static-files.d.ts +17 -0
- package/dist/get-static-files.js +31 -0
- package/dist/get-timeline-clip-name.d.ts +1 -0
- package/dist/get-timeline-clip-name.js +25 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +73 -0
- package/dist/internals.d.ts +97 -0
- package/dist/internals.js +99 -0
- package/dist/interpolate-colors.d.ts +5 -0
- package/dist/interpolate-colors.js +401 -0
- package/dist/interpolate.d.ts +18 -0
- package/dist/interpolate.js +123 -0
- package/dist/is-approximately-the-same.d.ts +1 -0
- package/dist/is-approximately-the-same.js +8 -0
- package/dist/is-player.d.ts +3 -0
- package/dist/is-player.js +14 -0
- package/dist/loading-indicator.d.ts +2 -0
- package/dist/loading-indicator.js +35 -0
- package/dist/loop/index.d.ts +9 -0
- package/dist/loop/index.js +29 -0
- package/dist/multiple-versions-warning.d.ts +1 -0
- package/dist/multiple-versions-warning.js +32 -0
- package/dist/nonce.d.ts +7 -0
- package/dist/nonce.js +17 -0
- package/dist/play-and-handle-not-allowed-error.d.ts +2 -0
- package/dist/play-and-handle-not-allowed-error.js +44 -0
- package/dist/portal-node.d.ts +1 -0
- package/dist/portal-node.js +23 -0
- package/dist/prefetch-state.d.ts +8 -0
- package/dist/prefetch-state.js +27 -0
- package/dist/prefetch.d.ts +9 -0
- package/dist/prefetch.js +108 -0
- package/dist/random.d.ts +7 -0
- package/dist/random.js +41 -0
- package/dist/register-root.d.ts +4 -0
- package/dist/register-root.js +33 -0
- package/dist/series/flatten-children.d.ts +2 -0
- package/dist/series/flatten-children.js +19 -0
- package/dist/series/index.d.ts +13 -0
- package/dist/series/index.js +60 -0
- package/dist/setup-env-variables.d.ts +2 -0
- package/dist/setup-env-variables.js +36 -0
- package/dist/spring/index.d.ts +27 -0
- package/dist/spring/index.js +51 -0
- package/dist/spring/measure-spring.d.ts +8 -0
- package/dist/spring/measure-spring.js +64 -0
- package/dist/spring/spring-utils.d.ts +21 -0
- package/dist/spring/spring-utils.js +103 -0
- package/dist/static-file.d.ts +5 -0
- package/dist/static-file.js +33 -0
- package/dist/timeline-position-state.d.ts +29 -0
- package/dist/timeline-position-state.js +41 -0
- package/dist/truthy.d.ts +3 -0
- package/dist/truthy.js +7 -0
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/use-current-frame.d.ts +6 -0
- package/dist/use-current-frame.js +28 -0
- package/dist/use-lazy-component.d.ts +7 -0
- package/dist/use-lazy-component.js +49 -0
- package/dist/use-media-in-timeline.d.ts +10 -0
- package/dist/use-media-in-timeline.js +129 -0
- package/dist/use-media-playback.d.ts +10 -0
- package/dist/use-media-playback.js +77 -0
- package/dist/use-media-tag-volume.d.ts +2 -0
- package/dist/use-media-tag-volume.js +31 -0
- package/dist/use-sync-volume-with-media-tag.d.ts +10 -0
- package/dist/use-sync-volume-with-media-tag.js +21 -0
- package/dist/use-unsafe-video-config.d.ts +2 -0
- package/dist/use-unsafe-video-config.js +27 -0
- package/dist/use-video-config.d.ts +7 -0
- package/dist/use-video-config.js +29 -0
- package/dist/use-video.d.ts +12 -0
- package/dist/use-video.js +28 -0
- package/dist/validate-media-props.d.ts +4 -0
- package/dist/validate-media-props.js +24 -0
- package/dist/validate-start-from-props.d.ts +1 -0
- package/dist/validate-start-from-props.js +31 -0
- package/dist/validation/validate-composition-id.d.ts +3 -0
- package/dist/validation/validate-composition-id.js +13 -0
- package/dist/validation/validate-dimensions.d.ts +1 -0
- package/dist/validation/validate-dimensions.js +21 -0
- package/dist/validation/validate-duration-in-frames.d.ts +1 -0
- package/dist/validation/validate-duration-in-frames.js +15 -0
- package/dist/validation/validate-folder-name.d.ts +3 -0
- package/dist/validation/validate-folder-name.js +19 -0
- package/dist/validation/validate-fps.d.ts +1 -0
- package/dist/validation/validate-fps.js +21 -0
- package/dist/validation/validate-offthreadvideo-image-format.d.ts +1 -0
- package/dist/validation/validate-offthreadvideo-image-format.js +15 -0
- package/dist/validation/validation-spring-duration.d.ts +1 -0
- package/dist/validation/validation-spring-duration.js +21 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/video/OffthreadVideo.d.ts +3 -0
- package/dist/video/OffthreadVideo.js +33 -0
- package/dist/video/OffthreadVideoForRendering.d.ts +3 -0
- package/dist/video/OffthreadVideoForRendering.js +104 -0
- package/dist/video/Video.d.ts +8 -0
- package/dist/video/Video.js +50 -0
- package/dist/video/VideoForDevelopment.d.ts +11 -0
- package/dist/video/VideoForDevelopment.js +113 -0
- package/dist/video/VideoForRendering.d.ts +10 -0
- package/dist/video/VideoForRendering.js +203 -0
- package/dist/video/duration-state.d.ts +17 -0
- package/dist/video/duration-state.js +34 -0
- package/dist/video/get-current-time.d.ts +13 -0
- package/dist/video/get-current-time.js +31 -0
- package/dist/video/index.d.ts +3 -0
- package/dist/video/index.js +7 -0
- package/dist/video/props.d.ts +25 -0
- package/dist/video/props.js +2 -0
- package/dist/video/video-fragment.d.ts +12 -0
- package/dist/video/video-fragment.js +60 -0
- package/dist/video-config.d.ts +8 -0
- package/dist/video-config.js +2 -0
- package/dist/volume-position-state.d.ts +19 -0
- package/dist/volume-position-state.js +32 -0
- package/dist/volume-prop.d.ts +7 -0
- package/dist/volume-prop.js +24 -0
- package/dist/warn-about-non-seekable-media.d.ts +1 -0
- package/dist/warn-about-non-seekable-media.js +34 -0
- package/dist/wrap-remotion-context.d.ts +18 -0
- package/dist/wrap-remotion-context.js +73 -0
- package/package.json +4 -5
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.measureSpring = exports.spring = void 0;
|
|
4
|
+
const validation_spring_duration_1 = require("../validation/validation-spring-duration");
|
|
5
|
+
const measure_spring_1 = require("./measure-spring");
|
|
6
|
+
const spring_utils_1 = require("./spring-utils");
|
|
7
|
+
/**
|
|
8
|
+
* Calculates a position based on physical parameters, start and end value, and time.
|
|
9
|
+
* @link https://www.remotion.dev/docs/spring
|
|
10
|
+
* @param {number} frame The current time value. Most of the time you want to pass in the return value of useCurrentFrame.
|
|
11
|
+
* @param {number} fps The framerate at which the animation runs. Pass in the value obtained by `useVideoConfig()`.
|
|
12
|
+
* @param {?Object} config optional object that allows you to customize the physical properties of the animation.
|
|
13
|
+
* @param {number} [config.mass=1] The weight of the spring. If you reduce the mass, the animation becomes faster!
|
|
14
|
+
* @param {number} [config.damping=10] How hard the animation decelerates.
|
|
15
|
+
* @param {number} [config.stiffness=100] Affects bounciness of the animation.
|
|
16
|
+
* @param {boolean} [config.overshootClamping=false] Whether to prevent the animation going beyond the target value.
|
|
17
|
+
* @param {?number} [config.from] The initial value of the animation. Default `0`
|
|
18
|
+
* @param {?number} [config.to] The end value of the animation. Default `1`
|
|
19
|
+
* @param {?number} [config.durationInFrames] Stretch the duration of an animation to a set value.. Default `undefined`
|
|
20
|
+
* @param {?number} [config.durationThreshold] How close to the end the animation is considered to be done. Default `0.005`
|
|
21
|
+
*/
|
|
22
|
+
function spring({ frame, fps, config = {}, from = 0, to = 1, durationInFrames, durationRestThreshold, }) {
|
|
23
|
+
(0, validation_spring_duration_1.validateSpringDuration)(durationInFrames);
|
|
24
|
+
const durationRatio = durationInFrames === undefined
|
|
25
|
+
? 1
|
|
26
|
+
: durationInFrames /
|
|
27
|
+
(0, measure_spring_1.measureSpring)({
|
|
28
|
+
fps,
|
|
29
|
+
config,
|
|
30
|
+
from,
|
|
31
|
+
to,
|
|
32
|
+
threshold: durationRestThreshold,
|
|
33
|
+
});
|
|
34
|
+
const spr = (0, spring_utils_1.springCalculation)({
|
|
35
|
+
fps,
|
|
36
|
+
frame: frame / durationRatio,
|
|
37
|
+
config,
|
|
38
|
+
from,
|
|
39
|
+
to,
|
|
40
|
+
});
|
|
41
|
+
if (!config.overshootClamping) {
|
|
42
|
+
return spr.current;
|
|
43
|
+
}
|
|
44
|
+
if (to >= from) {
|
|
45
|
+
return Math.min(spr.current, to);
|
|
46
|
+
}
|
|
47
|
+
return Math.max(spr.current, to);
|
|
48
|
+
}
|
|
49
|
+
exports.spring = spring;
|
|
50
|
+
var measure_spring_2 = require("./measure-spring");
|
|
51
|
+
Object.defineProperty(exports, "measureSpring", { enumerable: true, get: function () { return measure_spring_2.measureSpring; } });
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.measureSpring = void 0;
|
|
4
|
+
const validate_fps_1 = require("../validation/validate-fps");
|
|
5
|
+
const spring_utils_1 = require("./spring-utils");
|
|
6
|
+
function measureSpring({ fps, config = {}, threshold = 0.005, from = 0, to = 1, }) {
|
|
7
|
+
if (typeof threshold !== 'number') {
|
|
8
|
+
throw new TypeError(`threshold must be a number, got ${threshold} of type ${typeof threshold}`);
|
|
9
|
+
}
|
|
10
|
+
if (threshold === 0) {
|
|
11
|
+
return Infinity;
|
|
12
|
+
}
|
|
13
|
+
if (threshold === 1) {
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
if (isNaN(threshold)) {
|
|
17
|
+
throw new TypeError('Threshold is NaN');
|
|
18
|
+
}
|
|
19
|
+
if (!Number.isFinite(threshold)) {
|
|
20
|
+
throw new TypeError('Threshold is not finite');
|
|
21
|
+
}
|
|
22
|
+
if (threshold < 0) {
|
|
23
|
+
throw new TypeError('Threshold is below 0');
|
|
24
|
+
}
|
|
25
|
+
(0, validate_fps_1.validateFps)(fps, 'to the measureSpring() function', false);
|
|
26
|
+
const range = Math.abs(from - to);
|
|
27
|
+
let frame = 0;
|
|
28
|
+
let finishedFrame = 0;
|
|
29
|
+
const calc = () => {
|
|
30
|
+
return (0, spring_utils_1.springCalculation)({
|
|
31
|
+
fps,
|
|
32
|
+
frame,
|
|
33
|
+
config,
|
|
34
|
+
from,
|
|
35
|
+
to,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
let animation = calc();
|
|
39
|
+
const calcDifference = () => {
|
|
40
|
+
return (Math.abs(animation.current - animation.toValue) /
|
|
41
|
+
(range === 0 ? 1 : range));
|
|
42
|
+
};
|
|
43
|
+
let difference = calcDifference();
|
|
44
|
+
while (difference >= threshold) {
|
|
45
|
+
frame++;
|
|
46
|
+
animation = calc();
|
|
47
|
+
difference = calcDifference();
|
|
48
|
+
}
|
|
49
|
+
// Since spring is bouncy, just because it's under the threshold we
|
|
50
|
+
// cannot be sure it's done. We need to animate further until it stays in the
|
|
51
|
+
// threshold for, say, 20 frames.
|
|
52
|
+
finishedFrame = frame;
|
|
53
|
+
for (let i = 0; i < 20; i++) {
|
|
54
|
+
frame++;
|
|
55
|
+
animation = calc();
|
|
56
|
+
difference = calcDifference();
|
|
57
|
+
if (difference >= threshold) {
|
|
58
|
+
i = 0;
|
|
59
|
+
finishedFrame = frame + 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return finishedFrame;
|
|
63
|
+
}
|
|
64
|
+
exports.measureSpring = measureSpring;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare type AnimationNode = {
|
|
2
|
+
lastTimestamp: number;
|
|
3
|
+
toValue: number;
|
|
4
|
+
current: number;
|
|
5
|
+
velocity: number;
|
|
6
|
+
prevPosition?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare type SpringConfig = {
|
|
9
|
+
damping: number;
|
|
10
|
+
mass: number;
|
|
11
|
+
stiffness: number;
|
|
12
|
+
overshootClamping: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function springCalculation({ from, to, frame, fps, config, }: {
|
|
15
|
+
from?: number;
|
|
16
|
+
to?: number;
|
|
17
|
+
frame: number;
|
|
18
|
+
fps: number;
|
|
19
|
+
config?: Partial<SpringConfig>;
|
|
20
|
+
}): AnimationNode;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.springCalculation = void 0;
|
|
4
|
+
const defaultSpringConfig = {
|
|
5
|
+
damping: 10,
|
|
6
|
+
mass: 1,
|
|
7
|
+
stiffness: 100,
|
|
8
|
+
overshootClamping: false,
|
|
9
|
+
};
|
|
10
|
+
const advanceCache = {};
|
|
11
|
+
function advance({ animation, now, config, }) {
|
|
12
|
+
const { toValue, lastTimestamp, current, velocity } = animation;
|
|
13
|
+
const deltaTime = Math.min(now - lastTimestamp, 64);
|
|
14
|
+
const c = config.damping;
|
|
15
|
+
const m = config.mass;
|
|
16
|
+
const k = config.stiffness;
|
|
17
|
+
const cacheKey = [
|
|
18
|
+
toValue,
|
|
19
|
+
lastTimestamp,
|
|
20
|
+
current,
|
|
21
|
+
velocity,
|
|
22
|
+
c,
|
|
23
|
+
m,
|
|
24
|
+
k,
|
|
25
|
+
now,
|
|
26
|
+
].join('-');
|
|
27
|
+
if (advanceCache[cacheKey]) {
|
|
28
|
+
return advanceCache[cacheKey];
|
|
29
|
+
}
|
|
30
|
+
const v0 = -velocity;
|
|
31
|
+
const x0 = toValue - current;
|
|
32
|
+
const zeta = c / (2 * Math.sqrt(k * m)); // damping ratio
|
|
33
|
+
const omega0 = Math.sqrt(k / m); // undamped angular frequency of the oscillator (rad/ms)
|
|
34
|
+
const omega1 = omega0 * Math.sqrt(1 - zeta ** 2); // exponential decay
|
|
35
|
+
const t = deltaTime / 1000;
|
|
36
|
+
const sin1 = Math.sin(omega1 * t);
|
|
37
|
+
const cos1 = Math.cos(omega1 * t);
|
|
38
|
+
// under damped
|
|
39
|
+
const underDampedEnvelope = Math.exp(-zeta * omega0 * t);
|
|
40
|
+
const underDampedFrag1 = underDampedEnvelope *
|
|
41
|
+
(sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);
|
|
42
|
+
const underDampedPosition = toValue - underDampedFrag1;
|
|
43
|
+
// This looks crazy -- it's actually just the derivative of the oscillation function
|
|
44
|
+
const underDampedVelocity = zeta * omega0 * underDampedFrag1 -
|
|
45
|
+
underDampedEnvelope *
|
|
46
|
+
(cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);
|
|
47
|
+
// critically damped
|
|
48
|
+
const criticallyDampedEnvelope = Math.exp(-omega0 * t);
|
|
49
|
+
const criticallyDampedPosition = toValue - criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);
|
|
50
|
+
const criticallyDampedVelocity = criticallyDampedEnvelope *
|
|
51
|
+
(v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0);
|
|
52
|
+
const animationNode = {
|
|
53
|
+
toValue,
|
|
54
|
+
prevPosition: current,
|
|
55
|
+
lastTimestamp: now,
|
|
56
|
+
current: zeta < 1 ? underDampedPosition : criticallyDampedPosition,
|
|
57
|
+
velocity: zeta < 1 ? underDampedVelocity : criticallyDampedVelocity,
|
|
58
|
+
};
|
|
59
|
+
advanceCache[cacheKey] = animationNode;
|
|
60
|
+
return animationNode;
|
|
61
|
+
}
|
|
62
|
+
const calculationCache = {};
|
|
63
|
+
function springCalculation({ from = 0, to = 1, frame, fps, config = {}, }) {
|
|
64
|
+
const cacheKey = [
|
|
65
|
+
from,
|
|
66
|
+
to,
|
|
67
|
+
frame,
|
|
68
|
+
fps,
|
|
69
|
+
config.damping,
|
|
70
|
+
config.mass,
|
|
71
|
+
config.overshootClamping,
|
|
72
|
+
config.stiffness,
|
|
73
|
+
].join('-');
|
|
74
|
+
if (calculationCache[cacheKey]) {
|
|
75
|
+
return calculationCache[cacheKey];
|
|
76
|
+
}
|
|
77
|
+
let animation = {
|
|
78
|
+
lastTimestamp: 0,
|
|
79
|
+
current: from,
|
|
80
|
+
toValue: to,
|
|
81
|
+
velocity: 0,
|
|
82
|
+
prevPosition: 0,
|
|
83
|
+
};
|
|
84
|
+
const frameClamped = Math.max(0, frame);
|
|
85
|
+
const unevenRest = frameClamped % 1;
|
|
86
|
+
for (let f = 0; f <= Math.floor(frameClamped); f++) {
|
|
87
|
+
if (f === Math.floor(frameClamped)) {
|
|
88
|
+
f += unevenRest;
|
|
89
|
+
}
|
|
90
|
+
const time = (f / fps) * 1000;
|
|
91
|
+
animation = advance({
|
|
92
|
+
animation,
|
|
93
|
+
now: time,
|
|
94
|
+
config: {
|
|
95
|
+
...defaultSpringConfig,
|
|
96
|
+
...config,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
calculationCache[cacheKey] = animation;
|
|
101
|
+
return animation;
|
|
102
|
+
}
|
|
103
|
+
exports.springCalculation = springCalculation;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.staticFile = void 0;
|
|
4
|
+
const trimLeadingSlash = (path) => {
|
|
5
|
+
if (path.startsWith('/')) {
|
|
6
|
+
return trimLeadingSlash(path.substr(1));
|
|
7
|
+
}
|
|
8
|
+
return path;
|
|
9
|
+
};
|
|
10
|
+
const inner = (path) => {
|
|
11
|
+
if (typeof window !== 'undefined' && window.remotion_staticBase) {
|
|
12
|
+
return `${window.remotion_staticBase}/${trimLeadingSlash(path)}`;
|
|
13
|
+
}
|
|
14
|
+
return `/${trimLeadingSlash(path)}`;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Reference a file from the public/ folder.
|
|
18
|
+
* If the file does not appear in the autocomplete, type the path manually.
|
|
19
|
+
*/
|
|
20
|
+
const staticFile = (path) => {
|
|
21
|
+
if (path.startsWith('http://') || path.startsWith('https://')) {
|
|
22
|
+
throw new TypeError(`staticFile() does not support remote URLs - got "${path}". Instead, pass the URL without wrapping it in staticFile(). See: https://remotion.dev/docs/staticfile-remote-urls`);
|
|
23
|
+
}
|
|
24
|
+
if (path.startsWith('..') || path.startsWith('./')) {
|
|
25
|
+
throw new TypeError(`staticFile() does not support relative paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
26
|
+
}
|
|
27
|
+
const preparsed = inner(path);
|
|
28
|
+
if (!preparsed.startsWith('/')) {
|
|
29
|
+
return `/${preparsed}`;
|
|
30
|
+
}
|
|
31
|
+
return preparsed;
|
|
32
|
+
};
|
|
33
|
+
exports.staticFile = staticFile;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
export declare type PlayableMediaTag = {
|
|
3
|
+
play: () => void;
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type TimelineContextValue = {
|
|
7
|
+
frame: number;
|
|
8
|
+
playing: boolean;
|
|
9
|
+
rootId: string;
|
|
10
|
+
playbackRate: number;
|
|
11
|
+
imperativePlaying: MutableRefObject<boolean>;
|
|
12
|
+
setPlaybackRate: (u: React.SetStateAction<number>) => void;
|
|
13
|
+
audioAndVideoTags: MutableRefObject<PlayableMediaTag[]>;
|
|
14
|
+
};
|
|
15
|
+
export declare type SetTimelineContextValue = {
|
|
16
|
+
setFrame: (u: React.SetStateAction<number>) => void;
|
|
17
|
+
setPlaying: (u: React.SetStateAction<boolean>) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const TimelineContext: import("react").Context<TimelineContextValue>;
|
|
20
|
+
export declare const SetTimelineContext: import("react").Context<SetTimelineContextValue>;
|
|
21
|
+
export declare const useTimelinePosition: () => number;
|
|
22
|
+
export declare const useTimelineSetFrame: () => (u: React.SetStateAction<number>) => void;
|
|
23
|
+
declare type PlayingReturnType = readonly [
|
|
24
|
+
boolean,
|
|
25
|
+
(u: React.SetStateAction<boolean>) => void,
|
|
26
|
+
MutableRefObject<boolean>
|
|
27
|
+
];
|
|
28
|
+
export declare const usePlayingState: () => PlayingReturnType;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePlayingState = exports.useTimelineSetFrame = exports.useTimelinePosition = exports.SetTimelineContext = exports.TimelineContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.TimelineContext = (0, react_1.createContext)({
|
|
6
|
+
frame: 0,
|
|
7
|
+
playing: false,
|
|
8
|
+
playbackRate: 1,
|
|
9
|
+
rootId: '',
|
|
10
|
+
imperativePlaying: {
|
|
11
|
+
current: false,
|
|
12
|
+
},
|
|
13
|
+
setPlaybackRate: () => {
|
|
14
|
+
throw new Error('default');
|
|
15
|
+
},
|
|
16
|
+
audioAndVideoTags: { current: [] },
|
|
17
|
+
});
|
|
18
|
+
exports.SetTimelineContext = (0, react_1.createContext)({
|
|
19
|
+
setFrame: () => {
|
|
20
|
+
throw new Error('default');
|
|
21
|
+
},
|
|
22
|
+
setPlaying: () => {
|
|
23
|
+
throw new Error('default');
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const useTimelinePosition = () => {
|
|
27
|
+
const state = (0, react_1.useContext)(exports.TimelineContext);
|
|
28
|
+
return state.frame;
|
|
29
|
+
};
|
|
30
|
+
exports.useTimelinePosition = useTimelinePosition;
|
|
31
|
+
const useTimelineSetFrame = () => {
|
|
32
|
+
const { setFrame } = (0, react_1.useContext)(exports.SetTimelineContext);
|
|
33
|
+
return setFrame;
|
|
34
|
+
};
|
|
35
|
+
exports.useTimelineSetFrame = useTimelineSetFrame;
|
|
36
|
+
const usePlayingState = () => {
|
|
37
|
+
const { playing, imperativePlaying } = (0, react_1.useContext)(exports.TimelineContext);
|
|
38
|
+
const { setPlaying } = (0, react_1.useContext)(exports.SetTimelineContext);
|
|
39
|
+
return (0, react_1.useMemo)(() => [playing, setPlaying, imperativePlaying], [imperativePlaying, playing, setPlaying]);
|
|
40
|
+
};
|
|
41
|
+
exports.usePlayingState = usePlayingState;
|
package/dist/truthy.d.ts
ADDED