mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 09:20:10 +01:00
Move into monaco-typescript folder
This commit is contained in:
parent
4fbf3a1cf2
commit
6bb69eca2b
38 changed files with 0 additions and 0 deletions
16
monaco-typescript/.github/workflows/ci.yml
vendored
Normal file
16
monaco-typescript/.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
name: 'CI'
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
name: 'Builds and Compiles'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '10.x'
|
||||
- run: npm install
|
||||
- run: npm run import-typescript
|
||||
- run: npm run compile
|
||||
- run: npm run prepublishOnly
|
||||
4
monaco-typescript/.gitignore
vendored
Normal file
4
monaco-typescript/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
/node_modules/
|
||||
/out/
|
||||
/release/
|
||||
.DS_Store
|
||||
12
monaco-typescript/.npmignore
Normal file
12
monaco-typescript/.npmignore
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/.github/
|
||||
/.vscode/
|
||||
/scripts/
|
||||
/src/
|
||||
/test/
|
||||
/gulpfile.js
|
||||
/tsconfig.json
|
||||
/.npmignore
|
||||
/.prettierrc
|
||||
/.prettierignore
|
||||
/out/
|
||||
/release/**/test/
|
||||
3
monaco-typescript/.prettierignore
Normal file
3
monaco-typescript/.prettierignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
/out/
|
||||
/release/
|
||||
/src/lib/
|
||||
8
monaco-typescript/.prettierrc
Normal file
8
monaco-typescript/.prettierrc
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"arrowParens": "always",
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"semi": true,
|
||||
"useTabs": true,
|
||||
"printWidth": 100
|
||||
}
|
||||
9
monaco-typescript/.vscode/settings.json
vendored
Normal file
9
monaco-typescript/.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"search.exclude": {
|
||||
"**/node_modules": true,
|
||||
"**/out": true,
|
||||
"**/release": true
|
||||
}
|
||||
}
|
||||
21
monaco-typescript/LICENSE.md
Normal file
21
monaco-typescript/LICENSE.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
39
monaco-typescript/README.md
Normal file
39
monaco-typescript/README.md
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# Monaco TypeScript
|
||||
|
||||
Simple TypeScript and JavaScript language support for the Monaco Editor.
|
||||
|
||||

