Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@filerobot/utils

Package Overview
Dependencies
Maintainers
1
Versions
1360
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@filerobot/utils - npm Package Compare versions

Comparing version 0.0.0-beta.60 to 0.0.0-beta.61

31

lib/getFileDetails.js
import { TIME_OPTIONS } from './constants';
import getItemIcon from './getItemIcon';
import getFileExtension from '../lib/getFileExtension';
export default (function (file) {
var _file$meta, _file$meta2;
import isSupportedVideo from '../lib/isSupportedVideo';
export default (function (file, i18n) {
var _meta$img_w, _meta$img_h, _meta$playlists, _meta$playlists2;
var imgWidth = file === null || file === void 0 ? void 0 : (_file$meta = file.meta) === null || _file$meta === void 0 ? void 0 : _file$meta.img_w;
var imgHeight = file === null || file === void 0 ? void 0 : (_file$meta2 = file.meta) === null || _file$meta2 === void 0 ? void 0 : _file$meta2.img_h;
var isDefined = imgWidth && imgHeight;
var meta = file === null || file === void 0 ? void 0 : file.meta;
var width = (_meta$img_w = meta === null || meta === void 0 ? void 0 : meta.img_w) != null ? _meta$img_w : meta === null || meta === void 0 ? void 0 : meta.video_w;
var height = (_meta$img_h = meta === null || meta === void 0 ? void 0 : meta.img_h) != null ? _meta$img_h : meta === null || meta === void 0 ? void 0 : meta.video_w;
var isDefined = width && height;
var isVideo = isSupportedVideo(file);
var videoDuration = meta === null || meta === void 0 ? void 0 : meta.video_duration;
var videoTranscodingProgress = file.transcodingProgress ? file.transcodingProgress + "%" : (meta === null || meta === void 0 ? void 0 : (_meta$playlists = meta.playlists) === null || _meta$playlists === void 0 ? void 0 : _meta$playlists.length) > 0 ? i18n('yes') : isVideo ? i18n('no') : undefined;
var videoTranscodingStatus = file.transcodingStatus || (meta === null || meta === void 0 ? void 0 : (_meta$playlists2 = meta.playlists) === null || _meta$playlists2 === void 0 ? void 0 : _meta$playlists2.length) > 0 ? file.transcodingStatus || i18n('ok') : undefined;
var uuid = file.uuid;

@@ -15,9 +21,9 @@ var name = file.name;

var url = file.url;
var previewUrl = getItemIcon(file);
var previewUrl = file.preview || (meta === null || meta === void 0 ? void 0 : meta.video_thumbnail) || getItemIcon(file);
var createdAt = file.created_at ? new Date(file.created_at).toLocaleTimeString('en', TIME_OPTIONS) : '';
var modifiedAt = file.updated_at ? new Date(file.modified_at).toLocaleTimeString('en', TIME_OPTIONS) : '';
var ratio = isDefined ? (imgWidth / imgHeight).toPrecision(3) : 0;
var ratio = isDefined ? (width / height).toPrecision(3) : 0;
var size = file.size.pretty;
var tags = file !== null && file !== void 0 && file.tags ? file.tags : {};
var resolution = isDefined ? imgWidth + 'x' + imgHeight : null;
var resolution = isDefined ? width + 'x' + height : null;
var visibility = file.visibility;

@@ -30,4 +36,4 @@ return {

url: url,
imgWidth: imgWidth,
imgHeight: imgHeight,
width: width,
height: height,
ratio: ratio,

@@ -40,4 +46,7 @@ size: size,

mime: mime,
previewUrl: previewUrl
previewUrl: previewUrl,
videoDuration: videoDuration,
videoTranscodingProgress: videoTranscodingProgress,
videoTranscodingStatus: videoTranscodingStatus
};
});

@@ -11,2 +11,4 @@ import getFileExtension from './getFileExtension';

var getItemIcon = function getItemIcon(fileOrFolder, viewType, showFuncAndHeight) {
var _fileOrFolder$meta, _fileOrFolder$meta2;
if (viewType === void 0) {

@@ -35,3 +37,3 @@ viewType = VIEWS_IDS.GRID;

if (link) {
return link.replace('func=proxy', '') + separator + "w=200&force_format=png&doc_page=1";
return link.replace('func=proxy', '') + separator + 'w=200&force_format=png&doc_page=1';
}

@@ -58,2 +60,8 @@ }

var thumbnail = (fileOrFolder === null || fileOrFolder === void 0 ? void 0 : (_fileOrFolder$meta = fileOrFolder.meta) === null || _fileOrFolder$meta === void 0 ? void 0 : _fileOrFolder$meta.video_thumbnail) || (fileOrFolder === null || fileOrFolder === void 0 ? void 0 : (_fileOrFolder$meta2 = fileOrFolder.meta) === null || _fileOrFolder$meta2 === void 0 ? void 0 : _fileOrFolder$meta2.image_thumbnail);
if (thumbnail) {
return thumbnail;
}
if (extension) {

@@ -60,0 +68,0 @@ return FILE_TYPES_AND_ICONS[extension.toLowerCase()] || FILE_TYPES_AND_ICONS._default;

import isImage from './isImage';
import isPDF from './isPDF';
import isOpenedFromAdobe from './isOpenedFromAdobe';
import isSupportedVideo from '../lib/isSupportedVideo';
export default function isPreviewSupported(file) {
// Checking if we could show a preview for this item or not
if (isImage(file) || isPDF(file) && !isOpenedFromAdobe()) {
if (isImage(file) || isPDF(file) && !isOpenedFromAdobe() || isSupportedVideo(file) && !isOpenedFromAdobe()) {
return true;

@@ -8,0 +9,0 @@ }

@@ -6,3 +6,3 @@ {

"types": "types/index.d.ts",
"version": "0.0.0-beta.60",
"version": "0.0.0-beta.61",
"files": [

@@ -15,3 +15,3 @@ "/dist",

"dependencies": {
"@filerobot/icons": "0.0.0-beta.60",
"@filerobot/icons": "0.0.0-beta.61",
"abortcontroller-polyfill": "^1.4.0",

@@ -18,0 +18,0 @@ "lodash.throttle": "^4.1.1"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc