Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Here is the starting point for your application code.
// All stuff below is just to show you how it works. You can delete all of it.
// Use new ES6 modules syntax for everything.
import { remote } from 'electron'; // native electron module
import jetpack from 'fs-jetpack'; // module loaded from npm
import env from './env';
console.log('Loaded environment variables:', env);
const app = remote.app;
const appDir = jetpack.cwd(app.getAppPath());
// Holy crap! This is browser window with HTML and stuff, but I can read
// here files like it is node.js! Welcome to Electron world :)
console.log(
'The author of this app is:',
appDir.read('package.json', 'json').author
);
document.addEventListener('DOMContentLoaded', () => {
// DO something
});
_onLogoutNylasIdentity = async () => {
await this.saveIdentity(null);
// We need to relaunch the app to clear the webview session
// and prevent the webview from re signing in with the same NylasID
remote.app.relaunch();
remote.app.quit();
};
webview.addEventListener('new-window', (e) => {
const currentURL = url.parse(webview.getURL());
const destURL = url.parse(e.url);
if (destURL.protocol !== 'http:' && destURL.protocol !== 'https:' && destURL.protocol !== `${scheme}:`) {
ipcRenderer.send('confirm-protocol', destURL.protocol, e.url);
return;
}
if (currentURL.host === destURL.host) {
if (destURL.path.match(/^\/api\/v[3-4]\/public\/files\//)) {
ipcRenderer.send('download-url', e.url);
} else {
// New window should disable nodeIntegration.
window.open(e.url, remote.app.getName(), 'nodeIntegration=no, show=yes');
}
} else {
// if the link is external, use default browser.
shell.openExternal(e.url);
}
});
_getAppCfgPath() {
let userDataPath = remote.app.getPath('userData');
let tar = Editor.libraryPath;
tar = tar.replace(/\\/g, '-');
tar = tar.replace(/:/g, '-');
tar = tar.replace(/\//g, '-');
return path.join(userDataPath, "bitmap-font-cfg-" + tar + ".json");
// return Editor.url('packages://hot-update-tools/save/cfg.json');
},
initCfg(cb) {
import { remote } from 'electron';
import * as fs from 'fs';
import * as path from 'path';
import { lt, lte, satisfies } from 'semver';
import { ActiveObject } from '../types/data';
import { RawHero } from '../types/rawdata';
import { StringKeyObject } from './dataUtils';
import { getBlessedTraditionInstanceIdByNumericId, getMagicalTraditionInstanceIdByNumericId } from './IDUtils';
export const currentVersion = JSON.parse (fs.readFileSync (
path.join (remote.app.getAppPath (), 'package.json'),
'utf8'
)).version as string;
// tslint:disable-next-line:variable-name
const convertLowerThan0_49_5 = (hero: RawHero): RawHero => {
const entry = { ...hero };
const newActivatable: StringKeyObject = {};
const convertIds: StringKeyObject = {
'SA_6': { id: 'SA_5', tier: 2 },
'SA_7': { id: 'SA_6' },
'SA_8': { id: 'SA_7' },
'SA_9': { id: 'SA_8' },
'SA_10': { id: 'SA_9' },
'SA_11': { id: 'SA_10' },
export async function openUserDataFolderAndQuit() {
shell.openItem(resolveUserDataDirectory())
remote.app.quit()
}
const {
app,
BrowserWindow,
shell,
ipcMain,
Menu,
TouchBar,
remote,
} = require('electron');
const { TouchBarButton, TouchBarLabel, TouchBarSpacer } = TouchBar;
const isDev =
'ELECTRON_IS_DEV' in process.env
? parseInt(process.env.ELECTRON_IS_DEV, 10) === 1
: !(app || remote.app).isPackaged;
let mainWindow;
const createWindow = () => {
mainWindow = new BrowserWindow({
backgroundColor: '#F7F7F7',
minWidth: 880,
show: false,
titleBarStyle: 'hidden',
webPreferences: {
nodeIntegration: false,
preload: __dirname + '/preload.js',
},
height: 860,
width: 1280,
});
app.run($rootScope => {
$rootScope.Platform = require('os').platform();
$rootScope.Electron = remote.app;
$rootScope.AppName = $rootScope.Electron.getName();
$rootScope.Version = $rootScope.Electron.getVersion();
$rootScope.Window = remote.getCurrentWindow();
$rootScope.Pussh = remote.getGlobal('Pussh');
$rootScope.Window.focus();
});
import path from 'path';
import fs from '@/fs';
import { ChunkGhost } from '@/core/ghost';
import { remote } from 'electron';
import { Sample, ScheduledSample } from '@/core';
import { value, watch } from 'vue-function-api';
import { manager } from '@/base/manager';
import { project } from '@/dawg/extensions/core/project';
import { applicationContext } from '@/dawg/extensions/core/application-context';
import { positionable } from '@/modules/sequencer/helpers';
import GH from '@/dawg/extensions/core/record/ChunkGhost.vue';
import { ui } from '@/base/ui';
const ChunkGhostComponent = positionable(GH);
export const DOCUMENTS_PATH = remote.app.getPath('documents');
export const RECORDING_PATH = path.join(DOCUMENTS_PATH, remote.app.getName(), 'recordings');
function blobsToAudioBuffer(blobs: Blob[]): Promise {
const reader = new FileReader();
return new Promise((resolve) => {
reader.onload = (event) => {
const buffer = reader.result as ArrayBuffer;
Audio.context.decodeAudioData(buffer).then((decodedBuffer) => {
resolve(decodedBuffer);
});
};
const audioBlob = new Blob(blobs);
reader.readAsArrayBuffer(audioBlob);
});
}
class Config {
private _values: ConfigValues = {
window: {
fullscreen: false,
maximized: false,
},
tools: {
},
currentTool: "",
color: {h: 0, s: 0, v: 0},
palette: [],
files: [],
brushPresets: [],
currentBrushPreset: 0,
}
path = path.join(remote.app.getPath("userData"), "config.json")
get values() {
return this._values
}
set values(values: ConfigValues) {
fs.writeFileSync(this.path, JSON.stringify(values, null, 2))
this._values = values
}
constructor() {
try {
const data = fs.readFileSync(this.path, "utf8")
deepAssign(this.values, JSON.parse(data))
} catch (e) {
}