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