@remotion/transitions 4.0.464 → 4.0.465

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/dissolve.js ADDED
@@ -0,0 +1,2 @@
1
+ // For backwards compatibility when you use `esm-wallaby`
2
+ module.exports = require('./dist/presentations/dissolve.js');
@@ -0,0 +1,376 @@
1
+ // src/html-in-canvas-presentation.tsx
2
+ import { useLayoutEffect, useMemo, useRef, useState, useCallback } from "react";
3
+ import {
4
+ HtmlInCanvas,
5
+ HTML_IN_CANVAS_UNSUPPORTED_MESSAGE,
6
+ useDelayRender
7
+ } from "remotion";
8
+ import { AbsoluteFill, Internals } from "remotion";
9
+ import { jsx } from "react/jsx-runtime";
10
+ var HtmlInCanvasPresentation = ({
11
+ children,
12
+ onElementImage,
13
+ onUnmount,
14
+ presentationProgress,
15
+ presentationDirection,
16
+ shader,
17
+ effects,
18
+ passedProps,
19
+ bothEnteringAndExiting
20
+ }) => {
21
+ if (!HtmlInCanvas.isSupported()) {
22
+ throw new Error(HTML_IN_CANVAS_UNSUPPORTED_MESSAGE);
23
+ }
24
+ const canvasRef = useRef(null);
25
+ const canvasSubtreeStyle = useMemo(() => {
26
+ return {
27
+ width: "100%",
28
+ height: "100%",
29
+ position: "absolute",
30
+ top: 0,
31
+ left: 0,
32
+ right: 0,
33
+ bottom: 0
34
+ };
35
+ }, []);
36
+ const [offscreenCanvas] = useState(() => new OffscreenCanvas(1, 1));
37
+ const passedPropsRef = useRef(passedProps);
38
+ passedPropsRef.current = passedProps;
39
+ const memoizedEffects = Internals.useMemoizedEffects({
40
+ effects: effects ?? [],
41
+ overrideId: null
42
+ });
43
+ const effectsRef = useRef(memoizedEffects);
44
+ effectsRef.current = memoizedEffects;
45
+ const [instance] = useState(() => shader(offscreenCanvas));
46
+ useLayoutEffect(() => {
47
+ return () => {
48
+ instance.cleanup();
49
+ };
50
+ }, [offscreenCanvas, instance]);
51
+ const chainState = Internals.useEffectChainState();
52
+ const { delayRender, continueRender } = useDelayRender();
53
+ const draw = useCallback(async (prevImage, nextImage, progress) => {
54
+ if (!canvasRef.current) {
55
+ throw new Error("Canvas not found");
56
+ }
57
+ const handle = delayRender("onPaint");
58
+ if (!prevImage && !nextImage) {
59
+ continueRender(handle);
60
+ instance.clear();
61
+ return;
62
+ }
63
+ const width = prevImage?.width ?? nextImage?.width ?? 0;
64
+ const height = prevImage?.height ?? nextImage?.height ?? 0;
65
+ if (width === 0 || height === 0) {
66
+ continueRender(handle);
67
+ instance.clear();
68
+ return;
69
+ }
70
+ offscreenCanvas.width = width;
71
+ offscreenCanvas.height = height;
72
+ instance.draw({
73
+ prevImage,
74
+ nextImage,
75
+ width,
76
+ height,
77
+ time: progress,
78
+ passedProps: passedPropsRef.current
79
+ });
80
+ await Internals.runEffectChain({
81
+ state: chainState.get(width, height),
82
+ source: offscreenCanvas,
83
+ effects: effectsRef.current ?? [],
84
+ width,
85
+ height,
86
+ output: canvasRef.current
87
+ });
88
+ continueRender(handle);
89
+ }, [chainState, instance, offscreenCanvas, continueRender, delayRender]);
90
+ const passThrough = bothEnteringAndExiting && presentationDirection === "exiting";
91
+ useLayoutEffect(() => {
92
+ if (passThrough) {
93
+ return;
94
+ }
95
+ const canvas = canvasRef.current;
96
+ if (!canvas) {
97
+ throw new Error("Canvas not found");
98
+ }
99
+ canvas.layoutSubtree = true;
100
+ const onPaint = () => {
101
+ const firstChild = canvas.firstChild;
102
+ if (!firstChild) {
103
+ return;
104
+ }
105
+ const elementImage = canvas.captureElementImage(firstChild);
106
+ onElementImage(elementImage, draw);
107
+ };
108
+ canvas.addEventListener("paint", onPaint);
109
+ return () => {
110
+ canvas.removeEventListener("paint", onPaint);
111
+ };
112
+ }, [onElementImage, presentationDirection, draw, passThrough]);
113
+ useLayoutEffect(() => {
114
+ if (passThrough) {
115
+ return;
116
+ }
117
+ const canvas = canvasRef.current;
118
+ if (!canvas) {
119
+ throw new Error("Canvas not found");
120
+ }
121
+ canvas.requestPaint?.();
122
+ }, [presentationProgress, passThrough, memoizedEffects]);
123
+ useLayoutEffect(() => {
124
+ if (passThrough) {
125
+ return;
126
+ }
127
+ return () => {
128
+ onUnmount();
129
+ };
130
+ }, [onUnmount, passThrough]);
131
+ useLayoutEffect(() => {
132
+ if (passThrough) {
133
+ return;
134
+ }
135
+ const canvas = canvasRef.current;
136
+ if (!canvas) {
137
+ return;
138
+ }
139
+ const observer = new ResizeObserver(([entry]) => {
140
+ canvas.width = entry.devicePixelContentBoxSize[0].inlineSize;
141
+ canvas.height = entry.devicePixelContentBoxSize[0].blockSize;
142
+ });
143
+ observer.observe(canvas, { box: "device-pixel-content-box" });
144
+ }, [passThrough]);
145
+ if (passThrough) {
146
+ return children;
147
+ }
148
+ return /* @__PURE__ */ jsx(AbsoluteFill, {
149
+ children: /* @__PURE__ */ jsx("canvas", {
150
+ ref: canvasRef,
151
+ style: canvasSubtreeStyle,
152
+ children
153
+ })
154
+ });
155
+ };
156
+ var makeHtmlInCanvasPresentation = (shader) => {
157
+ const CompWithShader = (props) => {
158
+ const { passedProps, ...otherProps } = props;
159
+ const { effects, ...restPassedProps } = props.passedProps;
160
+ return /* @__PURE__ */ jsx(HtmlInCanvasPresentation, {
161
+ shader,
162
+ passedProps: restPassedProps,
163
+ effects,
164
+ ...otherProps
165
+ });
166
+ };
167
+ return (props) => {
168
+ return {
169
+ component: CompWithShader,
170
+ props
171
+ };
172
+ };
173
+ };
174
+
175
+ // src/presentations/dissolve.tsx
176
+ var DEFAULT_LINE_WIDTH = 0.1;
177
+ var DEFAULT_SPREAD_COLOR = "#ff0000";
178
+ var DEFAULT_HOT_COLOR = "#e6e633";
179
+ var DEFAULT_POW = 5;
180
+ var DEFAULT_INTENSITY = 1;
181
+ var parseHexColor = (hex) => {
182
+ const cleaned = hex.startsWith("#") ? hex.slice(1) : hex;
183
+ if (!/^[0-9a-fA-F]{6}$/.test(cleaned)) {
184
+ throw new Error(`Invalid color "${hex}" passed to dissolve(). Expected a "#rrggbb" hex string.`);
185
+ }
186
+ return [
187
+ parseInt(cleaned.slice(0, 2), 16) / 255,
188
+ parseInt(cleaned.slice(2, 4), 16) / 255,
189
+ parseInt(cleaned.slice(4, 6), 16) / 255
190
+ ];
191
+ };
192
+ var VERTEX_SHADER = `#version 300 es
193
+ in vec2 a_pos;
194
+ out vec2 v_uv;
195
+ void main() {
196
+ v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
197
+ gl_Position = vec4(a_pos, 0.0, 1.0);
198
+ }`;
199
+ var FRAGMENT_SHADER = `#version 300 es
200
+ precision highp float;
201
+
202
+ uniform sampler2D u_prev;
203
+ uniform sampler2D u_next;
204
+ uniform float u_time;
205
+ uniform float u_line_width;
206
+ uniform vec3 u_spread_color;
207
+ uniform vec3 u_hot_color;
208
+ uniform float u_pow;
209
+ uniform float u_intensity;
210
+
211
+ in vec2 v_uv;
212
+ out vec4 outColor;
213
+
214
+ vec4 transition(vec2 uv, float progress) {
215
+ vec4 from = texture(u_next, uv);
216
+ vec4 to = texture(u_prev, uv);
217
+ float burn = 0.5 + 0.5 * (0.299 * from.r + 0.587 * from.g + 0.114 * from.b);
218
+ float show = burn - progress;
219
+ if (show < 0.001) {
220
+ return to;
221
+ }
222
+ float factor = 1.0 - smoothstep(0.0, u_line_width, show);
223
+ vec3 burnColor = mix(u_spread_color, u_hot_color, factor);
224
+ burnColor = pow(burnColor, vec3(u_pow)) * u_intensity;
225
+ vec3 finalRGB = mix(from.rgb, burnColor, factor * step(0.0001, progress));
226
+ return vec4(finalRGB, from.a);
227
+ }
228
+
229
+ void main() {
230
+ // In Remotion's HTML-in-canvas convention, u_prev is bound to the incoming
231
+ // scene and u_next is bound to the outgoing scene, so the gl-transitions
232
+ // "from" → u_next and "to" → u_prev. With this binding, progress = u_time
233
+ // (no inversion) maps to the gl-transitions convention where progress = 0
234
+ // shows the outgoing scene and progress = 1 shows the incoming one.
235
+ float progress = u_time;
236
+ outColor = transition(v_uv, progress);
237
+ }`;
238
+ var compileShader = (gl, source, type) => {
239
+ const shader = gl.createShader(type);
240
+ if (!shader) {
241
+ throw new Error("Failed to create shader");
242
+ }
243
+ gl.shaderSource(shader, source);
244
+ gl.compileShader(shader);
245
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
246
+ const log = gl.getShaderInfoLog(shader);
247
+ gl.deleteShader(shader);
248
+ throw new Error(`Failed to compile shader: ${log}`);
249
+ }
250
+ return shader;
251
+ };
252
+ var createProgram = (gl) => {
253
+ const program = gl.createProgram();
254
+ if (!program) {
255
+ throw new Error("Failed to create WebGL program");
256
+ }
257
+ const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);
258
+ const fs = compileShader(gl, FRAGMENT_SHADER, gl.FRAGMENT_SHADER);
259
+ gl.attachShader(program, vs);
260
+ gl.attachShader(program, fs);
261
+ gl.linkProgram(program);
262
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
263
+ const log = gl.getProgramInfoLog(program);
264
+ gl.deleteProgram(program);
265
+ throw new Error(`Failed to link program: ${log}`);
266
+ }
267
+ return program;
268
+ };
269
+ var createTexture = (gl) => {
270
+ const tex = gl.createTexture();
271
+ if (!tex) {
272
+ throw new Error("Failed to create texture");
273
+ }
274
+ gl.bindTexture(gl.TEXTURE_2D, tex);
275
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
276
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
277
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
278
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
279
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
280
+ return tex;
281
+ };
282
+ var dissolveShader = (canvas) => {
283
+ const gl = canvas.getContext("webgl2", { premultipliedAlpha: true });
284
+ if (!gl) {
285
+ throw new Error("Failed to create WebGL2 context");
286
+ }
287
+ const program = createProgram(gl);
288
+ const prevTex = createTexture(gl);
289
+ const nextTex = createTexture(gl);
290
+ const vao = gl.createVertexArray();
291
+ gl.bindVertexArray(vao);
292
+ const buffer = gl.createBuffer();
293
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
294
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
295
+ const aPos = gl.getAttribLocation(program, "a_pos");
296
+ gl.enableVertexAttribArray(aPos);
297
+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
298
+ const uTime = gl.getUniformLocation(program, "u_time");
299
+ const uPrev = gl.getUniformLocation(program, "u_prev");
300
+ const uNext = gl.getUniformLocation(program, "u_next");
301
+ const uLineWidth = gl.getUniformLocation(program, "u_line_width");
302
+ const uSpreadColor = gl.getUniformLocation(program, "u_spread_color");
303
+ const uHotColor = gl.getUniformLocation(program, "u_hot_color");
304
+ const uPow = gl.getUniformLocation(program, "u_pow");
305
+ const uIntensity = gl.getUniformLocation(program, "u_intensity");
306
+ const cleanup = () => {
307
+ gl.deleteProgram(program);
308
+ gl.deleteTexture(prevTex);
309
+ gl.deleteTexture(nextTex);
310
+ };
311
+ const clear = () => {
312
+ gl.clearColor(0, 0, 0, 0);
313
+ gl.clear(gl.COLOR_BUFFER_BIT);
314
+ };
315
+ const draw = ({
316
+ prevImage,
317
+ nextImage,
318
+ width,
319
+ height,
320
+ time,
321
+ passedProps
322
+ }) => {
323
+ const {
324
+ lineWidth = DEFAULT_LINE_WIDTH,
325
+ spreadColor = DEFAULT_SPREAD_COLOR,
326
+ hotColor = DEFAULT_HOT_COLOR,
327
+ pow = DEFAULT_POW,
328
+ intensity = DEFAULT_INTENSITY
329
+ } = passedProps;
330
+ if (!prevImage && !nextImage) {
331
+ return;
332
+ }
333
+ if (prevImage && (prevImage.width === 0 || prevImage.height === 0)) {
334
+ return;
335
+ }
336
+ if (nextImage && (nextImage.width === 0 || nextImage.height === 0)) {
337
+ return;
338
+ }
339
+ const effectiveTime = !prevImage ? 0 : !nextImage ? 1 : time;
340
+ gl.viewport(0, 0, width, height);
341
+ gl.clearColor(0, 0, 0, 0);
342
+ gl.clear(gl.COLOR_BUFFER_BIT);
343
+ gl.useProgram(program);
344
+ gl.activeTexture(gl.TEXTURE0);
345
+ gl.bindTexture(gl.TEXTURE_2D, prevTex);
346
+ if (prevImage) {
347
+ gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, prevImage);
348
+ }
349
+ gl.uniform1i(uPrev, 0);
350
+ gl.activeTexture(gl.TEXTURE1);
351
+ gl.bindTexture(gl.TEXTURE_2D, nextTex);
352
+ if (nextImage) {
353
+ gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, nextImage);
354
+ }
355
+ gl.uniform1i(uNext, 1);
356
+ const spread = parseHexColor(spreadColor);
357
+ const hot = parseHexColor(hotColor);
358
+ gl.uniform1f(uTime, effectiveTime);
359
+ gl.uniform1f(uLineWidth, lineWidth);
360
+ gl.uniform3f(uSpreadColor, spread[0], spread[1], spread[2]);
361
+ gl.uniform3f(uHotColor, hot[0], hot[1], hot[2]);
362
+ gl.uniform1f(uPow, pow);
363
+ gl.uniform1f(uIntensity, intensity);
364
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
365
+ };
366
+ return {
367
+ clear,
368
+ cleanup,
369
+ draw
370
+ };
371
+ };
372
+ var dissolve = makeHtmlInCanvasPresentation(dissolveShader);
373
+ export {
374
+ dissolveShader,
375
+ dissolve
376
+ };
@@ -541,7 +541,7 @@ var HtmlInCanvasPresentation = ({
541
541
  presentationProgress,
542
542
  presentationDirection,
543
543
  shader,
544
- _experimentalEffects,
544
+ effects,
545
545
  passedProps,
546
546
  bothEnteringAndExiting
547
547
  }) => {
@@ -564,7 +564,7 @@ var HtmlInCanvasPresentation = ({
564
564
  const passedPropsRef = useRef2(passedProps);
565
565
  passedPropsRef.current = passedProps;
566
566
  const memoizedEffects = Internals2.useMemoizedEffects({
567
- effects: _experimentalEffects ?? [],
567
+ effects: effects ?? [],
568
568
  overrideId: null
569
569
  });
570
570
  const effectsRef = useRef2(memoizedEffects);
@@ -683,11 +683,11 @@ var HtmlInCanvasPresentation = ({
683
683
  var makeHtmlInCanvasPresentation = (shader) => {
684
684
  const CompWithShader = (props) => {
685
685
  const { passedProps, ...otherProps } = props;
686
- const { _experimentalEffects, ...restPassedProps } = props.passedProps;
686
+ const { effects, ...restPassedProps } = props.passedProps;
687
687
  return /* @__PURE__ */ jsx4(HtmlInCanvasPresentation, {
688
688
  shader,
689
689
  passedProps: restPassedProps,
690
- _experimentalEffects,
690
+ effects,
691
691
  ...otherProps
692
692
  });
693
693
  };
@@ -14,7 +14,7 @@ var HtmlInCanvasPresentation = ({
14
14
  presentationProgress,
15
15
  presentationDirection,
16
16
  shader,
17
- _experimentalEffects,
17
+ effects,
18
18
  passedProps,
19
19
  bothEnteringAndExiting
20
20
  }) => {
@@ -37,7 +37,7 @@ var HtmlInCanvasPresentation = ({
37
37
  const passedPropsRef = useRef(passedProps);
38
38
  passedPropsRef.current = passedProps;
39
39
  const memoizedEffects = Internals.useMemoizedEffects({
40
- effects: _experimentalEffects ?? [],
40
+ effects: effects ?? [],
41
41
  overrideId: null
42
42
  });
43
43
  const effectsRef = useRef(memoizedEffects);
@@ -156,11 +156,11 @@ var HtmlInCanvasPresentation = ({
156
156
  var makeHtmlInCanvasPresentation = (shader) => {
157
157
  const CompWithShader = (props) => {
158
158
  const { passedProps, ...otherProps } = props;
159
- const { _experimentalEffects, ...restPassedProps } = props.passedProps;
159
+ const { effects, ...restPassedProps } = props.passedProps;
160
160
  return /* @__PURE__ */ jsx(HtmlInCanvasPresentation, {
161
161
  shader,
162
162
  passedProps: restPassedProps,
163
- _experimentalEffects,
163
+ effects,
164
164
  ...otherProps
165
165
  });
166
166
  };
@@ -14,7 +14,7 @@ var HtmlInCanvasPresentation = ({
14
14
  presentationProgress,
15
15
  presentationDirection,
16
16
  shader,
17
- _experimentalEffects,
17
+ effects,
18
18
  passedProps,
19
19
  bothEnteringAndExiting
20
20
  }) => {
@@ -37,7 +37,7 @@ var HtmlInCanvasPresentation = ({
37
37
  const passedPropsRef = useRef(passedProps);
38
38
  passedPropsRef.current = passedProps;
39
39
  const memoizedEffects = Internals.useMemoizedEffects({
40
- effects: _experimentalEffects ?? [],
40
+ effects: effects ?? [],
41
41
  overrideId: null
42
42
  });
43
43
  const effectsRef = useRef(memoizedEffects);
@@ -156,11 +156,11 @@ var HtmlInCanvasPresentation = ({
156
156
  var makeHtmlInCanvasPresentation = (shader) => {
157
157
  const CompWithShader = (props) => {
158
158
  const { passedProps, ...otherProps } = props;
159
- const { _experimentalEffects, ...restPassedProps } = props.passedProps;
159
+ const { effects, ...restPassedProps } = props.passedProps;
160
160
  return /* @__PURE__ */ jsx(HtmlInCanvasPresentation, {
161
161
  shader,
162
162
  passedProps: restPassedProps,
163
- _experimentalEffects,
163
+ effects,
164
164
  ...otherProps
165
165
  });
166
166
  };
@@ -1,8 +1,8 @@
1
1
  import { type EffectsProp } from 'remotion';
2
2
  import type { TransitionPresentation, TransitionPresentationComponentProps } from './types';
3
- export declare const HtmlInCanvasPresentation: <TPassedProps extends Record<string, unknown>>({ children, onElementImage, onUnmount, presentationProgress, presentationDirection, shader, _experimentalEffects, passedProps, bothEnteringAndExiting, }: TransitionPresentationComponentProps<TPassedProps> & {
3
+ export declare const HtmlInCanvasPresentation: <TPassedProps extends Record<string, unknown>>({ children, onElementImage, onUnmount, presentationProgress, presentationDirection, shader, effects, passedProps, bothEnteringAndExiting, }: TransitionPresentationComponentProps<TPassedProps> & {
4
4
  readonly shader: HtmlInCanvasShader<TPassedProps>;
5
- readonly _experimentalEffects?: EffectsProp | undefined;
5
+ readonly effects?: EffectsProp | undefined;
6
6
  }) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
7
7
  export type HtmlInCanvasShaderDrawParams<Props> = {
8
8
  prevImage: ElementImage | null;
@@ -19,7 +19,7 @@ export type HtmlInCanvasShader<Props> = (canvas: OffscreenCanvas) => {
19
19
  draw: HtmlInCanvasShaderDraw<Props>;
20
20
  };
21
21
  export declare const makeHtmlInCanvasPresentation: <TPassedProps extends Record<string, unknown>>(shader: HtmlInCanvasShader<TPassedProps>) => (props: TPassedProps & {
22
- _experimentalEffects?: EffectsProp | undefined;
22
+ effects?: EffectsProp | undefined;
23
23
  }) => TransitionPresentation<TPassedProps & {
24
- _experimentalEffects?: EffectsProp | undefined;
24
+ effects?: EffectsProp | undefined;
25
25
  }>;
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const remotion_1 = require("remotion");
7
7
  const remotion_2 = require("remotion");
8
- const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, presentationProgress, presentationDirection, shader, _experimentalEffects, passedProps, bothEnteringAndExiting, }) => {
8
+ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, presentationProgress, presentationDirection, shader, effects, passedProps, bothEnteringAndExiting, }) => {
9
9
  if (!remotion_1.HtmlInCanvas.isSupported()) {
10
10
  throw new Error(remotion_1.HTML_IN_CANVAS_UNSUPPORTED_MESSAGE);
11
11
  }
@@ -25,7 +25,7 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
25
25
  const passedPropsRef = (0, react_1.useRef)(passedProps);
26
26
  passedPropsRef.current = passedProps;
27
27
  const memoizedEffects = remotion_2.Internals.useMemoizedEffects({
28
- effects: _experimentalEffects !== null && _experimentalEffects !== void 0 ? _experimentalEffects : [],
28
+ effects: effects !== null && effects !== void 0 ? effects : [],
29
29
  overrideId: null,
30
30
  });
31
31
  const effectsRef = (0, react_1.useRef)(memoizedEffects);
@@ -142,8 +142,8 @@ exports.HtmlInCanvasPresentation = HtmlInCanvasPresentation;
142
142
  const makeHtmlInCanvasPresentation = (shader) => {
143
143
  const CompWithShader = (props) => {
144
144
  const { passedProps, ...otherProps } = props;
145
- const { _experimentalEffects, ...restPassedProps } = props.passedProps;
146
- return (jsx_runtime_1.jsx(exports.HtmlInCanvasPresentation, { shader: shader, passedProps: restPassedProps, _experimentalEffects: _experimentalEffects, ...otherProps }));
145
+ const { effects, ...restPassedProps } = props.passedProps;
146
+ return (jsx_runtime_1.jsx(exports.HtmlInCanvasPresentation, { shader: shader, passedProps: restPassedProps, effects: effects, ...otherProps }));
147
147
  };
148
148
  return (props) => {
149
149
  return {
@@ -0,0 +1,17 @@
1
+ export type DissolveProps = {
2
+ lineWidth?: number;
3
+ spreadColor?: string;
4
+ hotColor?: string;
5
+ pow?: number;
6
+ intensity?: number;
7
+ };
8
+ export declare const dissolveShader: (canvas: OffscreenCanvas) => {
9
+ clear: () => void;
10
+ cleanup: () => void;
11
+ draw: import("..").HtmlInCanvasShaderDraw<DissolveProps>;
12
+ };
13
+ export declare const dissolve: (props: DissolveProps & {
14
+ effects?: import("remotion").EffectsProp | undefined;
15
+ }) => import("..").TransitionPresentation<DissolveProps & {
16
+ effects?: import("remotion").EffectsProp | undefined;
17
+ }>;
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dissolve = exports.dissolveShader = void 0;
4
+ const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
5
+ const DEFAULT_LINE_WIDTH = 0.1;
6
+ const DEFAULT_SPREAD_COLOR = '#ff0000';
7
+ const DEFAULT_HOT_COLOR = '#e6e633';
8
+ const DEFAULT_POW = 5.0;
9
+ const DEFAULT_INTENSITY = 1.0;
10
+ const parseHexColor = (hex) => {
11
+ const cleaned = hex.startsWith('#') ? hex.slice(1) : hex;
12
+ if (!/^[0-9a-fA-F]{6}$/.test(cleaned)) {
13
+ throw new Error(`Invalid color "${hex}" passed to dissolve(). Expected a "#rrggbb" hex string.`);
14
+ }
15
+ return [
16
+ parseInt(cleaned.slice(0, 2), 16) / 255,
17
+ parseInt(cleaned.slice(2, 4), 16) / 255,
18
+ parseInt(cleaned.slice(4, 6), 16) / 255,
19
+ ];
20
+ };
21
+ const VERTEX_SHADER = `#version 300 es
22
+ in vec2 a_pos;
23
+ out vec2 v_uv;
24
+ void main() {
25
+ v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
26
+ gl_Position = vec4(a_pos, 0.0, 1.0);
27
+ }`;
28
+ // Adapted from https://gl-transitions.com/editor/dissolve
29
+ // Author: hjm1fb · License: MIT
30
+ const FRAGMENT_SHADER = `#version 300 es
31
+ precision highp float;
32
+
33
+ uniform sampler2D u_prev;
34
+ uniform sampler2D u_next;
35
+ uniform float u_time;
36
+ uniform float u_line_width;
37
+ uniform vec3 u_spread_color;
38
+ uniform vec3 u_hot_color;
39
+ uniform float u_pow;
40
+ uniform float u_intensity;
41
+
42
+ in vec2 v_uv;
43
+ out vec4 outColor;
44
+
45
+ vec4 transition(vec2 uv, float progress) {
46
+ vec4 from = texture(u_next, uv);
47
+ vec4 to = texture(u_prev, uv);
48
+ float burn = 0.5 + 0.5 * (0.299 * from.r + 0.587 * from.g + 0.114 * from.b);
49
+ float show = burn - progress;
50
+ if (show < 0.001) {
51
+ return to;
52
+ }
53
+ float factor = 1.0 - smoothstep(0.0, u_line_width, show);
54
+ vec3 burnColor = mix(u_spread_color, u_hot_color, factor);
55
+ burnColor = pow(burnColor, vec3(u_pow)) * u_intensity;
56
+ vec3 finalRGB = mix(from.rgb, burnColor, factor * step(0.0001, progress));
57
+ return vec4(finalRGB, from.a);
58
+ }
59
+
60
+ void main() {
61
+ // In Remotion's HTML-in-canvas convention, u_prev is bound to the incoming
62
+ // scene and u_next is bound to the outgoing scene, so the gl-transitions
63
+ // "from" → u_next and "to" → u_prev. With this binding, progress = u_time
64
+ // (no inversion) maps to the gl-transitions convention where progress = 0
65
+ // shows the outgoing scene and progress = 1 shows the incoming one.
66
+ float progress = u_time;
67
+ outColor = transition(v_uv, progress);
68
+ }`;
69
+ const compileShader = (gl, source, type) => {
70
+ const shader = gl.createShader(type);
71
+ if (!shader) {
72
+ throw new Error('Failed to create shader');
73
+ }
74
+ gl.shaderSource(shader, source);
75
+ gl.compileShader(shader);
76
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
77
+ const log = gl.getShaderInfoLog(shader);
78
+ gl.deleteShader(shader);
79
+ throw new Error(`Failed to compile shader: ${log}`);
80
+ }
81
+ return shader;
82
+ };
83
+ const createProgram = (gl) => {
84
+ const program = gl.createProgram();
85
+ if (!program) {
86
+ throw new Error('Failed to create WebGL program');
87
+ }
88
+ const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);
89
+ const fs = compileShader(gl, FRAGMENT_SHADER, gl.FRAGMENT_SHADER);
90
+ gl.attachShader(program, vs);
91
+ gl.attachShader(program, fs);
92
+ gl.linkProgram(program);
93
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
94
+ const log = gl.getProgramInfoLog(program);
95
+ gl.deleteProgram(program);
96
+ throw new Error(`Failed to link program: ${log}`);
97
+ }
98
+ return program;
99
+ };
100
+ const createTexture = (gl) => {
101
+ const tex = gl.createTexture();
102
+ if (!tex) {
103
+ throw new Error('Failed to create texture');
104
+ }
105
+ gl.bindTexture(gl.TEXTURE_2D, tex);
106
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
107
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
108
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
109
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
110
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
111
+ return tex;
112
+ };
113
+ const dissolveShader = (canvas) => {
114
+ const gl = canvas.getContext('webgl2', { premultipliedAlpha: true });
115
+ if (!gl) {
116
+ throw new Error('Failed to create WebGL2 context');
117
+ }
118
+ const program = createProgram(gl);
119
+ const prevTex = createTexture(gl);
120
+ const nextTex = createTexture(gl);
121
+ const vao = gl.createVertexArray();
122
+ gl.bindVertexArray(vao);
123
+ const buffer = gl.createBuffer();
124
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
125
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
126
+ const aPos = gl.getAttribLocation(program, 'a_pos');
127
+ gl.enableVertexAttribArray(aPos);
128
+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
129
+ const uTime = gl.getUniformLocation(program, 'u_time');
130
+ const uPrev = gl.getUniformLocation(program, 'u_prev');
131
+ const uNext = gl.getUniformLocation(program, 'u_next');
132
+ const uLineWidth = gl.getUniformLocation(program, 'u_line_width');
133
+ const uSpreadColor = gl.getUniformLocation(program, 'u_spread_color');
134
+ const uHotColor = gl.getUniformLocation(program, 'u_hot_color');
135
+ const uPow = gl.getUniformLocation(program, 'u_pow');
136
+ const uIntensity = gl.getUniformLocation(program, 'u_intensity');
137
+ const cleanup = () => {
138
+ gl.deleteProgram(program);
139
+ gl.deleteTexture(prevTex);
140
+ gl.deleteTexture(nextTex);
141
+ };
142
+ const clear = () => {
143
+ gl.clearColor(0, 0, 0, 0);
144
+ gl.clear(gl.COLOR_BUFFER_BIT);
145
+ };
146
+ const draw = ({ prevImage, nextImage, width, height, time, passedProps, }) => {
147
+ const { lineWidth = DEFAULT_LINE_WIDTH, spreadColor = DEFAULT_SPREAD_COLOR, hotColor = DEFAULT_HOT_COLOR, pow = DEFAULT_POW, intensity = DEFAULT_INTENSITY, } = passedProps;
148
+ if (!prevImage && !nextImage) {
149
+ return;
150
+ }
151
+ if (prevImage && (prevImage.width === 0 || prevImage.height === 0)) {
152
+ return;
153
+ }
154
+ if (nextImage && (nextImage.width === 0 || nextImage.height === 0)) {
155
+ return;
156
+ }
157
+ // When one side is missing, force the mix to fully show the other.
158
+ // At time=0 the shader outputs nextImage. At time=1 the shader outputs prevImage.
159
+ const effectiveTime = !prevImage ? 0 : !nextImage ? 1 : time;
160
+ gl.viewport(0, 0, width, height);
161
+ gl.clearColor(0, 0, 0, 0);
162
+ gl.clear(gl.COLOR_BUFFER_BIT);
163
+ gl.useProgram(program);
164
+ gl.activeTexture(gl.TEXTURE0);
165
+ gl.bindTexture(gl.TEXTURE_2D, prevTex);
166
+ if (prevImage) {
167
+ gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, prevImage);
168
+ }
169
+ gl.uniform1i(uPrev, 0);
170
+ gl.activeTexture(gl.TEXTURE1);
171
+ gl.bindTexture(gl.TEXTURE_2D, nextTex);
172
+ if (nextImage) {
173
+ gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, nextImage);
174
+ }
175
+ gl.uniform1i(uNext, 1);
176
+ const spread = parseHexColor(spreadColor);
177
+ const hot = parseHexColor(hotColor);
178
+ gl.uniform1f(uTime, effectiveTime);
179
+ gl.uniform1f(uLineWidth, lineWidth);
180
+ gl.uniform3f(uSpreadColor, spread[0], spread[1], spread[2]);
181
+ gl.uniform3f(uHotColor, hot[0], hot[1], hot[2]);
182
+ gl.uniform1f(uPow, pow);
183
+ gl.uniform1f(uIntensity, intensity);
184
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
185
+ };
186
+ return {
187
+ clear,
188
+ cleanup,
189
+ draw,
190
+ };
191
+ };
192
+ exports.dissolveShader = dissolveShader;
193
+ exports.dissolve = (0, html_in_canvas_presentation_1.makeHtmlInCanvasPresentation)(exports.dissolveShader);
@@ -7,7 +7,7 @@ export declare const zoomBlurShader: (canvas: OffscreenCanvas) => {
7
7
  draw: import("..").HtmlInCanvasShaderDraw<ZoomBlurProps>;
8
8
  };
9
9
  export declare const zoomBlur: (props: ZoomBlurProps & {
10
- _experimentalEffects?: import("remotion").EffectsProp | undefined;
10
+ effects?: import("remotion").EffectsProp | undefined;
11
11
  }) => import("..").TransitionPresentation<ZoomBlurProps & {
12
- _experimentalEffects?: import("remotion").EffectsProp | undefined;
12
+ effects?: import("remotion").EffectsProp | undefined;
13
13
  }>;
@@ -5,7 +5,7 @@ export declare const zoomInOutShader: (canvas: OffscreenCanvas) => {
5
5
  draw: import("..").HtmlInCanvasShaderDraw<ZoomInOutProps>;
6
6
  };
7
7
  export declare const zoomInOut: (props: ZoomInOutProps & {
8
- _experimentalEffects?: import("remotion").EffectsProp | undefined;
8
+ effects?: import("remotion").EffectsProp | undefined;
9
9
  }) => import("..").TransitionPresentation<ZoomInOutProps & {
10
- _experimentalEffects?: import("remotion").EffectsProp | undefined;
10
+ effects?: import("remotion").EffectsProp | undefined;
11
11
  }>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/transitions"
4
4
  },
5
5
  "name": "@remotion/transitions",
6
- "version": "4.0.464",
6
+ "version": "4.0.465",
7
7
  "description": "Library for creating transitions in Remotion",
8
8
  "main": "dist/esm/index.mjs",
9
9
  "module": "dist/esm/index.js",
@@ -22,18 +22,18 @@
22
22
  "url": "https://github.com/remotion-dev/remotion/issues"
23
23
  },
24
24
  "dependencies": {
25
- "remotion": "4.0.464",
26
- "@remotion/shapes": "4.0.464",
27
- "@remotion/paths": "4.0.464"
25
+ "remotion": "4.0.465",
26
+ "@remotion/shapes": "4.0.465",
27
+ "@remotion/paths": "4.0.465"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@happy-dom/global-registrator": "14.5.1",
31
- "remotion": "4.0.464",
31
+ "remotion": "4.0.465",
32
32
  "react": "19.2.3",
33
33
  "react-dom": "19.2.3",
34
- "@remotion/test-utils": "4.0.464",
35
- "@remotion/player": "4.0.464",
36
- "@remotion/eslint-config-internal": "4.0.464",
34
+ "@remotion/test-utils": "4.0.465",
35
+ "@remotion/player": "4.0.465",
36
+ "@remotion/eslint-config-internal": "4.0.465",
37
37
  "eslint": "9.19.0",
38
38
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
39
39
  },
@@ -109,6 +109,12 @@
109
109
  "import": "./dist/esm/iris.mjs",
110
110
  "require": "./dist/presentations/iris.js"
111
111
  },
112
+ "./dissolve": {
113
+ "types": "./dist/presentations/dissolve.d.ts",
114
+ "module": "./dist/esm/dissolve.mjs",
115
+ "import": "./dist/esm/dissolve.mjs",
116
+ "require": "./dist/presentations/dissolve.js"
117
+ },
112
118
  "./package.json": "./package.json"
113
119
  },
114
120
  "typesVersions": {
@@ -139,6 +145,9 @@
139
145
  ],
140
146
  "zoom-in-out": [
141
147
  "dist/presentations/zoom-in-out.d.ts"
148
+ ],
149
+ "dissolve": [
150
+ "dist/presentations/dissolve.d.ts"
142
151
  ]
143
152
  }
144
153
  },