Merge pull request #777 from ente-io/remove-workbox
remove service worker
This commit is contained in:
commit
263c430979
|
@ -37,11 +37,6 @@ module.exports = {
|
|||
'report-to': ' https://csp-reporter.ente.io/local',
|
||||
},
|
||||
|
||||
WORKBOX_CONFIG: {
|
||||
swSrc: 'src/serviceWorker.js',
|
||||
exclude: [/manifest\.json$/i],
|
||||
},
|
||||
|
||||
ALL_ROUTES: '/(.*)',
|
||||
|
||||
buildCSPHeader: (directives) => ({
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
||||
enabled: process.env.ANALYZE === 'true',
|
||||
});
|
||||
const withWorkbox = require('@ente-io/next-with-workbox');
|
||||
|
||||
const { withSentryConfig } = require('@sentry/nextjs');
|
||||
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
|
||||
|
@ -19,7 +18,6 @@ const {
|
|||
COOP_COEP_HEADERS,
|
||||
WEB_SECURITY_HEADERS,
|
||||
CSP_DIRECTIVES,
|
||||
WORKBOX_CONFIG,
|
||||
ALL_ROUTES,
|
||||
getIsSentryEnabled,
|
||||
} = require('./configUtil');
|
||||
|
@ -30,42 +28,39 @@ const IS_SENTRY_ENABLED = getIsSentryEnabled();
|
|||
|
||||
module.exports = (phase) =>
|
||||
withSentryConfig(
|
||||
withWorkbox(
|
||||
withBundleAnalyzer(
|
||||
withTM({
|
||||
compiler: {
|
||||
styledComponents: {
|
||||
ssr: true,
|
||||
displayName: true,
|
||||
},
|
||||
withBundleAnalyzer(
|
||||
withTM({
|
||||
compiler: {
|
||||
styledComponents: {
|
||||
ssr: true,
|
||||
displayName: true,
|
||||
},
|
||||
env: {
|
||||
SENTRY_RELEASE: GIT_SHA,
|
||||
},
|
||||
workbox: WORKBOX_CONFIG,
|
||||
},
|
||||
env: {
|
||||
SENTRY_RELEASE: GIT_SHA,
|
||||
},
|
||||
|
||||
headers() {
|
||||
return [
|
||||
{
|
||||
// Apply these headers to all routes in your application....
|
||||
source: ALL_ROUTES,
|
||||
headers: convertToNextHeaderFormat({
|
||||
...COOP_COEP_HEADERS,
|
||||
...WEB_SECURITY_HEADERS,
|
||||
...buildCSPHeader(CSP_DIRECTIVES),
|
||||
}),
|
||||
},
|
||||
];
|
||||
},
|
||||
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
|
||||
webpack: (config, { isServer }) => {
|
||||
if (!isServer) {
|
||||
config.resolve.fallback.fs = false;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
})
|
||||
)
|
||||
headers() {
|
||||
return [
|
||||
{
|
||||
// Apply these headers to all routes in your application....
|
||||
source: ALL_ROUTES,
|
||||
headers: convertToNextHeaderFormat({
|
||||
...COOP_COEP_HEADERS,
|
||||
...WEB_SECURITY_HEADERS,
|
||||
...buildCSPHeader(CSP_DIRECTIVES),
|
||||
}),
|
||||
},
|
||||
];
|
||||
},
|
||||
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
|
||||
webpack: (config, { isServer }) => {
|
||||
if (!isServer) {
|
||||
config.resolve.fallback.fs = false;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
})
|
||||
),
|
||||
{
|
||||
release: GIT_SHA,
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@date-io/date-fns": "^2.14.0",
|
||||
"@ente-io/next-with-workbox": "^1.0.3",
|
||||
"@mui/icons-material": "^5.6.2",
|
||||
"@mui/material": "^5.6.2",
|
||||
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest",
|
||||
|
@ -54,11 +53,6 @@
|
|||
"react-window": "^1.8.6",
|
||||
"sanitize-filename": "^1.6.3",
|
||||
"styled-components": "^5.3.5",
|
||||
"workbox-precaching": "^6.1.5",
|
||||
"workbox-recipes": "^6.1.5",
|
||||
"workbox-routing": "^6.1.5",
|
||||
"workbox-strategies": "^6.1.5",
|
||||
"workbox-window": "^6.1.5",
|
||||
"xml-js": "^1.6.11",
|
||||
"yup": "^0.29.3"
|
||||
},
|
||||
|
|
|
@ -8,7 +8,6 @@ import 'photoswipe/dist/photoswipe.css';
|
|||
import 'styles/global.css';
|
||||
import EnteSpinner from 'components/EnteSpinner';
|
||||
import { logError } from '../utils/sentry';
|
||||
// import { Workbox } from 'workbox-window';
|
||||
import { getData, LS_KEYS } from 'utils/storage/localStorage';
|
||||
import HTTPService from 'services/HTTPService';
|
||||
import FlashMessageBar from 'components/FlashMessageBar';
|
||||
|
@ -121,34 +120,6 @@ export default function App({ Component, err }) {
|
|||
const [notificationAttributes, setNotificationAttributes] =
|
||||
useState<NotificationAttributes>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
!('serviceWorker' in navigator) ||
|
||||
process.env.NODE_ENV !== 'production'
|
||||
) {
|
||||
console.warn('Progressive Web App support is disabled');
|
||||
return;
|
||||
}
|
||||
// const wb = new Workbox('sw.js', { scope: '/' });
|
||||
// wb.register();
|
||||
|
||||
if ('serviceWorker' in navigator && !isElectron()) {
|
||||
navigator.serviceWorker.onmessage = (event) => {
|
||||
if (event.data.action === 'upload-files') {
|
||||
const files = event.data.files;
|
||||
setSharedFiles(files);
|
||||
}
|
||||
};
|
||||
navigator.serviceWorker
|
||||
.getRegistrations()
|
||||
.then(function (registrations) {
|
||||
for (const registration of registrations) {
|
||||
registration.unregister();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
HTTPService.getInterceptors().response.use(
|
||||
(resp) => resp,
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
import { precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching';
|
||||
import { registerRoute, setDefaultHandler } from 'workbox-routing';
|
||||
import { NetworkOnly } from 'workbox-strategies';
|
||||
import { pageCache, offlineFallback } from 'workbox-recipes';
|
||||
|
||||
pageCache();
|
||||
|
||||
precacheAndRoute(self.__WB_MANIFEST);
|
||||
cleanupOutdatedCaches();
|
||||
|
||||
registerRoute(
|
||||
'/share-target',
|
||||
async ({ event }) => {
|
||||
event.waitUntil(
|
||||
(async function () {
|
||||
const data = await event.request.formData();
|
||||
const client = await self.clients.get(
|
||||
event.resultingClientId || event.clientId
|
||||
);
|
||||
const files = data.getAll('files');
|
||||
setTimeout(() => {
|
||||
client.postMessage({ files, action: 'upload-files' });
|
||||
}, 1000);
|
||||
})()
|
||||
);
|
||||
return Response.redirect('./');
|
||||
},
|
||||
'POST'
|
||||
);
|
||||
|
||||
// Use a stale-while-revalidate strategy for all other requests.
|
||||
setDefaultHandler(new NetworkOnly());
|
||||
|
||||
offlineFallback();
|
Loading…
Reference in a new issue