From 28d37d578a724b7425d5a72d239a960d3ee2b85f Mon Sep 17 00:00:00 2001
From: khlam <4841220+khlam@users.noreply.github.com>
Date: Sat, 19 Dec 2020 13:24:59 -0800
Subject: [PATCH 1/3] 0.4.4; fix #5
---
main.js | 8 +++++++-
package-lock.json | 19 ++++++++++---------
package.json | 4 ++--
views/css/settingsStyle.css | 6 ++++--
views/settings.html | 2 +-
5 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/main.js b/main.js
index 3d69ba0..d74e430 100644
--- a/main.js
+++ b/main.js
@@ -109,7 +109,9 @@ function createSettingsWindow() {
settingsWindow = new BrowserWindow({
width: 700,
height: 400,
+ show: true,
resizable: false,
+ alwaysOnTop:true,
icon: './views/assets/icon.ico',
webPreferences: {
preload: path.join(__dirname, 'src/settingsLoad.js'),
@@ -401,7 +403,11 @@ ipcMain.on('asynchronous-message', (event, _data) => {
isChangingPTTKey = true
console.log("waiting for user to rebind")
if (settingsWindow && isChangingPTTKey) {
+
restartioHook().then(v => {
+
+ mainWindow.blur()
+
ioHook.once('keydown', event => {
if (settingsWindow && isChangingPTTKey) {
console.log("rebind success")
@@ -414,7 +420,7 @@ ipcMain.on('asynchronous-message', (event, _data) => {
}
})
- // If user uses mouse button for PTT, ignore mouse 1
+ // Ignore using left click (mouse1)
ioHook.once('mousedown', event => {
if (settingsWindow && isChangingPTTKey && event.button !== 1) {
console.log("rebind success")
diff --git a/package-lock.json b/package-lock.json
index ddbd21f..6a86293 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,17 +1,17 @@
{
"name": "discordsandbox",
- "version": "0.4.3",
+ "version": "0.4.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "discordsandbox",
- "version": "0.4.3",
+ "version": "0.4.4",
"hasInstallScript": true,
"license": "GNU GENERAL PUBLIC LICENSE Version 3",
"dependencies": {
"chokidar": "^3.3.1",
- "iohook": "^0.6.6"
+ "iohook": "^0.7.2"
},
"devDependencies": {
"electron": "^7.2.4",
@@ -1764,10 +1764,11 @@
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
},
"node_modules/iohook": {
- "version": "0.6.6",
- "resolved": "https://registry.npmjs.org/iohook/-/iohook-0.6.6.tgz",
- "integrity": "sha512-mlKH2mx4mKTsZF+RKpEac1GU/ueAhroFTcEI9jrM35ig2xP/uMSwq2us32jJQ6Wepp1PP3n1Ekqpfdbm2U9ulQ==",
+ "version": "0.7.2",
+ "resolved": "https://registry.npmjs.org/iohook/-/iohook-0.7.2.tgz",
+ "integrity": "sha512-PObMWA3Cx+y1s6Xu6EssuzzfW4bP2HgPsss73ELOSLCH1HEW1RnY/pkrqqVwZIu17uKKqtA6IACBtiTHFT/xXw==",
"hasInstallScript": true,
+ "license": "MIT",
"dependencies": {
"bindings": "^1.3.0",
"node-abi": "^2.4.0",
@@ -5254,9 +5255,9 @@
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
},
"iohook": {
- "version": "0.6.6",
- "resolved": "https://registry.npmjs.org/iohook/-/iohook-0.6.6.tgz",
- "integrity": "sha512-mlKH2mx4mKTsZF+RKpEac1GU/ueAhroFTcEI9jrM35ig2xP/uMSwq2us32jJQ6Wepp1PP3n1Ekqpfdbm2U9ulQ==",
+ "version": "0.7.2",
+ "resolved": "https://registry.npmjs.org/iohook/-/iohook-0.7.2.tgz",
+ "integrity": "sha512-PObMWA3Cx+y1s6Xu6EssuzzfW4bP2HgPsss73ELOSLCH1HEW1RnY/pkrqqVwZIu17uKKqtA6IACBtiTHFT/xXw==",
"requires": {
"bindings": "^1.3.0",
"node-abi": "^2.4.0",
diff --git a/package.json b/package.json
index 1f965d0..08116a1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "discordsandbox",
- "version": "0.4.3",
+ "version": "0.4.4",
"description": "Discord Sandboxed",
"main": "main.js",
"scripts": {
@@ -23,7 +23,7 @@
},
"dependencies": {
"chokidar": "^3.3.1",
- "iohook": "^0.6.6"
+ "iohook": "^0.7.2"
},
"iohook": {
"targets": [
diff --git a/views/css/settingsStyle.css b/views/css/settingsStyle.css
index 122f744..9a89546 100644
--- a/views/css/settingsStyle.css
+++ b/views/css/settingsStyle.css
@@ -10,6 +10,8 @@ html, body{
color: #FFFFFF;
}
-#niceButton {
- background-color: rgb(255, 59, 48);
+.niceButton {
+ margin: 10px;
+ color: #FFFFFF;
+ background-color: #000000;
}
\ No newline at end of file
diff --git a/views/settings.html b/views/settings.html
index 53c0264..498369f 100644
--- a/views/settings.html
+++ b/views/settings.html
@@ -36,7 +36,7 @@
Push to Talk Key |
-
+ loading...
|
From 9b82337bf6cf60f2800c2fc00f6a634f6f6004da Mon Sep 17 00:00:00 2001
From: khlam <4841220+khlam@users.noreply.github.com>
Date: Sun, 20 Dec 2020 16:54:23 -0800
Subject: [PATCH 2/3] 1.0.0; Fix config.json and directory not getting created.
Now using github actions to build and publish releases.
---
.github/workflows/build-release.yml | 80 +++++++++++++++++++++++++++++
appveyor.yml | 39 --------------
main.js | 26 +++++++---
package-lock.json | 12 +++++
package.json | 3 +-
src/config.js | 57 +++++++++++---------
6 files changed, 146 insertions(+), 71 deletions(-)
create mode 100644 .github/workflows/build-release.yml
delete mode 100644 appveyor.yml
diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml
new file mode 100644
index 0000000..389daf6
--- /dev/null
+++ b/.github/workflows/build-release.yml
@@ -0,0 +1,80 @@
+name: build-release
+
+on:
+ push:
+ branches: [ master, dev]
+
+jobs:
+ release:
+ runs-on: ${{ matrix.os }}
+ if: "!contains(github.event.head_commit.message, '[skip build]')"
+
+ strategy:
+ matrix:
+ os: [windows-latest]
+
+ steps:
+ - name: Check out Git repository
+ uses: actions/checkout@v1
+
+ - name: Install Node.js
+ uses: actions/setup-node@v1
+ with:
+ node-version: 15.4.0
+
+ - name: Get Version
+ run: |
+ echo "VERSION=$(echo $(node -p "require(\"./package.json\").version"))" >> $GITHUB_ENV
+ shell: bash
+
+ - name: Label as Nightly
+ if: "endsWith(github.ref, 'dev')"
+ run: |
+ echo "LABEL=$(echo 'nightly')" >> $GITHUB_ENV
+ echo "PRERELEASE=$(echo true)" >> $GITHUB_ENV
+ shell: bash
+
+ - name: Label as Stable
+ if: "endsWith(github.ref, 'master')"
+ run: |
+ echo "LABEL=stable" >> $GITHUB_ENV
+ echo "PRERELEASE=$(echo false)" >> $GITHUB_ENV
+ shell: bash
+
+ - name: Label Release
+ run: echo "RELEASELABEL=$(echo $VERSION-$LABEL)" >> $GITHUB_ENV
+ shell: bash
+
+ - name: Get Zip Name
+ run: echo "ZIPNAME=$(echo DiscordSandbox-$RELEASELABEL-win32x64.zip)" >> $GITHUB_ENV
+ shell: bash
+
+ - name: Install Dependencies
+ run: npm install
+
+ - name: Build and Release
+ run: npm run package-win
+
+ - name: Zip Release with Readme and License
+ run: 7z a $ZIPNAME ./release/*.exe README.md LICENSE.md
+ shell: bash
+
+ - name: Create Release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ tag_name: ${{ env.RELEASELABEL }}
+ release_name: ${{ env.RELEASELABEL }}
+ draft: false
+ prerelease: ${{ env.PRERELEASE }}
+ - name: Upload Release
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: ./${{ env.ZIPNAME }}
+ asset_name: ${{ env.ZIPNAME }}
+ asset_content_type: application/zip
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index e34e762..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-branches:
- only:
- - master
- - dev
-skip_tags: true
-cache:
- - node_modules
-environment:
- matrix:
- - nodejs_version: 8
-install:
- - ps: $env:package_version = (Get-Content -Raw -Path package.json | ConvertFrom-Json).version
- - ps: Install-Product node $env:nodejs_version
- - ps: If ($env:APPVEYOR_REPO_BRANCH -eq "master") { $env:toggle_prerelease="false"; $env:rel_type="stable"} Else {$env:toggle_prerelease="true"; $env:rel_type="nightly"}
- - set CI=true
- - npm install -g npm@latest
- - set PATH=%APPDATA%\npm;%PATH%
- - npm install
-matrix:
- fast_finish: true
-build_script:
- - npm run package-win
-after_build:
-- ps: 7z a DiscordSandbox-$env:package_version-$env:rel_type-win32x64.zip $env:APPVEYOR_BUILD_FOLDER\release\*.exe $env:APPVEYOR_BUILD_FOLDER\README.md $env:APPVEYOR_BUILD_FOLDER\LICENSE.md
-artifacts:
-- path: DiscordSandbox-$(package_version)-$(rel_type)-win32x64.zip
- name: DiscordSandbox-$(package_version)-$(rel_type)-win32x64
-shallow_clone: true
-clone_depth: 1
-deploy:
-- provider: GitHub
- release: $(package_version)-$(rel_type)
- prerelease: $(toggle_prerelease)
- description: Automatically built from branch `$(APPVEYOR_REPO_BRANCH)`, AppVeyor build `$(APPVEYOR_BUILD_VERSION)`$(APPVEYOR_REPO_COMMIT_MESSAGE)
- auth_token:
- secure: JPLPY6cHS8ydAPy2lc49ym1aBGk5uUStEAKfEQuVqdB2Jl9X/sfWdu4MVagLff1D
- artifact: DiscordSandbox-$(package_version)-$(rel_type)-win32x64.zip
- on:
- branch: $(APPVEYOR_REPO_BRANCH)
diff --git a/main.js b/main.js
index d74e430..c3e4602 100644
--- a/main.js
+++ b/main.js
@@ -67,10 +67,16 @@ function createMainWindow () {
icon: './views/assets/icon.ico',
webPreferences: {
preload: path.join(__dirname, 'src/mainLoad.js'),
+ partition: 'persist:discord',
nodeIntegration: false, // https://electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content
enableRemoteModule: false, // https://electronjs.org/docs/tutorial/security#15-disable-the-remote-module
- partition: 'persist:discord',
- webviewTag: true
+ webviewTag: true,
+ sandbox: true,
+ nodeIntegrationInSubFrames: false,
+ webSecurity: true,
+ allowRunningInsecureContent: false,
+ plugins: false,
+ experimentalFeatures: false
},
frame: false
})
@@ -92,8 +98,15 @@ function createLogWindow() {
icon: './views/assets/icon.ico',
webPreferences: {
preload: path.join(__dirname, 'src/logLoad.js'),
- nodeIntegration: false,
- enableRemoteModule: false,
+ nodeIntegration: false, // https://electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content
+ enableRemoteModule: false, // https://electronjs.org/docs/tutorial/security#15-disable-the-remote-module
+ webviewTag: true,
+ sandbox: true,
+ nodeIntegrationInSubFrames: false,
+ webSecurity: true,
+ allowRunningInsecureContent: false,
+ plugins: false,
+ experimentalFeatures: false
},
frame: false
})
@@ -170,11 +183,12 @@ function setPTTKey() {
pttEnable = 'mousedown'
pttDisable = 'mouseup'
pttWatch = 'button'
- }
- if (configObj.pttDevice === 'keyboard'){
+ }else if (configObj.pttDevice === 'keyboard'){
pttEnable = 'keydown'
pttDisable = 'keyup'
pttWatch = 'keycode'
+ }else {
+ console.log("ERROR: configObj did not set PTT device to mouse or keyboard.")
}
ioHook.on(pttEnable, event => {
if (event[pttWatch] == configObj.key && (micPermissionGranted === true) && (isConnected === true) && (isChangingPTTKey === false)) {
diff --git a/package-lock.json b/package-lock.json
index 6a86293..972a556 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,16 +1,28 @@
{
"name": "discordsandbox",
+<<<<<<< HEAD
"version": "0.4.4",
+=======
+ "version": "1.0.0",
+>>>>>>> dev
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "discordsandbox",
+<<<<<<< HEAD
"version": "0.4.4",
+=======
+ "version": "1.0.0",
+>>>>>>> dev
"hasInstallScript": true,
"license": "GNU GENERAL PUBLIC LICENSE Version 3",
"dependencies": {
"chokidar": "^3.3.1",
+<<<<<<< HEAD
+=======
+ "graceful-fs": "^4.2.2",
+>>>>>>> dev
"iohook": "^0.7.2"
},
"devDependencies": {
diff --git a/package.json b/package.json
index 08116a1..b7559a1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "discordsandbox",
- "version": "0.4.4",
+ "version": "1.0.0",
"description": "Discord Sandboxed",
"main": "main.js",
"scripts": {
@@ -23,6 +23,7 @@
},
"dependencies": {
"chokidar": "^3.3.1",
+ "graceful-fs": "^4.2.2",
"iohook": "^0.7.2"
},
"iohook": {
diff --git a/src/config.js b/src/config.js
index 19aa5e0..d528234 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,43 +1,50 @@
const {app} = require('electron')
-const fs = require('fs')
+const fs = require('graceful-fs')
const path = require('path')
function _saveToConfig (configObj) {
return new Promise(function (resolve, reject) {
const documentsDir = app.getPath('documents')
- const configDir = path.join(documentsDir, 'Discord Sandbox')
+ const configDir = path.join(documentsDir, 'DiscordSandbox')
const configFile = path.join(configDir, 'config.json')
console.log('\tUpdating config.json', configObj)
- fs.writeFile(configFile, JSON.stringify(configObj, null, 2), 'utf8', (err) => reject(err))
- return resolve(configObj)
+ fs.writeFile(configFile, JSON.stringify(configObj, null, 2), (err) => {
+ if (err) throw err;
+ return resolve(configObj)
+ })
})
}
module.exports = {
initConfig: function () {
return new Promise((resolve, reject) => {
- const documentsDir = app.getPath('documents') // Fetchs user's documents directory
- const configDir = path.join(documentsDir, 'Discord Sandbox') // config is stored in user's home dir
- const configFile = path.join(configDir, 'config.json') // Saves all config information in config.json
-
- let configObj // Init configObj
-
- // If config.json does not exist, create it with blank values
- if (!fs.existsSync(configFile)) {
- console.log(`\tCreated ${configFile}`)
- configObj = {
- 'pttDevice': 'mouse',
- 'key': '4',
- 'delay': '1000',
+ const documentsDir = app.getPath('documents') // Fetchs user's documents directory
+ const configDir = path.join(documentsDir, 'DiscordSandbox') // config is stored in user's home dir
+ const configFile = path.join(configDir, 'config.json') // Saves all config information in config.json
+
+ let configObj // Init configObj
+
+ // If config dir does not exist create it
+ if (!fs.existsSync(configDir)){
+ fs.mkdirSync(configDir)
+ }
+
+ // If config.json does not exist, create it with blank values
+ if (!fs.existsSync(configFile)) {
+ console.log(`\tCreated ${configFile}`)
+ configObj = {
+ 'pttDevice': 'mouse',
+ 'key': '4',
+ 'delay': '1000',
+ }
+ return resolve(_saveToConfig(configObj))
+ }
+ try {
+ configObj = JSON.parse(fs.readFileSync(configFile, 'utf8'))
+ return resolve(configObj)
+ } catch (err) {
+ return reject(err)
}
- return resolve(_saveToConfig(configObj))
- }
- try {
- configObj = JSON.parse(fs.readFileSync(configFile, 'utf8'))
- return resolve(configObj)
- } catch (err) {
- return reject(err)
- }
})
},
saveConfig: function(configObj) {
From 452dcbbe67509bb5391825aba6140acb7f06a46f Mon Sep 17 00:00:00 2001
From: khlam <4841220+khlam@users.noreply.github.com>
Date: Sun, 20 Dec 2020 16:57:41 -0800
Subject: [PATCH 3/3] 1.0.0; Fix config.json and directory not getting created.
Now using github actions to build and publish releases.
---
package-lock.json | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 972a556..24bb341 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,28 +1,17 @@
{
"name": "discordsandbox",
-<<<<<<< HEAD
- "version": "0.4.4",
-=======
"version": "1.0.0",
->>>>>>> dev
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "discordsandbox",
-<<<<<<< HEAD
- "version": "0.4.4",
-=======
"version": "1.0.0",
->>>>>>> dev
"hasInstallScript": true,
"license": "GNU GENERAL PUBLIC LICENSE Version 3",
"dependencies": {
"chokidar": "^3.3.1",
-<<<<<<< HEAD
-=======
"graceful-fs": "^4.2.2",
->>>>>>> dev
"iohook": "^0.7.2"
},
"devDependencies": {