@files-preview-app/preview-file 1.3.10 → 1.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -2718,13 +2718,28 @@ var MediaPlugin = class {
2718
2718
  video.src = url;
2719
2719
  video.controls = true;
2720
2720
  video.playsInline = true;
2721
- video.style.maxWidth = "90%";
2722
- video.style.maxHeight = "90%";
2723
2721
  video.style.borderRadius = "8px";
2724
2722
  video.style.boxShadow = "0 8px 30px rgba(0,0,0,0.3)";
2725
2723
  video.style.backgroundColor = "#000000";
2724
+ video.style.objectFit = "contain";
2725
+ video.style.transition = "transform 0.2s ease";
2726
2726
  element = video;
2727
2727
  mediaElement = video;
2728
+ const onMeta = () => {
2729
+ if (video.videoWidth > 0 && video.videoHeight > 0) {
2730
+ naturalW = video.videoWidth;
2731
+ naturalH = video.videoHeight;
2732
+ }
2733
+ updateBaseDimensions();
2734
+ applyTransform();
2735
+ };
2736
+ if (video.readyState >= 1 && video.videoWidth > 0) {
2737
+ naturalW = video.videoWidth;
2738
+ naturalH = video.videoHeight;
2739
+ } else {
2740
+ video.addEventListener("loadedmetadata", onMeta, { once: true });
2741
+ video.addEventListener("canplay", onMeta, { once: true });
2742
+ }
2728
2743
  } else if (isAudio) {
2729
2744
  const audio = document.createElement("audio");
2730
2745
  audio.src = url;
@@ -2765,11 +2780,19 @@ var MediaPlugin = class {
2765
2780
  let fitMode = ctx?.options?.fitMode || "width";
2766
2781
  let isUserZoomed = false;
2767
2782
  const updateBaseDimensions = () => {
2768
- if (!isImage) return;
2769
- const img = element;
2770
- if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2771
- naturalW = img.naturalWidth;
2772
- naturalH = img.naturalHeight;
2783
+ if (!isImage && !isVideo) return;
2784
+ if (isImage) {
2785
+ const img = element;
2786
+ if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2787
+ naturalW = img.naturalWidth;
2788
+ naturalH = img.naturalHeight;
2789
+ }
2790
+ } else if (isVideo) {
2791
+ const vid = element;
2792
+ if (vid.videoWidth > 0 && vid.videoHeight > 0) {
2793
+ naturalW = vid.videoWidth;
2794
+ naturalH = vid.videoHeight;
2795
+ }
2773
2796
  }
2774
2797
  const availW = Math.max(100, ctx.container.clientWidth - 32);
2775
2798
  const availH = Math.max(100, ctx.container.clientHeight - 32);
@@ -2783,7 +2806,7 @@ var MediaPlugin = class {
2783
2806
  baseH = Math.max(1, Math.round(naturalH * fitRatio));
2784
2807
  };
2785
2808
  const applyTransform = () => {
2786
- if (isImage) {
2809
+ if (isImage || isVideo) {
2787
2810
  if (!isUserZoomed) {
2788
2811
  updateBaseDimensions();
2789
2812
  }
@@ -2794,10 +2817,10 @@ var MediaPlugin = class {
2794
2817
  sizer.style.width = `${boxW}px`;
2795
2818
  sizer.style.height = `${boxH}px`;
2796
2819
  sizer.style.margin = boxH < availH ? "auto 0" : "0";
2797
- const imgW = isRotated90 ? boxH : boxW;
2798
- const imgH = isRotated90 ? boxW : boxH;
2799
- element.style.width = `${imgW}px`;
2800
- element.style.height = `${imgH}px`;
2820
+ const elW = isRotated90 ? boxH : boxW;
2821
+ const elH = isRotated90 ? boxW : boxH;
2822
+ element.style.width = `${elW}px`;
2823
+ element.style.height = `${elH}px`;
2801
2824
  element.style.maxWidth = "none";
2802
2825
  element.style.maxHeight = "none";
2803
2826
  element.style.transform = rotation ? `rotate(${rotation}deg)` : "none";
@@ -2807,6 +2830,8 @@ var MediaPlugin = class {
2807
2830
  element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2808
2831
  }
2809
2832
  };
2833
+ updateBaseDimensions();
2834
+ applyTransform();
2810
2835
  if (isImage) {
2811
2836
  const img = element;
2812
2837
  if (img.complete && img.naturalWidth > 0) {
@@ -2851,7 +2876,7 @@ var MediaPlugin = class {
2851
2876
  currentZoom = level;
2852
2877
  applyTransform();
2853
2878
  } : void 0,
2854
- fitToPage: isImage ? () => {
2879
+ fitToPage: isImage || isVideo ? () => {
2855
2880
  isUserZoomed = false;
2856
2881
  fitMode = "page";
2857
2882
  currentZoom = 1;
@@ -2861,7 +2886,7 @@ var MediaPlugin = class {
2861
2886
  updateBaseDimensions();
2862
2887
  applyTransform();
2863
2888
  } : void 0,
2864
- fitToWidth: isImage ? () => {
2889
+ fitToWidth: isImage || isVideo ? () => {
2865
2890
  isUserZoomed = false;
2866
2891
  fitMode = "width";
2867
2892
  currentZoom = 1;
@@ -2871,7 +2896,7 @@ var MediaPlugin = class {
2871
2896
  updateBaseDimensions();
2872
2897
  applyTransform();
2873
2898
  } : void 0,
2874
- resetZoom: isImage ? () => {
2899
+ resetZoom: isImage || isVideo ? () => {
2875
2900
  isUserZoomed = false;
2876
2901
  fitMode = ctx?.options?.fitMode || "width";
2877
2902
  currentZoom = 1;
@@ -6010,6 +6035,16 @@ var ThreeDPlugin = class {
6010
6035
  type: "button",
6011
6036
  group: "actions",
6012
6037
  execute: () => instance.download?.()
6038
+ },
6039
+ {
6040
+ id: "open-window",
6041
+ icon: "open-window",
6042
+ label: "Open in Separate Full Window",
6043
+ type: "button",
6044
+ group: "actions",
6045
+ execute: () => {
6046
+ instance.openInSeparateWindow?.();
6047
+ }
6013
6048
  }
6014
6049
  ];
6015
6050
  }
@@ -6080,12 +6115,21 @@ var ThreeDPlugin = class {
6080
6115
  });
6081
6116
  meshGroup.add(obj);
6082
6117
  }
6118
+ const initialBox = new THREE.Box3().setFromObject(meshGroup);
6119
+ const center = initialBox.getCenter(new THREE.Vector3());
6120
+ meshGroup.position.sub(center);
6083
6121
  scene.add(meshGroup);
6084
6122
  const box = new THREE.Box3().setFromObject(meshGroup);
6085
- const sphere = box.getBoundingSphere(new THREE.Sphere());
6086
- const radius = Math.max(sphere.radius, 10);
6123
+ const size = box.getSize(new THREE.Vector3());
6124
+ const maxDim = Math.max(size.x, size.y, size.z) || 10;
6125
+ grid.position.y = -size.y / 2;
6126
+ const gridScale = Math.max(0.1, maxDim / 50);
6127
+ grid.scale.set(gridScale, 1, gridScale);
6128
+ const fovRad = camera.fov * (Math.PI / 180);
6129
+ let cameraDistance = maxDim / 2 / Math.tan(fovRad / 2);
6130
+ cameraDistance = Math.max(cameraDistance * 1.5, 2);
6087
6131
  const fitCamera = () => {
6088
- camera.position.set(radius * 1.5, radius * 1.2, radius * 2);
6132
+ camera.position.set(cameraDistance * 0.8, cameraDistance * 0.6, cameraDistance);
6089
6133
  camera.lookAt(0, 0, 0);
6090
6134
  controls.target.set(0, 0, 0);
6091
6135
  controls.update();
@@ -6131,6 +6175,7 @@ var ThreeDPlugin = class {
6131
6175
  controls.update();
6132
6176
  },
6133
6177
  fitToPage: fitCamera,
6178
+ fitToWidth: fitCamera,
6134
6179
  resetZoom: fitCamera,
6135
6180
  rotateCW: () => {
6136
6181
  isWireframe = !isWireframe;