@remotion/studio 4.0.391 → 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.
@@ -50299,6 +50299,106 @@ var getQualityForWebRendererQuality = (quality) => {
50299
50299
  throw new Error(`Unsupported quality: ${quality}`);
50300
50300
  }
50301
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
+ };
50302
50402
  function parseValue({
50303
50403
  value,
50304
50404
  reference
@@ -50433,92 +50533,6 @@ function setBorderRadius({
50433
50533
  ctx.restore();
50434
50534
  };
50435
50535
  }
50436
- var parseTransformOrigin = (transformOrigin) => {
50437
- if (transformOrigin.trim() === "") {
50438
- return null;
50439
- }
50440
- const [x, y] = transformOrigin.split(" ");
50441
- return { x: parseFloat(x), y: parseFloat(y) };
50442
- };
50443
- var getInternalTransformOrigin = (transform) => {
50444
- const centerX = transform.boundingClientRect.width / 2;
50445
- const centerY = transform.boundingClientRect.height / 2;
50446
- const origin = parseTransformOrigin(transform.transformOrigin) ?? {
50447
- x: centerX,
50448
- y: centerY
50449
- };
50450
- return origin;
50451
- };
50452
- var getGlobalTransformOrigin = (transform) => {
50453
- const { x: originX, y: originY } = getInternalTransformOrigin(transform);
50454
- return {
50455
- x: originX + transform.boundingClientRect.left,
50456
- y: originY + transform.boundingClientRect.top
50457
- };
50458
- };
50459
- var calculateTransforms = (element) => {
50460
- let parent = element;
50461
- const transforms = [];
50462
- const toReset = [];
50463
- let opacity = 1;
50464
- let elementComputedStyle = null;
50465
- while (parent) {
50466
- const computedStyle = getComputedStyle(parent);
50467
- const parentOpacity = computedStyle.opacity;
50468
- if (parentOpacity && parentOpacity !== "") {
50469
- opacity *= parseFloat(parentOpacity);
50470
- }
50471
- if (parent === element) {
50472
- elementComputedStyle = computedStyle;
50473
- }
50474
- if (computedStyle.transform && computedStyle.transform !== "none" || parent === element) {
50475
- const toParse = computedStyle.transform === "none" || computedStyle.transform === "" ? undefined : computedStyle.transform;
50476
- const matrix = new DOMMatrix(toParse);
50477
- const { transform } = parent.style;
50478
- parent.style.transform = "none";
50479
- transforms.push({
50480
- matrix,
50481
- rect: parent,
50482
- transformOrigin: computedStyle.transformOrigin,
50483
- boundingClientRect: null
50484
- });
50485
- const parentRef = parent;
50486
- toReset.push(() => {
50487
- parentRef.style.transform = transform;
50488
- });
50489
- }
50490
- parent = parent.parentElement;
50491
- }
50492
- for (const transform of transforms) {
50493
- transform.boundingClientRect = transform.rect.getBoundingClientRect();
50494
- }
50495
- const dimensions = transforms[0].boundingClientRect;
50496
- const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
50497
- const totalMatrix = new DOMMatrix;
50498
- for (const transform of transforms.slice().reverse()) {
50499
- if (!transform.boundingClientRect) {
50500
- throw new Error("Bounding client rect not found");
50501
- }
50502
- const globalTransformOrigin = getGlobalTransformOrigin(transform);
50503
- const transformMatrix = new DOMMatrix().translate(globalTransformOrigin.x, globalTransformOrigin.y).multiply(transform.matrix).translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
50504
- totalMatrix.multiplySelf(transformMatrix);
50505
- }
50506
- if (!elementComputedStyle) {
50507
- throw new Error("Element computed style not found");
50508
- }
50509
- return {
50510
- dimensions,
50511
- totalMatrix,
50512
- reset: () => {
50513
- for (const reset of toReset) {
50514
- reset();
50515
- }
50516
- },
50517
- nativeTransformOrigin,
50518
- opacity,
50519
- computedStyle: elementComputedStyle
50520
- };
50521
- };
50522
50536
  var drawBorder = ({
50523
50537
  ctx,
50524
50538
  x,
@@ -50623,20 +50637,14 @@ var setTransform = ({
50623
50637
  ctx.setTransform(new DOMMatrix);
50624
50638
  };
50625
50639
  };
50626
- var drawElementToCanvas = async ({
50627
- element,
50640
+ var drawElement = async ({
50641
+ dimensions,
50642
+ computedStyle,
50628
50643
  context,
50629
- draw
50644
+ draw,
50645
+ opacity,
50646
+ totalMatrix
50630
50647
  }) => {
50631
- const { totalMatrix, reset, dimensions, opacity, computedStyle } = calculateTransforms(element);
50632
- if (opacity === 0) {
50633
- reset();
50634
- return;
50635
- }
50636
- if (dimensions.width <= 0 || dimensions.height <= 0) {
50637
- reset();
50638
- return;
50639
- }
50640
50648
  const background2 = computedStyle.backgroundColor;
50641
50649
  const borderRadius = parseBorderRadius({
50642
50650
  borderRadius: computedStyle.borderRadius,
@@ -50678,6 +50686,192 @@ var drawElementToCanvas = async ({
50678
50686
  finishOpacity();
50679
50687
  finishBorderRadius();
50680
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
+ }
50681
50875
  reset();
50682
50876
  };
50683
50877
  var getCollapsedText = (span) => {
@@ -50318,6 +50318,106 @@ var getQualityForWebRendererQuality = (quality) => {
50318
50318
  throw new Error(`Unsupported quality: ${quality}`);
50319
50319
  }
50320
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
+ };
50321
50421
  function parseValue({
50322
50422
  value,
50323
50423
  reference
@@ -50452,92 +50552,6 @@ function setBorderRadius({
50452
50552
  ctx.restore();
50453
50553
  };
50454
50554
  }
50455
- var parseTransformOrigin = (transformOrigin) => {
50456
- if (transformOrigin.trim() === "") {
50457
- return null;
50458
- }
50459
- const [x, y] = transformOrigin.split(" ");
50460
- return { x: parseFloat(x), y: parseFloat(y) };
50461
- };
50462
- var getInternalTransformOrigin = (transform) => {
50463
- const centerX = transform.boundingClientRect.width / 2;
50464
- const centerY = transform.boundingClientRect.height / 2;
50465
- const origin = parseTransformOrigin(transform.transformOrigin) ?? {
50466
- x: centerX,
50467
- y: centerY
50468
- };
50469
- return origin;
50470
- };
50471
- var getGlobalTransformOrigin = (transform) => {
50472
- const { x: originX, y: originY } = getInternalTransformOrigin(transform);
50473
- return {
50474
- x: originX + transform.boundingClientRect.left,
50475
- y: originY + transform.boundingClientRect.top
50476
- };
50477
- };
50478
- var calculateTransforms = (element) => {
50479
- let parent = element;
50480
- const transforms = [];
50481
- const toReset = [];
50482
- let opacity = 1;
50483
- let elementComputedStyle = null;
50484
- while (parent) {
50485
- const computedStyle = getComputedStyle(parent);
50486
- const parentOpacity = computedStyle.opacity;
50487
- if (parentOpacity && parentOpacity !== "") {
50488
- opacity *= parseFloat(parentOpacity);
50489
- }
50490
- if (parent === element) {
50491
- elementComputedStyle = computedStyle;
50492
- }
50493
- if (computedStyle.transform && computedStyle.transform !== "none" || parent === element) {
50494
- const toParse = computedStyle.transform === "none" || computedStyle.transform === "" ? undefined : computedStyle.transform;
50495
- const matrix = new DOMMatrix(toParse);
50496
- const { transform } = parent.style;
50497
- parent.style.transform = "none";
50498
- transforms.push({
50499
- matrix,
50500
- rect: parent,
50501
- transformOrigin: computedStyle.transformOrigin,
50502
- boundingClientRect: null
50503
- });
50504
- const parentRef = parent;
50505
- toReset.push(() => {
50506
- parentRef.style.transform = transform;
50507
- });
50508
- }
50509
- parent = parent.parentElement;
50510
- }
50511
- for (const transform of transforms) {
50512
- transform.boundingClientRect = transform.rect.getBoundingClientRect();
50513
- }
50514
- const dimensions = transforms[0].boundingClientRect;
50515
- const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
50516
- const totalMatrix = new DOMMatrix;
50517
- for (const transform of transforms.slice().reverse()) {
50518
- if (!transform.boundingClientRect) {
50519
- throw new Error("Bounding client rect not found");
50520
- }
50521
- const globalTransformOrigin = getGlobalTransformOrigin(transform);
50522
- const transformMatrix = new DOMMatrix().translate(globalTransformOrigin.x, globalTransformOrigin.y).multiply(transform.matrix).translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
50523
- totalMatrix.multiplySelf(transformMatrix);
50524
- }
50525
- if (!elementComputedStyle) {
50526
- throw new Error("Element computed style not found");
50527
- }
50528
- return {
50529
- dimensions,
50530
- totalMatrix,
50531
- reset: () => {
50532
- for (const reset of toReset) {
50533
- reset();
50534
- }
50535
- },
50536
- nativeTransformOrigin,
50537
- opacity,
50538
- computedStyle: elementComputedStyle
50539
- };
50540
- };
50541
50555
  var drawBorder = ({
50542
50556
  ctx,
50543
50557
  x,
@@ -50642,20 +50656,14 @@ var setTransform = ({
50642
50656
  ctx.setTransform(new DOMMatrix);
50643
50657
  };
50644
50658
  };
50645
- var drawElementToCanvas = async ({
50646
- element,
50659
+ var drawElement = async ({
50660
+ dimensions,
50661
+ computedStyle,
50647
50662
  context,
50648
- draw
50663
+ draw,
50664
+ opacity,
50665
+ totalMatrix
50649
50666
  }) => {
50650
- const { totalMatrix, reset, dimensions, opacity, computedStyle } = calculateTransforms(element);
50651
- if (opacity === 0) {
50652
- reset();
50653
- return;
50654
- }
50655
- if (dimensions.width <= 0 || dimensions.height <= 0) {
50656
- reset();
50657
- return;
50658
- }
50659
50667
  const background2 = computedStyle.backgroundColor;
50660
50668
  const borderRadius = parseBorderRadius({
50661
50669
  borderRadius: computedStyle.borderRadius,
@@ -50697,6 +50705,192 @@ var drawElementToCanvas = async ({
50697
50705
  finishOpacity();
50698
50706
  finishBorderRadius();
50699
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
+ }
50700
50894
  reset();
50701
50895
  };
50702
50896
  var getCollapsedText = (span) => {
@@ -50598,6 +50598,106 @@ var getQualityForWebRendererQuality = (quality) => {
50598
50598
  throw new Error(`Unsupported quality: ${quality}`);
50599
50599
  }
50600
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
+ };
50601
50701
  function parseValue({
50602
50702
  value,
50603
50703
  reference
@@ -50732,92 +50832,6 @@ function setBorderRadius({
50732
50832
  ctx.restore();
50733
50833
  };
50734
50834
  }
50735
- var parseTransformOrigin = (transformOrigin) => {
50736
- if (transformOrigin.trim() === "") {
50737
- return null;
50738
- }
50739
- const [x, y] = transformOrigin.split(" ");
50740
- return { x: parseFloat(x), y: parseFloat(y) };
50741
- };
50742
- var getInternalTransformOrigin = (transform) => {
50743
- const centerX = transform.boundingClientRect.width / 2;
50744
- const centerY = transform.boundingClientRect.height / 2;
50745
- const origin = parseTransformOrigin(transform.transformOrigin) ?? {
50746
- x: centerX,
50747
- y: centerY
50748
- };
50749
- return origin;
50750
- };
50751
- var getGlobalTransformOrigin = (transform) => {
50752
- const { x: originX, y: originY } = getInternalTransformOrigin(transform);
50753
- return {
50754
- x: originX + transform.boundingClientRect.left,
50755
- y: originY + transform.boundingClientRect.top
50756
- };
50757
- };
50758
- var calculateTransforms = (element) => {
50759
- let parent = element;
50760
- const transforms = [];
50761
- const toReset = [];
50762
- let opacity = 1;
50763
- let elementComputedStyle = null;
50764
- while (parent) {
50765
- const computedStyle = getComputedStyle(parent);
50766
- const parentOpacity = computedStyle.opacity;
50767
- if (parentOpacity && parentOpacity !== "") {
50768
- opacity *= parseFloat(parentOpacity);
50769
- }
50770
- if (parent === element) {
50771
- elementComputedStyle = computedStyle;
50772
- }
50773
- if (computedStyle.transform && computedStyle.transform !== "none" || parent === element) {
50774
- const toParse = computedStyle.transform === "none" || computedStyle.transform === "" ? undefined : computedStyle.transform;
50775
- const matrix = new DOMMatrix(toParse);
50776
- const { transform } = parent.style;
50777
- parent.style.transform = "none";
50778
- transforms.push({
50779
- matrix,
50780
- rect: parent,
50781
- transformOrigin: computedStyle.transformOrigin,
50782
- boundingClientRect: null
50783
- });
50784
- const parentRef = parent;
50785
- toReset.push(() => {
50786
- parentRef.style.transform = transform;
50787
- });
50788
- }
50789
- parent = parent.parentElement;
50790
- }
50791
- for (const transform of transforms) {
50792
- transform.boundingClientRect = transform.rect.getBoundingClientRect();
50793
- }
50794
- const dimensions = transforms[0].boundingClientRect;
50795
- const nativeTransformOrigin = getInternalTransformOrigin(transforms[0]);
50796
- const totalMatrix = new DOMMatrix;
50797
- for (const transform of transforms.slice().reverse()) {
50798
- if (!transform.boundingClientRect) {
50799
- throw new Error("Bounding client rect not found");
50800
- }
50801
- const globalTransformOrigin = getGlobalTransformOrigin(transform);
50802
- const transformMatrix = new DOMMatrix().translate(globalTransformOrigin.x, globalTransformOrigin.y).multiply(transform.matrix).translate(-globalTransformOrigin.x, -globalTransformOrigin.y);
50803
- totalMatrix.multiplySelf(transformMatrix);
50804
- }
50805
- if (!elementComputedStyle) {
50806
- throw new Error("Element computed style not found");
50807
- }
50808
- return {
50809
- dimensions,
50810
- totalMatrix,
50811
- reset: () => {
50812
- for (const reset of toReset) {
50813
- reset();
50814
- }
50815
- },
50816
- nativeTransformOrigin,
50817
- opacity,
50818
- computedStyle: elementComputedStyle
50819
- };
50820
- };
50821
50835
  var drawBorder = ({
50822
50836
  ctx,
50823
50837
  x,
@@ -50922,20 +50936,14 @@ var setTransform = ({
50922
50936
  ctx.setTransform(new DOMMatrix);
50923
50937
  };
50924
50938
  };
50925
- var drawElementToCanvas = async ({
50926
- element,
50939
+ var drawElement = async ({
50940
+ dimensions,
50941
+ computedStyle,
50927
50942
  context,
50928
- draw
50943
+ draw,
50944
+ opacity,
50945
+ totalMatrix
50929
50946
  }) => {
50930
- const { totalMatrix, reset, dimensions, opacity, computedStyle } = calculateTransforms(element);
50931
- if (opacity === 0) {
50932
- reset();
50933
- return;
50934
- }
50935
- if (dimensions.width <= 0 || dimensions.height <= 0) {
50936
- reset();
50937
- return;
50938
- }
50939
50947
  const background2 = computedStyle.backgroundColor;
50940
50948
  const borderRadius = parseBorderRadius({
50941
50949
  borderRadius: computedStyle.borderRadius,
@@ -50977,6 +50985,192 @@ var drawElementToCanvas = async ({
50977
50985
  finishOpacity();
50978
50986
  finishBorderRadius();
50979
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
+ }
50980
51174
  reset();
50981
51175
  };
50982
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-fnfxxf7g.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,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio"
4
4
  },
5
5
  "name": "@remotion/studio",
6
- "version": "4.0.391",
6
+ "version": "4.0.392",
7
7
  "description": "APIs for interacting with the Remotion Studio",
8
8
  "main": "dist",
9
9
  "sideEffects": false,
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "semver": "7.5.3",
28
- "remotion": "4.0.391",
29
- "@remotion/player": "4.0.391",
30
- "@remotion/media-utils": "4.0.391",
31
- "@remotion/renderer": "4.0.391",
32
- "@remotion/web-renderer": "4.0.391",
33
- "@remotion/studio-shared": "4.0.391",
34
- "@remotion/zod-types": "4.0.391",
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.391",
45
+ "@remotion/eslint-config-internal": "4.0.392",
46
46
  "eslint": "9.19.0"
47
47
  },
48
48
  "publishConfig": {