remotion 4.0.469 → 4.0.470

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.
@@ -5,6 +5,7 @@ export declare const RemotionRootContexts: React.FC<{
5
5
  readonly numberOfAudioTags: number;
6
6
  readonly logLevel: LogLevel;
7
7
  readonly audioLatencyHint: AudioContextLatencyCategory;
8
+ readonly previewSampleRate: number | null;
8
9
  readonly videoEnabled: boolean;
9
10
  readonly audioEnabled: boolean;
10
11
  readonly frameState: Record<string, number> | null;
@@ -13,7 +13,7 @@ const SequenceManager_js_1 = require("./SequenceManager.js");
13
13
  const TimelineContext_js_1 = require("./TimelineContext.js");
14
14
  const use_media_enabled_js_1 = require("./use-media-enabled.js");
15
15
  const duration_state_js_1 = require("./video/duration-state.js");
16
- const RemotionRootContexts = ({ children, numberOfAudioTags, logLevel, audioLatencyHint, videoEnabled, audioEnabled, frameState, }) => {
16
+ const RemotionRootContexts = ({ children, numberOfAudioTags, logLevel, audioLatencyHint, previewSampleRate, videoEnabled, audioEnabled, frameState, }) => {
17
17
  const nonceContext = (0, react_1.useMemo)(() => {
18
18
  let counter = 0;
19
19
  return {
@@ -23,6 +23,6 @@ const RemotionRootContexts = ({ children, numberOfAudioTags, logLevel, audioLate
23
23
  const logging = (0, react_1.useMemo)(() => {
24
24
  return { logLevel, mountTime: Date.now() };
25
25
  }, [logLevel]);
26
- return ((0, jsx_runtime_1.jsx)(log_level_context_js_1.LogLevelContext.Provider, { value: logging, children: (0, jsx_runtime_1.jsx)(nonce_js_1.NonceContext.Provider, { value: nonceContext, children: (0, jsx_runtime_1.jsx)(TimelineContext_js_1.TimelineContextProvider, { frameState: frameState, children: (0, jsx_runtime_1.jsx)(use_media_enabled_js_1.MediaEnabledProvider, { videoEnabled: videoEnabled, audioEnabled: audioEnabled, children: (0, jsx_runtime_1.jsx)(EditorProps_js_1.EditorPropsProvider, { children: (0, jsx_runtime_1.jsx)(prefetch_state_js_1.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(SequenceManager_js_1.SequenceManagerProvider, { children: (0, jsx_runtime_1.jsx)(duration_state_js_1.DurationsContextProvider, { children: (0, jsx_runtime_1.jsx)(buffering_js_1.BufferingProvider, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: audioEnabled, children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfAudioTags, children: children }) }) }) }) }) }) }) }) }) }) }));
26
+ return ((0, jsx_runtime_1.jsx)(log_level_context_js_1.LogLevelContext.Provider, { value: logging, children: (0, jsx_runtime_1.jsx)(nonce_js_1.NonceContext.Provider, { value: nonceContext, children: (0, jsx_runtime_1.jsx)(TimelineContext_js_1.TimelineContextProvider, { frameState: frameState, children: (0, jsx_runtime_1.jsx)(use_media_enabled_js_1.MediaEnabledProvider, { videoEnabled: videoEnabled, audioEnabled: audioEnabled, children: (0, jsx_runtime_1.jsx)(EditorProps_js_1.EditorPropsProvider, { children: (0, jsx_runtime_1.jsx)(prefetch_state_js_1.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(SequenceManager_js_1.SequenceManagerProvider, { children: (0, jsx_runtime_1.jsx)(duration_state_js_1.DurationsContextProvider, { children: (0, jsx_runtime_1.jsx)(buffering_js_1.BufferingProvider, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: audioEnabled, previewSampleRate: previewSampleRate, children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfAudioTags, children: children }) }) }) }) }) }) }) }) }) }) }));
27
27
  };
28
28
  exports.RemotionRootContexts = RemotionRootContexts;
@@ -1,5 +1,4 @@
1
- import { type AudioHTMLAttributes } from 'react';
2
- import React from 'react';
1
+ import React, { type AudioHTMLAttributes } from 'react';
3
2
  import type { SharedElementSourceNode } from './shared-element-source-node.js';
4
3
  import type { RemotionAudioContextState } from './use-audio-context.js';
