Permalink
Browse files

application initialisation

  • Loading branch information...
fdecampredon committed Mar 1, 2014
1 parent 6c16b1d commit ae2299bfb2fc43a25f61d1044b0d022bbc6c5bdc
Showing with 29 additions and 59 deletions.
  1. +1 −1 config.json
  2. +21 −57 main.js
  3. +1 −1 src/main/errorReporter.ts
  4. +2 −0 src/ts-worker/index.ts
  5. +4 −0 src/ts-worker/projectManager.ts
View
@@ -1,4 +1,4 @@
{
"isDebug": false,
"isDebug": true,
"logLevel": "warning"
}
View
78 main.js
@@ -3,63 +3,27 @@
define(function (require, exports, module) {
'use strict';
require(
[
'third_party/typescriptServices',
'third_party/minimatch',
'text!config.json'
],
function (typescript, minimatch, configText) {
var AppInit = brackets.getModule('utils/AppInit'),
config = JSON.parse(configText),
baseUrl = config.isDebug ? './built/local/' : './bin/',
worker,
typeScriptUtils,
initializeFunction,
requireReady,
workerReady;
require(['text!config.json'], function (configText) {
var AppInit = brackets.getModule('utils/AppInit'),
config = JSON.parse(configText),
baseUrl = config.isDebug ? './built/' : './bin/';
require([baseUrl + 'main'], function (init) {
var initConfig = {
logLevel: config.logLevel,
typeScriptLocation: require.toUrl('./third_party/typescript/'),
workerLocation: require.toUrl(baseUrl + 'worker.js')
};
function initializeApplication() {
if (requireReady && workerReady) {
typeScriptUtils.DEFAULT_LIB_LOCATION = require.toUrl('third_party/lib.d.ts');
typeScriptUtils.minimatch = minimatch;
if (config.isDebug) {
worker.onmessage = null;
typeScriptUtils.worker = worker;
}
//in debug mode avoid using AppInit that catch errors ...
if (config.isDebug) {
initializeFunction(config);
} else {
AppInit.appReady(function () {
initializeFunction(config);
});
}
}
if (config.isDebug) {
init(initConfig);
} else {
AppInit.appReady(function () {
init(initConfig);
});
}
if (config.isDebug) {
worker = new Worker(require.toUrl('./ts-worker.js'));
worker.onmessage = function () {
workerReady = true;
initializeApplication();
};
worker.postMessage(require.toUrl(baseUrl));
} else {
workerReady = true;
}
require([ baseUrl + 'main/typeScriptUtils', baseUrl + 'main/index'], function (tsUtils, init) {
typeScriptUtils = tsUtils;
initializeFunction = init;
requireReady = true;
initializeApplication();
});
}
);
});
});
});
@@ -14,7 +14,7 @@
import immediate = require('../commons/immediate');
import ErrorService = require('../commons/ErrorService');
import ErrorService = require('../commons/errorService');
//--------------------------------------------------------------------------
//
View
@@ -6,6 +6,7 @@ import CompletionService = require('./completionService');
import WorkerBridge = require('../commons/workerBridge');
import logger = require('../commons/logger');
import path = require('path');
var projectManager = new TypeScriptProjectManager(),
errorService = new ErrorService(projectManager),
@@ -19,6 +20,7 @@ bridge.init({
definitionService: definitionService
}).then(proxy => {
proxy.getTypeScriptLocation().then( (location: string) => {
importScripts(path.join(location, 'typeScriptService'));
proxy.getLogLevel().then((logLevel: string) => {
self.console = proxy.console;
logger.setLogLevel(logLevel);
@@ -84,6 +84,10 @@ class TypeScriptProjectManager {
workingSet: ws.WorkingSet, projectFactory: TypeScriptProjectManager.ProjectFactory): JQueryPromise<void> {
this.defaultTypeScriptLocation = defaultTypeScriptLocation;
this.fileSystem = fileSystem;
this.workingSet = workingSet;
this.projectFactory = projectFactory;
var initializing = this.createProjects();
this.creatingProjects = initializing;
this.disposable = this.fileSystem.projectFilesChanged.subscribe(this.filesChangeHandler);

0 comments on commit ae2299b

Please sign in to comment.