🎥 Make videos programmatically with React
@remotion/web-renderer: Fix TS18047 ctx narrowing in html-in-canvas paint handler
Jonny Burger26c5e7a64548
diff --git a/packages/web-renderer/src/html-in-canvas.ts b/packages/web-renderer/src/html-in-canvas.tsindex b0f66016c4..37ca8c2978 100644--- a/packages/web-renderer/src/html-in-canvas.ts+++ b/packages/web-renderer/src/html-in-canvas.ts@@ -98,11 +98,15 @@ export const createLayerWithDrawElementImage = async ({};try {- const ctx = layoutCanvas.getContext('2d') as Canvas2DWithDrawElement | null;- if (!ctx || typeof ctx.drawElementImage !== 'function') {+ const maybeCtx = layoutCanvas.getContext(+ '2d',+ ) as Canvas2DWithDrawElement | null;+ if (!maybeCtx || typeof maybeCtx.drawElementImage !== 'function') {throw new Error('html-in-canvas: drawElementImage not available');}+ const context = maybeCtx;+const {requestPaint} = layoutCanvas;if (typeof requestPaint !== 'function') {throw new Error('html-in-canvas: requestPaint not available');@@ -119,8 +123,8 @@ export const createLayerWithDrawElementImage = async ({window.clearTimeout(timeoutId);try {- ctx.reset();- ctx.drawElementImage(element, 0, 0, scaledWidth, scaledHeight);+ context.reset();+ context.drawElementImage(element, 0, 0, scaledWidth, scaledHeight);settled = true;resolve();} catch (err) {