merge main into sync-support

This commit is contained in:
Abhinav 2022-04-19 12:42:15 +05:30
parent 1b43c92365
commit 8fb57a3b88
20 changed files with 932 additions and 1204 deletions

1
.gitignore vendored
View file

@ -1,6 +1,5 @@
node_modules
app
.next/
dist
.vscode
buildingSteps.md

8
.gitmodules vendored
View file

@ -1,8 +0,0 @@
[submodule "src/ui"]
path = src/ui
url = https://github.com/ente-io/bada-frame
branch = recover-failed-imports
[submodule "thirdparty/next-electron-server"]
path = thirdparty/next-electron-server
url = https://github.com/ente-io/next-electron-server
branch = desktop

View file

@ -4,7 +4,7 @@
"version": "1.4.0-alpha8",
"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}",
@ -36,13 +36,10 @@
},
"scripts": {
"postinstall": "electron-builder install-app-deps",
"build-main": "tsc",
"build-ui": "cd src/ui && yarn && yarn build && cd ../../",
"pre-build": "concurrently \"yarn && yarn run build-main\" \"cd src/ui && yarn\"",
"build": "yarn && yarn build-ui && yarn run build-main",
"build": "tsc",
"watch": "tsc -w",
"lint": "eslint -c .eslintrc --ext .ts ./src",
"start": "yarn run pre-build && concurrently \"yarn run watch\" \"electron ./app/main/index.js\" \"cd src/ui && yarn dev\"",
"start": "yarn build && electron ./app/main.js",
"test-release": "yarn build && electron-builder"
},
"author": "ente <code@ente.io>",
@ -50,7 +47,6 @@
"@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-notarize": "^1.2.0",
@ -68,7 +64,6 @@
"electron-reload": "^2.0.0-alpha.1",
"electron-store": "^8.0.1",
"electron-updater": "^4.3.8",
"next-electron-server": "file:./thirdparty/next-electron-server",
"promise-fs": "^2.1.1"
}
}

View file

@ -1,5 +0,0 @@
const PROD_HOST_URL: string = 'ente://app';
const RENDERER_OUTPUT_DIR: string = './src/ui/out';
const FILE_STREAM_CHUNK_SIZE: number = 4 * 1024 * 1024;
export { PROD_HOST_URL, RENDERER_OUTPUT_DIR, FILE_STREAM_CHUNK_SIZE };

4
src/config/index.ts Normal file
View file

@ -0,0 +1,4 @@
const PROD_HOST_URL = 'https://web.ente.io';
const FILE_STREAM_CHUNK_SIZE: number = 4 * 1024 * 1024;
export { PROD_HOST_URL, FILE_STREAM_CHUNK_SIZE };

View file

@ -5,7 +5,6 @@ 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) {
@ -24,7 +23,6 @@ let updateIsAvailable = false;
export const isAppQuitting = (): boolean => {
return appIsQuitting;
};
export const setIsAppQuitting = (value: boolean): void => {
appIsQuitting = value;
};
@ -36,11 +34,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}`);
@ -50,7 +43,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) {

View file

@ -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,
});
}
);
}

1
src/ui

@ -1 +0,0 @@
Subproject commit 7c552acd07a0a5639639ff13094c53adbb7e784b

View file

@ -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 {

View file

@ -1,9 +1,8 @@
import { app, BrowserWindow, nativeImage } from 'electron';
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 {

View file

@ -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';

View file

@ -4,7 +4,7 @@ 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({

View file

@ -1,6 +1,6 @@
import path from 'path';
import * as fs from 'promise-fs';
import { FILE_STREAM_CHUNK_SIZE } from '../../config';
import { FILE_STREAM_CHUNK_SIZE } from '../config';
import { uploadStatusStore } from '../services/store';
import { ElectronFile } from '../types';
@ -26,7 +26,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(

View file

@ -6,10 +6,10 @@
"noImplicitAny": true,
"sourceMap": true,
"outDir": "app",
"baseUrl": ".",
"baseUrl": "./src",
"paths": {
"*": ["node_modules/*"]
}
},
"include": ["src/main/**/*", "src/config.ts"]
"include": ["src/**/*"]
}

2050
yarn.lock

File diff suppressed because it is too large Load diff