Skip to content

Commit

Permalink
And that's all we need
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Sep 17, 2024
1 parent c2e0011 commit 044bae3
Show file tree
Hide file tree
Showing 15 changed files with 6,979 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
out/
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/vdon-viewer.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Commands

build (curr os): `npm run make`
build (windows): `npm run make:win`

TODO: document command line args
36 changes: 36 additions & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');

module.exports = {
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin', 'win32', 'linux'],
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
19 changes: 19 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">-->
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
</body>

<script>
alert(window.electron.roomType);
</script>
</html>
72 changes: 72 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const { app, BrowserWindow } = require('electron');
const path = require('node:path');
const { Command, Option } = require('commander');

const program = new Command();

program
.addOption(
new Option(
'-v, --view <view>',
'The view type you wish to load (audio or video)',
)
.default('audio')
.choices(['audio', 'video']),
)
.addOption(
new Option(
'-rt, --room-type <room-type>',
'The key of the active room type you wish to load.'
)
.default('active')
)
;

program.parse();

app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');

function createWindow () {
const { view, roomType } = program.opts();
const titleExtraOpts = [
roomType || null
].filter(Boolean).join(',');

const win = new BrowserWindow({
width: 1280,
height: 720,
// Vue is overwriting the title, this is just wasting cpu cycles.
// But then again, we're using electron so who fucking cares lmao
title: `VDO.Ninja Viewer - ${view === 'audio' ? 'Audio' : 'Video'} View ${titleExtraOpts.length ? `(${titleExtraOpts})` : ''}`,
fullscreen: view === 'video',
webPreferences: {
backgroundThrottling: false,
contextIsolation: true,
nodeIntegration: true,
preload: path.join(__dirname, 'preload.js'),
additionalArguments: [
`roomType:${roomType}`,
'applyDelay:false', // TODO: implement when we need this
],
},
});

win.loadURL(`http://localhost:9090/bundles/nodecg-vdoninja/graphics/${view}-view/main.html`).catch(console.error);
}

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

// Specific macos stuff, doubt we ever need this.
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});

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

0 comments on commit 044bae3

Please sign in to comment.