@meframe/core 0.1.0 → 0.1.2

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.
Files changed (44) hide show
  1. package/dist/cache/CacheManager.d.ts +2 -2
  2. package/dist/cache/CacheManager.d.ts.map +1 -1
  3. package/dist/cache/CacheManager.js +4 -4
  4. package/dist/cache/CacheManager.js.map +1 -1
  5. package/dist/cache/l1/AudioL1Cache.d.ts +5 -2
  6. package/dist/cache/l1/AudioL1Cache.d.ts.map +1 -1
  7. package/dist/cache/l1/AudioL1Cache.js +7 -3
  8. package/dist/cache/l1/AudioL1Cache.js.map +1 -1
  9. package/dist/controllers/PlaybackController.d.ts.map +1 -1
  10. package/dist/controllers/PlaybackController.js +1 -1
  11. package/dist/controllers/PlaybackController.js.map +1 -1
  12. package/dist/model/CompositionModel.d.ts.map +1 -1
  13. package/dist/model/CompositionModel.js +4 -5
  14. package/dist/model/CompositionModel.js.map +1 -1
  15. package/dist/model/types.d.ts +6 -0
  16. package/dist/model/types.d.ts.map +1 -1
  17. package/dist/model/types.js.map +1 -1
  18. package/dist/orchestrator/CompositionPlanner.d.ts +0 -1
  19. package/dist/orchestrator/CompositionPlanner.d.ts.map +1 -1
  20. package/dist/orchestrator/CompositionPlanner.js +4 -12
  21. package/dist/orchestrator/CompositionPlanner.js.map +1 -1
  22. package/dist/orchestrator/ExportScheduler.d.ts.map +1 -1
  23. package/dist/orchestrator/ExportScheduler.js +2 -0
  24. package/dist/orchestrator/ExportScheduler.js.map +1 -1
  25. package/dist/orchestrator/GlobalAudioSession.d.ts +2 -2
  26. package/dist/orchestrator/GlobalAudioSession.d.ts.map +1 -1
  27. package/dist/orchestrator/GlobalAudioSession.js +11 -6
  28. package/dist/orchestrator/GlobalAudioSession.js.map +1 -1
  29. package/dist/orchestrator/Orchestrator.d.ts.map +1 -1
  30. package/dist/orchestrator/Orchestrator.js +2 -7
  31. package/dist/orchestrator/Orchestrator.js.map +1 -1
  32. package/dist/stages/compose/LayerRenderer.d.ts +5 -0
  33. package/dist/stages/compose/LayerRenderer.d.ts.map +1 -1
  34. package/dist/stages/compose/LayerRenderer.js +91 -89
  35. package/dist/stages/compose/LayerRenderer.js.map +1 -1
  36. package/dist/stages/compose/instructions.d.ts +6 -6
  37. package/dist/stages/compose/instructions.d.ts.map +1 -1
  38. package/dist/stages/compose/types.d.ts +6 -0
  39. package/dist/stages/compose/types.d.ts.map +1 -1
  40. package/dist/workers/stages/compose/{video-compose.worker.B-_C-_y6.js → video-compose.worker.C8728Oi3.js} +97 -98
  41. package/dist/workers/stages/compose/video-compose.worker.C8728Oi3.js.map +1 -0
  42. package/dist/workers/worker-manifest.json +1 -1
  43. package/package.json +1 -1
  44. package/dist/workers/stages/compose/video-compose.worker.B-_C-_y6.js.map +0 -1
@@ -843,41 +843,46 @@ class LayerRenderer {
843
843
  const parsed = parseFloat(strValue);
844
844
  return isNaN(parsed) ? void 0 : parsed;
845
845
  }