5
4
  /**
@@ -85,6 +84,7 @@ export declare const SharedAudioContextProvider: React.FC<{
85
84
  readonly children: React.ReactNode;
86
85
  readonly audioLatencyHint: AudioContextLatencyCategory;
87
86
  readonly audioEnabled: boolean;
87
+ readonly previewSampleRate: number | null;
88
88
  }>;
89
89
  export declare const SharedAudioTagsContextProvider: React.FC<{
90
90
  readonly numberOfAudioTags: number;
@@ -88,12 +88,20 @@ const shouldSaveForLater = (state) => {
88
88
  }
89
89
  throw new Error(`Unexpected audio context state: ${state}`);
90
90
  };
91
- const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled }) => {
91
+ const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, previewSampleRate }) => {
92
92
  const logLevel = (0, log_level_context_js_1.useLogLevel)();
93
+ const sampleRate = previewSampleRate !== null && previewSampleRate !== void 0 ? previewSampleRate : 48000;
94
+ (0, react_1.useEffect)(() => {
95
+ if (typeof window === 'undefined') {
96
+ return;
97
+ }
98
+ window.remotion_sampleRate = sampleRate;
99
+ }, [sampleRate]);
93
100
  const ctxAndGain = (0, use_audio_context_js_1.useSingletonAudioContext)({
94
101
  logLevel,
95
102
  latencyHint: audioLatencyHint,
96
103
  audioEnabled,
104
+ sampleRate,
97
105
  });
98
106
  const audioContextIsPlayingEventually = (0, react_1.useRef)(false);
99
107
  const isResuming = (0, react_1.useRef)(null);
@@ -1,9 +1,10 @@
1
1
  import type { LogLevel } from '../log';
2
2
  export type RemotionAudioContextState = AudioContextState | 'running-to-suspended' | 'suspended-to-running';
3
- export declare const useSingletonAudioContext: ({ logLevel, latencyHint, audioEnabled, }: {
3
+ export declare const useSingletonAudioContext: ({ logLevel, latencyHint, audioEnabled, sampleRate, }: {
4
4
  logLevel: LogLevel;
5
5
  latencyHint: AudioContextLatencyCategory;
6
6
  audioEnabled: boolean;
7
+ sampleRate: number;
7
8
  }) => {
8
9
  audioContext: AudioContext;
9
10
  gainNode: GainNode;
@@ -15,8 +15,12 @@ const warnOnce = (logLevel) => {
15
15
  log_1.Log.warn({ logLevel, tag: null }, 'AudioContext is not supported in this browser');
16
16
  }
17
17
  };
18
- const useSingletonAudioContext = ({ logLevel, latencyHint, audioEnabled, }) => {
18
+ const useSingletonAudioContext = ({ logLevel, latencyHint, audioEnabled, sampleRate, }) => {
19
19
  const env = (0, use_remotion_environment_1.useRemotionEnvironment)();
20
+ const initialSampleRate = (0, react_1.useRef)(sampleRate);
21
+ if (sampleRate !== initialSampleRate.current) {
22
+ throw new Error(`Changing the AudioContext sample rate dynamically is not supported. The sample rate was initialized with ${initialSampleRate.current} Hz, but ${sampleRate} Hz was passed later.`);
23
+ }
20
24
  const context = (0, react_1.useMemo)(() => {
21
25
  if (env.isRendering) {
22
26
  return null;
@@ -33,7 +37,7 @@ const useSingletonAudioContext = ({ logLevel, latencyHint, audioEnabled, }) => {
33
37
  // By default, this can end up being 44100Hz.
34
38
  // Playing a 48000Hz file in a 44100Hz context, such as https://remotion.media/video.mp4 in a @remotion/media tag
35
39
  // we observe some issues that seem to go away when we set the sample rate to 48000 with Sony LinkBuds Bluetooth headphones.
36
- sampleRate: 48000,
40
+ sampleRate,
37
41
  });
38
42
  const gainNode = audioContext.createGain();
39
43
  gainNode.connect(audioContext.destination);
@@ -79,7 +83,7 @@ const useSingletonAudioContext = ({ logLevel, latencyHint, audioEnabled, }) => {
79
83
  resume,
80
84
  suspend,
81
85
  };
82
- }, [logLevel, latencyHint, env.isRendering, audioEnabled]);
86
+ }, [logLevel, latencyHint, env.isRendering, audioEnabled, sampleRate]);
83
87
  return context;
84
88
  };
85
89
  exports.useSingletonAudioContext = useSingletonAudioContext;
@@ -11,8 +11,8 @@ export type EffectApplyParams<P, S> = {
11
11
  readonly gpuDevice: AnyGpuDevice | null;
12
12
  /**
13
13
  * When `true`, WebGL `texImage2D` uploads use `UNPACK_FLIP_Y_WEBGL` so DOM-style
14
- * 2D frame canvases match clip-space UVs. Set by `runEffectChain` — `false` for
15
- * prior WebGL outputs and `ImageBitmap` bridges from WebGL.
14
+ * canvas sources match clip-space UVs. Set by `runEffectChain` — `false` for
15
+ * `ImageBitmap` bridges from WebGL, which are already oriented for upload.
16
16
  */
17
17
  readonly flipSourceY: boolean;
18
18
  };
@@ -2,7 +2,7 @@ import { CanvasPool } from './canvas-pool.js';
2
2
  import type { EffectDefinition, EffectDefinitionAndStack } from './effect-types.js';
