From 2b17ad5cfa17b1a56e0e4f669bc7948f445c4264 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 1 Apr 2022 15:42:50 +1100 Subject: [PATCH] WIP --- OS.js | 47 ------ background.html | 2 +- dev-app-update.yml.sample | 3 - find_broken_perms.sh | 2 - fix_broken_perms.sh | 4 - index.html | 25 --- package.json | 5 +- preload.js | 282 +++++++++++++++++++-------------- preload.ts | 253 ------------------------------ scripts/esbuild.js | 318 +++++++++++++++++++------------------- ts/data/data.ts | 4 +- ts/mains/main_node.ts | 13 +- ts/node/config.ts | 2 +- ts/node/locale.ts | 2 +- ts/node/spell_check.ts | 2 +- ts/node/tsconfig.json | 6 + tsconfig.json | 2 +- webpack.config.js | 152 ------------------ webpack.config.js.back | 153 ++++++++++++++++++ yarn.lock | 71 ++++++++- 20 files changed, 567 insertions(+), 781 deletions(-) delete mode 100644 OS.js delete mode 100644 dev-app-update.yml.sample delete mode 100755 find_broken_perms.sh delete mode 100755 fix_broken_perms.sh delete mode 100644 index.html delete mode 100644 preload.ts create mode 100644 ts/node/tsconfig.json delete mode 100644 webpack.config.js create mode 100644 webpack.config.js.back diff --git a/OS.js b/OS.js deleted file mode 100644 index a7503986a..000000000 --- a/OS.js +++ /dev/null @@ -1,47 +0,0 @@ -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); -var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); -var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -var OS_exports = {}; -__export(OS_exports, { - isLinux: () => isLinux, - isMacOS: () => isMacOS, - isWindows: () => isWindows -}); -module.exports = __toCommonJS(OS_exports); -var import_lodash = __toESM(require("lodash")); -var import_os = __toESM(require("os")); -var import_semver = __toESM(require("semver")); -const isMacOS = /* @__PURE__ */ __name(() => process.platform === "darwin", "isMacOS"); -const isLinux = /* @__PURE__ */ __name(() => process.platform === "linux", "isLinux"); -const isWindows = /* @__PURE__ */ __name((minVersion) => { - const osRelease = import_os.default.release(); - if (process.platform !== "win32") { - return false; - } - return import_lodash.default.isUndefined(minVersion) ? true : import_semver.default.gte(osRelease, minVersion); -}, "isWindows"); -// Annotate the CommonJS export names for ESM import in node: -0 && (module.exports = { - isLinux, - isMacOS, - isWindows -}); -//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidHMvT1MudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImltcG9ydCBfIGZyb20gJ2xvZGFzaCc7XG5pbXBvcnQgb3MgZnJvbSAnb3MnO1xuaW1wb3J0IHNlbXZlciBmcm9tICdzZW12ZXInO1xuXG5leHBvcnQgY29uc3QgaXNNYWNPUyA9ICgpID0+IHByb2Nlc3MucGxhdGZvcm0gPT09ICdkYXJ3aW4nO1xuZXhwb3J0IGNvbnN0IGlzTGludXggPSAoKSA9PiBwcm9jZXNzLnBsYXRmb3JtID09PSAnbGludXgnO1xuZXhwb3J0IGNvbnN0IGlzV2luZG93cyA9IChtaW5WZXJzaW9uPzogc3RyaW5nKSA9PiB7XG4gIGNvbnN0IG9zUmVsZWFzZSA9IG9zLnJlbGVhc2UoKTtcblxuICBpZiAocHJvY2Vzcy5wbGF0Zm9ybSAhPT0gJ3dpbjMyJykge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuXG4gIHJldHVybiBfLmlzVW5kZWZpbmVkKG1pblZlcnNpb24pID8gdHJ1ZSA6IHNlbXZlci5ndGUob3NSZWxlYXNlLCBtaW5WZXJzaW9uKTtcbn07XG4iXSwKICAibWFwcGluZ3MiOiAiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBLG9CQUFjO0FBQ2QsZ0JBQWU7QUFDZixvQkFBbUI7QUFFWixNQUFNLFVBQVUsNkJBQU0sUUFBUSxhQUFhLFVBQTNCO0FBQ2hCLE1BQU0sVUFBVSw2QkFBTSxRQUFRLGFBQWEsU0FBM0I7QUFDaEIsTUFBTSxZQUFZLHdCQUFDLGVBQXdCO0FBQ2hELFFBQU0sWUFBWSxrQkFBRyxRQUFRO0FBRTdCLE1BQUksUUFBUSxhQUFhLFNBQVM7QUFDaEMsV0FBTztBQUFBLEVBQ1Q7QUFFQSxTQUFPLHNCQUFFLFlBQVksVUFBVSxJQUFJLE9BQU8sc0JBQU8sSUFBSSxXQUFXLFVBQVU7QUFDNUUsR0FSeUI7IiwKICAibmFtZXMiOiBbXQp9Cg== diff --git a/background.html b/background.html index ac9235d9b..dede1180c 100644 --- a/background.html +++ b/background.html @@ -39,6 +39,6 @@ - + diff --git a/dev-app-update.yml.sample b/dev-app-update.yml.sample deleted file mode 100644 index 3b1ea6914..000000000 --- a/dev-app-update.yml.sample +++ /dev/null @@ -1,3 +0,0 @@ -owner: -repo: -provider: github diff --git a/find_broken_perms.sh b/find_broken_perms.sh deleted file mode 100755 index 18e77bbac..000000000 --- a/find_broken_perms.sh +++ /dev/null @@ -1,2 +0,0 @@ -find release/linux-unpacked -type d -not -perm 755 -o -type f -not -perm 644 | xargs stat -find release/win-unpacked -type d -not -perm 755 -o -type f -not -perm 644 | xargs stat diff --git a/fix_broken_perms.sh b/fix_broken_perms.sh deleted file mode 100755 index a48d1f6d8..000000000 --- a/fix_broken_perms.sh +++ /dev/null @@ -1,4 +0,0 @@ -set -e -find release/linux -type d | xargs chmod 755 -find release/linux -type f | xargs chmod 644 -chmod +x release/linux/session-desktop* diff --git a/index.html b/index.html deleted file mode 100644 index 4d92ba0cc..000000000 --- a/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - Session - - - - - - -
- -
- - - diff --git a/package.json b/package.json index 6ae0c4c64..1dde93083 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,12 @@ "name": "Oxen Labs", "email": "team@oxen.io" }, + "repository": { "type": "git", "url": "https://github.com/oxen-io/session-desktop.git" }, - "main": "dist/electron_main.js", + "main": "ts/mains/main_node.js", "scripts": { "postinstall": "yarn patch-package && yarn electron-builder install-app-deps", "start-prod": "cross-env NODE_ENV=dev NODE_APP_INSTANCE=devprod$MULTI electron .", @@ -83,7 +84,7 @@ "nan": "2.14.2", "node-fetch": "2.3.0", "node-sass": "6.0.1", - "os-locale": "6.0.2", + "os-locale": "5.0.0", "p-retry": "^4.2.0", "pify": "3.0.0", "protobufjs": "^6.11.2", diff --git a/preload.js b/preload.js index 33823adf7..cf2f73609 100644 --- a/preload.js +++ b/preload.js @@ -1,23 +1,24 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const electron_1 = require("electron"); -const storage_1 = require("./ts/util/storage"); -const url_1 = __importDefault(require("url")); -const path_1 = __importDefault(require("path")); -const config = url_1.default.parse(window.location.toString(), true).query; +const { app, clipboard, ipcRenderer, webFrame } = require('electron/main'); +const { Storage } = require('./ts/util/storage'); + +const url = require('url'); +const path = require('path'); + +const config = url.parse(window.location.toString(), true).query; const configAny = config; + let title = config.name; if (config.environment !== 'production') { - title += ` - ${config.environment}`; + title += ` - ${config.environment}`; } if (config.appInstance) { - title += ` - ${config.appInstance}`; + title += ` - ${config.appInstance}`; } +// tslint:disable: no-require-imports no-var-requires + global.dcodeIO = global.dcodeIO || {}; global.dcodeIO.ByteBuffer = require('bytebuffer'); + window.platform = process.platform; window.getTitle = () => title; window.getEnvironment = () => configAny.environment; @@ -26,172 +27,225 @@ window.getVersion = () => configAny.version; window.isDev = () => config.environment === 'development'; window.getCommitHash = () => configAny.commitHash; window.getNodeVersion = () => configAny.node_version; + window.sessionFeatureFlags = { - useOnionRequests: true, - useCallMessage: true, + useOnionRequests: true, + useCallMessage: true, }; + window.versionInfo = { - environment: window.getEnvironment(), - version: window.getVersion(), - commitHash: window.getCommitHash(), - appInstance: window.getAppInstance(), + environment: window.getEnvironment(), + version: window.getVersion(), + commitHash: window.getCommitHash(), + appInstance: window.getAppInstance(), }; -const ipc = electron_1.ipcRenderer; + +const ipc = ipcRenderer; const localeMessages = ipc.sendSync('locale-data'); + window.updateZoomFactor = () => { - const zoomFactor = window.getSettingValue('zoom-factor-setting') || 100; - window.setZoomFactor(zoomFactor / 100); + const zoomFactor = window.getSettingValue('zoom-factor-setting') || 100; + window.setZoomFactor(zoomFactor / 100); }; + window.setZoomFactor = number => { - electron_1.webFrame.setZoomFactor(number); + webFrame.setZoomFactor(number); }; -window.setPassword = async (passPhrase, oldPhrase) => new Promise((resolve, reject) => { + +// Set the password for the database +window.setPassword = async (passPhrase, oldPhrase) => + new Promise((resolve, reject) => { ipc.once('set-password-response', (_event, error) => { - if (error) { - reject(error); - return; - } - resolve(undefined); + if (error) { + reject(error); return; + } + resolve(undefined); + return; }); ipc.send('set-password', passPhrase, oldPhrase); -}); -window.setStartInTray = async (startInTray) => new Promise((resolve, reject) => { + }); + +window.setStartInTray = async startInTray => + new Promise((resolve, reject) => { ipc.once('start-in-tray-on-start-response', (_event, error) => { - if (error) { - reject(error); - return; - } - resolve(); + if (error) { + reject(error); return; + } + resolve(); + return; }); ipc.send('start-in-tray-on-start', startInTray); -}); + }); + window.getStartInTray = async () => { - return new Promise(resolve => { - ipc.once('get-start-in-tray-response', (_event, value) => { - resolve(value); - }); - ipc.send('get-start-in-tray'); + return new Promise(resolve => { + ipc.once('get-start-in-tray-response', (_event, value) => { + resolve(value); }); + ipc.send('get-start-in-tray'); + }); }; + window._ = require('lodash'); + +// We never do these in our code, so we'll prevent it everywhere window.open = () => null; +// eslint-disable-next-line no-eval, no-multi-assign window.eval = global.eval = () => null; + window.drawAttention = () => { - ipc.send('draw-attention'); + // window.log.debug('draw attention'); + ipc.send('draw-attention'); }; window.showWindow = () => { - window.log.info('show window'); - ipc.send('show-window'); + window.log.info('show window'); + ipc.send('show-window'); }; + window.setAutoHideMenuBar = autoHide => { - ipc.send('set-auto-hide-menu-bar', autoHide); + ipc.send('set-auto-hide-menu-bar', autoHide); }; window.setMenuBarVisibility = visibility => { - ipc.send('set-menu-bar-visibility', visibility); + ipc.send('set-menu-bar-visibility', visibility); }; + window.restart = () => { - window.log.info('restart'); - ipc.send('restart'); + window.log.info('restart'); + ipc.send('restart'); }; + window.closeAbout = () => { - ipc.send('close-about'); + ipc.send('close-about'); }; window.readyForUpdates = () => { - ipc.send('ready-for-updates'); + ipc.send('ready-for-updates'); }; + ipc.on('get-theme-setting', () => { - const theme = window.Events.getThemeSetting(); - ipc.send('get-success-theme-setting', theme); + const theme = window.Events.getThemeSetting(); + ipc.send('get-success-theme-setting', theme); }); + window.getSettingValue = (settingID, comparisonValue = null) => { - if (settingID === 'media-permissions') { - return window.getMediaPermissions(); - } - else if (settingID === 'call-media-permissions') { - return window.getCallMediaPermissions(); - } - else if (settingID === 'auto-update') { - return window.getAutoUpdateEnabled(); - } - const settingVal = storage_1.Storage.get(settingID); - return comparisonValue ? !!settingVal === comparisonValue : settingVal; -}; + // Comparison value allows you to pull boolean values from any type. + // Eg. window.getSettingValue('theme', 'light') + // returns 'false' when the value is 'dark'. + + // We need to get specific settings from the main process + if (settingID === 'media-permissions') { + return window.getMediaPermissions(); + } else if (settingID === 'call-media-permissions') { + return window.getCallMediaPermissions(); + } else if (settingID === 'auto-update') { + return window.getAutoUpdateEnabled(); + } + + const settingVal = Storage.get(settingID); + return comparisonValue ? !!settingVal === comparisonValue : settingVal; +}; + window.setSettingValue = async (settingID, value) => { - if (settingID === 'auto-update') { - window.setAutoUpdateEnabled(value); - return; - } - await storage_1.Storage.put(settingID, value); -}; + // For auto updating we need to pass the value to the main process + if (settingID === 'auto-update') { + window.setAutoUpdateEnabled(value); + return; + } + + await Storage.put(settingID, value); +}; + window.getMediaPermissions = () => ipc.sendSync('get-media-permissions'); window.setMediaPermissions = value => { - ipc.send('set-media-permissions', !!value); + ipc.send('set-media-permissions', !!value); }; + window.getCallMediaPermissions = () => ipc.sendSync('get-call-media-permissions'); window.setCallMediaPermissions = value => { - ipc.send('set-call-media-permissions', !!value); + ipc.send('set-call-media-permissions', !!value); }; + window.askForMediaAccess = () => { - ipc.send('media-access'); + ipc.send('media-access'); }; + +// Auto update setting window.getAutoUpdateEnabled = () => ipc.sendSync('get-auto-update-setting'); window.setAutoUpdateEnabled = value => { - ipc.send('set-auto-update-setting', !!value); + ipc.send('set-auto-update-setting', !!value); }; + ipc.on('get-ready-for-shutdown', async () => { - const { shutdown } = window.Events || {}; - if (!shutdown) { - window.log.error('preload shutdown handler: shutdown method not found'); - ipc.send('now-ready-for-shutdown'); - return; - } - try { - await shutdown(); - ipc.send('now-ready-for-shutdown'); - } - catch (error) { - ipc.send('now-ready-for-shutdown', error && error.stack ? error.stack : error); - } + const { shutdown } = window.Events || {}; + if (!shutdown) { + window.log.error('preload shutdown handler: shutdown method not found'); + ipc.send('now-ready-for-shutdown'); + return; + } + + try { + await shutdown(); + ipc.send('now-ready-for-shutdown'); + } catch (error) { + ipc.send('now-ready-for-shutdown', error && error.stack ? error.stack : error); + } }); -require("./ts/util/logging"); + +// We pull these dependencies in now, from here, because they have Node.js dependencies + +require('./ts/util/logging'); + if (config.proxyUrl) { - window.log.info('Using provided proxy url'); + window.log.info('Using provided proxy url'); } window.nodeSetImmediate = setImmediate; -const signal_1 = require("./ts/node/signal"); -const i18n_1 = require("./ts/util/i18n"); -window.Signal = (0, signal_1.setupSignal)(); -const util_worker_interface_1 = require("./ts/node/util_worker_interface"); -console.warn('++++++++++++++++++++++++ app', electron_1.app); -const utilWorkerPath = path_1.default.join(electron_1.app.getAppPath(), 'js', 'util_worker.js'); -const utilWorker = new util_worker_interface_1.WorkerInterface(utilWorkerPath, 3 * 60 * 1000); + +const data = require('./ts/data/dataInit'); +const { setupi18n } = require('./ts/util/i18n'); +window.Signal = data.initData(); +const { WorkerInterface } = require('./ts/node/util_worker_interface'); + +// A Worker with a 3 minute timeout + +console.warn('app', require('electron/main').app); +const utilWorkerPath = path.join(app.getAppPath(), 'js', 'util_worker.js'); +const utilWorker = new WorkerInterface(utilWorkerPath, 3 * 60 * 1000); + window.callWorker = (fnName, ...args) => utilWorker.callWorker(fnName, ...args); +// Linux seems to periodically let the event loop stop, so this is a global workaround setInterval(() => { - window.nodeSetImmediate(() => { }); + // tslint:disable-next-line: no-empty + window.nodeSetImmediate(() => {}); }, 1000); + window.React = require('react'); window.ReactDOM = require('react-dom'); -window.clipboard = electron_1.clipboard; + +window.clipboard = clipboard; + window.getSeedNodeList = () => [ - { - url: 'https://storage.seed1.loki.network:4433/', - }, - { - url: 'https://storage.seed3.loki.network:4433/', - }, - { - url: 'https://public.loki.foundation:4433/', - }, + { + url: 'https://storage.seed1.loki.network:4433/', + }, + { + url: 'https://storage.seed3.loki.network:4433/', + }, + { + url: 'https://public.loki.foundation:4433/', + }, ]; + const { locale: localFromEnv } = config; -window.i18n = (0, i18n_1.setupi18n)(localFromEnv, localeMessages); +window.i18n = setupi18n(localFromEnv, localeMessages); + window.addEventListener('contextmenu', e => { - const editable = e?.target.closest('textarea, input, [contenteditable="true"]'); - const link = e?.target.closest('a'); - const selection = Boolean(window?.getSelection()?.toString()); - if (!editable && !selection && !link) { - e.preventDefault(); - } + const editable = (e?.target).closest('textarea, input, [contenteditable="true"]'); + const link = (e?.target).closest('a'); + const selection = Boolean(window?.getSelection()?.toString()); + if (!editable && !selection && !link) { + e.preventDefault(); + } }); + +// Blocking diff --git a/preload.ts b/preload.ts deleted file mode 100644 index 3e9b4063d..000000000 --- a/preload.ts +++ /dev/null @@ -1,253 +0,0 @@ -import { app, clipboard, ipcRenderer, webFrame } from 'electron'; - -import { Storage } from './ts/util/storage'; - -import url from 'url'; -import path from 'path'; - -const config = url.parse(window.location.toString(), true).query; -const configAny = config as any; - -let title = config.name; -if (config.environment !== 'production') { - title += ` - ${config.environment}`; -} -if (config.appInstance) { - title += ` - ${config.appInstance}`; -} -// tslint:disable: no-require-imports no-var-requires - -global.dcodeIO = global.dcodeIO || {}; -global.dcodeIO.ByteBuffer = require('bytebuffer'); - -window.platform = process.platform; -window.getTitle = () => title as string; -window.getEnvironment = () => configAny.environment; -window.getAppInstance = () => configAny.appInstance; -window.getVersion = () => configAny.version; -window.isDev = () => config.environment === 'development'; -window.getCommitHash = () => configAny.commitHash; -window.getNodeVersion = () => configAny.node_version; - -window.sessionFeatureFlags = { - useOnionRequests: true, - useCallMessage: true, -}; - -window.versionInfo = { - environment: window.getEnvironment(), - version: window.getVersion(), - commitHash: window.getCommitHash(), - appInstance: window.getAppInstance(), -}; - -const ipc = ipcRenderer; -const localeMessages = ipc.sendSync('locale-data'); - -window.updateZoomFactor = () => { - const zoomFactor = window.getSettingValue('zoom-factor-setting') || 100; - window.setZoomFactor(zoomFactor / 100); -}; - -window.setZoomFactor = number => { - webFrame.setZoomFactor(number); -}; - -// Set the password for the database -window.setPassword = async (passPhrase: string, oldPhrase: string) => - new Promise((resolve, reject) => { - ipc.once('set-password-response', (_event, error) => { - if (error) { - reject(error); - return; - } - resolve(undefined); - return; - }); - ipc.send('set-password', passPhrase, oldPhrase); - }); - -window.setStartInTray = async startInTray => - new Promise((resolve, reject) => { - ipc.once('start-in-tray-on-start-response', (_event, error) => { - if (error) { - reject(error); - return; - } - resolve(); - return; - }); - ipc.send('start-in-tray-on-start', startInTray); - }); - -window.getStartInTray = async () => { - return new Promise(resolve => { - ipc.once('get-start-in-tray-response', (_event, value) => { - resolve(value); - }); - ipc.send('get-start-in-tray'); - }); -}; - -window._ = require('lodash'); - -// We never do these in our code, so we'll prevent it everywhere -window.open = () => null; -// eslint-disable-next-line no-eval, no-multi-assign -window.eval = global.eval = () => null; - -window.drawAttention = () => { - // window.log.debug('draw attention'); - ipc.send('draw-attention'); -}; -window.showWindow = () => { - window.log.info('show window'); - ipc.send('show-window'); -}; - -window.setAutoHideMenuBar = autoHide => { - ipc.send('set-auto-hide-menu-bar', autoHide); -}; -window.setMenuBarVisibility = visibility => { - ipc.send('set-menu-bar-visibility', visibility); -}; - -window.restart = () => { - window.log.info('restart'); - ipc.send('restart'); -}; - -window.closeAbout = () => { - ipc.send('close-about'); -}; -window.readyForUpdates = () => { - ipc.send('ready-for-updates'); -}; - -ipc.on('get-theme-setting', () => { - const theme = window.Events.getThemeSetting(); - ipc.send('get-success-theme-setting', theme); -}); - -window.getSettingValue = (settingID, comparisonValue = null) => { - // Comparison value allows you to pull boolean values from any type. - // Eg. window.getSettingValue('theme', 'light') - // returns 'false' when the value is 'dark'. - - // We need to get specific settings from the main process - if (settingID === 'media-permissions') { - return window.getMediaPermissions(); - } else if (settingID === 'call-media-permissions') { - return window.getCallMediaPermissions(); - } else if (settingID === 'auto-update') { - return window.getAutoUpdateEnabled(); - } - - const settingVal = Storage.get(settingID); - return comparisonValue ? !!settingVal === comparisonValue : settingVal; -}; - -window.setSettingValue = async (settingID, value) => { - // For auto updating we need to pass the value to the main process - if (settingID === 'auto-update') { - window.setAutoUpdateEnabled(value); - return; - } - - await Storage.put(settingID, value); -}; - -window.getMediaPermissions = () => ipc.sendSync('get-media-permissions'); -window.setMediaPermissions = value => { - ipc.send('set-media-permissions', !!value); -}; - -window.getCallMediaPermissions = () => ipc.sendSync('get-call-media-permissions'); -window.setCallMediaPermissions = value => { - ipc.send('set-call-media-permissions', !!value); -}; - -window.askForMediaAccess = () => { - ipc.send('media-access'); -}; - -// Auto update setting -window.getAutoUpdateEnabled = () => ipc.sendSync('get-auto-update-setting'); -window.setAutoUpdateEnabled = value => { - ipc.send('set-auto-update-setting', !!value); -}; - -ipc.on('get-ready-for-shutdown', async () => { - const { shutdown } = window.Events || {}; - if (!shutdown) { - window.log.error('preload shutdown handler: shutdown method not found'); - ipc.send('now-ready-for-shutdown'); - return; - } - - try { - await shutdown(); - ipc.send('now-ready-for-shutdown'); - } catch (error) { - ipc.send('now-ready-for-shutdown', error && error.stack ? error.stack : error); - } -}); - -// We pull these dependencies in now, from here, because they have Node.js dependencies - -// tslint:disable-next-line: no-import-side-effect -import './ts/util/logging'; // ok - -if (config.proxyUrl) { - window.log.info('Using provided proxy url'); -} -window.nodeSetImmediate = setImmediate; - -import * as data from './ts/data/dataInit'; -import { setupi18n } from './ts/util/i18n'; -console.warn('================ initData', data); -window.Signal = initData(); - -import { WorkerInterface } from './ts/node/util_worker_interface'; -// A Worker with a 3 minute timeout - -const utilWorkerPath = path.join(app.getAppPath(), 'js', 'util_worker.js'); -const utilWorker = new WorkerInterface(utilWorkerPath, 3 * 60 * 1000); - -window.callWorker = (fnName, ...args) => utilWorker.callWorker(fnName, ...args); -// Linux seems to periodically let the event loop stop, so this is a global workaround -setInterval(() => { - // tslint:disable-next-line: no-empty - window.nodeSetImmediate(() => {}); -}, 1000); - -window.React = require('react'); -window.ReactDOM = require('react-dom'); - -window.clipboard = clipboard; - -window.getSeedNodeList = () => [ - { - url: 'https://storage.seed1.loki.network:4433/', - }, - { - url: 'https://storage.seed3.loki.network:4433/', - }, - { - url: 'https://public.loki.foundation:4433/', - }, -]; - -const { locale: localFromEnv } = config; -window.i18n = setupi18n(localFromEnv as string, localeMessages); - -window.addEventListener('contextmenu', e => { - const editable = (e?.target as any).closest('textarea, input, [contenteditable="true"]'); - const link = (e?.target as any).closest('a'); - const selection = Boolean(window?.getSelection()?.toString()); - if (!editable && !selection && !link) { - e.preventDefault(); - } -}); - -// Blocking diff --git a/scripts/esbuild.js b/scripts/esbuild.js index b31de0317..c416f7dbe 100644 --- a/scripts/esbuild.js +++ b/scripts/esbuild.js @@ -1,167 +1,167 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -const esbuild = require('esbuild'); -const path = require('path'); -const glob = require('glob'); - -const ROOT_DIR = path.join(__dirname, '..'); -const DIST_DIR = path.join(ROOT_DIR, 'dist'); - -const watch = process.argv.some(argv => argv === '-w' || argv === '--watch'); -const isProd = process.argv.some(argv => argv === '-prod' || argv === '--prod'); - -const nodeDefaults = { - platform: 'node', - target: 'node16', - sourcemap: isProd ? false : 'inline', - // Otherwise React components get renamed - // See: https://github.com/evanw/esbuild/issues/1147 - keepNames: true, - logLevel: 'info', - watch, -}; - -const defaultBundle = { - ...nodeDefaults, - // define: { - // 'process.env.NODE_ENV': isProd ? '"production"' : '"development"', - // }, - bundle: true, - external: [ - // Native libraries - // 'better-sqlite3', - 'electron', - // 'sass', - // 'bytebuffer', - // 'lodash', - // 'react', - // 'react-dom', - // Things that don't bundle well - // 'backbone', - 'got', - // 'jquery', - 'node-fetch', - // 'proxy-agent', - - 'ip2country', - // 'react-redux', - // 'react-qr-svg', - // 'reselect', - // 'redux', - // '@reduxjs/toolkit', - 'styled-components', - // 'react-contexify', - 'filesize', - 'redux-persist', - 'redux-promise-middleware', - 'emoji-mart', - 'mic-recorder-to-mp3', - // 'react-intersection-observer', - // 'react-h5-audio-player', - 'semver', - 'os', - // 'react-toastify', - 'libsodium-wrappers-sumo', - 'fs-extra', - 'blueimp-load-image', - 'blob-util', - // 'redux-logger', - 'rimraf', - 'better-sqlite3', - 'glob', - 'rc-slider', - // 'react-virtualized', - 'rc-slider', - // 'react-draggable', - // 'react-mentions', - - // Large libraries - // See: https://esbuild.github.io/api/#analyze - 'moment', - ], -}; - -// App, tests, and scripts -esbuild.build({ - ...nodeDefaults, - format: 'cjs', - mainFields: ['browser', 'main'], - entryPoints: glob - .sync('{app,ts}/**/*.{ts,tsx}', { - nodir: true, - root: ROOT_DIR, - }) - .filter(file => !file.endsWith('.d.ts')), - outdir: path.join(DIST_DIR), -}); - -// App, tests, and scripts - -// build main renderer -esbuild.build({ - ...defaultBundle, - format: 'cjs', - platform: 'node', - mainFields: ['browser', 'main', 'module'], - inject: [path.join(ROOT_DIR, 'node_modules', 'jquery', 'dist', 'jquery.min.js')], - entryPoints: ['./ts/mains/main_renderer.ts'], - outfile: path.join(DIST_DIR, 'electron_renderer.js'), -}); - -// build main_node -esbuild.build({ - ...defaultBundle, - format: 'cjs', - mainFields: ['main'], - entryPoints: ['./ts/mains/main_node.ts'], - outfile: path.join(DIST_DIR, 'electron_main.js'), -}); - -// Preload bundle -// eslint-disable-next-line more/no-then -esbuild.buildSync({ - ...defaultBundle, - format: 'cjs', - entryPoints: ['preload.ts'], - outdir: path.join(DIST_DIR), -}); -esbuild.buildSync({ - ...defaultBundle, - entryPoints: [path.join(ROOT_DIR, 'dist', 'preload.js')], - inject: [path.join(ROOT_DIR, 'libtextsecure', 'libsignal-protocol.js')], - outfile: path.join(DIST_DIR, 'preload.bundled.js'), -}); - -// HEIC worker +// // eslint-disable-next-line import/no-extraneous-dependencies +// const esbuild = require('esbuild'); +// const path = require('path'); +// const glob = require('glob'); + +// const ROOT_DIR = path.join(__dirname, '..'); +// const DIST_DIR = path.join(ROOT_DIR, 'dist'); + +// const watch = process.argv.some(argv => argv === '-w' || argv === '--watch'); +// const isProd = process.argv.some(argv => argv === '-prod' || argv === '--prod'); + +// const nodeDefaults = { +// platform: 'node', +// target: 'node16', +// sourcemap: isProd ? false : 'inline', +// // Otherwise React components get renamed +// // See: https://github.com/evanw/esbuild/issues/1147 +// keepNames: true, +// logLevel: 'info', +// watch, +// }; + +// const defaultBundle = { +// ...nodeDefaults, +// // define: { +// // 'process.env.NODE_ENV': isProd ? '"production"' : '"development"', +// // }, +// bundle: true, +// external: [ +// // Native libraries +// // 'better-sqlite3', +// 'electron', +// // 'sass', +// // 'bytebuffer', +// // 'lodash', +// // 'react', +// // 'react-dom', +// // Things that don't bundle well +// // 'backbone', +// 'got', +// // 'jquery', +// 'node-fetch', +// // 'proxy-agent', + +// 'ip2country', +// // 'react-redux', +// // 'react-qr-svg', +// // 'reselect', +// // 'redux', +// // '@reduxjs/toolkit', +// 'styled-components', +// // 'react-contexify', +// 'filesize', +// 'redux-persist', +// 'redux-promise-middleware', +// 'emoji-mart', +// 'mic-recorder-to-mp3', +// // 'react-intersection-observer', +// // 'react-h5-audio-player', +// 'semver', +// 'os', +// // 'react-toastify', +// 'libsodium-wrappers-sumo', +// 'fs-extra', +// 'blueimp-load-image', +// 'blob-util', +// // 'redux-logger', +// 'rimraf', +// 'better-sqlite3', +// 'glob', +// 'rc-slider', +// // 'react-virtualized', +// 'rc-slider', +// // 'react-draggable', +// // 'react-mentions', + +// // Large libraries +// // See: https://esbuild.github.io/api/#analyze +// 'moment', +// ], +// }; + +// // App, tests, and scripts // esbuild.build({ -// ...bundleDefaults, -// entryPoints: [path.join(ROOT_DIR, 'ts', 'workers', 'heicConverterWorker.ts')], -// outfile: path.join(DIST_DIR, 'ts', 'workers', 'heicConverter.bundle.js'), +// ...nodeDefaults, +// format: 'cjs', +// mainFields: ['browser', 'main'], +// entryPoints: glob +// .sync('{app,ts}/**/*.{ts,tsx}', { +// nodir: true, +// root: ROOT_DIR, +// }) +// .filter(file => !file.endsWith('.d.ts')), +// outdir: path.join(DIST_DIR), // }); -// // SQL worker -// const libDir = path.join('..', '..', 'node_modules', 'better-sqlite3'); -// const bindingFile = path.join(libDir, 'build', 'Release', 'better_sqlite3.node'); +// // App, tests, and scripts +// // build main renderer // esbuild.build({ -// ...nodeDefaults, -// bundle: true, +// ...defaultBundle, +// format: 'cjs', +// platform: 'node', +// mainFields: ['browser', 'main', 'module'], +// inject: [path.join(ROOT_DIR, 'node_modules', 'jquery', 'dist', 'jquery.min.js')], +// entryPoints: ['./ts/mains/main_renderer.ts'], +// outfile: path.join(DIST_DIR, 'electron_renderer.js'), +// }); -// plugins: [ -// { -// name: 'bindings', -// setup(build) { -// build.onResolve({ filter: /^bindings$/ }, () => ({ -// path: path.join(ROOT_DIR, 'ts', 'sql', 'mainWorkerBindings.ts'), -// })); - -// build.onResolve({ filter: /^better_sqlite3\.node$/ }, () => ({ -// path: bindingFile, -// external: true, -// })); -// }, -// }, -// ], +// // build main_node +// esbuild.build({ +// ...defaultBundle, +// format: 'cjs', +// mainFields: ['main'], +// entryPoints: ['./ts/mains/main_node.ts'], +// outfile: path.join(DIST_DIR, 'electron_main.js'), +// }); -// entryPoints: [path.join(ROOT_DIR, 'ts', 'sql', 'mainWorker.ts')], -// outfile: path.join(DIST_DIR, 'ts', 'sql', 'mainWorker.bundle.js'), +// // Preload bundle +// // eslint-disable-next-line more/no-then +// esbuild.buildSync({ +// ...defaultBundle, +// format: 'cjs', +// entryPoints: ['preload.ts'], +// outdir: path.join(DIST_DIR), +// }); +// esbuild.buildSync({ +// ...defaultBundle, +// entryPoints: [path.join(ROOT_DIR, 'dist', 'preload.js')], +// inject: [path.join(ROOT_DIR, 'libtextsecure', 'libsignal-protocol.js')], +// outfile: path.join(DIST_DIR, 'preload.bundled.js'), // }); + +// // HEIC worker +// // esbuild.build({ +// // ...bundleDefaults, +// // entryPoints: [path.join(ROOT_DIR, 'ts', 'workers', 'heicConverterWorker.ts')], +// // outfile: path.join(DIST_DIR, 'ts', 'workers', 'heicConverter.bundle.js'), +// // }); + +// // // SQL worker +// // const libDir = path.join('..', '..', 'node_modules', 'better-sqlite3'); +// // const bindingFile = path.join(libDir, 'build', 'Release', 'better_sqlite3.node'); + +// // esbuild.build({ +// // ...nodeDefaults, +// // bundle: true, + +// // plugins: [ +// // { +// // name: 'bindings', +// // setup(build) { +// // build.onResolve({ filter: /^bindings$/ }, () => ({ +// // path: path.join(ROOT_DIR, 'ts', 'sql', 'mainWorkerBindings.ts'), +// // })); + +// // build.onResolve({ filter: /^better_sqlite3\.node$/ }, () => ({ +// // path: bindingFile, +// // external: true, +// // })); +// // }, +// // }, +// // ], + +// // entryPoints: [path.join(ROOT_DIR, 'ts', 'sql', 'mainWorker.ts')], +// // outfile: path.join(DIST_DIR, 'ts', 'sql', 'mainWorker.bundle.js'), +// // }); diff --git a/ts/data/data.ts b/ts/data/data.ts index 2a1a1fce5..590e5962c 100644 --- a/ts/data/data.ts +++ b/ts/data/data.ts @@ -18,9 +18,11 @@ import { ReduxConversationType } from '../state/ducks/conversations'; import { ExpirationTimerOptions } from '../util/expiringMessages'; import { Storage } from '../util/storage'; import { channels } from './channels'; -import { createOrUpdateItem, getItemById } from './channelsItem'; +import { createOrUpdateItem, getAllItems, getItemById, removeItemById } from './channelsItem'; import * as dataInit from './dataInit'; +export { createOrUpdateItem, getAllItems, getItemById, removeItemById }; + const ERASE_SQL_KEY = 'erase-sql-key'; const ERASE_ATTACHMENTS_KEY = 'erase-attachments'; const CLEANUP_ORPHANED_ATTACHMENTS_KEY = 'cleanup-orphaned-attachments'; diff --git a/ts/mains/main_node.ts b/ts/mains/main_node.ts index ecc2821cc..e21414926 100644 --- a/ts/mains/main_node.ts +++ b/ts/mains/main_node.ts @@ -28,6 +28,7 @@ import packageJson from '../../package.json'; // checked - only node setupGlobalErrorHandler(); import electronLocalshortcut from 'electron-localshortcut'; +console; // tslint:disable: no-console @@ -263,11 +264,11 @@ async function createWindow() { fullscreen: false as boolean | undefined, backgroundColor: '#000', webPreferences: { - nodeIntegration: true, + nodeIntegration: false, enableRemoteModule: true, nodeIntegrationInWorker: true, contextIsolation: false, - preload: path.join(__dirname, 'preload.bundled.js'), + preload: path.join(__dirname, '..', '..', 'preload.js'), nativeWindowOpen: true, spellcheck: await getSpellCheckSetting(), }, @@ -367,7 +368,7 @@ async function createWindow() { } }); - await mainWindow.loadURL(prepareURL([__dirname, '../background.html'])); + await mainWindow.loadURL(prepareURL([__dirname, '..', '..', 'background.html'])); if ((process.env.NODE_APP_INSTANCE || '').startsWith('devprod')) { // Open the DevTools. @@ -486,7 +487,7 @@ async function showPasswordWindow() { contextIsolation: false, // sandbox: true, - preload: path.join(__dirname, 'password_preload.js'), + preload: path.join(__dirname, '..', 'password_preload.js'), nativeWindowOpen: true, }, // don't setup icon, the executable one will be used by default @@ -557,7 +558,7 @@ async function showAbout() { nodeIntegration: false, nodeIntegrationInWorker: false, contextIsolation: false, - preload: path.join(__dirname, 'about_preload.js'), + preload: path.join(__dirname, '..', 'about_preload.js'), nativeWindowOpen: true, }, parent: mainWindow, @@ -605,7 +606,7 @@ async function showDebugLogWindow() { nodeIntegration: false, nodeIntegrationInWorker: false, contextIsolation: false, - preload: path.join(__dirname, 'debug_log_preload.js'), + preload: path.join(__dirname, '..', 'debug_log_preload.js'), nativeWindowOpen: true, }, parent: mainWindow, diff --git a/ts/node/config.ts b/ts/node/config.ts index 0936dcc3e..d58739241 100644 --- a/ts/node/config.ts +++ b/ts/node/config.ts @@ -14,7 +14,7 @@ if (electronIsDev) { // Set environment vars to configure node-config before requiring it process.env.NODE_ENV = environment; -process.env.NODE_CONFIG_DIR = path.join(__dirname, '..', 'config'); +process.env.NODE_CONFIG_DIR = path.join(__dirname, '..', '..', 'config'); if (environment === 'production') { // harden production config against the local env diff --git a/ts/node/locale.ts b/ts/node/locale.ts index 73ba234d5..abc59a2bb 100644 --- a/ts/node/locale.ts +++ b/ts/node/locale.ts @@ -13,7 +13,7 @@ function normalizeLocaleName(locale: string) { function getLocaleMessages(locale: string): LocaleMessagesType { const onDiskLocale = locale.replace('-', '_'); - const targetFile = path.join(__dirname, '..', '_locales', onDiskLocale, 'messages.json'); + const targetFile = path.join(__dirname, '..', '..', '_locales', onDiskLocale, 'messages.json'); // tslint:disable-next-line: non-literal-fs-path return JSON.parse(fs.readFileSync(targetFile, 'utf-8')); diff --git a/ts/node/spell_check.ts b/ts/node/spell_check.ts index 352ddb6bf..42dc04eae 100644 --- a/ts/node/spell_check.ts +++ b/ts/node/spell_check.ts @@ -1,7 +1,7 @@ // tslint:disable: no-console import { BrowserWindow, Menu } from 'electron'; -import { osLocaleSync } from 'os-locale'; +import { sync as osLocaleSync } from 'os-locale'; export const setup = (browserWindow: BrowserWindow, messages: any) => { const { session } = browserWindow.webContents; diff --git a/ts/node/tsconfig.json b/ts/node/tsconfig.json new file mode 100644 index 000000000..3df02b6fa --- /dev/null +++ b/ts/node/tsconfig.json @@ -0,0 +1,6 @@ +// { +// "extends": "../tsconfig.json", +// "compilerOptions": { +// "module": "esnext" +// } +// } diff --git a/tsconfig.json b/tsconfig.json index 8ddce822b..8fcf299e7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { // Basic Options - "target": "es2020", // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT' or 'es2020'. + "target": "es6", // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT' or 'es2020'. "module": "commonjs", // Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. "lib": [ "dom", // Required to access `window` diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 48f538eee..000000000 --- a/webpack.config.js +++ /dev/null @@ -1,152 +0,0 @@ -/* eslint-disable class-methods-use-this */ -const path = require('path'); - -const HtmlWebpackPlugin = require('html-webpack-plugin'); - -const optimization = { - nodeEnv: false, - removeAvailableModules: true, - removeEmptyChunks: true, - providedExports: true, - minimize: false, - // minimizer: [new TerserPlugin({ parallel: true })], - // splitChunks: true, -}; - -const EXTERNAL_MODULE = new Set([ - 'backbone', - 'better-sqlite3', - 'fsevents', - 'got', - 'jquery', - 'node-fetch', -]); - -module.exports = [ - { - // bundling mode - - mode: 'development', // mode: 'production', - devtool: false, - - optimization, - - // entry files - resolve: { - extensions: ['.ts', '.tsx', '.js', '.json'], - }, - entry: './ts/mains/main_node.ts', - target: 'electron-main', - module: { - // loaders - - rules: [ - { - test: /\.js$/, - loader: `node-bindings-loader`, - }, - { - test: /\.node$/, - loader: `node-loader`, - }, - { - test: /\.tsx?$/, - include: /ts/, - use: [ - { - loader: 'ts-loader', - options: { - transpileOnly: true, - experimentalWatchApi: true, - }, - }, - ], - exclude: /node_modules/, - }, - ], - }, - // output bundles (location) - - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'electron_main.js', - }, - }, - { - entry: './preload.ts', - mode: 'development', - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'preload.bundled.js', - }, - target: 'electron-main', - resolve: { - extensions: ['.ts', '.tsx', '.js', '.json'], - mainFields: ['browser', 'main'], - }, - externals: [ - ({ request = '' }, callback) => { - if (EXTERNAL_MODULE.has(request)) { - return callback(undefined, `commonjs2 ${request}`); - } - - callback(); - }, - ], - module: { - rules: [ - { - test: /\.tsx?$/, - include: [path.resolve(__dirname), path.resolve(__dirname, 'js')], - exclude: /node_modules/, - - use: [ - { - loader: 'ts-loader', - options: { transpileOnly: true }, - }, - ], - }, - ], - }, - }, - - { - mode: 'development', - entry: './ts/mains/main_renderer.ts', - target: 'electron-renderer', - devtool: false, - resolve: { - extensions: ['.ts', '.tsx', '.js', '.json'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - include: [path.resolve(__dirname, 'ts'), path.resolve(__dirname, 'js')], - exclude: /node_modules/, - - use: [ - { - loader: 'ts-loader', - options: { - transpileOnly: true, - experimentalWatchApi: true, - }, - }, - ], - }, - ], - }, - optimization, - output: { - path: path.resolve(__dirname, 'dist', 'js'), - filename: 'electron_renderer.js', - }, - plugins: [ - new HtmlWebpackPlugin({ - template: './background.html', - }), - ], - }, -]; diff --git a/webpack.config.js.back b/webpack.config.js.back new file mode 100644 index 000000000..865d9c483 --- /dev/null +++ b/webpack.config.js.back @@ -0,0 +1,153 @@ +/* eslint-disable class-methods-use-this */ + +/*const path = require('path'); + +const HtmlWebpackPlugin = require('html-webpack-plugin'); + +const optimization = { + nodeEnv: false, + removeAvailableModules: true, + removeEmptyChunks: true, + providedExports: true, + minimize: false, + // minimizer: [new TerserPlugin({ parallel: true })], + // splitChunks: true, +}; + +const EXTERNAL_MODULE = new Set([ + 'backbone', + 'better-sqlite3', + 'fsevents', + 'got', + 'jquery', + 'node-fetch', +]); + +module.exports = [ + { + // bundling mode + + mode: 'development', // mode: 'production', + devtool: false, + + optimization, + + // entry files + resolve: { + extensions: ['.ts', '.tsx', '.js', '.json'], + }, + entry: './ts/mains/main_node.ts', + target: 'electron-main', + module: { + // loaders + + rules: [ + { + test: /\.js$/, + loader: `node-bindings-loader`, + }, + { + test: /\.node$/, + loader: `node-loader`, + }, + { + test: /\.tsx?$/, + include: /ts/, + use: [ + { + loader: 'ts-loader', + options: { + transpileOnly: true, + experimentalWatchApi: true, + }, + }, + ], + exclude: /node_modules/, + }, + ], + }, + // output bundles (location) + + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'electron_main.js', + }, + }, + // { + // entry: './preload.ts', + // mode: 'development', + // output: { + // path: path.resolve(__dirname, 'dist'), + // filename: 'preload.bundled.js', + // }, + // target: 'electron-main', + // resolve: { + // extensions: ['.ts', '.tsx', '.js', '.json'], + // mainFields: ['browser', 'main'], + // }, + // externals: [ + // ({ request = '' }, callback) => { + // if (EXTERNAL_MODULE.has(request)) { + // return callback(undefined, `commonjs2 ${request}`); + // } + + // callback(); + // }, + // ], + // module: { + // rules: [ + // { + // test: /\.tsx?$/, + // include: [path.resolve(__dirname), path.resolve(__dirname, 'js')], + // exclude: /node_modules/, + + // use: [ + // { + // loader: 'ts-loader', + // options: { transpileOnly: true }, + // }, + // ], + // }, + // ], + // }, + // }, + + // { + // mode: 'development', + // entry: './ts/mains/main_renderer.ts', + // target: 'electron-renderer', + // devtool: false, + // resolve: { + // extensions: ['.ts', '.tsx', '.js', '.json'], + // }, + // module: { + // rules: [ + // { + // test: /\.tsx?$/, + // include: [path.resolve(__dirname, 'ts'), path.resolve(__dirname, 'js')], + // exclude: /node_modules/, + + // use: [ + // { + // loader: 'ts-loader', + // options: { + // transpileOnly: true, + // experimentalWatchApi: true, + // }, + // }, + // ], + // }, + // ], + // }, + // optimization, + // output: { + // path: path.resolve(__dirname, 'dist', 'js'), + // filename: 'electron_renderer.js', + // }, + // plugins: [ + // new HtmlWebpackPlugin({ + // template: './background.html', + // }), + // ], + // }, +]; diff --git a/yarn.lock b/yarn.lock index 73d41804f..9b028fa04 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3546,6 +3546,21 @@ events@^3.2.0: resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== +execa@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" + integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA== + dependencies: + cross-spawn "^7.0.0" + get-stream "^5.0.0" + human-signals "^1.1.1" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.0" + onetime "^5.1.0" + signal-exit "^3.0.2" + strip-final-newline "^2.0.0" + execa@^5.0.0: version "5.1.1" resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" @@ -3966,6 +3981,13 @@ get-stream@^4.1.0: dependencies: pump "^3.0.0" +get-stream@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" + integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== + dependencies: + pump "^3.0.0" + get-stream@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.1.0.tgz#01203cdc92597f9b909067c3e656cc1f4d3c4dc9" @@ -4449,6 +4471,11 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" +human-signals@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" + integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== + human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" @@ -5060,7 +5087,7 @@ lazy-val@^1.0.4: resolved "https://registry.yarnpkg.com/lazy-val/-/lazy-val-1.0.4.tgz#882636a7245c2cfe6e0a4e3ba6c5d68a137e5c65" integrity sha512-u93kb2fPbIrfzBuLjZE+w+fJbUUMhNDXxNmMfaqNgpfQf1CO5ZSe2LfsnBqVAk7i/2NF48OSoRj+Xe2VT+lE8Q== -lcid@^3.1.1: +lcid@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/lcid/-/lcid-3.1.1.tgz#9030ec479a058fc36b5e8243ebaac8b6ac582fd0" integrity sha512-M6T051+5QCGLBQb8id3hdvIW8+zeFV2FyBGFS9IEK5H9Wt4MueD4bW1eWikpHgZp+5xR3l5c8pZUkQsIA0BFZg== @@ -5281,6 +5308,13 @@ make-dir@^3.0.0: dependencies: semver "^6.0.0" +map-age-cleaner@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" + integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== + dependencies: + p-defer "^1.0.0" + map-obj@^1.0.0, map-obj@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" @@ -5308,6 +5342,15 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= +mem@^5.0.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/mem/-/mem-5.1.1.tgz#7059b67bf9ac2c924c9f1cff7155a064394adfb3" + integrity sha512-qvwipnozMohxLXG1pOqoLiZKNkC4r4qqRucSoDwXowsNGDSULiqFTRUF05vcZWnwJSG22qTsynQhxbaMtnX9gw== + dependencies: + map-age-cleaner "^0.1.3" + mimic-fn "^2.1.0" + p-is-promise "^2.1.0" + meow@^3.3.0: version "3.7.0" resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" @@ -5785,7 +5828,7 @@ npm-conf@^1.1.3: config-chain "^1.1.11" pify "^3.0.0" -npm-run-path@^4.0.1: +npm-run-path@^4.0.0, npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== @@ -5860,7 +5903,7 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" -onetime@^5.1.2: +onetime@^5.1.0, onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== @@ -5901,12 +5944,14 @@ os-homedir@1.0.2, os-homedir@^1.0.0: resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= -os-locale@6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-6.0.2.tgz#2e5122600f48cd9b846524c07f898db1c596bf20" - integrity sha512-qIb8bzRqaN/vVqEYZ7lTAg6PonskO7xOmM7OClD28F6eFa4s5XGe4bGpHUHMoCHbNNuR0pDYFeSLiW5bnjWXIA== +os-locale@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-5.0.0.tgz#6d26c1d95b6597c5d5317bf5fba37eccec3672e0" + integrity sha512-tqZcNEDAIZKBEPnHPlVDvKrp7NzgLi7jRmhKiUoa2NUmhl13FtkAGLUVR+ZsYvApBQdBfYm43A4tXXQ4IrYLBA== dependencies: - lcid "^3.1.1" + execa "^4.0.0" + lcid "^3.0.0" + mem "^5.0.0" os-tmpdir@^1.0.0, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: version "1.0.2" @@ -5926,6 +5971,16 @@ p-cancelable@^1.0.0: resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc" integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw== +p-defer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" + integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= + +p-is-promise@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e" + integrity sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg== + p-limit@^1.1.0: version "1.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8"