@remotion/studio 4.0.390 → 4.0.392

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.
@@ -50004,10 +50004,14 @@ var handleArtifacts = () => {
50004
50004
  var TARGET_NUMBER_OF_CHANNELS = 2;
50005
50005
  var TARGET_SAMPLE_RATE = 48000;
50006
50006
  function mixAudio(waves, length) {
50007
- if (waves.length === 1) {
50007
+ if (waves.length === 1 && waves[0].length === length) {
50008
50008
  return waves[0];
50009
50009
  }
50010
50010
  const mixed = new Int16Array(length);
50011
+ if (waves.length === 1) {
50012
+ mixed.set(waves[0].subarray(0, length));
50013
+ return mixed;
50014
+ }
50011
50015
  for (let i = 0;i < length; i++) {
50012
50016
  const sum = waves.reduce((acc, wave2) => {
50013
50017
  return acc + (wave2[i] ?? 0);
@@ -50122,7 +50126,8 @@ async function createScaffold({
50122
50126
  remotion_renderReady: true,
50123
50127
  remotion_delayRenderTimeouts: {},
50124
50128
  remotion_puppeteerTimeout: delayRenderTimeoutInMilliseconds,
50125
- remotion_attempt: 0
50129
+ remotion_attempt: 0,
50130
+ remotion_delayRenderHandles: []
50126
50131
  };
50127
50132
  const timeUpdater = createRef12();
50128
50133
  const collectAssets = createRef12();
@@ -50294,6 +50299,106 @@ var getQualityForWebRendererQuality = (quality) => {
50294
50299
  throw new Error(`Unsupported quality: ${quality}`);
50295
50300
  }
50296
50301
  };
50302
+ var parseTransformOrigin = (transformOrigin) => {
50303
+ if (transformOrigin.trim() === "") {
50304
+ return null;
50305
+ }
50306
+ const [x, y] = transformOrigin.split(" ");
50307
+ return { x: parseFloat(x), y: parseFloat(y) };
50308
+ };
50309
+ var getInternalTransformOrigin = (transform) => {
50310
+ const centerX = transform.boundingClientRect.width / 2;
50311
+ const centerY = transform.boundingClientRect.height / 2;
50312
+ const origin = parseTransformOrigin(transform.transformOrigin) ?? {
50313
+ x: centerX,
50314
+ y: centerY
50315
+ };
50316
+ return origin;
50317
+ };
50318
+ var getGlobalTransformOrigin = (transform) => {
50319
+ const { x: originX, y: originY } = getInternalTransformOrigin(transform);
50320
+ return {
50321
+ x: originX + transform.boundingClientRect.left,
50322
+ y: originY + transform.boundingClientRect.top
50323
+ };
50324
+ };
50325
+ var calculateTransforms = (element) => {
50326
+ let parent = element;
50327
+ const transforms = [];
50328
+ const toReset = [];
50329
+ let opacity = 1;
50330
+ let elementComputedStyle = null;
50331
+ while (parent) {
50332
+ const computedStyle = getComputedStyle(parent);
50333
+ const parentOpacity = computedStyle.opacity;
50334
+ if (parentOpacity && parentOpacity !== "") {
50335
+ opacity *= parseFloat(parentOpacity);
50336
+ }
50337
+ if (parent === element) {
50338
+ elementComputedStyle = computedStyle;
50339
+ }
50340
+ if (computedStyle.transform && computedStyle.transform !== "none" || parent === element) {
50341
+ const toParse = computedStyle.transform === "none" || computedStyle.transform === "" ? undefined : computedStyle.transform;
50342
+ const matrix = new DOMMatrix(toParse);
50343
+ const { transform, scale, rotate: rotate2 } = parent.style;
50344
+ const additionalMatrices = [];
50345
+ if (rotate2 !== "") {
50346
+ additionalMatrices.push(new DOMMatrix(`rotate(${rotate2})`));
50347
+ }
50348
+ if (scale !== "") {
50349
+ additionalMatrices.push(new DOMMatrix(`scale(${scale})`));
50350
+ }
50351
+ additionalMatrices.push(matrix);
50352
+ parent.style.transform = "none";
50353
+ parent.style.scale = "none";
50354
+ parent.style.rotate = "none";
50355
+ transforms.push({
50356
+ rect: parent,
50357
+ transformOrigin: computedStyle.transformOrigin,
50358
+ boundingClientRect: null,
50359
+ matrices: additionalMatrices
50360
+ });
50361
+ const parentRef = parent;
50362
+ toReset.push(() => {
50363
+ parentRef.style.transform = transform;
50364
+ parentRef.style.scale = scale;
50365
+ parentRef.style.rotate = rotate2;
50366
+ });
50367
+ }
50368
+ parent = parent.parentElement;
50369
+ }
50370
+ for (const transform of transforms) {
50371
+ transform.boundingClientRect = transform.rect.getBoundingClientRect();
50372
+ }
50373
+ const dimensions = transforms[0].boundingClientRect;
50374
+ const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
50375
+ const totalMatrix = new DOMMatrix;
50376
+ for (const transform of transforms.slice().reverse()) {
50377
+ if (!transform.boundingClientRect) {
50378
+ throw new Error("Bounding client rect not found");
50379
+ }
50380
+ for (const matrix of transform.matrices) {
50381
+ const globalTransformOrigin = getGlobalTransformOrigin(transform);
50382
+ const transformMatrix = new DOMMatrix().translate(globalTransformOrigin.x, globalTransformOrigin.y).multiply(matrix).translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
50383
+ totalMatrix.multiplySelf(transformMatrix);
50384
+ }
50385
+ }
50386
+ if (!elementComputedStyle) {
50387
+ throw new Error("Element computed style not found");
50388
+ }
50389
+ return {
50390
+ dimensions,
50391
+ totalMatrix,
50392
+ reset: () => {
50393
+ for (const reset of toReset) {
50394
+ reset();
50395
+ }
50396
+ },
50397
+ nativeTransformOrigin,
50398
+ opacity,
50399
+ computedStyle: elementComputedStyle
50400
+ };
50401
+ };
50297
50402
  function parseValue({
50298
50403
  value,
50299
50404
  reference
@@ -50428,92 +50533,6 @@ function setBorderRadius({
50428
50533
  ctx.restore();
50429
50534
  };
50430
50535
  }
50431
- var parseTransformOrigin = (transformOrigin) => {
50432
- if (transformOrigin.trim() === "") {
50433
- return null;
50434
- }
50435
- const [x, y] = transformOrigin.split(" ");
50436
- return { x: parseFloat(x), y: parseFloat(y) };
50437
- };
50438
- var getInternalTransformOrigin = (transform) => {
50439
- const centerX = transform.boundingClientRect.width / 2;
50440
- const centerY = transform.boundingClientRect.height / 2;
50441
- const origin = parseTransformOrigin(transform.transformOrigin) ?? {
50442
- x: centerX,
50443
- y: centerY
50444
- };
50445
- return origin;
50446
- };
50447
- var getGlobalTransformOrigin = (transform) => {
50448
- const { x: originX, y: originY } = getInternalTransformOrigin(transform);
50449
- return {
50450
- x: originX + transform.boundingClientRect.left,
50451
- y: originY + transform.boundingClientRect.top
50452
- };
50453
- };
50454
- var calculateTransforms = (element) => {
50455
- let parent = element;
50456
- const transforms = [];
50457
- const toReset = [];
50458
- let opacity = 1;
50459
- let elementComputedStyle = null;
50460
- while (parent) {
50461
- const computedStyle = getComputedStyle(parent);
50462
- const parentOpacity = computedStyle.opacity;
50463
- if (parentOpacity && parentOpacity !== "") {
50464
- opacity *= parseFloat(parentOpacity);
50465
- }
50466
- if (parent === element) {
50467
- elementComputedStyle = computedStyle;
50468
- }
50469
- if (computedStyle.transform && computedStyle.transform !== "none" || parent === element) {
50470
- const toParse = computedStyle.transform === "none" || computedStyle.transform === "" ? undefined : computedStyle.transform;
50471
- const matrix = new DOMMatrix(toParse);
50472
- const { transform } = parent.style;
50473
- parent.style.transform = "none";
50474
- transforms.push({
50475
- matrix,
50476
- rect: parent,
50477
- transformOrigin: computedStyle.transformOrigin,
50478
- boundingClientRect: null
50479
- });
50480
- const parentRef = parent;
50481
- toReset.push(() => {
50482
- parentRef.style.transform = transform;
50483
- });
50484
- }
50485
- parent = parent.parentElement;
50486
- }
50487
- for (const transform of transforms) {
50488
- transform.boundingClientRect = transform.rect.getBoundingClientRect();
50489
- }
50490
- const dimensions = transforms[0].boundingClientRect;
50491
- const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
50492
- const totalMatrix = new DOMMatrix;
50493
- for (const transform of transforms.slice().reverse()) {
50494
- if (!transform.boundingClientRect) {
50495
- throw new Error("Bounding client rect not found");
50496
- }
50497
- const globalTransformOrigin = getGlobalTransformOrigin(transform);
50498
- const transformMatrix = new DOMMatrix().translate(globalTransformOrigin.x, globalTransformOrigin.y).multiply(transform.matrix).translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
50499
- totalMatrix.multiplySelf(transformMatrix);
50500
- }
50501
- if (!elementComputedStyle) {
50502
- throw new Error("Element computed style not found");
50503
- }
50504
- return {
50505
- dimensions,
50506
- totalMatrix,
50507
- reset: () => {
50508
- for (const reset of toReset) {
50509
- reset();
50510
- }
50511
- },
50512
- nativeTransformOrigin,
50513
- opacity,
50514
- computedStyle: elementComputedStyle
50515
- };
50516
- };
50517
50536
  var drawBorder = ({
50518
50537
  ctx,
50519
50538
  x,
@@ -50618,20 +50637,14 @@ var setTransform = ({
50618
50637
  ctx.setTransform(new DOMMatrix);
50619
50638
  };
50620
50639
  };
50621
- var drawElementToCanvas = async ({
50622
- element,
50640
+ var drawElement = async ({
50641
+ dimensions,
50642
+ computedStyle,
50623
50643
  context,
50624
- draw
50644
+ draw,
50645
+ opacity,
50646
+ totalMatrix
50625
50647
  }) => {
50626
- const { totalMatrix, reset, dimensions, opacity, computedStyle } = calculateTransforms(element);
50627
- if (opacity === 0) {
50628
- reset();
50629
- return;
50630
- }
50631
- if (dimensions.width <= 0 || dimensions.height <= 0) {
50632
- reset();
50633
- return;
50634
- }
50635
50648
  const background2 = computedStyle.backgroundColor;
50636
50649
  const borderRadius = parseBorderRadius({
50637
50650
  borderRadius: computedStyle.borderRadius,
@@ -50673,6 +50686,192 @@ var drawElementToCanvas = async ({
50673
50686
  finishOpacity();
50674
50687
  finishBorderRadius();
50675
50688
  finishTransform();
50689
+ };
50690
+ function compileShader(shaderGl, source, type) {
50691
+ const shader = shaderGl.createShader(type);
50692
+ if (!shader) {
50693
+ throw new Error("Could not create shader");
50694
+ }
50695
+ shaderGl.shaderSource(shader, source);
50696
+ shaderGl.compileShader(shader);
50697
+ if (!shaderGl.getShaderParameter(shader, shaderGl.COMPILE_STATUS)) {
50698
+ const log = shaderGl.getShaderInfoLog(shader);
50699
+ shaderGl.deleteShader(shader);
50700
+ throw new Error("Shader compile error: " + log);
50701
+ }
50702
+ return shader;
50703
+ }
50704
+ var transformIn3d = ({
50705
+ canvasWidth,
50706
+ canvasHeight,
50707
+ matrix,
50708
+ sourceCanvas,
50709
+ offsetLeft,
50710
+ offsetTop
50711
+ }) => {
50712
+ const canvas = new OffscreenCanvas(canvasWidth, canvasHeight);
50713
+ const gl = canvas.getContext("webgl");
50714
+ if (!gl) {
50715
+ throw new Error("WebGL not supported");
50716
+ }
50717
+ const vsSource = `
50718
+ attribute vec2 aPosition;
50719
+ attribute vec2 aTexCoord;
50720
+ uniform mat4 uTransform;
50721
+ uniform mat4 uProjection;
50722
+ varying vec2 vTexCoord;
50723
+
50724
+ void main() {
50725
+ gl_Position = uProjection * uTransform * vec4(aPosition, 0.0, 1.0);
50726
+ vTexCoord = aTexCoord;
50727
+ }
50728
+ `;
50729
+ const fsSource = `
50730
+ precision mediump float;
50731
+ uniform sampler2D uTexture;
50732
+ varying vec2 vTexCoord;
50733
+
50734
+ void main() {
50735
+ gl_FragColor = texture2D(uTexture, vTexCoord);
50736
+ }
50737
+ `;
50738
+ const vertexShader = compileShader(gl, vsSource, gl.VERTEX_SHADER);
50739
+ const fragmentShader = compileShader(gl, fsSource, gl.FRAGMENT_SHADER);
50740
+ const program = gl.createProgram();
50741
+ gl.attachShader(program, vertexShader);
50742
+ gl.attachShader(program, fragmentShader);
50743
+ gl.linkProgram(program);
50744
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
50745
+ throw new Error("Program link error: " + gl.getProgramInfoLog(program));
50746
+ }
50747
+ gl.useProgram(program);
50748
+ const vertices = new Float32Array([
50749
+ offsetLeft,
50750
+ offsetTop,
50751
+ 0,
50752
+ 0,
50753
+ canvasWidth + offsetLeft,
50754
+ offsetTop,
50755
+ 1,
50756
+ 0,
50757
+ offsetLeft,
50758
+ canvasHeight + offsetTop,
50759
+ 0,
50760
+ 1,
50761
+ offsetLeft,
50762
+ canvasHeight + offsetTop,
50763
+ 0,
50764
+ 1,
50765
+ canvasWidth + offsetLeft,
50766
+ offsetTop,
50767
+ 1,
50768
+ 0,
50769
+ canvasWidth + offsetLeft,
50770
+ canvasHeight + offsetTop,
50771
+ 1,
50772
+ 1
50773
+ ]);
50774
+ const vertexBuffer = gl.createBuffer();
50775
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
50776
+ gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
50777
+ const aPosition = gl.getAttribLocation(program, "aPosition");
50778
+ const aTexCoord = gl.getAttribLocation(program, "aTexCoord");
50779
+ gl.enableVertexAttribArray(aPosition);
50780
+ gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 4 * 4, 0);
50781
+ gl.enableVertexAttribArray(aTexCoord);
50782
+ gl.vertexAttribPointer(aTexCoord, 2, gl.FLOAT, false, 4 * 4, 2 * 4);
50783
+ const texture = gl.createTexture();
50784
+ gl.bindTexture(gl.TEXTURE_2D, texture);
50785
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
50786
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
50787
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
50788
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
50789
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, sourceCanvas);
50790
+ const transformMatrix = matrix.toFloat32Array();
50791
+ const zScale = 1e9;
50792
+ const projectionMatrix = new Float32Array([
50793
+ 2 / canvasWidth,
50794
+ 0,
50795
+ 0,
50796
+ 0,
50797
+ 0,
50798
+ -2 / canvasHeight,
50799
+ 0,
50800
+ 0,
50801
+ 0,
50802
+ 0,
50803
+ -2 / zScale,
50804
+ 0,
50805
+ -1,
50806
+ 1,
50807
+ 0,
50808
+ 1
50809
+ ]);
50810
+ const uTransform = gl.getUniformLocation(program, "uTransform");
50811
+ const uProjection = gl.getUniformLocation(program, "uProjection");
50812
+ const uTexture = gl.getUniformLocation(program, "uTexture");
50813
+ gl.uniformMatrix4fv(uTransform, false, transformMatrix);
50814
+ gl.uniformMatrix4fv(uProjection, false, projectionMatrix);
50815
+ gl.uniform1i(uTexture, 0);
50816
+ gl.clearColor(0, 0, 0, 0);
50817
+ gl.clear(gl.COLOR_BUFFER_BIT);
50818
+ gl.enable(gl.BLEND);
50819
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
50820
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
50821
+ return canvas;
50822
+ };
50823
+ var drawElementToCanvas = async ({
50824
+ element,
50825
+ context,
50826
+ draw
50827
+ }) => {
50828
+ const { totalMatrix, reset, dimensions, opacity, computedStyle } = calculateTransforms(element);
50829
+ if (opacity === 0) {
50830
+ reset();
50831
+ return;
50832
+ }
50833
+ if (dimensions.width <= 0 || dimensions.height <= 0) {
50834
+ reset();
50835
+ return;
50836
+ }
50837
+ if (!totalMatrix.is2D) {
50838
+ const offsetLeft = Math.min(dimensions.left, 0);
50839
+ const offsetTop = Math.min(dimensions.top, 0);
50840
+ const tempCanvasWidth = Math.max(dimensions.width, dimensions.right);
50841
+ const tempCanvasHeight = Math.max(dimensions.height, dimensions.bottom);
50842
+ const tempCanvas = new OffscreenCanvas(tempCanvasWidth, tempCanvasHeight);
50843
+ const context2 = tempCanvas.getContext("2d");
50844
+ if (!context2) {
50845
+ throw new Error("Could not get context");
50846
+ }
50847
+ const adjustedDimensions = new DOMRect(dimensions.left - offsetLeft, dimensions.top - offsetTop, dimensions.width, dimensions.height);
50848
+ await drawElement({
50849
+ dimensions: adjustedDimensions,
50850
+ computedStyle,
50851
+ context: context2,
50852
+ draw,
50853
+ opacity,
50854
+ totalMatrix: new DOMMatrix
50855
+ });
50856
+ const transformed = transformIn3d({
50857
+ canvasWidth: tempCanvasWidth,
50858
+ canvasHeight: tempCanvasHeight,
50859
+ matrix: totalMatrix,
50860
+ sourceCanvas: tempCanvas,
50861
+ offsetLeft,
50862
+ offsetTop
50863
+ });
50864
+ context.drawImage(transformed, 0, 0);
50865
+ } else {
50866
+ await drawElement({
50867
+ dimensions,
50868
+ computedStyle,
50869
+ context,
50870
+ draw,
50871
+ opacity,
50872
+ totalMatrix
50873
+ });
50874
+ }
50676
50875
  reset();
50677
50876
  };
50678
50877
  var getCollapsedText = (span) => {
@@ -50023,10 +50023,14 @@ var handleArtifacts = () => {
50023
50023
  var TARGET_NUMBER_OF_CHANNELS = 2;
50024
50024
  var TARGET_SAMPLE_RATE = 48000;
50025
50025
  function mixAudio(waves, length) {
50026
- if (waves.length === 1) {
50026
+ if (waves.length === 1 && waves[0].length === length) {
50027
50027
  return waves[0];
50028
50028
  }
50029
50029
  const mixed = new Int16Array(length);
50030
+ if (waves.length === 1) {
50031
+ mixed.set(waves[0].subarray(0, length));
50032
+ return mixed;
50033
+ }
50030
50034
  for (let i = 0;i < length; i++) {
50031
50035
  const sum = waves.reduce((acc, wave2) => {
50032
50036
  return acc + (wave2[i] ?? 0);
@@ -50141,7 +50145,8 @@ async function createScaffold({
50141
50145
  remotion_renderReady: true,
50142
50146
  remotion_delayRenderTimeouts: {},
50143
50147
  remotion_puppeteerTimeout: delayRenderTimeoutInMilliseconds,
50144
- remotion_attempt: 0
50148
+ remotion_attempt: 0,
50149
+ remotion_delayRenderHandles: []
50145
50150
  };
50146
50151
  const timeUpdater = createRef12();
50147
50152
  const collectAssets = createRef12();
@@ -50313,6 +50318,106 @@ var getQualityForWebRendererQuality = (quality) => {
50313
50318
  throw new Error(`Unsupported quality: ${quality}`);
50314
50319
  }
50315
50320
  };
50321
+ var parseTransformOrigin = (transformOrigin) => {
50322
+ if (transformOrigin.trim() === "") {
50323
+ return null;
50324
+ }
50325
+ const [x, y] = transformOrigin.split(" ");
50326
+ return { x: parseFloat(x), y: parseFloat(y) };
50327
+ };
50328
+ var getInternalTransformOrigin = (transform) => {
50329
+ const centerX = transform.boundingClientRect.width / 2;
50330
+ const centerY = transform.boundingClientRect.height / 2;
50331
+ const origin = parseTransformOrigin(transform.transformOrigin) ?? {
50332
+ x: centerX,
50333
+ y: centerY
50334
+ };
50335
+ return origin;
50336
+ };
50337
+ var getGlobalTransformOrigin = (transform) => {
50338
+ const { x: originX, y: originY } = getInternalTransformOrigin(transform);
50339
+ return {
50340
+ x: originX + transform.boundingClientRect.left,
50341
+ y: originY + transform.boundingClientRect.top
50342
+ };
50343
+ };
50344
+ var calculateTransforms = (element) => {
50345
+ let parent = element;
50346
+ const transforms = [];
50347
+ const toReset = [];
50348
+ let opacity = 1;
50349
+ let elementComputedStyle = null;
50350
+ while (parent) {
50351
+ const computedStyle = getComputedStyle(parent);
50352
+ const parentOpacity = computedStyle.opacity;
50353
+ if (parentOpacity && parentOpacity !== "") {
50354
+ opacity *= parseFloat(parentOpacity);
50355
+ }
50356
+ if (parent === element) {
50357
+ elementComputedStyle = computedStyle;
50358
+ }
50359
+ if (computedStyle.transform && computedStyle.transform !== "none" || parent === element) {
50360
+ const toParse = computedStyle.transform === "none" || computedStyle.transform === "" ? undefined : computedStyle.transform;
50361
+ const matrix = new DOMMatrix(toParse);
50362
+ const { transform, scale, rotate: rotate2 } = parent.style;
50363
+ const additionalMatrices = [];
50364
+ if (rotate2 !== "") {
50365
+ additionalMatrices.push(new DOMMatrix(`rotate(${rotate2})`));
50366
+ }
50367
+ if (scale !== "") {
50368
+ additionalMatrices.push(new DOMMatrix(`scale(${scale})`));
50369
+ }
50370
+ additionalMatrices.push(matrix);
50371
+ parent.style.transform = "none";
50372
+ parent.style.scale = "none";
50373
+ parent.style.rotate = "none";
50374
+ transforms.push({
50375
+ rect: parent,
50376
+ transformOrigin: computedStyle.transformOrigin,
50377
+ boundingClientRect: null,
50378
+ matrices: additionalMatrices
50379
+ });
50380
+ const parentRef = parent;
50381
+ toReset.push(() => {
50382
+ parentRef.style.transform = transform;
50383
+ parentRef.style.scale = scale;
50384
+ parentRef.style.rotate = rotate2;
50385
+ });
50386
+ }
50387
+ parent = parent.parentElement;
50388
+ }
50389
+ for (const transform of transforms) {
50390
+ transform.boundingClientRect = transform.rect.getBoundingClientRect();
50391
+ }
50392
+ const dimensions = transforms[0].boundingClientRect;
50393
+ const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
50394
+ const totalMatrix = new DOMMatrix;
50395
+ for (const transform of transforms.slice().reverse()) {
50396
+ if (!transform.boundingClientRect) {
50397
+ throw new Error("Bounding client rect not found");
50398
+ }
50399
+ for (const matrix of transform.matrices) {
50400
+ const globalTransformOrigin = getGlobalTransformOrigin(transform);
50401
+ const transformMatrix = new DOMMatrix().translate(globalTransformOrigin.x, globalTransformOrigin.y).multiply(matrix).translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
50402
+ totalMatrix.multiplySelf(transformMatrix);
50403
+ }
50404
+ }
50405
+ if (!elementComputedStyle) {
50406
+ throw new Error("Element computed style not found");
50407
+ }
50408
+ return {
50409
+ dimensions,
50410
+ totalMatrix,
50411
+ reset: () => {
50412
+ for (const reset of toReset) {
50413
+ reset();
50414
+ }
50415
+ },
50416
+ nativeTransformOrigin,
50417
+ opacity,
50418
+ computedStyle: elementComputedStyle
50419
+ };
50420
+ };
50316
50421
  function parseValue({
50317
50422
  value,
50318
50423
  reference
@@ -50447,92 +50552,6 @@ function setBorderRadius({
50447
50552
  ctx.restore();
50448
50553
  };
50449
50554
  }
50450
- var parseTransformOrigin = (transformOrigin) => {
50451
- if (transformOrigin.trim() === "") {
50452
- return null;
50453
- }
50454
- const [x, y] = transformOrigin.split(" ");
50455
- return { x: parseFloat(x), y: parseFloat(y) };
50456
- };
50457
- var getInternalTransformOrigin = (transform) => {
50458
- const centerX = transform.boundingClientRect.width / 2;
50459
- const centerY = transform.boundingClientRect.height / 2;
50460
- const origin = parseTransformOrigin(transform.transformOrigin) ?? {
50461
- x: centerX,
50462
- y: centerY
50463
- };
50464
- return origin;
50465
- };
50466
- var getGlobalTransformOrigin = (transform) => {
50467
- const { x: originX, y: originY } = getInternalTransformOrigin(transform);
50468
- return {
50469
- x: originX + transform.boundingClientRect.left,
50470
- y: originY + transform.boundingClientRect.top
50471
- };
50472
- };
50473
- var calculateTransforms = (element) => {
50474
- let parent = element;
50475
- const transforms = [];
50476
- const toReset = [];
50477
- let opacity = 1;
50478
- let elementComputedStyle = null;
50479
- while (parent) {
50480
- const computedStyle = getComputedStyle(parent);
50481
- const parentOpacity = computedStyle.opacity;
50482
- if (parentOpacity && parentOpacity !== "") {
50483
- opacity *= parseFloat(parentOpacity);
50484
- }
50485
- if (parent === element) {
50486
- elementComputedStyle = computedStyle;
50487
- }
50488
- if (computedStyle.transform && computedStyle.transform !== "none" || parent === element) {
50489
- const toParse = computedStyle.transform === "none" || computedStyle.transform === "" ? undefined : computedStyle.transform;
50490
- const matrix = new DOMMatrix(toParse);
50491
- const { transform } = parent.style;
50492
- parent.style.transform = "none";
50493
- transforms.push({
50494
- matrix,
50495
- rect: parent,
50496
- transformOrigin: computedStyle.transformOrigin,
50497
- boundingClientRect: null
50498
- });
50499
- const parentRef = parent;
50500
- toReset.push(() => {
50501
- parentRef.style.transform = transform;
50502
- });
50503
- }
50504
- parent = parent.parentElement;
50505
- }
50506
- for (const transform of transforms) {
50507
- transform.boundingClientRect = transform.rect.getBoundingClientRect();
50508
- }
50509
- const dimensions = transforms[0].boundingClientRect;
50510
- const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
50511
- const totalMatrix = new DOMMatrix;
50512
- for (const transform of transforms.slice().reverse()) {
50513
- if (!transform.boundingClientRect) {
50514
- throw new Error("Bounding client rect not found");
50515
- }
50516
- const globalTransformOrigin = getGlobalTransformOrigin(transform);
50517
- const transformMatrix = new DOMMatrix().translate(globalTransformOrigin.x, globalTransformOrigin.y).multiply(transform.matrix).translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
50518
- totalMatrix.multiplySelf(transformMatrix);
50519
- }
50520
- if (!elementComputedStyle) {
50521
- throw new Error("Element computed style not found");
50522
- }
50523
- return {
50524
- dimensions,
50525
- totalMatrix,
50526
- reset: () => {
50527
- for (const reset of toReset) {
50528
- reset();
50529
- }
50530
- },
50531
- nativeTransformOrigin,
50532
- opacity,
50533
- computedStyle: elementComputedStyle
50534
- };
50535
- };
50536
50555
  var drawBorder = ({
50537
50556
  ctx,
50538
50557
  x,
@@ -50637,20 +50656,14 @@ var setTransform = ({
50637
50656
  ctx.setTransform(new DOMMatrix);
50638
50657
  };
50639
50658
  };
50640
- var drawElementToCanvas = async ({
50641
- element,
50659
+ var drawElement = async ({
50660
+ dimensions,
50661
+ computedStyle,
50642
50662
  context,
50643
- draw
50663
+ draw,
50664
+ opacity,
50665
+ totalMatrix
50644
50666
  }) => {
50645
- const { totalMatrix, reset, dimensions, opacity, computedStyle } = calculateTransforms(element);
50646
- if (opacity === 0) {
50647
- reset();
50648
- return;
50649
- }
50650
- if (dimensions.width <= 0 || dimensions.height <= 0) {
50651
- reset();
50652
- return;
50653
- }
50654
50667
  const background2 = computedStyle.backgroundColor;
50655
50668
  const borderRadius = parseBorderRadius({
50656
50669
  borderRadius: computedStyle.borderRadius,
@@ -50692,6 +50705,192 @@ var drawElementToCanvas = async ({
50692
50705
  finishOpacity();
50693
50706
  finishBorderRadius();
50694
50707
  finishTransform();
50708
+ };
50709
+ function compileShader(shaderGl, source, type) {
50710
+ const shader = shaderGl.createShader(type);
50711
+ if (!shader) {
50712
+ throw new Error("Could not create shader");
50713
+ }
50714
+ shaderGl.shaderSource(shader, source);
50715
+ shaderGl.compileShader(shader);
50716
+ if (!shaderGl.getShaderParameter(shader, shaderGl.COMPILE_STATUS)) {
50717
+ const log = shaderGl.getShaderInfoLog(shader);
50718
+ shaderGl.deleteShader(shader);
50719
+ throw new Error("Shader compile error: " + log);
50720
+ }
50721
+ return shader;
50722
+ }
50723
+ var transformIn3d = ({
50724
+ canvasWidth,
50725
+ canvasHeight,
50726
+ matrix,
50727
+ sourceCanvas,
50728
+ offsetLeft,
50729
+ offsetTop
50730
+ }) => {
50731
+ const canvas = new OffscreenCanvas(canvasWidth, canvasHeight);
50732
+ const gl = canvas.getContext("webgl");
50733
+ if (!gl) {
50734
+ throw new Error("WebGL not supported");
50735
+ }
50736
+ const vsSource = `
50737
+ attribute vec2 aPosition;
50738
+ attribute vec2 aTexCoord;
50739
+ uniform mat4 uTransform;
50740
+ uniform mat4 uProjection;
50741
+ varying vec2 vTexCoord;
50742
+
50743
+ void main() {
50744
+ gl_Position = uProjection * uTransform * vec4(aPosition, 0.0, 1.0);
50745
+ vTexCoord = aTexCoord;
50746
+ }
50747
+ `;
50748
+ const fsSource = `
50749
+ precision mediump float;
50750
+ uniform sampler2D uTexture;
50751
+ varying vec2 vTexCoord;
50752
+
50753
+ void main() {
50754
+ gl_FragColor = texture2D(uTexture, vTexCoord);
50755
+ }
50756
+ `;
50757
+ const vertexShader = compileShader(gl, vsSource, gl.VERTEX_SHADER);
50758
+ const fragmentShader = compileShader(gl, fsSource, gl.FRAGMENT_SHADER);
50759
+ const program = gl.createProgram();
50760
+ gl.attachShader(program, vertexShader);
50761
+ gl.attachShader(program, fragmentShader);
50762
+ gl.linkProgram(program);
50763
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
50764
+ throw new Error("Program link error: " + gl.getProgramInfoLog(program));
50765
+ }
50766
+ gl.useProgram(program);
50767
+ const vertices = new Float32Array([
50768
+ offsetLeft,
50769
+ offsetTop,
50770
+ 0,
50771
+ 0,
50772
+ canvasWidth + offsetLeft,
50773
+ offsetTop,
50774
+ 1,
50775
+ 0,
50776
+ offsetLeft,
50777
+ canvasHeight + offsetTop,
50778
+ 0,
50779
+ 1,
50780
+ offsetLeft,
50781
+ canvasHeight + offsetTop,
50782
+ 0,
50783
+ 1,
50784
+ canvasWidth + offsetLeft,
50785
+ offsetTop,
50786
+ 1,
50787
+ 0,
50788
+ canvasWidth + offsetLeft,
50789
+ canvasHeight + offsetTop,
50790
+ 1,
50791
+ 1
50792
+ ]);
50793
+ const vertexBuffer = gl.createBuffer();
50794
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
50795
+ gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
50796
+ const aPosition = gl.getAttribLocation(program, "aPosition");
50797
+ const aTexCoord = gl.getAttribLocation(program, "aTexCoord");
50798
+ gl.enableVertexAttribArray(aPosition);
50799
+ gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 4 * 4, 0);
50800
+ gl.enableVertexAttribArray(aTexCoord);
50801
+ gl.vertexAttribPointer(aTexCoord, 2, gl.FLOAT, false, 4 * 4, 2 * 4);
50802
+ const texture = gl.createTexture();
50803
+ gl.bindTexture(gl.TEXTURE_2D, texture);
50804
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
50805
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
50806
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
50807
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
50808
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, sourceCanvas);
50809
+ const transformMatrix = matrix.toFloat32Array();
50810
+ const zScale = 1e9;
50811
+ const projectionMatrix = new Float32Array([
50812
+ 2 / canvasWidth,
50813
+ 0,
50814
+ 0,
50815
+ 0,
50816
+ 0,
50817
+ -2 / canvasHeight,
50818
+ 0,
50819
+ 0,
50820
+ 0,
50821
+ 0,
50822
+ -2 / zScale,
50823
+ 0,
50824
+ -1,
50825
+ 1,
50826
+ 0,
50827
+ 1
50828
+ ]);
50829
+ const uTransform = gl.getUniformLocation(program, "uTransform");
50830
+ const uProjection = gl.getUniformLocation(program, "uProjection");
50831
+ const uTexture = gl.getUniformLocation(program, "uTexture");
50832
+ gl.uniformMatrix4fv(uTransform, false, transformMatrix);
50833
+ gl.uniformMatrix4fv(uProjection, false, projectionMatrix);
50834
+ gl.uniform1i(uTexture, 0);
50835
+ gl.clearColor(0, 0, 0, 0);
50836
+ gl.clear(gl.COLOR_BUFFER_BIT);
50837
+ gl.enable(gl.BLEND);
50838
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
50839
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
50840
+ return canvas;
50841
+ };
50842
+ var drawElementToCanvas = async ({
50843
+ element,
50844
+ context,
50845
+ draw
50846
+ }) => {
50847
+ const { totalMatrix, reset, dimensions, opacity, computedStyle } = calculateTransforms(element);
50848
+ if (opacity === 0) {
50849
+ reset();
50850
+ return;
50851
+ }
50852
+ if (dimensions.width <= 0 || dimensions.height <= 0) {
50853
+ reset();
50854
+ return;
50855
+ }
50856
+ if (!totalMatrix.is2D) {
50857
+ const offsetLeft = Math.min(dimensions.left, 0);
50858
+ const offsetTop = Math.min(dimensions.top, 0);
50859
+ const tempCanvasWidth = Math.max(dimensions.width, dimensions.right);
50860
+ const tempCanvasHeight = Math.max(dimensions.height, dimensions.bottom);
50861
+ const tempCanvas = new OffscreenCanvas(tempCanvasWidth, tempCanvasHeight);
50862
+ const context2 = tempCanvas.getContext("2d");
50863
+ if (!context2) {
50864
+ throw new Error("Could not get context");
50865
+ }
50866
+ const adjustedDimensions = new DOMRect(dimensions.left - offsetLeft, dimensions.top - offsetTop, dimensions.width, dimensions.height);
50867
+ await drawElement({
50868
+ dimensions: adjustedDimensions,
50869
+ computedStyle,
50870
+ context: context2,
50871
+ draw,
50872
+ opacity,
50873
+ totalMatrix: new DOMMatrix
50874
+ });
50875
+ const transformed = transformIn3d({
50876
+ canvasWidth: tempCanvasWidth,
50877
+ canvasHeight: tempCanvasHeight,
50878
+ matrix: totalMatrix,
50879
+ sourceCanvas: tempCanvas,
50880
+ offsetLeft,
50881
+ offsetTop
50882
+ });
50883
+ context.drawImage(transformed, 0, 0);
50884
+ } else {
50885
+ await drawElement({
50886
+ dimensions,
50887
+ computedStyle,
50888
+ context,
50889
+ draw,
50890
+ opacity,
50891
+ totalMatrix
50892
+ });
50893
+ }
50695
50894
  reset();
50696
50895
  };
50697
50896
  var getCollapsedText = (span) => {
@@ -50303,10 +50303,14 @@ var handleArtifacts = () => {
50303
50303
  var TARGET_NUMBER_OF_CHANNELS = 2;
50304
50304
  var TARGET_SAMPLE_RATE = 48000;
50305
50305
  function mixAudio(waves, length) {
50306
- if (waves.length === 1) {
50306
+ if (waves.length === 1 && waves[0].length === length) {
50307
50307
  return waves[0];
50308
50308
  }
50309
50309
  const mixed = new Int16Array(length);
50310
+ if (waves.length === 1) {
50311
+ mixed.set(waves[0].subarray(0, length));
50312
+ return mixed;
50313
+ }
50310
50314
  for (let i = 0;i < length; i++) {
50311
50315
  const sum = waves.reduce((acc, wave2) => {
50312
50316
  return acc + (wave2[i] ?? 0);
@@ -50421,7 +50425,8 @@ async function createScaffold({
50421
50425
  remotion_renderReady: true,
50422
50426
  remotion_delayRenderTimeouts: {},
50423
50427
  remotion_puppeteerTimeout: delayRenderTimeoutInMilliseconds,
50424
- remotion_attempt: 0
50428
+ remotion_attempt: 0,
50429
+ remotion_delayRenderHandles: []
50425
50430
  };
50426
50431
  const timeUpdater = createRef13();
50427
50432
  const collectAssets = createRef13();
@@ -50593,6 +50598,106 @@ var getQualityForWebRendererQuality = (quality) => {
50593
50598
  throw new Error(`Unsupported quality: ${quality}`);
50594
50599
  }
50595
50600
  };
50601
+ var parseTransformOrigin = (transformOrigin) => {
50602
+ if (transformOrigin.trim() === "") {
50603
+ return null;
50604
+ }
50605
+ const [x, y] = transformOrigin.split(" ");
50606
+ return { x: parseFloat(x), y: parseFloat(y) };
50607
+ };
50608
+ var getInternalTransformOrigin = (transform) => {
50609
+ const centerX = transform.boundingClientRect.width / 2;
50610
+ const centerY = transform.boundingClientRect.height / 2;
50611
+ const origin = parseTransformOrigin(transform.transformOrigin) ?? {
50612
+ x: centerX,
50613
+ y: centerY
50614
+ };
50615
+ return origin;
50616
+ };
50617
+ var getGlobalTransformOrigin = (transform) => {
50618
+ const { x: originX, y: originY } = getInternalTransformOrigin(transform);
50619
+ return {
50620
+ x: originX + transform.boundingClientRect.left,
50621
+ y: originY + transform.boundingClientRect.top
50622
+ };
50623
+ };
50624
+ var calculateTransforms = (element) => {
50625
+ let parent = element;
50626
+ const transforms = [];
50627
+ const toReset = [];
50628
+ let opacity = 1;
50629
+ let elementComputedStyle = null;
50630
+ while (parent) {
50631
+ const computedStyle = getComputedStyle(parent);
50632
+ const parentOpacity = computedStyle.opacity;
50633
+ if (parentOpacity && parentOpacity !== "") {
50634
+ opacity *= parseFloat(parentOpacity);
50635
+ }
50636
+ if (parent === element) {
50637
+ elementComputedStyle = computedStyle;
50638
+ }
50639
+ if (computedStyle.transform && computedStyle.transform !== "none" || parent === element) {
50640
+ const toParse = computedStyle.transform === "none" || computedStyle.transform === "" ? undefined : computedStyle.transform;
50641
+ const matrix = new DOMMatrix(toParse);
50642
+ const { transform, scale, rotate: rotate2 } = parent.style;
50643
+ const additionalMatrices = [];
50644
+ if (rotate2 !== "") {
50645
+ additionalMatrices.push(new DOMMatrix(`rotate(${rotate2})`));
50646
+ }
50647
+ if (scale !== "") {
50648
+ additionalMatrices.push(new DOMMatrix(`scale(${scale})`));
50649
+ }
50650
+ additionalMatrices.push(matrix);
50651
+ parent.style.transform = "none";
50652
+ parent.style.scale = "none";
50653
+ parent.style.rotate = "none";
50654
+ transforms.push({
50655
+ rect: parent,
50656
+ transformOrigin: computedStyle.transformOrigin,
50657
+ boundingClientRect: null,
50658
+ matrices: additionalMatrices
50659
+ });
50660
+ const parentRef = parent;
50661
+ toReset.push(() => {
50662
+ parentRef.style.transform = transform;
50663
+ parentRef.style.scale = scale;
50664
+ parentRef.style.rotate = rotate2;
50665
+ });
50666
+ }
50667
+ parent = parent.parentElement;
50668
+ }
50669
+ for (const transform of transforms) {
50670
+ transform.boundingClientRect = transform.rect.getBoundingClientRect();
50671
+ }
50672
+ const dimensions = transforms[0].boundingClientRect;
50673
+ const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
50674
+ const totalMatrix = new DOMMatrix;
50675
+ for (const transform of transforms.slice().reverse()) {
50676
+ if (!transform.boundingClientRect) {
50677
+ throw new Error("Bounding client rect not found");
50678
+ }
50679
+ for (const matrix of transform.matrices) {
50680
+ const globalTransformOrigin = getGlobalTransformOrigin(transform);
50681
+ const transformMatrix = new DOMMatrix().translate(globalTransformOrigin.x, globalTransformOrigin.y).multiply(matrix).translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
50682
+ totalMatrix.multiplySelf(transformMatrix);
50683
+ }
50684
+ }
50685
+ if (!elementComputedStyle) {
50686
+ throw new Error("Element computed style not found");
50687
+ }
50688
+ return {
50689
+ dimensions,
50690
+ totalMatrix,
50691
+ reset: () => {
50692
+ for (const reset of toReset) {
50693
+ reset();
50694
+ }
50695
+ },
50696
+ nativeTransformOrigin,
50697
+ opacity,
50698
+ computedStyle: elementComputedStyle
50699
+ };
50700
+ };
50596
50701
  function parseValue({
50597
50702
  value,
50598
50703
  reference
@@ -50727,92 +50832,6 @@ function setBorderRadius({
50727
50832
  ctx.restore();
50728
50833
  };
50729
50834
  }
50730
- var parseTransformOrigin = (transformOrigin) => {
50731
- if (transformOrigin.trim() === "") {
50732
- return null;
50733
- }
50734
- const [x, y] = transformOrigin.split(" ");
50735
- return { x: parseFloat(x), y: parseFloat(y) };
50736
- };
50737
- var getInternalTransformOrigin = (transform) => {
50738
- const centerX = transform.boundingClientRect.width / 2;
50739
- const centerY = transform.boundingClientRect.height / 2;
50740
- const origin = parseTransformOrigin(transform.transformOrigin) ?? {
50741
- x: centerX,
50742
- y: centerY
50743
- };
50744
- return origin;
50745
- };
50746
- var getGlobalTransformOrigin = (transform) => {
50747
- const { x: originX, y: originY } = getInternalTransformOrigin(transform);
50748
- return {
50749
- x: originX + transform.boundingClientRect.left,
50750
- y: originY + transform.boundingClientRect.top
50751
- };
50752
- };
50753
- var calculateTransforms = (element) => {
50754
- let parent = element;
50755
- const transforms = [];
50756
- const toReset = [];
50757
- let opacity = 1;
50758
- let elementComputedStyle = null;
50759
- while (parent) {
50760
- const computedStyle = getComputedStyle(parent);
50761
- const parentOpacity = computedStyle.opacity;
50762
- if (parentOpacity && parentOpacity !== "") {
50763
- opacity *= parseFloat(parentOpacity);
50764
- }
50765
- if (parent === element) {
50766
- elementComputedStyle = computedStyle;
50767
- }
50768
- if (computedStyle.transform && computedStyle.transform !== "none" || parent === element) {
50769
- const toParse = computedStyle.transform === "none" || computedStyle.transform === "" ? undefined : computedStyle.transform;
50770
- const matrix = new DOMMatrix(toParse);
50771
- const { transform } = parent.style;
50772
- parent.style.transform = "none";
50773
- transforms.push({
50774
- matrix,
50775
- rect: parent,
50776
- transformOrigin: computedStyle.transformOrigin,
50777
- boundingClientRect: null
50778
- });
50779
- const parentRef = parent;
50780
- toReset.push(() => {
50781
- parentRef.style.transform = transform;
50782
- });
50783
- }
50784
- parent = parent.parentElement;
50785
- }
50786
- for (const transform of transforms) {
50787
- transform.boundingClientRect = transform.rect.getBoundingClientRect();
50788
- }
50789
- const dimensions = transforms[0].boundingClientRect;
50790
- const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
50791
- const totalMatrix = new DOMMatrix;
50792
- for (const transform of transforms.slice().reverse()) {
50793
- if (!transform.boundingClientRect) {
50794
- throw new Error("Bounding client rect not found");
50795
- }
50796
- const globalTransformOrigin = getGlobalTransformOrigin(transform);
50797
- const transformMatrix = new DOMMatrix().translate(globalTransformOrigin.x, globalTransformOrigin.y).multiply(transform.matrix).translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
50798
- totalMatrix.multiplySelf(transformMatrix);
50799
- }
50800
- if (!elementComputedStyle) {
50801
- throw new Error("Element computed style not found");
50802
- }
50803
- return {
50804
- dimensions,
50805
- totalMatrix,
50806
- reset: () => {
50807
- for (const reset of toReset) {
50808
- reset();
50809
- }
50810
- },
50811
- nativeTransformOrigin,
50812
- opacity,
50813
- computedStyle: elementComputedStyle
50814
- };
50815
- };
50816
50835
  var drawBorder = ({
50817
50836
  ctx,
50818
50837
  x,
@@ -50917,20 +50936,14 @@ var setTransform = ({
50917
50936
  ctx.setTransform(new DOMMatrix);
50918
50937
  };
50919
50938
  };
50920
- var drawElementToCanvas = async ({
50921
- element,
50939
+ var drawElement = async ({
50940
+ dimensions,
50941
+ computedStyle,
50922
50942
  context,
50923
- draw
50943
+ draw,
50944
+ opacity,
50945
+ totalMatrix
50924
50946
  }) => {
50925
- const { totalMatrix, reset, dimensions, opacity, computedStyle } = calculateTransforms(element);
50926
- if (opacity === 0) {
50927
- reset();
50928
- return;
50929
- }
50930
- if (dimensions.width <= 0 || dimensions.height <= 0) {
50931
- reset();
50932
- return;
50933
- }
50934
50947
  const background2 = computedStyle.backgroundColor;
50935
50948
  const borderRadius = parseBorderRadius({
50936
50949
  borderRadius: computedStyle.borderRadius,
@@ -50972,6 +50985,192 @@ var drawElementToCanvas = async ({
50972
50985
  finishOpacity();
50973
50986
  finishBorderRadius();
50974
50987
  finishTransform();
50988
+ };
50989
+ function compileShader(shaderGl, source, type) {
50990
+ const shader = shaderGl.createShader(type);
50991
+ if (!shader) {
50992
+ throw new Error("Could not create shader");
50993
+ }
50994
+ shaderGl.shaderSource(shader, source);
50995
+ shaderGl.compileShader(shader);
50996
+ if (!shaderGl.getShaderParameter(shader, shaderGl.COMPILE_STATUS)) {
50997
+ const log = shaderGl.getShaderInfoLog(shader);
50998
+ shaderGl.deleteShader(shader);
50999
+ throw new Error("Shader compile error: " + log);
51000
+ }
51001
+ return shader;
51002
+ }
51003
+ var transformIn3d = ({
51004
+ canvasWidth,
51005
+ canvasHeight,
51006
+ matrix,
51007
+ sourceCanvas,
51008
+ offsetLeft,
51009
+ offsetTop
51010
+ }) => {
51011
+ const canvas = new OffscreenCanvas(canvasWidth, canvasHeight);
51012
+ const gl = canvas.getContext("webgl");
51013
+ if (!gl) {
51014
+ throw new Error("WebGL not supported");
51015
+ }
51016
+ const vsSource = `
51017
+ attribute vec2 aPosition;
51018
+ attribute vec2 aTexCoord;
51019
+ uniform mat4 uTransform;
51020
+ uniform mat4 uProjection;
51021
+ varying vec2 vTexCoord;
51022
+
51023
+ void main() {
51024
+ gl_Position = uProjection * uTransform * vec4(aPosition, 0.0, 1.0);
51025
+ vTexCoord = aTexCoord;
51026
+ }
51027
+ `;
51028
+ const fsSource = `
51029
+ precision mediump float;
51030
+ uniform sampler2D uTexture;
51031
+ varying vec2 vTexCoord;
51032
+
51033
+ void main() {
51034
+ gl_FragColor = texture2D(uTexture, vTexCoord);
51035
+ }
51036
+ `;
51037
+ const vertexShader = compileShader(gl, vsSource, gl.VERTEX_SHADER);
51038
+ const fragmentShader = compileShader(gl, fsSource, gl.FRAGMENT_SHADER);
51039
+ const program = gl.createProgram();
51040
+ gl.attachShader(program, vertexShader);
51041
+ gl.attachShader(program, fragmentShader);
51042
+ gl.linkProgram(program);
51043
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
51044
+ throw new Error("Program link error: " + gl.getProgramInfoLog(program));
51045
+ }
51046
+ gl.useProgram(program);
51047
+ const vertices = new Float32Array([
51048
+ offsetLeft,
51049
+ offsetTop,
51050
+ 0,
51051
+ 0,
51052
+ canvasWidth + offsetLeft,
51053
+ offsetTop,
51054
+ 1,
51055
+ 0,
51056
+ offsetLeft,
51057
+ canvasHeight + offsetTop,
51058
+ 0,
51059
+ 1,
51060
+ offsetLeft,
51061
+ canvasHeight + offsetTop,
51062
+ 0,
51063
+ 1,
51064
+ canvasWidth + offsetLeft,
51065
+ offsetTop,
51066
+ 1,
51067
+ 0,
51068
+ canvasWidth + offsetLeft,
51069
+ canvasHeight + offsetTop,
51070
+ 1,
51071
+ 1
51072
+ ]);
51073
+ const vertexBuffer = gl.createBuffer();
51074
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
51075
+ gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
51076
+ const aPosition = gl.getAttribLocation(program, "aPosition");
51077
+ const aTexCoord = gl.getAttribLocation(program, "aTexCoord");
51078
+ gl.enableVertexAttribArray(aPosition);
51079
+ gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 4 * 4, 0);
51080
+ gl.enableVertexAttribArray(aTexCoord);
51081
+ gl.vertexAttribPointer(aTexCoord, 2, gl.FLOAT, false, 4 * 4, 2 * 4);
51082
+ const texture = gl.createTexture();
51083
+ gl.bindTexture(gl.TEXTURE_2D, texture);
51084
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
51085
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
51086
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
51087
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
51088
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, sourceCanvas);
51089
+ const transformMatrix = matrix.toFloat32Array();
51090
+ const zScale = 1e9;
51091
+ const projectionMatrix = new Float32Array([
51092
+ 2 / canvasWidth,
51093
+ 0,
51094
+ 0,
51095
+ 0,
51096
+ 0,
51097
+ -2 / canvasHeight,
51098
+ 0,
51099
+ 0,
51100
+ 0,
51101
+ 0,
51102
+ -2 / zScale,
51103
+ 0,
51104
+ -1,
51105
+ 1,
51106
+ 0,
51107
+ 1
51108
+ ]);
51109
+ const uTransform = gl.getUniformLocation(program, "uTransform");
51110
+ const uProjection = gl.getUniformLocation(program, "uProjection");
51111
+ const uTexture = gl.getUniformLocation(program, "uTexture");
51112
+ gl.uniformMatrix4fv(uTransform, false, transformMatrix);
51113
+ gl.uniformMatrix4fv(uProjection, false, projectionMatrix);
51114
+ gl.uniform1i(uTexture, 0);
51115
+ gl.clearColor(0, 0, 0, 0);
51116
+ gl.clear(gl.COLOR_BUFFER_BIT);
51117
+ gl.enable(gl.BLEND);
51118
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
51119
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
51120
+ return canvas;
51121
+ };
51122
+ var drawElementToCanvas = async ({
51123
+ element,
51124
+ context,
51125
+ draw
51126
+ }) => {
51127
+ const { totalMatrix, reset, dimensions, opacity, computedStyle } = calculateTransforms(element);
51128
+ if (opacity === 0) {
51129
+ reset();
51130
+ return;
51131
+ }
51132
+ if (dimensions.width <= 0 || dimensions.height <= 0) {
51133
+ reset();
51134
+ return;
51135
+ }
51136
+ if (!totalMatrix.is2D) {
51137
+ const offsetLeft = Math.min(dimensions.left, 0);
51138
+ const offsetTop = Math.min(dimensions.top, 0);
51139
+ const tempCanvasWidth = Math.max(dimensions.width, dimensions.right);
51140
+ const tempCanvasHeight = Math.max(dimensions.height, dimensions.bottom);
51141
+ const tempCanvas = new OffscreenCanvas(tempCanvasWidth, tempCanvasHeight);
51142
+ const context2 = tempCanvas.getContext("2d");
51143
+ if (!context2) {
51144
+ throw new Error("Could not get context");
51145
+ }
51146
+ const adjustedDimensions = new DOMRect(dimensions.left - offsetLeft, dimensions.top - offsetTop, dimensions.width, dimensions.height);
51147
+ await drawElement({
51148
+ dimensions: adjustedDimensions,
51149
+ computedStyle,
51150
+ context: context2,
51151
+ draw,
51152
+ opacity,
51153
+ totalMatrix: new DOMMatrix
51154
+ });
51155
+ const transformed = transformIn3d({
51156
+ canvasWidth: tempCanvasWidth,
51157
+ canvasHeight: tempCanvasHeight,
51158
+ matrix: totalMatrix,
51159
+ sourceCanvas: tempCanvas,
51160
+ offsetLeft,
51161
+ offsetTop
51162
+ });
51163
+ context.drawImage(transformed, 0, 0);
51164
+ } else {
51165
+ await drawElement({
51166
+ dimensions,
51167
+ computedStyle,
51168
+ context,
51169
+ draw,
51170
+ opacity,
51171
+ totalMatrix
51172
+ });
51173
+ }
50975
51174
  reset();
50976
51175
  };
50977
51176
  var getCollapsedText = (span) => {
@@ -206,7 +206,7 @@ var renderContent = (Root) => {
206
206
  renderToDOM(/* @__PURE__ */ jsx("div", {
207
207
  children: /* @__PURE__ */ jsx(DelayedSpinner, {})
208
208
  }));
209
- import("./chunk-w9aq75yh.js").then(({ StudioInternals }) => {
209
+ import("./chunk-02cyqxg9.js").then(({ StudioInternals }) => {
210
210
  window.remotion_isStudio = true;
211
211
  window.remotion_isReadOnlyStudio = true;
212
212
  window.remotion_inputProps = "{}";
package/package.json CHANGED
@@ -3,13 +3,13 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio"
4
4
  },
5
5
  "name": "@remotion/studio",
6
- "version": "4.0.390",
6
+ "version": "4.0.392",
7
7
  "description": "APIs for interacting with the Remotion Studio",
8
8
  "main": "dist",
9
9
  "sideEffects": false,
10
10
  "scripts": {
11
11
  "lint": "eslint src",
12
- "make": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && tsc -d && bun --env-file=../.env.bundle bundle.ts",
12
+ "make": "tsc -d && bun --env-file=../.env.bundle bundle.ts",
13
13
  "test": "bun test src",
14
14
  "formatting": "prettier --experimental-cli src --check"
15
15
  },
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "semver": "7.5.3",
28
- "remotion": "4.0.390",
29
- "@remotion/player": "4.0.390",
30
- "@remotion/media-utils": "4.0.390",
31
- "@remotion/renderer": "4.0.390",
32
- "@remotion/web-renderer": "4.0.390",
33
- "@remotion/studio-shared": "4.0.390",
34
- "@remotion/zod-types": "4.0.390",
28
+ "remotion": "4.0.392",
29
+ "@remotion/player": "4.0.392",
30
+ "@remotion/media-utils": "4.0.392",
31
+ "@remotion/renderer": "4.0.392",
32
+ "@remotion/web-renderer": "4.0.392",
33
+ "@remotion/studio-shared": "4.0.392",
34
+ "@remotion/zod-types": "4.0.392",
35
35
  "mediabunny": "1.25.8",
36
36
  "memfs": "3.4.3",
37
37
  "source-map": "0.7.3",
@@ -42,7 +42,7 @@
42
42
  "react": "19.2.3",
43
43
  "react-dom": "19.2.3",
44
44
  "@types/semver": "^7.3.4",
45
- "@remotion/eslint-config-internal": "4.0.390",
45
+ "@remotion/eslint-config-internal": "4.0.392",
46
46
  "eslint": "9.19.0"
47
47
  },
48
48
  "publishConfig": {