1
0
Alex Dima 7 жил өмнө
parent
commit
92af97ca38

+ 1 - 2
.npmignore

@@ -1,8 +1,7 @@
 /.vscode/
-/lib/
 /out/
+/scripts/
 /src/
-/test/
 /gulpfile.js
 /tsconfig.json
 /.npmignore

+ 1 - 1
ThirdPartyNotices.txt

@@ -8,7 +8,7 @@ herein, whether by implication, estoppel or otherwise.
 
 
 
-%% typescript version 1.8.10 (https://github.com/Microsoft/TypeScript)
+%% typescript version 2.7.2 (https://github.com/Microsoft/TypeScript)
 =========================================
 Copyright (c) Microsoft Corporation. All rights reserved.
 

+ 11 - 45
gulpfile.js

@@ -15,10 +15,10 @@ var rimraf = require('rimraf');
 var es = require('event-stream');
 
 var TYPESCRIPT_LIB_SOURCE = path.join(__dirname, 'node_modules', 'typescript', 'lib');
-var TYPESCRIPT_LIB_DESTINATION = path.join(__dirname, 'lib');
+var TYPESCRIPT_LIB_DESTINATION = path.join(__dirname, 'src', 'lib');
 
 gulp.task('clean-release', function(cb) { rimraf('release', { maxBusyTries: 1 }, cb); });
-gulp.task('release', ['clean-release','compile'], function() {
+gulp.task('release', ['clean-release'], function() {
 
 	var sha1 = getGitVersion(__dirname);
 	var semver = require('./package.json').version;
@@ -36,22 +36,22 @@ gulp.task('release', ['clean-release','compile'], function() {
 
 	function bundleOne(moduleId, exclude) {
 		return rjs({
-			baseUrl: '/out/',
+			baseUrl: '/out/amd/',
 			name: 'vs/language/typescript/' + moduleId,
 			out: moduleId + '.js',
 			exclude: exclude,
 			paths: {
-				'vs/language/typescript': __dirname + '/out'
+				'vs/language/typescript': __dirname + '/out/amd/'
 			}
 		})
 	}
 
 	return merge(
 		merge(
-			bundleOne('src/monaco.contribution'),
+			bundleOne('monaco.contribution'),
 			bundleOne('lib/typescriptServices'),
-			bundleOne('src/mode', ['vs/language/typescript/lib/typescriptServices']),
-			bundleOne('src/worker', ['vs/language/typescript/lib/typescriptServices'])
+			bundleOne('mode', ['vs/language/typescript/lib/typescriptServices']),
+			bundleOne('worker', ['vs/language/typescript/lib/typescriptServices'])
 		)
 		.pipe(uglify({
 			preserveComments: 'some'
@@ -65,31 +65,10 @@ gulp.task('release', ['clean-release','compile'], function() {
 		}))
 		.pipe(gulp.dest('./release/')),
 
-		gulp.src('src/monaco.d.ts').pipe(gulp.dest('./release/'))
+		gulp.src('src/monaco.d.ts').pipe(gulp.dest('./release/')),
 	);
 });
 
-
-var compilation = tsb.create(assign({ verbose: true }, require('./tsconfig.json').compilerOptions));
-
-var tsSources = require('./tsconfig.json').include.concat(require('./tsconfig.json').files);
-
-function compileTask() {
-	return merge(
-		gulp.src('lib/*.js', { base: '.' }),
-		gulp.src(tsSources).pipe(compilation())
-	)
-	.pipe(gulp.dest('out'));
-}
-
-gulp.task('clean-out', function(cb) { rimraf('out', { maxBusyTries: 1 }, cb); });
-gulp.task('compile', ['clean-out'], compileTask);
-gulp.task('compile-without-clean', compileTask);
-gulp.task('watch', ['compile'], function() {
-	gulp.watch(tsSources, ['compile-without-clean']);
-});
-
-
 /**
  * Import files from TypeScript's dist
  */
@@ -132,27 +111,14 @@ function importLibDeclarationFile(name) {
 
 	var contents = fs.readFileSync(srcPath).toString();
 
-	var dstPath1 = path.join(TYPESCRIPT_LIB_DESTINATION, dstName + '.js');
-	fs.writeFileSync(dstPath1,
-`/*---------------------------------------------------------------------------------------------
- *  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 ${name}
-
-define([], function() { return { contents: "${escapeText(contents)}"}; });
-
-`);
-
-	var dstPath2 = path.join(TYPESCRIPT_LIB_DESTINATION, dstName + '.d.ts');
-	fs.writeFileSync(dstPath2,
+	var dstPath = path.join(TYPESCRIPT_LIB_DESTINATION, dstName + '.ts');
+	fs.writeFileSync(dstPath,
 `/*---------------------------------------------------------------------------------------------
  *  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;
+export const contents = "${escapeText(contents)}";
 `);
 }
 

+ 0 - 6
lib/lib-es6-ts.d.ts

@@ -1,6 +0,0 @@
-/*---------------------------------------------------------------------------------------------
- *  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;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 7
lib/lib-es6-ts.js


+ 0 - 6
lib/lib-ts.d.ts

@@ -1,6 +0,0 @@
-/*---------------------------------------------------------------------------------------------
- *  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;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 7
lib/lib-ts.js


+ 3 - 2
package.json

@@ -4,8 +4,9 @@
   "description": "TypeScript and JavaScript language support for Monaco Editor",
   "scripts": {
     "test": "mocha",
-    "watch": "gulp watch",
-    "prepublish": "gulp release",
+    "compile": "node ./scripts/rmdir.js ./out && node ./scripts/copy.js ./src/lib/typescriptServices.js ./out/amd/lib/typescriptServices.js && tsc -p ./src",
+    "watch": "tsc -p ./src --watch",
+    "prepublish": "npm run compile && gulp release",
     "import-typescript": "gulp import-typescript"
   },
   "author": "Microsoft Corporation",

+ 25 - 0
scripts/copy.js

@@ -0,0 +1,25 @@
+const fs = require('fs');
+const path = require('path');
+
+const source = path.join(process.cwd(), process.argv[2]);
+const destination = path.join(process.cwd(), process.argv[3]);
+
+// ensure target dir
+(function () {
+	let dirs = [];
+	let dirname = path.dirname(destination);
+	while (dirname !== process.cwd()) {
+		dirs.push(dirname);
+		dirname = path.dirname(dirname);
+	}
+
+	dirs.reverse();
+
+	dirs.forEach((dir) => {
+		try { fs.mkdirSync(dir); } catch (err) { }
+	})
+})();
+
+fs.writeFileSync(destination, fs.readFileSync(source));
+
+console.log(`Copied ${process.argv[2]} to ${process.argv[3]}`);

+ 21 - 0
scripts/rmdir.js

@@ -0,0 +1,21 @@
+const fs = require('fs');
+const path = require('path');
+
+const target = path.join(process.cwd(), process.argv[2]);
+rmDir(target);
+console.log(`Deleted ${process.argv[2]}`);
+
+function rmDir(dirPath) {
+	let entries = fs.readdirSync(dirPath);
+	if (entries.length > 0) {
+		for (var i = 0; i < entries.length; i++) {
+			var filePath = path.join(dirPath, entries[i]);
+			if (fs.statSync(filePath).isFile()) {
+				fs.unlinkSync(filePath);
+			} else {
+				rmDir(filePath);
+			}
+		}
+	}
+	fs.rmdirSync(dirPath);
+}

+ 1 - 1
src/languageFeatures.ts

@@ -5,7 +5,7 @@
 'use strict';
 
 import { LanguageServiceDefaultsImpl } from './monaco.contribution';
-import * as ts from '../lib/typescriptServices';
+import * as ts from './lib/typescriptServices';
 import { TypeScriptWorker } from './worker';
 
 import Uri = monaco.Uri;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 5 - 0
src/lib/lib-es6-ts.ts


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 5 - 0
src/lib/lib-ts.ts


+ 0 - 0
lib/typescriptServices.d.ts → src/lib/typescriptServices.d.ts


+ 0 - 0
lib/typescriptServices.js → src/lib/typescriptServices.js


+ 1 - 1
src/monaco.contribution.ts

@@ -196,7 +196,7 @@ monaco.languages.typescript = createAPI();
 // --- Registration to monaco editor ---
 
 function withMode(callback: (module: typeof mode) => void): void {
-	require<typeof mode>(['vs/language/typescript/src/mode'], callback);
+	require<typeof mode>(['./mode'], callback);
 }
 
 monaco.languages.register({

+ 0 - 0
test/assert.d.ts → src/test/assert.d.ts


+ 0 - 0
test/mocha.d.ts → src/test/mocha.d.ts


+ 1 - 1
test/tokenization.test.ts → src/test/tokenization.test.ts

@@ -5,7 +5,7 @@
 'use strict';
 
 import * as assert from 'assert';
-import {createTokenizationSupport, Language} from '../src/tokenization';
+import {createTokenizationSupport, Language} from '../tokenization';
 
 suite('tokenization', () => {
 

+ 1 - 1
src/tokenization.ts

@@ -4,7 +4,7 @@
  *--------------------------------------------------------------------------------------------*/
 'use strict';
 
-import ts = require('../lib/typescriptServices');
+import ts = require('./lib/typescriptServices');
 
 export enum Language {
 	TypeScript,

+ 13 - 0
src/tsconfig.json

@@ -0,0 +1,13 @@
+{
+  "compilerOptions": {
+    "module": "amd",
+    "outDir": "../out/amd",
+    "target": "es5"
+  },
+  "include": [
+    "**/*.ts"
+  ],
+  "files": [
+    "../node_modules/monaco-editor-core/monaco.d.ts"
+  ]
+}

+ 3 - 3
src/worker.ts

@@ -4,9 +4,9 @@
  *--------------------------------------------------------------------------------------------*/
 'use strict';
 
-import ts = require('../lib/typescriptServices');
-import { contents as libdts } from '../lib/lib-ts';
-import { contents as libes6ts } from '../lib/lib-es6-ts';
+import ts = require('./lib/typescriptServices');
+import { contents as libdts } from './lib/lib-ts';
+import { contents as libes6ts } from './lib/lib-es6-ts';
 
 import Promise = monaco.Promise;
 import IWorkerContext = monaco.worker.IWorkerContext;

+ 1 - 1
src/workerManager.ts

@@ -63,7 +63,7 @@ export class WorkerManager {
 			this._worker = monaco.editor.createWebWorker<TypeScriptWorker>({
 
 				// module that exports the create() method and returns a `TypeScriptWorker` instance
-				moduleId: 'vs/language/typescript/src/worker',
+				moduleId: 'vs/language/typescript/worker',
 
 				label: this._modeId,
 

+ 1 - 1
test/all.js

@@ -4,7 +4,7 @@ var path = require('path');
 requirejs.config({
     baseUrl: 'out',
     paths: {
-        'vs/language/typescript': path.join(__dirname, '/../out')
+        'vs/language/typescript': path.join(__dirname, '/../out/amd')
     },
     nodeRequire: require
 });

+ 0 - 15
tsconfig.json

@@ -1,15 +0,0 @@
-{
-  "compilerOptions": {
-    "module": "amd",
-    "outDir": "out",
-    "target": "es5"
-  },
-  "include": [
-    "src/*.ts",
-    "test/*.ts",
-    "lib/*.d.ts"
-  ],
-  "files": [
-    "node_modules/monaco-editor-core/monaco.d.ts"
-  ]
-}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно