Skip to content

Commit

Permalink
update @ProtonMail web clients
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimiry committed Dec 8, 2024
1 parent 9a1465c commit dce28d7
Show file tree
Hide file tree
Showing 10 changed files with 373 additions and 152 deletions.
21 changes: 0 additions & 21 deletions patches/protonmail/app-calendar.patch
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,3 @@ index b4d841c7cd..00ce66f767 100644

const container = document.querySelector('.app-root');

diff --git a/applications/calendar/webpack.config.ts b/applications/calendar/webpack.config.ts
index 729c7fc564..8c21b9143e 100644
--- a/applications/calendar/webpack.config.ts
+++ b/applications/calendar/webpack.config.ts
@@ -1,12 +1,12 @@
import { Configuration } from 'webpack';

import getConfig from '@proton/pack/webpack.config';
-import { addDevEntry } from '@proton/pack/webpack/entries';
+import { addLoginEntry } from '@proton/pack/webpack/entries';

const result = (env: any): Configuration => {
const config = getConfig(env);
- if (env.appMode === 'standalone') {
- addDevEntry(config);
+ if (env.appMode === 'standalone') { // keeping original condition, so login page only included for the "mail" app
+ addLoginEntry(config);
}
return config;
};

82 changes: 31 additions & 51 deletions patches/protonmail/app-drive.patch
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,6 @@ index 7ca2da66f3..2a99b061bb 100644

ReactDOM.render(isPublicUrl ? <UrlsApp /> : <App />, document.querySelector('.app-root'));

diff --git a/applications/drive/webpack.config.ts b/applications/drive/webpack.config.ts
index afccc2a4b1..8682856d3a 100644
--- a/applications/drive/webpack.config.ts
+++ b/applications/drive/webpack.config.ts
@@ -2,7 +2,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
import webpack from 'webpack';

import getConfig from '@proton/pack/webpack.config';
-import { addDevEntry, getIndexChunks } from '@proton/pack/webpack/entries';
+import { addLoginEntry, getIndexChunks } from '@proton/pack/webpack/entries';

/**
* There are some specific references to Buffer in the drive application,
@@ -47,8 +47,8 @@ const result = (env: any): webpack.Configuration => {
})
);

- if (env.appMode === 'standalone') {
- addDevEntry(config);
+ if (env.appMode === 'standalone') { // keeping original condition, so login page only included for the "mail" app
+ addLoginEntry(config);
}

return {

diff --git a/applications/drive/src/.htaccess b/applications/drive/src/.htaccess
index b0b25a5fae..11d4e4af0f 100644
--- a/applications/drive/src/.htaccess
Expand All @@ -69,48 +44,53 @@ index b0b25a5fae..11d4e4af0f 100644
AddOutputFilter INCLUDES;DEFLATE svg

diff --git a/applications/drive/src/app/store/_downloads/fileSaver/download.ts b/applications/drive/src/app/store/_downloads/fileSaver/download.ts
index 7483da5f4f..62d7bb7733 100644
index e3a5bd4889..da2217e2f3 100644
--- a/applications/drive/src/app/store/_downloads/fileSaver/download.ts
+++ b/applications/drive/src/app/store/_downloads/fileSaver/download.ts
@@ -13,8 +13,7 @@ import { TransferMeta } from '../../../components/TransferManager/transfer';
@@ -1,6 +1,5 @@
import { WritableStream } from 'web-streams-polyfill';

-import { isIos, isSafari } from '@proton/shared/lib/helpers/browser';
import { stripLeadingAndTrailingSlash } from '@proton/shared/lib/helpers/string';
import { PUBLIC_PATH } from '@proton/shared/lib/webpack.constants';

@@ -15,17 +14,7 @@ let workerWakeupInterval: ReturnType<typeof setInterval>;
* IOS - forces all browsers to use webkit, so same problems as safari in all browsers.
* For them download is done in-memory using blob response.
*/
-export const isUnsupported = () =>
- !('serviceWorker' in navigator) || isSafari() || (isEdge() && !isEdgeChromium()) || isIos();
-export const isUnsupported = () => {
- /* TODO: To be removed after test DRVWEB-4375 */
- if (typeof window !== 'undefined') {
- const isSWForSafariEnabled = 'isSWForSafariEnabled' in window && window.isSWForSafariEnabled;
- if (isSWForSafariEnabled) {
- return !('serviceWorker' in navigator);
- }
- }
- // Original
- return !('serviceWorker' in navigator) || isSafari() || isIos();
-};
+export const isUnsupported = () => !('serviceWorker' in navigator);

// createDownloadIframe opens download URL created in service worker to
// initialize the download in the browser. The response has headers to
@@ -56,21 +55,28 @@ function serviceWorkerKeepAlive() {
@@ -73,6 +62,7 @@ function serviceWorkerKeepAlive() {
}, 10000);
}

