Browse Source

Move css sources into `/src/`

Alex Dima 3 years ago
parent
commit
b3f2986d69

+ 1 - 2
.prettierignore

@@ -1,5 +1,4 @@
-/monaco-css/out/
-/monaco-css/release/
+/out/
 /monaco-editor-samples/browser-esm-parcel/.cache/
 /monaco-editor-samples/browser-esm-parcel/dist/
 /monaco-editor-samples/browser-esm-webpack/dist/*.js

+ 17 - 18
monaco-css/build.js → build/build.js

@@ -5,37 +5,36 @@
 
 //@ts-check
 
-const { removeDir, tsc, dts, buildESM, buildAMD } = require('../build/utils');
+const { removeDir, tsc, dts, buildESM2, buildAMD2 } = require('../build/utils');
 
-removeDir(`monaco-css/release`);
-removeDir(`monaco-css/out`);
+removeDir(`out`);
 
-tsc(`monaco-css/src/tsconfig.json`);
+tsc(`src/tsconfig.json`);
 
 dts(
-	`monaco-css/out/amd/monaco.contribution.d.ts`,
-	`monaco-css/monaco.d.ts`,
+	`out/amd/css/monaco.contribution.d.ts`,
+	`out/release/css/monaco.d.ts`,
 	'monaco.languages.css'
 );
 
-buildESM({
-	base: 'monaco-css',
-	entryPoints: ['src/monaco.contribution.ts', 'src/cssMode.ts', 'src/css.worker.ts'],
+buildESM2({
+	base: 'css',
+	entryPoints: ['src/css/monaco.contribution.ts', 'src/css/cssMode.ts', 'src/css/css.worker.ts'],
 	external: ['monaco-editor-core', '*/cssMode']
 });