846
+ /**
847
+ * Calculate dimensions from renderConfig
848
+ * Returns dimensions maintaining aspect ratio when only one dimension is specified
849
+ */
850
+ calculateDimensionsFromConfig(sourceWidth, sourceHeight, renderConfig) {
851
+ if (!renderConfig) {
852
+ return { width: sourceWidth, height: sourceHeight };
853
+ }
854
+ const width = this.parseDimension(renderConfig.width, this.width);
855
+ const height = this.parseDimension(renderConfig.height, this.height);
856
+ if (width && height) {
857
+ return { width, height };
858
+ } else if (width) {
859
+ return {
860
+ width,
861
+ height: Math.round(sourceHeight / sourceWidth * width)
862
+ };
863
+ } else if (height) {
864
+ return {
865
+ width: Math.round(sourceWidth / sourceHeight * height),
866
+ height
867
+ };
868
+ } else {
869
+ return { width: sourceWidth, height: sourceHeight };
870
+ }
871
+ }
846
872
  getLayerDimensions(layer) {
847
873
  if (layer.type === "image") {
848
874
  const imageLayer = layer;
849
875
  if (imageLayer.source) {
850
876
  const imgWidth = imageLayer.source.width;
851
877
  const imgHeight = imageLayer.source.height;
852
- const isAttachment = !!imageLayer.attachmentId;
853
- if (isAttachment) {
854
- const targetWidthRaw = imageLayer.targetWidth;
855
- const targetHeightRaw = imageLayer.targetHeight;
856
- const targetWidth = this.parseDimension(targetWidthRaw, this.width);
857
- const targetHeight = this.parseDimension(targetHeightRaw, this.height);
858
- if (targetWidth && targetHeight) {
859
- return { width: targetWidth, height: targetHeight };
860
- } else if (targetWidth) {
861
- return {
862
- width: targetWidth,
863
- height: imgHeight / imgWidth * targetWidth
864
- };
865
- } else if (targetHeight) {
866
- return {
867
- width: imgWidth / imgHeight * targetHeight,
868
- height: targetHeight
869
- };
870
- }
871
- }
872
- return { width: imgWidth, height: imgHeight };
878
+ return this.calculateDimensionsFromConfig(imgWidth, imgHeight, imageLayer.renderConfig);
873
879
  }
874
880
  } else if (layer.type === "video") {
875
881
  const videoLayer = layer;
876
882
  const videoFrame = videoLayer.videoFrame;
877
- return {
878
- width: videoFrame.displayWidth || videoFrame.codedWidth,
879
- height: videoFrame.displayHeight || videoFrame.codedHeight
880
- };
883
+ const videoWidth = videoFrame.displayWidth || videoFrame.codedWidth;
884
+ const videoHeight = videoFrame.displayHeight || videoFrame.codedHeight;
885
+ return this.calculateDimensionsFromConfig(videoWidth, videoHeight, videoLayer.renderConfig);
881
886
  }
882
887
  return { width: this.width, height: this.height };
883
888
  }
@@ -922,11 +927,27 @@ class LayerRenderer {
922
927
  this.ctx.translate(-centerX, -centerY);
923
928
  }
