From 6fed0b516229c97ddb17231952bf645175816943 Mon Sep 17 00:00:00 2001 From: Akash Hamirwasia Date: Fri, 21 Oct 2022 23:32:36 +0530 Subject: [PATCH 01/12] Delete FUNDING.yml --- .github/FUNDING.yml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index f4540344..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -custom: ['https://www.buymeacoffee.com/AkashHamirwasia'] From 60e91856fa2ac7275bab3520b84f97d3febf1224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E8=B0=94=E7=9A=84meow?= <42793079+ruoduan-hub@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:19:38 +0800 Subject: [PATCH 02/12] fix: docker-compose now - docker-compose version 1.29.2, build unknown - Linux 5.15.0-1029-oracle #35-Ubuntu SMP Tue Jan 24 15:17:52 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ``` ERROR: The Compose file './docker-compose.yml' is invalid because: services.blaze-server.environment.TRUST_PROXY contains true, which is an invalid type, it should be a string, number, or a null ``` --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3700fa27..409efca1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: context: . dockerfile: ./server/Dockerfile environment: - TRUST_PROXY: true + TRUST_PROXY: 1 ports: - 3030:3030 From 0e6f60979e98f1853a64b2b015f968726fdea714 Mon Sep 17 00:00:00 2001 From: blenderskool Date: Tue, 18 Jul 2023 00:36:16 +0530 Subject: [PATCH 03/12] Migrate to GA4 Universal Analytics has been shut down --- README.md | 4 ++-- client/src/routes/App/layouts/AppLanding/AppLanding.js | 6 ++---- client/src/template.html | 10 +++++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a7e116ce..d7efddb4 100644 --- a/README.md +++ b/README.md @@ -140,8 +140,8 @@ Blaze app can now be accessed at port `8080` :tada: ## Privacy and Analytics - Blaze server does not track or record the files that are being shared both by WebSockets and WebTorrent. - Any user related data like nickname, room names are always stored on device, and are only shared with the server when the user joins a room for file sharing. -- Blaze client uses Google Analytics to record the following: - - [Basic visit data](https://developers.google.com/analytics/devguides/collection/analyticsjs#what_data_does_the_google_analytics_tag_capture) as recorded by [Google Analytics](https://support.google.com/analytics/answer/6004245?ref_topic=2919631) +- Blaze client uses Google Analytics 4 to record the following: + - Part of [Basic visit data](https://support.google.com/analytics/answer/9234069?hl=en) - page views, scrolls and outbound clicks, rest are disabled. - If Blaze PWA is installed on the device, and whether files are shared using share targets. ## Contributing diff --git a/client/src/routes/App/layouts/AppLanding/AppLanding.js b/client/src/routes/App/layouts/AppLanding/AppLanding.js index 9d8e7f08..63638a69 100644 --- a/client/src/routes/App/layouts/AppLanding/AppLanding.js +++ b/client/src/routes/App/layouts/AppLanding/AppLanding.js @@ -1,6 +1,6 @@ import { h } from 'preact'; import { memo } from 'preact/compat'; -import { ArrowDownCircle, Gift, Grid, PieChart, Settings } from 'preact-feather'; +import { ArrowDownCircle, Gift, Grid, Settings } from 'preact-feather'; import { Link } from 'preact-router/match'; import { useContext } from 'preact/hooks'; import { PWAInstall } from '../../contexts/PWAInstall'; @@ -36,9 +36,7 @@ function AppLanding({ children, title, subtitle }) { deferredPrompt.prompt(); const { outcome } = await deferredPrompt.userChoice; - window.ga('send', 'event', { - eventCategory: 'pwa-install', - eventAction: 'promo-shown', + window.gtag('event', 'pwa-install-prompt', { outcome, }); }; diff --git a/client/src/template.html b/client/src/template.html index 77dbe194..d1c0ff8e 100644 --- a/client/src/template.html +++ b/client/src/template.html @@ -35,13 +35,13 @@ + - <% preact.headEnd %> From 8b9e588869253a6d9b755101025fa4c97a27696b Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:42:01 +0200 Subject: [PATCH 04/12] Switch from downloadjs to multi-download --- client/package-lock.json | 6 --- client/package.json | 1 - .../routes/App/FileTransfer/FileTransfer.js | 42 +++++++++++++++---- client/src/utils/fileShare.js | 4 +- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index e1610719..ed979358 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -13,7 +13,6 @@ "classnames": "^2.3.2", "copy-to-clipboard": "^3.3.3", "date-fns": "^2.29.3", - "downloadjs": "^1.4.7", "nanoid": "^3.3.4", "preact": "^10.3.2", "preact-feather": "^4.2.1", @@ -6373,11 +6372,6 @@ "node": ">=12" } }, - "node_modules/downloadjs": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/downloadjs/-/downloadjs-1.4.7.tgz", - "integrity": "sha1-9p+W+UDg0FU9rCkROYZaPNAQHjw=" - }, "node_modules/duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", diff --git a/client/package.json b/client/package.json index e7c9b843..dffc8e21 100644 --- a/client/package.json +++ b/client/package.json @@ -23,7 +23,6 @@ "classnames": "^2.3.2", "copy-to-clipboard": "^3.3.3", "date-fns": "^2.29.3", - "downloadjs": "^1.4.7", "nanoid": "^3.3.4", "preact": "^10.3.2", "preact-feather": "^4.2.1", diff --git a/client/src/routes/App/FileTransfer/FileTransfer.js b/client/src/routes/App/FileTransfer/FileTransfer.js index 727aee96..11679fc1 100644 --- a/client/src/routes/App/FileTransfer/FileTransfer.js +++ b/client/src/routes/App/FileTransfer/FileTransfer.js @@ -1,5 +1,4 @@ import { h, createRef } from 'preact'; -import download from 'downloadjs'; import { route } from 'preact-router'; import { PureComponent, forwardRef, memo } from 'preact/compat'; import { ArrowLeft, CheckCircle, Home, Plus, Image, Film, Box, Music, File, Zap, Share2, Send } from 'preact-feather'; @@ -22,6 +21,35 @@ import roomsDispatch from '../../../reducers/rooms'; import './FileTransfer.scss'; + +// adapted from https://github.com/sindresorhus/multi-download/blob/v4.0.0/index.js +// to take File https://developer.mozilla.org/en-US/docs/Web/API/File +const delay = milliseconds => new Promise(resolve => { + setTimeout(resolve, milliseconds); +}); +const download = async (file) => { + const a = document.createElement('a'); + a.download = file.name; + a.href = URL.createObjectURL(file); + a.style.display = 'none'; + document.body.append(a); + a.click(); + + // Chrome requires the timeout + await delay(100); + a.remove(); +}; +const multiDownload = async (files) => { + if (!files) { + throw new Error('`files` required'); + } + + for (const [index, file] of files.entries()) { + await delay(index * 1000); // eslint-disable-line no-await-in-loop + download(file); + } +} + const CanvasUnwrapped = (props, ref) => { return ; }; @@ -292,17 +320,17 @@ class FileTransfer extends PureComponent { isSelectorEnabled: false, }); }, - onDone: (file, meta) => { + onDone: (files) => { if (file !== undefined) { if (Array.isArray(file)) { - file.forEach(file => { - file.getBlob((err, blob) => download(blob, file.name)); - }); + multiDownload( + // make regular File from webtorrent File https://github.com/webtorrent/webtorrent/blob/v2.4.14/lib/file.js#L7 + files.map(file => new File([file.getBlob()], file.name, {type: file.type})) + ); } else { - download(file, meta.name, meta.type); + download(file); } - } this.resetState(); }, }); diff --git a/client/src/utils/fileShare.js b/client/src/utils/fileShare.js index 056a1971..d3a7e35c 100644 --- a/client/src/utils/fileShare.js +++ b/client/src/utils/fileShare.js @@ -50,7 +50,7 @@ class FileShare { this.socket.listen(constants.FILE_INIT, (data) => { if (data.end) { if (fileParts.length) { - onDone(new Blob(fileParts), metaData.meta[0]); + onDone(new File(fileParts, metaData.meta[0].name, {type: metaData.meta[0].type})); fileParts = []; size = 0; statProg = 0.25; @@ -227,4 +227,4 @@ class FileShare { } -export default FileShare; \ No newline at end of file +export default FileShare; From 72de2fe8fbc8b05a4d8c996d4e4a323fd0945cee Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:59:56 +0200 Subject: [PATCH 05/12] Move to utils/download.js --- .../routes/App/FileTransfer/FileTransfer.js | 30 +------------------ client/src/utils/download.js | 29 ++++++++++++++++++ 2 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 client/src/utils/download.js diff --git a/client/src/routes/App/FileTransfer/FileTransfer.js b/client/src/routes/App/FileTransfer/FileTransfer.js index 11679fc1..3b2d11c7 100644 --- a/client/src/routes/App/FileTransfer/FileTransfer.js +++ b/client/src/routes/App/FileTransfer/FileTransfer.js @@ -16,40 +16,12 @@ import Visualizer from '../../../utils/visualizer'; import formatSize from '../../../utils/formatSize'; import pluralize from '../../../utils/pluralize'; import urls from '../../../utils/urls'; +import { download, multiDownload } from '../../../utils/download'; import constants from '../../../../../common/constants'; import roomsDispatch from '../../../reducers/rooms'; import './FileTransfer.scss'; - -// adapted from https://github.com/sindresorhus/multi-download/blob/v4.0.0/index.js -// to take File https://developer.mozilla.org/en-US/docs/Web/API/File -const delay = milliseconds => new Promise(resolve => { - setTimeout(resolve, milliseconds); -}); -const download = async (file) => { - const a = document.createElement('a'); - a.download = file.name; - a.href = URL.createObjectURL(file); - a.style.display = 'none'; - document.body.append(a); - a.click(); - - // Chrome requires the timeout - await delay(100); - a.remove(); -}; -const multiDownload = async (files) => { - if (!files) { - throw new Error('`files` required'); - } - - for (const [index, file] of files.entries()) { - await delay(index * 1000); // eslint-disable-line no-await-in-loop - download(file); - } -} - const CanvasUnwrapped = (props, ref) => { return ; }; diff --git a/client/src/utils/download.js b/client/src/utils/download.js new file mode 100644 index 00000000..889c195d --- /dev/null +++ b/client/src/utils/download.js @@ -0,0 +1,29 @@ +// adapted from https://github.com/sindresorhus/multi-download/blob/v4.0.0/index.js +// to take File as input https://developer.mozilla.org/en-US/docs/Web/API/File +const delay = milliseconds => new Promise(resolve => { + setTimeout(resolve, milliseconds); +}); + +const download = async (file) => { + const a = document.createElement('a'); + a.download = file.name; + a.href = URL.createObjectURL(file); + a.style.display = 'none'; + document.body.append(a); + a.click(); + + // Chrome requires the timeout + await delay(100); + a.remove(); +}; + +const multiDownload = async (files) => { + if (!files) { + throw new Error('`files` required'); + } + + for (const [index, file] of files.entries()) { + await delay(index * 1000); // eslint-disable-line no-await-in-loop + download(file); + } +} From abe585ad0ec1739b81cbfc7c2c79e1285ba30a4d Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:23:21 +0200 Subject: [PATCH 06/12] Amend comment --- client/src/routes/App/FileTransfer/FileTransfer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/routes/App/FileTransfer/FileTransfer.js b/client/src/routes/App/FileTransfer/FileTransfer.js index 3b2d11c7..af9cfdbf 100644 --- a/client/src/routes/App/FileTransfer/FileTransfer.js +++ b/client/src/routes/App/FileTransfer/FileTransfer.js @@ -296,7 +296,7 @@ class FileTransfer extends PureComponent { if (file !== undefined) { if (Array.isArray(file)) { multiDownload( - // make regular File from webtorrent File https://github.com/webtorrent/webtorrent/blob/v2.4.14/lib/file.js#L7 + // make regular File from webtorrent File https://github.com/webtorrent/webtorrent/blob/v1.9.7/lib/file.js#L13 files.map(file => new File([file.getBlob()], file.name, {type: file.type})) ); } From 9cd46a80a664667026c28e60ac7e9f5f4ea2a9f3 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:05:25 +0200 Subject: [PATCH 07/12] Add URL.revokeObjectURL --- client/src/utils/download.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/utils/download.js b/client/src/utils/download.js index 889c195d..c234b3f6 100644 --- a/client/src/utils/download.js +++ b/client/src/utils/download.js @@ -6,8 +6,9 @@ const delay = milliseconds => new Promise(resolve => { const download = async (file) => { const a = document.createElement('a'); + const url = URL.createObjectURL(file); a.download = file.name; - a.href = URL.createObjectURL(file); + a.href = url; a.style.display = 'none'; document.body.append(a); a.click(); @@ -15,6 +16,8 @@ const download = async (file) => { // Chrome requires the timeout await delay(100); a.remove(); + + URL.revokeObjectURL(url); }; const multiDownload = async (files) => { From b11cee7ef0cc47718a9c71a597e45dee422ff709 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:06:46 +0200 Subject: [PATCH 08/12] Simplify delay behaviour, add JSDoc comments --- client/src/utils/download.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/client/src/utils/download.js b/client/src/utils/download.js index c234b3f6..1fd67393 100644 --- a/client/src/utils/download.js +++ b/client/src/utils/download.js @@ -1,9 +1,17 @@ -// adapted from https://github.com/sindresorhus/multi-download/blob/v4.0.0/index.js +// Adapted from https://github.com/sindresorhus/multi-download/blob/v4.0.0/index.js // to take File as input https://developer.mozilla.org/en-US/docs/Web/API/File + +/** + * Creates a promise that resolves after the specified number of milliseconds + */ const delay = milliseconds => new Promise(resolve => { setTimeout(resolve, milliseconds); }); +/** + * Downloads a single file + * @param file - An instance of the File type representing the file to download + */ const download = async (file) => { const a = document.createElement('a'); const url = URL.createObjectURL(file); @@ -12,21 +20,22 @@ const download = async (file) => { a.style.display = 'none'; document.body.append(a); a.click(); - - // Chrome requires the timeout - await delay(100); + await delay(100); // for Chrome a.remove(); - URL.revokeObjectURL(url); }; +/** + * Initiates multiple file downloads with a constant delay between each one + * @param files - An array of instances of the File type representing the files to download + */ const multiDownload = async (files) => { if (!files) { throw new Error('`files` required'); - } + }; - for (const [index, file] of files.entries()) { - await delay(index * 1000); // eslint-disable-line no-await-in-loop + for (const file of files) { + await delay(1000); download(file); } -} +}; From 89ba32755322f1dade2562bd3d18f3a5ad109ab1 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:19:59 +0200 Subject: [PATCH 09/12] Typo --- client/src/routes/App/FileTransfer/FileTransfer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/routes/App/FileTransfer/FileTransfer.js b/client/src/routes/App/FileTransfer/FileTransfer.js index af9cfdbf..36dd47d5 100644 --- a/client/src/routes/App/FileTransfer/FileTransfer.js +++ b/client/src/routes/App/FileTransfer/FileTransfer.js @@ -293,15 +293,15 @@ class FileTransfer extends PureComponent { }); }, onDone: (files) => { - if (file !== undefined) { - if (Array.isArray(file)) { + if (files !== undefined) { + if (Array.isArray(files)) { multiDownload( // make regular File from webtorrent File https://github.com/webtorrent/webtorrent/blob/v1.9.7/lib/file.js#L13 files.map(file => new File([file.getBlob()], file.name, {type: file.type})) ); } else { - download(file); + download(files); } this.resetState(); }, From 6f5c806e2d0fe2a2796ffc4cb4b464790c113809 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 15 Oct 2024 13:45:48 +0200 Subject: [PATCH 10/12] Fix typo --- client/src/routes/App/FileTransfer/FileTransfer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/routes/App/FileTransfer/FileTransfer.js b/client/src/routes/App/FileTransfer/FileTransfer.js index 36dd47d5..7de56298 100644 --- a/client/src/routes/App/FileTransfer/FileTransfer.js +++ b/client/src/routes/App/FileTransfer/FileTransfer.js @@ -303,6 +303,7 @@ class FileTransfer extends PureComponent { else { download(files); } + } this.resetState(); }, }); From 993e47beefe83302a70272886cf0e646ba024223 Mon Sep 17 00:00:00 2001 From: Akash Hamirwasia Date: Tue, 15 Oct 2024 17:56:21 +0530 Subject: [PATCH 11/12] Fix multi-file downloads for WebTorrent --- .../routes/App/FileTransfer/FileTransfer.js | 16 ++++----------- client/src/utils/download.js | 2 +- client/src/utils/fileShare.js | 20 ++++++++++++++++--- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/client/src/routes/App/FileTransfer/FileTransfer.js b/client/src/routes/App/FileTransfer/FileTransfer.js index 7de56298..b3006296 100644 --- a/client/src/routes/App/FileTransfer/FileTransfer.js +++ b/client/src/routes/App/FileTransfer/FileTransfer.js @@ -16,7 +16,7 @@ import Visualizer from '../../../utils/visualizer'; import formatSize from '../../../utils/formatSize'; import pluralize from '../../../utils/pluralize'; import urls from '../../../utils/urls'; -import { download, multiDownload } from '../../../utils/download'; +import { multiDownload } from '../../../utils/download'; import constants from '../../../../../common/constants'; import roomsDispatch from '../../../reducers/rooms'; @@ -293,17 +293,9 @@ class FileTransfer extends PureComponent { }); }, onDone: (files) => { - if (files !== undefined) { - if (Array.isArray(files)) { - multiDownload( - // make regular File from webtorrent File https://github.com/webtorrent/webtorrent/blob/v1.9.7/lib/file.js#L13 - files.map(file => new File([file.getBlob()], file.name, {type: file.type})) - ); - } - else { - download(files); - } - } + if (files === undefined) return; + + multiDownload(files); this.resetState(); }, }); diff --git a/client/src/utils/download.js b/client/src/utils/download.js index 1fd67393..5056994d 100644 --- a/client/src/utils/download.js +++ b/client/src/utils/download.js @@ -29,7 +29,7 @@ const download = async (file) => { * Initiates multiple file downloads with a constant delay between each one * @param files - An array of instances of the File type representing the files to download */ -const multiDownload = async (files) => { +export const multiDownload = async (files) => { if (!files) { throw new Error('`files` required'); }; diff --git a/client/src/utils/fileShare.js b/client/src/utils/fileShare.js index d3a7e35c..acc5a90a 100644 --- a/client/src/utils/fileShare.js +++ b/client/src/utils/fileShare.js @@ -50,7 +50,9 @@ class FileShare { this.socket.listen(constants.FILE_INIT, (data) => { if (data.end) { if (fileParts.length) { - onDone(new File(fileParts, metaData.meta[0].name, {type: metaData.meta[0].type})); + onDone([ + new File(fileParts, metaData.meta[0].name, {type: metaData.meta[0].type}) + ]); fileParts = []; size = 0; statProg = 0.25; @@ -106,8 +108,20 @@ class FileShare { torrent.on('upload', update); torrent.on('download', update); - torrent.on('done', () => { - onDone(torrent.files); + torrent.on('done', async () => { + const files = await Promise.all( + torrent.files.map( + (file) => + new Promise((resolve, reject) => { + // make regular File from webtorrent File https://github.com/webtorrent/webtorrent/blob/v1.9.7/lib/file.js#L13 + file.getBlob((err, blob) => { + if (err) reject(err); + resolve(new File([blob], file.name, { type: file.type })); + }); + }) + ) + ); + onDone(files); }); } From a6ae197b7c7ddfad85d42db58c3c58f94fd6bbc7 Mon Sep 17 00:00:00 2001 From: Akash Hamirwasia Date: Tue, 15 Oct 2024 22:42:33 +0530 Subject: [PATCH 12/12] Update client/src/utils/download.js Co-authored-by: ddelange <14880945+ddelange@users.noreply.github.com> --- client/src/utils/download.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/utils/download.js b/client/src/utils/download.js index 5056994d..b02c3651 100644 --- a/client/src/utils/download.js +++ b/client/src/utils/download.js @@ -35,7 +35,7 @@ export const multiDownload = async (files) => { }; for (const file of files) { - await delay(1000); download(file); + await delay(1000); } };