3
3
  export type EffectChainState = {
4
4
  pool: CanvasPool;
5
- setupCache: WeakMap<EffectDefinition<unknown, unknown>, unknown>;
5
+ setupCache: WeakMap<EffectDefinition<unknown, unknown>, WeakMap<HTMLCanvasElement, unknown>>;
6
6
  cleanupRegistry: Array<{
7
7
  definition: EffectDefinition<unknown, unknown>;
8
8
  state: unknown;
@@ -20,11 +20,16 @@ const cleanupEffectChainState = (state) => {
20
20
  exports.cleanupEffectChainState = cleanupEffectChainState;
21
21
  const ensureSetup = (state, def, target) => {
22
22
  const widened = def;
23
- if (state.setupCache.has(widened)) {
24
- return state.setupCache.get(widened);
23
+ let cacheForDefinition = state.setupCache.get(widened);
24
+ if (!cacheForDefinition) {
25
+ cacheForDefinition = new WeakMap();
26
+ state.setupCache.set(widened, cacheForDefinition);
27
+ }
28
+ if (cacheForDefinition.has(target)) {
29
+ return cacheForDefinition.get(target);
25
30
  }
26
31
  const setupState = def.setup(target);
27
- state.setupCache.set(widened, setupState);
32
+ cacheForDefinition.set(target, setupState);
28
33
  state.cleanupRegistry.push({ definition: widened, state: setupState });
29
34
  return setupState;
30
35
  };
@@ -68,7 +73,9 @@ const runEffectChain = async ({ state, source, effects, output, width, height, }
68
73
  if (isCancelled()) {
69
74
  return false;
70
75
  }
71
- // Raw component sources are 2D frame canvases (Gif, WrappedCanvas.canvas, …).
76
+ // Canvas sources are DOM-oriented. Flip them when uploading into WebGL so
77
+ // texture coordinates match clip-space output. `ImageBitmap` bridges below
78
+ // opt out because they are already oriented for upload.
72
79
  let flipWebGLSourceY = true;
73
80
  for (let runIndex = 0; runIndex < runs.length; runIndex++) {
74
81
  const run = runs[runIndex];
@@ -88,7 +95,10 @@ const runEffectChain = async ({ state, source, effects, output, width, height, }
88
95
  flipSourceY: run.backend === 'webgl2' ? flipWebGLSourceY : false,
89
96
  });
90
97
  if (run.backend === 'webgl2') {
91
- flipWebGLSourceY = false;
98
+ // Same-backend ping-pong passes feed the previous WebGL canvas back
99
+ // through `texImage2D()`. That source is still a DOM canvas, so the
100
+ // next upload also needs to be flipped.
101
+ flipWebGLSourceY = true;
92
102
  state.pool.assertContextNotLost(dst);
93
103
  }
94
104
  currentImage = dst;
@@ -55,7 +55,8 @@ declare global {
55
55
  remotion_envVariables: string;
56
56
  remotion_isMainTab: boolean;
57
57
  remotion_mediaCacheSizeInBytes: number | null;
58
- remotion_sampleRate: number;
58
+ remotion_sampleRate: number | null;
59
+ remotion_previewSampleRate: number | null;
59
60
  remotion_initialMemoryAvailable: number | null;
60
61
  remotion_collectAssets: () => TRenderAsset[];
61
62
  remotion_isPlayer: boolean;
@@ -92,20 +93,20 @@ export type BundleEvaluationState = {
92
93
  export type BundleState = BundleIndexState | BundleEvaluationState | BundleCompositionState;
93
94
  export * from './AbsoluteFill.js';
94
95
  export * from './animated-image/index.js';
95
- export type { EffectDefinitionAndStack, EffectDescriptor, EffectsProp, EffectDefinition, EffectFactory, } from './effects/index.js';
96
+ export type { EffectDefinition, EffectDefinitionAndStack, EffectDescriptor, EffectFactory, EffectsProp, } from './effects/index.js';
96
97
  /**
97
98
  * @description Renders a solid-color rectangle on a `<canvas>`.
98
99
  * @see [Documentation](https://www.remotion.dev/docs/solid)
99
100
  */
100
- export { Solid } from './effects/Solid.js';
101
- export type { SolidProps } from './effects/Solid.js';
102
- export { HtmlInCanvas, HTML_IN_CANVAS_UNSUPPORTED_MESSAGE, isHtmlInCanvasSupported, type HtmlInCanvasOnInit, type HtmlInCanvasOnInitCleanup, type HtmlInCanvasOnPaint, } from './HtmlInCanvas.js';
103
- export type { HtmlInCanvasOnPaintParams, HtmlInCanvasProps, } from './HtmlInCanvas.js';
104
101
  export type { AnyZodObject } from './any-zod-type.js';
105
102
  export { Artifact } from './Artifact.js';
106
103
  export { Audio, Html5Audio, RemotionAudioProps } from './audio/index.js';
107
104
  export type { LoopVolumeCurveBehavior } from './audio/use-audio-frame.js';
108
105
  export { cancelRender } from './cancel-render.js';
106
+ export { Solid } from './effects/Solid.js';
107
+ export type { SolidProps } from './effects/Solid.js';
108
+ export { HTML_IN_CANVAS_UNSUPPORTED_MESSAGE, HtmlInCanvas, isHtmlInCanvasSupported, type HtmlInCanvasOnInit, type HtmlInCanvasOnInitCleanup, type HtmlInCanvasOnPaint, } from './HtmlInCanvas.js';
109
+ export type { HtmlInCanvasOnPaintParams, HtmlInCanvasProps, } from './HtmlInCanvas.js';
109
110
  /**
110
111
  * @description Renders a static image to a `<canvas>` and applies Remotion effects.
111
112
  * @see [Documentation](https://www.remotion.dev/docs/canvasimage)
@@ -121,16 +122,16 @@ export { DownloadBehavior } from './download-behavior.js';
121
122
  export * from './easing.js';
122
123
  export * from './Folder.js';
123
124
  export * from './freeze.js';
124
- export type { NonceHistory } from './nonce.js';
125
125
  export { getRemotionEnvironment } from './get-remotion-environment.js';
126
126
  export { getStaticFiles, StaticFile } from './get-static-files.js';
127
127
  export * from './IFrame.js';
128
128
  export { Img, ImgProps } from './Img.js';
129
129
  export * from './internals.js';
130
- export { interpolateColors } from './interpolate-colors.js';
130
+ export { interpolateColors, type InterpolateColorsOptions, } from './interpolate-colors.js';
131
131
  export { LogLevel } from './log.js';
132
132
  export { Loop } from './loop/index.js';
133
- export { assertValidInterpolateEasingOption, EasingFunction, ExtrapolateType, interpolate, InterpolateOptions, random, RandomSeed, } from './no-react';
133
+ export { assertValidInterpolateEasingOption, assertValidInterpolatePosterizeOption, EasingFunction, ExtrapolateType, interpolate, InterpolateOptions, random, RandomSeed, } from './no-react';
134
+ export type { NonceHistory } from './nonce.js';
134
135
  export { prefetch, PrefetchOnProgress } from './prefetch.js';
135
136
  export { registerRoot } from './register-root.js';
136
137
  export type { PixelFormat, VideoImageFormat } from './render-types.js';
package/dist/cjs/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Config = exports.Experimental = exports.watchStaticFile = exports.MediaPlaybackError = exports.Video = exports.OffthreadVideo = exports.Html5Video = exports.useRemotionEnvironment = exports.useDelayRender = exports.useCurrentScale = exports.useCurrentFrame = exports.useBufferState = exports.staticFile = exports.Series = exports.Sequence = exports.registerRoot = exports.prefetch = exports.random = exports.interpolate = exports.assertValidInterpolateEasingOption = exports.Loop = exports.interpolateColors = exports.Img = exports.getStaticFiles = exports.getRemotionEnvironment = exports.delayRender = exports.continueRender = exports.getInputProps = exports.Composition = exports.CanvasImage = exports.cancelRender = exports.Html5Audio = exports.Audio = exports.Artifact = exports.isHtmlInCanvasSupported = exports.HTML_IN_CANVAS_UNSUPPORTED_MESSAGE = exports.HtmlInCanvas = exports.Solid = void 0;
17
+ exports.Config = exports.Experimental = exports.watchStaticFile = exports.MediaPlaybackError = exports.Video = exports.OffthreadVideo = exports.Html5Video = exports.useRemotionEnvironment = exports.useDelayRender = exports.useCurrentScale = exports.useCurrentFrame = exports.useBufferState = exports.staticFile = exports.Series = exports.Sequence = exports.registerRoot = exports.prefetch = exports.random = exports.interpolate = exports.assertValidInterpolatePosterizeOption = exports.assertValidInterpolateEasingOption = exports.Loop = exports.interpolateColors = exports.Img = exports.getStaticFiles = exports.getRemotionEnvironment = exports.delayRender = exports.continueRender = exports.getInputProps = exports.Composition = exports.CanvasImage = exports.isHtmlInCanvasSupported = exports.HtmlInCanvas = exports.HTML_IN_CANVAS_UNSUPPORTED_MESSAGE = exports.Solid = exports.cancelRender = exports.Html5Audio = exports.Audio = exports.Artifact = void 0;
18
18
  require("./_check-rsc.js");
19
19
  require("./asset-types.js");
20
20
  const Clipper_js_1 = require("./Clipper.js");
@@ -27,16 +27,6 @@ const Sequence_js_1 = require("./Sequence.js");
27
27
  (0, multiple_versions_warning_js_1.checkMultipleRemotionVersions)();
28
28
  __exportStar(require("./AbsoluteFill.js"), exports);
29
29
  __exportStar(require("./animated-image/index.js"), exports);
30
- /**
31
- * @description Renders a solid-color rectangle on a `<canvas>`.
32
- * @see [Documentation](https://www.remotion.dev/docs/solid)
33
- */
34
- var Solid_js_1 = require("./effects/Solid.js");
35
- Object.defineProperty(exports, "Solid", { enumerable: true, get: function () { return Solid_js_1.Solid; } });
36
- var HtmlInCanvas_js_1 = require("./HtmlInCanvas.js");
37
- Object.defineProperty(exports, "HtmlInCanvas", { enumerable: true, get: function () { return HtmlInCanvas_js_1.HtmlInCanvas; } });
38
- Object.defineProperty(exports, "HTML_IN_CANVAS_UNSUPPORTED_MESSAGE", { enumerable: true, get: function () { return HtmlInCanvas_js_1.HTML_IN_CANVAS_UNSUPPORTED_MESSAGE; } });
39
- Object.defineProperty(exports, "isHtmlInCanvasSupported", { enumerable: true, get: function () { return HtmlInCanvas_js_1.isHtmlInCanvasSupported; } });
40
30
  var Artifact_js_1 = require("./Artifact.js");
41
31
  Object.defineProperty(exports, "Artifact", { enumerable: true, get: function () { return Artifact_js_1.Artifact; } });
42
32
  var index_js_1 = require("./audio/index.js");
@@ -44,6 +34,12 @@ Object.defineProperty(exports, "Audio", { enumerable: true, get: function () { r
44
34
  Object.defineProperty(exports, "Html5Audio", { enumerable: true, get: function () { return index_js_1.Html5Audio; } });
45
35
  var cancel_render_js_1 = require("./cancel-render.js");
46
36
  Object.defineProperty(exports, "cancelRender", { enumerable: true, get: function () { return cancel_render_js_1.cancelRender; } });
37
+ var Solid_js_1 = require("./effects/Solid.js");
38
+ Object.defineProperty(exports, "Solid", { enumerable: true, get: function () { return Solid_js_1.Solid; } });
39
+ var HtmlInCanvas_js_1 = require("./HtmlInCanvas.js");
40
+ Object.defineProperty(exports, "HTML_IN_CANVAS_UNSUPPORTED_MESSAGE", { enumerable: true, get: function () { return HtmlInCanvas_js_1.HTML_IN_CANVAS_UNSUPPORTED_MESSAGE; } });
41
+ Object.defineProperty(exports, "HtmlInCanvas", { enumerable: true, get: function () { return HtmlInCanvas_js_1.HtmlInCanvas; } });
42
+ Object.defineProperty(exports, "isHtmlInCanvasSupported", { enumerable: true, get: function () { return HtmlInCanvas_js_1.isHtmlInCanvasSupported; } });
47
43
  /**
48
44
  * @description Renders a static image to a `<canvas>` and applies Remotion effects.
49
45
  * @see [Documentation](https://www.remotion.dev/docs/canvasimage)
@@ -74,6 +70,7 @@ var index_js_3 = require("./loop/index.js");
74
70
  Object.defineProperty(exports, "Loop", { enumerable: true, get: function () { return index_js_3.Loop; } });
75
71
  var no_react_1 = require("./no-react");
76
72
  Object.defineProperty(exports, "assertValidInterpolateEasingOption", { enumerable: true, get: function () { return no_react_1.assertValidInterpolateEasingOption; } });
73
+ Object.defineProperty(exports, "assertValidInterpolatePosterizeOption", { enumerable: true, get: function () { return no_react_1.assertValidInterpolatePosterizeOption; } });
77
74
  Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return no_react_1.interpolate; } });
78
75
  Object.defineProperty(exports, "random", { enumerable: true, get: function () { return no_react_1.random; } });
79
76
  var prefetch_js_1 = require("./prefetch.js");
@@ -18,7 +18,7 @@ import { type CanUpdateEffectPropsResponse, type CanUpdateEffectPropsResponseFal
18
18
  import * as TimelinePosition from './timeline-position-state.js';
19
19
  import { type PlaybackRateContextValue, type SetTimelineContextValue, type TimelineContextValue } from './TimelineContext.js';
20
20
  import { truthy } from './truthy.js';
21
- import type { CanUpdateSequencePropStatusFalse, CanUpdateSequencePropStatusTrue, GetCodeValues, GetDragOverrides, GetEffectCodeValues, GetEffectDragOverrides } from './use-schema.js';
21
+ import type { CanUpdateSequencePropStatusFalse, CanUpdateSequencePropStatusKeyframed, CanUpdateSequencePropStatusTrue, GetCodeValues, GetDragOverrides, GetEffectCodeValues, GetEffectDragOverrides } from './use-schema.js';
22
22
  import { type CanUpdateSequencePropStatus, type CodeValues, type DragOverrides, type EffectDragOverrides } from './use-schema.js';
23
23
  import type { MediaVolumeContextValue, SetMediaVolumeContextValue } from './volume-position-state.js';
24
24
  import type { WatchRemotionStaticFilesPayload } from './watch-static-file.js';
@@ -253,6 +253,7 @@ export declare const Internals: {
253
253
  readonly numberOfAudioTags: number;
254
254
  readonly logLevel: import("./log.js").LogLevel;
255
255
  readonly audioLatencyHint: AudioContextLatencyCategory;
256
+ readonly previewSampleRate: number | null;
256
257
  readonly videoEnabled: boolean;
257
258
  readonly audioEnabled: boolean;
258
259
  readonly frameState: Record<string, number> | null;
@@ -321,6 +322,7 @@ export declare const Internals: {
321
322
  readonly children: React.ReactNode;
322
323
  readonly audioLatencyHint: AudioContextLatencyCategory;
323
324
  readonly audioEnabled: boolean;
325
+ readonly previewSampleRate: number | null;
324
326
  }>;
325
327
  readonly SharedAudioTagsContext: import("react").Context<{
326
328
  registerAudio: (options: {
@@ -623,6 +625,8 @@ export declare const Internals: {
623
625
  readonly useEffectChainState: () => {
624
626
  get: (width: number, height: number) => import("./effects/run-effect-chain.js").EffectChainState | null;
625
627
  };
628
+ readonly createEffectChainState: (width: number, height: number) => import("./effects/run-effect-chain.js").EffectChainState;
629
+ readonly cleanupEffectChainState: (state: import("./effects/run-effect-chain.js").EffectChainState) => void;
626
630
  readonly runEffectChain: ({ state, source, effects, output, width, height, }: import("./effects/run-effect-chain.js").RunEffectChainOptions) => Promise<boolean>;
627
631
  readonly useMemoizedEffects: ({ effects, overrideId, }: {
628
632
  effects: readonly import("./index.js").EffectDescriptor<unknown>[];
@@ -632,15 +636,20 @@ export declare const Internals: {
632
636
  readonly createEffect: <P, S>(definition: import("./index.js").EffectDefinition<P, S>) => import("./index.js").EffectFactory<P>;
633
637
  readonly createWebGLContextError: (effectName: string) => Error;
634
638
  readonly createWebGL2ContextError: (effectName: string) => Error;
635
- readonly computeEffectiveSchemaValuesDotNotation: ({ schema, currentValue, overrideValues, propStatus, }: {
639
+ readonly computeEffectiveSchemaValuesDotNotation: ({ schema, currentValue, overrideValues, propStatus, frame, }: {
636
640
  schema: SequenceSchema;
637
641
  currentValue: Record<string, unknown>;
638
642
  overrideValues: Record<string, unknown>;
639
643
  propStatus: Record<string, CanUpdateSequencePropStatus> | undefined;
644
+ frame: number | null;
640
645
  }) => {
641
646
  merged: Record<string, unknown>;
642
647
  propsToDelete: Set<string>;
643
648
  };
649
+ readonly interpolateKeyframedStatus: ({ frame, status, }: {
650
+ frame: number;
651
+ status: CanUpdateSequencePropStatusKeyframed;
652
+ }) => number | string | null;
644
653
  readonly OverrideIdsToNodePathsGettersContext: import("react").Context<OverrideToNodePathGetters>;
645
654
  readonly OverrideIdsToNodePathsSettersContext: import("react").Context<OverrideToNodeSetters>;
646
655
  readonly findPropsToDelete: ({ schema, key, value, }: {
@@ -666,4 +675,4 @@ export declare const Internals: {
666
675
  };
667
676
  readonly hiddenField: SequenceFieldSchema;
668
677
  };
669
- export type { CannotUpdateSequenceReason, CanUpdateEffectPropsResponse, CanUpdateEffectPropsResponseFalse, CanUpdateEffectPropsResponseTrue, CanUpdateSequencePropsResponse, CanUpdateSequencePropsResponseFalse, CanUpdateSequencePropsResponseTrue, CanUpdateSequencePropStatus, CanUpdateSequencePropStatusFalse, CanUpdateSequencePropStatusTrue, CodeValues, CompositionManagerContext, CompProps, DragOverrides, EffectDragOverrides, GetCodeValues, GetDragOverrides, GetEffectCodeValues, GetEffectDragOverrides, LoggingContextValue, MediaVolumeContextValue, NonceHistory, OverrideIdsToNodePathsGettersContext, OverrideIdsToNodePathsSettersContext, OverrideIdToNodePaths, OverrideToNodePathGetters, OverrideToNodeSetters, PlaybackRateContextValue, RemotionEnvironment, ResolvedStackLocation, ScheduleAudioNodeOptions, ScheduleAudioNodeResult, SequenceFieldSchema, SequenceNodePath, SequencePropsSubscriptionKey, SequenceSchema, SerializedJSONWithCustomFields, SetMediaVolumeContextValue, SetTimelineContextValue, TCompMetadata, TComposition, TimelineContextValue, TRenderAsset, TSequence, VisibleFieldSchema, WatchRemotionStaticFilesPayload, RemotionAudioContextState, };
678
+ export type { CannotUpdateSequenceReason, CanUpdateEffectPropsResponse, CanUpdateEffectPropsResponseFalse, CanUpdateEffectPropsResponseTrue, CanUpdateSequencePropsResponse, CanUpdateSequencePropsResponseFalse, CanUpdateSequencePropsResponseTrue, CanUpdateSequencePropStatus, CanUpdateSequencePropStatusFalse, CanUpdateSequencePropStatusKeyframed, CanUpdateSequencePropStatusTrue, CodeValues, CompositionManagerContext, CompProps, DragOverrides, EffectDragOverrides, GetCodeValues, GetDragOverrides, GetEffectCodeValues, GetEffectDragOverrides, LoggingContextValue, MediaVolumeContextValue, NonceHistory, OverrideIdsToNodePathsGettersContext, OverrideIdsToNodePathsSettersContext, OverrideIdToNodePaths, OverrideToNodePathGetters, OverrideToNodeSetters, PlaybackRateContextValue, RemotionAudioContextState, RemotionEnvironment, ResolvedStackLocation, ScheduleAudioNodeOptions, ScheduleAudioNodeResult, SequenceFieldSchema, SequenceNodePath, SequencePropsSubscriptionKey, SequenceSchema, SerializedJSONWithCustomFields, SetMediaVolumeContextValue, SetTimelineContextValue, TCompMetadata, TComposition, TimelineContextValue, TRenderAsset, TSequence, VisibleFieldSchema, WatchRemotionStaticFilesPayload, };
@@ -62,6 +62,7 @@ const get_effective_visual_mode_value_js_1 = require("./get-effective-visual-mod
62
62
  const get_preview_dom_element_js_1 = require("./get-preview-dom-element.js");
63
63
  const get_remotion_environment_js_1 = require("./get-remotion-environment.js");
64
64
  const input_props_override_js_1 = require("./input-props-override.js");
65
+ const interpolate_keyframed_status_js_1 = require("./interpolate-keyframed-status.js");
65
66
  const is_player_js_1 = require("./is-player.js");
66
67
  const log_level_context_js_1 = require("./log-level-context.js");
67
68
  const log_js_1 = require("./log.js");
@@ -230,6 +231,8 @@ exports.Internals = {
230
231
  getEffectiveVisualModeValue: get_effective_visual_mode_value_js_1.getEffectiveVisualModeValue,
231
232
  CompositionRenderErrorContext: composition_render_error_context_js_1.CompositionRenderErrorContext,
232
233
  useEffectChainState: use_effect_chain_state_js_1.useEffectChainState,
234
+ createEffectChainState: run_effect_chain_js_1.createEffectChainState,
235
+ cleanupEffectChainState: run_effect_chain_js_1.cleanupEffectChainState,
233
236
  runEffectChain: run_effect_chain_js_1.runEffectChain,
234
237
  useMemoizedEffects: use_memoized_effects_js_1.useMemoizedEffects,
235
238
  useMemoizedEffectDefinitions: use_memoized_effects_js_1.useMemoizedEffectDefinitions,
@@ -237,6 +240,7 @@ exports.Internals = {
237
240
  createWebGLContextError: webgl2_context_error_js_1.createWebGLContextError,
238
241
  createWebGL2ContextError: webgl2_context_error_js_1.createWebGL2ContextError,
239
242
  computeEffectiveSchemaValuesDotNotation: use_schema_js_1.computeEffectiveSchemaValuesDotNotation,
243
+ interpolateKeyframedStatus: interpolate_keyframed_status_js_1.interpolateKeyframedStatus,
240
244
  OverrideIdsToNodePathsGettersContext: sequence_node_path_js_1.OverrideIdsToNodePathsGettersContext,
241
245
  OverrideIdsToNodePathsSettersContext: sequence_node_path_js_1.OverrideIdsToNodePathsSettersContext,
242
246
  findPropsToDelete: find_props_to_delete_js_1.findPropsToDelete,
@@ -2,8 +2,11 @@
2
2
  * Copied from:
3
3
  * https://github.com/software-mansion/react-native-reanimated/blob/master/src/reanimated2/Colors.ts
4
4
  */
5
+ export type InterpolateColorsOptions = {
6
+ posterize: number | undefined;
7
+ };
5
8
  export declare const colorNames: {
6
9
  [key: string]: number;
7
10
  };
8
11
  export declare function processColor(color: string): number;
9
- export declare const interpolateColors: (input: number, inputRange: readonly number[], outputRange: readonly string[]) => string;
12
+ export declare const interpolateColors: (input: number, inputRange: readonly number[], outputRange: readonly string[], options?: InterpolateColorsOptions) => string;
@@ -536,11 +536,12 @@ function processColor(color) {
536
536
  const normalizedColor = normalizeColor(color);
537
537
  return ((normalizedColor << 24) | (normalizedColor >>> 8)) >>> 0; // argb
538
538
  }
539
- const interpolateColorsRGB = (value, inputRange, colors) => {
539
+ const interpolateColorsRGB = (value, inputRange, colors, options) => {
540
540
  const [r, g, b, a] = [red, green, blue, opacity].map((f) => {
541
541
  const unrounded = (0, interpolate_js_1.interpolate)(value, inputRange, colors.map((c) => f(c)), {
542
542
  extrapolateLeft: 'clamp',
543
543
  extrapolateRight: 'clamp',
544
+ posterize: options === null || options === void 0 ? void 0 : options.posterize,
544
545
  });
545
546
  if (f === opacity) {
546
547
  return Number(unrounded.toFixed(3));
@@ -553,7 +554,7 @@ const interpolateColorsRGB = (value, inputRange, colors) => {
553
554
  * @description Allows you to map a range of values to colors using a concise syntax.
554
555
  * @see [Documentation](https://remotion.dev/docs/interpolate-colors)
555
556
  */
556
- const interpolateColors = (input, inputRange, outputRange) => {
557
+ const interpolateColors = (input, inputRange, outputRange, options) => {
557
558
  if (typeof input === 'undefined') {
558
559
  throw new TypeError('input can not be undefined');
559
560
  }
@@ -571,6 +572,6 @@ const interpolateColors = (input, inputRange, outputRange) => {
571
572
  ' values provided) must have the same length');
572
573
  }
573
574
  const processedOutputRange = outputRange.map((c) => processColor(c));
574
- return interpolateColorsRGB(input, inputRange, processedOutputRange);
575
+ return interpolateColorsRGB(input, inputRange, processedOutputRange, options);
575
576
  };
576
577
  exports.interpolateColors = interpolateColors;
@@ -0,0 +1,5 @@
1
+ import type { CanUpdateSequencePropStatusKeyframed } from './use-schema.js';
2
+ export declare const interpolateKeyframedStatus: ({ frame, status, }: {
3
+ frame: number;
4
+ status: CanUpdateSequencePropStatusKeyframed;
5
+ }) => number | string | null;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.interpolateKeyframedStatus = void 0;
4
+ const bezier_js_1 = require("./bezier.js");
5
+ const easing_js_1 = require("./easing.js");
6
+ const interpolate_colors_js_1 = require("./interpolate-colors.js");
7
+ const interpolate_js_1 = require("./interpolate.js");
8
+ const easingToFn = (e) => {
9
+ if (e === 'linear') {
10
+ return easing_js_1.Easing.linear;
11
+ }
12
+ return (0, bezier_js_1.bezier)(e[0], e[1], e[2], e[3]);
13
+ };
14
+ const interpolateKeyframedStatus = ({ frame, status, }) => {
15
+ const { keyframes, easing, clamping, interpolationFunction } = status;
16
+ if (keyframes.length === 0) {
17
+ return null;
18
+ }
19
+ const inputRange = keyframes.map((k) => k.frame);
20
+ const outputs = keyframes.map((k) => k.value);
21
+ if (interpolationFunction === 'interpolateColors') {
22
+ if (!outputs.every((v) => typeof v === 'string')) {
23
+ return null;
24
+ }
25
+ if (keyframes.length === 1) {
26
+ return outputs[0];
27
+ }
28
+ try {
29
+ return (0, interpolate_colors_js_1.interpolateColors)(frame, inputRange, outputs, {
30
+ posterize: status.posterize,
31
+ });
32
+ }
33
+ catch (_a) {
34
+ return null;
35
+ }
36
+ }
37
+ if (interpolationFunction !== 'interpolate') {
38
+ return null;
39
+ }
40
+ if (!outputs.every((v) => typeof v === 'number')) {
41
+ return null;
42
+ }
43
+ if (keyframes.length === 1) {
44
+ return outputs[0];
45
+ }
46
+ try {
47
+ return (0, interpolate_js_1.interpolate)(frame, inputRange, outputs, {
48
+ easing: easing.map(easingToFn),
49
+ extrapolateLeft: clamping.left,
50
+ extrapolateRight: clamping.right,
51
+ posterize: status.posterize,
52
+ });
53
+ }
54
+ catch (_b) {
55
+ return null;
56
+ }
57
+ };
58
+ exports.interpolateKeyframedStatus = interpolateKeyframedStatus;
@@ -8,6 +8,8 @@ export type InterpolateOptions = Partial<{
8
8
  easing: EasingFunction | readonly EasingFunction[];
9
9
  extrapolateLeft: ExtrapolateType;
10
10
  extrapolateRight: ExtrapolateType;
11
+ posterize: number;
11
12
  }>;
12
13
  export declare function assertValidInterpolateEasingOption(easing: EasingFunction | readonly EasingFunction[] | undefined, inputRangeLength: number): void;
14
+ export declare function assertValidInterpolatePosterizeOption(posterize: number | undefined): void;
13
15
  export declare function interpolate(input: number, inputRange: readonly number[], outputRange: readonly number[], options?: InterpolateOptions): number;
@@ -2,6 +2,7 @@
2
2
  // Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/nodes/AnimatedInterpolation.js
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.assertValidInterpolateEasingOption = assertValidInterpolateEasingOption;
5
+ exports.assertValidInterpolatePosterizeOption = assertValidInterpolatePosterizeOption;
5
6
  exports.interpolate = interpolate;
6
7
  function interpolateFunction(input, inputRange, outputRange, options) {
7
8
  const { extrapolateLeft, extrapolateRight, easing } = options;
@@ -95,6 +96,16 @@ function assertValidInterpolateEasingOption(easing, inputRangeLength) {
95
96
  }
96
97
  }
97
98
  }
99
+ function assertValidInterpolatePosterizeOption(posterize) {
100
+ if (posterize === undefined) {
101
+ return;
102
+ }
103
+ if (typeof posterize !== 'number' ||
104
+ !Number.isFinite(posterize) ||
105
+ posterize <= 0) {
106
+ throw new Error(`posterize must be a positive finite number, but got ${posterize}`);
107
+ }
108
+ }
98
109
  /*
99
110
  * @description Allows you to map a range of values to another using a concise syntax.
100
111
  * @see [Documentation](https://remotion.dev/docs/interpolate)
@@ -120,6 +131,7 @@ function interpolate(input, inputRange, outputRange, options) {
120
131
  checkInfiniteRange('outputRange', outputRange);
121
132
  checkValidInputRange(inputRange);
122
133
  assertValidInterpolateEasingOption(options === null || options === void 0 ? void 0 : options.easing, inputRange.length);
134
+ assertValidInterpolatePosterizeOption(options === null || options === void 0 ? void 0 : options.posterize);
123
135
  const easingOption = options === null || options === void 0 ? void 0 : options.easing;
124
136
  const defaultEasing = (num) => num;
125
137
  const resolveEasingForSegment = (segmentIndex) => {
@@ -146,8 +158,11 @@ function interpolate(input, inputRange, outputRange, options) {
146
158
  if (inputRange.length === 1) {
147
159
  return outputRange[0];
148
160
  }
149
- const range = findRange(input, inputRange);
150
- return interpolateFunction(input, [inputRange[range], inputRange[range + 1]], [outputRange[range], outputRange[range + 1]], {
161
+ const posterizedInput = (options === null || options === void 0 ? void 0 : options.posterize) === undefined
162
+ ? input
163
+ : Math.floor(input / options.posterize) * options.posterize;
164
+ const range = findRange(posterizedInput, inputRange);
165
+ return interpolateFunction(posterizedInput, [inputRange[range], inputRange[range + 1]], [outputRange[range], outputRange[range + 1]], {
151
166
  easing: resolveEasingForSegment(range),
152
167
  extrapolateLeft,
153
168
  extrapolateRight,
@@ -1,6 +1,6 @@
1
1
  export type { ArtifactAsset, AudioOrVideoAsset, InlineAudioAsset, TRenderAsset, } from './CompositionManager';
2
2
  export type { DownloadBehavior } from './download-behavior';
3
- export { assertValidInterpolateEasingOption, interpolate } from './interpolate';
3
+ export { assertValidInterpolateEasingOption, assertValidInterpolatePosterizeOption, interpolate, } from './interpolate';
4
4
  export type { EasingFunction, ExtrapolateType, InterpolateOptions, } from './interpolate';
5
5
  export { random } from './random.js';
6
6
  export type { RandomSeed } from './random.js';
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoReactInternals = exports.random = exports.interpolate = exports.assertValidInterpolateEasingOption = void 0;
3
+ exports.NoReactInternals = exports.random = exports.interpolate = exports.assertValidInterpolatePosterizeOption = exports.assertValidInterpolateEasingOption = void 0;
4
4
  var interpolate_1 = require("./interpolate");
5
5
  Object.defineProperty(exports, "assertValidInterpolateEasingOption", { enumerable: true, get: function () { return interpolate_1.assertValidInterpolateEasingOption; } });
6
+ Object.defineProperty(exports, "assertValidInterpolatePosterizeOption", { enumerable: true, get: function () { return interpolate_1.assertValidInterpolatePosterizeOption; } });
6
7
  Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return interpolate_1.interpolate; } });
7
8
  var random_js_1 = require("./random.js");
8
9
  Object.defineProperty(exports, "random", { enumerable: true, get: function () { return random_js_1.random; } });
@@ -14,6 +14,7 @@ export type CanUpdateSequencePropStatusClamping = {
14
14
  left: ExtrapolateType;
15
15
  right: ExtrapolateType;
16
16
  };
17
+ export type CanUpdateSequencePropStatusInterpolationFunction = 'interpolate' | 'interpolateColors';
17
18
  export type CanUpdateSequencePropStatusComputed = {
18
19
  canUpdate: false;
19
20
  reason: 'computed';
@@ -21,9 +22,11 @@ export type CanUpdateSequencePropStatusComputed = {
21
22
  export type CanUpdateSequencePropStatusKeyframed = {
22
23
  canUpdate: false;
23
24
  reason: 'keyframed';
25
+ interpolationFunction: CanUpdateSequencePropStatusInterpolationFunction;
24
26
  keyframes: CanUpdateSequencePropStatusKeyframe[];
25
27
  easing: CanUpdateSequencePropStatusEasing[];
26
28
  clamping: CanUpdateSequencePropStatusClamping;
29
+ posterize: number | undefined;
27
30
  };
28
31
  export type CanUpdateSequencePropStatusFalse = CanUpdateSequencePropStatusComputed | CanUpdateSequencePropStatusKeyframed;
29
32
  export type CanUpdateSequencePropStatus = CanUpdateSequencePropStatusTrue | CanUpdateSequencePropStatusFalse;
@@ -34,11 +37,12 @@ export type GetCodeValues = (nodePath: SequencePropsSubscriptionKey) => Record<s
34
37
  export type GetEffectCodeValues = (nodePath: SequencePropsSubscriptionKey, effectIndex: number) => Record<string, CanUpdateSequencePropStatus> | undefined;
35
38
  export type GetDragOverrides = (nodePath: SequencePropsSubscriptionKey) => DragOverrides[string];
36
39
  export type GetEffectDragOverrides = (nodePath: SequencePropsSubscriptionKey, effectIndex: number) => Record<string, unknown>;
37
- export declare const computeEffectiveSchemaValuesDotNotation: ({ schema, currentValue, overrideValues, propStatus, }: {
40
+ export declare const computeEffectiveSchemaValuesDotNotation: ({ schema, currentValue, overrideValues, propStatus, frame, }: {
38
41
  schema: SequenceSchema;
39
42
  currentValue: Record<string, unknown>;
40
43
  overrideValues: Record<string, unknown>;
41
44
  propStatus: Record<string, CanUpdateSequencePropStatus> | undefined;
45
+ frame: number | null;
42
46
  }) => {
43
47
  merged: Record<string, unknown>;
44
48
  propsToDelete: Set<string>;