/** * Open up the simulator by sending a message to ipcRenderer('openSimulator') */ openSim() { ipcRenderer.send('openSimulator', 'helloworld'); }
/** * Opens up simulator within IDE window by sending a message to ipcRenderer('start simulator') * Changes state of simulator to true to trigger conditional rendering of Editor and Simulator */ openSimulatorInMain() { if(this.state.simulator === false){ this.setState({ simulator: true }); ipcRenderer.send('start simulator', 'helloworld'); } else { this.closeSim() } }
closeSim() { this.setState({ simulator: false }); ipcRenderer.send('closeSim', this.state.liveServerPID); }
electron.ipcRenderer.on("saveDownloads", function() { saveDownloads(true); });
/** * sends input name to main, where the file/directory is actually created. * creation of new file/directory will trigger watch handler */ createItem(event) { if (event.key === 'Enter') { //send path and file type to main process to actually create file/dir only if there is value if (event.target.value) ipcRenderer.send( 'createItem', this.state.selectedItem.path, event.target.value, this.state.createMenuInfo.type ); //set type of file change so watch handler knows which type this.setState({ fileChangeType: 'new' }); } }
//handles click event from delete prompt deletePromptHandler(answer) { if (answer) { ipcRenderer.send('delete', this.state.selectedItem.path); } else { this.setState({ fileChangeType: null }); } this.setState({ deletePromptOpen: false }); }
electron.ipcRenderer.send("quitApp");
ipcRenderer.on('application:import-file', this.onImport); ipcRenderer.on('application:export-file', this.onExport); ipcRenderer.on('application:add-path', this.onAddPath); ipcRenderer.on('application:save-as', this.onSaveCommands); ipcRenderer.on('application:load-file', this.onLoadScript); ipcRenderer.on('application:prompt-clear-all', this.onClearCommands); ipcRenderer.on('application:prompt-expand-all', this.onExpandAll); ipcRenderer.on('application:prompt-collapse-all', this.onCollapseAll); ipcRenderer.on('application:prompt-break', this.onBreakPrompt); ipcRenderer.on('application:prompt-format', this.onFormatPromptCode); ipcRenderer.on('application:prompt-mode', (sender, value) => this.onSetREPLMode(value)); ipcRenderer.on('application:editor-mode', (sender, value) => this.onSetEditorMode(value)); ipcRenderer.on('application:prompt-language', (sender, value) => { global.Mancy.session.lang = value; ReplLanguages.setREPL(value); ipcRenderer.on('application:preferences', ReplPreferencesActions.openPreferences); ipcRenderer.on('application:focus', this.loadPreferences); ipcRenderer.on('application:transpile-babel', () => global.Mancy.session.babel = true ); ipcRenderer.on('application:preference-theme-dark', () => ReplPreferencesActions.setTheme('Dark Theme')); ipcRenderer.on('application:preference-theme-light', () => ReplPreferencesActions.setTheme('Light Theme')); ipcRenderer.on('application:view-theme-dark', () => this.setTheme('Dark Theme'));
/** * Registers listeners for opening projects and new projects */ fileTreeInit() { ipcRenderer.on('openDir', (event, dirPath) => { if (dirPath !== this.state.rootDirPath) { this.setFileTree(dirPath); } }), ipcRenderer.on('newProject', (event, arg) => { if (this.state.watch) this.state.watch.close(); console.log(this.state) this.setState({ fileTree: null, watch: null, rootDirPath: '', selectedItem: { id: null, path: null, type: null }, cra: true, }); }) }
ipcRenderer.on('openDir', (event, projPath) => { if (this.state.openedProjectPath !== projPath) { this.setState({ openTabs: {}, openedProjectPath: projPath }); ipcRenderer.on('saveFile', (event, arg) => { if (this.state.previousPaths[this.state.previousPaths.length - 1] !== null) { this.saveTab(); ipcRenderer.on('delete', (event, arg) => { if (this.state.selectedItem.id) { this.setState({ ipcRenderer.on('enter', (event, arg) => { if (this.state.selectedItem.focused) { ipcRenderer.on('start simulator', (event, arg) => { console.log('this is start simulator event line 111 appjsx', event); this.setState({ url: arg[0], liveServerPID: arg[1] }); }); ipcRenderer.on('craOut', (event, arg) => { this.setState({ craOut: arg, cra: false }); }); ipcRenderer.on('closeSim', (event, arg) => { this.setState({ url: ' ' }) })
const logger = ( namespace, options ) => { // FIXME: The `remote` module is being deprecated and will be excluded // from Electron v9.x. // It is possible to use the `remote` module to directly require the // main process logging module. However, this is a security concern and is // discouraged. Instead, we post log messages to the main process via ipc. const send = ( level, message, meta ) => { ipcRenderer.send( 'log', level, namespace, options, message, meta ); }; return { error: ( message, meta ) => send( 'error', namespace, options, message, meta ), warn: ( message, meta ) => send( 'warn', namespace, options, message, meta ), info: ( message, meta ) => send( 'info', namespace, options, message, meta ), debug: ( message, meta ) => send( 'debug', namespace, options, message, meta ), silly: ( message, meta ) => send( 'silly', namespace, options, message, meta ), }; }
}); ipcRenderer.send('closeSplash');
const globalNames = ipcRenderer.sendSync('application:global-context-names'); missingGlobals = globalNames.filter(n => !context[n]);
} else if (actionType === 'delete') { ipcRenderer.send('delete', path); this.setState({ fileChangeType: 'delete'
/** * sends old path and new name to main process to rename, closes rename form and sets filechangetype and newName for fswatch * @param {Javascript event Object} event */ renameHandler(event) { if (event.key === 'Enter' && event.target.value) { ipcRenderer.send('rename', this.state.selectedItem.path, event.target.value); this.setState({ renameFlag: false, fileChangeType: 'rename', newName: event.target.value }); } else if (event.key === 'Enter' && !event.target.value) { this.setState({ renameFlag: false }); } let copyObj = { createMenuInfo: { id: null, type: null } } this.setState({ createMenuInfo: copyObj, openMenuId: null }); }