|
||||
|
||||
_Note_ that this project focuses on single-file scenarios and that things like project-isolation, cross-file-features like Rename etc. are _outside_ the scope of this project and not supported.
|
||||
|
||||
## Issues
|
||||
|
||||
Please file issues concerning `monaco-typescript` in the [`monaco-editor` repository](https://github.com/Microsoft/monaco-editor/issues).
|
||||
|
||||
## Installing
|
||||
|
||||
This npm module is bundled and distributed in the [monaco-editor](https://www.npmjs.com/package/monaco-editor) npm module.
|
||||
|
||||
## Development
|
||||
|
||||
- `git clone https://github.com/Microsoft/monaco-typescript`
|
||||
- `cd monaco-typescript`
|
||||
- `npm install .`
|
||||
- `npm run compile`
|
||||
- `npm run watch`
|
||||
- open `$/monaco-typescript/test/index.html` in your favorite browser.
|
||||
|
||||
## Updating TypeScript
|
||||
|
||||
- change typescript's version in `package.json`.
|
||||
- execute `npm install .`
|
||||
- execute `npm run import-typescript`
|
||||
- adopt new APIs
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md)
|
||||
41
monaco-typescript/SECURITY.md
Normal file
41
monaco-typescript/SECURITY.md
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
|
||||
|
||||
## Security
|
||||
|
||||
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
|
||||
|
||||
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](<https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)>), please report it to us as described below.
|
||||
|
||||
## Reporting Security Issues
|
||||
|
||||
**Please do not report security vulnerabilities through public GitHub issues.**
|
||||
|
||||
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
|
||||
|
||||
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
|
||||
|
||||
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
|
||||
|
||||
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
||||
|
||||
- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
||||
- Full paths of source file(s) related to the manifestation of the issue
|
||||
- The location of the affected source code (tag/branch/commit or direct URL)
|
||||
- Any special configuration required to reproduce the issue
|
||||
- Step-by-step instructions to reproduce the issue
|
||||
- Proof-of-concept or exploit code (if possible)
|
||||
- Impact of the issue, including how an attacker might exploit the issue
|
||||
|
||||
This information will help us triage your report more quickly.
|
||||
|
||||
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
|
||||
|
||||
## Preferred Languages
|
||||
|
||||
We prefer all communications to be in English.
|
||||
|
||||
## Policy
|
||||
|
||||
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
|
||||
|
||||
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
||||
71
monaco-typescript/ThirdPartyNotices.txt
Normal file
71
monaco-typescript/ThirdPartyNotices.txt
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
|
||||
Do Not Translate or Localize
|
||||
|
||||
This project incorporates components from the projects listed below. The original copyright notices and the licenses
|
||||
under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted
|
||||
herein, whether by implication, estoppel or otherwise.
|
||||
|
||||
|
||||
|
||||
|
||||
%% typescript version 2.7.2 (https://github.com/Microsoft/TypeScript)
|
||||
=========================================
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Apache License
|
||||
|
||||
Version 2.0, January 2004
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
=========================================
|
||||
END OF typescript NOTICES AND INFORMATION
|
||||
442
monaco-typescript/monaco.d.ts
vendored
Normal file
442
monaco-typescript/monaco.d.ts
vendored
Normal file
|
|
@ -0,0 +1,442 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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,
|
||||
UMD = 3,
|
||||
System = 4,
|
||||
ES2015 = 5,
|
||||
ESNext = 99
|
||||
}
|
||||
export enum JsxEmit {
|
||||
None = 0,
|
||||
Preserve = 1,
|
||||
React = 2,
|
||||
ReactNative = 3,
|
||||
ReactJSX = 4,
|
||||
ReactJSXDev = 5
|
||||
}
|
||||
export enum NewLineKind {
|
||||
CarriageReturnLineFeed = 0,
|
||||
LineFeed = 1
|
||||
}
|
||||
export enum ScriptTarget {
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
ES2015 = 2,
|
||||
ES2016 = 3,
|
||||
ES2017 = 4,
|
||||
ES2018 = 5,
|
||||
ES2019 = 6,
|
||||
ES2020 = 7,
|
||||
ESNext = 99,
|
||||
JSON = 100,
|
||||
Latest = 99
|
||||
}
|
||||
export enum ModuleResolutionKind {
|
||||
Classic = 1,
|
||||
NodeJs = 2
|
||||
}
|
||||
interface MapLike<T> {
|
||||
[index: string]: T;
|
||||
}
|
||||
type CompilerOptionsValue =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| (string | number)[]
|
||||
| string[]
|
||||
| MapLike<string[]>
|
||||
| null
|
||||
| undefined;
|
||||
interface CompilerOptions {
|
||||
allowJs?: boolean;
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
allowUmdGlobalAccess?: boolean;
|
||||
allowUnreachableCode?: boolean;
|
||||
allowUnusedLabels?: boolean;
|
||||
alwaysStrict?: boolean;
|
||||
baseUrl?: string;
|
||||
charset?: string;
|
||||
checkJs?: boolean;
|
||||
declaration?: boolean;
|
||||
declarationMap?: boolean;
|
||||
emitDeclarationOnly?: boolean;
|
||||
declarationDir?: string;
|
||||
disableSizeLimit?: boolean;
|
||||
disableSourceOfProjectReferenceRedirect?: boolean;
|
||||
downlevelIteration?: boolean;
|
||||
emitBOM?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
importHelpers?: boolean;
|
||||
inlineSourceMap?: boolean;
|
||||
inlineSources?: boolean;
|
||||
isolatedModules?: boolean;
|
||||
jsx?: JsxEmit;
|
||||
keyofStringsOnly?: boolean;
|
||||
lib?: string[];
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
maxNodeModuleJsDepth?: number;
|
||||
module?: ModuleKind;
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
newLine?: NewLineKind;
|
||||
noEmit?: boolean;
|
||||
noEmitHelpers?: boolean;
|
||||
noEmitOnError?: boolean;
|
||||
noErrorTruncation?: boolean;
|
||||
noFallthroughCasesInSwitch?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noImplicitThis?: boolean;
|
||||
noStrictGenericChecks?: boolean;
|
||||
noUnusedLocals?: boolean;
|
||||
noUnusedParameters?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
noLib?: boolean;
|
||||
noResolve?: boolean;
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
outFile?: string;
|
||||
paths?: MapLike<string[]>;
|
||||
preserveConstEnums?: boolean;
|
||||
preserveSymlinks?: boolean;
|
||||
project?: string;
|
||||
reactNamespace?: string;
|
||||
jsxFactory?: string;
|
||||
composite?: boolean;
|
||||
removeComments?: boolean;
|
||||
rootDir?: string;
|
||||
rootDirs?: string[];
|
||||
skipLibCheck?: boolean;
|
||||
skipDefaultLibCheck?: boolean;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
strict?: boolean;
|
||||
strictFunctionTypes?: boolean;
|
||||
strictBindCallApply?: boolean;
|
||||
strictNullChecks?: boolean;
|
||||
strictPropertyInitialization?: boolean;
|
||||
stripInternal?: boolean;
|
||||
suppressExcessPropertyErrors?: boolean;
|
||||
suppressImplicitAnyIndexErrors?: boolean;
|
||||
target?: ScriptTarget;
|
||||
traceResolution?: boolean;
|
||||
resolveJsonModule?: boolean;
|
||||
types?: string[];
|
||||
/** Paths used to compute primary types search locations */
|
||||
typeRoots?: string[];
|
||||
esModuleInterop?: boolean;
|
||||
useDefineForClassFields?: boolean;
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
export interface DiagnosticsOptions {
|
||||
noSemanticValidation?: boolean;
|
||||
noSyntaxValidation?: boolean;
|
||||
noSuggestionDiagnostics?: boolean;
|
||||
/**
|
||||
* Limit diagnostic computation to only visible files.
|
||||
* Defaults to false.
|
||||
*/
|
||||
onlyVisible?: 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 InlayHintsOptions {
|
||||
readonly includeInlayParameterNameHints?: 'none' | 'literals' | 'all';
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
}
|
||||
interface IExtraLib {
|
||||
content: string;
|
||||
version: number;
|
||||
}
|
||||
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.
|
||||
*/
|
||||
interface DiagnosticMessageChain {
|
||||
messageText: string;
|
||||
/** Diagnostic category: warning = 0, error = 1, suggestion = 2, message = 3 */
|
||||
category: 0 | 1 | 2 | 3;
|
||||
code: number;
|
||||
next?: DiagnosticMessageChain[];
|
||||
}
|
||||
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?: {};
|
||||
reportsDeprecated?: {};
|
||||
source?: string;
|
||||
relatedInformation?: DiagnosticRelatedInformation[];
|
||||
}
|
||||
export interface DiagnosticRelatedInformation {
|
||||
/** Diagnostic category: warning = 0, error = 1, suggestion = 2, message = 3 */
|
||||
category: 0 | 1 | 2 | 3;
|
||||
code: number;
|
||||
/** TypeScriptWorker removes all but the `fileName` property to avoid serializing circular JSON structures. */
|
||||
file:
|
||||
| {
|
||||
fileName: string;
|
||||
}
|
||||
| undefined;
|
||||
start: number | undefined;
|
||||
length: number | undefined;
|
||||
messageText: string | DiagnosticMessageChain;
|
||||
}
|
||||
interface EmitOutput {
|
||||
outputFiles: OutputFile[];
|
||||
emitSkipped: boolean;
|
||||
}
|
||||
interface OutputFile {
|
||||
name: string;
|
||||
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;
|
||||
readonly inlayHintsOptions: InlayHintsOptions;
|
||||
/**
|
||||
* 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
|
||||
* documents, like `jquery.d.ts`.
|
||||
*
|
||||
* @param content The file content
|
||||
* @param filePath An optional file path
|
||||
* @returns A disposable which will remove the file from the
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* Configure webworker options
|
||||
*/
|
||||
setWorkerOptions(options: WorkerOptions): 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;
|
||||
/**
|
||||
* Configure inlay hints options.
|
||||
*/
|
||||
setInlayHintsOptions(options: InlayHintsOptions): void;
|
||||
}
|
||||
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>`
|
||||
*/
|
||||
getCompletionsAtPosition(fileName: string, position: number): Promise<any | undefined>;
|
||||
/**
|
||||
* Get code completion details for the given file, position, and entry.
|
||||
* @returns `Promise<typescript.CompletionEntryDetails | undefined>`
|
||||
*/
|
||||
getCompletionEntryDetails(
|
||||
fileName: string,
|
||||
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>`
|
||||
*/
|
||||
getSignatureHelpItems(
|
||||
fileName: string,
|
||||
position: number,
|
||||
options: any
|
||||
): Promise<any | undefined>;
|
||||
/**
|
||||
* Get quick info for the item at the given position in the file.
|
||||
* @returns `Promise<typescript.QuickInfo | undefined>`
|
||||
*/
|
||||
getQuickInfoAtPosition(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>`
|
||||
*/
|
||||
getOccurrencesAtPosition(
|
||||
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>`
|
||||
*/
|
||||
getDefinitionAtPosition(
|
||||
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>`
|
||||
*/
|
||||
getReferencesAtPosition(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`
|
||||
* @returns `Promise<typescript.TextChange[]>`
|
||||
*/
|
||||
getFormattingEditsForDocument(fileName: string, options: any): Promise<any[]>;
|
||||
/**
|
||||
* Get changes which should be applied to format the given range in the file.
|
||||
* @param options `typescript.FormatCodeOptions`
|
||||
* @returns `Promise<typescript.TextChange[]>`
|
||||
*/
|
||||
getFormattingEditsForRange(
|
||||
fileName: string,
|
||||
start: number,
|
||||
end: number,
|
||||
options: any
|
||||
): Promise<any[]>;
|
||||
/**
|
||||
* Get formatting changes which should be applied after the given keystroke.
|
||||
* @param options `typescript.FormatCodeOptions`
|
||||
* @returns `Promise<typescript.TextChange[]>`
|
||||
*/
|
||||
getFormattingEditsAfterKeystroke(
|
||||
fileName: string,
|
||||
postion: number,
|
||||
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>`
|
||||
*/
|
||||
findRenameLocations(
|
||||
fileName: string,
|
||||
positon: number,
|
||||
findInStrings: boolean,
|
||||
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`
|
||||
* @returns `Promise<typescript.RenameInfo>`
|
||||
*/
|
||||
getRenameInfo(fileName: string, positon: number, options: any): Promise<any>;
|
||||
/**
|
||||
* Get transpiled output for the given file.
|
||||
* @returns `typescript.EmitOutput`
|
||||
*/
|
||||
getEmitOutput(fileName: string): Promise<EmitOutput>;
|
||||
/**
|
||||
* Get possible code fixes at the given position in the file.
|
||||
* @param formatOptions `typescript.FormatCodeOptions`
|
||||
* @returns `Promise<ReadonlyArray<typescript.CodeFixAction>>`
|
||||
*/
|
||||
getCodeFixesAtPosition(
|
||||
fileName: string,
|
||||
start: number,
|
||||
end: number,
|
||||
errorCodes: number[],
|
||||
formatOptions: any
|
||||
): Promise<ReadonlyArray<any>>;
|
||||
/**
|
||||
* Get inlay hints in the range of the file.
|
||||
* @param fileName
|
||||
* @returns `Promise<typescript.InlayHint[]>`
|
||||
*/
|
||||
provideInlayHints(fileName: string, start: number, end: number): Promise<ReadonlyArray<any>>;
|
||||
}
|
||||
export const typescriptVersion: string;
|
||||
export const typescriptDefaults: LanguageServiceDefaults;
|
||||
export const javascriptDefaults: LanguageServiceDefaults;
|
||||
export const getTypeScriptWorker: () => Promise<(...uris: Uri[]) => Promise<TypeScriptWorker>>;
|
||||
export const getJavaScriptWorker: () => Promise<(...uris: Uri[]) => Promise<TypeScriptWorker>>;
|
||||
}
|
||||
485
monaco-typescript/package-lock.json
generated
Normal file
485
monaco-typescript/package-lock.json
generated
Normal file
|
|
@ -0,0 +1,485 @@
|
|||
{
|
||||
"name": "monaco-typescript",
|
||||
"version": "4.10.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@types/minimatch": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz",
|
||||
"integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript/vfs": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.3.5.tgz",
|
||||
"integrity": "sha512-pI8Saqjupf9MfLw7w2+og+fmb0fZS0J6vsKXXrp4/PDXEFvntgzXmChCXC/KefZZS0YGS6AT8e0hGAJcTsdJlg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^4.1.1"
|
||||
}
|
||||
},
|
||||
"ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-convert": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"array-differ": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz",
|
||||
"integrity": "sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==",
|
||||
"dev": true
|
||||
},
|
||||
"array-union": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
|
||||
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
|
||||
"dev": true
|
||||
},
|
||||
"arrify": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz",
|
||||
"integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==",
|
||||
"dev": true
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"buffer-from": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||
"dev": true
|
||||
},
|
||||
"chalk": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
|
||||
"integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
}
|
||||
},
|
||||
"color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-name": "~1.1.4"
|
||||
}
|
||||
},
|
||||
"color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-key": "^3.1.0",
|
||||
"shebang-command": "^2.0.0",
|
||||
"which": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
|
||||
"integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
},
|
||||
"end-of-stream": {
|
||||
"version": "1.4.4",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
|
||||
"integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"execa": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz",
|
||||
"integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cross-spawn": "^7.0.0",
|
||||
"get-stream": "^5.0.0",
|
||||
"human-signals": "^1.1.1",
|
||||
"is-stream": "^2.0.0",
|
||||
"merge-stream": "^2.0.0",
|
||||
"npm-run-path": "^4.0.0",
|
||||
"onetime": "^5.1.0",
|
||||
"signal-exit": "^3.0.2",
|
||||
"strip-final-newline": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"find-up": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
|
||||
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"locate-path": "^5.0.0",
|
||||
"path-exists": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"get-stream": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
|
||||
"integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"pump": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true
|
||||
},
|
||||
"human-signals": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz",
|
||||
"integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==",
|
||||
"dev": true
|
||||
},
|
||||
"husky": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-5.2.0.tgz",
|
||||
"integrity": "sha512-AM8T/auHXRBxlrfPVLKP6jt49GCM2Zz47m8G3FOMsLmTv8Dj/fKVWE0Rh2d4Qrvmy131xEsdQnb3OXRib67PGg==",
|
||||
"dev": true
|
||||
},
|
||||
"ignore": {
|
||||
"version": "5.1.8",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz",
|
||||
"integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==",
|
||||
"dev": true
|
||||
},
|
||||
"is-stream": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
|
||||
"integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",
|
||||
"dev": true
|
||||
},
|
||||
"isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
|
||||
"dev": true
|
||||
},
|
||||
"locate-path": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
|
||||
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-locate": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"merge-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
|
||||
"integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
|
||||
"dev": true
|
||||
},
|
||||
"mimic-fn": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
|
||||
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
|
||||
"dev": true
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"monaco-editor-core": {
|
||||
"version": "0.30.0",
|
||||
"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.30.0.tgz",
|
||||
"integrity": "sha512-vFJ7BEOCqLv4xWgFW+UheI/PtccHHNht29lNmo79Re1kNhWCBLLb2nThjRMLPO1rd41vX9hhd9C07/iKOk9/jQ==",
|
||||
"dev": true
|
||||
},
|
||||
"monaco-languages": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/monaco-languages/-/monaco-languages-2.11.0.tgz",
|
||||
"integrity": "sha512-fpeP8XUPejcdoUEMZ5bo4MW8VzEadhrsuyDtT48p2a2PSRT/CXptQm4eGnIfgxf5R95jrCZ0456c5dSEPBuktA==",
|
||||
"dev": true
|
||||
},
|
||||
"monaco-plugin-helpers": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/monaco-plugin-helpers/-/monaco-plugin-helpers-1.0.3.tgz",
|
||||
"integrity": "sha512-6AYI3ONAy8ki74qG2JqtFrLdiJHQlgeO5l4Rwr0OMyIpGXhc94y5rZuFxOtgGkxgSrZfHSwOt/MulUNZ/mOQOw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"typescript": "^2.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": {
|
||||
"version": "2.9.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz",
|
||||
"integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"mri": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
|
||||
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
|
||||
"dev": true
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
},
|
||||
"multimatch": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/multimatch/-/multimatch-4.0.0.tgz",
|
||||
"integrity": "sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/minimatch": "^3.0.3",
|
||||
"array-differ": "^3.0.0",
|
||||
"array-union": "^2.1.0",
|
||||
"arrify": "^2.0.1",
|
||||
"minimatch": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"npm-run-path": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz",
|
||||
"integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-key": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"onetime": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",
|
||||
"integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mimic-fn": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"p-limit": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
|
||||
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-try": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"p-locate": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
|
||||
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-limit": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"p-try": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
|
||||
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
|
||||
"dev": true
|
||||
},
|
||||
"path-exists": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
|
||||
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
|
||||
"dev": true
|
||||
},
|
||||
"path-key": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz",
|
||||
"integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==",
|
||||
"dev": true
|
||||
},
|
||||
"pretty-quick": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pretty-quick/-/pretty-quick-3.1.1.tgz",
|
||||
"integrity": "sha512-ZYLGiMoV2jcaas3vTJrLvKAYsxDoXQBUn8OSTxkl67Fyov9lyXivJTl0+2WVh+y6EovGcw7Lm5ThYpH+Sh3XxQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^3.0.0",
|
||||
"execa": "^4.0.0",
|
||||
"find-up": "^4.1.0",
|
||||
"ignore": "^5.1.4",
|
||||
"mri": "^1.1.5",
|
||||
"multimatch": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"pump": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
|
||||
"integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"end-of-stream": "^1.1.0",
|
||||
"once": "^1.3.1"
|
||||
}
|
||||
},
|
||||
"requirejs": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz",
|
||||
"integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==",
|
||||
"dev": true
|
||||
},
|
||||
"shebang-command": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"shebang-regex": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"shebang-regex": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
|
||||
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
|
||||
"dev": true
|
||||
},
|
||||
"signal-exit": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz",
|
||||
"integrity": "sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ==",
|
||||
"dev": true
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.7.3",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
|
||||
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
|
||||
"dev": true
|
||||
},
|
||||
"source-map-support": {
|
||||
"version": "0.5.20",
|
||||
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.20.tgz",
|
||||
"integrity": "sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"buffer-from": "^1.0.0",
|
||||
"source-map": "^0.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"strip-final-newline": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz",
|
||||
"integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==",
|
||||
"dev": true
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"terser": {
|
||||
"version": "5.9.0",
|
||||
"resolved": "https://registry.npmjs.org/terser/-/terser-5.9.0.tgz",
|
||||
"integrity": "sha512-h5hxa23sCdpzcye/7b8YqbE5OwKca/ni0RQz1uRX3tGh8haaGHqcuSqbGRybuAKNdntZ0mDgFNXPJ48xQ2RXKQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commander": "^2.20.0",
|
||||
"source-map": "~0.7.2",
|
||||
"source-map-support": "~0.5.20"
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.4.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz",
|
||||
"integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==",
|
||||
"dev": true
|
||||
},
|
||||
"which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"isexe": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
42
monaco-typescript/package.json
Normal file
42
monaco-typescript/package.json
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"name": "monaco-typescript",
|
||||
"version": "4.10.0",
|
||||
"description": "TypeScript and JavaScript language support for Monaco Editor",
|
||||
"scripts": {
|
||||
"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": "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 ."
|
||||
},
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Microsoft/monaco-typescript"
|
||||
},
|
||||
"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.5",
|
||||
"husky": "^5.1.3",
|
||||
"monaco-editor-core": "0.30.0",
|
||||
"monaco-languages": "^2.11.0",
|
||||
"monaco-plugin-helpers": "^1.0.3",
|
||||
"prettier": "^2.4.1",
|
||||
"pretty-quick": "^3.1.1",
|
||||
"requirejs": "^2.3.6",
|
||||
"terser": "^5.9.0",
|
||||
"typescript": "^4.4.4"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged"
|
||||
}
|
||||
}
|
||||
}
|
||||
64
monaco-typescript/scripts/bundle.js
Normal file
64
monaco-typescript/scripts/bundle.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const requirejs = require('requirejs');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const terser = require('terser');
|
||||
const helpers = require('monaco-plugin-helpers');
|
||||
|
||||
const REPO_ROOT = path.resolve(__dirname, '..');
|
||||
|
||||
const sha1 = helpers.getGitVersion(REPO_ROOT);
|
||||
const semver = require('../package.json').version;
|
||||
const headerVersion = semver + '(' + sha1 + ')';
|
||||
|
||||
const BUNDLED_FILE_HEADER = [
|
||||
'/*!-----------------------------------------------------------------------------',
|
||||
' * Copyright (c) Microsoft Corporation. All rights reserved.',
|
||||
' * monaco-typescript version: ' + headerVersion,
|
||||
' * Released under the MIT license',
|
||||
' * https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md',
|
||||
' *-----------------------------------------------------------------------------*/',
|
||||
''
|
||||
].join('\n');
|
||||
|
||||
bundleOne('monaco.contribution');
|
||||
bundleOne('tsMode', ['vs/language/typescript/monaco.contribution']);
|
||||
bundleOne('tsWorker');
|
||||
|
||||
function bundleOne(moduleId, exclude) {
|
||||
requirejs.optimize(
|
||||
{
|
||||
baseUrl: 'out/amd/',
|
||||
name: 'vs/language/typescript/' + moduleId,
|
||||
out: 'release/dev/' + moduleId + '.js',
|
||||
exclude: exclude,
|
||||
paths: {
|
||||
'vs/language/typescript': REPO_ROOT + '/out/amd',
|
||||
'vs/language/typescript/fillers/monaco-editor-core':
|
||||
REPO_ROOT + '/out/amd/fillers/monaco-editor-core-amd'
|
||||
},
|
||||
optimize: 'none'
|
||||
},
|
||||
async function (buildResponse) {
|
||||
const devFilePath = path.join(REPO_ROOT, 'release/dev/' + moduleId + '.js');
|
||||
const minFilePath = path.join(REPO_ROOT, 'release/min/' + moduleId + '.js');
|
||||
const fileContents = fs.readFileSync(devFilePath).toString();
|
||||
console.log();
|
||||
console.log(`Minifying ${devFilePath}...`);
|
||||
const result = await terser.minify(fileContents, {
|
||||
output: {
|
||||
comments: 'some'
|
||||
}
|
||||
});
|
||||
console.log(`Done minifying ${devFilePath}.`);
|
||||
try {
|
||||
fs.mkdirSync(path.join(REPO_ROOT, 'release/min'));
|
||||
} catch (err) {}
|
||||
fs.writeFileSync(minFilePath, BUNDLED_FILE_HEADER + result.code);
|
||||
}
|
||||
);
|
||||
}
|
||||
44
monaco-typescript/scripts/dts.js
Normal file
44
monaco-typescript/scripts/dts.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const REPO_ROOT = path.join(__dirname, '../');
|
||||
const SRC_PATH = path.join(REPO_ROOT, 'out/amd/monaco.contribution.d.ts');
|
||||
const DST_PATH = path.join(REPO_ROOT, 'monaco.d.ts');
|
||||
|
||||
const lines = fs
|
||||
.readFileSync(SRC_PATH)
|
||||
.toString()
|
||||
.split(/\r\n|\r|\n/);
|
||||
let result = [
|
||||
`/*---------------------------------------------------------------------------------------------`,
|
||||
` * 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 {`
|
||||
];
|
||||
for (let line of lines) {
|
||||
if (/^import/.test(line)) {
|
||||
continue;
|
||||
}
|
||||
if (line === 'export {};') {
|
||||
continue;
|
||||
}
|
||||
line = line.replace(/ /g, '\t');
|
||||
line = line.replace(/declare /g, '');
|
||||
if (line.length > 0) {
|
||||
line = `\t${line}`;
|
||||
result.push(line);
|
||||
}
|
||||
}
|
||||
result.push(`}`);
|
||||
result.push(``);
|
||||
|
||||
fs.writeFileSync(DST_PATH, result.join('\n'));
|
||||
247
monaco-typescript/scripts/importTypescript.js
Normal file
247
monaco-typescript/scripts/importTypescript.js
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const child_process = require('child_process');
|
||||
|
||||
const generatedNote = `//
|
||||
// **NOTE**: Do not edit directly! This file is generated using \`npm run import-typescript\`
|
||||
//
|
||||
`;
|
||||
|
||||
const TYPESCRIPT_LIB_SOURCE = path.join(__dirname, '../node_modules/typescript/lib');
|
||||
const TYPESCRIPT_LIB_DESTINATION = path.join(__dirname, '../src/lib');
|
||||
|
||||
(function () {
|
||||
try {
|
||||
fs.statSync(TYPESCRIPT_LIB_DESTINATION);
|
||||
} catch (err) {
|
||||
fs.mkdirSync(TYPESCRIPT_LIB_DESTINATION);
|
||||
}
|
||||
importLibs();
|
||||
|
||||
const npmLsOutput = JSON.parse(
|
||||
child_process.execSync('npm ls typescript --depth=0 --json=true').toString()
|
||||
);
|
||||
const typeScriptDependencyVersion = npmLsOutput.dependencies.typescript.version;
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServicesMetadata.ts'),
|
||||
`${generatedNote}
|
||||
export const typescriptVersion = "${typeScriptDependencyVersion}";\n`
|
||||
);
|
||||
|
||||
let tsServices = fs
|
||||
.readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.js'))
|
||||
.toString();
|
||||
|
||||
// Ensure we never run into the node system...
|
||||
// (this also removes require calls that trick webpack into shimming those modules...)
|
||||
tsServices = tsServices.replace(
|
||||
/\n ts\.sys =([^]*)\n \}\)\(\);/m,
|
||||
`\n // MONACOCHANGE\n ts.sys = undefined;\n // END MONACOCHANGE`
|
||||
);
|
||||
|
||||
// Eliminate more require() calls...
|
||||
tsServices = tsServices.replace(
|
||||
/^( +)etwModule = require\(.*$/m,
|
||||
'$1// MONACOCHANGE\n$1etwModule = undefined;\n$1// END MONACOCHANGE'
|
||||
);
|
||||
tsServices = tsServices.replace(
|
||||
/^( +)var result = ts\.sys\.require\(.*$/m,
|
||||
'$1// MONACOCHANGE\n$1var result = undefined;\n$1// END MONACOCHANGE'
|
||||
);
|
||||
tsServices = tsServices.replace(
|
||||
/^( +)fs = require\("fs"\);$/m,
|
||||
'$1// MONACOCHANGE\n$1fs = undefined;\n$1// END MONACOCHANGE'
|
||||
);
|
||||
tsServices = tsServices.replace(
|
||||
/^( +)debugger;$/m,
|
||||
'$1// MONACOCHANGE\n$1// debugger;\n$1// END MONACOCHANGE'
|
||||
);
|
||||
tsServices = tsServices.replace(
|
||||
/= require\("perf_hooks"\)/m,
|
||||
'/* MONACOCHANGE */= {}/* END MONACOCHANGE */'
|
||||
);
|
||||
|
||||
// Flag any new require calls (outside comments) so they can be corrected preemptively.
|
||||
// To avoid missing cases (or using an even more complex regex), temporarily remove comments
|
||||
// about require() and then check for lines actually calling require().
|
||||
// \/[*/] matches the start of a comment (single or multi-line).
|
||||
// ^\s+\*[^/] matches (presumably) a later line of a multi-line comment.
|
||||
const tsServicesNoCommentedRequire = tsServices.replace(
|
||||
/(\/[*/]|^\s+\*[^/]).*\brequire\(.*/gm,
|
||||
''
|
||||
);
|
||||
const linesWithRequire = tsServicesNoCommentedRequire.match(/^.*?\brequire\(.*$/gm);
|
||||
|
||||
// Allow error messages to include references to require() in their strings
|
||||
const runtimeRequires =
|
||||
linesWithRequire &&
|
||||
linesWithRequire.filter((l) => !l.includes(': diag(') && !l.includes('ts.DiagnosticCategory'));
|
||||
|
||||
if (runtimeRequires && runtimeRequires.length && linesWithRequire) {
|
||||
console.error(
|
||||
'Found new require() calls on the following lines. These should be removed to avoid breaking webpack builds.\n'
|
||||
);
|
||||
console.error(
|
||||
runtimeRequires.map((r) => `${r} (${tsServicesNoCommentedRequire.indexOf(r)})`).join('\n')
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const tsServices_amd =
|
||||
generatedNote +
|
||||
tsServices +
|
||||
`
|
||||
// MONACOCHANGE
|
||||
// Defining the entire module name because r.js has an issue and cannot bundle this file
|
||||
// correctly with an anonymous define call
|
||||
define("vs/language/typescript/lib/typescriptServices", [], function() { return ts; });
|
||||
// END MONACOCHANGE
|
||||
`;
|
||||
fs.writeFileSync(
|
||||
path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices-amd.js'),
|
||||
stripSourceMaps(tsServices_amd)
|
||||
);
|
||||
|
||||
const tsServices_esm =
|
||||
generatedNote +
|
||||
tsServices +
|
||||
`
|
||||
// MONACOCHANGE
|
||||
export var createClassifier = ts.createClassifier;
|
||||
export var createLanguageService = ts.createLanguageService;
|
||||
export var displayPartsToString = ts.displayPartsToString;
|
||||
export var EndOfLineState = ts.EndOfLineState;
|
||||
export var flattenDiagnosticMessageText = ts.flattenDiagnosticMessageText;
|
||||
export var IndentStyle = ts.IndentStyle;
|
||||
export var ScriptKind = ts.ScriptKind;
|
||||
export var ScriptTarget = ts.ScriptTarget;
|
||||
export var TokenClass = ts.TokenClass;
|
||||
// END MONACOCHANGE
|
||||
`;
|
||||
fs.writeFileSync(
|
||||
path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.js'),
|
||||
stripSourceMaps(tsServices_esm)
|
||||
);
|
||||
|
||||
let dtsServices = fs
|
||||
.readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.d.ts'))
|
||||
.toString();
|
||||
dtsServices += `
|
||||
// MONACOCHANGE
|
||||
export = ts;
|
||||
// END MONACOCHANGE
|
||||
`;
|
||||
fs.writeFileSync(
|
||||
path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.d.ts'),
|
||||
generatedNote + dtsServices
|
||||
);
|
||||
})();
|
||||
|
||||
function importLibs() {
|
||||
function readLibFile(name) {
|
||||
const srcPath = path.join(TYPESCRIPT_LIB_SOURCE, name);
|
||||
return fs.readFileSync(srcPath).toString();
|
||||
}
|
||||
|
||||
let strLibResult = `/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
${generatedNote}
|
||||
|
||||
/** Contains all the lib files */
|
||||
export const libFileMap: Record<string, string> = {}
|
||||
`;
|
||||
let strIndexResult = `/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
${generatedNote}
|
||||
|
||||
/** Contains all the lib files */
|
||||
export const libFileSet: Record<string, boolean> = {}
|
||||
`;
|
||||
const dtsFiles = fs.readdirSync(TYPESCRIPT_LIB_SOURCE).filter((f) => f.includes('lib.'));
|
||||
while (dtsFiles.length > 0) {
|
||||
const name = dtsFiles.shift();
|
||||
const output = readLibFile(name).replace(/\r\n/g, '\n');
|
||||
strLibResult += `libFileMap['${name}'] = "${escapeText(output)}";\n`;
|
||||
strIndexResult += `libFileSet['${name}'] = true;\n`;
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'lib.ts'), strLibResult);
|
||||
fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'lib.index.ts'), strIndexResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape text such that it can be used in a javascript string enclosed by double quotes (")
|
||||
*/
|
||||
function escapeText(text) {
|
||||
// See http://www.javascriptkit.com/jsref/escapesequence.shtml
|
||||
const _backspace = '\b'.charCodeAt(0);
|
||||
const _formFeed = '\f'.charCodeAt(0);
|
||||
const _newLine = '\n'.charCodeAt(0);
|
||||
const _nullChar = 0;
|
||||
const _carriageReturn = '\r'.charCodeAt(0);
|
||||
const _tab = '\t'.charCodeAt(0);
|
||||
const _verticalTab = '\v'.charCodeAt(0);
|
||||
const _backslash = '\\'.charCodeAt(0);
|
||||
const _doubleQuote = '"'.charCodeAt(0);
|
||||
|
||||
const len = text.length;
|
||||
let startPos = 0;
|
||||
let chrCode;
|
||||
let replaceWith = null;
|
||||
let resultPieces = [];
|
||||
|
||||
for (let i = 0; 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('');
|
||||
}
|
||||
|
||||
function stripSourceMaps(str) {
|
||||
return str.replace(/\/\/# sourceMappingURL[^\n]+/gm, '');
|
||||
}
|
||||
17
monaco-typescript/scripts/release.js
Normal file
17
monaco-typescript/scripts/release.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const path = require('path');
|
||||
const helpers = require('monaco-plugin-helpers');
|
||||
|
||||
const REPO_ROOT = path.join(__dirname, '../');
|
||||
|
||||
helpers.packageESM({
|
||||
repoRoot: REPO_ROOT,
|
||||
esmSource: 'out/esm',
|
||||
esmDestination: 'release/esm',
|
||||
entryPoints: ['monaco.contribution.js', 'tsMode.js', 'ts.worker.js'],
|
||||
resolveSkip: ['monaco-editor-core']
|
||||
});
|
||||
12
monaco-typescript/src/fillers/monaco-editor-core-amd.ts
Normal file
12
monaco-typescript/src/fillers/monaco-editor-core-amd.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// Resolves with the global monaco API
|
||||
|
||||
declare const define: any;
|
||||
|
||||
define([], function () {
|
||||
return (<any>self).monaco;
|
||||
});
|
||||
6
monaco-typescript/src/fillers/monaco-editor-core.ts
Normal file
6
monaco-typescript/src/fillers/monaco-editor-core.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export * from 'monaco-editor-core';
|
||||
1265
monaco-typescript/src/languageFeatures.ts
Normal file
1265
monaco-typescript/src/languageFeatures.ts
Normal file
File diff suppressed because it is too large
Load diff
8
monaco-typescript/src/lib/editor.worker.d.ts
vendored
Normal file
8
monaco-typescript/src/lib/editor.worker.d.ts
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
declare module 'monaco-editor-core/esm/vs/editor/editor.worker' {
|
||||
export function initialize(callback: (ctx: any, createData: any) => any): void;
|
||||
}
|
||||
72
monaco-typescript/src/lib/lib.index.ts
Normal file
72
monaco-typescript/src/lib/lib.index.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
//
|
||||
// **NOTE**: Do not edit directly! This file is generated using `npm run import-typescript`
|
||||
//
|
||||
|
||||
|
||||
/** Contains all the lib files */
|
||||
export const libFileSet: Record<string, boolean> = {}
|
||||
libFileSet['lib.d.ts'] = true;
|
||||
libFileSet['lib.dom.d.ts'] = true;
|
||||
libFileSet['lib.dom.iterable.d.ts'] = true;
|
||||
libFileSet['lib.es2015.collection.d.ts'] = true;
|
||||
libFileSet['lib.es2015.core.d.ts'] = true;
|
||||
libFileSet['lib.es2015.d.ts'] = true;
|
||||
libFileSet['lib.es2015.generator.d.ts'] = true;
|
||||
libFileSet['lib.es2015.iterable.d.ts'] = true;
|
||||
libFileSet['lib.es2015.promise.d.ts'] = true;
|
||||
libFileSet['lib.es2015.proxy.d.ts'] = true;
|
||||
libFileSet['lib.es2015.reflect.d.ts'] = true;
|
||||
libFileSet['lib.es2015.symbol.d.ts'] = true;
|
||||
libFileSet['lib.es2015.symbol.wellknown.d.ts'] = true;
|
||||
libFileSet['lib.es2016.array.include.d.ts'] = true;
|
||||
libFileSet['lib.es2016.d.ts'] = true;
|
||||
libFileSet['lib.es2016.full.d.ts'] = true;
|
||||
libFileSet['lib.es2017.d.ts'] = true;
|
||||
libFileSet['lib.es2017.full.d.ts'] = true;
|
||||
libFileSet['lib.es2017.intl.d.ts'] = true;
|
||||
libFileSet['lib.es2017.object.d.ts'] = true;
|
||||
libFileSet['lib.es2017.sharedmemory.d.ts'] = true;
|
||||
libFileSet['lib.es2017.string.d.ts'] = true;
|
||||
libFileSet['lib.es2017.typedarrays.d.ts'] = true;
|
||||
libFileSet['lib.es2018.asyncgenerator.d.ts'] = true;
|
||||
libFileSet['lib.es2018.asynciterable.d.ts'] = true;
|
||||
libFileSet['lib.es2018.d.ts'] = true;
|
||||
libFileSet['lib.es2018.full.d.ts'] = true;
|
||||
libFileSet['lib.es2018.intl.d.ts'] = true;
|
||||
libFileSet['lib.es2018.promise.d.ts'] = true;
|
||||
libFileSet['lib.es2018.regexp.d.ts'] = true;
|
||||
libFileSet['lib.es2019.array.d.ts'] = true;
|
||||
libFileSet['lib.es2019.d.ts'] = true;
|
||||
libFileSet['lib.es2019.full.d.ts'] = true;
|
||||
libFileSet['lib.es2019.object.d.ts'] = true;
|
||||
libFileSet['lib.es2019.string.d.ts'] = true;
|
||||
libFileSet['lib.es2019.symbol.d.ts'] = true;
|
||||
libFileSet['lib.es2020.bigint.d.ts'] = true;
|
||||
libFileSet['lib.es2020.d.ts'] = true;
|
||||
libFileSet['lib.es2020.full.d.ts'] = true;
|
||||
libFileSet['lib.es2020.intl.d.ts'] = true;
|
||||
libFileSet['lib.es2020.promise.d.ts'] = true;
|
||||
libFileSet['lib.es2020.sharedmemory.d.ts'] = true;
|
||||
libFileSet['lib.es2020.string.d.ts'] = true;
|
||||
libFileSet['lib.es2020.symbol.wellknown.d.ts'] = true;
|
||||
libFileSet['lib.es2021.d.ts'] = true;
|
||||
libFileSet['lib.es2021.full.d.ts'] = true;
|
||||
libFileSet['lib.es2021.promise.d.ts'] = true;
|
||||
libFileSet['lib.es2021.string.d.ts'] = true;
|
||||
libFileSet['lib.es2021.weakref.d.ts'] = true;
|
||||
libFileSet['lib.es5.d.ts'] = true;
|
||||
libFileSet['lib.es6.d.ts'] = true;
|
||||
libFileSet['lib.esnext.d.ts'] = true;
|
||||
libFileSet['lib.esnext.full.d.ts'] = true;
|
||||
libFileSet['lib.esnext.intl.d.ts'] = true;
|
||||
libFileSet['lib.esnext.promise.d.ts'] = true;
|
||||
libFileSet['lib.esnext.string.d.ts'] = true;
|
||||
libFileSet['lib.esnext.weakref.d.ts'] = true;
|
||||
libFileSet['lib.scripthost.d.ts'] = true;
|
||||
libFileSet['lib.webworker.d.ts'] = true;
|
||||
libFileSet['lib.webworker.importscripts.d.ts'] = true;
|
||||
libFileSet['lib.webworker.iterable.d.ts'] = true;
|
||||
72
monaco-typescript/src/lib/lib.ts
Normal file
72
monaco-typescript/src/lib/lib.ts
Normal file
File diff suppressed because one or more lines are too long
160237
monaco-typescript/src/lib/typescriptServices-amd.js
Normal file
160237
monaco-typescript/src/lib/typescriptServices-amd.js
Normal file
File diff suppressed because one or more lines are too long
7483
monaco-typescript/src/lib/typescriptServices.d.ts
vendored
Normal file
7483
monaco-typescript/src/lib/typescriptServices.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
160243
monaco-typescript/src/lib/typescriptServices.js
Normal file
160243
monaco-typescript/src/lib/typescriptServices.js
Normal file
File diff suppressed because one or more lines are too long
5
monaco-typescript/src/lib/typescriptServicesMetadata.ts
Normal file
5
monaco-typescript/src/lib/typescriptServicesMetadata.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
//
|
||||
// **NOTE**: Do not edit directly! This file is generated using `npm run import-typescript`
|
||||
//
|
||||
|
||||
export const typescriptVersion = "4.4.4";
|
||||
705
monaco-typescript/src/monaco.contribution.ts
Normal file
705
monaco-typescript/src/monaco.contribution.ts
Normal file
|
|
@ -0,0 +1,705 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import type * as mode from './tsMode';
|
||||
import { typescriptVersion as tsversion } from './lib/typescriptServicesMetadata'; // do not import the whole typescriptServices here
|
||||
import { languages, Emitter, IEvent, IDisposable, Uri } from './fillers/monaco-editor-core';
|
||||
|
||||
//#region enums copied from typescript to prevent loading the entire typescriptServices ---
|
||||
|
||||
export enum ModuleKind {
|
||||
None = 0,
|
||||
CommonJS = 1,
|
||||
AMD = 2,
|
||||
UMD = 3,
|
||||
System = 4,
|
||||
ES2015 = 5,
|
||||
ESNext = 99
|
||||
}
|
||||
|
||||
export enum JsxEmit {
|
||||
None = 0,
|
||||
Preserve = 1,
|
||||
React = 2,
|
||||
ReactNative = 3,
|
||||
ReactJSX = 4,
|
||||
ReactJSXDev = 5
|
||||
}
|
||||
|
||||
export enum NewLineKind {
|
||||
CarriageReturnLineFeed = 0,
|
||||
LineFeed = 1
|
||||
}
|
||||
|
||||
export enum ScriptTarget {
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
ES2015 = 2,
|
||||
ES2016 = 3,
|
||||
ES2017 = 4,
|
||||
ES2018 = 5,
|
||||
ES2019 = 6,
|
||||
ES2020 = 7,
|
||||
ESNext = 99,
|
||||
JSON = 100,
|
||||
Latest = ESNext
|
||||
}
|
||||
|
||||
export enum ModuleResolutionKind {
|
||||
Classic = 1,
|
||||
NodeJs = 2
|
||||
}
|
||||
//#endregion
|
||||
|
||||
interface MapLike<T> {
|
||||
[index: string]: T;
|
||||
}
|
||||
|
||||
type CompilerOptionsValue =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| (string | number)[]
|
||||
| string[]
|
||||
| MapLike<string[]>
|
||||
| null
|
||||
| undefined;
|
||||
|
||||
interface CompilerOptions {
|
||||
allowJs?: boolean;
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
allowUmdGlobalAccess?: boolean;
|
||||
allowUnreachableCode?: boolean;
|
||||
allowUnusedLabels?: boolean;
|
||||
alwaysStrict?: boolean;
|
||||
baseUrl?: string;
|
||||
charset?: string;
|
||||
checkJs?: boolean;
|
||||
declaration?: boolean;
|
||||
declarationMap?: boolean;
|
||||
emitDeclarationOnly?: boolean;
|
||||
declarationDir?: string;
|
||||
disableSizeLimit?: boolean;
|
||||
disableSourceOfProjectReferenceRedirect?: boolean;
|
||||
downlevelIteration?: boolean;
|
||||
emitBOM?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
importHelpers?: boolean;
|
||||
inlineSourceMap?: boolean;
|
||||
inlineSources?: boolean;
|
||||
isolatedModules?: boolean;
|
||||
jsx?: JsxEmit;
|
||||
keyofStringsOnly?: boolean;
|
||||
lib?: string[];
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
maxNodeModuleJsDepth?: number;
|
||||
module?: ModuleKind;
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
newLine?: NewLineKind;
|
||||
noEmit?: boolean;
|
||||
noEmitHelpers?: boolean;
|
||||
noEmitOnError?: boolean;
|
||||
noErrorTruncation?: boolean;
|
||||
noFallthroughCasesInSwitch?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
noImplicitReturns?: boolean;
|
||||
noImplicitThis?: boolean;
|
||||
noStrictGenericChecks?: boolean;
|
||||
noUnusedLocals?: boolean;
|
||||
noUnusedParameters?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
noLib?: boolean;
|
||||
noResolve?: boolean;
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
outFile?: string;
|
||||
paths?: MapLike<string[]>;
|
||||
preserveConstEnums?: boolean;
|
||||
preserveSymlinks?: boolean;
|
||||
project?: string;
|
||||
reactNamespace?: string;
|
||||
jsxFactory?: string;
|
||||
composite?: boolean;
|
||||
removeComments?: boolean;
|
||||
rootDir?: string;
|
||||
rootDirs?: string[];
|
||||
skipLibCheck?: boolean;
|
||||
skipDefaultLibCheck?: boolean;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
strict?: boolean;
|
||||
strictFunctionTypes?: boolean;
|
||||
strictBindCallApply?: boolean;
|
||||
strictNullChecks?: boolean;
|
||||
strictPropertyInitialization?: boolean;
|
||||
stripInternal?: boolean;
|
||||
suppressExcessPropertyErrors?: boolean;
|
||||
suppressImplicitAnyIndexErrors?: boolean;
|
||||
target?: ScriptTarget;
|
||||
traceResolution?: boolean;
|
||||
resolveJsonModule?: boolean;
|
||||
types?: string[];
|
||||
/** Paths used to compute primary types search locations */
|
||||
typeRoots?: string[];
|
||||
esModuleInterop?: boolean;
|
||||
useDefineForClassFields?: boolean;
|
||||
[option: string]: CompilerOptionsValue | undefined;
|
||||
}
|
||||
|
||||
export interface DiagnosticsOptions {
|
||||
noSemanticValidation?: boolean;
|
||||
noSyntaxValidation?: boolean;
|
||||
noSuggestionDiagnostics?: boolean;
|
||||
/**
|
||||
* Limit diagnostic computation to only visible files.
|
||||
* Defaults to false.
|
||||
*/
|
||||
onlyVisible?: 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 InlayHintsOptions {
|
||||
readonly includeInlayParameterNameHints?: 'none' | 'literals' | 'all';
|
||||
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
|
||||
readonly includeInlayFunctionParameterTypeHints?: boolean;
|
||||
readonly includeInlayVariableTypeHints?: boolean;
|
||||
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
|
||||
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
|
||||
readonly includeInlayEnumMemberValueHints?: boolean;
|
||||
}
|
||||
|
||||
interface IExtraLib {
|
||||
content: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
interface DiagnosticMessageChain {
|
||||
messageText: string;
|
||||
/** Diagnostic category: warning = 0, error = 1, suggestion = 2, message = 3 */
|
||||
category: 0 | 1 | 2 | 3;
|
||||
code: number;
|
||||
next?: DiagnosticMessageChain[];
|
||||
}
|
||||
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?: {};
|
||||
reportsDeprecated?: {};
|
||||
source?: string;
|
||||
relatedInformation?: DiagnosticRelatedInformation[];
|
||||
}
|
||||
export interface DiagnosticRelatedInformation {
|
||||
/** Diagnostic category: warning = 0, error = 1, suggestion = 2, message = 3 */
|
||||
category: 0 | 1 | 2 | 3;
|
||||
code: number;
|
||||
/** TypeScriptWorker removes all but the `fileName` property to avoid serializing circular JSON structures. */
|
||||
file: { fileName: string } | undefined;
|
||||
start: number | undefined;
|
||||
length: number | undefined;
|
||||
messageText: string | DiagnosticMessageChain;
|
||||
}
|
||||
|
||||
interface EmitOutput {
|
||||
outputFiles: OutputFile[];
|
||||
emitSkipped: boolean;
|
||||
}
|
||||
interface OutputFile {
|
||||
name: string;
|
||||
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;
|
||||
|
||||
readonly inlayHintsOptions: InlayHintsOptions;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* documents, like `jquery.d.ts`.
|
||||
*
|
||||
* @param content The file content
|
||||
* @param filePath An optional file path
|
||||
* @returns A disposable which will remove the file from the
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Configure webworker options
|
||||
*/
|
||||
setWorkerOptions(options: WorkerOptions): 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;
|
||||
|
||||
/**
|
||||
* Configure inlay hints options.
|
||||
*/
|
||||
setInlayHintsOptions(options: InlayHintsOptions): void;
|
||||
}
|
||||
|
||||
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>`
|
||||
*/
|
||||
getCompletionsAtPosition(fileName: string, position: number): Promise<any | undefined>;
|
||||
|
||||
/**
|
||||
* Get code completion details for the given file, position, and entry.
|
||||
* @returns `Promise<typescript.CompletionEntryDetails | undefined>`
|
||||
*/
|
||||
getCompletionEntryDetails(
|
||||
fileName: string,
|
||||
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>`
|
||||
*/
|
||||
getSignatureHelpItems(fileName: string, position: number, options: any): Promise<any | undefined>;
|
||||
|
||||
/**
|
||||
* Get quick info for the item at the given position in the file.
|
||||
* @returns `Promise<typescript.QuickInfo | undefined>`
|
||||
*/
|
||||
getQuickInfoAtPosition(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>`
|
||||
*/
|
||||
getOccurrencesAtPosition(
|
||||
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>`
|
||||
*/
|
||||
getDefinitionAtPosition(
|
||||
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>`
|
||||
*/
|
||||
getReferencesAtPosition(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`
|
||||
* @returns `Promise<typescript.TextChange[]>`
|
||||
*/
|
||||
getFormattingEditsForDocument(fileName: string, options: any): Promise<any[]>;
|
||||
|
||||
/**
|
||||
* Get changes which should be applied to format the given range in the file.
|
||||
* @param options `typescript.FormatCodeOptions`
|
||||
* @returns `Promise<typescript.TextChange[]>`
|
||||
*/
|
||||
getFormattingEditsForRange(
|
||||
fileName: string,
|
||||
start: number,
|
||||
end: number,
|
||||
options: any
|
||||
): Promise<any[]>;
|
||||
|
||||
/**
|
||||
* Get formatting changes which should be applied after the given keystroke.
|
||||
* @param options `typescript.FormatCodeOptions`
|
||||
* @returns `Promise<typescript.TextChange[]>`
|
||||
*/
|
||||
getFormattingEditsAfterKeystroke(
|
||||
fileName: string,
|
||||
postion: number,
|
||||
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>`
|
||||
*/
|
||||
findRenameLocations(
|
||||
fileName: string,
|
||||
positon: number,
|
||||
findInStrings: boolean,
|
||||
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`
|
||||
* @returns `Promise<typescript.RenameInfo>`
|
||||
*/
|
||||
getRenameInfo(fileName: string, positon: number, options: any): Promise<any>;
|
||||
|
||||
/**
|
||||
* Get transpiled output for the given file.
|
||||
* @returns `typescript.EmitOutput`
|
||||
*/
|
||||
getEmitOutput(fileName: string): Promise<EmitOutput>;
|
||||
|
||||
/**
|
||||
* Get possible code fixes at the given position in the file.
|
||||
* @param formatOptions `typescript.FormatCodeOptions`
|
||||
* @returns `Promise<ReadonlyArray<typescript.CodeFixAction>>`
|
||||
*/
|
||||
getCodeFixesAtPosition(
|
||||
fileName: string,
|
||||
start: number,
|
||||
end: number,
|
||||
errorCodes: number[],
|
||||
formatOptions: any
|
||||
): Promise<ReadonlyArray<any>>;
|
||||
|
||||
/**
|
||||
* Get inlay hints in the range of the file.
|
||||
* @param fileName
|
||||
* @returns `Promise<typescript.InlayHint[]>`
|
||||
*/
|
||||
provideInlayHints(fileName: string, start: number, end: number): Promise<ReadonlyArray<any>>;
|
||||
}
|
||||
|
||||
// --- TypeScript configuration and defaults ---------
|
||||
|
||||
class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
||||
private _onDidChange = new Emitter<void>();
|
||||
private _onDidExtraLibsChange = new Emitter<void>();
|
||||
|
||||
private _extraLibs: IExtraLibs;
|
||||
private _removedExtraLibs: { [path: string]: number };
|
||||
private _eagerModelSync: boolean;
|
||||
private _compilerOptions!: CompilerOptions;
|
||||
private _diagnosticsOptions!: DiagnosticsOptions;
|
||||
private _workerOptions!: WorkerOptions;
|
||||
private _onDidExtraLibsChangeTimeout: number;
|
||||
private _inlayHintsOptions!: InlayHintsOptions;
|
||||
|
||||
constructor(
|
||||
compilerOptions: CompilerOptions,
|
||||
diagnosticsOptions: DiagnosticsOptions,
|
||||
workerOptions: WorkerOptions,
|
||||
inlayHintsOptions: InlayHintsOptions
|
||||
) {
|
||||
this._extraLibs = Object.create(null);
|
||||
this._removedExtraLibs = Object.create(null);
|
||||
this._eagerModelSync = false;
|
||||
this.setCompilerOptions(compilerOptions);
|
||||
this.setDiagnosticsOptions(diagnosticsOptions);
|
||||
this.setWorkerOptions(workerOptions);
|
||||
this.setInlayHintsOptions(inlayHintsOptions);
|
||||
this._onDidExtraLibsChangeTimeout = -1;
|
||||
}
|
||||
|
||||
get onDidChange(): IEvent<void> {
|
||||
return this._onDidChange.event;
|
||||
}
|
||||
|
||||
get onDidExtraLibsChange(): IEvent<void> {
|
||||
return this._onDidExtraLibsChange.event;
|
||||
}
|
||||
|
||||
get workerOptions(): WorkerOptions {
|
||||
return this._workerOptions;
|
||||
}
|
||||
|
||||
get inlayHintsOptions(): InlayHintsOptions {
|
||||
return this._inlayHintsOptions;
|
||||
}
|
||||
|
||||
getExtraLibs(): IExtraLibs {
|
||||
return this._extraLibs;
|
||||
}
|
||||
|
||||
addExtraLib(content: string, _filePath?: string): IDisposable {
|
||||
let filePath: string;
|
||||
if (typeof _filePath === 'undefined') {
|
||||
filePath = `ts:extralib-${Math.random().toString(36).substring(2, 15)}`;
|
||||
} else {
|
||||
filePath = _filePath;
|
||||
}
|
||||
|
||||
if (this._extraLibs[filePath] && this._extraLibs[filePath].content === content) {
|
||||
// no-op, there already exists an extra lib with this content
|
||||
return {
|
||||
dispose: () => {}
|
||||
};
|
||||
}
|
||||
|
||||
let myVersion = 1;
|
||||
if (this._removedExtraLibs[filePath]) {
|
||||
myVersion = this._removedExtraLibs[filePath] + 1;
|
||||
}
|
||||
if (this._extraLibs[filePath]) {
|
||||
myVersion = this._extraLibs[filePath].version + 1;
|
||||
}
|
||||
|
||||
this._extraLibs[filePath] = {
|
||||
content: content,
|
||||
version: myVersion
|
||||
};
|
||||
this._fireOnDidExtraLibsChangeSoon();
|
||||
|
||||
return {
|
||||
dispose: () => {
|
||||
let extraLib = this._extraLibs[filePath];
|
||||
if (!extraLib) {
|
||||
return;
|
||||
}
|
||||
if (extraLib.version !== myVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete this._extraLibs[filePath];
|
||||
this._removedExtraLibs[filePath] = myVersion;
|
||||
this._fireOnDidExtraLibsChangeSoon();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
setExtraLibs(libs: { content: string; filePath?: string }[]): void {
|
||||
for (const filePath in this._extraLibs) {
|
||||
this._removedExtraLibs[filePath] = this._extraLibs[filePath].version;
|
||||
}
|
||||
// clear out everything
|
||||
this._extraLibs = Object.create(null);
|
||||
|
||||
if (libs && libs.length > 0) {
|
||||
for (const lib of libs) {
|
||||
const filePath =
|
||||
lib.filePath || `ts:extralib-${Math.random().toString(36).substring(2, 15)}`;
|
||||
const content = lib.content;
|
||||
let myVersion = 1;
|
||||
if (this._removedExtraLibs[filePath]) {
|
||||
myVersion = this._removedExtraLibs[filePath] + 1;
|
||||
}
|
||||
this._extraLibs[filePath] = {
|
||||
content: content,
|
||||
version: myVersion
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
this._fireOnDidExtraLibsChangeSoon();
|
||||
}
|
||||
|
||||
private _fireOnDidExtraLibsChangeSoon(): void {
|
||||
if (this._onDidExtraLibsChangeTimeout !== -1) {
|
||||
// already scheduled
|
||||
return;
|
||||
}
|
||||
this._onDidExtraLibsChangeTimeout = setTimeout(() => {
|
||||
this._onDidExtraLibsChangeTimeout = -1;
|
||||
this._onDidExtraLibsChange.fire(undefined);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
getCompilerOptions(): CompilerOptions {
|
||||
return this._compilerOptions;
|
||||
}
|
||||
|
||||
setCompilerOptions(options: CompilerOptions): void {
|
||||
this._compilerOptions = options || Object.create(null);
|
||||
this._onDidChange.fire(undefined);
|
||||
}
|
||||
|
||||
getDiagnosticsOptions(): DiagnosticsOptions {
|
||||
return this._diagnosticsOptions;
|
||||
}
|
||||
|
||||
setDiagnosticsOptions(options: DiagnosticsOptions): void {
|
||||
this._diagnosticsOptions = options || Object.create(null);
|
||||
this._onDidChange.fire(undefined);
|
||||
}
|
||||
|
||||
setWorkerOptions(options: WorkerOptions): void {
|
||||
this._workerOptions = options || Object.create(null);
|
||||
this._onDidChange.fire(undefined);
|
||||
}
|
||||
|
||||
setInlayHintsOptions(options: InlayHintsOptions): void {
|
||||
this._inlayHintsOptions = options || Object.create(null);
|
||||
this._onDidChange.fire(undefined);
|
||||
}
|
||||
|
||||
setMaximumWorkerIdleTime(value: number): void {}
|
||||
|
||||
setEagerModelSync(value: boolean) {
|
||||
// doesn't fire an event since no
|
||||
// worker restart is required here
|
||||
this._eagerModelSync = value;
|
||||
}
|
||||
|
||||
getEagerModelSync() {
|
||||
return this._eagerModelSync;
|
||||
}
|
||||
}
|
||||
|
||||
export const typescriptVersion: string = tsversion;
|
||||
|
||||
export const typescriptDefaults: LanguageServiceDefaults = new LanguageServiceDefaultsImpl(
|
||||
{ allowNonTsExtensions: true, target: ScriptTarget.Latest },
|
||||
{ noSemanticValidation: false, noSyntaxValidation: false, onlyVisible: false },
|
||||
{},
|
||||
{}
|
||||
);
|
||||
|
||||
export const javascriptDefaults: LanguageServiceDefaults = new LanguageServiceDefaultsImpl(
|
||||
{ allowNonTsExtensions: true, allowJs: true, target: ScriptTarget.Latest },
|
||||
{ noSemanticValidation: true, noSyntaxValidation: false, onlyVisible: false },
|
||||
{},
|
||||
{}
|
||||
);
|
||||
|
||||
export const getTypeScriptWorker = (): Promise<(...uris: Uri[]) => Promise<TypeScriptWorker>> => {
|
||||
return getMode().then((mode) => mode.getTypeScriptWorker());
|
||||
};
|
||||
|
||||
export const getJavaScriptWorker = (): Promise<(...uris: Uri[]) => Promise<TypeScriptWorker>> => {
|
||||
return getMode().then((mode) => mode.getJavaScriptWorker());
|
||||
};
|
||||
|
||||
// export to the global based API
|
||||
(<any>languages).typescript = {
|
||||
ModuleKind,
|
||||
JsxEmit,
|
||||
NewLineKind,
|
||||
ScriptTarget,
|
||||
ModuleResolutionKind,
|
||||
typescriptVersion,
|
||||
typescriptDefaults,
|
||||
javascriptDefaults,
|
||||
getTypeScriptWorker,
|
||||
getJavaScriptWorker
|
||||
};
|
||||
|
||||
// --- Registration to monaco editor ---
|
||||
|
||||
function getMode(): Promise<typeof mode> {
|
||||
return import('./tsMode');
|
||||
}
|
||||
|
||||
languages.onLanguage('typescript', () => {
|
||||
return getMode().then((mode) => mode.setupTypeScript(typescriptDefaults));
|
||||
});
|
||||
languages.onLanguage('javascript', () => {
|
||||
return getMode().then((mode) => mode.setupJavaScript(javascriptDefaults));
|
||||
});
|
||||
16
monaco-typescript/src/ts.worker.ts
Normal file
16
monaco-typescript/src/ts.worker.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as edworker from 'monaco-editor-core/esm/vs/editor/editor.worker';
|
||||
import { TypeScriptWorker, ICreateData } from './tsWorker';
|
||||
import { worker } from './fillers/monaco-editor-core';
|
||||
|
||||
self.onmessage = () => {
|
||||
// ignore the first message
|
||||
edworker.initialize((ctx: worker.IWorkerContext, createData: ICreateData) => {
|
||||
return new TypeScriptWorker(ctx, createData);
|
||||
});
|
||||
};
|
||||
87
monaco-typescript/src/tsMode.ts
Normal file
87
monaco-typescript/src/tsMode.ts
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { WorkerManager } from './workerManager';
|
||||
import type { TypeScriptWorker } from './tsWorker';
|
||||
import { LanguageServiceDefaults } from './monaco.contribution';
|
||||
import * as languageFeatures from './languageFeatures';
|
||||
import { languages, Uri } from './fillers/monaco-editor-core';
|
||||
|
||||
let javaScriptWorker: (...uris: Uri[]) => Promise<TypeScriptWorker>;
|
||||
let typeScriptWorker: (...uris: Uri[]) => Promise<TypeScriptWorker>;
|
||||
|
||||
export function setupTypeScript(defaults: LanguageServiceDefaults): void {
|
||||
typeScriptWorker = setupMode(defaults, 'typescript');
|
||||
}
|
||||
|
||||
export function setupJavaScript(defaults: LanguageServiceDefaults): void {
|
||||
javaScriptWorker = setupMode(defaults, 'javascript');
|
||||
}
|
||||
|
||||
export function getJavaScriptWorker(): Promise<(...uris: Uri[]) => Promise<TypeScriptWorker>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!javaScriptWorker) {
|
||||
return reject('JavaScript not registered!');
|
||||
}
|
||||
|
||||
resolve(javaScriptWorker);
|
||||
});
|
||||
}
|
||||
|
||||
export function getTypeScriptWorker(): Promise<(...uris: Uri[]) => Promise<TypeScriptWorker>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!typeScriptWorker) {
|
||||
return reject('TypeScript not registered!');
|
||||
}
|
||||
|
||||
resolve(typeScriptWorker);
|
||||
});
|
||||
}
|
||||
|
||||
function setupMode(
|
||||
defaults: LanguageServiceDefaults,
|
||||
modeId: string
|
||||
): (...uris: Uri[]) => Promise<TypeScriptWorker> {
|
||||
const client = new WorkerManager(modeId, defaults);
|
||||
const worker = (...uris: Uri[]): Promise<TypeScriptWorker> => {
|
||||
return client.getLanguageServiceWorker(...uris);
|
||||
};
|
||||
|
||||
const libFiles = new languageFeatures.LibFiles(worker);
|
||||
|
||||
languages.registerCompletionItemProvider(modeId, new languageFeatures.SuggestAdapter(worker));
|
||||
languages.registerSignatureHelpProvider(
|
||||
modeId,
|
||||
new languageFeatures.SignatureHelpAdapter(worker)
|
||||
);
|
||||
languages.registerHoverProvider(modeId, new languageFeatures.QuickInfoAdapter(worker));
|
||||
languages.registerDocumentHighlightProvider(
|
||||
modeId,
|
||||
new languageFeatures.OccurrencesAdapter(worker)
|
||||
);
|
||||
languages.registerDefinitionProvider(
|
||||
modeId,
|
||||
new languageFeatures.DefinitionAdapter(libFiles, worker)
|
||||
);
|
||||
languages.registerReferenceProvider(
|
||||
modeId,
|
||||
new languageFeatures.ReferenceAdapter(libFiles, worker)
|
||||
);
|
||||
languages.registerDocumentSymbolProvider(modeId, new languageFeatures.OutlineAdapter(worker));
|
||||
languages.registerDocumentRangeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatAdapter(worker)
|
||||
);
|
||||
languages.registerOnTypeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatOnTypeAdapter(worker)
|
||||
);
|
||||
languages.registerCodeActionProvider(modeId, new languageFeatures.CodeActionAdaptor(worker));
|
||||
languages.registerRenameProvider(modeId, new languageFeatures.RenameAdapter(libFiles, worker));
|
||||
languages.registerInlayHintsProvider(modeId, new languageFeatures.InlayHintsAdapter(worker));
|
||||
new languageFeatures.DiagnosticsAdapter(libFiles, defaults, modeId, worker);
|
||||
return worker;
|
||||
}
|
||||
496
monaco-typescript/src/tsWorker.ts
Normal file
496
monaco-typescript/src/tsWorker.ts
Normal file
|
|
@ -0,0 +1,496 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as ts from './lib/typescriptServices';
|
||||
import { libFileMap } from './lib/lib';
|
||||
import {
|
||||
Diagnostic,
|
||||
DiagnosticRelatedInformation,
|
||||
IExtraLibs,
|
||||
TypeScriptWorker as ITypeScriptWorker
|
||||
} from './monaco.contribution';
|
||||
import { Uri, worker } from './fillers/monaco-editor-core';
|
||||
|
||||
/**
|
||||
* Loading a default lib as a source file will mess up TS completely.
|
||||
* So our strategy is to hide such a text model from TS.
|
||||
* See https://github.com/microsoft/monaco-editor/issues/2182
|
||||
*/
|
||||
function fileNameIsLib(resource: Uri | string): boolean {
|
||||
if (typeof resource === 'string') {
|
||||
if (/^file:\/\/\//.test(resource)) {
|
||||
return !!libFileMap[resource.substr(8)];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (resource.path.indexOf('/lib.') === 0) {
|
||||
return !!libFileMap[resource.path.slice(1)];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWorker {
|
||||
// --- model sync -----------------------
|
||||
|
||||
private _ctx: worker.IWorkerContext;
|
||||
private _extraLibs: IExtraLibs = Object.create(null);
|
||||
private _languageService = ts.createLanguageService(this);
|
||||
private _compilerOptions: ts.CompilerOptions;
|
||||
private _inlayHintsOptions?: ts.InlayHintsOptions;
|
||||
|
||||
constructor(ctx: worker.IWorkerContext, createData: ICreateData) {
|
||||
this._ctx = ctx;
|
||||
this._compilerOptions = createData.compilerOptions;
|
||||
this._extraLibs = createData.extraLibs;
|
||||
this._inlayHintsOptions = createData.inlayHintsOptions;
|
||||
}
|
||||
|
||||
// --- language service host ---------------
|
||||
|
||||
getCompilationSettings(): ts.CompilerOptions {
|
||||
return this._compilerOptions;
|
||||
}
|
||||
|
||||
getLanguageService(): ts.LanguageService {
|
||||
return this._languageService;
|
||||
}
|
||||
|
||||
getExtraLibs(): IExtraLibs {
|
||||
return this._extraLibs;
|
||||
}
|
||||
|
||||
getScriptFileNames(): string[] {
|
||||
const allModels = this._ctx.getMirrorModels().map((model) => model.uri);
|
||||
const models = allModels.filter((uri) => !fileNameIsLib(uri)).map((uri) => uri.toString());
|
||||
return models.concat(Object.keys(this._extraLibs));
|
||||
}
|
||||
|
||||
private _getModel(fileName: string): worker.IMirrorModel | null {
|
||||
let models = this._ctx.getMirrorModels();
|
||||
for (let i = 0; i < models.length; i++) {
|
||||
if (models[i].uri.toString() === fileName) {
|
||||
return models[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getScriptVersion(fileName: string): string {
|
||||
let model = this._getModel(fileName);
|
||||
if (model) {
|
||||
return model.version.toString();
|
||||
} else if (this.isDefaultLibFileName(fileName)) {
|
||||
// default lib is static
|
||||
return '1';
|
||||
} else if (fileName in this._extraLibs) {
|
||||
return String(this._extraLibs[fileName].version);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
async getScriptText(fileName: string): Promise<string | undefined> {
|
||||
return this._getScriptText(fileName);
|
||||
}
|
||||
|
||||
_getScriptText(fileName: string): string | undefined {
|
||||
let text: string;
|
||||
let model = this._getModel(fileName);
|
||||
const libizedFileName = 'lib.' + fileName + '.d.ts';
|
||||
if (model) {
|
||||
// a true editor model
|
||||
text = model.getValue();
|
||||
} else if (fileName in libFileMap) {
|
||||
text = libFileMap[fileName];
|
||||
} else if (libizedFileName in libFileMap) {
|
||||
text = libFileMap[libizedFileName];
|
||||
} else if (fileName in this._extraLibs) {
|
||||
// extra lib
|
||||
text = this._extraLibs[fileName].content;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
getScriptSnapshot(fileName: string): ts.IScriptSnapshot | undefined {
|
||||
const text = this._getScriptText(fileName);
|
||||
if (text === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
return <ts.IScriptSnapshot>{
|
||||
getText: (start, end) => text.substring(start, end),
|
||||
getLength: () => text.length,
|
||||
getChangeRange: () => undefined
|
||||
};
|
||||
}
|
||||
|
||||
getScriptKind?(fileName: string): ts.ScriptKind {
|
||||
const suffix = fileName.substr(fileName.lastIndexOf('.') + 1);
|
||||
switch (suffix) {
|
||||
case 'ts':
|
||||
return ts.ScriptKind.TS;
|
||||
case 'tsx':
|
||||
return ts.ScriptKind.TSX;
|
||||
case 'js':
|
||||
return ts.ScriptKind.JS;
|
||||
case 'jsx':
|
||||
return ts.ScriptKind.JSX;
|
||||
default:
|
||||
return this.getCompilationSettings().allowJs ? ts.ScriptKind.JS : ts.ScriptKind.TS;
|
||||
}
|
||||
}
|
||||
|
||||
getCurrentDirectory(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
getDefaultLibFileName(options: ts.CompilerOptions): string {
|
||||
switch (options.target) {
|
||||
case 99 /* ESNext */:
|
||||
const esnext = 'lib.esnext.full.d.ts';
|
||||
if (esnext in libFileMap || esnext in this._extraLibs) return esnext;
|
||||
case 7 /* ES2020 */:
|
||||
case 6 /* ES2019 */:
|
||||
case 5 /* ES2018 */:
|
||||
case 4 /* ES2017 */:
|
||||
case 3 /* ES2016 */:
|
||||
case 2 /* ES2015 */:
|
||||
default:
|
||||
// Support a dynamic lookup for the ES20XX version based on the target
|
||||
// which is safe unless TC39 changes their numbering system
|
||||
const eslib = `lib.es${2013 + (options.target || 99)}.full.d.ts`;
|
||||
// Note: This also looks in _extraLibs, If you want
|
||||
// to add support for additional target options, you will need to
|
||||
// add the extra dts files to _extraLibs via the API.
|
||||
if (eslib in libFileMap || eslib in this._extraLibs) {
|
||||
return eslib;
|
||||
}
|
||||
|
||||
return 'lib.es6.d.ts'; // We don't use lib.es2015.full.d.ts due to breaking change.
|
||||
case 1:
|
||||
case 0:
|
||||
return 'lib.d.ts';
|
||||
}
|
||||
}
|
||||
|
||||
isDefaultLibFileName(fileName: string): boolean {
|
||||
return fileName === this.getDefaultLibFileName(this._compilerOptions);
|
||||
}
|
||||
|
||||
async getLibFiles(): Promise<Record<string, string>> {
|
||||
return libFileMap;
|
||||
}
|
||||
|
||||
// --- language features
|
||||
|
||||
private static clearFiles(tsDiagnostics: ts.Diagnostic[]): Diagnostic[] {
|
||||
// Clear the `file` field, which cannot be JSON'yfied because it
|
||||
// contains cyclic data structures, except for the `fileName`
|
||||
// property.
|
||||
// Do a deep clone so we don't mutate the ts.Diagnostic object (see https://github.com/microsoft/monaco-editor/issues/2392)
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
for (const tsDiagnostic of tsDiagnostics) {
|
||||
const diagnostic: Diagnostic = { ...tsDiagnostic };
|
||||
diagnostic.file = diagnostic.file ? { fileName: diagnostic.file.fileName } : undefined;
|
||||
if (tsDiagnostic.relatedInformation) {
|
||||
diagnostic.relatedInformation = [];
|
||||
for (const tsRelatedDiagnostic of tsDiagnostic.relatedInformation) {
|
||||
const relatedDiagnostic: DiagnosticRelatedInformation = { ...tsRelatedDiagnostic };
|
||||
relatedDiagnostic.file = relatedDiagnostic.file
|
||||
? { fileName: relatedDiagnostic.file.fileName }
|
||||
: undefined;
|
||||
diagnostic.relatedInformation.push(relatedDiagnostic);
|
||||
}
|
||||
}
|
||||
diagnostics.push(diagnostic);
|
||||
}
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
async getSyntacticDiagnostics(fileName: string): Promise<Diagnostic[]> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
const diagnostics = this._languageService.getSyntacticDiagnostics(fileName);
|
||||
return TypeScriptWorker.clearFiles(diagnostics);
|
||||
}
|
||||
|
||||
async getSemanticDiagnostics(fileName: string): Promise<Diagnostic[]> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
const diagnostics = this._languageService.getSemanticDiagnostics(fileName);
|
||||
return TypeScriptWorker.clearFiles(diagnostics);
|
||||
}
|
||||
|
||||
async getSuggestionDiagnostics(fileName: string): Promise<Diagnostic[]> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
const diagnostics = this._languageService.getSuggestionDiagnostics(fileName);
|
||||
return TypeScriptWorker.clearFiles(diagnostics);
|
||||
}
|
||||
|
||||
async getCompilerOptionsDiagnostics(fileName: string): Promise<Diagnostic[]> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
const diagnostics = this._languageService.getCompilerOptionsDiagnostics();
|
||||
return TypeScriptWorker.clearFiles(diagnostics);
|
||||
}
|
||||
|
||||
async getCompletionsAtPosition(
|
||||
fileName: string,
|
||||
position: number
|
||||
): Promise<ts.CompletionInfo | undefined> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
return this._languageService.getCompletionsAtPosition(fileName, position, undefined);
|
||||
}
|
||||
|
||||
async getCompletionEntryDetails(
|
||||
fileName: string,
|
||||
position: number,
|
||||
entry: string
|
||||
): Promise<ts.CompletionEntryDetails | undefined> {
|
||||
return this._languageService.getCompletionEntryDetails(
|
||||
fileName,
|
||||
position,
|
||||
entry,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
}
|
||||
|
||||
async getSignatureHelpItems(
|
||||
fileName: string,
|
||||
position: number,
|
||||
options: ts.SignatureHelpItemsOptions | undefined
|
||||
): Promise<ts.SignatureHelpItems | undefined> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
return this._languageService.getSignatureHelpItems(fileName, position, options);
|
||||
}
|
||||
|
||||
async getQuickInfoAtPosition(
|
||||
fileName: string,
|
||||
position: number
|
||||
): Promise<ts.QuickInfo | undefined> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
return this._languageService.getQuickInfoAtPosition(fileName, position);
|
||||
}
|
||||
|
||||
async getOccurrencesAtPosition(
|
||||
fileName: string,
|
||||
position: number
|
||||
): Promise<ReadonlyArray<ts.ReferenceEntry> | undefined> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
return this._languageService.getOccurrencesAtPosition(fileName, position);
|
||||
}
|
||||
|
||||
async getDefinitionAtPosition(
|
||||
fileName: string,
|
||||
position: number
|
||||
): Promise<ReadonlyArray<ts.DefinitionInfo> | undefined> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
return this._languageService.getDefinitionAtPosition(fileName, position);
|
||||
}
|
||||
|
||||
async getReferencesAtPosition(
|
||||
fileName: string,
|
||||
position: number
|
||||
): Promise<ts.ReferenceEntry[] | undefined> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
return this._languageService.getReferencesAtPosition(fileName, position);
|
||||
}
|
||||
|
||||
async getNavigationBarItems(fileName: string): Promise<ts.NavigationBarItem[]> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
return this._languageService.getNavigationBarItems(fileName);
|
||||
}
|
||||
|
||||
async getFormattingEditsForDocument(
|
||||
fileName: string,
|
||||
options: ts.FormatCodeOptions
|
||||
): Promise<ts.TextChange[]> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
return this._languageService.getFormattingEditsForDocument(fileName, options);
|
||||
}
|
||||
|
||||
async getFormattingEditsForRange(
|
||||
fileName: string,
|
||||
start: number,
|
||||
end: number,
|
||||
options: ts.FormatCodeOptions
|
||||
): Promise<ts.TextChange[]> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
return this._languageService.getFormattingEditsForRange(fileName, start, end, options);
|
||||
}
|
||||
|
||||
async getFormattingEditsAfterKeystroke(
|
||||
fileName: string,
|
||||
postion: number,
|
||||
ch: string,
|
||||
options: ts.FormatCodeOptions
|
||||
): Promise<ts.TextChange[]> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
return this._languageService.getFormattingEditsAfterKeystroke(fileName, postion, ch, options);
|
||||
}
|
||||
|
||||
async findRenameLocations(
|
||||
fileName: string,
|
||||
position: number,
|
||||
findInStrings: boolean,
|
||||
findInComments: boolean,
|
||||
providePrefixAndSuffixTextForRename: boolean
|
||||
): Promise<readonly ts.RenameLocation[] | undefined> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
return this._languageService.findRenameLocations(
|
||||
fileName,
|
||||
position,
|
||||
findInStrings,
|
||||
findInComments,
|
||||
providePrefixAndSuffixTextForRename
|
||||
);
|
||||
}
|
||||
|
||||
async getRenameInfo(
|
||||
fileName: string,
|
||||
position: number,
|
||||
options: ts.RenameInfoOptions
|
||||
): Promise<ts.RenameInfo> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return { canRename: false, localizedErrorMessage: 'Cannot rename in lib file' };
|
||||
}
|
||||
return this._languageService.getRenameInfo(fileName, position, options);
|
||||
}
|
||||
|
||||
async getEmitOutput(fileName: string): Promise<ts.EmitOutput> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return { outputFiles: [], emitSkipped: true };
|
||||
}
|
||||
return this._languageService.getEmitOutput(fileName);
|
||||
}
|
||||
|
||||
async getCodeFixesAtPosition(
|
||||
fileName: string,
|
||||
start: number,
|
||||
end: number,
|
||||
errorCodes: number[],
|
||||
formatOptions: ts.FormatCodeOptions
|
||||
): Promise<ReadonlyArray<ts.CodeFixAction>> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
const preferences = {};
|
||||
try {
|
||||
return this._languageService.getCodeFixesAtPosition(
|
||||
fileName,
|
||||
start,
|
||||
end,
|
||||
errorCodes,
|
||||
formatOptions,
|
||||
preferences
|
||||
);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async updateExtraLibs(extraLibs: IExtraLibs): Promise<void> {
|
||||
this._extraLibs = extraLibs;
|
||||
}
|
||||
|
||||
async provideInlayHints(
|
||||
fileName: string,
|
||||
start: number,
|
||||
end: number
|
||||
): Promise<readonly ts.InlayHint[]> {
|
||||
if (fileNameIsLib(fileName)) {
|
||||
return [];
|
||||
}
|
||||
const preferences: ts.InlayHintsOptions = this._inlayHintsOptions ?? {};
|
||||
const span: ts.TextSpan = {
|
||||
start,
|
||||
length: end - start
|
||||
};
|
||||
|
||||
try {
|
||||
return this._languageService.provideInlayHints(fileName, span, preferences);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface ICreateData {
|
||||
compilerOptions: ts.CompilerOptions;
|
||||
extraLibs: IExtraLibs;
|
||||
customWorkerPath?: string;
|
||||
inlayHintsOptions?: ts.InlayHintsOptions;
|
||||
}
|
||||
|
||||
/** The shape of the factory */
|
||||
export interface CustomTSWebWorkerFactory {
|
||||
(
|
||||
TSWorkerClass: typeof TypeScriptWorker,
|
||||
tsc: typeof ts,
|
||||
libs: Record<string, string>
|
||||
): typeof TypeScriptWorker;
|
||||
}
|
||||
|
||||
declare global {
|
||||
var importScripts: (path: string) => void | undefined;
|
||||
var customTSWorkerFactory: CustomTSWebWorkerFactory | undefined;
|
||||
}
|
||||
|
||||
export function create(ctx: worker.IWorkerContext, createData: ICreateData): TypeScriptWorker {
|
||||
let TSWorkerClass = TypeScriptWorker;
|
||||
if (createData.customWorkerPath) {
|
||||
if (typeof importScripts === 'undefined') {
|
||||
console.warn(
|
||||
'Monaco is not using webworkers for background tasks, and that is needed to support the customWorkerPath flag'
|
||||
);
|
||||
} else {
|
||||
importScripts(createData.customWorkerPath);
|
||||
|
||||
const workerFactoryFunc: CustomTSWebWorkerFactory | undefined = self.customTSWorkerFactory;
|
||||
if (!workerFactoryFunc) {
|
||||
throw new Error(
|
||||
`The script at ${createData.customWorkerPath} does not add customTSWorkerFactory to self`
|
||||
);
|
||||
}
|
||||
|
||||
TSWorkerClass = workerFactoryFunc(TypeScriptWorker, ts, libFileMap);
|
||||
}
|
||||
}
|
||||
|
||||
return new TSWorkerClass(ctx, createData);
|
||||
}
|
||||
11
monaco-typescript/src/tsconfig.esm.json
Normal file
11
monaco-typescript/src/tsconfig.esm.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../out/esm",
|
||||
"declaration": true,
|
||||
"target": "es5",
|
||||
"lib": ["dom", "es5", "es2015.collection", "es2015.iterable", "es2015.promise"],
|
||||
"strict": true
|
||||
}
|
||||
}
|
||||
11
monaco-typescript/src/tsconfig.json
Normal file
11
monaco-typescript/src/tsconfig.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "amd",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../out/amd",
|
||||
"declaration": true,
|
||||
"target": "es5",
|
||||
"lib": ["dom", "es5", "es2015.collection", "es2015.iterable", "es2015.promise"],
|
||||
"strict": true
|
||||
}
|
||||
}
|
||||
114
monaco-typescript/src/workerManager.ts
Normal file
114
monaco-typescript/src/workerManager.ts
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { LanguageServiceDefaults } from './monaco.contribution';
|
||||
import type { TypeScriptWorker } from './tsWorker';
|
||||
import { editor, Uri, IDisposable } from './fillers/monaco-editor-core';
|
||||
|
||||
export class WorkerManager {
|
||||
private _modeId: string;
|
||||
private _defaults: LanguageServiceDefaults;
|
||||
private _configChangeListener: IDisposable;
|
||||
private _updateExtraLibsToken: number;
|
||||
private _extraLibsChangeListener: IDisposable;
|
||||
|
||||
private _worker: editor.MonacoWebWorker<TypeScriptWorker> | null;
|
||||
private _client: Promise<TypeScriptWorker> | null;
|
||||
|
||||
constructor(modeId: string, defaults: LanguageServiceDefaults) {
|
||||
this._modeId = modeId;
|
||||
this._defaults = defaults;
|
||||
this._worker = null;
|
||||
this._client = null;
|
||||
this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
|
||||
this._updateExtraLibsToken = 0;
|
||||
this._extraLibsChangeListener = this._defaults.onDidExtraLibsChange(() =>
|
||||
this._updateExtraLibs()
|
||||
);
|
||||
}
|
||||
|
||||
private _stopWorker(): void {
|
||||
if (this._worker) {
|
||||
this._worker.dispose();
|
||||
this._worker = null;
|
||||
}
|
||||
this._client = null;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._configChangeListener.dispose();
|
||||
this._extraLibsChangeListener.dispose();
|
||||
this._stopWorker();
|
||||
}
|
||||
|
||||
private async _updateExtraLibs(): Promise<void> {
|
||||
if (!this._worker) {
|
||||
return;
|
||||
}
|
||||
const myToken = ++this._updateExtraLibsToken;
|
||||
const proxy = await this._worker.getProxy();
|
||||
if (this._updateExtraLibsToken !== myToken) {
|
||||
// avoid multiple calls
|
||||
return;
|
||||
}
|
||||
proxy.updateExtraLibs(this._defaults.getExtraLibs());
|
||||
}
|
||||
|
||||
private _getClient(): Promise<TypeScriptWorker> {
|
||||
if (!this._client) {
|
||||
this._worker = editor.createWebWorker<TypeScriptWorker>({
|
||||
// module that exports the create() method and returns a `TypeScriptWorker` instance
|
||||
moduleId: 'vs/language/typescript/tsWorker',
|
||||
|
||||
label: this._modeId,
|
||||
|
||||
keepIdleModels: true,
|
||||
|
||||
// passed in to the create() method
|
||||
createData: {
|
||||
compilerOptions: this._defaults.getCompilerOptions(),
|
||||
extraLibs: this._defaults.getExtraLibs(),
|
||||
customWorkerPath: this._defaults.workerOptions.customWorkerPath,
|
||||
inlayHintsOptions: this._defaults.inlayHintsOptions
|
||||
}
|
||||
});
|
||||
|
||||
let p = <Promise<TypeScriptWorker>>this._worker.getProxy();
|
||||
|
||||
if (this._defaults.getEagerModelSync()) {
|
||||
p = p.then((worker) => {
|
||||
if (this._worker) {
|
||||
return this._worker.withSyncedResources(
|
||||
editor
|
||||
.getModels()
|
||||
.filter((model) => model.getLanguageId() === this._modeId)
|
||||
.map((model) => model.uri)
|
||||
);
|
||||
}
|
||||
return worker;
|
||||
});
|
||||
}
|
||||
|
||||
this._client = p;
|
||||
}
|
||||
|
||||
return this._client;
|
||||
}
|
||||
|
||||
getLanguageServiceWorker(...resources: Uri[]): Promise<TypeScriptWorker> {
|
||||
let _client: TypeScriptWorker;
|
||||
return this._getClient()
|
||||
.then((client) => {
|
||||
_client = client;
|
||||
})
|
||||
.then((_) => {
|
||||
if (this._worker) {
|
||||
return this._worker.withSyncedResources(resources);
|
||||
}
|
||||
})
|
||||
.then((_) => _client);
|
||||
}
|
||||
}
|
||||
241
monaco-typescript/test/custom-worker.html
Normal file
241
monaco-typescript/test/custom-worker.html
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
<!--
|
||||
To test this file, you need to use a local server. The recommendation is that you run:
|
||||
|
||||
npx serve .
|
||||
|
||||
Then open http://localhost:5000/test/custom-worker
|
||||
-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
data-name="vs/editor/editor.main"
|
||||
href="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.css"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Monaco Editor TypeScript test page</h2>
|
||||
<button id="resetBtn">Reset Sample</button>
|
||||
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
|
||||
<h3>Custom webworker</h3>
|
||||
<button id="logDTS">Log DTS</button>
|
||||
<button id="getAST">Print AST to console</button>
|
||||
|
||||
<script>
|
||||
const paths = {
|
||||
'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
|
||||
'vs/language/typescript/fillers/monaco-editor-core':
|
||||
'../out/amd/fillers/monaco-editor-core-amd',
|
||||
'vs/language/typescript': '../out/amd',
|
||||
vs: '../node_modules/monaco-editor-core/dev/vs'
|
||||
};
|
||||
if (document.location.protocol === 'http:') {
|
||||
// Add support for running local http server
|
||||
let testIndex = document.location.pathname.indexOf('/test/');
|
||||
if (testIndex !== -1) {
|
||||
let prefix = document.location.pathname.substr(0, testIndex);
|
||||
paths['vs/language/typescript'] = prefix + '/out/amd';
|
||||
}
|
||||
}
|
||||
self.require = {
|
||||
paths: paths
|
||||
};
|
||||
</script>
|
||||
<script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>
|
||||
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.nls.js"></script>
|
||||
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
|
||||
|
||||
<script>
|
||||
function getDefaultCode() {
|
||||
return [
|
||||
'/* Game of Life',
|
||||
' * Implemented in TypeScript',
|
||||
' * To learn more about TypeScript, please visit http://www.typescriptlang.org/',
|
||||
' */',
|
||||
'',
|
||||
'module Conway {',
|
||||
'',
|
||||
' export class Cell {',
|
||||
' public row: number;',
|
||||
' public col: number;',
|
||||
' public live: boolean;',
|
||||
'',
|
||||
' constructor(row: number, col: number, live: boolean) {',
|
||||
' this.row = row;',
|
||||
' this.col = col;',
|
||||
' this.live = live',
|
||||
' }',
|
||||
' }',
|
||||
'',
|
||||
' export class GameOfLife {',
|
||||
' private gridSize: number;',
|
||||
' private canvasSize: number;',
|
||||
' private lineColor: string;',
|
||||
' private liveColor: string;',
|
||||
' private deadColor: string;',
|
||||
' private initialLifeProbability: number;',
|
||||
' private animationRate: number;',
|
||||
' private cellSize: number;',
|
||||
' private context: CanvasRenderingContext2D;',
|
||||
' private world;',
|
||||
'',
|
||||
'',
|
||||
' constructor() {',
|
||||
' this.gridSize = 50;',
|
||||
' this.canvasSize = 600;',
|
||||
" this.lineColor = '#cdcdcd';",
|
||||
" this.liveColor = '#666';",
|
||||
" this.deadColor = '#eee';",
|
||||
' this.initialLifeProbability = 0.5;',
|
||||
' this.animationRate = 60;',
|
||||
' this.cellSize = 0;',
|
||||
' this.world = this.createWorld();',
|
||||
' this.circleOfLife();',
|
||||
' }',
|
||||
'',
|
||||
' public createWorld() {',
|
||||
' return this.travelWorld( (cell : Cell) => {',
|
||||
' cell.live = Math.random() < this.initialLifeProbability;',
|
||||
' return cell;',
|
||||
' });',
|
||||
' }',
|
||||
'',
|
||||
' public circleOfLife() : void {',
|
||||
' this.world = this.travelWorld( (cell: Cell) => {',
|
||||
' cell = this.world[cell.row][cell.col];',
|
||||
' this.draw(cell);',
|
||||
' return this.resolveNextGeneration(cell);',
|
||||
' });',
|
||||
' setTimeout( () => {this.circleOfLife()}, this.animationRate);',
|
||||
' }',
|
||||
'',
|
||||
' public resolveNextGeneration(cell : Cell) {',
|
||||
' var count = this.countNeighbors(cell);',
|
||||
' var newCell = new Cell(cell.row, cell.col, cell.live);',
|
||||
' if(count < 2 || count > 3) newCell.live = false;',
|
||||
' else if(count == 3) newCell.live = true;',
|
||||
' return newCell;',
|
||||
' }',
|
||||
'',
|
||||
' public countNeighbors(cell : Cell) {',
|
||||
' var neighbors = 0;',
|
||||
' for(var row = -1; row <=1; row++) {',
|
||||
' for(var col = -1; col <= 1; col++) {',
|
||||
' if(row == 0 && col == 0) continue;',
|
||||
' if(this.isAlive(cell.row + row, cell.col + col)) {',
|
||||
' neighbors++;',
|
||||
' }',
|
||||
' }',
|
||||
' }',
|
||||
' return neighbors;',
|
||||
' }',
|
||||
'',
|
||||
' public isAlive(row : number, col : number) {',
|
||||
' if(row < 0 || col < 0 || row >= this.gridSize || col >= this.gridSize) return false;',
|
||||
' return this.world[row][col].live;',
|
||||
' }',
|
||||
'',
|
||||
' public travelWorld(callback) {',
|
||||
' var result = [];',
|
||||
' for(var row = 0; row < this.gridSize; row++) {',
|
||||
' var rowData = [];',
|
||||
' for(var col = 0; col < this.gridSize; col++) {',
|
||||
' rowData.push(callback(new Cell(row, col, false)));',
|
||||
' }',
|
||||
' result.push(rowData);',
|
||||
' }',
|
||||
' return result;',
|
||||
' }',
|
||||
'',
|
||||
' public draw(cell : Cell) {',
|
||||
' if(this.context == null) this.context = this.createDrawingContext();',
|
||||
' if(this.cellSize == 0) this.cellSize = this.canvasSize/this.gridSize;',
|
||||
'',
|
||||
' this.context.strokeStyle = this.lineColor;',
|
||||
' this.context.strokeRect(cell.row * this.cellSize, cell.col*this.cellSize, this.cellSize, this.cellSize);',
|
||||
' this.context.fillStyle = cell.live ? this.liveColor : this.deadColor;',
|
||||
' this.context.fillRect(cell.row * this.cellSize, cell.col*this.cellSize, this.cellSize, this.cellSize);',
|
||||
' }',
|
||||
'',
|
||||
' public createDrawingContext() {',
|
||||
" var canvas = <HTMLCanvasElement> document.getElementById('conway-canvas');",
|
||||
' if(canvas == null) {',
|
||||
" canvas = document.createElement('canvas');",
|
||||
" canvas.id = 'conway-canvas';",
|
||||
' canvas.width = this.canvasSize;',
|
||||
' canvas.height = this.canvasSize;',
|
||||
' document.body.appendChild(canvas);',
|
||||
' }',
|
||||
" return canvas.getContext('2d');",
|
||||
' }',
|
||||
' }',
|
||||
'}',
|
||||
'',
|
||||
'var game = new Conway.GameOfLife();'
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function getDefaultComplierOpts() {
|
||||
return { target: 99, jsx: 1, allowNonTsExtensions: true };
|
||||
}
|
||||
require([
|
||||
'vs/basic-languages/monaco.contribution',
|
||||
'vs/language/typescript/monaco.contribution'
|
||||
], () => {
|
||||
const dirname = (path) => {
|
||||
const slashIndex = path.lastIndexOf('/');
|
||||
if (slashIndex >= 0) {
|
||||
return path.substring(0, slashIndex);
|
||||
}
|
||||
return path;
|
||||
};
|
||||
const customWorkerPath = `${dirname(location.href)}/custom-worker.js`;
|
||||
monaco.languages.typescript.typescriptDefaults.setWorkerOptions({
|
||||
customWorkerPath: customWorkerPath
|
||||
});
|
||||
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
||||
target: 99,
|
||||
jsx: 1,
|
||||
allowNonTsExtensions: true,
|
||||
declaration: true,
|
||||
noLibCheck: true
|
||||
});
|
||||
|
||||
var editor = monaco.editor.create(document.getElementById('container'), {
|
||||
value: localStorage.getItem('code') || getDefaultCode(),
|
||||
language: 'typescript',
|
||||
lightbulb: { enabled: true }
|
||||
});
|
||||
|
||||
editor.onDidChangeModelContent(() => {
|
||||
const code = editor.getModel().getValue();
|
||||
localStorage.setItem('code', code);
|
||||
});
|
||||
|
||||
document.getElementById('resetBtn').onclick = () => {
|
||||
editor.setValue(getDefaultCode());
|
||||
};
|
||||
|
||||
document.getElementById('logDTS').onclick = async () => {
|
||||
const model = editor.getModel();
|
||||
const worker = await monaco.languages.typescript.getTypeScriptWorker();
|
||||
const thisWorker = await worker(model.uri);
|
||||
const dts = await thisWorker.getDTSEmitForFile(model.uri.toString());
|
||||
console.log(dts);
|
||||
};
|
||||
|
||||
document.getElementById('getAST').onclick = async () => {
|
||||
const model = editor.getModel();
|
||||
const worker = await monaco.languages.typescript.getTypeScriptWorker();
|
||||
const thisWorker = await worker(model.uri);
|
||||
const ast = await thisWorker.printAST(model.uri.toString());
|
||||
console.log(ast);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
59
monaco-typescript/test/custom-worker.js
Normal file
59
monaco-typescript/test/custom-worker.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// This example uses @typescript/vfs to create a virtual TS program
|
||||
// which can do work on a bg thread.
|
||||
|
||||
// This version of the vfs edits the global scope (in the case of a webworker, this is 'self')
|
||||
importScripts('https://unpkg.com/@typescript/vfs@1.3.0/dist/vfs.globals.js');
|
||||
|
||||
/** @type { import("@typescript/vfs") } */
|
||||
const tsvfs = globalThis.tsvfs;
|
||||
|
||||
/** @type {import("../src/tsWorker").CustomTSWebWorkerFactory }*/
|
||||
const worker = (TypeScriptWorker, ts, libFileMap) => {
|
||||
return class MonacoTSWorker extends TypeScriptWorker {
|
||||
// Adds a custom function to the webworker
|
||||
async getDTSEmitForFile(fileName) {
|
||||
const result = await this.getEmitOutput(fileName);
|
||||
const firstDTS = result.outputFiles.find((o) => o.name.endsWith('.d.ts'));
|
||||
return (firstDTS && firstDTS.text) || '';
|
||||
}
|
||||
|
||||
async printAST(fileName) {
|
||||
console.log('Creating virtual TS project');
|
||||
const compilerOptions = this.getCompilationSettings();
|
||||
const fsMap = new Map();
|
||||
for (const key of Object.keys(libFileMap)) {
|
||||
fsMap.set(key, '/' + libFileMap[key]);
|
||||
}
|
||||
|
||||
const thisCode = await this.getScriptText(fileName);
|
||||
fsMap.set('index.ts', thisCode);
|
||||
|
||||
console.log('Starting up TS program');
|
||||
const system = tsvfs.createSystem(fsMap);
|
||||
const host = tsvfs.createVirtualCompilerHost(system, compilerOptions, ts);
|
||||
|
||||
const program = ts.createProgram({
|
||||
rootNames: [...fsMap.keys()],
|
||||
options: compilerOptions,
|
||||
host: host.compilerHost
|
||||
});
|
||||
|
||||
// Now I can look at the AST for the .ts file too
|
||||
const mainSrcFile = program.getSourceFile('index.ts');
|
||||
let miniAST = 'SourceFile';
|
||||
|
||||
const recurse = (parent, depth) => {
|
||||
if (depth > 5) return;
|
||||
ts.forEachChild(parent, (node) => {
|
||||
const spaces = ' '.repeat(depth + 1);
|
||||
miniAST += `\n${spaces}${ts.SyntaxKind[node.kind]}`;
|
||||
recurse(node, depth + 1);
|
||||
});
|
||||
};
|
||||
recurse(mainSrcFile, 0);
|
||||
return miniAST;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
self.customTSWorkerFactory = worker;
|
||||
210
monaco-typescript/test/index.html
Normal file
210
monaco-typescript/test/index.html
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
data-name="vs/editor/editor.main"
|
||||
href="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.css"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Monaco Editor TypeScript test page</h2>
|
||||
<button id="resetBtn">Reset Sample</button>
|
||||
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
|
||||
<h3>Compiler settings</h3>
|
||||
<textarea style="font-family: monospace" id="compilerOpts" cols="60" rows="30"></textarea><br />
|
||||
<button id="updateCompilerSettingsBtn">Update compiler settings</button>
|
||||
|
||||
<script>
|
||||
const paths = {
|
||||
'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
|
||||
'vs/language/typescript/fillers/monaco-editor-core':
|
||||
'../out/amd/fillers/monaco-editor-core-amd',
|
||||
'vs/language/typescript': '../out/amd',
|
||||
vs: '../node_modules/monaco-editor-core/dev/vs'
|
||||
};
|
||||
if (document.location.protocol === 'http:') {
|
||||
// Add support for running local http server
|
||||
let testIndex = document.location.pathname.indexOf('/test/');
|
||||
if (testIndex !== -1) {
|
||||
let prefix = document.location.pathname.substr(0, testIndex);
|
||||
paths['vs/language/typescript'] = prefix + '/out/amd';
|
||||
}
|
||||
}
|
||||
self.require = {
|
||||
paths: paths
|
||||
};
|
||||
</script>
|
||||
<script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>
|
||||
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.nls.js"></script>
|
||||
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
|
||||
|
||||
<script>
|
||||
function getDefaultCode() {
|
||||
return [
|
||||
'/* Game of Life',
|
||||
' * Implemented in TypeScript',
|
||||
' * To learn more about TypeScript, please visit http://www.typescriptlang.org/',
|
||||
' */',
|
||||
'',
|
||||
'module Conway {',
|
||||
'',
|
||||
' export class Cell {',
|
||||
' public row: number;',
|
||||
' public col: number;',
|
||||
' public live: boolean;',
|
||||
'',
|
||||
' constructor(row: number, col: number, live: boolean) {',
|
||||
' this.row = row;',
|
||||
' this.col = col;',
|
||||
' this.live = live',
|
||||
' }',
|
||||
' }',
|
||||
'',
|
||||
' export class GameOfLife {',
|
||||
' private gridSize: number;',
|
||||
' private canvasSize: number;',
|
||||
' private lineColor: string;',
|
||||
' private liveColor: string;',
|
||||
' private deadColor: string;',
|
||||
' private initialLifeProbability: number;',
|
||||
' private animationRate: number;',
|
||||
' private cellSize: number;',
|
||||
' private context: CanvasRenderingContext2D;',
|
||||
' private world;',
|
||||
'',
|
||||
'',
|
||||
' constructor() {',
|
||||
' this.gridSize = 50;',
|
||||
' this.canvasSize = 600;',
|
||||
" this.lineColor = '#cdcdcd';",
|
||||
" this.liveColor = '#666';",
|
||||
" this.deadColor = '#eee';",
|
||||
' this.initialLifeProbability = 0.5;',
|
||||
' this.animationRate = 60;',
|
||||
' this.cellSize = 0;',
|
||||
' this.world = this.createWorld();',
|
||||
' this.circleOfLife();',
|
||||
' }',
|
||||
'',
|
||||
' public createWorld() {',
|
||||
' return this.travelWorld( (cell : Cell) => {',
|
||||
' cell.live = Math.random() < this.initialLifeProbability;',
|
||||
' return cell;',
|
||||
' });',
|
||||
' }',
|
||||
'',
|
||||
' public circleOfLife() : void {',
|
||||
' this.world = this.travelWorld( (cell: Cell) => {',
|
||||
' cell = this.world[cell.row][cell.col];',
|
||||
' this.draw(cell);',
|
||||
' return this.resolveNextGeneration(cell);',
|
||||
' });',
|
||||
' setTimeout( () => {this.circleOfLife()}, this.animationRate);',
|
||||
' }',
|
||||
'',
|
||||
' public resolveNextGeneration(cell : Cell) {',
|
||||
' var count = this.countNeighbors(cell);',
|
||||
' var newCell = new Cell(cell.row, cell.col, cell.live);',
|
||||
' if(count < 2 || count > 3) newCell.live = false;',
|
||||
' else if(count == 3) newCell.live = true;',
|
||||
' return newCell;',
|
||||
' }',
|
||||
'',
|
||||
' public countNeighbors(cell : Cell) {',
|
||||
' var neighbors = 0;',
|
||||
' for(var row = -1; row <=1; row++) {',
|
||||
' for(var col = -1; col <= 1; col++) {',
|
||||
' if(row == 0 && col == 0) continue;',
|
||||
' if(this.isAlive(cell.row + row, cell.col + col)) {',
|
||||
' neighbors++;',
|
||||
' }',
|
||||
' }',
|
||||
' }',
|
||||
' return neighbors;',
|
||||
' }',
|
||||
'',
|
||||
' public isAlive(row : number, col : number) {',
|
||||
' if(row < 0 || col < 0 || row >= this.gridSize || col >= this.gridSize) return false;',
|
||||
' return this.world[row][col].live;',
|
||||
' }',
|
||||
'',
|
||||
' public travelWorld(callback) {',
|
||||
' var result = [];',
|
||||
' for(var row = 0; row < this.gridSize; row++) {',
|
||||
' var rowData = [];',
|
||||
' for(var col = 0; col < this.gridSize; col++) {',
|
||||
' rowData.push(callback(new Cell(row, col, false)));',
|
||||
' }',
|
||||
' result.push(rowData);',
|
||||
' }',
|
||||
' return result;',
|
||||
' }',
|
||||
'',
|
||||
' public draw(cell : Cell) {',
|
||||
' if(this.context == null) this.context = this.createDrawingContext();',
|
||||
' if(this.cellSize == 0) this.cellSize = this.canvasSize/this.gridSize;',
|
||||
'',
|
||||
' this.context.strokeStyle = this.lineColor;',
|
||||
' this.context.strokeRect(cell.row * this.cellSize, cell.col*this.cellSize, this.cellSize, this.cellSize);',
|
||||
' this.context.fillStyle = cell.live ? this.liveColor : this.deadColor;',
|
||||
' this.context.fillRect(cell.row * this.cellSize, cell.col*this.cellSize, this.cellSize, this.cellSize);',
|
||||
' }',
|
||||
'',
|
||||
' public createDrawingContext() {',
|
||||
" var canvas = <HTMLCanvasElement> document.getElementById('conway-canvas');",
|
||||
' if(canvas == null) {',
|
||||
" canvas = document.createElement('canvas');",
|
||||
" canvas.id = 'conway-canvas';",
|
||||
' canvas.width = this.canvasSize;',
|
||||
' canvas.height = this.canvasSize;',
|
||||
' document.body.appendChild(canvas);',
|
||||
' }',
|
||||
" return canvas.getContext('2d');",
|
||||
' }',
|
||||
' }',
|
||||
'}',
|
||||
'',
|
||||
'var game = new Conway.GameOfLife();'
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function getDefaultComplierOpts() {
|
||||
return { target: 99, jsx: 1, allowNonTsExtensions: true };
|
||||
}
|
||||
require([
|
||||
'vs/basic-languages/monaco.contribution',
|
||||
'vs/language/typescript/monaco.contribution'
|
||||
], () => {
|
||||
const editor = monaco.editor.create(document.getElementById('container'), {
|
||||
value: localStorage.getItem('code') || getDefaultCode(),
|
||||
language: 'typescript',
|
||||
lightbulb: { enabled: true }
|
||||
});
|
||||
|
||||
editor.onDidChangeModelContent(() => {
|
||||
const code = editor.getModel().getValue();
|
||||
localStorage.setItem('code', code);
|
||||
});
|
||||
|
||||
document.getElementById('resetBtn').onclick = () => {
|
||||
editor.setValue(getDefaultCode());
|
||||
};
|
||||
|
||||
const optsString =
|
||||
localStorage.getItem('compiler-opts') ||
|
||||
JSON.stringify(getDefaultComplierOpts(), null, 4);
|
||||
document.getElementById('compilerOpts').textContent = optsString;
|
||||
monaco.languages.typescript.typescriptDefaults.setCompilerOptions(JSON.parse(optsString));
|
||||
|
||||
document.getElementById('updateCompilerSettingsBtn').onclick = () => {
|
||||
const newOpts = document.getElementById('compilerOpts').value;
|
||||
monaco.languages.typescript.typescriptDefaults.setCompilerOptions(JSON.parse(newOpts));
|
||||
localStorage.setItem('compiler-opts', newOpts);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
219
monaco-typescript/test/inlayHints.html
Normal file
219
monaco-typescript/test/inlayHints.html
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
data-name="vs/editor/editor.main"
|
||||
href="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.css"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Monaco Editor TypeScript test page</h2>
|
||||
<button id="resetBtn">Reset Sample</button>
|
||||
<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
|
||||
<h3>Inlay Hints options</h3>
|
||||
<textarea style="font-family: monospace" id="inlayHintsOpts" cols="60" rows="30"></textarea
|
||||
><br />
|
||||
<button id="updateInlayHintsOptionsBtn">Update Inaly Hints options</button>
|
||||
|
||||
<script>
|
||||
const paths = {
|
||||
'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
|
||||
'vs/language/typescript/fillers/monaco-editor-core':
|
||||
'../out/amd/fillers/monaco-editor-core-amd',
|
||||
'vs/language/typescript': '../out/amd',
|
||||
vs: '../node_modules/monaco-editor-core/dev/vs'
|
||||
};
|
||||
if (document.location.protocol === 'http:') {
|
||||
// Add support for running local http server
|
||||
let testIndex = document.location.pathname.indexOf('/test/');
|
||||
if (testIndex !== -1) {
|
||||
let prefix = document.location.pathname.substr(0, testIndex);
|
||||
paths['vs/language/typescript'] = prefix + '/out/amd';
|
||||
}
|
||||
}
|
||||
self.require = {
|
||||
paths: paths
|
||||
};
|
||||
</script>
|
||||
<script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>
|
||||
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.nls.js"></script>
|
||||
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
|
||||
|
||||
<script>
|
||||
function getDefaultCode() {
|
||||
return [
|
||||
'/* Game of Life',
|
||||
' * Implemented in TypeScript',
|
||||
' * To learn more about TypeScript, please visit http://www.typescriptlang.org/',
|
||||
' */',
|
||||
'',
|
||||
'module Conway {',
|
||||
'',
|
||||
' export class Cell {',
|
||||
' public row: number;',
|
||||
' public col: number;',
|
||||
' public live: boolean;',
|
||||
'',
|
||||
' constructor(row: number, col: number, live: boolean) {',
|
||||
' this.row = row;',
|
||||
' this.col = col;',
|
||||
' this.live = live',
|
||||
' }',
|
||||
' }',
|
||||
'',
|
||||
' export class GameOfLife {',
|
||||
' private gridSize: number;',
|
||||
' private canvasSize: number;',
|
||||
' private lineColor: string;',
|
||||
' private liveColor: string;',
|
||||
' private deadColor: string;',
|
||||
' private initialLifeProbability: number;',
|
||||
' private animationRate: number;',
|
||||
' private cellSize: number;',
|
||||
' private context: CanvasRenderingContext2D;',
|
||||
' private world;',
|
||||
'',
|
||||
'',
|
||||
' constructor() {',
|
||||
' this.gridSize = 50;',
|
||||
' this.canvasSize = 600;',
|
||||
" this.lineColor = '#cdcdcd';",
|
||||
" this.liveColor = '#666';",
|
||||
" this.deadColor = '#eee';",
|
||||
' this.initialLifeProbability = 0.5;',
|
||||
' this.animationRate = 60;',
|
||||
' this.cellSize = 0;',
|
||||
' this.world = this.createWorld();',
|
||||
' this.circleOfLife();',
|
||||
' }',
|
||||
'',
|
||||
' public createWorld() {',
|
||||
' return this.travelWorld( (cell : Cell) => {',
|
||||
' cell.live = Math.random() < this.initialLifeProbability;',
|
||||
' return cell;',
|
||||
' });',
|
||||
' }',
|
||||
'',
|
||||
' public circleOfLife() : void {',
|
||||
' this.world = this.travelWorld( (cell: Cell) => {',
|
||||
' cell = this.world[cell.row][cell.col];',
|
||||
' this.draw(cell);',
|
||||
' return this.resolveNextGeneration(cell);',
|
||||
' });',
|
||||
' setTimeout( () => {this.circleOfLife()}, this.animationRate);',
|
||||
' }',
|
||||
'',
|
||||
' public resolveNextGeneration(cell : Cell) {',
|
||||
' var count = this.countNeighbors(cell);',
|
||||
' var newCell = new Cell(cell.row, cell.col, cell.live);',
|
||||
' if(count < 2 || count > 3) newCell.live = false;',
|
||||
' else if(count == 3) newCell.live = true;',
|
||||
' return newCell;',
|
||||
' }',
|
||||
'',
|
||||
' public countNeighbors(cell : Cell) {',
|
||||
' var neighbors = 0;',
|
||||
' for(var row = -1; row <=1; row++) {',
|
||||
' for(var col = -1; col <= 1; col++) {',
|
||||
' if(row == 0 && col == 0) continue;',
|
||||
' if(this.isAlive(cell.row + row, cell.col + col)) {',
|
||||
' neighbors++;',
|
||||
' }',
|
||||
' }',
|
||||
' }',
|
||||
' return neighbors;',
|
||||
' }',
|
||||
'',
|
||||
' public isAlive(row : number, col : number) {',
|
||||
' if(row < 0 || col < 0 || row >= this.gridSize || col >= this.gridSize) return false;',
|
||||
' return this.world[row][col].live;',
|
||||
' }',
|
||||
'',
|
||||
' public travelWorld(callback) {',
|
||||
' var result = [];',
|
||||
' for(var row = 0; row < this.gridSize; row++) {',
|
||||
' var rowData = [];',
|
||||
' for(var col = 0; col < this.gridSize; col++) {',
|
||||
' rowData.push(callback(new Cell(row, col, false)));',
|
||||
' }',
|
||||
' result.push(rowData);',
|
||||
' }',
|
||||
' return result;',
|
||||
' }',
|
||||
'',
|
||||
' public draw(cell : Cell) {',
|
||||
' if(this.context == null) this.context = this.createDrawingContext();',
|
||||
' if(this.cellSize == 0) this.cellSize = this.canvasSize/this.gridSize;',
|
||||
'',
|
||||
' this.context.strokeStyle = this.lineColor;',
|
||||
' this.context.strokeRect(cell.row * this.cellSize, cell.col*this.cellSize, this.cellSize, this.cellSize);',
|
||||
' this.context.fillStyle = cell.live ? this.liveColor : this.deadColor;',
|
||||
' this.context.fillRect(cell.row * this.cellSize, cell.col*this.cellSize, this.cellSize, this.cellSize);',
|
||||
' }',
|
||||
'',
|
||||
' public createDrawingContext() {',
|
||||
" var canvas = <HTMLCanvasElement> document.getElementById('conway-canvas');",
|
||||
' if(canvas == null) {',
|
||||
" canvas = document.createElement('canvas');",
|
||||
" canvas.id = 'conway-canvas';",
|
||||
' canvas.width = this.canvasSize;',
|
||||
' canvas.height = this.canvasSize;',
|
||||
' document.body.appendChild(canvas);',
|
||||
' }',
|
||||
" return canvas.getContext('2d');",
|
||||
' }',
|
||||
' }',
|
||||
'}',
|
||||
'',
|
||||
'var game = new Conway.GameOfLife();'
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function getDefaultInlayHintsOpts() {
|
||||
return {
|
||||
includeInlayParameterNameHints: 'all',
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName: true,
|
||||
includeInlayFunctionParameterTypeHints: true,
|
||||
includeInlayVariableTypeHints: true,
|
||||
includeInlayPropertyDeclarationTypeHints: true,
|
||||
includeInlayFunctionLikeReturnTypeHints: true,
|
||||
includeInlayEnumMemberValueHints: true
|
||||
};
|
||||
}
|
||||
require([
|
||||
'vs/basic-languages/monaco.contribution',
|
||||
'vs/language/typescript/monaco.contribution'
|
||||
], () => {
|
||||
const editor = monaco.editor.create(document.getElementById('container'), {
|
||||
value: localStorage.getItem('code') || getDefaultCode(),
|
||||
language: 'typescript',
|
||||
lightbulb: { enabled: true }
|
||||
});
|
||||
|
||||
editor.onDidChangeModelContent(() => {
|
||||
const code = editor.getModel().getValue();
|
||||
localStorage.setItem('code', code);
|
||||
});
|
||||
|
||||
document.getElementById('resetBtn').onclick = () => {
|
||||
editor.setValue(getDefaultCode());
|
||||
};
|
||||
|
||||
const optsString =
|
||||
localStorage.getItem('inlay-hints-opts') ||
|
||||
JSON.stringify(getDefaultInlayHintsOpts(), null, 4);
|
||||
document.getElementById('inlayHintsOpts').textContent = optsString;
|
||||
monaco.languages.typescript.typescriptDefaults.setInlayHintsOptions(JSON.parse(optsString));
|
||||
|
||||
document.getElementById('updateInlayHintsOptionsBtn').onclick = () => {
|
||||
const newOpts = document.getElementById('inlayHintsOpts').value;
|
||||
monaco.languages.typescript.typescriptDefaults.setInlayHintsOptions(JSON.parse(newOpts));
|
||||
localStorage.setItem('inlay-hints-opts', newOpts);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue