Skip to content

Commit

Permalink
chore: Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasvr committed Oct 8, 2021
0 parents commit 05ec268
Show file tree
Hide file tree
Showing 13 changed files with 12,143 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = tab
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
16 changes: 16 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": "standard",
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
"indent": ["error", "tab"],
"no-tabs": ["error", { "allowIndentationTabs": true }],
"node/no-callback-literal": "off"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2021 Mathias Rasmussen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ESC Configurator App

Standalone app for [esc-configurator.com](https://esc-configurator.com/)

Main repo at [stylesuxx/esc-configurator](https://github.com/stylesuxx/esc-configurator)

## Note
You can use and install [ESC Configurator](https://esc-configurator.com/)
directly from a supported browser without the need to download anything!

This app is provided as an alternative and should be used as a last resort.

Find latest release [here](https://github.com/mathiasvr/esc-configurator-app/releases/latest).
Binary file added build/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: '@commitlint/config-conventional',
rules: {
'subject-case': [2, 'always', 'sentence-case'],
'body-case': [2, 'always', 'sentence-case']
}
}
86 changes: 86 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
const { app, shell, BrowserWindow, Menu } = require('electron')

app.enableSandbox()

function createWindow () {
const mainWindow = new BrowserWindow({
width: 1200,
height: 800,
minWidth: 900,
minHeight: 600
})

mainWindow.loadURL('https://esc-configurator.com/')

// Prevent navigation in main window
mainWindow.webContents.on('will-navigate', e => {
e.preventDefault()
})

// Open links in user browser
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
if (/https?:\/\//i.test(url)) shell.openExternal(url)
return { action: 'deny' }
})

mainWindow.webContents.session.on('select-serial-port', (event, ports, _, callback) => {
event.preventDefault()

if (ports.length === 0) return

const child = new BrowserWindow({
parent: mainWindow,
modal: true,
show: false,
resizable: false,
width: 600,
height: 300
})

const portNames = ports.map(p => p.displayName || p.portName)

child.loadFile('port-modal/modal.html', { query: { data: JSON.stringify(portNames) } })

child.once('ready-to-show', () => {
child.show()
})

// https://github.com/electron/electron/issues/28215
// child.once('close', () => {
child.webContents.once('close', () => {
const url = new URL(child.webContents.getURL())
const index = parseInt(url.hash.slice(1), 10)
const port = ports[index]
callback(port ? port.portId : '')
})
})
}

app.whenReady().then(() => {
createWindow()

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})

const menu = Menu.buildFromTemplate([
{ role: 'appMenu' },
{ role: 'fileMenu' },
{ role: 'editMenu' },
{ role: 'viewMenu' },
{ role: 'windowMenu' },
{
role: 'help',
submenu: [{
label: 'Learn More',
click: async () => await shell.openExternal('https://github.com/stylesuxx/esc-configurator')
}]
}
])

Menu.setApplicationMenu(menu)
Loading

0 comments on commit 05ec268

Please sign in to comment.