Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getEnvPath() {
// let envPath = config.get('envPath');
// if (envPath) {
// if (isWin) {
// envPath = ';' + envPath;
// } else {
// envPath = ':/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:/usr/local/share/node/bin:' + envPath;
// }
// } else {
// envPath = ':/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:/usr/local/share/node/bin';
// }
const envPath =
':/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:/usr/local/share/node/bin';
return `:${envPath}:${fixPathForAsarUnpack(
path.join(app.getAppPath(), 'node_modules/node/bin'),
)}:${fixPathForAsarUnpack(path.join(app.getAppPath(), 'node_modules/npm/bin'))}`;
}
function getEnvPath() {
// let envPath = config.get('envPath');
// if (envPath) {
// if (isWin) {
// envPath = ';' + envPath;
// } else {
// envPath = ':/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:/usr/local/share/node/bin:' + envPath;
// }
// } else {
// envPath = ':/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:/usr/local/share/node/bin';
// }
const envPath =
':/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:/usr/local/share/node/bin';
return `:${envPath}:${fixPathForAsarUnpack(
path.join(app.getAppPath(), 'node_modules/node/bin'),
)}:${fixPathForAsarUnpack(path.join(app.getAppPath(), 'node_modules/npm/bin'))}`;
}
/* eslint-disable array-element-newline */
'use strict';
const os = require('os');
const path = require('path');
const execa = require('execa');
const moment = require('moment');
const prettyMs = require('pretty-ms');
const tmp = require('tmp');
const ffmpeg = require('@ffmpeg-installer/ffmpeg');
const util = require('electron-util');
const PCancelable = require('p-cancelable');
const tempy = require('tempy');
const {track} = require('./common/analytics');
const ffmpegPath = util.fixPathForAsarUnpack(ffmpeg.path);
const timeRegex = /time=\s*(\d\d:\d\d:\d\d.\d\d)/gm;
const speedRegex = /speed=\s*(-?\d+(,\d+)*(\.\d+(e\d+)?)?)/gm;
// https://trac.ffmpeg.org/ticket/309
const makeEven = n => 2 * Math.round(n / 2);
const convert = (outputPath, opts, args) => {
track(`file/export/fps/${opts.fps}`);
return new PCancelable((resolve, reject, onCancel) => {
const converter = execa(ffmpegPath, args);
const durationMs = moment.duration(opts.endTime - opts.startTime, 'seconds').asMilliseconds();
let speed;
onCancel(() => {
track('file/export/convert/canceled');
const getPort = require('get-port');
const fs = require('fs');
const path = require('path');
const { app } = require('electron');
const log = require('electron-log');
const { fixPathForAsarUnpack } = require('electron-util');
const taskRunner = require('./taskRunner');
const utils = require('./utils');
const studioMap = {};
const nodeBin = fixPathForAsarUnpack(path.join(app.getAppPath(), 'node_modules/node/bin/node'));
const studioBin = fixPathForAsarUnpack(require.resolve('rekit-studio/bin/index.js'));
log.info('Node bin: ', nodeBin);
log.info('Studio bin: ', studioBin);
let stopping = {}; // This is used for avoid catching 'exit' event while manually stopping
function startStudio(prjDir, restart) {
if (!fs.existsSync(prjDir)) {
return Promise.reject(new Error(`Project not exists: ${prjDir}`));
}
delete stopping[prjDir];
if (studioMap[prjDir] && !restart) {
log.info('already started', prjDir);
return Promise.resolve(studioMap[prjDir]);
}
log.info('starting rekit studio');
// if restart, keep the port
const defaultPort = studioMap[prjDir] ? parseInt(studioMap[prjDir].port, 10) : null;
log.info('default port: ', defaultPort);
import '../../build/release/black-magic.node';
import { spawn } from 'child_process';
import { chmodSync } from 'fs';
import { fixPathForAsarUnpack } from 'electron-util';
import { register } from 'electron-localshortcut';
import { HEIGHT, WIDTH_RATIO, MACOS, MACOS_MOJAVE, WINDOWS, CONTAINER, WIDTH } from '../constants'
import { nextVisualization, prevVisualization } from '../visualizations/visualizations.js';
// Visualizations look snappier on 60Hz refresh rate screens if we disable vsync
app.commandLine.appendSwitch("disable-gpu-vsync");
app.commandLine.appendArgument("disable-gpu-vsync");
if (MACOS) {
// FIXME: Probably a better way of doing this
chmodSync(fixPathForAsarUnpack(__dirname + "/volume-capture-daemon"), '555');
spawn(fixPathForAsarUnpack(__dirname + "/volume-capture-daemon"));
}
let mainWindow: Electron.BrowserWindow;
let mousePoller: NodeJS.Timeout;
register('A', () => {
mainWindow.webContents.send('prev-visualization');
});
register('D', () => {
mainWindow.webContents.send('next-visualization');
});
function createWindow() {
// Create the browser window
mainWindow = new BrowserWindow({
const getPort = require('get-port');
const fs = require('fs');
const path = require('path');
const { app } = require('electron');
const log = require('electron-log');
const { fixPathForAsarUnpack } = require('electron-util');
const taskRunner = require('./taskRunner');
const utils = require('./utils');
const studioMap = {};
const nodeBin = fixPathForAsarUnpack(path.join(app.getAppPath(), 'node_modules/node/bin/node'));
const studioBin = fixPathForAsarUnpack(require.resolve('rekit-studio/bin/index.js'));
log.info('Node bin: ', nodeBin);
log.info('Studio bin: ', studioBin);
let stopping = {}; // This is used for avoid catching 'exit' event while manually stopping
function startStudio(prjDir, restart) {
if (!fs.existsSync(prjDir)) {
return Promise.reject(new Error(`Project not exists: ${prjDir}`));
}
delete stopping[prjDir];
if (studioMap[prjDir] && !restart) {
log.info('already started', prjDir);
return Promise.resolve(studioMap[prjDir]);
}
log.info('starting rekit studio');
// if restart, keep the port
const defaultPort = studioMap[prjDir] ? parseInt(studioMap[prjDir].port, 10) : null;
loadButton(id: string): string {
return process.env.NODE_ENV !== 'production'
? `${path.join('static', 'icons', 'icons.svg')}#${id}`
: fixPathForAsarUnpack(`${path.join(__static, 'icons', 'icons.svg')}#${id}`);
}
loadDefaultFavicon(event: Electron.Event) {
const ffmpeg = require('@ffmpeg-installer/ffmpeg');
const util = require('electron-util');
const execa = require('execa');
const makeDir = require('make-dir');
const moment = require('moment');
const settings = require('./common/settings');
const {track} = require('./common/analytics');
const {openPrefsWindow} = require('./preferences');
const {getExportsWindow, openExportsWindow} = require('./exports');
const {openEditorWindow} = require('./editor');
const {toggleExportMenuItem} = require('./menus');
const Export = require('./export');
const {ensureDockIsShowingSync} = require('./utils/dock');
const ffmpegPath = util.fixPathForAsarUnpack(ffmpeg.path);
let lastSavedDirectory;
const filterMap = new Map([
['mp4', [{name: 'Movies', extensions: ['mp4']}]],
['webm', [{name: 'Movies', extensions: ['webm']}]],
['gif', [{name: 'Images', extensions: ['gif']}]],
['apng', [{name: 'Images', extensions: ['apng']}]]
]);
const getPreview = async inputPath => {
const previewPath = tmp.tmpNameSync({postfix: '.jpg'});
await execa(ffmpegPath, [
'-ss', 0,
'-i', inputPath,
'-t', 1,
'-vframes', 1,
loadButton(id: string): string {
return process.env.NODE_ENV !== 'production'
? `${path.join('static', 'icons', 'icons.svg')}#${id}`
: fixPathForAsarUnpack(`${path.join(__static, 'icons', 'icons.svg')}#${id}`);
}
onCustomButtonClick(event) {
favIconUrl: null,
status: null,
incognito: false,
statusText: false,
isLoading: false,
isSearching: false,
canGoBack: false,
canGoForward: false,
canRefresh: false,
error: false,
hasMedia: false,
isAudioMuted: false,
pageActionMapping: {},
},
defaultFavicon: nativeImage
.createFromPath(fixPathForAsarUnpack(path.join(__static, 'icons', 'document.png')))
.toDataURL(),
lulumiFavicon: nativeImage
.createFromPath(fixPathForAsarUnpack(path.join(__static, 'icons', 'icon.png')))
.toDataURL(),
};
export default {
tabConfig,
searchEngine,
homepage,
pdfViewer,
lulumiPagesCustomProtocol: 'lulumi://',
aboutPages: {
about: 'List of about pages',
},
currentSearchEngine: searchEngine[0],