@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/vue.cjs CHANGED
@@ -2750,13 +2750,28 @@ var MediaPlugin = class {
2750
2750
  video.src = url;
2751
2751
  video.controls = true;
2752
2752
  video.playsInline = true;
2753
- video.style.maxWidth = "90%";
2754
- video.style.maxHeight = "90%";
2755
2753
  video.style.borderRadius = "8px";
2756
2754
  video.style.boxShadow = "0 8px 30px rgba(0,0,0,0.3)";
2757
2755
  video.style.backgroundColor = "#000000";
2756
+ video.style.objectFit = "contain";
2757
+ video.style.transition = "transform 0.2s ease";
2758
2758
  element = video;
2759
2759
  mediaElement = video;
2760
+ const onMeta = () => {
2761
+ if (video.videoWidth > 0 && video.videoHeight > 0) {
2762
+ naturalW = video.videoWidth;
2763
+ naturalH = video.videoHeight;
2764
+ }
2765
+ updateBaseDimensions();
2766
+ applyTransform();
2767
+ };
2768
+ if (video.readyState >= 1 && video.videoWidth > 0) {
2769
+ naturalW = video.videoWidth;
2770
+ naturalH = video.videoHeight;
2771
+ } else {
2772
+ video.addEventListener("loadedmetadata", onMeta, { once: true });
2773
+ video.addEventListener("canplay", onMeta, { once: true });
2774
+ }
2760
2775
  } else if (isAudio) {
2761
2776
  const audio = document.createElement("audio");
2762
2777
  audio.src = url;
@@ -2797,11 +2812,19 @@ var MediaPlugin = class {
2797
2812
  let fitMode = ctx?.options?.fitMode || "width";
2798
2813
  let isUserZoomed = false;
2799
2814
  const updateBaseDimensions = () => {
2800
- if (!isImage) return;
2801
- const img = element;
2802
- if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2803
- naturalW = img.naturalWidth;
2804
- naturalH = img.naturalHeight;
2815
+ if (!isImage && !isVideo) return;
2816
+ if (isImage) {
2817
+ const img = element;
2818
+ if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2819
+ naturalW = img.naturalWidth;
2820
+ naturalH = img.naturalHeight;
2821
+ }
2822
+ } else if (isVideo) {
2823
+ const vid = element;
2824
+ if (vid.videoWidth > 0 && vid.videoHeight > 0) {
2825
+ naturalW = vid.videoWidth;
2826
+ naturalH = vid.videoHeight;
2827
+ }
2805
2828
  }
2806
2829
  const availW = Math.max(100, ctx.container.clientWidth - 32);
2807
2830
  const availH = Math.max(100, ctx.container.clientHeight - 32);
@@ -2815,7 +2838,7 @@ var MediaPlugin = class {
2815
2838
  baseH = Math.max(1, Math.round(naturalH * fitRatio));
2816
2839
  };
2817
2840
  const applyTransform = () => {
2818
- if (isImage) {
2841
+ if (isImage || isVideo) {
2819
2842
  if (!isUserZoomed) {
2820
2843
  updateBaseDimensions();
2821
2844
  }
@@ -2826,10 +2849,10 @@ var MediaPlugin = class {
2826
2849
  sizer.style.width = `${boxW}px`;
2827
2850
  sizer.style.height = `${boxH}px`;
2828
2851
  sizer.style.margin = boxH < availH ? "auto 0" : "0";
2829
- const imgW = isRotated90 ? boxH : boxW;
2830
- const imgH = isRotated90 ? boxW : boxH;
2831
- element.style.width = `${imgW}px`;
2832
- element.style.height = `${imgH}px`;
2852
+ const elW = isRotated90 ? boxH : boxW;
2853
+ const elH = isRotated90 ? boxW : boxH;
2854
+ element.style.width = `${elW}px`;
2855
+ element.style.height = `${elH}px`;
2833
2856
  element.style.maxWidth = "none";
2834
2857
  element.style.maxHeight = "none";
2835
2858
  element.style.transform = rotation ? `rotate(${rotation}deg)` : "none";
@@ -2839,6 +2862,8 @@ var MediaPlugin = class {
2839
2862
  element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2840
2863
  }
2841
2864
  };
2865
+ updateBaseDimensions();
2866
+ applyTransform();
2842
2867
  if (isImage) {
2843
2868
  const img = element;
2844
2869
  if (img.complete && img.naturalWidth > 0) {
@@ -2883,7 +2908,7 @@ var MediaPlugin = class {
2883
2908
  currentZoom = level;
2884
2909
  applyTransform();
2885
2910
  } : void 0,
2886
- fitToPage: isImage ? () => {
2911
+ fitToPage: isImage || isVideo ? () => {
2887
2912
  isUserZoomed = false;
2888
2913
  fitMode = "page";
2889
2914
  currentZoom = 1;
@@ -2893,7 +2918,7 @@ var MediaPlugin = class {
2893
2918
  updateBaseDimensions();
2894
2919
  applyTransform();
2895
2920
  } : void 0,
2896
- fitToWidth: isImage ? () => {
2921
+ fitToWidth: isImage || isVideo ? () => {
2897
2922
  isUserZoomed = false;
2898
2923
  fitMode = "width";
2899
2924
  currentZoom = 1;
@@ -2903,7 +2928,7 @@ var MediaPlugin = class {
2903
2928
  updateBaseDimensions();
2904
2929
  applyTransform();
2905
2930
  } : void 0,
2906
- resetZoom: isImage ? () => {
2931
+ resetZoom: isImage || isVideo ? () => {
2907
2932
  isUserZoomed = false;
2908
2933
  fitMode = ctx?.options?.fitMode || "width";
2909
2934
  currentZoom = 1;
@@ -6042,6 +6067,16 @@ var ThreeDPlugin = class {
6042
6067
  type: "button",
6043
6068
  group: "actions",
6044
6069
  execute: () => instance.download?.()
6070
+ },
6071
+ {
6072
+ id: "open-window",
6073
+ icon: "open-window",
6074
+ label: "Open in Separate Full Window",
6075
+ type: "button",
6076
+ group: "actions",
6077
+ execute: () => {
6078
+ instance.openInSeparateWindow?.();
6079
+ }
6045
6080
  }
6046
6081
  ];
6047
6082
  }
@@ -6112,12 +6147,21 @@ var ThreeDPlugin = class {
6112
6147
  });
6113
6148
  meshGroup.add(obj);
6114
6149
  }
6150
+ const initialBox = new THREE__namespace.Box3().setFromObject(meshGroup);
6151
+ const center = initialBox.getCenter(new THREE__namespace.Vector3());
6152
+ meshGroup.position.sub(center);
6115
6153
  scene.add(meshGroup);
6116
6154
  const box = new THREE__namespace.Box3().setFromObject(meshGroup);
6117
- const sphere = box.getBoundingSphere(new THREE__namespace.Sphere());
6118
- const radius = Math.max(sphere.radius, 10);
6155
+ const size = box.getSize(new THREE__namespace.Vector3());
6156
+ const maxDim = Math.max(size.x, size.y, size.z) || 10;
6157
+ grid.position.y = -size.y / 2;
6158
+ const gridScale = Math.max(0.1, maxDim / 50);
6159
+ grid.scale.set(gridScale, 1, gridScale);
6160
+ const fovRad = camera.fov * (Math.PI / 180);
6161
+ let cameraDistance = maxDim / 2 / Math.tan(fovRad / 2);
6162
+ cameraDistance = Math.max(cameraDistance * 1.5, 2);
6119
6163
  const fitCamera = () => {
6120
- camera.position.set(radius * 1.5, radius * 1.2, radius * 2);
6164
+ camera.position.set(cameraDistance * 0.8, cameraDistance * 0.6, cameraDistance);
6121
6165
  camera.lookAt(0, 0, 0);
6122
6166
  controls.target.set(0, 0, 0);
6123
6167
  controls.update();
@@ -6163,6 +6207,7 @@ var ThreeDPlugin = class {
6163
6207
  controls.update();
6164
6208
  },
6165
6209
  fitToPage: fitCamera,
6210
+ fitToWidth: fitCamera,
6166
6211
  resetZoom: fitCamera,
6167
6212
  rotateCW: () => {
6168
6213
  isWireframe = !isWireframe;