+/* <electron-mail-mark> */
export async function initDownloadSW() {
if (isUnsupported()) {
throw new Error('Saving file via download is unsupported by this browser');
}

- await navigator.serviceWorker.register(
- /* webpackChunkName: "downloadSW" */
- new URL('./downloadSW', import.meta.url),
- {
- scope: `/${stripLeadingAndTrailingSlash(PUBLIC_PATH)}`,
- }
- );
+ try {
+ await navigator.serviceWorker.register(
+ /* webpackChunkName: "downloadSW" */
+ new URL('./downloadSW', import.meta.url),
+ {
+ scope: `/${stripLeadingAndTrailingSlash(PUBLIC_PATH)}`,
+ }
+ );
+ } catch (e) {
+ console.error(`Failed to register service worker.`, e.message);
+ throw e;
+ }
@@ -81,7 +71,7 @@ export async function initDownloadSW() {
await navigator.serviceWorker
.register(
/* webpackChunkName: "downloadSW" */
- new URL('./downloadSW', import.meta.url),
+ new URL('./downloadSW', import.meta.url), // electron-mail-mark
{
scope: `/${stripLeadingAndTrailingSlash(PUBLIC_PATH)}`,
}
@@ -107,6 +97,7 @@ export async function initDownloadSW() {

serviceWorkerKeepAlive();
}
Expand Down
28 changes: 9 additions & 19 deletions patches/protonmail/app-mail.patch
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,9 @@ index b4d841c7cd..96d2b5c9b4 100644
const container = document.querySelector('.app-root');

diff --git a/applications/mail/webpack.config.ts b/applications/mail/webpack.config.ts
index 72f0b86274..22c087d99c 100644
index 72f0b86274..68abcf32f9 100644
--- a/applications/mail/webpack.config.ts
+++ b/applications/mail/webpack.config.ts
@@ -5,7 +5,7 @@ import { Configuration, ProvidePlugin } from 'webpack';
import { InjectManifest } from 'workbox-webpack-plugin';

import getConfig from '@proton/pack/webpack.config';
-import { addDevEntry, getIndexChunks, getSupportedEntry, mergeEntry } from '@proton/pack/webpack/entries';
+import { addLoginEntry, getIndexChunks } from '@proton/pack/webpack/entries';

const result = (env: any): Configuration => {
setAutoFreeze(false);
@@ -41,14 +41,6 @@ const result = (env: any): Configuration => {
);
// }
Expand All @@ -53,16 +44,15 @@ index 72f0b86274..22c087d99c 100644
const htmlPlugin = config.plugins.find((plugin): plugin is HtmlWebpackPlugin => {
return plugin instanceof HtmlWebpackPlugin;
});
@@ -58,7 +50,7 @@ const result = (env: any): Configuration => {
@@ -57,7 +49,7 @@ const result = (env: any): Configuration => {
}
const htmlIndex = config.plugins.indexOf(htmlPlugin);

- if (env.appMode === 'standalone') {
- addDevEntry(config);
+ if (env.appMode === 'bundle') { // including login page for the "mail" app
+ addLoginEntry(config);
+ if (env.appMode === 'bundle') { // making "login.html" page included in the root folder
addDevEntry(config);
}

// We keep the order because the other plugins have an impact
@@ -75,19 +67,6 @@ const result = (env: any): Configuration => {
inject: 'body',
})
Expand Down Expand Up @@ -425,18 +415,18 @@ index 2aaa779d3..487f54ff3 100644
};

diff --git a/applications/mail/src/app/components/drawer/MailQuickSettings.tsx b/applications/mail/src/app/components/drawer/MailQuickSettings.tsx
index c7fa985bb1..c7b33cf2f9 100644
index a0158185f3..c9f107441d 100644
--- a/applications/mail/src/app/components/drawer/MailQuickSettings.tsx
+++ b/applications/mail/src/app/components/drawer/MailQuickSettings.tsx
@@ -40,7 +40,6 @@ import { useGetStartedChecklist } from 'proton-mail/containers/onboardingCheckli
@@ -51,7 +51,6 @@ import { useGetStartedChecklist } from 'proton-mail/containers/onboardingCheckli
import useMailModel from 'proton-mail/hooks/useMailModel';

import ClearBrowserDataModal from '../header/ClearBrowserDataModal';
-import MailDefaultHandlerModal from '../header/MailDefaultHandlerModal';
import { useMailOnboardingTelemetry } from '../onboarding/useMailOnboardingTelemetry';

const { OFF, UNSET, SERVER_ONLY } = AI_ASSISTANT_ACCESS;

@@ -378,7 +377,6 @@ const MailQuickSettings = () => {
@@ -417,7 +416,6 @@ const MailQuickSettings = () => {
</Tooltip>
</QuickSettingsButtonSection>

Expand Down
8 changes: 3 additions & 5 deletions patches/protonmail/common-15.patch
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,16 @@ index 55715b89d..c87879ad4 100755
}

diff --git a/packages/pack/webpack/entries.ts b/packages/pack/webpack/entries.ts
index 30db3c5c9f..0a8a32dfba 100644
index 30db3c5c9f..6c7a92bdc7 100644
--- a/packages/pack/webpack/entries.ts
+++ b/packages/pack/webpack/entries.ts
@@ -27,25 +27,15 @@ export const mergeEntry = (originalEntry: any, entry: any) => {
};
@@ -28,24 +28,14 @@ export const mergeEntry = (originalEntry: any, entry: any) => {
};

-export const addDevEntry = (config: any) => {
export const addDevEntry = (config: any) => {
- if (config.mode === 'production') {
- return;
- }
+export const addLoginEntry = (config: any) => {
// @ts-ignore
- config.entry.dev = [require.resolve('@proton/components/containers/app/StandaloneApp.tsx')];
+ config.entry.login = [require.resolve('@proton/components/containers/app/StandaloneApp.tsx')];
Expand Down
8 changes: 3 additions & 5 deletions patches/protonmail/common-16.patch
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,16 @@ index 55715b89d..c87879ad4 100755
}

diff --git a/packages/pack/webpack/entries.ts b/packages/pack/webpack/entries.ts
index 30db3c5c9f..0a8a32dfba 100644
index 30db3c5c9f..6c7a92bdc7 100644
--- a/packages/pack/webpack/entries.ts
+++ b/packages/pack/webpack/entries.ts
@@ -27,25 +27,15 @@ export const mergeEntry = (originalEntry: any, entry: any) => {
};
@@ -28,24 +28,14 @@ export const mergeEntry = (originalEntry: any, entry: any) => {
};

-export const addDevEntry = (config: any) => {
export const addDevEntry = (config: any) => {
- if (config.mode === 'production') {
- return;
- }
+export const addLoginEntry = (config: any) => {
// @ts-ignore
- config.entry.dev = [require.resolve('@proton/components/containers/app/StandaloneApp.tsx')];
+ config.entry.login = [require.resolve('@proton/components/containers/app/StandaloneApp.tsx')];
Expand Down
38 changes: 0 additions & 38 deletions patches/protonmail/link-handler-10.patch

This file was deleted.

16 changes: 8 additions & 8 deletions patches/protonmail/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"proton-mail": [
"common-15.patch",
"constants-13.patch",
"link-handler-10.patch",
"link-handler-11.patch",
"pack-api-arg-5.patch",
"pack-webpack-11.patch",
"product-link-6.patch",
Expand All @@ -21,8 +21,8 @@
"pack-api-arg-5.patch",
"pack-webpack-12.patch",
"product-link-6.patch",
"sentry-22.patch",
"session-storage-8.patch",
"sentry-23.patch",
"session-storage-9.patch",
"url-8.patch",
"drawer-app.patch",
"slug-helper-1.patch",
Expand All @@ -32,7 +32,7 @@
"proton-calendar": [
"common-15.patch",
"constants-13.patch",
"link-handler-10.patch",
"link-handler-11.patch",
"pack-api-arg-5.patch",
"pack-webpack-11.patch",
"product-link-6.patch",
Expand All @@ -45,11 +45,11 @@
"app-calendar.patch"
],
"proton-drive": [
"common-15.patch",
"common-16.patch",
"constants-13.patch",
"link-handler-11.patch",
"pack-api-arg-5.patch",
"pack-webpack-11.patch",
"pack-webpack-12.patch",
"product-link-6.patch",
"sentry-22.patch",
"session-storage-8.patch",
Expand All @@ -66,8 +66,8 @@
"pack-api-arg-5.patch",
"pack-webpack-12.patch",
"product-link-6.patch",
"sentry-22.patch",
"session-storage-8.patch",
"sentry-23.patch",
"session-storage-9.patch",
"url-8.patch",
"drawer-app.patch",
"slug-helper-1.patch",
Expand Down
Loading

0 comments on commit dce28d7

Please sign in to comment.