@remotion/web-renderer 4.0.415 → 4.0.417
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/package.json +7 -7
- package/dist/add-sample.js +0 -20
- package/dist/artifact.js +0 -56
- package/dist/audio.js +0 -42
- package/dist/calculate-transforms.d.ts +0 -9
- package/dist/calculate-transforms.js +0 -74
- package/dist/can-use-webfs-target.js +0 -19
- package/dist/composable.d.ts +0 -10
- package/dist/composable.js +0 -1
- package/dist/compose-canvas.d.ts +0 -1
- package/dist/compose-canvas.js +0 -12
- package/dist/compose-svg.d.ts +0 -1
- package/dist/compose-svg.js +0 -34
- package/dist/compose.js +0 -85
- package/dist/create-scaffold.js +0 -104
- package/dist/drawing/border-radius.js +0 -151
- package/dist/drawing/calculate-object-fit.js +0 -208
- package/dist/drawing/calculate-transforms.js +0 -127
- package/dist/drawing/clamp-rect-to-parent-bounds.js +0 -18
- package/dist/drawing/do-rects-intersect.js +0 -6
- package/dist/drawing/draw-background.js +0 -62
- package/dist/drawing/draw-border.js +0 -353
- package/dist/drawing/draw-box-shadow.js +0 -103
- package/dist/drawing/draw-dom-element.js +0 -85
- package/dist/drawing/draw-element-to-canvas.d.ts +0 -11
- package/dist/drawing/draw-element-to-canvas.js +0 -64
- package/dist/drawing/draw-element.js +0 -84
- package/dist/drawing/draw-outline.js +0 -93
- package/dist/drawing/draw-rounded.js +0 -34
- package/dist/drawing/drawn-fn.js +0 -1
- package/dist/drawing/fit-svg-into-its-dimensions.js +0 -35
- package/dist/drawing/get-clipped-background.d.ts +0 -23
- package/dist/drawing/get-clipped-background.js +0 -14
- package/dist/drawing/get-padding-box.js +0 -30
- package/dist/drawing/get-pretransform-rect.js +0 -49
- package/dist/drawing/go-rects-intersect.d.ts +0 -1
- package/dist/drawing/go-rects-intersect.js +0 -6
- package/dist/drawing/handle-3d-transform.js +0 -26
- package/dist/drawing/handle-mask.js +0 -21
- package/dist/drawing/has-transform.js +0 -14
- package/dist/drawing/mask-image.js +0 -14
- package/dist/drawing/opacity.js +0 -7
- package/dist/drawing/overflow.js +0 -14
- package/dist/drawing/parse-linear-gradient.js +0 -260
- package/dist/drawing/parse-transform-origin.js +0 -7
- package/dist/drawing/precompose.d.ts +0 -27
- package/dist/drawing/precompose.js +0 -14
- package/dist/drawing/process-node.js +0 -122
- package/dist/drawing/round-to-expand-rect.js +0 -7
- package/dist/drawing/text/apply-text-transform.js +0 -12
- package/dist/drawing/text/draw-text.js +0 -53
- package/dist/drawing/text/find-line-breaks.text.js +0 -118
- package/dist/drawing/text/get-base-height.d.ts +0 -1
- package/dist/drawing/text/get-base-height.js +0 -13
- package/dist/drawing/text/get-collapsed-text.d.ts +0 -1
- package/dist/drawing/text/get-collapsed-text.js +0 -46
- package/dist/drawing/text/handle-text-node.js +0 -24
- package/dist/drawing/transform-in-3d.js +0 -177
- package/dist/drawing/transform-rect-with-matrix.js +0 -19
- package/dist/drawing/transform.js +0 -10
- package/dist/drawing/turn-svg-into-drawable.js +0 -41
- package/dist/find-capturable-elements.d.ts +0 -2
- package/dist/find-capturable-elements.js +0 -28
- package/dist/frame-range.js +0 -15
- package/dist/get-audio-encoding-config.js +0 -18
- package/dist/get-biggest-bounding-client-rect.js +0 -43
- package/dist/index.js +0 -2
- package/dist/internal-state.js +0 -21
- package/dist/mediabunny-mappings.js +0 -63
- package/dist/output-target.js +0 -1
- package/dist/parse-transform-origin.d.ts +0 -4
- package/dist/parse-transform-origin.js +0 -7
- package/dist/props-if-has-props.js +0 -1
- package/dist/render-media-on-web.js +0 -297
- package/dist/render-operations-queue.js +0 -3
- package/dist/render-still-on-web.js +0 -109
- package/dist/send-telemetry-event.js +0 -22
- package/dist/take-screenshot.js +0 -30
- package/dist/throttle-progress.js +0 -43
- package/dist/tree-walker-cleanup-after-children.js +0 -33
- package/dist/update-time.js +0 -17
- package/dist/validate-video-frame.js +0 -34
- package/dist/wait-for-ready.js +0 -35
- package/dist/walk-tree.js +0 -14
- package/dist/web-fs-target.js +0 -41
- package/dist/with-resolvers.js +0 -9
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/web-renderer"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/web-renderer",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.417",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"author": "Remotion <jonny@remotion.dev>",
|
|
20
20
|
"license": "UNLICENSED",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@remotion/licensing": "4.0.
|
|
23
|
-
"remotion": "4.0.
|
|
22
|
+
"@remotion/licensing": "4.0.417",
|
|
23
|
+
"remotion": "4.0.417",
|
|
24
24
|
"mediabunny": "1.29.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@react-three/fiber": "9.2.0",
|
|
28
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
29
|
-
"@remotion/player": "4.0.
|
|
30
|
-
"@remotion/media": "4.0.
|
|
31
|
-
"@remotion/three": "4.0.
|
|
28
|
+
"@remotion/eslint-config-internal": "4.0.417",
|
|
29
|
+
"@remotion/player": "4.0.417",
|
|
30
|
+
"@remotion/media": "4.0.417",
|
|
31
|
+
"@remotion/three": "4.0.417",
|
|
32
32
|
"@types/three": "0.170.0",
|
|
33
33
|
"@typescript/native-preview": "7.0.0-dev.20260105.1",
|
|
34
34
|
"@vitejs/plugin-react": "4.1.0",
|
package/dist/add-sample.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AudioSample, VideoSample } from 'mediabunny';
|
|
2
|
-
export const addVideoSampleAndCloseFrame = async (frameToEncode, videoSampleSource) => {
|
|
3
|
-
const sample = new VideoSample(frameToEncode);
|
|
4
|
-
try {
|
|
5
|
-
await videoSampleSource.add(sample);
|
|
6
|
-
}
|
|
7
|
-
finally {
|
|
8
|
-
sample.close();
|
|
9
|
-
frameToEncode.close();
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
export const addAudioSample = async (audio, audioSampleSource) => {
|
|
13
|
-
const sample = new AudioSample(audio);
|
|
14
|
-
try {
|
|
15
|
-
await audioSampleSource.add(sample);
|
|
16
|
-
}
|
|
17
|
-
finally {
|
|
18
|
-
sample.close();
|
|
19
|
-
}
|
|
20
|
-
};
|
package/dist/artifact.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { NoReactInternals } from 'remotion/no-react';
|
|
2
|
-
export const onlyArtifact = async ({ assets, frameBuffer, }) => {
|
|
3
|
-
const artifacts = assets.filter((asset) => asset.type === 'artifact');
|
|
4
|
-
let frameBufferUint8 = null;
|
|
5
|
-
const result = [];
|
|
6
|
-
for (const artifact of artifacts) {
|
|
7
|
-
if (artifact.contentType === 'binary' || artifact.contentType === 'text') {
|
|
8
|
-
result.push({
|
|
9
|
-
frame: artifact.frame,
|
|
10
|
-
content: artifact.content,
|
|
11
|
-
filename: artifact.filename,
|
|
12
|
-
downloadBehavior: artifact.downloadBehavior,
|
|
13
|
-
});
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
if (artifact.contentType === 'thumbnail') {
|
|
17
|
-
if (frameBuffer === null) {
|
|
18
|
-
// A thumbnail artifact was defined to be emitted, but the output was not a video.
|
|
19
|
-
// Also, in Lambda, there are extra frames which are not video frames.
|
|
20
|
-
// This could happen if a thumbnail is unconditionally emitted.
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
const ab = frameBuffer instanceof Blob
|
|
24
|
-
? await frameBuffer.arrayBuffer()
|
|
25
|
-
: new Uint8Array(await (await frameBuffer.convertToBlob({ type: 'image/png' })).arrayBuffer());
|
|
26
|
-
frameBufferUint8 = new Uint8Array(ab);
|
|
27
|
-
result.push({
|
|
28
|
-
frame: artifact.frame,
|
|
29
|
-
content: frameBufferUint8,
|
|
30
|
-
filename: artifact.filename,
|
|
31
|
-
downloadBehavior: artifact.downloadBehavior,
|
|
32
|
-
});
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
throw new Error('Unknown artifact type: ' + artifact);
|
|
36
|
-
}
|
|
37
|
-
return result.filter(NoReactInternals.truthy);
|
|
38
|
-
};
|
|
39
|
-
export const handleArtifacts = () => {
|
|
40
|
-
const previousArtifacts = [];
|
|
41
|
-
const handle = async ({ imageData, frame, assets: artifactAssets, onArtifact, }) => {
|
|
42
|
-
const artifacts = await onlyArtifact({
|
|
43
|
-
assets: artifactAssets,
|
|
44
|
-
frameBuffer: imageData,
|
|
45
|
-
});
|
|
46
|
-
for (const artifact of artifacts) {
|
|
47
|
-
const previousArtifact = previousArtifacts.find((a) => a.filename === artifact.filename);
|
|
48
|
-
if (previousArtifact) {
|
|
49
|
-
throw new Error(`An artifact with output "${artifact.filename}" was already registered at frame ${previousArtifact.frame}, but now registered again at frame ${frame}. Artifacts must have unique names. https://remotion.dev/docs/artifacts`);
|
|
50
|
-
}
|
|
51
|
-
onArtifact(artifact);
|
|
52
|
-
previousArtifacts.push({ frame, filename: artifact.filename });
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return { handle };
|
|
56
|
-
};
|
package/dist/audio.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const TARGET_NUMBER_OF_CHANNELS = 2;
|
|
2
|
-
const TARGET_SAMPLE_RATE = 48000;
|
|
3
|
-
function mixAudio(waves, length) {
|
|
4
|
-
if (waves.length === 1 && waves[0].length === length) {
|
|
5
|
-
return waves[0];
|
|
6
|
-
}
|
|
7
|
-
const mixed = new Int16Array(length);
|
|
8
|
-
if (waves.length === 1) {
|
|
9
|
-
mixed.set(waves[0].subarray(0, length));
|
|
10
|
-
return mixed;
|
|
11
|
-
}
|
|
12
|
-
for (let i = 0; i < length; i++) {
|
|
13
|
-
const sum = waves.reduce((acc, wave) => {
|
|
14
|
-
var _a;
|
|
15
|
-
return acc + ((_a = wave[i]) !== null && _a !== void 0 ? _a : 0);
|
|
16
|
-
}, 0);
|
|
17
|
-
// Clamp to Int16 range
|
|
18
|
-
mixed[i] = Math.max(-32768, Math.min(32767, sum));
|
|
19
|
-
}
|
|
20
|
-
return mixed;
|
|
21
|
-
}
|
|
22
|
-
export const onlyInlineAudio = ({ assets, fps, frame, }) => {
|
|
23
|
-
const inlineAudio = assets.filter((asset) => asset.type === 'inline-audio');
|
|
24
|
-
if (inlineAudio.length === 0) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
const expectedLength = Math.round((TARGET_NUMBER_OF_CHANNELS * TARGET_SAMPLE_RATE) / fps);
|
|
28
|
-
for (const asset of inlineAudio) {
|
|
29
|
-
if (asset.toneFrequency !== 1) {
|
|
30
|
-
throw new Error('Setting the toneFrequency is not supported yet in web rendering.');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
const mixedAudio = mixAudio(inlineAudio.map((asset) => asset.audio), expectedLength);
|
|
34
|
-
return new AudioData({
|
|
35
|
-
data: mixedAudio,
|
|
36
|
-
format: 's16',
|
|
37
|
-
numberOfChannels: TARGET_NUMBER_OF_CHANNELS,
|
|
38
|
-
numberOfFrames: expectedLength / TARGET_NUMBER_OF_CHANNELS,
|
|
39
|
-
sampleRate: TARGET_SAMPLE_RATE,
|
|
40
|
-
timestamp: (frame / fps) * 1000000,
|
|
41
|
-
});
|
|
42
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { parseTransformOrigin } from './parse-transform-origin';
|
|
2
|
-
const getInternalTransformOrigin = (transform) => {
|
|
3
|
-
var _a;
|
|
4
|
-
const centerX = transform.boundingClientRect.width / 2;
|
|
5
|
-
const centerY = transform.boundingClientRect.height / 2;
|
|
6
|
-
const origin = (_a = parseTransformOrigin(transform.transformOrigin)) !== null && _a !== void 0 ? _a : {
|
|
7
|
-
x: centerX,
|
|
8
|
-
y: centerY,
|
|
9
|
-
};
|
|
10
|
-
return origin;
|
|
11
|
-
};
|
|
12
|
-
const getGlobalTransformOrigin = (transform) => {
|
|
13
|
-
const { x: originX, y: originY } = getInternalTransformOrigin(transform);
|
|
14
|
-
return {
|
|
15
|
-
x: originX + transform.boundingClientRect.left,
|
|
16
|
-
y: originY + transform.boundingClientRect.top,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export const calculateTransforms = (element) => {
|
|
20
|
-
// Compute the cumulative transform by traversing parent nodes
|
|
21
|
-
let parent = element;
|
|
22
|
-
const transforms = [];
|
|
23
|
-
const toReset = [];
|
|
24
|
-
while (parent) {
|
|
25
|
-
const computedStyle = getComputedStyle(parent);
|
|
26
|
-
if ((computedStyle.transform && computedStyle.transform !== 'none') ||
|
|
27
|
-
parent === element) {
|
|
28
|
-
const toParse = computedStyle.transform === 'none' || computedStyle.transform === ''
|
|
29
|
-
? undefined
|
|
30
|
-
: computedStyle.transform;
|
|
31
|
-
const matrix = new DOMMatrix(toParse);
|
|
32
|
-
const { transform } = parent.style;
|
|
33
|
-
parent.style.transform = 'none';
|
|
34
|
-
transforms.push({
|
|
35
|
-
matrix,
|
|
36
|
-
rect: parent,
|
|
37
|
-
transformOrigin: computedStyle.transformOrigin,
|
|
38
|
-
boundingClientRect: null,
|
|
39
|
-
});
|
|
40
|
-
const parentRef = parent;
|
|
41
|
-
toReset.push(() => {
|
|
42
|
-
parentRef.style.transform = transform;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
parent = parent.parentElement;
|
|
46
|
-
}
|
|
47
|
-
for (const transform of transforms) {
|
|
48
|
-
transform.boundingClientRect = transform.rect.getBoundingClientRect();
|
|
49
|
-
}
|
|
50
|
-
const dimensions = transforms[0].boundingClientRect;
|
|
51
|
-
const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
|
|
52
|
-
const totalMatrix = new DOMMatrix();
|
|
53
|
-
for (const transform of transforms.slice().reverse()) {
|
|
54
|
-
if (!transform.boundingClientRect) {
|
|
55
|
-
throw new Error('Bounding client rect not found');
|
|
56
|
-
}
|
|
57
|
-
const globalTransformOrigin = getGlobalTransformOrigin(transform);
|
|
58
|
-
const transformMatrix = new DOMMatrix()
|
|
59
|
-
.translate(globalTransformOrigin.x, globalTransformOrigin.y)
|
|
60
|
-
.multiply(transform.matrix)
|
|
61
|
-
.translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
|
|
62
|
-
totalMatrix.multiplySelf(transformMatrix);
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
dimensions,
|
|
66
|
-
totalMatrix,
|
|
67
|
-
reset: () => {
|
|
68
|
-
for (const reset of toReset) {
|
|
69
|
-
reset();
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
nativeTransformOrigin,
|
|
73
|
-
};
|
|
74
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const canUseWebFsWriter = async () => {
|
|
2
|
-
if (!('storage' in navigator)) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
if (!('getDirectory' in navigator.storage)) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
try {
|
|
9
|
-
const directoryHandle = await navigator.storage.getDirectory();
|
|
10
|
-
const fileHandle = await directoryHandle.getFileHandle('remotion-probe-web-fs-support', {
|
|
11
|
-
create: true,
|
|
12
|
-
});
|
|
13
|
-
const canUse = fileHandle.createWritable !== undefined;
|
|
14
|
-
return canUse;
|
|
15
|
-
}
|
|
16
|
-
catch (_a) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
};
|
package/dist/composable.d.ts
DELETED
package/dist/composable.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/compose-canvas.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const composeCanvas: (canvas: HTMLCanvasElement | HTMLImageElement | SVGSVGElement, context: OffscreenCanvasRenderingContext2D) => Promise<void>;
|
package/dist/compose-canvas.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { calculateTransforms } from './calculate-transforms';
|
|
2
|
-
import { turnSvgIntoDrawable } from './compose-svg';
|
|
3
|
-
export const composeCanvas = async (canvas, context) => {
|
|
4
|
-
const { totalMatrix, reset, dimensions } = calculateTransforms(canvas);
|
|
5
|
-
context.setTransform(totalMatrix);
|
|
6
|
-
const drawable = canvas instanceof SVGSVGElement
|
|
7
|
-
? await turnSvgIntoDrawable(canvas)
|
|
8
|
-
: canvas;
|
|
9
|
-
context.drawImage(drawable, dimensions.left, dimensions.top, dimensions.width, dimensions.height);
|
|
10
|
-
context.setTransform(new DOMMatrix());
|
|
11
|
-
reset();
|
|
12
|
-
};
|
package/dist/compose-svg.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const turnSvgIntoDrawable: (svg: SVGSVGElement) => Promise<HTMLImageElement>;
|
package/dist/compose-svg.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export const turnSvgIntoDrawable = (svg) => {
|
|
2
|
-
const originalTransform = svg.style.transform;
|
|
3
|
-
const originalTransformOrigin = svg.style.transformOrigin;
|
|
4
|
-
const originalMarginLeft = svg.style.marginLeft;
|
|
5
|
-
const originalMarginRight = svg.style.marginRight;
|
|
6
|
-
const originalMarginTop = svg.style.marginTop;
|
|
7
|
-
const originalMarginBottom = svg.style.marginBottom;
|
|
8
|
-
svg.style.transform = 'none';
|
|
9
|
-
svg.style.transformOrigin = '';
|
|
10
|
-
// Margins were already included in the positioning calculation,
|
|
11
|
-
// so we need to remove them to avoid double counting.
|
|
12
|
-
svg.style.marginLeft = '0';
|
|
13
|
-
svg.style.marginRight = '0';
|
|
14
|
-
svg.style.marginTop = '0';
|
|
15
|
-
svg.style.marginBottom = '0';
|
|
16
|
-
const svgData = new XMLSerializer().serializeToString(svg);
|
|
17
|
-
svg.style.marginLeft = originalMarginLeft;
|
|
18
|
-
svg.style.marginRight = originalMarginRight;
|
|
19
|
-
svg.style.marginTop = originalMarginTop;
|
|
20
|
-
svg.style.marginBottom = originalMarginBottom;
|
|
21
|
-
svg.style.transform = originalTransform;
|
|
22
|
-
svg.style.transformOrigin = originalTransformOrigin;
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
const image = new Image();
|
|
25
|
-
const url = `data:image/svg+xml;base64,${btoa(svgData)}`;
|
|
26
|
-
image.onload = function () {
|
|
27
|
-
resolve(image);
|
|
28
|
-
};
|
|
29
|
-
image.onerror = () => {
|
|
30
|
-
reject(new Error('Failed to convert SVG to image'));
|
|
31
|
-
};
|
|
32
|
-
image.src = url;
|
|
33
|
-
});
|
|
34
|
-
};
|
package/dist/compose.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { drawDomElement } from './drawing/draw-dom-element';
|
|
2
|
-
import { processNode } from './drawing/process-node';
|
|
3
|
-
import { handleTextNode } from './drawing/text/handle-text-node';
|
|
4
|
-
import { createTreeWalkerCleanupAfterChildren } from './tree-walker-cleanup-after-children';
|
|
5
|
-
import { skipToNextNonDescendant } from './walk-tree';
|
|
6
|
-
const walkOverNode = ({ node, context, logLevel, parentRect, internalState, rootElement, onlyBackgroundClip, }) => {
|
|
7
|
-
if (node instanceof HTMLElement || node instanceof SVGElement) {
|
|
8
|
-
return processNode({
|
|
9
|
-
element: node,
|
|
10
|
-
context,
|
|
11
|
-
draw: drawDomElement(node),
|
|
12
|
-
logLevel,
|
|
13
|
-
parentRect,
|
|
14
|
-
internalState,
|
|
15
|
-
rootElement,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
if (node instanceof Text) {
|
|
19
|
-
return handleTextNode({
|
|
20
|
-
node,
|
|
21
|
-
context,
|
|
22
|
-
logLevel,
|
|
23
|
-
parentRect,
|
|
24
|
-
internalState,
|
|
25
|
-
rootElement,
|
|
26
|
-
onlyBackgroundClip,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
throw new Error('Unknown node type');
|
|
30
|
-
};
|
|
31
|
-
const getFilterFunction = (node) => {
|
|
32
|
-
if (!(node instanceof Element)) {
|
|
33
|
-
// Must be a text node!
|
|
34
|
-
return NodeFilter.FILTER_ACCEPT;
|
|
35
|
-
}
|
|
36
|
-
// SVG does have children, but we process SVG elements in its
|
|
37
|
-
// entirety
|
|
38
|
-
if (node.parentElement instanceof SVGSVGElement) {
|
|
39
|
-
return NodeFilter.FILTER_REJECT;
|
|
40
|
-
}
|
|
41
|
-
const computedStyle = getComputedStyle(node);
|
|
42
|
-
if (computedStyle.display === 'none') {
|
|
43
|
-
return NodeFilter.FILTER_REJECT;
|
|
44
|
-
}
|
|
45
|
-
return NodeFilter.FILTER_ACCEPT;
|
|
46
|
-
};
|
|
47
|
-
export const compose = async ({ element, context, logLevel, parentRect, internalState, onlyBackgroundClip, }) => {
|
|
48
|
-
const treeWalker = document.createTreeWalker(element, onlyBackgroundClip
|
|
49
|
-
? NodeFilter.SHOW_TEXT
|
|
50
|
-
: NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, getFilterFunction);
|
|
51
|
-
// Skip to the first text node
|
|
52
|
-
if (onlyBackgroundClip) {
|
|
53
|
-
treeWalker.nextNode();
|
|
54
|
-
if (!treeWalker.currentNode) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const { checkCleanUpAtBeginningOfIteration, addCleanup, cleanupInTheEndOfTheIteration, } = createTreeWalkerCleanupAfterChildren(treeWalker);
|
|
59
|
-
while (true) {
|
|
60
|
-
checkCleanUpAtBeginningOfIteration();
|
|
61
|
-
const val = await walkOverNode({
|
|
62
|
-
node: treeWalker.currentNode,
|
|
63
|
-
context,
|
|
64
|
-
logLevel,
|
|
65
|
-
parentRect,
|
|
66
|
-
internalState,
|
|
67
|
-
rootElement: element,
|
|
68
|
-
onlyBackgroundClip,
|
|
69
|
-
});
|
|
70
|
-
if (val.type === 'skip-children') {
|
|
71
|
-
if (!skipToNextNonDescendant(treeWalker)) {
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
if (val.cleanupAfterChildren) {
|
|
77
|
-
addCleanup(treeWalker.currentNode, val.cleanupAfterChildren);
|
|
78
|
-
}
|
|
79
|
-
if (!treeWalker.nextNode()) {
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
cleanupInTheEndOfTheIteration();
|
|
85
|
-
};
|
package/dist/create-scaffold.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createRef } from 'react';
|
|
3
|
-
import { flushSync } from 'react-dom';
|
|
4
|
-
import ReactDOM from 'react-dom/client';
|
|
5
|
-
import { Internals } from 'remotion';
|
|
6
|
-
import { UpdateTime } from './update-time';
|
|
7
|
-
import { withResolvers } from './with-resolvers';
|
|
8
|
-
export async function createScaffold({ width, height, delayRenderTimeoutInMilliseconds, logLevel, resolvedProps, id, mediaCacheSizeInBytes, durationInFrames, fps, initialFrame, schema, Component, audioEnabled, videoEnabled, defaultCodec, defaultOutName, }) {
|
|
9
|
-
if (!ReactDOM.createRoot) {
|
|
10
|
-
throw new Error('@remotion/web-renderer requires React 18 or higher');
|
|
11
|
-
}
|
|
12
|
-
const div = document.createElement('div');
|
|
13
|
-
// Match same behavior as in portal-node.ts
|
|
14
|
-
div.style.position = 'fixed';
|
|
15
|
-
div.style.display = 'flex';
|
|
16
|
-
div.style.flexDirection = 'column';
|
|
17
|
-
div.style.backgroundColor = 'transparent';
|
|
18
|
-
div.style.width = `${width}px`;
|
|
19
|
-
div.style.height = `${height}px`;
|
|
20
|
-
div.style.zIndex = '-9999';
|
|
21
|
-
div.style.top = '0';
|
|
22
|
-
div.style.left = '0';
|
|
23
|
-
div.style.right = '0';
|
|
24
|
-
div.style.bottom = '0';
|
|
25
|
-
div.style.visibility = 'hidden';
|
|
26
|
-
div.style.pointerEvents = 'none';
|
|
27
|
-
const scaffoldClassName = `remotion-scaffold-${Math.random().toString(36).substring(2, 15)}`;
|
|
28
|
-
div.className = scaffoldClassName;
|
|
29
|
-
const cleanupCSS = Internals.CSSUtils.injectCSS(Internals.CSSUtils.makeDefaultPreviewCSS(`.${scaffoldClassName}`, 'white'));
|
|
30
|
-
document.body.appendChild(div);
|
|
31
|
-
const { promise, resolve, reject } = withResolvers();
|
|
32
|
-
// TODO: This might not work in React 18
|
|
33
|
-
const root = ReactDOM.createRoot(div, {
|
|
34
|
-
onUncaughtError: (err) => {
|
|
35
|
-
reject(err);
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const delayRenderScope = {
|
|
39
|
-
remotion_renderReady: true,
|
|
40
|
-
remotion_delayRenderTimeouts: {},
|
|
41
|
-
remotion_puppeteerTimeout: delayRenderTimeoutInMilliseconds,
|
|
42
|
-
remotion_attempt: 0,
|
|
43
|
-
remotion_delayRenderHandles: [],
|
|
44
|
-
};
|
|
45
|
-
const timeUpdater = createRef();
|
|
46
|
-
const collectAssets = createRef();
|
|
47
|
-
flushSync(() => {
|
|
48
|
-
root.render(_jsx(Internals.MaxMediaCacheSizeContext.Provider, { value: mediaCacheSizeInBytes, children: _jsx(Internals.RemotionEnvironmentContext.Provider, { value: {
|
|
49
|
-
isStudio: false,
|
|
50
|
-
isRendering: true,
|
|
51
|
-
isPlayer: false,
|
|
52
|
-
isReadOnlyStudio: false,
|
|
53
|
-
isClientSideRendering: true,
|
|
54
|
-
}, children: _jsx(Internals.DelayRenderContextType.Provider, { value: delayRenderScope, children: _jsx(Internals.CompositionManager.Provider, { value: {
|
|
55
|
-
compositions: [
|
|
56
|
-
{
|
|
57
|
-
id,
|
|
58
|
-
// @ts-expect-error
|
|
59
|
-
component: Component,
|
|
60
|
-
nonce: 0,
|
|
61
|
-
defaultProps: {},
|
|
62
|
-
folderName: null,
|
|
63
|
-
parentFolderName: null,
|
|
64
|
-
schema: schema !== null && schema !== void 0 ? schema : null,
|
|
65
|
-
calculateMetadata: null,
|
|
66
|
-
durationInFrames,
|
|
67
|
-
fps,
|
|
68
|
-
height,
|
|
69
|
-
width,
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
canvasContent: {
|
|
73
|
-
type: 'composition',
|
|
74
|
-
compositionId: id,
|
|
75
|
-
},
|
|
76
|
-
currentCompositionMetadata: {
|
|
77
|
-
props: resolvedProps,
|
|
78
|
-
durationInFrames,
|
|
79
|
-
fps,
|
|
80
|
-
height,
|
|
81
|
-
width,
|
|
82
|
-
defaultCodec: defaultCodec !== null && defaultCodec !== void 0 ? defaultCodec : null,
|
|
83
|
-
defaultOutName: defaultOutName !== null && defaultOutName !== void 0 ? defaultOutName : null,
|
|
84
|
-
defaultVideoImageFormat: null,
|
|
85
|
-
defaultPixelFormat: null,
|
|
86
|
-
defaultProResProfile: null,
|
|
87
|
-
},
|
|
88
|
-
folders: [],
|
|
89
|
-
}, children: _jsx(Internals.RenderAssetManagerProvider, { collectAssets: collectAssets, children: _jsx(UpdateTime, { audioEnabled: audioEnabled, videoEnabled: videoEnabled, logLevel: logLevel, compId: id, initialFrame: initialFrame, timeUpdater: timeUpdater, children: _jsx(Internals.CanUseRemotionHooks.Provider, { value: true, children: _jsx(Component, { ...resolvedProps }) }) }) }) }) }) }) }));
|
|
90
|
-
});
|
|
91
|
-
resolve();
|
|
92
|
-
await promise;
|
|
93
|
-
return {
|
|
94
|
-
delayRenderScope,
|
|
95
|
-
div,
|
|
96
|
-
cleanupScaffold: () => {
|
|
97
|
-
root.unmount();
|
|
98
|
-
div.remove();
|
|
99
|
-
cleanupCSS();
|
|
100
|
-
},
|
|
101
|
-
timeUpdater,
|
|
102
|
-
collectAssets,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { drawRoundedRectPath } from './draw-rounded';
|
|
2
|
-
import { getBoxBasedOnBackgroundClip } from './get-padding-box';
|
|
3
|
-
function parseValue({ value, reference, }) {
|
|
4
|
-
value = value.trim();
|
|
5
|
-
if (value.endsWith('%')) {
|
|
6
|
-
const percentage = parseFloat(value);
|
|
7
|
-
return (percentage / 100) * reference;
|
|
8
|
-
}
|
|
9
|
-
if (value.endsWith('px')) {
|
|
10
|
-
return parseFloat(value);
|
|
11
|
-
}
|
|
12
|
-
// If no unit, assume pixels
|
|
13
|
-
return parseFloat(value);
|
|
14
|
-
}
|
|
15
|
-
function expandShorthand(values) {
|
|
16
|
-
if (values.length === 1) {
|
|
17
|
-
// All corners the same
|
|
18
|
-
return [values[0], values[0], values[0], values[0]];
|
|
19
|
-
}
|
|
20
|
-
if (values.length === 2) {
|
|
21
|
-
// [0] = top-left & bottom-right, [1] = top-right & bottom-left
|
|
22
|
-
return [values[0], values[1], values[0], values[1]];
|
|
23
|
-
}
|
|
24
|
-
if (values.length === 3) {
|
|
25
|
-
// [0] = top-left, [1] = top-right & bottom-left, [2] = bottom-right
|
|
26
|
-
return [values[0], values[1], values[2], values[1]];
|
|
27
|
-
}
|
|
28
|
-
// 4 values: top-left, top-right, bottom-right, bottom-left
|
|
29
|
-
return [values[0], values[1], values[2], values[3]];
|
|
30
|
-
}
|
|
31
|
-
function clampBorderRadius({ borderRadius, width, height, }) {
|
|
32
|
-
// According to CSS spec, if the sum of border radii on adjacent corners
|
|
33
|
-
// exceeds the length of the edge, they should be proportionally reduced
|
|
34
|
-
const clamped = {
|
|
35
|
-
topLeft: { ...borderRadius.topLeft },
|
|
36
|
-
topRight: { ...borderRadius.topRight },
|
|
37
|
-
bottomRight: { ...borderRadius.bottomRight },
|
|
38
|
-
bottomLeft: { ...borderRadius.bottomLeft },
|
|
39
|
-
};
|
|
40
|
-
// Check top edge
|
|
41
|
-
const topSum = clamped.topLeft.horizontal + clamped.topRight.horizontal;
|
|
42
|
-
if (topSum > width) {
|
|
43
|
-
const factor = width / topSum;
|
|
44
|
-
clamped.topLeft.horizontal *= factor;
|
|
45
|
-
clamped.topRight.horizontal *= factor;
|
|
46
|
-
}
|
|
47
|
-
// Check right edge
|
|
48
|
-
const rightSum = clamped.topRight.vertical + clamped.bottomRight.vertical;
|
|
49
|
-
if (rightSum > height) {
|
|
50
|
-
const factor = height / rightSum;
|
|
51
|
-
clamped.topRight.vertical *= factor;
|
|
52
|
-
clamped.bottomRight.vertical *= factor;
|
|
53
|
-
}
|
|
54
|
-
// Check bottom edge
|
|
55
|
-
const bottomSum = clamped.bottomRight.horizontal + clamped.bottomLeft.horizontal;
|
|
56
|
-
if (bottomSum > width) {
|
|
57
|
-
const factor = width / bottomSum;
|
|
58
|
-
clamped.bottomRight.horizontal *= factor;
|
|
59
|
-
clamped.bottomLeft.horizontal *= factor;
|
|
60
|
-
}
|
|
61
|
-
// Check left edge
|
|
62
|
-
const leftSum = clamped.bottomLeft.vertical + clamped.topLeft.vertical;
|
|
63
|
-
if (leftSum > height) {
|
|
64
|
-
const factor = height / leftSum;
|
|
65
|
-
clamped.bottomLeft.vertical *= factor;
|
|
66
|
-
clamped.topLeft.vertical *= factor;
|
|
67
|
-
}
|
|
68
|
-
return clamped;
|
|
69
|
-
}
|
|
70
|
-
export function parseBorderRadius({ borderRadius, width, height, }) {
|
|
71
|
-
// Split by '/' to separate horizontal and vertical radii
|
|
72
|
-
const parts = borderRadius.split('/').map((part) => part.trim());
|
|
73
|
-
const horizontalPart = parts[0];
|
|
74
|
-
const verticalPart = parts[1];
|
|
75
|
-
// Split each part into individual values
|
|
76
|
-
const horizontalValues = horizontalPart.split(/\s+/).filter((v) => v);
|
|
77
|
-
const verticalValues = verticalPart
|
|
78
|
-
? verticalPart.split(/\s+/).filter((v) => v)
|
|
79
|
-
: horizontalValues; // If no '/', use horizontal values for vertical
|
|
80
|
-
// Expand shorthand to 4 values
|
|
81
|
-
const [hTopLeft, hTopRight, hBottomRight, hBottomLeft] = expandShorthand(horizontalValues);
|
|
82
|
-
const [vTopLeft, vTopRight, vBottomRight, vBottomLeft] = expandShorthand(verticalValues);
|
|
83
|
-
return clampBorderRadius({
|
|
84
|
-
borderRadius: {
|
|
85
|
-
topLeft: {
|
|
86
|
-
horizontal: parseValue({ value: hTopLeft, reference: width }),
|
|
87
|
-
vertical: parseValue({ value: vTopLeft, reference: height }),
|
|
88
|
-
},
|
|
89
|
-
topRight: {
|
|
90
|
-
horizontal: parseValue({ value: hTopRight, reference: width }),
|
|
91
|
-
vertical: parseValue({ value: vTopRight, reference: height }),
|
|
92
|
-
},
|
|
93
|
-
bottomRight: {
|
|
94
|
-
horizontal: parseValue({ value: hBottomRight, reference: width }),
|
|
95
|
-
vertical: parseValue({ value: vBottomRight, reference: height }),
|
|
96
|
-
},
|
|
97
|
-
bottomLeft: {
|
|
98
|
-
horizontal: parseValue({ value: hBottomLeft, reference: width }),
|
|
99
|
-
vertical: parseValue({ value: vBottomLeft, reference: height }),
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
width,
|
|
103
|
-
height,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
export function setBorderRadius({ ctx, rect, borderRadius, forceClipEvenWhenZero = false, computedStyle, backgroundClip, }) {
|
|
107
|
-
if (borderRadius.topLeft.horizontal === 0 &&
|
|
108
|
-
borderRadius.topLeft.vertical === 0 &&
|
|
109
|
-
borderRadius.topRight.horizontal === 0 &&
|
|
110
|
-
borderRadius.topRight.vertical === 0 &&
|
|
111
|
-
borderRadius.bottomRight.horizontal === 0 &&
|
|
112
|
-
borderRadius.bottomRight.vertical === 0 &&
|
|
113
|
-
borderRadius.bottomLeft.horizontal === 0 &&
|
|
114
|
-
borderRadius.bottomLeft.vertical === 0 &&
|
|
115
|
-
!forceClipEvenWhenZero) {
|
|
116
|
-
return () => { };
|
|
117
|
-
}
|
|
118
|
-
ctx.save();
|
|
119
|
-
const boundingRect = getBoxBasedOnBackgroundClip(rect, computedStyle, backgroundClip);
|
|
120
|
-
// See background-clip tests for why this logic matters!
|
|
121
|
-
const actualBorderRadius = {
|
|
122
|
-
topLeft: {
|
|
123
|
-
horizontal: Math.max(0, borderRadius.topLeft.horizontal - (boundingRect.left - rect.left)),
|
|
124
|
-
vertical: Math.max(0, borderRadius.topLeft.vertical - (boundingRect.top - rect.top)),
|
|
125
|
-
},
|
|
126
|
-
topRight: {
|
|
127
|
-
horizontal: Math.max(0, borderRadius.topRight.horizontal - (rect.right - boundingRect.right)),
|
|
128
|
-
vertical: Math.max(0, borderRadius.topRight.vertical - (boundingRect.top - rect.top)),
|
|
129
|
-
},
|
|
130
|
-
bottomRight: {
|
|
131
|
-
horizontal: Math.max(0, borderRadius.bottomRight.horizontal - (rect.right - boundingRect.right)),
|
|
132
|
-
vertical: Math.max(0, borderRadius.bottomRight.vertical - (rect.bottom - boundingRect.bottom)),
|
|
133
|
-
},
|
|
134
|
-
bottomLeft: {
|
|
135
|
-
horizontal: Math.max(0, borderRadius.bottomLeft.horizontal - (boundingRect.left - rect.left)),
|
|
136
|
-
vertical: Math.max(0, borderRadius.bottomLeft.vertical - (rect.bottom - boundingRect.bottom)),
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
drawRoundedRectPath({
|
|
140
|
-
ctx,
|
|
141
|
-
x: boundingRect.left,
|
|
142
|
-
y: boundingRect.top,
|
|
143
|
-
width: boundingRect.width,
|
|
144
|
-
height: boundingRect.height,
|
|
145
|
-
borderRadius: actualBorderRadius,
|
|
146
|
-
});
|
|
147
|
-
ctx.clip();
|
|
148
|
-
return () => {
|
|
149
|
-
ctx.restore();
|
|
150
|
-
};
|
|
151
|
-
}
|