remotion 4.0.506 → 4.0.507
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/README.md +1 -0
- package/dist/cjs/Interactive.d.ts +10 -0
- package/dist/cjs/audio/shared-audio-tags.d.ts +2 -1
- package/dist/cjs/audio/shared-audio-tags.js +22 -6
- package/dist/cjs/audio/wait-until-actually-resumed.d.ts +2 -1
- package/dist/cjs/audio/wait-until-actually-resumed.js +34 -4
- package/dist/cjs/buffering.js +17 -8
- package/dist/cjs/interactivity-schema.d.ts +10 -0
- package/dist/cjs/interactivity-schema.js +8 -0
- package/dist/cjs/internals.d.ts +4 -1
- package/dist/cjs/internals.js +4 -0
- package/dist/cjs/interpolate-keyframed-status.js +2 -0
- package/dist/cjs/portal-node.d.ts +3 -0
- package/dist/cjs/portal-node.js +22 -1
- package/dist/cjs/render-resource-manager.d.ts +13 -0
- package/dist/cjs/render-resource-manager.js +47 -0
- package/dist/cjs/use-current-scale.js +10 -6
- package/dist/cjs/use-schema.d.ts +4 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/with-interactivity-schema.js +3 -1
- package/dist/esm/index.mjs +183 -59
- package/dist/esm/no-react.mjs +8 -0
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
- package/dist/cjs/interpolate-translate.d.ts +0 -8
- package/dist/cjs/interpolate-translate.js +0 -70
- package/dist/cjs/sequence-field-schema.d.ts +0 -425
- package/dist/cjs/sequence-field-schema.js +0 -133
- package/dist/cjs/wrap-in-schema.d.ts +0 -20
- package/dist/cjs/wrap-in-schema.js +0 -203
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ Remotion is extensively documented over more than 1000 pages.
|
|
|
48
48
|
- [Prompts](https://www.remotion.dev/prompts)
|
|
49
49
|
- [Templates](https://remotion.dev/templates)
|
|
50
50
|
- Components
|
|
51
|
+
- [Elements](https://remotion.dev/elements)
|
|
51
52
|
- [Effects](https://remotion.dev/effects)
|
|
52
53
|
- [Shapes](https://remotion.dev/docs/shapes)
|
|
53
54
|
- [Transitions](https://remotion.dev/transitions)
|
|
@@ -296,6 +296,11 @@ export declare const Interactive: {
|
|
|
296
296
|
};
|
|
297
297
|
};
|
|
298
298
|
svgPaintSchema: {
|
|
299
|
+
readonly color: {
|
|
300
|
+
readonly type: "color";
|
|
301
|
+
readonly default: undefined;
|
|
302
|
+
readonly description: "Current color";
|
|
303
|
+
};
|
|
299
304
|
readonly stroke: {
|
|
300
305
|
readonly type: "color";
|
|
301
306
|
readonly default: "none";
|
|
@@ -316,6 +321,11 @@ export declare const Interactive: {
|
|
|
316
321
|
};
|
|
317
322
|
};
|
|
318
323
|
svgStrokeSchema: {
|
|
324
|
+
readonly color: {
|
|
325
|
+
readonly type: "color";
|
|
326
|
+
readonly default: undefined;
|
|
327
|
+
readonly description: "Current color";
|
|
328
|
+
};
|
|
319
329
|
readonly stroke: {
|
|
320
330
|
readonly type: "color";
|
|
321
331
|
readonly default: "none";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { type AudioHTMLAttributes } from 'react';
|
|
2
2
|
import type { SharedElementSourceNode } from './shared-element-source-node.js';
|
|
3
3
|
import type { RemotionAudioContextState } from './use-audio-context.js';
|
|
4
|
+
import { type AudioContextResumeResult } from './wait-until-actually-resumed.js';
|
|
4
5
|
/**
|
|
5
6
|
* This functionality of Remotion will keep a certain amount
|
|
6
7
|
* of <audio> tags pre-mounted and by default filled with an empty audio track.
|
|
@@ -58,7 +59,7 @@ type SharedAudioContextValue = {
|
|
|
58
59
|
scheduleAudioNode: (options: ScheduleAudioNodeOptions) => ScheduleAudioNodeResult;
|
|
59
60
|
resume: () => Promise<void>;
|
|
60
61
|
suspend: () => Promise<void>;
|
|
61
|
-
getIsResumingAudioContext: () => Promise<
|
|
62
|
+
getIsResumingAudioContext: () => Promise<AudioContextResumeResult> | null;
|
|
62
63
|
unscheduleAudioNode: (node: AudioBufferSourceNode) => void;
|
|
63
64
|
};
|
|
64
65
|
type SharedAudioTagsContextValue = {
|
|
@@ -105,6 +105,7 @@ const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled,
|
|
|
105
105
|
});
|
|
106
106
|
const audioContextIsPlayingEventually = (0, react_1.useRef)(false);
|
|
107
107
|
const isResuming = (0, react_1.useRef)(null);
|
|
108
|
+
const nextResumeAttemptId = (0, react_1.useRef)(0);
|
|
108
109
|
const audioSyncAnchor = (0, react_1.useMemo)(() => ({ value: 0 }), []);
|
|
109
110
|
const audioSyncAnchorListeners = (0, react_1.useRef)([]);
|
|
110
111
|
const audioSyncAnchorEmitter = (0, react_1.useMemo)(() => {
|
|
@@ -203,24 +204,39 @@ const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled,
|
|
|
203
204
|
});
|
|
204
205
|
nodesToResume.current.clear();
|
|
205
206
|
const resumePromise = ctxAndGain.resume();
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
const abortController = new AbortController();
|
|
208
|
+
const resumeAttemptId = nextResumeAttemptId.current++;
|
|
209
|
+
const waitPromise = new Promise((resolve) => {
|
|
210
|
+
(0, wait_until_actually_resumed_js_1.waitUntilActuallyResumed)(ctxAndGain.audioContext, logLevel, abortController.signal).then(resolve);
|
|
208
211
|
resumePromise.catch((err) => {
|
|
209
|
-
log_js_1.Log.warn({ logLevel, tag: 'audio' }, 'AudioContext resume rejected, continuing without audio
|
|
210
|
-
|
|
212
|
+
log_js_1.Log.warn({ logLevel, tag: 'audio' }, 'AudioContext resume rejected, muting playback and continuing without audio', err);
|
|
213
|
+
abortController.abort();
|
|
214
|
+
resolve('failed');
|
|
211
215
|
});
|
|
212
216
|
}).finally(() => {
|
|
213
|
-
|
|
217
|
+
var _a;
|
|
218
|
+
if (((_a = isResuming.current) === null || _a === void 0 ? void 0 : _a.id) === resumeAttemptId) {
|
|
219
|
+
isResuming.current = null;
|
|
220
|
+
}
|
|
214
221
|
});
|
|
222
|
+
isResuming.current = {
|
|
223
|
+
abortController,
|
|
224
|
+
id: resumeAttemptId,
|
|
225
|
+
promise: waitPromise,
|
|
226
|
+
};
|
|
215
227
|
return resumePromise.catch(() => {
|
|
216
228
|
// Already logged above; swallow to avoid unhandled rejection
|
|
217
229
|
// since callers (e.g. use-playback.ts) do not await this.
|
|
218
230
|
});
|
|
219
231
|
}, [ctxAndGain, logLevel]);
|
|
220
232
|
const getIsResumingAudioContext = (0, react_1.useCallback)(() => {
|
|
221
|
-
|
|
233
|
+
var _a;
|
|
234
|
+
var _b;
|
|
235
|
+
return (_b = (_a = isResuming.current) === null || _a === void 0 ? void 0 : _a.promise) !== null && _b !== void 0 ? _b : null;
|
|
222
236
|
}, []);
|
|
223
237
|
const suspend = (0, react_1.useCallback)(() => {
|
|
238
|
+
var _a;
|
|
239
|
+
(_a = isResuming.current) === null || _a === void 0 ? void 0 : _a.abortController.abort();
|
|
224
240
|
if (!ctxAndGain) {
|
|
225
241
|
return Promise.resolve();
|
|
226
242
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type AudioContextResumeResult = 'resumed' | 'cancelled' | 'failed';
|
|
2
|
+
export declare const waitUntilActuallyResumed: (audioContext: AudioContext, logLevel: "error" | "info" | "trace" | "verbose" | "warn", signal: AbortSignal) => Promise<AudioContextResumeResult>;
|
|
@@ -2,15 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.waitUntilActuallyResumed = void 0;
|
|
4
4
|
const log_js_1 = require("../log.js");
|
|
5
|
-
const
|
|
5
|
+
const RESUME_WAIT_TIMEOUT = 1000;
|
|
6
|
+
const waitUntilActuallyResumed = (audioContext, logLevel, signal) => {
|
|
6
7
|
return new Promise((resolve) => {
|
|
7
8
|
const startCurrentTime = audioContext.currentTime;
|
|
8
9
|
const start = audioContext.getOutputTimestamp();
|
|
9
10
|
const startOutputPerformanceTime = start.performanceTime;
|
|
10
11
|
const startWallClock = performance.now();
|
|
12
|
+
let animationFrame = null;
|
|
13
|
+
let timeout = null;
|
|
14
|
+
let settled = false;
|
|
15
|
+
let onAbort = () => undefined;
|
|
16
|
+
const finish = (result) => {
|
|
17
|
+
if (settled) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
settled = true;
|
|
21
|
+
if (animationFrame !== null) {
|
|
22
|
+
cancelAnimationFrame(animationFrame);
|
|
23
|
+
}
|
|
24
|
+
if (timeout !== null) {
|
|
25
|
+
clearTimeout(timeout);
|
|
26
|
+
}
|
|
27
|
+
signal.removeEventListener('abort', onAbort);
|
|
28
|
+
resolve(result);
|
|
29
|
+
};
|
|
30
|
+
onAbort = () => finish('cancelled');
|
|
11
31
|
const check = () => {
|
|
12
32
|
var _a;
|
|
13
33
|
var _b;
|
|
34
|
+
animationFrame = null;
|
|
14
35
|
const { currentTime } = audioContext;
|
|
15
36
|
const outputTimestamp = audioContext.getOutputTimestamp();
|
|
16
37
|
const elapsedWallClock = performance.now() - startWallClock;
|
|
@@ -20,12 +41,21 @@ const waitUntilActuallyResumed = (audioContext, logLevel) => {
|
|
|
20
41
|
outputTimestamp.contextTime !== undefined &&
|
|
21
42
|
outputTimestamp.contextTime > startCurrentTime) {
|
|
22
43
|
log_js_1.Log.verbose({ logLevel, tag: 'audio' }, `waitUntilActuallyResumed: getOutputTimestamp.performanceTime advanced from ${startOutputPerformanceTime.toFixed(6)} to ${outputTimestamp.performanceTime.toFixed(6)} after ${elapsedWallClock.toFixed(1)}ms. currentTime=${currentTime.toFixed(6)} (advanced by ${(currentTime - startCurrentTime).toFixed(6)}), getOutputTimestamp.performanceTime=${(_b = (_a = outputTimestamp.performanceTime) === null || _a === void 0 ? void 0 : _a.toFixed(1)) !== null && _b !== void 0 ? _b : 'undefined'}`);
|
|
23
|
-
|
|
44
|
+
finish('resumed');
|
|
24
45
|
return;
|
|
25
46
|
}
|
|
26
|
-
requestAnimationFrame(check);
|
|
47
|
+
animationFrame = requestAnimationFrame(check);
|
|
27
48
|
};
|
|
28
|
-
|
|
49
|
+
if (signal.aborted) {
|
|
50
|
+
finish('cancelled');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
54
|
+
timeout = setTimeout(() => {
|
|
55
|
+
log_js_1.Log.warn({ logLevel, tag: 'audio' }, 'WARNING: You enabled autoPlay on an unmuted <Player /> and the browser did not allow the video to be started. Remotion muted the <Player /> so it can play. To properly handle this, either set the `muted` prop or remove the `autoPlay` prop');
|
|
56
|
+
finish('failed');
|
|
57
|
+
}, RESUME_WAIT_TIMEOUT);
|
|
58
|
+
animationFrame = requestAnimationFrame(check);
|
|
29
59
|
});
|
|
30
60
|
};
|
|
31
61
|
exports.waitUntilActuallyResumed = waitUntilActuallyResumed;
|
package/dist/cjs/buffering.js
CHANGED
|
@@ -41,8 +41,14 @@ const playback_logging_1 = require("./playback-logging");
|
|
|
41
41
|
const use_remotion_environment_1 = require("./use-remotion-environment");
|
|
42
42
|
const useBufferManager = (logLevel, mountTime) => {
|
|
43
43
|
const [blocks, setBlocks] = (0, react_1.useState)([]);
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// Listener registries are refs, not state: `usePlayback` parks its loop
|
|
45
|
+
// during buffering and registers its resume listener from a rAF callback.
|
|
46
|
+
// With state, that registration only lands after the next React commit -
|
|
47
|
+
// if the last block unblocks before then, the resume dispatch reads the
|
|
48
|
+
// previous array, the listener is never called, and the playback loop
|
|
49
|
+
// stays parked forever (frame clock frozen while isPlaying() is true).
|
|
50
|
+
const onBufferingCallbacks = (0, react_1.useRef)([]);
|
|
51
|
+
const onResumeCallbacks = (0, react_1.useRef)([]);
|
|
46
52
|
const env = (0, use_remotion_environment_1.useRemotionEnvironment)();
|
|
47
53
|
const rendering = env.isRendering;
|
|
48
54
|
const buffering = (0, react_1.useRef)(false);
|
|
@@ -71,18 +77,21 @@ const useBufferManager = (logLevel, mountTime) => {
|
|
|
71
77
|
};
|
|
72
78
|
}, [rendering]);
|
|
73
79
|
const listenForBuffering = (0, react_1.useCallback)((callback) => {
|
|
74
|
-
|
|
80
|
+
onBufferingCallbacks.current = [
|
|
81
|
+
...onBufferingCallbacks.current,
|
|
82
|
+
callback,
|
|
83
|
+
];
|
|
75
84
|
return {
|
|
76
85
|
remove: () => {
|
|
77
|
-
|
|
86
|
+
onBufferingCallbacks.current = onBufferingCallbacks.current.filter((cb) => cb !== callback);
|
|
78
87
|
},
|
|
79
88
|
};
|
|
80
89
|
}, []);
|
|
81
90
|
const listenForResume = (0, react_1.useCallback)((callback) => {
|
|
82
|
-
|
|
91
|
+
onResumeCallbacks.current = [...onResumeCallbacks.current, callback];
|
|
83
92
|
return {
|
|
84
93
|
remove: () => {
|
|
85
|
-
|
|
94
|
+
onResumeCallbacks.current = onResumeCallbacks.current.filter((cb) => cb !== callback);
|
|
86
95
|
},
|
|
87
96
|
};
|
|
88
97
|
}, []);
|
|
@@ -95,7 +104,7 @@ const useBufferManager = (logLevel, mountTime) => {
|
|
|
95
104
|
// not re-dispatch `waiting` to listeners.
|
|
96
105
|
if (blocks.length > 0 && !buffering.current) {
|
|
97
106
|
buffering.current = true;
|
|
98
|
-
onBufferingCallbacks.forEach((c) => c());
|
|
107
|
+
[...onBufferingCallbacks.current].forEach((c) => c());
|
|
99
108
|
(0, playback_logging_1.playbackLogging)({
|
|
100
109
|
logLevel,
|
|
101
110
|
message: 'Player is entering buffer state',
|
|
@@ -119,7 +128,7 @@ const useBufferManager = (logLevel, mountTime) => {
|
|
|
119
128
|
// dispatch `resume` to listeners.
|
|
120
129
|
if (blocks.length === 0 && buffering.current) {
|
|
121
130
|
buffering.current = false;
|
|
122
|
-
onResumeCallbacks.forEach((c) => c());
|
|
131
|
+
[...onResumeCallbacks.current].forEach((c) => c());
|
|
123
132
|
(0, playback_logging_1.playbackLogging)({
|
|
124
133
|
logLevel,
|
|
125
134
|
message: 'Player is exiting buffer state',
|
|
@@ -386,6 +386,11 @@ export declare const backgroundSchema: {
|
|
|
386
386
|
};
|
|
387
387
|
};
|
|
388
388
|
export declare const svgStrokeSchema: {
|
|
389
|
+
readonly color: {
|
|
390
|
+
readonly type: "color";
|
|
391
|
+
readonly default: undefined;
|
|
392
|
+
readonly description: "Current color";
|
|
393
|
+
};
|
|
389
394
|
readonly stroke: {
|
|
390
395
|
readonly type: "color";
|
|
391
396
|
readonly default: "none";
|
|
@@ -401,6 +406,11 @@ export declare const svgStrokeSchema: {
|
|
|
401
406
|
};
|
|
402
407
|
};
|
|
403
408
|
export declare const svgPaintSchema: {
|
|
409
|
+
readonly color: {
|
|
410
|
+
readonly type: "color";
|
|
411
|
+
readonly default: undefined;
|
|
412
|
+
readonly description: "Current color";
|
|
413
|
+
};
|
|
404
414
|
readonly stroke: {
|
|
405
415
|
readonly type: "color";
|
|
406
416
|
readonly default: "none";
|
|
@@ -208,7 +208,15 @@ exports.backgroundSchema = {
|
|
|
208
208
|
description: 'Color',
|
|
209
209
|
},
|
|
210
210
|
};
|
|
211
|
+
const svgColorSchema = {
|
|
212
|
+
color: {
|
|
213
|
+
type: 'color',
|
|
214
|
+
default: undefined,
|
|
215
|
+
description: 'Current color',
|
|
216
|
+
},
|
|
217
|
+
};
|
|
211
218
|
exports.svgStrokeSchema = {
|
|
219
|
+
...svgColorSchema,
|
|
212
220
|
stroke: {
|
|
213
221
|
type: 'color',
|
|
214
222
|
// `none` is the SVG initial value of stroke.
|
package/dist/cjs/internals.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ import { useRemotionContexts } from './wrap-remotion-context.js';
|
|
|
26
26
|
export type { EffectChainState } from './effects/run-effect-chain.js';
|
|
27
27
|
export declare const Internals: {
|
|
28
28
|
readonly MaxMediaCacheSizeContext: import("react").Context<number | null>;
|
|
29
|
+
readonly makeRenderResourceManager: () => import("./render-resource-manager.js").RenderResourceManager;
|
|
30
|
+
readonly RenderResourceManagerContext: import("react").Context<import("./render-resource-manager.js").RenderResourceManager | null>;
|
|
29
31
|
readonly useUnsafeVideoConfig: () => import("./video-config.js").VideoConfig | null;
|
|
30
32
|
readonly useFrameForVolumeProp: (behavior: import("./index.js").LoopVolumeCurveBehavior) => number;
|
|
31
33
|
readonly useTimelinePosition: () => number;
|
|
@@ -812,7 +814,7 @@ export declare const Internals: {
|
|
|
812
814
|
scheduleAudioNode: (options: ScheduleAudioNodeOptions) => ScheduleAudioNodeResult;
|
|
813
815
|
resume: () => Promise<void>;
|
|
814
816
|
suspend: () => Promise<void>;
|
|
815
|
-
getIsResumingAudioContext: () => Promise<
|
|
817
|
+
getIsResumingAudioContext: () => Promise<import("./audio/wait-until-actually-resumed.js").AudioContextResumeResult> | null;
|
|
816
818
|
unscheduleAudioNode: (node: AudioBufferSourceNode) => void;
|
|
817
819
|
} | null>;
|
|
818
820
|
readonly SharedAudioContextProvider: import("react").FC<{
|
|
@@ -873,6 +875,7 @@ export declare const Internals: {
|
|
|
873
875
|
getCompositions: () => import("./CompositionManager.js").AnyComposition[];
|
|
874
876
|
} | null>;
|
|
875
877
|
readonly portalNode: () => HTMLElement;
|
|
878
|
+
readonly setPortalNodeCurrentScale: (scale: number) => void;
|
|
876
879
|
readonly waitForRoot: (fn: (comp: import("react").FC<{}>) => void) => () => void;
|
|
877
880
|
readonly SetTimelineContext: import("react").Context<SetTimelineContextValue>;
|
|
878
881
|
readonly CanUseRemotionHooksProvider: import("react").FC<{
|
package/dist/cjs/internals.js
CHANGED
|
@@ -78,6 +78,7 @@ const PremountContext_js_1 = require("./PremountContext.js");
|
|
|
78
78
|
const register_root_js_1 = require("./register-root.js");
|
|
79
79
|
const remotion_environment_context_js_1 = require("./remotion-environment-context.js");
|
|
80
80
|
const RemotionRoot_js_1 = require("./RemotionRoot.js");
|
|
81
|
+
const render_resource_manager_js_1 = require("./render-resource-manager.js");
|
|
81
82
|
const RenderAssetManager_js_1 = require("./RenderAssetManager.js");
|
|
82
83
|
const resolve_video_config_js_1 = require("./resolve-video-config.js");
|
|
83
84
|
const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
|
|
@@ -123,6 +124,8 @@ const compositionSelectorRef = (0, react_1.createRef)();
|
|
|
123
124
|
// API and are less likely to use it
|
|
124
125
|
exports.Internals = {
|
|
125
126
|
MaxMediaCacheSizeContext: max_video_cache_size_js_1.MaxMediaCacheSizeContext,
|
|
127
|
+
makeRenderResourceManager: render_resource_manager_js_1.makeRenderResourceManager,
|
|
128
|
+
RenderResourceManagerContext: render_resource_manager_js_1.RenderResourceManagerContext,
|
|
126
129
|
useUnsafeVideoConfig: use_unsafe_video_config_js_1.useUnsafeVideoConfig,
|
|
127
130
|
useFrameForVolumeProp: use_audio_frame_js_1.useFrameForVolumeProp,
|
|
128
131
|
useTimelinePosition: TimelinePosition.useTimelinePosition,
|
|
@@ -188,6 +191,7 @@ exports.Internals = {
|
|
|
188
191
|
getPreviewDomElement: get_preview_dom_element_js_1.getPreviewDomElement,
|
|
189
192
|
compositionsRef: CompositionManager_js_1.compositionsRef,
|
|
190
193
|
portalNode: portal_node_js_1.portalNode,
|
|
194
|
+
setPortalNodeCurrentScale: portal_node_js_1.setPortalNodeCurrentScale,
|
|
191
195
|
waitForRoot: register_root_js_1.waitForRoot,
|
|
192
196
|
SetTimelineContext: TimelineContext_js_1.SetTimelineContext,
|
|
193
197
|
CanUseRemotionHooksProvider: CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider,
|
|
@@ -10,6 +10,8 @@ const easingToFn = ({ easing, forceSpringAllowTail, }) => {
|
|
|
10
10
|
switch (easing.type) {
|
|
11
11
|
case 'linear':
|
|
12
12
|
return easing_js_1.Easing.linear;
|
|
13
|
+
case 'step1':
|
|
14
|
+
return easing_js_1.Easing.step1;
|
|
13
15
|
case 'spring':
|
|
14
16
|
return easing_js_1.Easing.spring({
|
|
15
17
|
allowTail: (_a = forceSpringAllowTail !== null && forceSpringAllowTail !== void 0 ? forceSpringAllowTail : easing.allowTail) !== null && _a !== void 0 ? _a : undefined,
|
|
@@ -1 +1,4 @@
|
|
|
1
|
+
export declare const getPortalNodeCurrentScale: () => number;
|
|
2
|
+
export declare const subscribeToPortalNodeCurrentScale: (listener: () => void) => () => void;
|
|
3
|
+
export declare const setPortalNodeCurrentScale: (scale: number) => void;
|
|
1
4
|
export declare const portalNode: () => HTMLElement;
|
package/dist/cjs/portal-node.js
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.portalNode = void 0;
|
|
3
|
+
exports.portalNode = exports.setPortalNodeCurrentScale = exports.subscribeToPortalNodeCurrentScale = exports.getPortalNodeCurrentScale = void 0;
|
|
4
4
|
let _portalNode = null;
|
|
5
|
+
let portalNodeCurrentScale = 1;
|
|
6
|
+
let portalNodeCurrentScaleListeners = [];
|
|
7
|
+
const getPortalNodeCurrentScale = () => portalNodeCurrentScale;
|
|
8
|
+
exports.getPortalNodeCurrentScale = getPortalNodeCurrentScale;
|
|
9
|
+
const subscribeToPortalNodeCurrentScale = (listener) => {
|
|
10
|
+
portalNodeCurrentScaleListeners.push(listener);
|
|
11
|
+
return () => {
|
|
12
|
+
portalNodeCurrentScaleListeners = portalNodeCurrentScaleListeners.filter((currentListener) => currentListener !== listener);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
exports.subscribeToPortalNodeCurrentScale = subscribeToPortalNodeCurrentScale;
|
|
16
|
+
const setPortalNodeCurrentScale = (scale) => {
|
|
17
|
+
if (portalNodeCurrentScale === scale) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
portalNodeCurrentScale = scale;
|
|
21
|
+
for (const listener of portalNodeCurrentScaleListeners) {
|
|
22
|
+
listener();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.setPortalNodeCurrentScale = setPortalNodeCurrentScale;
|
|
5
26
|
const portalNode = () => {
|
|
6
27
|
if (!_portalNode) {
|
|
7
28
|
if (typeof document === 'undefined') {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type RenderResourceManager = {
|
|
3
|
+
getOrCreateResource: <T>({ key, create }: {
|
|
4
|
+
key: string;
|
|
5
|
+
create: () => {
|
|
6
|
+
resource: T;
|
|
7
|
+
dispose: () => void;
|
|
8
|
+
};
|
|
9
|
+
}) => T;
|
|
10
|
+
dispose: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare const makeRenderResourceManager: () => RenderResourceManager;
|
|
13
|
+
export declare const RenderResourceManagerContext: React.Context<RenderResourceManager | null>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RenderResourceManagerContext = exports.makeRenderResourceManager = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const makeRenderResourceManager = () => {
|
|
9
|
+
const resources = new Map();
|
|
10
|
+
let disposed = false;
|
|
11
|
+
return {
|
|
12
|
+
getOrCreateResource: ({ key, create, }) => {
|
|
13
|
+
if (disposed) {
|
|
14
|
+
throw new Error('Render resource manager has already been disposed');
|
|
15
|
+
}
|
|
16
|
+
const existing = resources.get(key);
|
|
17
|
+
if (existing) {
|
|
18
|
+
return existing.resource;
|
|
19
|
+
}
|
|
20
|
+
const created = create();
|
|
21
|
+
resources.set(key, created);
|
|
22
|
+
return created.resource;
|
|
23
|
+
},
|
|
24
|
+
dispose: () => {
|
|
25
|
+
if (disposed) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
disposed = true;
|
|
29
|
+
const resourcesToDispose = Array.from(resources.values());
|
|
30
|
+
resources.clear();
|
|
31
|
+
let firstError = null;
|
|
32
|
+
for (const resource of resourcesToDispose) {
|
|
33
|
+
try {
|
|
34
|
+
resource.dispose();
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
firstError !== null && firstError !== void 0 ? firstError : (firstError = error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (firstError !== null) {
|
|
41
|
+
throw firstError;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.makeRenderResourceManager = makeRenderResourceManager;
|
|
47
|
+
exports.RenderResourceManagerContext = react_1.default.createContext(null);
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.useCurrentScale = exports.calculateScale = exports.PreviewSizeContext = exports.CurrentScaleContext = void 0;
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
|
+
const portal_node_1 = require("./portal-node");
|
|
38
39
|
const use_remotion_environment_1 = require("./use-remotion-environment");
|
|
39
40
|
const use_unsafe_video_config_1 = require("./use-unsafe-video-config");
|
|
40
41
|
exports.CurrentScaleContext = react_1.default.createContext(null);
|
|
@@ -65,6 +66,12 @@ const useCurrentScale = (options) => {
|
|
|
65
66
|
const zoomContext = react_1.default.useContext(exports.PreviewSizeContext);
|
|
66
67
|
const config = (0, use_unsafe_video_config_1.useUnsafeVideoConfig)();
|
|
67
68
|
const env = (0, use_remotion_environment_1.useRemotionEnvironment)();
|
|
69
|
+
const [portalScale, setPortalScale] = react_1.default.useState(portal_node_1.getPortalNodeCurrentScale);
|
|
70
|
+
react_1.default.useEffect(() => {
|
|
71
|
+
const update = () => setPortalScale((0, portal_node_1.getPortalNodeCurrentScale)());
|
|
72
|
+
update();
|
|
73
|
+
return (0, portal_node_1.subscribeToPortalNodeCurrentScale)(update);
|
|
74
|
+
}, []);
|
|
68
75
|
if (hasContext === null || config === null || zoomContext === null) {
|
|
69
76
|
if (options === null || options === void 0 ? void 0 : options.dontThrowIfOutsideOfRemotion) {
|
|
70
77
|
return 1;
|
|
@@ -82,11 +89,8 @@ const useCurrentScale = (options) => {
|
|
|
82
89
|
if (hasContext.type === 'scale') {
|
|
83
90
|
return hasContext.scale;
|
|
84
91
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
compositionWidth: config.width,
|
|
89
|
-
previewSize: zoomContext.size.size,
|
|
90
|
-
});
|
|
92
|
+
// Studio initially renders the composition into an unscaled offscreen portal.
|
|
93
|
+
// Return the scale that the preview has actually committed to that portal.
|
|
94
|
+
return portalScale;
|
|
91
95
|
};
|
|
92
96
|
exports.useCurrentScale = useCurrentScale;
|
package/dist/cjs/use-schema.d.ts
CHANGED
|
@@ -35,6 +35,9 @@ export type VideoConfigNumericExpression = {
|
|
|
35
35
|
export type CanUpdateSequencePropStatusLinearEasing = {
|
|
36
36
|
type: 'linear';
|
|
37
37
|
};
|
|
38
|
+
export type CanUpdateSequencePropStatusStep1Easing = {
|
|
39
|
+
type: 'step1';
|
|
40
|
+
};
|
|
38
41
|
export type CanUpdateSequencePropStatusBezierEasing = {
|
|
39
42
|
type: 'bezier';
|
|
40
43
|
x1: number;
|
|
@@ -51,7 +54,7 @@ export type CanUpdateSequencePropStatusSpringEasing = {
|
|
|
51
54
|
overshootClamping: boolean;
|
|
52
55
|
durationRestThreshold: number | null;
|
|
53
56
|
};
|
|
54
|
-
export type CanUpdateSequencePropStatusEasing = CanUpdateSequencePropStatusLinearEasing | CanUpdateSequencePropStatusBezierEasing | CanUpdateSequencePropStatusSpringEasing;
|
|
57
|
+
export type CanUpdateSequencePropStatusEasing = CanUpdateSequencePropStatusLinearEasing | CanUpdateSequencePropStatusStep1Easing | CanUpdateSequencePropStatusBezierEasing | CanUpdateSequencePropStatusSpringEasing;
|
|
55
58
|
export declare const DEFAULT_LINEAR_EASING: CanUpdateSequencePropStatusLinearEasing;
|
|
56
59
|
export type CanUpdateSequencePropStatusClamping = {
|
|
57
60
|
left: ExtrapolateType;
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.withInteractivitySchema = exports.mergeValues = exports.selectActiveKeys = exports.readValuesFromProps = exports.getRuntimeValueForSchemaKey = exports.getNestedValue = void 0;
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
|
+
const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
|
|
38
39
|
const delete_nested_key_js_1 = require("./delete-nested-key.js");
|
|
39
40
|
const use_memoized_effects_js_1 = require("./effects/use-memoized-effects.js");
|
|
40
41
|
const enable_sequence_stack_traces_js_1 = require("./enable-sequence-stack-traces.js");
|
|
@@ -130,7 +131,8 @@ const withInteractivitySchema = ({ Component, componentName, componentIdentity,
|
|
|
130
131
|
const { _remotionInternalStack: internalStack, ...propsWithoutInternalStack } = props;
|
|
131
132
|
const cleanProps = propsWithoutInternalStack;
|
|
132
133
|
const env = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
|
|
133
|
-
|
|
134
|
+
const canUseRemotionHooks = (0, react_1.useContext)(CanUseRemotionHooks_js_1.CanUseRemotionHooks);
|
|
135
|
+
if (!env.isStudio || env.isRendering || !canUseRemotionHooks) {
|
|
134
136
|
return react_1.default.createElement(Component, {
|
|
135
137
|
...cleanProps,
|
|
136
138
|
controls: null,
|