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,88 @@
/*---------------------------------------------------------------------------------------------
* 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 { globals } from 'vs/base/common/platform';
import { logOnceWebWorkerWarning, IWorker, IWorkerCallback, IWorkerFactory } from 'vs/base/common/worker/simpleWorker';
// Option for hosts to overwrite the worker script url (used in the standalone editor)
const getCrossOriginWorkerScriptUrl: (workerId: string, label: string) => string = environment('getWorkerUrl', null);
function environment(name: string, fallback: any = false): any {
if (globals.MonacoEnvironment && globals.MonacoEnvironment.hasOwnProperty(name)) {
return globals.MonacoEnvironment[name];
}
return fallback;
}
function defaultGetWorkerUrl(workerId: string, label: string): string {
return require.toUrl('./' + workerId) + '#' + label;
}
var getWorkerUrl = getCrossOriginWorkerScriptUrl || defaultGetWorkerUrl;
/**
* A worker that uses HTML5 web workers so that is has
* its own global scope and its own thread.
*/
class WebWorker implements IWorker {
private id: number;
private worker: Worker;
constructor(moduleId: string, id: number, label: string, onMessageCallback: IWorkerCallback, onErrorCallback: (err: any) => void) {
this.id = id;
this.worker = new Worker(getWorkerUrl('workerMain.js', label));
this.postMessage(moduleId);
this.worker.onmessage = function (ev: any) {
onMessageCallback(ev.data);
};
if (typeof this.worker.addEventListener === 'function') {
this.worker.addEventListener('error', onErrorCallback);
}
}
public getId(): number {
return this.id;
}
public postMessage(msg: string): void {
if (this.worker) {
this.worker.postMessage(msg);
}
}
public dispose(): void {
this.worker.terminate();
this.worker = null;
}
}
export class DefaultWorkerFactory implements IWorkerFactory {
private static LAST_WORKER_ID = 0;
private _label: string;
private _webWorkerFailedBeforeError: any;
constructor(label: string) {
this._label = label;
this._webWorkerFailedBeforeError = false;
}
public create(moduleId: string, onMessageCallback: IWorkerCallback, onErrorCallback: (err: any) => void): IWorker {
let workerId = (++DefaultWorkerFactory.LAST_WORKER_ID);
if (this._webWorkerFailedBeforeError) {
throw this._webWorkerFailedBeforeError;
}
return new WebWorker(moduleId, workerId, this._label || 'anonymous' + workerId, onMessageCallback, (err) => {
logOnceWebWorkerWarning(err);
this._webWorkerFailedBeforeError = err;
onErrorCallback(err);
});
}
}