Merge branch 'main' into mouse_trap
This commit is contained in:
commit
b97c08c7a5
|
@ -1 +1,3 @@
|
|||
thirdparty
|
||||
src/worker/ffmpeg.worker.js
|
||||
src/worker/crypto.worker.js
|
||||
src/worker/convert.worker.js
|
|
@ -1,60 +1,58 @@
|
|||
{
|
||||
"root": true,
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true,
|
||||
"node": true
|
||||
"parserOptions": {
|
||||
"project": ["./tsconfig.json"]
|
||||
},
|
||||
"extends": [
|
||||
"plugin:react/recommended",
|
||||
"next/core-web-vitals",
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"google",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
"prettier"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
"ecmaVersion": 12,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"react",
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"plugins": ["@typescript-eslint"],
|
||||
|
||||
"rules": {
|
||||
"indent":"off",
|
||||
"indent": "off",
|
||||
"class-methods-use-this": "off",
|
||||
"react/prop-types": "off",
|
||||
"react/display-name": "off",
|
||||
"react/no-unescaped-entities": "off",
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error"
|
||||
],
|
||||
"@typescript-eslint/no-unused-vars": ["error"],
|
||||
"require-jsdoc": "off",
|
||||
"valid-jsdoc": "off",
|
||||
"max-len": "off",
|
||||
"new-cap": "off",
|
||||
"no-invalid-this": "off",
|
||||
"eqeqeq": "error",
|
||||
"object-curly-spacing": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
"space-before-function-paren": "off",
|
||||
"operator-linebreak":["error","after", { "overrides": { "?": "before", ":": "before" } }]
|
||||
},
|
||||
"settings": {
|
||||
"react": {
|
||||
"version": "detect"
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"JSX": "readonly",
|
||||
"NodeJS": "readonly",
|
||||
"ReadableStreamDefaultController": "readonly"
|
||||
"operator-linebreak": [
|
||||
"error",
|
||||
"after",
|
||||
{ "overrides": { "?": "before", ":": "before" } }
|
||||
],
|
||||
"@typescript-eslint/no-unsafe-member-access": "warn",
|
||||
"@typescript-eslint/no-unsafe-return": "warn",
|
||||
"@typescript-eslint/no-unsafe-assignment": "warn",
|
||||
"@typescript-eslint/no-inferrable-types": "warn",
|
||||
"@typescript-eslint/restrict-template-expressions": "warn",
|
||||
"@typescript-eslint/ban-types": "warn",
|
||||
"@typescript-eslint/no-floating-promises": "warn",
|
||||
"@typescript-eslint/no-unsafe-call": "warn",
|
||||
"@typescript-eslint/require-await": "warn",
|
||||
"@typescript-eslint/restrict-plus-operands": "warn",
|
||||
"@typescript-eslint/no-var-requires": "warn",
|
||||
"@typescript-eslint/no-empty-interface": "warn",
|
||||
"@typescript-eslint/no-misused-promises": "warn",
|
||||
"@typescript-eslint/no-empty-function": "warn",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "warn",
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
|
||||
"react-hooks/rules-of-hooks": "warn",
|
||||
"react-hooks/exhaustive-deps": "warn",
|
||||
"@next/next/no-img-element": "warn",
|
||||
"@typescript-eslint/no-unsafe-argument": "warn"
|
||||
}
|
||||
}
|
||||
|
|
13
.lintstagedrc.js
Normal file
13
.lintstagedrc.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
const path = require('path');
|
||||
|
||||
const buildEslintCommand = (filenames) =>
|
||||
`next lint --fix --file ${filenames
|
||||
.map((f) => path.relative(process.cwd(), f))
|
||||
.join(' --file ')}`;
|
||||
|
||||
const buildPrettierCommand = (filenames) =>
|
||||
`yarn prettier --write --ignore-unknown ${filenames.join(' ')}`;
|
||||
|
||||
module.exports = {
|
||||
'*.{js,jsx,ts,tsx}': [buildEslintCommand, buildPrettierCommand],
|
||||
};
|
|
@ -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,
|
||||
|
|
28
package.json
28
package.json
|
@ -5,7 +5,7 @@
|
|||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"albums": "next dev -p 3002",
|
||||
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
|
||||
"lint": "next lint",
|
||||
"prebuild": "yarn lint",
|
||||
"build": "next build",
|
||||
"postbuild": "next export",
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -76,16 +70,10 @@
|
|||
"@types/react-window-infinite-loader": "^1.0.3",
|
||||
"@types/styled-components": "^5.1.25",
|
||||
"@types/yup": "^0.29.7",
|
||||
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
||||
"@typescript-eslint/parser": "^4.25.0",
|
||||
"eslint": "^7.27.0",
|
||||
"eslint-config-airbnb": "^18.2.1",
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-import": "^2.23.3",
|
||||
"eslint-plugin-jsx-a11y": "^6.4.1",
|
||||
"eslint-plugin-react": "^7.23.2",
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.43.0",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-config-next": "^13.0.4",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"husky": "^7.0.1",
|
||||
"lint-staged": "^11.1.2",
|
||||
"prettier": "2.3.2",
|
||||
|
@ -95,12 +83,6 @@
|
|||
"standard": {
|
||||
"parser": "babel-eslint"
|
||||
},
|
||||
"lint-staged": {
|
||||
"src/**/*.{js,jsx,ts,tsx}": [
|
||||
"eslint --fix",
|
||||
"prettier --write --ignore-unknown"
|
||||
]
|
||||
},
|
||||
"resolutions": {
|
||||
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest"
|
||||
}
|
||||
|
|
|
@ -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();
|
|
@ -39,7 +39,6 @@ import {
|
|||
} from 'utils/file';
|
||||
|
||||
import { updateFileCreationDateInEXIF } from './upload/exifService';
|
||||
import { Metadata } from 'types/upload';
|
||||
import QueueProcessor from './queueProcessor';
|
||||
import { Collection } from 'types/collection';
|
||||
import {
|
||||
|
@ -460,11 +459,7 @@ class ExportService {
|
|||
await this.exportMotionPhoto(fileStream, file, collectionPath);
|
||||
} else {
|
||||
this.saveMediaFile(collectionPath, fileSaveName, fileStream);
|
||||
await this.saveMetadataFile(
|
||||
collectionPath,
|
||||
fileSaveName,
|
||||
file.metadata
|
||||
);
|
||||
await this.saveMetadataFile(collectionPath, fileSaveName, file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -483,11 +478,7 @@ class ExportService {
|
|||
file.id
|
||||
);
|
||||
this.saveMediaFile(collectionPath, imageSaveName, imageStream);
|
||||
await this.saveMetadataFile(
|
||||
collectionPath,
|
||||
imageSaveName,
|
||||
file.metadata
|
||||
);
|
||||
await this.saveMetadataFile(collectionPath, imageSaveName, file);
|
||||
|
||||
const videoStream = generateStreamFromArrayBuffer(motionPhoto.video);
|
||||
const videoSaveName = getUniqueFileSaveName(
|
||||
|
@ -496,11 +487,7 @@ class ExportService {
|
|||
file.id
|
||||
);
|
||||
this.saveMediaFile(collectionPath, videoSaveName, videoStream);
|
||||
await this.saveMetadataFile(
|
||||
collectionPath,
|
||||
videoSaveName,
|
||||
file.metadata
|
||||
);
|
||||
await this.saveMetadataFile(collectionPath, videoSaveName, file);
|
||||
}
|
||||
|
||||
private saveMediaFile(
|
||||
|
@ -516,11 +503,11 @@ class ExportService {
|
|||
private async saveMetadataFile(
|
||||
collectionFolderPath: string,
|
||||
fileSaveName: string,
|
||||
metadata: Metadata
|
||||
file: EnteFile
|
||||
) {
|
||||
await this.electronAPIs.saveFileToDisk(
|
||||
getFileMetadataSavePath(collectionFolderPath, fileSaveName),
|
||||
getGoogleLikeMetadataFile(fileSaveName, metadata)
|
||||
getGoogleLikeMetadataFile(fileSaveName, file)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,15 +128,18 @@ export const dedupe = (files: any[]) => {
|
|||
|
||||
export const getGoogleLikeMetadataFile = (
|
||||
fileSaveName: string,
|
||||
metadata: Metadata
|
||||
file: EnteFile
|
||||
) => {
|
||||
const metadata: Metadata = file.metadata;
|
||||
const creationTime = Math.floor(metadata.creationTime / 1000000);
|
||||
const modificationTime = Math.floor(
|
||||
(metadata.modificationTime ?? metadata.creationTime) / 1000000
|
||||
);
|
||||
const captionValue: string = file?.pubMagicMetadata?.data?.caption;
|
||||
return JSON.stringify(
|
||||
{
|
||||
title: fileSaveName,
|
||||
caption: captionValue,
|
||||
creationTime: {
|
||||
timestamp: creationTime,
|
||||
formatted: formatDate(creationTime * 1000),
|
||||
|
|
|
@ -55,7 +55,8 @@ export function getUnixTimeInMicroSeconds(dateTime: Date) {
|
|||
return null;
|
||||
}
|
||||
const unixTime = dateTime.getTime() * 1000;
|
||||
if (unixTime <= 0) {
|
||||
//ignoring dateTimeString = "0000:00:00 00:00:00";
|
||||
if (unixTime === Date.UTC(0, 0, 0, 0, 0, 0, 0)) {
|
||||
return null;
|
||||
} else {
|
||||
return unixTime;
|
||||
|
|
|
@ -20,12 +20,6 @@
|
|||
"downlevelIteration": true,
|
||||
"incremental": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"src/pages/index.tsx",
|
||||
"configUtil.js"
|
||||
],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue