@remotion/transitions 4.0.465 → 4.0.467
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/book-flip.js +2 -0
- package/cross-zoom.js +2 -0
- package/crosswarp.js +2 -0
- package/dist/TransitionSeries.js +16 -6
- package/dist/esm/book-flip.mjs +434 -0
- package/dist/esm/cross-zoom.mjs +377 -0
- package/dist/esm/crosswarp.mjs +331 -0
- package/dist/esm/dissolve.mjs +4 -3
- package/dist/esm/dreamy-zoom.mjs +348 -0
- package/dist/esm/film-burn.mjs +443 -0
- package/dist/esm/index.mjs +1020 -209
- package/dist/esm/linear-blur.mjs +343 -0
- package/dist/esm/ripple.mjs +342 -0
- package/dist/esm/swap.mjs +394 -0
- package/dist/esm/zoom-blur.mjs +4 -3
- package/dist/esm/zoom-in-out.mjs +4 -3
- package/dist/html-in-canvas-presentation.js +4 -5
- package/dist/index.d.ts +13 -3
- package/dist/index.js +9 -1
- package/dist/presentations/book-flip.d.ts +14 -0
- package/dist/presentations/book-flip.js +255 -0
- package/dist/presentations/cross-zoom.d.ts +13 -0
- package/dist/presentations/cross-zoom.js +199 -0
- package/dist/presentations/crosswarp.d.ts +11 -0
- package/dist/presentations/crosswarp.js +154 -0
- package/dist/presentations/dreamy-zoom.d.ts +14 -0
- package/dist/presentations/dreamy-zoom.js +169 -0
- package/dist/presentations/film-burn.d.ts +13 -0
- package/dist/presentations/film-burn.js +265 -0
- package/dist/presentations/linear-blur.d.ts +13 -0
- package/dist/presentations/linear-blur.js +164 -0
- package/dist/presentations/ripple.d.ts +14 -0
- package/dist/presentations/ripple.js +164 -0
- package/dist/presentations/swap.d.ts +15 -0
- package/dist/presentations/swap.js +212 -0
- package/dist/types.d.ts +1 -1
- package/dreamy-zoom.js +2 -0
- package/film-burn.js +2 -0
- package/linear-blur.js +2 -0
- package/package.json +80 -8
- package/ripple.js +2 -0
- package/swap.js +2 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
// src/html-in-canvas-presentation.tsx
|
|
2
|
+
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
AbsoluteFill,
|
|
5
|
+
HTML_IN_CANVAS_UNSUPPORTED_MESSAGE,
|
|
6
|
+
HtmlInCanvas,
|
|
7
|
+
Internals,
|
|
8
|
+
useDelayRender
|
|
9
|
+
} from "remotion";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
var HtmlInCanvasPresentation = ({
|
|
12
|
+
children,
|
|
13
|
+
onElementImage,
|
|
14
|
+
onUnmount,
|
|
15
|
+
presentationProgress,
|
|
16
|
+
presentationDirection,
|
|
17
|
+
shader,
|
|
18
|
+
effects,
|
|
19
|
+
passedProps,
|
|
20
|
+
bothEnteringAndExiting
|
|
21
|
+
}) => {
|
|
22
|
+
if (!HtmlInCanvas.isSupported()) {
|
|
23
|
+
throw new Error(HTML_IN_CANVAS_UNSUPPORTED_MESSAGE);
|
|
24
|
+
}
|
|
25
|
+
const canvasRef = useRef(null);
|
|
26
|
+
const canvasSubtreeStyle = useMemo(() => {
|
|
27
|
+
return {
|
|
28
|
+
width: "100%",
|
|
29
|
+
height: "100%",
|
|
30
|
+
position: "absolute",
|
|
31
|
+
top: 0,
|
|
32
|
+
left: 0,
|
|
33
|
+
right: 0,
|
|
34
|
+
bottom: 0
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
const [offscreenCanvas] = useState(() => new OffscreenCanvas(1, 1));
|
|
38
|
+
const passedPropsRef = useRef(passedProps);
|
|
39
|
+
passedPropsRef.current = passedProps;
|
|
40
|
+
const memoizedEffects = Internals.useMemoizedEffects({
|
|
41
|
+
effects: effects ?? [],
|
|
42
|
+
overrideId: null
|
|
43
|
+
});
|
|
44
|
+
const effectsRef = useRef(memoizedEffects);
|
|
45
|
+
effectsRef.current = memoizedEffects;
|
|
46
|
+
const [instance] = useState(() => shader(offscreenCanvas));
|
|
47
|
+
useLayoutEffect(() => {
|
|
48
|
+
return () => {
|
|
49
|
+
instance.cleanup();
|
|
50
|
+
};
|
|
51
|
+
}, [offscreenCanvas, instance]);
|
|
52
|
+
const chainState = Internals.useEffectChainState();
|
|
53
|
+
const { delayRender, continueRender } = useDelayRender();
|
|
54
|
+
const draw = useCallback(async (prevImage, nextImage, progress) => {
|
|
55
|
+
if (!canvasRef.current) {
|
|
56
|
+
throw new Error("Canvas not found");
|
|
57
|
+
}
|
|
58
|
+
const handle = delayRender("onPaint");
|
|
59
|
+
if (!prevImage && !nextImage) {
|
|
60
|
+
continueRender(handle);
|
|
61
|
+
instance.clear();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const width = prevImage?.width ?? nextImage?.width ?? 0;
|
|
65
|
+
const height = prevImage?.height ?? nextImage?.height ?? 0;
|
|
66
|
+
if (width === 0 || height === 0) {
|
|
67
|
+
continueRender(handle);
|
|
68
|
+
instance.clear();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
offscreenCanvas.width = width;
|
|
72
|
+
offscreenCanvas.height = height;
|
|
73
|
+
instance.draw({
|
|
74
|
+
prevImage,
|
|
75
|
+
nextImage,
|
|
76
|
+
width,
|
|
77
|
+
height,
|
|
78
|
+
time: progress,
|
|
79
|
+
passedProps: passedPropsRef.current
|
|
80
|
+
});
|
|
81
|
+
await Internals.runEffectChain({
|
|
82
|
+
state: chainState.get(width, height),
|
|
83
|
+
source: offscreenCanvas,
|
|
84
|
+
effects: effectsRef.current ?? [],
|
|
85
|
+
width,
|
|
86
|
+
height,
|
|
87
|
+
output: canvasRef.current
|
|
88
|
+
});
|
|
89
|
+
continueRender(handle);
|
|
90
|
+
}, [chainState, instance, offscreenCanvas, continueRender, delayRender]);
|
|
91
|
+
const passThrough = bothEnteringAndExiting && presentationDirection === "exiting";
|
|
92
|
+
useLayoutEffect(() => {
|
|
93
|
+
if (passThrough) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const canvas = canvasRef.current;
|
|
97
|
+
if (!canvas) {
|
|
98
|
+
throw new Error("Canvas not found");
|
|
99
|
+
}
|
|
100
|
+
canvas.layoutSubtree = true;
|
|
101
|
+
const onPaint = () => {
|
|
102
|
+
const firstChild = canvas.firstChild;
|
|
103
|
+
if (!firstChild) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const elementImage = canvas.captureElementImage(firstChild);
|
|
107
|
+
onElementImage(elementImage, draw);
|
|
108
|
+
};
|
|
109
|
+
canvas.addEventListener("paint", onPaint);
|
|
110
|
+
return () => {
|
|
111
|
+
canvas.removeEventListener("paint", onPaint);
|
|
112
|
+
};
|
|
113
|
+
}, [onElementImage, presentationDirection, draw, passThrough]);
|
|
114
|
+
useLayoutEffect(() => {
|
|
115
|
+
if (passThrough) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const canvas = canvasRef.current;
|
|
119
|
+
if (!canvas) {
|
|
120
|
+
throw new Error("Canvas not found");
|
|
121
|
+
}
|
|
122
|
+
canvas.requestPaint?.();
|
|
123
|
+
}, [presentationProgress, passThrough, memoizedEffects]);
|
|
124
|
+
useLayoutEffect(() => {
|
|
125
|
+
if (passThrough) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
return () => {
|
|
129
|
+
onUnmount();
|
|
130
|
+
};
|
|
131
|
+
}, [onUnmount, passThrough]);
|
|
132
|
+
useLayoutEffect(() => {
|
|
133
|
+
if (passThrough) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const canvas = canvasRef.current;
|
|
137
|
+
if (!canvas) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
141
|
+
canvas.width = entry.devicePixelContentBoxSize[0].inlineSize;
|
|
142
|
+
canvas.height = entry.devicePixelContentBoxSize[0].blockSize;
|
|
143
|
+
});
|
|
144
|
+
observer.observe(canvas, { box: "device-pixel-content-box" });
|
|
145
|
+
}, [passThrough]);
|
|
146
|
+
if (passThrough) {
|
|
147
|
+
return children;
|
|
148
|
+
}
|
|
149
|
+
return /* @__PURE__ */ jsx(AbsoluteFill, {
|
|
150
|
+
children: /* @__PURE__ */ jsx("canvas", {
|
|
151
|
+
ref: canvasRef,
|
|
152
|
+
style: canvasSubtreeStyle,
|
|
153
|
+
children
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
var makeHtmlInCanvasPresentation = (shader) => {
|
|
158
|
+
const CompWithShader = (props) => {
|
|
159
|
+
const { passedProps, ...otherProps } = props;
|
|
160
|
+
const { effects, ...restPassedProps } = props.passedProps;
|
|
161
|
+
return /* @__PURE__ */ jsx(HtmlInCanvasPresentation, {
|
|
162
|
+
shader,
|
|
163
|
+
passedProps: restPassedProps,
|
|
164
|
+
effects,
|
|
165
|
+
...otherProps
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
return (props) => {
|
|
169
|
+
return {
|
|
170
|
+
component: CompWithShader,
|
|
171
|
+
props
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/presentations/swap.tsx
|
|
177
|
+
var DEFAULT_REFLECTION = 0.4;
|
|
178
|
+
var DEFAULT_PERSPECTIVE = 0.2;
|
|
179
|
+
var DEFAULT_DEPTH = 3;
|
|
180
|
+
var VERTEX_SHADER = `#version 300 es
|
|
181
|
+
in vec2 a_pos;
|
|
182
|
+
out vec2 v_uv;
|
|
183
|
+
void main() {
|
|
184
|
+
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
185
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
186
|
+
}`;
|
|
187
|
+
var FRAGMENT_SHADER = `#version 300 es
|
|
188
|
+
precision highp float;
|
|
189
|
+
|
|
190
|
+
uniform sampler2D u_prev;
|
|
191
|
+
uniform sampler2D u_next;
|
|
192
|
+
uniform float u_time;
|
|
193
|
+
uniform float u_reflection;
|
|
194
|
+
uniform float u_perspective;
|
|
195
|
+
uniform float u_depth;
|
|
196
|
+
|
|
197
|
+
in vec2 v_uv;
|
|
198
|
+
out vec4 outColor;
|
|
199
|
+
|
|
200
|
+
const vec4 black = vec4(0.0, 0.0, 0.0, 1.0);
|
|
201
|
+
const vec2 boundMin = vec2(0.0, 0.0);
|
|
202
|
+
const vec2 boundMax = vec2(1.0, 1.0);
|
|
203
|
+
|
|
204
|
+
bool inBounds(vec2 p) {
|
|
205
|
+
return all(lessThan(boundMin, p)) && all(lessThan(p, boundMax));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
vec2 project(vec2 p) {
|
|
209
|
+
return p * vec2(1.0, -1.2) + vec2(0.0, 2.22);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
vec4 bgColor(vec2 p, vec2 pfr, vec2 pto) {
|
|
213
|
+
vec4 c = black;
|
|
214
|
+
pfr = project(pfr);
|
|
215
|
+
if (inBounds(pfr)) {
|
|
216
|
+
c += mix(black, texture(u_prev, pfr), u_reflection * mix(1.0, 0.0, pfr.y));
|
|
217
|
+
}
|
|
218
|
+
pto = project(pto);
|
|
219
|
+
if (inBounds(pto)) {
|
|
220
|
+
c += mix(black, texture(u_next, pto), u_reflection * mix(1.0, 0.0, pto.y));
|
|
221
|
+
}
|
|
222
|
+
return c;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
vec4 transition(vec2 p, float progress) {
|
|
226
|
+
vec2 pfr;
|
|
227
|
+
vec2 pto = vec2(-1.0);
|
|
228
|
+
|
|
229
|
+
float size = mix(1.0, u_depth, progress);
|
|
230
|
+
float persp = u_perspective * progress;
|
|
231
|
+
pfr = (p + vec2(-0.0, -0.5)) * vec2(
|
|
232
|
+
size / (1.0 - u_perspective * progress),
|
|
233
|
+
size / (1.0 - size * persp * p.x)
|
|
234
|
+
) + vec2(0.0, 0.5);
|
|
235
|
+
|
|
236
|
+
size = mix(1.0, u_depth, 1.0 - progress);
|
|
237
|
+
persp = u_perspective * (1.0 - progress);
|
|
238
|
+
pto = (p + vec2(-1.0, -0.5)) * vec2(
|
|
239
|
+
size / (1.0 - u_perspective * (1.0 - progress)),
|
|
240
|
+
size / (1.0 - size * persp * (0.5 - p.x))
|
|
241
|
+
) + vec2(1.0, 0.5);
|
|
242
|
+
|
|
243
|
+
if (progress < 0.5) {
|
|
244
|
+
if (inBounds(pfr)) {
|
|
245
|
+
return texture(u_prev, pfr);
|
|
246
|
+
}
|
|
247
|
+
if (inBounds(pto)) {
|
|
248
|
+
return texture(u_next, pto);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (inBounds(pto)) {
|
|
252
|
+
return texture(u_next, pto);
|
|
253
|
+
}
|
|
254
|
+
if (inBounds(pfr)) {
|
|
255
|
+
return texture(u_prev, pfr);
|
|
256
|
+
}
|
|
257
|
+
return bgColor(p, pfr, pto);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
void main() {
|
|
261
|
+
float progress = 1.0 - u_time;
|
|
262
|
+
outColor = transition(v_uv, progress);
|
|
263
|
+
}`;
|
|
264
|
+
var compileShader = (gl, source, type) => {
|
|
265
|
+
const shader = gl.createShader(type);
|
|
266
|
+
if (!shader) {
|
|
267
|
+
throw new Error("Failed to create shader");
|
|
268
|
+
}
|
|
269
|
+
gl.shaderSource(shader, source);
|
|
270
|
+
gl.compileShader(shader);
|
|
271
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
272
|
+
const log = gl.getShaderInfoLog(shader);
|
|
273
|
+
gl.deleteShader(shader);
|
|
274
|
+
throw new Error(`Failed to compile shader: ${log}`);
|
|
275
|
+
}
|
|
276
|
+
return shader;
|
|
277
|
+
};
|
|
278
|
+
var createProgram = (gl) => {
|
|
279
|
+
const program = gl.createProgram();
|
|
280
|
+
if (!program) {
|
|
281
|
+
throw new Error("Failed to create WebGL program");
|
|
282
|
+
}
|
|
283
|
+
const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);
|
|
284
|
+
const fs = compileShader(gl, FRAGMENT_SHADER, gl.FRAGMENT_SHADER);
|
|
285
|
+
gl.attachShader(program, vs);
|
|
286
|
+
gl.attachShader(program, fs);
|
|
287
|
+
gl.linkProgram(program);
|
|
288
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
289
|
+
const log = gl.getProgramInfoLog(program);
|
|
290
|
+
gl.deleteProgram(program);
|
|
291
|
+
throw new Error(`Failed to link program: ${log}`);
|
|
292
|
+
}
|
|
293
|
+
return program;
|
|
294
|
+
};
|
|
295
|
+
var createTexture = (gl) => {
|
|
296
|
+
const tex = gl.createTexture();
|
|
297
|
+
if (!tex) {
|
|
298
|
+
throw new Error("Failed to create texture");
|
|
299
|
+
}
|
|
300
|
+
gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
301
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
302
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
303
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
304
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
305
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
|
|
306
|
+
return tex;
|
|
307
|
+
};
|
|
308
|
+
var swapShader = (canvas) => {
|
|
309
|
+
const gl = canvas.getContext("webgl2", { premultipliedAlpha: true });
|
|
310
|
+
if (!gl) {
|
|
311
|
+
throw new Error("Failed to create WebGL2 context");
|
|
312
|
+
}
|
|
313
|
+
const program = createProgram(gl);
|
|
314
|
+
const prevTex = createTexture(gl);
|
|
315
|
+
const nextTex = createTexture(gl);
|
|
316
|
+
const vao = gl.createVertexArray();
|
|
317
|
+
gl.bindVertexArray(vao);
|
|
318
|
+
const buffer = gl.createBuffer();
|
|
319
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
320
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
|
|
321
|
+
const aPos = gl.getAttribLocation(program, "a_pos");
|
|
322
|
+
gl.enableVertexAttribArray(aPos);
|
|
323
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
|
|
324
|
+
const uTime = gl.getUniformLocation(program, "u_time");
|
|
325
|
+
const uPrev = gl.getUniformLocation(program, "u_prev");
|
|
326
|
+
const uNext = gl.getUniformLocation(program, "u_next");
|
|
327
|
+
const uReflection = gl.getUniformLocation(program, "u_reflection");
|
|
328
|
+
const uPerspective = gl.getUniformLocation(program, "u_perspective");
|
|
329
|
+
const uDepth = gl.getUniformLocation(program, "u_depth");
|
|
330
|
+
const cleanup = () => {
|
|
331
|
+
gl.deleteProgram(program);
|
|
332
|
+
gl.deleteTexture(prevTex);
|
|
333
|
+
gl.deleteTexture(nextTex);
|
|
334
|
+
};
|
|
335
|
+
const clear = () => {
|
|
336
|
+
gl.clearColor(0, 0, 0, 0);
|
|
337
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
338
|
+
};
|
|
339
|
+
const draw = ({
|
|
340
|
+
prevImage,
|
|
341
|
+
nextImage,
|
|
342
|
+
width,
|
|
343
|
+
height,
|
|
344
|
+
time,
|
|
345
|
+
passedProps
|
|
346
|
+
}) => {
|
|
347
|
+
const {
|
|
348
|
+
reflection = DEFAULT_REFLECTION,
|
|
349
|
+
perspective = DEFAULT_PERSPECTIVE,
|
|
350
|
+
depth = DEFAULT_DEPTH
|
|
351
|
+
} = passedProps;
|
|
352
|
+
if (!prevImage && !nextImage) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (prevImage && (prevImage.width === 0 || prevImage.height === 0)) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (nextImage && (nextImage.width === 0 || nextImage.height === 0)) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const effectiveTime = !prevImage ? 0 : !nextImage ? 1 : time;
|
|
362
|
+
gl.viewport(0, 0, width, height);
|
|
363
|
+
gl.clearColor(0, 0, 0, 0);
|
|
364
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
365
|
+
gl.useProgram(program);
|
|
366
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
367
|
+
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
368
|
+
if (prevImage) {
|
|
369
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, prevImage);
|
|
370
|
+
}
|
|
371
|
+
gl.uniform1i(uPrev, 0);
|
|
372
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
373
|
+
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
374
|
+
if (nextImage) {
|
|
375
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, nextImage);
|
|
376
|
+
}
|
|
377
|
+
gl.uniform1i(uNext, 1);
|
|
378
|
+
gl.uniform1f(uTime, effectiveTime);
|
|
379
|
+
gl.uniform1f(uReflection, reflection);
|
|
380
|
+
gl.uniform1f(uPerspective, perspective);
|
|
381
|
+
gl.uniform1f(uDepth, depth);
|
|
382
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
383
|
+
};
|
|
384
|
+
return {
|
|
385
|
+
clear,
|
|
386
|
+
cleanup,
|
|
387
|
+
draw
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
var swap = makeHtmlInCanvasPresentation(swapShader);
|
|
391
|
+
export {
|
|
392
|
+
swapShader,
|
|
393
|
+
swap
|
|
394
|
+
};
|
package/dist/esm/zoom-blur.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// src/html-in-canvas-presentation.tsx
|
|
2
|
-
import { useLayoutEffect, useMemo, useRef, useState
|
|
2
|
+
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
AbsoluteFill,
|
|
5
5
|
HTML_IN_CANVAS_UNSUPPORTED_MESSAGE,
|
|
6
|
+
HtmlInCanvas,
|
|
7
|
+
Internals,
|
|
6
8
|
useDelayRender
|
|
7
9
|
} from "remotion";
|
|
8
|
-
import { AbsoluteFill, Internals } from "remotion";
|
|
9
10
|
import { jsx } from "react/jsx-runtime";
|
|
10
11
|
var HtmlInCanvasPresentation = ({
|
|
11
12
|
children,
|
package/dist/esm/zoom-in-out.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// src/html-in-canvas-presentation.tsx
|
|
2
|
-
import { useLayoutEffect, useMemo, useRef, useState
|
|
2
|
+
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
AbsoluteFill,
|
|
5
5
|
HTML_IN_CANVAS_UNSUPPORTED_MESSAGE,
|
|
6
|
+
HtmlInCanvas,
|
|
7
|
+
Internals,
|
|
6
8
|
useDelayRender
|
|
7
9
|
} from "remotion";
|
|
8
|
-
import { AbsoluteFill, Internals } from "remotion";
|
|
9
10
|
import { jsx } from "react/jsx-runtime";
|
|
10
11
|
var HtmlInCanvasPresentation = ({
|
|
11
12
|
children,
|
|
@@ -4,7 +4,6 @@ exports.makeHtmlInCanvasPresentation = exports.HtmlInCanvasPresentation = void 0
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const remotion_1 = require("remotion");
|
|
7
|
-
const remotion_2 = require("remotion");
|
|
8
7
|
const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, presentationProgress, presentationDirection, shader, effects, passedProps, bothEnteringAndExiting, }) => {
|
|
9
8
|
if (!remotion_1.HtmlInCanvas.isSupported()) {
|
|
10
9
|
throw new Error(remotion_1.HTML_IN_CANVAS_UNSUPPORTED_MESSAGE);
|
|
@@ -24,7 +23,7 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
24
23
|
const [offscreenCanvas] = (0, react_1.useState)(() => new OffscreenCanvas(1, 1));
|
|
25
24
|
const passedPropsRef = (0, react_1.useRef)(passedProps);
|
|
26
25
|
passedPropsRef.current = passedProps;
|
|
27
|
-
const memoizedEffects =
|
|
26
|
+
const memoizedEffects = remotion_1.Internals.useMemoizedEffects({
|
|
28
27
|
effects: effects !== null && effects !== void 0 ? effects : [],
|
|
29
28
|
overrideId: null,
|
|
30
29
|
});
|
|
@@ -36,7 +35,7 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
36
35
|
instance.cleanup();
|
|
37
36
|
};
|
|
38
37
|
}, [offscreenCanvas, instance]);
|
|
39
|
-
const chainState =
|
|
38
|
+
const chainState = remotion_1.Internals.useEffectChainState();
|
|
40
39
|
const { delayRender, continueRender } = (0, remotion_1.useDelayRender)();
|
|
41
40
|
const draw = (0, react_1.useCallback)(async (prevImage, nextImage, progress) => {
|
|
42
41
|
var _a, _b, _c, _d, _e;
|
|
@@ -66,7 +65,7 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
66
65
|
time: progress,
|
|
67
66
|
passedProps: passedPropsRef.current,
|
|
68
67
|
});
|
|
69
|
-
await
|
|
68
|
+
await remotion_1.Internals.runEffectChain({
|
|
70
69
|
state: chainState.get(width, height),
|
|
71
70
|
source: offscreenCanvas,
|
|
72
71
|
effects: (_e = effectsRef.current) !== null && _e !== void 0 ? _e : [],
|
|
@@ -136,7 +135,7 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
136
135
|
if (passThrough) {
|
|
137
136
|
return children;
|
|
138
137
|
}
|
|
139
|
-
return (jsx_runtime_1.jsx(
|
|
138
|
+
return (jsx_runtime_1.jsx(remotion_1.AbsoluteFill, { children: jsx_runtime_1.jsx("canvas", { ref: canvasRef, style: canvasSubtreeStyle, children: children }) }));
|
|
140
139
|
};
|
|
141
140
|
exports.HtmlInCanvasPresentation = HtmlInCanvasPresentation;
|
|
142
141
|
const makeHtmlInCanvasPresentation = (shader) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export { linearTiming } from './timings/linear-timing.js';
|
|
2
2
|
export { springTiming } from './timings/spring-timing.js';
|
|
3
3
|
export { TransitionSeries } from './TransitionSeries.js';
|
|
4
|
-
export { TransitionPresentation, TransitionPresentationComponentProps, TransitionSeriesOverlayProps, TransitionTiming, } from './types.js';
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
4
|
+
export type { TransitionPresentation, TransitionPresentationComponentProps, TransitionSeriesOverlayProps, TransitionTiming, } from './types.js';
|
|
5
|
+
export { useTransitionProgress } from './use-transition-progress.js';
|
|
6
|
+
export type { TransitionState } from './use-transition-progress.js';
|
|
7
|
+
export { makeHtmlInCanvasPresentation } from './html-in-canvas-presentation.js';
|
|
8
|
+
export type { HtmlInCanvasShader, HtmlInCanvasShaderDraw, HtmlInCanvasShaderDrawParams, } from './html-in-canvas-presentation.js';
|
|
9
|
+
export { crossZoom } from './presentations/cross-zoom.js';
|
|
10
|
+
export type { CrossZoomProps } from './presentations/cross-zoom.js';
|
|
11
|
+
export { dreamyZoom } from './presentations/dreamy-zoom.js';
|
|
12
|
+
export type { DreamyZoomProps } from './presentations/dreamy-zoom.js';
|
|
13
|
+
export { filmBurn } from './presentations/film-burn.js';
|
|
14
|
+
export type { FilmBurnProps } from './presentations/film-burn.js';
|
|
15
|
+
export { linearBlur } from './presentations/linear-blur.js';
|
|
16
|
+
export type { LinearBlurProps } from './presentations/linear-blur.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeHtmlInCanvasPresentation = exports.useTransitionProgress = exports.TransitionSeries = exports.springTiming = exports.linearTiming = void 0;
|
|
3
|
+
exports.linearBlur = exports.filmBurn = exports.dreamyZoom = exports.crossZoom = exports.makeHtmlInCanvasPresentation = exports.useTransitionProgress = exports.TransitionSeries = exports.springTiming = exports.linearTiming = void 0;
|
|
4
4
|
// Timings
|
|
5
5
|
const linear_timing_js_1 = require("./timings/linear-timing.js");
|
|
6
6
|
Object.defineProperty(exports, "linearTiming", { enumerable: true, get: function () { return linear_timing_js_1.linearTiming; } });
|
|
@@ -15,3 +15,11 @@ Object.defineProperty(exports, "useTransitionProgress", { enumerable: true, get:
|
|
|
15
15
|
// HTML-in-canvas
|
|
16
16
|
const html_in_canvas_presentation_js_1 = require("./html-in-canvas-presentation.js");
|
|
17
17
|
Object.defineProperty(exports, "makeHtmlInCanvasPresentation", { enumerable: true, get: function () { return html_in_canvas_presentation_js_1.makeHtmlInCanvasPresentation; } });
|
|
18
|
+
const cross_zoom_js_1 = require("./presentations/cross-zoom.js");
|
|
19
|
+
Object.defineProperty(exports, "crossZoom", { enumerable: true, get: function () { return cross_zoom_js_1.crossZoom; } });
|
|
20
|
+
const dreamy_zoom_js_1 = require("./presentations/dreamy-zoom.js");
|
|
21
|
+
Object.defineProperty(exports, "dreamyZoom", { enumerable: true, get: function () { return dreamy_zoom_js_1.dreamyZoom; } });
|
|
22
|
+
const film_burn_js_1 = require("./presentations/film-burn.js");
|
|
23
|
+
Object.defineProperty(exports, "filmBurn", { enumerable: true, get: function () { return film_burn_js_1.filmBurn; } });
|
|
24
|
+
const linear_blur_js_1 = require("./presentations/linear-blur.js");
|
|
25
|
+
Object.defineProperty(exports, "linearBlur", { enumerable: true, get: function () { return linear_blur_js_1.linearBlur; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type BookFlipDirection = 'from-left' | 'from-right' | 'from-top' | 'from-bottom';
|
|
2
|
+
export type BookFlipProps = {
|
|
3
|
+
direction?: BookFlipDirection;
|
|
4
|
+
};
|
|
5
|
+
export declare const bookFlipShader: (canvas: OffscreenCanvas) => {
|
|
6
|
+
clear: () => void;
|
|
7
|
+
cleanup: () => void;
|
|
8
|
+
draw: import("..").HtmlInCanvasShaderDraw<BookFlipProps>;
|
|
9
|
+
};
|
|
10
|
+
export declare const bookFlip: (props: BookFlipProps & {
|
|
11
|
+
effects?: import("remotion").EffectsProp | undefined;
|
|
12
|
+
}) => import("..").TransitionPresentation<BookFlipProps & {
|
|
13
|
+
effects?: import("remotion").EffectsProp | undefined;
|
|
14
|
+
}>;
|