Example #1
1
	do_ping() {
		if (this.has_ipc) {
			console.log(ipcRenderer.sendSync('synchronous-message', 'sync ping')); // prints "pong"
			ipcRenderer.send('asynchronous-message', 'async ping');
		} else {
			console.log("There isn't Electron main process.");
		}
	}
Example #2
0
export function popup(items: IContextMenuItem[], options?: IPopupOptions): void {
	const processedItems: IContextMenuItem[] = [];

	const contextMenuId = contextMenuIdPool++;
	const onClickChannel = `vscode:onContextMenu${contextMenuId}`;
	const onClickChannelHandler = (_event: Event, itemId: number, context: IContextMenuEvent) => {
		const item = processedItems[itemId];
		if (item.click) {
			item.click(context);
		}
	};

	ipcRenderer.once(onClickChannel, onClickChannelHandler);
	ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, (_event: Event, closedContextMenuId: number) => {
		if (closedContextMenuId !== contextMenuId) {
			return;
		}

		ipcRenderer.removeListener(onClickChannel, onClickChannelHandler);

		if (options && options.onHide) {
			options.onHide();
		}
	});

	ipcRenderer.send(CONTEXT_MENU_CHANNEL, contextMenuId, items.map(item => createItem(item, processedItems)), onClickChannel, options);
}
function attachTo(item: ProcessItem) {
	const config: any = {
		type: 'node',
		request: 'attach',
		name: `process ${item.pid}`
	};

	let matches = DEBUG_FLAGS_PATTERN.exec(item.cmd);
	if (matches && matches.length >= 2) {
		// attach via port
		if (matches.length === 4 && matches[3]) {
			config.port = parseInt(matches[3]);
		}
		config.protocol = matches[1] === 'debug' ? 'legacy' : 'inspector';
	} else {
		// no port -> try to attach via pid (send SIGUSR1)
		config.processId = String(item.pid);
	}

	// a debug-port=n or inspect-port=n overrides the port
	matches = DEBUG_PORT_PATTERN.exec(item.cmd);
	if (matches && matches.length === 3) {
		// override port
		config.port = parseInt(matches[2]);
	}

	ipcRenderer.send('vscode:workbenchCommand', { id: 'workbench.action.debug.start', from: 'processExplorer', args: [config] });
}
Example #4
0
window.onload = () => {
	const tweetButtonElement = document.getElementById('tweet-button')
	const trackNameElement = document.getElementById('track-name')
	const artworkImageElement = document.getElementById('artwork')

	ipcRenderer.on('twitter-auth-reply', (event, arg) => {
		ipcRenderer.send('itunes-get-track')
	})

	ipcRenderer.on('itunes-get-track-reply', (event, arg) => {
		nowPlayingTrack = arg as NowPlayingTrack
		console.log('get track success')
		console.log(nowPlayingTrack)
		trackNameElement.innerHTML = createTweetMessage(nowPlayingTrack)
		artworkImageElement.style.backgroundImage = `url(${fileUrl(nowPlayingTrack.artworkPath)})`
	})

	tweetButtonElement.addEventListener('click', () => {
		if (!nowPlayingTrack) {
			console.log('nowplaying track not found')
			return
		}
		const tweet: NowPlayingTweet = {
			message: createTweetMessage(nowPlayingTrack),
			artworkPath: nowPlayingTrack.artworkPath,
		}
		ipcRenderer.send('twitter-post', tweet)
	})

	// first, twitter auth
	ipcRenderer.send('twitter-auth')
}
Example #5
0
 click: function(){
   ipcRenderer.send('open-custom');
       let notification = new Notification('Customdialog', {
           body: 'This is a custom window created by us'
       })
     
 }
Example #6
0
    }, (err) => {
      if (err != null) { callback(err, null); return; }

      const ipcId = getNextIpcId();
      ipcCallbacks[ipcId] = () => { callback(null, tempFolderPath); };
      electron.ipcRenderer.send("authorize-folder", secretKey, ipcId, window.location.origin, tempFolderPath);
    });
Example #7
0
			this._resolveAuthorityCache[authority].then((r) => {
				ipc.send('vscode:remoteAuthorityResolved', {
					authority: authority,
					host: r.host,
					port: r.port
				});
			});
Example #8
0
export function save(name: string, spec: any, pathToSave: string) {
  ipcRenderer.send("save", {
    name,
    spec,
    pathToSave
  });
}
Example #9
0
/**
 * Dispatches the given log entry to the main process where it will be picked
 * written to all log transports. See initializeWinston in logger.ts for more
 * details about what transports we set up.
 */
function log(level: LogLevel, message: string, error?: Error) {
  ipcRenderer.send(
    'log',
    level,
    formatLogMessage(`[${__PROCESS_KIND__}] ${message}`, error)
  )
}
Example #10
0
export const forwardToMain: Middleware = (store: MiddlewareAPI<AppState>) => (next: Dispatch<AppState>) => (action: AppAction) =>
{
    if (action.scope === "local")
        return next(action);

    ipcRenderer.send(REDUX_SYNC, action);
};