diff --git a/package-lock.json b/package-lock.json index 06791bfa0b..11df78369e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,6 @@ "dayjs": "1.11.8", "dompurify": "^2.3.1", "favico.js-slevomat": "^0.3.11", - "filesize": "^7.0.0", "jed": "1.1.1", "lit": "^2.4.0", "localforage-webextensionstorage-driver": "^3.0.0", @@ -5278,11 +5277,11 @@ } }, "node_modules/filesize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/filesize/-/filesize-7.0.0.tgz", - "integrity": "sha512-Wsstw+O1lZ9gVmOI1thyeQvODsaoId2qw14lCqIzUhoHKXX7T2hVpB7BR6SvgodMBgWccrx/y2eyV8L7tDmY6A==", + "version": "10.0.7", + "resolved": "https://registry.npmjs.org/filesize/-/filesize-10.0.7.tgz", + "integrity": "sha512-iMRG7Qo9nayLoU3PNCiLizYtsy4W1ClrapeCwEgtiQelOAOuRJiw4QaLI+sSr8xr901dgHv+EYP2bCusGZgoiA==", "engines": { - "node": ">= 0.4.0" + "node": ">= 10.4.0" } }, "node_modules/fill-range": { @@ -11265,7 +11264,7 @@ "@converse/skeletor": "0.0.8", "dayjs": "1.11.8", "dompurify": "^2.3.1", - "filesize": "^7.0.0", + "filesize": "^10.0.7", "localforage-webextensionstorage-driver": "^3.0.0", "lodash-es": "^4.17.21", "pluggable.js": "3.0.1", diff --git a/package.json b/package.json index 2476615e2f..d88f48980e 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,6 @@ "dayjs": "1.11.8", "dompurify": "^2.3.1", "favico.js-slevomat": "^0.3.11", - "filesize": "^7.0.0", "jed": "1.1.1", "lit": "^2.4.0", "localforage-webextensionstorage-driver": "^3.0.0", diff --git a/src/headless/package.json b/src/headless/package.json index bba2d7c0d3..4444423dc6 100644 --- a/src/headless/package.json +++ b/src/headless/package.json @@ -35,7 +35,7 @@ "@converse/skeletor": "0.0.8", "dayjs": "1.11.8", "dompurify": "^2.3.1", - "filesize": "^7.0.0", + "filesize": "^10.0.7", "localforage-webextensionstorage-driver": "^3.0.0", "lodash-es": "^4.17.21", "pluggable.js": "3.0.1", diff --git a/src/headless/plugins/chat/model.js b/src/headless/plugins/chat/model.js index 96508ee7fb..78f22da801 100644 --- a/src/headless/plugins/chat/model.js +++ b/src/headless/plugins/chat/model.js @@ -1,5 +1,4 @@ import ModelWithContact from './model-with-contact.js'; -import filesize from "filesize"; import isMatch from "lodash-es/isMatch"; import isObject from "lodash-es/isObject"; import log from '@converse/headless/log'; @@ -8,6 +7,7 @@ import { Model } from '@converse/skeletor/src/model.js'; import { TimeoutError } from '../../shared/errors.js'; import { _converse, api, converse } from "../../core.js"; import { debouncedPruneHistory, handleCorrection } from '@converse/headless/shared/chat/utils.js'; +import { filesize } from "filesize"; import { getMediaURLsMetadata } from '@converse/headless/shared/parsers.js'; import { getOpenPromise } from '@converse/openpromise'; import { initStorage } from '@converse/headless/utils/storage.js'; diff --git a/src/headless/shared/api/public.js b/src/headless/shared/api/public.js index adeed037e4..f38bc8f506 100644 --- a/src/headless/shared/api/public.js +++ b/src/headless/shared/api/public.js @@ -11,6 +11,7 @@ import { Collection } from "@converse/skeletor/src/collection"; import { Model } from '@converse/skeletor/src/model.js'; import { Strophe, $build, $iq, $msg, $pres } from 'strophe.js/src/strophe'; import { TimeoutError } from '../errors.js'; +import { filesize } from 'filesize'; import { html } from 'lit'; import { initAppSettings } from '../settings/utils.js'; import { sprintf } from 'sprintf-js'; @@ -200,6 +201,7 @@ export const converse = Object.assign(window.converse || {}, { URI, VERSION_NAME, dayjs, + filesize, html, log, sizzle, diff --git a/src/plugins/chatview/tests/http-file-upload.js b/src/plugins/chatview/tests/http-file-upload.js index f8d1444610..8bbd8f2563 100644 --- a/src/plugins/chatview/tests/http-file-upload.js +++ b/src/plugins/chatview/tests/http-file-upload.js @@ -391,7 +391,7 @@ describe("XEP-0363: HTTP File Upload", function () { const messages = view.querySelectorAll('.message.chat-error'); expect(messages.length).toBe(1); expect(messages[0].textContent.trim()).toBe( - 'The size of your file, my-juliet.jpg, exceeds the maximum allowed by your server, which is 5 MB.'); + 'The size of your file, my-juliet.jpg, exceeds the maximum allowed by your server, which is 5.24 MB.'); })); }); }); @@ -461,7 +461,7 @@ describe("XEP-0363: HTTP File Upload", function () { await u.waitUntil(() => view.querySelector('.chat-content progress').getAttribute('value') === '0.5'); message.set('progress', 1); await u.waitUntil(() => view.querySelector('.chat-content progress').getAttribute('value') === '1'); - expect(view.querySelector('.chat-content .chat-msg__text').textContent).toBe('Uploading file: my-juliet.jpg, 22.91 KB'); + expect(view.querySelector('.chat-content .chat-msg__text').textContent).toBe('Uploading file: my-juliet.jpg, 23.46 kB'); promise.resolve(); }); _converse.connection._dataRecv(mock.createRequest(stanza)); diff --git a/src/shared/chat/templates/file-progress.js b/src/shared/chat/templates/file-progress.js index 5b0726bf28..325b2f92ec 100644 --- a/src/shared/chat/templates/file-progress.js +++ b/src/shared/chat/templates/file-progress.js @@ -1,8 +1,10 @@ import 'shared/avatar/avatar.js'; -import filesize from 'filesize'; import { __ } from 'i18n'; +import { converse } from '@converse/headless/core.js'; import { html } from 'lit'; +const { filesize } = converse.env; + export default (el) => { const i18n_uploading = __('Uploading file:'); const filename = el.model.file.name;