Update dependency filesize to v11 (#30380)
* Update dependency filesize to v11 * Update fileSize types Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -117,7 +117,7 @@
|
||||
"emojibase-regex": "15.3.2",
|
||||
"escape-html": "^1.0.3",
|
||||
"file-saver": "^2.0.5",
|
||||
"filesize": "10.1.6",
|
||||
"filesize": "11.0.2",
|
||||
"github-markdown-css": "^5.5.1",
|
||||
"glob-to-regexp": "^0.4.1",
|
||||
"highlight.js": "^11.3.1",
|
||||
|
||||
@@ -7,16 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import {
|
||||
filesize,
|
||||
type FileSizeOptionsArray,
|
||||
type FileSizeOptionsBase,
|
||||
type FileSizeOptionsExponent,
|
||||
type FileSizeOptionsObject,
|
||||
type FileSizeOptionsString,
|
||||
type FileSizeReturnArray,
|
||||
type FileSizeReturnObject,
|
||||
} from "filesize";
|
||||
import { filesize, type FilesizeOptions, type FilesizeReturn } from "filesize";
|
||||
import { type MediaEventContent } from "matrix-js-sdk/src/types";
|
||||
|
||||
import { _t } from "../languageHandler";
|
||||
@@ -27,7 +18,7 @@ export function downloadLabelForFile(content: MediaEventContent, withSize = true
|
||||
if (content.info?.size && withSize) {
|
||||
// If we know the size of the file then add it as human-readable string to the end of the link text
|
||||
// so that the user knows how big a file they are downloading.
|
||||
text += " (" + <string>fileSize(content.info.size, { base: 2, standard: "jedec" }) + ")";
|
||||
text += " (" + fileSize(content.info.size, { base: 2, standard: "jedec" }) + ")";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
@@ -83,18 +74,11 @@ export function presentableTextForFile(
|
||||
// it since it is "ugly", users generally aren't aware what it
|
||||
// means and the type of the attachment can usually be inferred
|
||||
// from the file extension.
|
||||
text += " (" + <string>fileSize(content.info.size, { base: 2, standard: "jedec" }) + ")";
|
||||
text += " (" + fileSize(content.info.size, { base: 2, standard: "jedec" }) + ")";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
type FileSizeOptions =
|
||||
| FileSizeOptionsString
|
||||
| FileSizeOptionsBase
|
||||
| FileSizeOptionsArray
|
||||
| FileSizeOptionsExponent
|
||||
| FileSizeOptionsObject;
|
||||
|
||||
/**
|
||||
* wrapper function to set default values for filesize function
|
||||
*
|
||||
@@ -106,15 +90,7 @@ type FileSizeOptions =
|
||||
* exponent: number;
|
||||
* unit: string;}} formatted file size with unit e.g. 12kB, 12KB
|
||||
*/
|
||||
export function fileSize(byteCount: number, options: FileSizeOptionsString | FileSizeOptionsBase): string;
|
||||
export function fileSize(byteCount: number, options: FileSizeOptionsArray): FileSizeReturnArray;
|
||||
export function fileSize(byteCount: number, options: FileSizeOptionsExponent): number;
|
||||
export function fileSize(byteCount: number, options: FileSizeOptionsObject): FileSizeReturnObject;
|
||||
export function fileSize(byteCount: number): string;
|
||||
export function fileSize(
|
||||
byteCount: number,
|
||||
options?: FileSizeOptions,
|
||||
): string | number | FileSizeReturnArray | FileSizeReturnObject {
|
||||
const defaultOption: FileSizeOptions = { base: 2, standard: "jedec", ...options };
|
||||
return filesize(byteCount, defaultOption);
|
||||
export function fileSize<O extends FilesizeOptions>(byteCount: number, options?: O): FilesizeReturn<O> {
|
||||
const defaultOption = { base: 2, standard: "jedec", ...options } as O;
|
||||
return filesize<O>(byteCount, defaultOption);
|
||||
}
|
||||
|
||||
@@ -8108,10 +8108,10 @@ filelist@^1.0.4:
|
||||
dependencies:
|
||||
minimatch "^5.0.1"
|
||||
|
||||
filesize@10.1.6:
|
||||
version "10.1.6"
|
||||
resolved "https://registry.yarnpkg.com/filesize/-/filesize-10.1.6.tgz#31194da825ac58689c0bce3948f33ce83aabd361"
|
||||
integrity sha512-sJslQKU2uM33qH5nqewAwVB2QgR6w1aMNsYUp3aN5rMRyXEwJGmZvaWzeJFNTOXWlHQyBFCWrdj3fV/fsTOX8w==
|
||||
filesize@11.0.2:
|
||||
version "11.0.2"
|
||||
resolved "https://registry.yarnpkg.com/filesize/-/filesize-11.0.2.tgz#b7771e3836812582ad74b8a10d6eb0dc58c1ceda"
|
||||
integrity sha512-s/iAeeWLk5BschUIpmdrF8RA8lhFZ/xDZgKw1Tan72oGws1/dFGB06nYEiyyssWUfjKNQTNRlrwMVjO9/hvXDw==
|
||||
|
||||
fill-range@^7.1.1:
|
||||
version "7.1.1"
|
||||
|
||||
Reference in New Issue
Block a user