-buildAMD({
-	base: 'monaco-css',
-	entryPoint: 'src/monaco.contribution.ts',
+buildAMD2({
+	base: 'css',
+	entryPoint: 'src/css/monaco.contribution.ts',
 	amdModuleId: 'vs/language/css/monaco.contribution',
 	amdDependencies: ['vs/editor/editor.api']
 });
-buildAMD({
-	base: 'monaco-css',
-	entryPoint: 'src/cssMode.ts',
+buildAMD2({
+	base: 'css',
+	entryPoint: 'src/css/cssMode.ts',
 	amdModuleId: 'vs/language/css/cssMode'
 });
-buildAMD({
-	base: 'monaco-css',
-	entryPoint: 'src/cssWorker.ts',
+buildAMD2({
+	base: 'css',
+	entryPoint: 'src/css/cssWorker.ts',
 	amdModuleId: 'vs/language/css/cssWorker'
 });

+ 107 - 20
build/utils.js

@@ -13,6 +13,25 @@ const alias = require('esbuild-plugin-alias');
 
 const REPO_ROOT = path.join(__dirname, '..');
 
+/**
+ * @param {string} dirname
+ */
+function ensureDir(dirname) {
+	/** @type {string[]} */
+	const dirs = [];
+
+	while (dirname.length > REPO_ROOT.length) {
+		dirs.push(dirname);
+		dirname = path.dirname(dirname);
+	}
+	dirs.reverse();
+	dirs.forEach(function (dir) {
+		try {
+			fs.mkdirSync(dir);
+		} catch (err) {}
+	});
+}
+
 /**
  * Copy a file.
  *
@@ -23,24 +42,7 @@ function copyFile(_source, _destination) {
 	const source = path.join(REPO_ROOT, _source);
 	const destination = path.join(REPO_ROOT, _destination);
 
-	// ensure target dir
-	(function () {
-		/** @type {string[]} */
-		const dirs = [];
-		/** @type {string} */
-		let dirname = path.dirname(destination);
-		while (dirname.length > REPO_ROOT.length) {
-			dirs.push(dirname);
-			dirname = path.dirname(dirname);
-		}
-		dirs.reverse();
-		dirs.forEach(function (dir) {
-			try {
-				fs.mkdirSync(dir);
-			} catch (err) {}
-		});
-	})();
-
+	ensureDir(path.dirname(destination));
 	fs.writeFileSync(destination, fs.readFileSync(source));
 
 	console.log(`Copied ${_source} to ${_destination}`);
@@ -134,8 +136,6 @@ function dts(_source, _destination, namespace) {
 		` *  Licensed under the MIT License. See License.txt in the project root for license information.`,
 		` *--------------------------------------------------------------------------------------------*/`,
 		``,
-		`/// <reference path="../node_modules/monaco-editor-core/monaco.d.ts" />`,
-		``,
 		`declare namespace ${namespace} {`
 	];
 	for (let line of lines) {
@@ -155,6 +155,7 @@ function dts(_source, _destination, namespace) {
 	result.push(`}`);
 	result.push(``);
 
+	ensureDir(path.dirname(destination));
 	fs.writeFileSync(destination, result.join('\n'));
 
 	prettier(_destination);
@@ -207,6 +208,37 @@ function buildESM(options) {
 }
 exports.buildESM = buildESM;
 
+/**
+ * @param {{
+ *   base: string;
+ *   entryPoints: string[];
+ *   external: string[];
+ * }} options
+ */
+function buildESM2(options) {
+	build({
+		entryPoints: options.entryPoints,
+		bundle: true,
+		target: 'esnext',
+		format: 'esm',
+		define: {
+			AMD: 'false'
+		},
+		banner: {
+			js: bundledFileHeader
+		},
+		external: options.external,
+		outbase: `src/${options.base}`,
+		outdir: `out/release/${options.base}/esm/`,
+		plugins: [
+			alias({
+				'vscode-nls': path.join(__dirname, 'fillers/vscode-nls.ts')
+			})
+		]
+	});
+}
+exports.buildESM2 = buildESM2;
+
 /**
  * @param {'dev'|'min'} type
  * @param {{
@@ -262,6 +294,61 @@ function buildAMD(options) {
 }
 exports.buildAMD = buildAMD;
 
+/**
+ * @param {'dev'|'min'} type
+ * @param {{
+ *   base: string;
+ *   entryPoint: string;
+ *   amdModuleId: string;
+ *   amdDependencies?: string[];
+ * }} options
+ */
+function buildOneAMD2(type, options) {
+	/** @type {import('esbuild').BuildOptions} */
+	const opts = {
+		entryPoints: [options.entryPoint],
+		bundle: true,
+		target: 'esnext',
+		format: 'iife',
+		define: {
+			AMD: 'true'
+		},
+		globalName: 'moduleExports',
+		banner: {
+			js: `${bundledFileHeader}define("${options.amdModuleId}",[${(options.amdDependencies || []).map(dep => (`"${dep}"`)).join(',')}],()=>{`
+		},
+		footer: {
+			js: 'return moduleExports;\n});'
+		},
+		outbase: `src/${options.base}`,
+		outdir: `out/release/${options.base}/${type}/`,
+		plugins: [
+			alias({
+				'vscode-nls': path.join(__dirname, '../build/fillers/vscode-nls.ts'),
+				'monaco-editor-core': path.join(__dirname, '../build/fillers/monaco-editor-core-amd.ts')
+			})
+		]
+	};
+	if (type === 'min') {
+		opts.minify = true;
+	}
+	build(opts);
+}
+
+/**
+ * @param {{
+ *   base: string;
+ *   entryPoint: string;
+ *   amdModuleId: string;
+ *   amdDependencies?: string[];
+ * }} options
+ */
+function buildAMD2(options) {
+	buildOneAMD2('dev', options);
+	buildOneAMD2('min', options);
+}
+exports.buildAMD2 = buildAMD2;
+
 function getGitVersion() {
 	const git = path.join(REPO_ROOT, '.git');
 	const headPath = path.join(git, 'HEAD');

+ 0 - 171
monaco-css/monaco.d.ts

@@ -1,171 +0,0 @@
-/*---------------------------------------------------------------------------------------------
- *  Copyright (c) Microsoft Corporation. All rights reserved.
- *  Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
-
-/// <reference path="../node_modules/monaco-editor-core/monaco.d.ts" />
-
-declare namespace monaco.languages.css {
-	export interface Options {
-		readonly validate?: boolean;
-		readonly lint?: {
-			readonly compatibleVendorPrefixes?: 'ignore' | 'warning' | 'error';
-			readonly vendorPrefix?: 'ignore' | 'warning' | 'error';
-			readonly duplicateProperties?: 'ignore' | 'warning' | 'error';
-			readonly emptyRules?: 'ignore' | 'warning' | 'error';
-			readonly importStatement?: 'ignore' | 'warning' | 'error';
-			readonly boxModel?: 'ignore' | 'warning' | 'error';
-			readonly universalSelector?: 'ignore' | 'warning' | 'error';
-			readonly zeroUnits?: 'ignore' | 'warning' | 'error';
-			readonly fontFaceProperties?: 'ignore' | 'warning' | 'error';
-			readonly hexColorLength?: 'ignore' | 'warning' | 'error';
-			readonly argumentsInColorFunction?: 'ignore' | 'warning' | 'error';
-			readonly unknownProperties?: 'ignore' | 'warning' | 'error';
-			readonly ieHack?: 'ignore' | 'warning' | 'error';
-			readonly unknownVendorSpecificProperties?: 'ignore' | 'warning' | 'error';
-			readonly propertyIgnoredDueToDisplay?: 'ignore' | 'warning' | 'error';
-			readonly important?: 'ignore' | 'warning' | 'error';
-			readonly float?: 'ignore' | 'warning' | 'error';
-			readonly idSelector?: 'ignore' | 'warning' | 'error';
-		};
-		/**
-		 * Configures the CSS data types known by the langauge service.
-		 */
-		readonly data?: CSSDataConfiguration;
-	}
-	export interface ModeConfiguration {
-		/**
-		 * Defines whether the built-in completionItemProvider is enabled.
-		 */
-		readonly completionItems?: boolean;
-		/**
-		 * Defines whether the built-in hoverProvider is enabled.
-		 */
-		readonly hovers?: boolean;
-		/**
-		 * Defines whether the built-in documentSymbolProvider is enabled.
-		 */
-		readonly documentSymbols?: boolean;
-		/**
-		 * Defines whether the built-in definitions provider is enabled.
-		 */
-		readonly definitions?: boolean;
-		/**
-		 * Defines whether the built-in references provider is enabled.
-		 */
-		readonly references?: boolean;
-		/**
-		 * Defines whether the built-in references provider is enabled.
-		 */
-		readonly documentHighlights?: boolean;
-		/**
-		 * Defines whether the built-in rename provider is enabled.
-		 */
-		readonly rename?: boolean;
-		/**
-		 * Defines whether the built-in color provider is enabled.
-		 */
-		readonly colors?: boolean;
-		/**
-		 * Defines whether the built-in foldingRange provider is enabled.
-		 */
-		readonly foldingRanges?: boolean;
-		/**
-		 * Defines whether the built-in diagnostic provider is enabled.
-		 */
-		readonly diagnostics?: boolean;
-		/**
-		 * Defines whether the built-in selection range provider is enabled.
-		 */
-		readonly selectionRanges?: boolean;
-	}
-	export interface LanguageServiceDefaults {
-		readonly languageId: string;
-		readonly onDidChange: IEvent<LanguageServiceDefaults>;
-		readonly modeConfiguration: ModeConfiguration;
-		readonly options: Options;
-		setOptions(options: Options): void;
-		setModeConfiguration(modeConfiguration: ModeConfiguration): void;
-		/** @deprecated Use options instead */
-		readonly diagnosticsOptions: DiagnosticsOptions;
-		/** @deprecated Use setOptions instead */
-		setDiagnosticsOptions(options: DiagnosticsOptions): void;
-	}
-	/** @deprecated Use Options instead */
-	export type DiagnosticsOptions = Options;
-	export const cssDefaults: LanguageServiceDefaults;
-	export const scssDefaults: LanguageServiceDefaults;
-	export const lessDefaults: LanguageServiceDefaults;
-	export interface CSSDataConfiguration {
-		/**
-		 * Defines whether the standard CSS properties, at-directives, pseudoClasses and pseudoElements are shown.
-		 */
-		useDefaultDataProvider?: boolean;
-		/**
-		 * Provides a set of custom data providers.
-		 */
-		dataProviders?: {
-			[providerId: string]: CSSDataV1;
-		};
-	}
-	/**
-	 * Custom CSS properties, at-directives, pseudoClasses and pseudoElements
-	 * https://github.com/microsoft/vscode-css-languageservice/blob/main/docs/customData.md
-	 */
-	export interface CSSDataV1 {
-		version: 1 | 1.1;
-		properties?: IPropertyData[];
-		atDirectives?: IAtDirectiveData[];
-		pseudoClasses?: IPseudoClassData[];
-		pseudoElements?: IPseudoElementData[];
-	}
-	export type EntryStatus = 'standard' | 'experimental' | 'nonstandard' | 'obsolete';
-	export interface IReference {
-		name: string;
-		url: string;
-	}
-	export interface IPropertyData {
-		name: string;
-		description?: string | MarkupContent;
-		browsers?: string[];
-		restrictions?: string[];
-		status?: EntryStatus;
-		syntax?: string;
-		values?: IValueData[];
-		references?: IReference[];
-		relevance?: number;
-	}
-	export interface IAtDirectiveData {
-		name: string;
-		description?: string | MarkupContent;
-		browsers?: string[];
-		status?: EntryStatus;
-		references?: IReference[];
-	}
-	export interface IPseudoClassData {
-		name: string;
-		description?: string | MarkupContent;
-		browsers?: string[];
-		status?: EntryStatus;
-		references?: IReference[];
-	}
-	export interface IPseudoElementData {
-		name: string;
-		description?: string | MarkupContent;
-		browsers?: string[];
-		status?: EntryStatus;
-		references?: IReference[];
-	}
-	export interface IValueData {
-		name: string;
-		description?: string | MarkupContent;
-		browsers?: string[];
-		status?: EntryStatus;
-		references?: IReference[];
-	}
-	export interface MarkupContent {
-		kind: MarkupKind;
-		value: string;
-	}
-	export type MarkupKind = 'plaintext' | 'markdown';
-}

+ 4 - 4
monaco-editor/metadata.js

@@ -27,12 +27,12 @@
 				name: 'monaco-css',
 				contrib: 'vs/language/css/monaco.contribution',
 				modulePrefix: 'vs/language/css',
-				rootPath: './monaco-css',
+				rootPath: './out/release/css',
 				paths: {
 					// use ./ to indicate it is relative to the `rootPath`
-					dev: './release/dev',
-					min: './release/min',
-					esm: './release/esm'
+					dev: './dev',
+					min: './min',
+					esm: './esm'
 				}
 			},
 			{

+ 0 - 1
monaco-editor/typedoc/monaco.d.ts

@@ -7352,7 +7352,6 @@ declare namespace monaco.languages.typescript {
  *  Licensed under the MIT License. See License.txt in the project root for license information.
  *--------------------------------------------------------------------------------------------*/
 
-
 declare namespace monaco.languages.css {
     export interface Options {
         readonly validate?: boolean;

+ 0 - 1
monaco-editor/website/playground/monaco.d.ts.txt

@@ -7352,7 +7352,6 @@ declare namespace monaco.languages.typescript {
  *  Licensed under the MIT License. See License.txt in the project root for license information.
  *--------------------------------------------------------------------------------------------*/
 
-
 declare namespace monaco.languages.css {
     export interface Options {
         readonly validate?: boolean;

+ 2 - 2
package.json

@@ -8,12 +8,12 @@
 	"scripts": {
 		"simpleserver": "gulp simpleserver",
 		"import-typescript": "node ./monaco-typescript/importTypescript",
-		"watch-css": "tsc -w -p ./monaco-css/src",
+		"watch-src": "tsc -w -p ./src",
 		"watch-html": "tsc -w -p ./monaco-html/src",
 		"watch-json": "tsc -w -p ./monaco-json/src",
 		"watch-languages": "tsc -w -p ./monaco-languages/src",
 		"watch-typescript": "tsc -w -p ./monaco-typescript/src",
-		"watch": "npm-run-all -lp watch-css watch-html watch-json watch-languages watch-typescript",
+		"watch": "npm-run-all -lp watch-src watch-html watch-json watch-languages watch-typescript",
 		"release-css": "node ./monaco-css/build",
 		"release-html": "node ./monaco-html/build",
 		"release-json": "node ./monaco-json/build",

+ 0 - 0
monaco-css/src/css.worker.ts → src/css/css.worker.ts


+ 1 - 1
monaco-css/src/cssMode.ts → src/css/cssMode.ts

@@ -7,7 +7,7 @@ import { WorkerManager } from './workerManager';
 import type { CSSWorker } from './cssWorker';
 import { LanguageServiceDefaults } from './monaco.contribution';
 import * as languageFeatures from './languageFeatures';
-import { Uri, IDisposable, languages } from './fillers/monaco-editor-core';
+import { Uri, IDisposable, languages } from '../fillers/monaco-editor-core';
 
 export function setupMode(defaults: LanguageServiceDefaults): IDisposable {
 	const disposables: IDisposable[] = [];

+ 1 - 1
monaco-css/src/cssWorker.ts → src/css/cssWorker.ts

@@ -3,7 +3,7 @@
  *  Licensed under the MIT License. See License.txt in the project root for license information.
  *--------------------------------------------------------------------------------------------*/
 
-import type { worker } from './fillers/monaco-editor-core';
+import type { worker } from '../fillers/monaco-editor-core';
 import * as cssService from 'vscode-css-languageservice';
 import { Options } from './monaco.contribution';
 

+ 1 - 1
monaco-css/src/languageFeatures.ts → src/css/languageFeatures.ts

@@ -17,7 +17,7 @@ import {
 	CancellationToken,
 	IDisposable,
 	MarkerSeverity
-} from './fillers/monaco-editor-core';
+} from '../fillers/monaco-editor-core';
 import { TextEdit } from 'vscode-css-languageservice';
 import { InsertReplaceEdit } from 'vscode-languageserver-types';
 

+ 1 - 1
monaco-css/src/monaco.contribution.ts → src/css/monaco.contribution.ts

@@ -4,7 +4,7 @@
  *--------------------------------------------------------------------------------------------*/
 
 import * as mode from './cssMode';
-import { languages, Emitter, IEvent } from './fillers/monaco-editor-core';
+import { languages, Emitter, IEvent } from '../fillers/monaco-editor-core';
 
 export interface Options {
 	readonly validate?: boolean;

+ 1 - 1
monaco-css/src/workerManager.ts → src/css/workerManager.ts

@@ -5,7 +5,7 @@
 
 import { LanguageServiceDefaults } from './monaco.contribution';
 import type { CSSWorker } from './cssWorker';
-import { editor, IDisposable, Uri } from './fillers/monaco-editor-core';
+import { editor, IDisposable, Uri } from '../fillers/monaco-editor-core';
 
 const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
 

+ 0 - 0
monaco-css/src/fillers/monaco-editor-core.ts → src/fillers/monaco-editor-core.ts


+ 0 - 0
monaco-css/src/tsconfig.json → src/tsconfig.json