Skip to content

Commit

Permalink
Use the global monaco only in the AMD case (see microsoft/monaco-ed…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima authored and Pierre Guillaume Herveou committed Sep 21, 2020
1 parent afbf66e commit b01b579
Show file tree
Hide file tree
Showing 22 changed files with 843 additions and 392 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules/
/out/
/release/
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/.github/
/.vscode/
/scripts/
/src/
/test/
/gulpfile.js
/tsconfig.json
/.npmignore
/out/
/release/**/test/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/out/
/release/
/src/lib/
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"files.trimTrailingWhitespace": true,
"search.exclude": {
"**/node_modules": true,
"**/out": true,
"**/release": true
}
}
81 changes: 24 additions & 57 deletions src/monaco.d.ts → monaco.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
declare module monaco.languages.typescript {
enum ModuleKind {
/*---------------------------------------------------------------------------------------------
* 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.typescript {
export enum ModuleKind {
None = 0,
CommonJS = 1,
AMD = 2,
Expand All @@ -8,19 +15,17 @@ declare module monaco.languages.typescript {
ES2015 = 5,
ESNext = 99
}

enum JsxEmit {
export enum JsxEmit {
None = 0,
Preserve = 1,
React = 2,
ReactNative = 3
}
enum NewLineKind {
export enum NewLineKind {
CarriageReturnLineFeed = 0,
LineFeed = 1
}

enum ScriptTarget {
export enum ScriptTarget {
ES3 = 0,
ES5 = 1,
ES2015 = 2,
Expand All @@ -31,19 +36,16 @@ declare module monaco.languages.typescript {
ES2020 = 7,
ESNext = 99,
JSON = 100,
Latest = ESNext
Latest = 99
}

export enum ModuleResolutionKind {
Classic = 1,
NodeJs = 2
}

interface MapLike<T> {
[index: string]: T;
}

type CompilerOptionsValue =
declare type CompilerOptionsValue =
| string
| number
| boolean
Expand Down Expand Up @@ -135,28 +137,23 @@ declare module monaco.languages.typescript {
useDefineForClassFields?: boolean;
[option: string]: CompilerOptionsValue | undefined;
}

export interface DiagnosticsOptions {
noSemanticValidation?: boolean;
noSyntaxValidation?: boolean;
noSuggestionDiagnostics?: boolean;
diagnosticCodesToIgnore?: number[];
}

export interface WorkerOptions {
/** A full HTTP path to a JavaScript file which adds a function `customTSWorkerFactory` to the self inside a web-worker */
customWorkerPath?: string;
}

interface IExtraLib {
content: string;
version: number;
}

interface IExtraLibs {
export interface IExtraLibs {
[path: string]: IExtraLib;
}

/**
* A linked list of formatted diagnostic messages to be used as part of a multiline message.
* It is built from the bottom up, leaving the head to be the "main" diagnostic.
Expand All @@ -168,7 +165,7 @@ declare module monaco.languages.typescript {
code: number;
next?: DiagnosticMessageChain[];
}
interface Diagnostic extends DiagnosticRelatedInformation {
export interface Diagnostic extends DiagnosticRelatedInformation {
/** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */
reportsUnnecessary?: {};
source?: string;
Expand All @@ -184,7 +181,6 @@ declare module monaco.languages.typescript {
length: number | undefined;
messageText: string | DiagnosticMessageChain;
}

interface EmitOutput {
outputFiles: OutputFile[];
emitSkipped: boolean;
Expand All @@ -194,23 +190,20 @@ declare module monaco.languages.typescript {
writeByteOrderMark: boolean;
text: string;
}

export interface LanguageServiceDefaults {
/**
* Event fired when compiler options or diagnostics options are changed.
*/
readonly onDidChange: IEvent<void>;

/**
* Event fired when extra libraries registered with the language service change.
*/
readonly onDidExtraLibsChange: IEvent<void>;

readonly workerOptions: WorkerOptions;
/**
* Get the current extra libs registered with the language service.
*/
getExtraLibs(): IExtraLibs;

/**
* Add an additional source file to the language service. Use this
* for typescript (definition) files that won't be loaded as editor
Expand All @@ -222,81 +215,72 @@ declare module monaco.languages.typescript {
* language service upon disposal.
*/
addExtraLib(content: string, filePath?: string): IDisposable;

/**
* Remove all existing extra libs and set the additional source
* files to the language service. Use this for typescript definition
* files that won't be loaded as editor documents, like `jquery.d.ts`.
* @param libs An array of entries to register.
*/
setExtraLibs(libs: { content: string; filePath?: string }[]): void;

setExtraLibs(
libs: {
content: string;
filePath?: string;
}[]
): void;
/**
* Get current TypeScript compiler options for the language service.
*/
getCompilerOptions(): CompilerOptions;

/**
* Set TypeScript compiler options.
*/
setCompilerOptions(options: CompilerOptions): void;

/**
* Get the current diagnostics options for the language service.
*/
getDiagnosticsOptions(): DiagnosticsOptions;

/**
* Configure whether syntactic and/or semantic validation should
* be performed
*/
setDiagnosticsOptions(options: DiagnosticsOptions): void;

/**
* No-op.
*/
setMaximumWorkerIdleTime(value: number): void;

/**
* Configure if all existing models should be eagerly sync'd
* to the worker on start or restart.
*/
setEagerModelSync(value: boolean): void;

/**
* Get the current setting for whether all existing models should be eagerly sync'd
* to the worker on start or restart.
*/
getEagerModelSync(): boolean;
}

export interface TypeScriptWorker {
/**
* Get diagnostic messages for any syntax issues in the given file.
*/
getSyntacticDiagnostics(fileName: string): Promise<Diagnostic[]>;

/**
* Get diagnostic messages for any semantic issues in the given file.
*/
getSemanticDiagnostics(fileName: string): Promise<Diagnostic[]>;

/**
* Get diagnostic messages for any suggestions related to the given file.
*/
getSuggestionDiagnostics(fileName: string): Promise<Diagnostic[]>;

/**
* Get the content of a given file.
*/
getScriptText(fileName: string): Promise<string | undefined>;

/**
* Get diagnostic messages related to the current compiler options.
* @param fileName Not used
*/
getCompilerOptionsDiagnostics(fileName: string): Promise<Diagnostic[]>;

/**
* Get code completions for the given file and position.
* @returns `Promise<typescript.CompletionInfo | undefined>`
Expand All @@ -305,7 +289,6 @@ declare module monaco.languages.typescript {
fileName: string,
position: number
): Promise<any | undefined>;

/**
* Get code completion details for the given file, position, and entry.
* @returns `Promise<typescript.CompletionEntryDetails | undefined>`
Expand All @@ -315,7 +298,6 @@ declare module monaco.languages.typescript {
position: number,
entry: string
): Promise<any | undefined>;

/**
* Get signature help items for the item at the given file and position.
* @returns `Promise<typescript.SignatureHelpItems | undefined>`
Expand All @@ -324,7 +306,6 @@ declare module monaco.languages.typescript {
fileName: string,
position: number
): Promise<any | undefined>;

/**
* Get quick info for the item at the given position in the file.
* @returns `Promise<typescript.QuickInfo | undefined>`
Expand All @@ -333,7 +314,6 @@ declare module monaco.languages.typescript {
fileName: string,
position: number
): Promise<any | undefined>;

/**
* Get other ranges which are related to the item at the given position in the file (often used for highlighting).
* @returns `Promise<ReadonlyArray<typescript.ReferenceEntry> | undefined>`
Expand All @@ -342,7 +322,6 @@ declare module monaco.languages.typescript {
fileName: string,
position: number
): Promise<ReadonlyArray<any> | undefined>;

/**
* Get the definition of the item at the given position in the file.
* @returns `Promise<ReadonlyArray<typescript.DefinitionInfo> | undefined>`
Expand All @@ -351,7 +330,6 @@ declare module monaco.languages.typescript {
fileName: string,
position: number
): Promise<ReadonlyArray<any> | undefined>;

/**
* Get references to the item at the given position in the file.
* @returns `Promise<typescript.ReferenceEntry[] | undefined>`
Expand All @@ -360,13 +338,11 @@ declare module monaco.languages.typescript {
fileName: string,
position: number
): Promise<any[] | undefined>;

/**
* Get outline entries for the item at the given position in the file.
* @returns `Promise<typescript.NavigationBarItem[]>`
*/
getNavigationBarItems(fileName: string): Promise<any[]>;

/**
* Get changes which should be applied to format the given file.
* @param options `typescript.FormatCodeOptions`
Expand All @@ -376,7 +352,6 @@ declare module monaco.languages.typescript {
fileName: string,
options: any
): Promise<any[]>;

/**
* Get changes which should be applied to format the given range in the file.
* @param options `typescript.FormatCodeOptions`
Expand All @@ -388,7 +363,6 @@ declare module monaco.languages.typescript {
end: number,
options: any
): Promise<any[]>;

/**
* Get formatting changes which should be applied after the given keystroke.
* @param options `typescript.FormatCodeOptions`
Expand All @@ -400,7 +374,6 @@ declare module monaco.languages.typescript {
ch: string,
options: any
): Promise<any[]>;

/**
* Get other occurrences which should be updated when renaming the item at the given file and position.
* @returns `Promise<readonly typescript.RenameLocation[] | undefined>`
Expand All @@ -412,7 +385,6 @@ declare module monaco.languages.typescript {
findInComments: boolean,
providePrefixAndSuffixTextForRename: boolean
): Promise<readonly any[] | undefined>;

/**
* Get edits which should be applied to rename the item at the given file and position (or a failure reason).
* @param options `typescript.RenameInfoOptions`
Expand All @@ -423,13 +395,11 @@ declare module monaco.languages.typescript {
positon: number,
options: any
): Promise<any>;

/**
* Get transpiled output for the given file.
* @returns `typescript.EmitOutput`
*/
getEmitOutput(fileName: string): Promise<any>;

getEmitOutput(fileName: string): Promise<EmitOutput>;
/**
* Get possible code fixes at the given position in the file.
* @param formatOptions `typescript.FormatCodeOptions`
Expand All @@ -443,12 +413,9 @@ declare module monaco.languages.typescript {
formatOptions: any
): Promise<ReadonlyArray<any>>;
}

export const typescriptVersion: string;

export const typescriptDefaults: LanguageServiceDefaults;
export const javascriptDefaults: LanguageServiceDefaults;

export const getTypeScriptWorker: () => Promise<
(...uris: Uri[]) => Promise<TypeScriptWorker>
>;
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "3.7.0",
"description": "TypeScript and JavaScript language support for Monaco Editor",
"scripts": {
"compile-amd": "mcopy ./src/lib/typescriptServices-amd.js ./release/dev/lib/typescriptServices.js && tsc -p ./src/tsconfig.json",
"compile-esm": "mcopy ./src/lib/typescriptServices.js ./release/esm/lib/typescriptServices.js && tsc -p ./src/tsconfig.esm.json",
"compile": "mrmdir ./release && npm run compile-amd && npm run compile-esm",
"compile-amd": "mcopy ./src/lib/typescriptServices-amd.js ./out/amd/lib/typescriptServices.js && tsc -p ./src/tsconfig.json",
"compile-esm": "mcopy ./src/lib/typescriptServices.js ./out/esm/lib/typescriptServices.js && tsc -p ./src/tsconfig.esm.json",
"compile": "mrmdir ./out && npm run compile-amd && npm run compile-esm && node ./scripts/dts && prettier --write ./monaco.d.ts",
"watch": "tsc -p ./src --watch",
"prepublishOnly": "npm run compile && node ./scripts/bundle && mcopy ./src/monaco.d.ts ./release/monaco.d.ts",
"prepublishOnly": "mrmdir ./release && npm run compile && node ./scripts/release.js && node ./scripts/bundle && mcopy ./monaco.d.ts ./release/monaco.d.ts && mcopy ./out/esm/monaco.contribution.d.ts ./release/esm/monaco.contribution.d.ts && mcopy ./out/esm/fillers/monaco-editor-core.d.ts ./release/esm/fillers/monaco-editor-core.d.ts",
"import-typescript": "node ./scripts/importTypescript",
"prettier": "prettier --write ."
},
Expand All @@ -20,6 +20,8 @@
"bugs": {
"url": "https://github.com/Microsoft/monaco-typescript/issues"
},
"module": "./release/esm/monaco.contribution.js",
"typings": "./release/esm/monaco.contribution.d.ts",
"devDependencies": {
"@typescript/vfs": "^1.3.0",
"husky": "^4.3.0",
Expand Down
Loading

0 comments on commit b01b579

Please sign in to comment.