SQL Operations Studio Public Preview 1 (0.23) release source code

This commit is contained in:
Karl Burtram
2017-11-09 14:30:27 -08:00
parent b88ecb8d93
commit 3cdac41339
8829 changed files with 759707 additions and 286 deletions

View File

@@ -0,0 +1,19 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import Event from 'vs/base/common/event';
import URI from 'vs/base/common/uri';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export const ID = 'urlService';
export const IURLService = createDecorator<IURLService>(ID);
export interface IURLService {
_serviceBrand: any;
open(url: string): void;
onOpenURL: Event<URI>;
}

View File

@@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import { IChannel, eventToCall, eventFromCall, Serializer, Deserializer } from 'vs/base/parts/ipc/common/ipc';
import { IURLService } from './url';
import Event, { filterEvent } from 'vs/base/common/event';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import URI from 'vs/base/common/uri';
const URISerializer: Serializer<URI, any> = uri => uri.toJSON();
const URIDeserializer: Deserializer<URI, any> = raw => URI.revive(raw);
export interface IURLChannel extends IChannel {
call(command: 'event:onOpenURL'): TPromise<void>;
call(command: string, arg?: any): TPromise<any>;
}
export class URLChannel implements IURLChannel {
private focusedWindowId: number;
constructor(
private service: IURLService,
@IWindowsService windowsService: IWindowsService
) {
windowsService.onWindowFocus(id => this.focusedWindowId = id);
}
call(command: string, arg?: any): TPromise<any> {
switch (command) {
case 'event:onOpenURL': return eventToCall(filterEvent(this.service.onOpenURL, () => this.isWindowFocused(arg)), URISerializer);
}
return undefined;
}
/**
* We only want the focused window to get pinged with the onOpenUrl event.
* The idea here is to filter the onOpenUrl event with the knowledge of which
* was the last window to be focused. When first listening to the event,
* each client sends its window ID via the arguments to `call(...)`.
* When the event fires, the server has enough knowledge to filter the event
* and fire it only to the focused window.
*/
private isWindowFocused(windowID: number): boolean {
return this.focusedWindowId === windowID;
}
}
export class URLChannelClient implements IURLService {
_serviceBrand: any;
constructor(private channel: IChannel, private windowID: number) { }
private _onOpenURL = eventFromCall<URI>(this.channel, 'event:onOpenURL', this.windowID, URIDeserializer);
get onOpenURL(): Event<URI> { return this._onOpenURL; }
open(url: string): void {
return; // not implemented
}
}

View File

@@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import Event, { mapEvent, chain, echo, Emitter, any } from 'vs/base/common/event';
import { fromEventEmitter } from 'vs/base/node/event';
import { IURLService } from 'vs/platform/url/common/url';
import product from 'vs/platform/node/product';
import { app } from 'electron';
import URI from 'vs/base/common/uri';
export class URLService implements IURLService {
_serviceBrand: any;
private openUrlEmitter: Emitter<string> = new Emitter<string>();
onOpenURL: Event<URI>;
constructor(initial: string | string[] = []) {
const globalBuffer = (global.getOpenUrls() || []) as string[];
const initialBuffer = [
...(typeof initial === 'string' ? [initial] : initial),
...globalBuffer
];
app.setAsDefaultProtocolClient(product.urlProtocol, process.execPath, ['--open-url']);
const rawOnOpenUrl = fromEventEmitter(app, 'open-url', (event: Electron.Event, url: string) => ({ event, url }));
// always prevent default and return the url as string
const preventedOnOpenUrl = mapEvent(rawOnOpenUrl, ({ event, url }) => {
event.preventDefault();
return url;
});
// echo all `onOpenUrl` events to each listener
const bufferedOnOpenUrl = echo(preventedOnOpenUrl, true, initialBuffer);
this.onOpenURL = chain(any(bufferedOnOpenUrl, this.openUrlEmitter.event))
.map(url => {
try {
return URI.parse(url);
} catch (e) {
return null;
}
})
.filter(uri => !!uri)
.event;
}
open(url: string): void {
this.openUrlEmitter.fire(url);
}
}