提交 545af1f1 编写于 作者: A Alex Dima

Remove vs/text loader plugin

上级 742f017f
......@@ -33,14 +33,8 @@ exports.loaderConfig = function (emptyPaths) {
var result = {
paths: {
'vs': 'out-build/vs',
'vs/extensions': 'extensions',
'vscode': 'empty:'
},
'vs/text': {
paths: {
'vs/extensions': 'extensions'
}
},
nodeModules: emptyPaths||[]
};
......@@ -55,7 +49,6 @@ function loader(bundledFileHeader) {
'out-build/vs/loader.js',
'out-build/vs/css.js',
'out-build/vs/nls.js',
'out-build/vs/text.js'
], { base: 'out-build' })
.pipe(es.through(function(data) {
if (isFirst) {
......
......@@ -34,8 +34,7 @@ var editorResources = [
var editorOtherSources = [
'out-build/vs/css.js',
'out-build/vs/nls.js',
'out-build/vs/text.js'
'out-build/vs/nls.js'
];
var BUNDLED_FILE_HEADER = [
......
......@@ -48,7 +48,6 @@ var indentationFilter = [
'!**/vs/base/common/marked/raw.marked.js',
'!**/vs/base/common/winjs.base.raw.js',
'!**/vs/base/node/terminateProcess.sh',
'!**/vs/text.js',
'!**/vs/nls.js',
'!**/vs/css.js',
'!**/vs/loader.js',
......
......@@ -12,5 +12,5 @@ exports.standaloneLanguages = require('./vs/editor/standalone-languages/buildfil
exports.standaloneLanguages2 = require('./vs/languages/buildfile-editor-languages').collectModules();
exports.entrypoint = function (name) {
return [{ name: name, include: [], exclude: ['vs/css', 'vs/nls', 'vs/text'] }];
return [{ name: name, include: [], exclude: ['vs/css', 'vs/nls'] }];
};
......@@ -8,9 +8,9 @@
exports.collectModules = function() {
return [{
name: 'vs/base/common/worker/workerServer',
exclude: [ 'vs/css', 'vs/nls', 'vs/text' ]
exclude: [ 'vs/css', 'vs/nls' ]
}, {
name: 'vs/base/common/worker/simpleWorker',
exclude: [ 'vs/css', 'vs/nls', 'vs/text' ]
exclude: [ 'vs/css', 'vs/nls' ]
}];
};
......@@ -6,7 +6,7 @@
function createModuleDescription(name, exclude) {
var result= {};
var excludes = ['vs/css', 'vs/nls', 'vs/text'];
var excludes = ['vs/css', 'vs/nls'];
result.name= name;
if (Array.isArray(exclude) && exclude.length > 0) {
excludes = excludes.concat(exclude);
......
......@@ -9,9 +9,9 @@ exports.collectModules = function() {
return [{
name: 'vs/editor/common/worker/editorWorkerServer',
include: [ 'vs/base/common/severity' ],
exclude: [ 'vs/base/common/worker/workerServer', 'vs/css', 'vs/nls', 'vs/text' ]
exclude: [ 'vs/base/common/worker/workerServer', 'vs/css', 'vs/nls' ]
}, {
name: 'vs/editor/common/services/editorSimpleWorker',
exclude: [ 'vs/base/common/worker/simpleWorker', 'vs/css', 'vs/nls', 'vs/text' ]
exclude: [ 'vs/base/common/worker/simpleWorker', 'vs/css', 'vs/nls' ]
}];
};
......@@ -23,7 +23,7 @@ var EntryPoint = (function() {
excludes = toArray(excludes);
this.result.push({
name: moduleId,
exclude: ['vs/css', 'vs/nls', 'vs/text'].concat(this.modules).concat(excludes)
exclude: ['vs/css', 'vs/nls'].concat(this.modules).concat(excludes)
});
return new EntryPoint(this.result, this.modules.concat([moduleId].concat(excludes)));
};
......@@ -48,17 +48,17 @@ exports.collectModules = function(args) {
result.push({
name: 'vs/languages/typescript/common/lib/typescriptServices',
exclude: ['vs/css', 'vs/nls', 'vs/text']
exclude: ['vs/css', 'vs/nls']
});
result.push({
name: 'vs/languages/typescript/common/worker',
exclude: ['vs/base/common/worker/simpleWorker', 'vs/languages/typescript/common/lib/typescriptServices', 'vs/css', 'vs/nls', 'vs/text']
exclude: ['vs/base/common/worker/simpleWorker', 'vs/languages/typescript/common/lib/typescriptServices', 'vs/css', 'vs/nls']
});
result.push({
name: 'vs/languages/typescript/common/mode',
exclude: ['vs/editor/editor.main', 'vs/languages/typescript/common/lib/typescriptServices', 'vs/css', 'vs/nls', 'vs/text']
exclude: ['vs/editor/editor.main', 'vs/languages/typescript/common/lib/typescriptServices', 'vs/css', 'vs/nls']
});
return result;
......
......@@ -23,7 +23,7 @@ var EntryPoint = (function() {
excludes = toArray(excludes);
this.result.push({
name: moduleId,
exclude: ['vs/css', 'vs/nls', 'vs/text'].concat(this.modules).concat(excludes)
exclude: ['vs/css', 'vs/nls'].concat(this.modules).concat(excludes)
});
return new EntryPoint(this.result, this.modules.concat([moduleId].concat(excludes)));
};
......
var fs = require('fs');
var path = require('path');
toString(path.join(__dirname, 'lib.d.ts'), path.join(__dirname, 'lib-ts.js'));
toString(path.join(__dirname, 'lib.es6.d.ts'), path.join(__dirname, 'lib-es6-ts.js'));
function toString(source, dest) {
var contents = fs.readFileSync(source).toString();
fs.writeFileSync(dest,
`/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// This is a generated file from ${path.basename(source)}
define([], { contents: "${escapeText(contents)}"});
`)
}
/**
* Escape text such that it can be used in a javascript string enclosed by double quotes (")
*/
function escapeText(text) {
// http://www.javascriptkit.com/jsref/escapesequence.shtml
// \b Backspace.
// \f Form feed.
// \n Newline.
// \O Nul character.
// \r Carriage return.
// \t Horizontal tab.
// \v Vertical tab.
// \' Single quote or apostrophe.
// \" Double quote.
// \\ Backslash.
// \ddd The Latin-1 character specified by the three octal digits between 0 and 377. ie, copyright symbol is \251.
// \xdd The Latin-1 character specified by the two hexadecimal digits dd between 00 and FF. ie, copyright symbol is \xA9.
// \udddd The Unicode character specified by the four hexadecimal digits dddd. ie, copyright symbol is \u00A9.
var _backspace = '\b'.charCodeAt(0);
var _formFeed = '\f'.charCodeAt(0);
var _newLine = '\n'.charCodeAt(0);
var _nullChar = 0;
var _carriageReturn = '\r'.charCodeAt(0);
var _tab = '\t'.charCodeAt(0);
var _verticalTab = '\v'.charCodeAt(0);
var _backslash = '\\'.charCodeAt(0);
var _doubleQuote = '"'.charCodeAt(0);
var startPos = 0, chrCode, replaceWith = null, resultPieces = [];
for (var i = 0, len = text.length; i < len; i++) {
chrCode = text.charCodeAt(i);
switch (chrCode) {
case _backspace:
replaceWith = '\\b';
break;
case _formFeed:
replaceWith = '\\f';
break;
case _newLine:
replaceWith = '\\n';
break;
case _nullChar:
replaceWith = '\\0';
break;
case _carriageReturn:
replaceWith = '\\r';
break;
case _tab:
replaceWith = '\\t';
break;
case _verticalTab:
replaceWith = '\\v';
break;
case _backslash:
replaceWith = '\\\\';
break;
case _doubleQuote:
replaceWith = '\\"';
break;
}
if (replaceWith !== null) {
resultPieces.push(text.substring(startPos, i));
resultPieces.push(replaceWith);
startPos = i + 1;
replaceWith = null;
}
}
resultPieces.push(text.substring(startPos, len));
return resultPieces.join('');
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export declare var contents: string;
\ No newline at end of file
此差异已折叠。
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export declare var contents: string;
\ No newline at end of file
此差异已折叠。
......@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/text!vs/languages/typescript/common/lib/lib.d.ts';
import 'vs/text!vs/languages/typescript/common/lib/lib.es6.d.ts';
import {contents as libdts} from 'vs/languages/typescript/common/lib/lib-ts';
import {contents as libes6ts} from 'vs/languages/typescript/common/lib/lib-es6-ts';
import * as ts from 'vs/languages/typescript/common/lib/typescriptServices';
import URI from 'vs/base/common/uri';
import {TPromise} from 'vs/base/common/winjs.base';
......@@ -13,6 +13,16 @@ import {TypeScriptWorkerProtocol, IRawModelData} from './typescript';
import {IModelContentChangedEvent2} from 'vs/editor/common/editorCommon';
import {MirrorModel2} from 'vs/editor/common/model/mirrorModel2';
const DEFAULT_LIB = {
NAME: 'defaultLib:lib.d.ts',
CONTENTS: libdts
};
const ES6_LIB = {
NAME: 'defaultLib:lib.es6.d.ts',
CONTENTS: libes6ts
};
class TypeScriptWorker extends TypeScriptWorkerProtocol implements ts.LanguageServiceHost {
// --- model sync -----------------------
......@@ -78,9 +88,10 @@ class TypeScriptWorker extends TypeScriptWorkerProtocol implements ts.LanguageSe
// static extra lib
text = this._extraLibs[fileName];
} else if (this.isDefaultLibFileName(fileName)) {
// load lib(.es6)?.d.ts as module
text = require(fileName);
} else if (fileName === DEFAULT_LIB.NAME) {
text = DEFAULT_LIB.CONTENTS;
} else if (fileName === ES6_LIB.NAME) {
text = ES6_LIB.CONTENTS;
} else {
return;
}
......@@ -98,9 +109,7 @@ class TypeScriptWorker extends TypeScriptWorkerProtocol implements ts.LanguageSe
getDefaultLibFileName(options: ts.CompilerOptions): string {
// TODO@joh support lib.es7.d.ts
return options.target > ts.ScriptTarget.ES5
? 'vs/text!vs/languages/typescript/common/lib/lib.es6.d.ts'
: 'vs/text!vs/languages/typescript/common/lib/lib.d.ts';
return options.target > ts.ScriptTarget.ES5 ? DEFAULT_LIB.NAME : ES6_LIB.NAME;
}
isDefaultLibFileName(fileName: string): boolean {
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------
* Please make sure to make edits in the .ts file at https://github.com/Microsoft/vscode-loader/
*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------
*--------------------------------------------------------------------------------------------*/
'use strict';
var TextLoaderPlugin;
(function (TextLoaderPlugin) {
var BrowserTextLoader = (function () {
function BrowserTextLoader() {
}
BrowserTextLoader.prototype.load = function (name, fileUrl, externalCallback, externalErrorback) {
var req = new XMLHttpRequest();
req.onreadystatechange = function () {
if (req.readyState === 4) {
if ((req.status >= 200 && req.status < 300) || req.status === 1223 || (req.status === 0 && req.responseText && req.responseText.length > 0)) {
externalCallback(req.responseText);
}
else {
externalErrorback(req);
}
req.onreadystatechange = null;
}
};
req.open('GET', fileUrl, true);
req.responseType = '';
// Do not set X-Requested-With to allow for cross-domain requests
// req.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
req.send(null);
};
return BrowserTextLoader;
}());
function readFileAndRemoveBOM(fs, path) {
var BOM_CHAR_CODE = 65279;
var contents = fs.readFileSync(path, 'utf8');
// Remove BOM
if (contents.charCodeAt(0) === BOM_CHAR_CODE) {
contents = contents.substring(1);
}
return contents;
}
var NodeTextLoader = (function () {
function NodeTextLoader() {
this.fs = require.nodeRequire('fs');
}
NodeTextLoader.prototype.load = function (name, fileUrl, callback, errorback) {
callback(readFileAndRemoveBOM(this.fs, fileUrl));
};
return NodeTextLoader;
}());
// ------------------------------ Finally, the plugin
var TextPlugin = (function () {
function TextPlugin(textLoader) {
this.textLoader = textLoader;
}
TextPlugin.prototype.load = function (name, req, load, config) {
config = config || {};
var myConfig = config['vs/text'] || {};
var myPaths = myConfig.paths || {};
var redirectedName = name;
for (var path in myPaths) {
if (myPaths.hasOwnProperty(path)) {
if (name.indexOf(path) === 0) {
redirectedName = myPaths[path] + name.substr(path.length);
}
}
}
var fileUrl = req.toUrl(redirectedName);
this.textLoader.load(name, fileUrl, function (contents) {
if (config.isBuild) {
TextPlugin.BUILD_MAP[name] = contents;
}
load(contents);
}, function (err) {
if (typeof load.error === 'function') {
load.error('Could not find ' + fileUrl);
}
});
};
TextPlugin.prototype.write = function (pluginName, moduleName, write) {
if (TextPlugin.BUILD_MAP.hasOwnProperty(moduleName)) {
var escapedText = Utilities.escapeText(TextPlugin.BUILD_MAP[moduleName]);
write('define("' + pluginName + '!' + moduleName + '", function () { return "' + escapedText + '"; });');
}
};
TextPlugin.BUILD_MAP = {};
return TextPlugin;
}());
TextLoaderPlugin.TextPlugin = TextPlugin;
var Utilities = (function () {
function Utilities() {
}
/**
* Escape text such that it can be used in a javascript string enclosed by double quotes (")
*/
Utilities.escapeText = function (text) {
// http://www.javascriptkit.com/jsref/escapesequence.shtml
// \b Backspace.
// \f Form feed.
// \n Newline.
// \O Nul character.
// \r Carriage return.
// \t Horizontal tab.
// \v Vertical tab.
// \' Single quote or apostrophe.
// \" Double quote.
// \\ Backslash.
// \ddd The Latin-1 character specified by the three octal digits between 0 and 377. ie, copyright symbol is \251.
// \xdd The Latin-1 character specified by the two hexadecimal digits dd between 00 and FF. ie, copyright symbol is \xA9.
// \udddd The Unicode character specified by the four hexadecimal digits dddd. ie, copyright symbol is \u00A9.
var _backspace = '\b'.charCodeAt(0);
var _formFeed = '\f'.charCodeAt(0);
var _newLine = '\n'.charCodeAt(0);
var _nullChar = 0;
var _carriageReturn = '\r'.charCodeAt(0);
var _tab = '\t'.charCodeAt(0);
var _verticalTab = '\v'.charCodeAt(0);
var _backslash = '\\'.charCodeAt(0);
var _doubleQuote = '"'.charCodeAt(0);
var startPos = 0, chrCode, replaceWith = null, resultPieces = [];
for (var i = 0, len = text.length; i < len; i++) {
chrCode = text.charCodeAt(i);
switch (chrCode) {
case _backspace:
replaceWith = '\\b';
break;
case _formFeed:
replaceWith = '\\f';
break;
case _newLine:
replaceWith = '\\n';
break;
case _nullChar:
replaceWith = '\\0';
break;
case _carriageReturn:
replaceWith = '\\r';
break;
case _tab:
replaceWith = '\\t';
break;
case _verticalTab:
replaceWith = '\\v';
break;
case _backslash:
replaceWith = '\\\\';
break;
case _doubleQuote:
replaceWith = '\\"';
break;
}
if (replaceWith !== null) {
resultPieces.push(text.substring(startPos, i));
resultPieces.push(replaceWith);
startPos = i + 1;
replaceWith = null;
}
}
resultPieces.push(text.substring(startPos, len));
return resultPieces.join('');
};
return Utilities;
}());
TextLoaderPlugin.Utilities = Utilities;
(function () {
var textLoader = null;
var isElectron = (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions['electron'] !== 'undefined');
if (typeof process !== 'undefined' && process.versions && !!process.versions.node && !isElectron) {
textLoader = new NodeTextLoader();
}
else {
textLoader = new BrowserTextLoader();
}
define('vs/text', new TextPlugin(textLoader));
})();
})(TextLoaderPlugin || (TextLoaderPlugin = {}));
......@@ -6,7 +6,7 @@
function createModuleDescription(name, exclude) {
var result = {};
var excludes = ['vs/css', 'vs/nls', 'vs/text'];
var excludes = ['vs/css', 'vs/nls'];
result.name = name;
if (Array.isArray(exclude) && exclude.length > 0) {
excludes = excludes.concat(exclude);
......
......@@ -5,7 +5,6 @@
'use strict';
import 'vs/text!./webview.html';
import URI from 'vs/base/common/uri';
import {TPromise} from 'vs/base/common/winjs.base';
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册