Merge branch 'main' into zip
This commit is contained in:
commit
a738fdf4e4
22 changed files with 976 additions and 1245 deletions
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
|
@ -50,4 +50,5 @@ jobs:
|
|||
API_KEY_ISSUER_ID: ${{ secrets.api_key_issuer_id }}
|
||||
# setry crash reporting token
|
||||
SENTRY_AUTH_TOKEN: ${{secrets.sentry_auth_token}}
|
||||
USE_HARD_LINKS: false
|
||||
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,5 @@
|
|||
node_modules
|
||||
app
|
||||
.next/
|
||||
dist
|
||||
.vscode
|
||||
buildingSteps.md
|
||||
|
|
4
.gitmodules
vendored
4
.gitmodules
vendored
|
@ -1,4 +0,0 @@
|
|||
[submodule "src/renderer"]
|
||||
path = src/renderer
|
||||
url = https://github.com/ente-io/bada-frame
|
||||
branch = release
|
21
package.json
21
package.json
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"name": "ente",
|
||||
"productName": "ente",
|
||||
"version": "1.3.3",
|
||||
"version": "1.4.0-alpha12",
|
||||
"private": true,
|
||||
"description": "Desktop client for ente.io",
|
||||
"main": "app/main/index.js",
|
||||
"main": "app/main.js",
|
||||
"build": {
|
||||
"appId": "io.ente.bhari-frame",
|
||||
"artifactName": "${productName}-${version}.${ext}",
|
||||
|
@ -35,40 +35,33 @@
|
|||
},
|
||||
"scripts": {
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"build-main": "tsc",
|
||||
"build": "tsc",
|
||||
"watch": "tsc -w",
|
||||
"lint": "eslint -c .eslintrc --ext .ts ./src",
|
||||
"pre-build": "concurrently \"yarn && yarn run build-main\" \"cd src/renderer && yarn\"",
|
||||
"start": "yarn run pre-build && concurrently \"yarn run watch\" \"electron ./app/main/index.js\" \"cd src/renderer && yarn dev\"",
|
||||
"build-renderer": "cd src/renderer && yarn && yarn build && cd ../../",
|
||||
"test-release": "yarn && yarn build-renderer && yarn run build-main && electron-builder",
|
||||
"release": "electron-builder -mwl --publish always"
|
||||
"start": "yarn build && electron ./app/main.js",
|
||||
"test-release": "yarn build && electron-builder"
|
||||
},
|
||||
"author": "ente <code@ente.io>",
|
||||
"devDependencies": {
|
||||
"@sentry/cli": "^1.68.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.20.0",
|
||||
"@typescript-eslint/parser": "^4.20.0",
|
||||
"concurrently": "^7.0.0",
|
||||
"electron": "^15.3.0",
|
||||
"electron-builder": "^22.10.5",
|
||||
"electron-builder": "^23.0.3",
|
||||
"electron-builder-notarize": "^1.2.0",
|
||||
"electron-download": "^4.1.1",
|
||||
"electron-reload": "^2.0.0-alpha.1",
|
||||
"eslint": "^7.23.0",
|
||||
"prettier": "2.5.1",
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sentry/electron": "^2.5.1",
|
||||
"@types/mime": "^2.0.3",
|
||||
"@types/node": "^14.14.37",
|
||||
"@types/promise-fs": "^2.1.1",
|
||||
"electron-is-dev": "^2.0.0",
|
||||
"electron-log": "^4.3.5",
|
||||
"electron-reload": "^2.0.0-alpha.1",
|
||||
"electron-store": "^8.0.1",
|
||||
"electron-updater": "^4.3.8",
|
||||
"next-electron-server": "^0.0.8",
|
||||
"node-stream-zip": "^1.15.0",
|
||||
"promise-fs": "^2.1.1"
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
const PROD_HOST_URL: string = 'next://app';
|
||||
const RENDERER_OUTPUT_DIR: string = './src/renderer/out';
|
||||
const FILE_STREAM_CHUNK_SIZE: number = 4 * 1024 * 1024;
|
||||
const GOOGLE_PHOTOS_DIR = 'Takeout/Google Photos/';
|
||||
|
||||
export {
|
||||
PROD_HOST_URL,
|
||||
RENDERER_OUTPUT_DIR,
|
||||
FILE_STREAM_CHUNK_SIZE,
|
||||
GOOGLE_PHOTOS_DIR,
|
||||
};
|
5
src/config/index.ts
Normal file
5
src/config/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
const PROD_HOST_URL = 'https://web.ente.io';
|
||||
const FILE_STREAM_CHUNK_SIZE: number = 4 * 1024 * 1024;
|
||||
const GOOGLE_PHOTOS_DIR = 'Takeout/Google Photos/';
|
||||
|
||||
export { PROD_HOST_URL, FILE_STREAM_CHUNK_SIZE, GOOGLE_PHOTOS_DIR };
|
|
@ -1,14 +1,14 @@
|
|||
import { app, BrowserWindow, Menu, Tray, dialog, nativeImage } from 'electron';
|
||||
import * as path from 'path';
|
||||
import * as isDev from 'electron-is-dev';
|
||||
import AppUpdater from './utils/appUpdater';
|
||||
import { createWindow } from './utils/createWindow';
|
||||
import setupIpcComs from './utils/ipcComms';
|
||||
import { buildContextMenu, buildMenuBar } from './utils/menuUtil';
|
||||
import initSentry from './utils/sentry';
|
||||
import { PROD_HOST_URL, RENDERER_OUTPUT_DIR } from '../config';
|
||||
import { isDev } from './utils/common';
|
||||
|
||||
if (isDev) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const electronReload = require('electron-reload');
|
||||
electronReload(__dirname, {});
|
||||
}
|
||||
|
@ -35,11 +35,6 @@ export const setIsUpdateAvailable = (value: boolean): void => {
|
|||
updateIsAvailable = value;
|
||||
};
|
||||
|
||||
const serveNextAt = require('next-electron-server');
|
||||
serveNextAt(PROD_HOST_URL, {
|
||||
outputDir: RENDERER_OUTPUT_DIR,
|
||||
});
|
||||
|
||||
// Disable error dialogs by overriding
|
||||
dialog.showErrorBox = function (title, content) {
|
||||
console.log(`${title}\n${content}`);
|
||||
|
@ -49,7 +44,6 @@ const gotTheLock = app.requestSingleInstanceLock();
|
|||
if (!gotTheLock) {
|
||||
app.quit();
|
||||
} else {
|
||||
app.commandLine.appendSwitch('enable-features', 'SharedArrayBuffer');
|
||||
app.on('second-instance', () => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (mainWindow) {
|
|
@ -1,23 +0,0 @@
|
|||
import { BrowserWindow } from 'electron';
|
||||
|
||||
function lowerCaseHeaders(responseHeaders: Record<string, string[]>) {
|
||||
const headers: Record<string, string[]> = {};
|
||||
for (const key in responseHeaders) {
|
||||
headers[key.toLowerCase()] = responseHeaders[key];
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
export function addAllowOriginHeader(
|
||||
mainWindow: BrowserWindow
|
||||
) {
|
||||
mainWindow.webContents.session.webRequest.onHeadersReceived(
|
||||
(details, callback) => {
|
||||
details.responseHeaders = lowerCaseHeaders(details.responseHeaders);
|
||||
details.responseHeaders['access-control-allow-origin'] = ['*'];
|
||||
callback({
|
||||
responseHeaders: details.responseHeaders,
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
|
@ -7,8 +7,10 @@ import {
|
|||
setToUploadFiles,
|
||||
updatePendingUploadsFilePaths,
|
||||
getElectronFilesFromGoogleZip,
|
||||
setToUploadCollection,
|
||||
} from './utils/upload';
|
||||
import { logError } from './utils/logging';
|
||||
import { ElectronFile } from './types';
|
||||
|
||||
const { ipcRenderer } = electron;
|
||||
|
||||
|
@ -136,10 +138,10 @@ const showUploadZipDialog = async () => {
|
|||
const filePaths: string[] = await ipcRenderer.invoke(
|
||||
'show-upload-zip-dialog'
|
||||
);
|
||||
const filesList = await Promise.all(
|
||||
filePaths.map(getElectronFilesFromGoogleZip)
|
||||
);
|
||||
const files = filesList.flat();
|
||||
const files: ElectronFile[] = [];
|
||||
for (const filePath of filePaths) {
|
||||
files.push(...(await getElectronFilesFromGoogleZip(filePath)));
|
||||
}
|
||||
return files;
|
||||
} catch (e) {
|
||||
logError(e, 'error while selecting zips');
|
||||
|
@ -171,4 +173,5 @@ windowObject['ElectronAPIs'] = {
|
|||
updatePendingUploadsFilePaths,
|
||||
showUploadZipDialog,
|
||||
getElectronFilesFromGoogleZip,
|
||||
setToUploadCollection,
|
||||
};
|
|
@ -1 +0,0 @@
|
|||
Subproject commit d0bdb2e24bda9c480d69c5c19d1c234c23475be3
|
|
@ -1,7 +1,7 @@
|
|||
import { BrowserWindow, dialog, Tray } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
import log from 'electron-log';
|
||||
import { setIsAppQuitting, setIsUpdateAvailable } from '..';
|
||||
import { setIsAppQuitting, setIsUpdateAvailable } from '../main';
|
||||
import { buildContextMenu } from './menuUtil';
|
||||
|
||||
class AppUpdater {
|
2
src/utils/common.ts
Normal file
2
src/utils/common.ts
Normal file
|
@ -0,0 +1,2 @@
|
|||
import { app } from 'electron';
|
||||
export const isDev = !app.isPackaged;
|
|
@ -1,9 +1,8 @@
|
|||
import { app, BrowserWindow, nativeImage } from 'electron';
|
||||
import * as isDev from 'electron-is-dev';
|
||||
import * as path from 'path';
|
||||
import { isAppQuitting } from '..';
|
||||
import { addAllowOriginHeader } from './cors';
|
||||
import { PROD_HOST_URL } from '../../config';
|
||||
import { isDev } from './common';
|
||||
import { PROD_HOST_URL } from '../config';
|
||||
import { isAppQuitting } from '../main';
|
||||
|
||||
export function createWindow(): BrowserWindow {
|
||||
const appImgPath = isDev
|
||||
|
@ -31,11 +30,9 @@ export function createWindow(): BrowserWindow {
|
|||
});
|
||||
splash.maximize();
|
||||
|
||||
addAllowOriginHeader(mainWindow);
|
||||
|
||||
if (isDev) {
|
||||
splash.loadFile(`../../build/splash.html`);
|
||||
mainWindow.loadURL(PROD_HOST_URL);
|
||||
splash.loadFile(`../build/splash.html`);
|
||||
mainWindow.loadURL('http://localhost:3000');
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools();
|
||||
} else {
|
|
@ -5,7 +5,7 @@ import {
|
|||
BrowserWindow,
|
||||
MenuItemConstructorOptions,
|
||||
} from 'electron';
|
||||
import { isUpdateAvailable, setIsAppQuitting } from '..';
|
||||
import { isUpdateAvailable, setIsAppQuitting } from '../main';
|
||||
import { showUpdateDialog } from './appUpdater';
|
||||
|
||||
const isMac = process.platform === 'darwin';
|
|
@ -1,12 +1,12 @@
|
|||
import * as Sentry from '@sentry/electron/dist/main';
|
||||
|
||||
import * as isDev from 'electron-is-dev';
|
||||
import { keysStore } from '../services/store';
|
||||
import { isDev } from './common';
|
||||
|
||||
const SENTRY_DSN = 'https://e9268b784d1042a7a116f53c58ad2165@sentry.ente.io/5';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const version = require('../../../package.json').version;
|
||||
const version = require('../../package.json').version;
|
||||
|
||||
function initSentry(): void {
|
||||
Sentry.init({
|
|
@ -1,7 +1,7 @@
|
|||
import path from 'path';
|
||||
import StreamZip from 'node-stream-zip';
|
||||
import * as fs from 'promise-fs';
|
||||
import { FILE_STREAM_CHUNK_SIZE, GOOGLE_PHOTOS_DIR } from '../../config';
|
||||
import { FILE_STREAM_CHUNK_SIZE, GOOGLE_PHOTOS_DIR } from '../config';
|
||||
import { uploadStatusStore } from '../services/store';
|
||||
import { ElectronFile } from '../types';
|
||||
|
||||
|
@ -27,7 +27,7 @@ const getFileStream = async (filePath: string) => {
|
|||
let offset = 0;
|
||||
const readableStream = new ReadableStream<Uint8Array>({
|
||||
async pull(controller) {
|
||||
let buff = new Uint8Array(FILE_STREAM_CHUNK_SIZE);
|
||||
const buff = new Uint8Array(FILE_STREAM_CHUNK_SIZE);
|
||||
|
||||
// original types were not working correctly
|
||||
const bytesRead = (await fs.read(
|
||||
|
@ -159,15 +159,15 @@ export async function getElectronFile(filePath: string): Promise<ElectronFile> {
|
|||
};
|
||||
}
|
||||
|
||||
export const setToUploadFiles = (
|
||||
filePaths: string[],
|
||||
collectionName: string
|
||||
) => {
|
||||
export const setToUploadFiles = (filePaths: string[]) => {
|
||||
if (filePaths && filePaths.length > 0) {
|
||||
uploadStatusStore.set('filePaths', filePaths);
|
||||
} else {
|
||||
uploadStatusStore.set('filePaths', []);
|
||||
}
|
||||
};
|
||||
|
||||
export const setToUploadCollection = (collectionName: string) => {
|
||||
if (collectionName) {
|
||||
uploadStatusStore.set('collectionName', collectionName);
|
||||
} else {
|
|
@ -6,10 +6,10 @@
|
|||
"noImplicitAny": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "app",
|
||||
"baseUrl": ".",
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"*": ["node_modules/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/main/**/*", "src/config.ts"]
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue