diff --git a/index.js b/index.js index 5695afb..52a8948 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,2 @@ -import { app as application } from 'electron'; -import { createWindow } from './src/window'; -import { createTray } from './src/tray'; - -const app = application - -function start(){ - createWindow().then((window)=>{ - createTray(window,app) - }) -} - -app.on('ready', start); -app.on('window-all-closed', () => app.quit()); \ No newline at end of file +require = require("esm")(module) +module.exports = require("./main.js") \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..0c08980 --- /dev/null +++ b/main.js @@ -0,0 +1,16 @@ +import { app as application } from 'electron'; +import { createWindow } from './src/window'; +import { createTray } from './src/tray'; + +function init() { + const app = application + + app.on('ready', ()=>{ + createWindow().then((window)=>{ + createTray(window,app) + }) + }); + app.on('window-all-closed', () => app.quit()); +} + +init() \ No newline at end of file diff --git a/package.json b/package.json index 44a8291..1b029b2 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,13 @@ "version": "0.0.1", "description": "What app is this? This surely looks like WhatsApp", "main": "index.js", + "module": "main.js", "repository": "https://github.com/maifeeulasad/WhatApp.git", "author": "maifeeulasad ", "license": "MIT", "private": false, "dependencies": { - "babel-preset-es2015": "^6.24.1", - "babel-register": "^6.26.0" + "esm": "^3.2.25" }, "scripts": { "start": "electron -r babel-register .", @@ -17,6 +17,8 @@ }, "type": "module", "devDependencies": { + "babel-preset-es2015": "^6.24.1", + "babel-register": "^6.26.0", "electron": "^13.1.1", "electron-builder": "^22.10.5" } diff --git a/src/tray.js b/src/tray.js index 54618a0..5becd55 100644 --- a/src/tray.js +++ b/src/tray.js @@ -1,5 +1,5 @@ -const { Tray, Menu} = require('electron'); -const path = require('path'); +import { Tray, Menu } from 'electron' +import * as path from 'path' export function createTray(window, app) { const tray = new Tray(path.join(__dirname, '../resources/icon48.png')) diff --git a/src/window.js b/src/window.js index 19da16c..a252dcc 100644 --- a/src/window.js +++ b/src/window.js @@ -1,12 +1,12 @@ -const { app , screen, BrowserWindow } = require('electron') -const path = require('path'); +import { screen, BrowserWindow } from 'electron' +import * as path from 'path' const url = 'https://web.whatsapp.com/'; const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36'; export function createWindow() { return new Promise(res => { - const window = new BrowserWindow({ + let window = new BrowserWindow({ width: screen.width, height: screen.height, icon:path.join(__dirname, '../resources/icon48.png'), diff --git a/yarn.lock b/yarn.lock index 559f510..ddf67ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1245,6 +1245,11 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +esm@^3.2.25: + version "3.2.25" + resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10" + integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA== + esprima@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"