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,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);
}
}