How to use the electron.remote.app function in electron

To help you get started, we’ve selected a few electron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github karmainside / ms-teams-linux / src / app.js View on Github external
// 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
});
github Foundry376 / Mailspring / app / src / flux / stores / identity-store.es6 View on Github external
_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();
  };
github mattermost / desktop / src / browser / components / MattermostView.jsx View on Github external
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);
      }
    });
github tidys / CocosCreatorPlugins / packages / plugin-4399-web-js-sdk / core / CfgUtil.js View on Github external
_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) {
github elyukai / optolith-client / src / utils / versionUtils.ts View on Github external
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' },
github LedgerHQ / ledger-live-desktop / src / helpers / reset.js View on Github external
export async function openUserDataFolderAndQuit() {
  shell.openItem(resolveUserDataDirectory())
  remote.app.quit()
}
github GetStream / Winds / app / public / electron.js View on Github external
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,
	});
github teak / Pussh / app / js / settings-window.js View on Github external
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();
});
github dawg / vusic / src / dawg / extensions / core / record / index.ts View on Github external
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);
  });
}
github sketchglass / azurite / src / renderer / app / Config.ts View on Github external
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) {
    }