924
929
  renderVideoLayer(layer) {
925
- const { videoFrame, crop } = layer;
930
+ const { videoFrame, crop, renderConfig } = layer;
926
931
  const videoWidth = videoFrame.displayWidth || videoFrame.codedWidth;
927
932
  const videoHeight = videoFrame.displayHeight || videoFrame.codedHeight;
928
- const naturalScale = this.height / videoHeight;
929
- const dimensions = this.calculateRenderDimensions(videoWidth, videoHeight, naturalScale);
933
+ let renderX;
934
+ let renderY;
935
+ let renderWidth;
936
+ let renderHeight;
937
+ if (renderConfig) {
938
+ const dimensions = this.calculateDimensionsFromConfig(videoWidth, videoHeight, renderConfig);
939
+ renderWidth = dimensions.width;
940
+ renderHeight = dimensions.height;
941
+ renderX = Math.round((this.width - renderWidth) / 2);
942
+ renderY = Math.round((this.height - renderHeight) / 2);
943
+ } else {
944
+ const naturalScale = this.height / videoHeight;
945
+ const dimensions = this.calculateRenderDimensions(videoWidth, videoHeight, naturalScale);
946
+ renderX = dimensions.x;
947
+ renderY = dimensions.y;
948
+ renderWidth = dimensions.width;
949
+ renderHeight = dimensions.height;
950
+ }
930
951
  if (crop) {
931
952
  this.ctx.drawImage(
932
953
  videoFrame,
@@ -934,23 +955,17 @@ class LayerRenderer {
934
955
  crop.y,
935
956
  crop.width,
936
957
  crop.height,
937
- dimensions.x,
938
- dimensions.y,
939
- dimensions.width,
940
- dimensions.height
958
+ renderX,
959
+ renderY,
960
+ renderWidth,
961
+ renderHeight
941
962
  );
942
963
  } else {
943
- this.ctx.drawImage(
944
- videoFrame,
945
- dimensions.x,
946
- dimensions.y,
947
- dimensions.width,
948
- dimensions.height
949
- );
964
+ this.ctx.drawImage(videoFrame, renderX, renderY, renderWidth, renderHeight);
950
965
  }
951
966
  }
952
967
  renderImageLayer(layer) {
953
- const { source, crop } = layer;
968
+ const { source, crop, renderConfig } = layer;
954
969
  if (source instanceof ImageData) {
955
970
  if (crop) {
956
971
  const tempCanvas = new OffscreenCanvas(crop.width, crop.height);
@@ -960,56 +975,43 @@ class LayerRenderer {
960
975
  } else {
961
976
  this.ctx.putImageData(source, 0, 0);
962
977
  }
978
+ return;
979
+ }
980
+ if (!source) return;
981
+ const imgWidth = source.width;
982
+ const imgHeight = source.height;
983
+ let renderX;
984
+ let renderY;
985
+ let renderWidth;
986
+ let renderHeight;
987
+ if (renderConfig) {
988
+ const dimensions = this.calculateDimensionsFromConfig(imgWidth, imgHeight, renderConfig);
989
+ renderWidth = dimensions.width;
990
+ renderHeight = dimensions.height;
991
+ renderX = 0;
992
+ renderY = 0;
963
993
  } else {
964
- if (!source) {
965
- return;
966
- }
967
- const isAttachment = !!layer.attachmentId;
968
- const imgWidth = source.width;
969
- const imgHeight = source.height;
970
- let renderWidth;
971
- let renderHeight;
972
- if (isAttachment) {
973
- const targetWidthRaw = layer.targetWidth;
974
- const targetHeightRaw = layer.targetHeight;
975
- const targetWidth = this.parseDimension(targetWidthRaw, this.width);
976
- const targetHeight = this.parseDimension(targetHeightRaw, this.height);
977
- if (targetWidth && targetHeight) {
978
- renderWidth = targetWidth;
979
- renderHeight = targetHeight;
980
- } else if (targetWidth) {
981
- renderWidth = targetWidth;
982
- renderHeight = imgHeight / imgWidth * targetWidth;
983
- } else if (targetHeight) {
984
- renderHeight = targetHeight;
985
- renderWidth = imgWidth / imgHeight * targetHeight;
986
- } else {
987
- renderWidth = imgWidth;
988
- renderHeight = imgHeight;
989
- }
990
- } else {
991
- const naturalScale = this.width / imgWidth;
992
- const dimensions = this.calculateRenderDimensions(imgWidth, imgHeight, naturalScale);
993
- renderWidth = dimensions.width;
994
- renderHeight = dimensions.height;
995
- }
996
- const renderX = isAttachment ? 0 : Math.round((this.width - renderWidth) / 2);
997
- const renderY = isAttachment ? 0 : Math.round((this.height - renderHeight) / 2);
998
- if (crop) {
999
- this.ctx.drawImage(
1000
- source,
1001
- crop.x,
1002
- crop.y,
1003
- crop.width,
1004
- crop.height,
1005
- renderX,
1006
- renderY,
1007
- renderWidth,
1008
- renderHeight
1009
- );
1010
- } else {
1011
- this.ctx.drawImage(source, renderX, renderY, renderWidth, renderHeight);
1012
- }
994
+ const naturalScale = this.width / imgWidth;
995
+ const dimensions = this.calculateRenderDimensions(imgWidth, imgHeight, naturalScale);
996
+ renderWidth = dimensions.width;
997
+ renderHeight = dimensions.height;
998
+ renderX = Math.round((this.width - renderWidth) / 2);
999
+ renderY = Math.round((this.height - renderHeight) / 2);
1000
+ }
1001
+ if (crop) {
1002
+ this.ctx.drawImage(
1003
+ source,
1004
+ crop.x,
1005
+ crop.y,
1006
+ crop.width,
1007
+ crop.height,
1008
+ renderX,
1009
+ renderY,
1010
+ renderWidth,
1011
+ renderHeight
1012
+ );
1013
+ } else {
1014
+ this.ctx.drawImage(source, renderX, renderY, renderWidth, renderHeight);
1013
1015
  }
1014
1016
  }
1015
1017
  renderTextLayer(layer) {
@@ -2026,10 +2028,12 @@ function materializeLayer(layer, frame, imageMap, globalTimeUs) {
2026
2028
  opacity: layer.opacity ?? 1
2027
2029
  };
2028
2030
  if (layer.type === "video") {
2031
+ const payload = layer.payload;
2029
2032
  return {
2030
2033
  ...baseLayer,
2031
2034
  type: "video",
2032
- videoFrame: frame
2035
+ videoFrame: frame,
2036
+ renderConfig: payload.renderConfig
2033
2037
  };
2034
2038
  }
2035
2039
  if (layer.type === "text") {
@@ -2053,14 +2057,9 @@ function materializeLayer(layer, frame, imageMap, globalTimeUs) {
2053
2057
  ...baseLayer,
2054
2058
  type: "image",
2055
2059
  source,
2056
- attachmentId: payload.attachmentId
2060
+ attachmentId: payload.attachmentId,
2061
+ renderConfig: payload.renderConfig
2057
2062
  };
2058
- if (payload.targetWidth !== void 0) {
2059
- imageLayer.targetWidth = payload.targetWidth;
2060
- }
2061
- if (payload.targetHeight !== void 0) {
2062
- imageLayer.targetHeight = payload.targetHeight;
2063
- }
2064
2063
  if (payload.animation && globalTimeUs !== void 0) {
2065
2064
  const animState = computeAnimationState(payload.animation, globalTimeUs);
2066
2065
  if (!animState.visible) {
@@ -2462,4 +2461,4 @@ export {
2462
2461
  VideoComposeWorker,
2463
2462
  videoCompose_worker as default
2464
2463
  };
2465
- //# sourceMappingURL=video-compose.worker.B-_C-_y6.js.map
2464
+ //# sourceMappingURL=video-compose.worker.C8728Oi3.js.map