@remotion/web-renderer 4.0.386 → 4.0.387
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/dist/create-scaffold.js
CHANGED
|
@@ -17,6 +17,10 @@ export async function createScaffold({ width, height, delayRenderTimeoutInMillis
|
|
|
17
17
|
div.style.width = `${width}px`;
|
|
18
18
|
div.style.height = `${height}px`;
|
|
19
19
|
div.style.zIndex = '-9999';
|
|
20
|
+
div.style.top = '0';
|
|
21
|
+
div.style.visibility = 'hidden';
|
|
22
|
+
div.style.left = '0';
|
|
23
|
+
div.style.pointerEvents = 'none';
|
|
20
24
|
document.body.appendChild(div);
|
|
21
25
|
const { promise, resolve, reject } = withResolvers();
|
|
22
26
|
// TODO: This might not work in React 18
|
|
@@ -34,7 +38,7 @@ export async function createScaffold({ width, height, delayRenderTimeoutInMillis
|
|
|
34
38
|
const timeUpdater = createRef();
|
|
35
39
|
const collectAssets = createRef();
|
|
36
40
|
flushSync(() => {
|
|
37
|
-
root.render(_jsx(Internals.MaxMediaCacheSizeContext.Provider, { value: mediaCacheSizeInBytes, children: _jsx(Internals.RemotionEnvironmentContext, { value: {
|
|
41
|
+
root.render(_jsx(Internals.MaxMediaCacheSizeContext.Provider, { value: mediaCacheSizeInBytes, children: _jsx(Internals.RemotionEnvironmentContext.Provider, { value: {
|
|
38
42
|
isStudio: false,
|
|
39
43
|
isRendering: true,
|
|
40
44
|
isPlayer: false,
|
|
@@ -75,7 +79,7 @@ export async function createScaffold({ width, height, delayRenderTimeoutInMillis
|
|
|
75
79
|
defaultProResProfile: null,
|
|
76
80
|
},
|
|
77
81
|
folders: [],
|
|
78
|
-
}, 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, { value: true, children: _jsx(Component, { ...resolvedProps }) }) }) }) }) }) }) }));
|
|
82
|
+
}, 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 }) }) }) }) }) }) }) }));
|
|
79
83
|
});
|
|
80
84
|
resolve();
|
|
81
85
|
await promise;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const drawTextToCanvas: (parentElement: HTMLElement, context: OffscreenCanvasRenderingContext2D) => Promise<void>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { withResolvers } from '../../with-resolvers';
|
|
2
|
+
export const drawTextToCanvas = async (parentElement, context) => {
|
|
3
|
+
const clientRect = parentElement.getBoundingClientRect();
|
|
4
|
+
const computedStyle = getComputedStyle(parentElement);
|
|
5
|
+
const clonedNode = parentElement.cloneNode(true);
|
|
6
|
+
for (let i = 0; i < computedStyle.length; i++) {
|
|
7
|
+
const propertyName = computedStyle[i];
|
|
8
|
+
const value = computedStyle.getPropertyValue(propertyName);
|
|
9
|
+
if (propertyName === 'margin-top' ||
|
|
10
|
+
propertyName === 'margin-bottom' ||
|
|
11
|
+
propertyName === 'margin-left' ||
|
|
12
|
+
propertyName === 'margin-right' ||
|
|
13
|
+
propertyName === 'margin') {
|
|
14
|
+
// @ts-expect-error - propertyName is a valid CSS property
|
|
15
|
+
clonedNode.style[propertyName] = '0px';
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
// @ts-expect-error - propertyName is a valid CSS property
|
|
19
|
+
clonedNode.style[propertyName] = value;
|
|
20
|
+
}
|
|
21
|
+
// Create an SVG that contains the cloned node via a foreignObject
|
|
22
|
+
const svgNS = 'http://www.w3.org/2000/svg';
|
|
23
|
+
const svg = document.createElementNS(svgNS, 'svg');
|
|
24
|
+
svg.setAttribute('width', `${clientRect.width}`);
|
|
25
|
+
svg.setAttribute('height', `${clientRect.height}`);
|
|
26
|
+
const foreignObject = document.createElementNS(svgNS, 'foreignObject');
|
|
27
|
+
foreignObject.setAttribute('x', '0');
|
|
28
|
+
foreignObject.setAttribute('y', '0');
|
|
29
|
+
foreignObject.setAttribute('width', `${clientRect.width}`);
|
|
30
|
+
foreignObject.setAttribute('height', `${clientRect.height}`);
|
|
31
|
+
// The cloned node must be in XHTML namespace to render properly
|
|
32
|
+
const xhtmlNS = 'http://www.w3.org/1999/xhtml';
|
|
33
|
+
const wrappedDiv = document.createElementNS(xhtmlNS, 'div');
|
|
34
|
+
wrappedDiv.style.width = `${clientRect.width}px`;
|
|
35
|
+
wrappedDiv.style.height = `${clientRect.height}px`;
|
|
36
|
+
wrappedDiv.appendChild(clonedNode);
|
|
37
|
+
foreignObject.appendChild(wrappedDiv);
|
|
38
|
+
svg.appendChild(foreignObject);
|
|
39
|
+
// Convert SVG to data URL
|
|
40
|
+
const serializer = new XMLSerializer();
|
|
41
|
+
const svgString = serializer.serializeToString(svg);
|
|
42
|
+
const svgDataUrl = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgString)}`;
|
|
43
|
+
const { promise, resolve, reject } = withResolvers();
|
|
44
|
+
// Create image and draw when loaded
|
|
45
|
+
const img = new window.Image();
|
|
46
|
+
img.onload = function () {
|
|
47
|
+
resolve(img);
|
|
48
|
+
};
|
|
49
|
+
img.onerror = function (err) {
|
|
50
|
+
// We may want to add robust error handling here
|
|
51
|
+
reject(err);
|
|
52
|
+
};
|
|
53
|
+
img.src = svgDataUrl;
|
|
54
|
+
await promise;
|
|
55
|
+
console.log(clientRect);
|
|
56
|
+
context.drawImage(img, clientRect.left, clientRect.top, clientRect.width, clientRect.height);
|
|
57
|
+
};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -8465,6 +8465,10 @@ async function createScaffold({
|
|
|
8465
8465
|
div.style.width = `${width}px`;
|
|
8466
8466
|
div.style.height = `${height}px`;
|
|
8467
8467
|
div.style.zIndex = "-9999";
|
|
8468
|
+
div.style.top = "0";
|
|
8469
|
+
div.style.visibility = "hidden";
|
|
8470
|
+
div.style.left = "0";
|
|
8471
|
+
div.style.pointerEvents = "none";
|
|
8468
8472
|
document.body.appendChild(div);
|
|
8469
8473
|
const { promise, resolve, reject } = withResolvers();
|
|
8470
8474
|
const root = ReactDOM.createRoot(div, {
|
|
@@ -8483,7 +8487,7 @@ async function createScaffold({
|
|
|
8483
8487
|
flushSync2(() => {
|
|
8484
8488
|
root.render(/* @__PURE__ */ jsx2(Internals2.MaxMediaCacheSizeContext.Provider, {
|
|
8485
8489
|
value: mediaCacheSizeInBytes,
|
|
8486
|
-
children: /* @__PURE__ */ jsx2(Internals2.RemotionEnvironmentContext, {
|
|
8490
|
+
children: /* @__PURE__ */ jsx2(Internals2.RemotionEnvironmentContext.Provider, {
|
|
8487
8491
|
value: {
|
|
8488
8492
|
isStudio: false,
|
|
8489
8493
|
isRendering: true,
|
|
@@ -8538,7 +8542,7 @@ async function createScaffold({
|
|
|
8538
8542
|
compId: id,
|
|
8539
8543
|
initialFrame,
|
|
8540
8544
|
timeUpdater,
|
|
8541
|
-
children: /* @__PURE__ */ jsx2(Internals2.CanUseRemotionHooks, {
|
|
8545
|
+
children: /* @__PURE__ */ jsx2(Internals2.CanUseRemotionHooks.Provider, {
|
|
8542
8546
|
value: true,
|
|
8543
8547
|
children: /* @__PURE__ */ jsx2(Component, {
|
|
8544
8548
|
...resolvedProps
|
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.387",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"scripts": {
|
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
"author": "Remotion <jonny@remotion.dev>",
|
|
17
17
|
"license": "UNLICENSED",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"remotion": "4.0.
|
|
19
|
+
"remotion": "4.0.387",
|
|
20
20
|
"mediabunny": "1.25.8"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
24
|
-
"@remotion/player": "4.0.
|
|
25
|
-
"@remotion/media": "4.0.
|
|
23
|
+
"@remotion/eslint-config-internal": "4.0.387",
|
|
24
|
+
"@remotion/player": "4.0.387",
|
|
25
|
+
"@remotion/media": "4.0.387",
|
|
26
26
|
"@vitejs/plugin-react": "4.1.0",
|
|
27
27
|
"@vitest/browser-playwright": "4.0.9",
|
|
28
28
|
"playwright": "1.55.1",
|
|
29
29
|
"eslint": "9.19.0",
|
|
30
|
-
"react": "19.2.
|
|
31
|
-
"react-dom": "19.2.
|
|
30
|
+
"react": "19.2.3",
|
|
31
|
+
"react-dom": "19.2.3",
|
|
32
32
|
"vitest": "4.0.9",
|
|
33
33
|
"vitest-browser-react": "^2.0.2",
|
|
34
34
|
"zod": "3.22.3"
|