mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-06-19 14:31:13 +00:00
Merge pull request #47 from remcohaszing/fix-dependencies
Fix dependencies
This commit is contained in:
commit
4e00c72636
8 changed files with 63 additions and 44 deletions
|
|
@ -15,7 +15,7 @@
|
|||
<code id="path"></code>
|
||||
<div
|
||||
id="container"
|
||||
style="width:800px;height:600px;border:1px solid grey"
|
||||
style="width: 800px; height: 600px; border: 1px solid grey;"
|
||||
></div>
|
||||
|
||||
<style>
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
'vs/language/yaml/monaco.contribution',
|
||||
'prettier/standalone',
|
||||
'prettier/parser-yaml',
|
||||
], function() {
|
||||
], function () {
|
||||
const yaml = `p1: `;
|
||||
const modelUri = monaco.Uri.parse('a://b/foo.json');
|
||||
const editor = monaco.editor.create(
|
||||
|
|
@ -102,7 +102,9 @@
|
|||
],
|
||||
});
|
||||
|
||||
require(['vs/editor/contrib/quickOpen/quickOpen'], async quickOpen => {
|
||||
require(['vs/editor/contrib/quickOpen/quickOpen'], async (
|
||||
quickOpen
|
||||
) => {
|
||||
const NEVER_CANCEL_TOKEN = {
|
||||
isCancellationRequested: false,
|
||||
onCancellationRequested: () => Event.NONE,
|
||||
|
|
@ -122,7 +124,7 @@
|
|||
if (symbol && symbol.children && symbol.children.length) {
|
||||
target =
|
||||
_recur(
|
||||
symbol.children.find(child =>
|
||||
symbol.children.find((child) =>
|
||||
child.range.containsPosition(position)
|
||||
)
|
||||
) || symbol;
|
||||
|
|
|
|||
12
package.json
12
package.json
|
|
@ -12,7 +12,7 @@
|
|||
"bundle:esm": "node ./scripts/bundle-esm",
|
||||
"build": "yarn compile && yarn bundle",
|
||||
"prepare": "husky install && yarn build",
|
||||
"lint": "prettier \"**/*.{css,js,json,jsx,html,md,ts}\" --check"
|
||||
"lint": "prettier --check ."
|
||||
},
|
||||
"main": "./lib/esm/monaco.contribution.js",
|
||||
"module": "./lib/esm/monaco.contribution.js",
|
||||
|
|
@ -34,7 +34,8 @@
|
|||
"url": "https://github.com/pengx17/monaco-yaml/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"yaml-language-server": "^0.11.1"
|
||||
"js-yaml": "^3.14.1",
|
||||
"yaml-ast-parser-custom-tags": "^0.0.43"
|
||||
},
|
||||
"devDependencies": {
|
||||
"husky": "^5.2.0",
|
||||
|
|
@ -43,11 +44,12 @@
|
|||
"monaco-editor-core": "^0.21.2",
|
||||
"monaco-languages": "^2.1.1",
|
||||
"monaco-plugin-helpers": "^1.0.3",
|
||||
"prettier": "^1.19.1",
|
||||
"prettier": "2.0.5",
|
||||
"requirejs": "^2.3.6",
|
||||
"rimraf": "^2.6.2",
|
||||
"typescript": "^4.2.3",
|
||||
"uglify-es": "^3.3.9"
|
||||
"uglify-es": "^3.3.9",
|
||||
"yaml-language-server": "^0.11.1"
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true,
|
||||
|
|
@ -55,7 +57,7 @@
|
|||
"semi": true
|
||||
},
|
||||
"lint-staged": {
|
||||
"src/*.{json,scss,html,ts,js,jsx}|scripts/*.js": [
|
||||
"*.{css,json,md,html,ts,js,jsx,yaml}": [
|
||||
"prettier --write"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ function bundleOne(moduleId, exclude) {
|
|||
},
|
||||
],
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
const devFilePath = path.join(REPO_ROOT, 'lib/dev/' + moduleId + '.js');
|
||||
const minFilePath = path.join(REPO_ROOT, 'lib/min/' + moduleId + '.js');
|
||||
const fileContents = fs.readFileSync(devFilePath).toString();
|
||||
|
|
|
|||
12
src/fillers/monaco-editor-amd.ts
Normal file
12
src/fillers/monaco-editor-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 var define;
|
||||
|
||||
define([], function () {
|
||||
return (<any>self).monaco;
|
||||
});
|
||||
|
|
@ -58,13 +58,13 @@ export class DiagnosticsAdapter {
|
|||
|
||||
this._disposables.push(monaco.editor.onDidCreateModel(onModelAdd));
|
||||
this._disposables.push(
|
||||
monaco.editor.onWillDisposeModel(model => {
|
||||
monaco.editor.onWillDisposeModel((model) => {
|
||||
onModelRemoved(model);
|
||||
this._resetSchema(model.uri);
|
||||
})
|
||||
);
|
||||
this._disposables.push(
|
||||
monaco.editor.onDidChangeModelLanguage(event => {
|
||||
monaco.editor.onDidChangeModelLanguage((event) => {
|
||||
onModelRemoved(event.model);
|
||||
onModelAdd(event.model);
|
||||
this._resetSchema(event.model.uri);
|
||||
|
|
@ -72,8 +72,8 @@ export class DiagnosticsAdapter {
|
|||
);
|
||||
|
||||
this._disposables.push(
|
||||
defaults.onDidChange(_ => {
|
||||
monaco.editor.getModels().forEach(model => {
|
||||
defaults.onDidChange((_) => {
|
||||
monaco.editor.getModels().forEach((model) => {
|
||||
if (model.getModeId() === this._languageId) {
|
||||
onModelRemoved(model);
|
||||
onModelAdd(model);
|
||||
|
|
@ -95,28 +95,28 @@ export class DiagnosticsAdapter {
|
|||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._disposables.forEach(d => d && d.dispose());
|
||||
this._disposables.forEach((d) => d && d.dispose());
|
||||
this._disposables = [];
|
||||
}
|
||||
|
||||
private _resetSchema(resource: Uri): void {
|
||||
this._worker().then(worker => {
|
||||
this._worker().then((worker) => {
|
||||
worker.resetSchema(resource.toString());
|
||||
});
|
||||
}
|
||||
|
||||
private _doValidate(resource: Uri, languageId: string): void {
|
||||
this._worker(resource)
|
||||
.then(worker => {
|
||||
return worker.doValidation(resource.toString()).then(diagnostics => {
|
||||
const markers = diagnostics.map(d => toDiagnostics(resource, d));
|
||||
.then((worker) => {
|
||||
return worker.doValidation(resource.toString()).then((diagnostics) => {
|
||||
const markers = diagnostics.map((d) => toDiagnostics(resource, d));
|
||||
const model = monaco.editor.getModel(resource);
|
||||
if (model.getModeId() === languageId) {
|
||||
monaco.editor.setModelMarkers(model, languageId, markers);
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(undefined, err => {
|
||||
.then(undefined, (err) => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
|
@ -308,10 +308,10 @@ export class CompletionAdapter
|
|||
const resource = model.uri;
|
||||
|
||||
return this._worker(resource)
|
||||
.then(worker => {
|
||||
.then((worker) => {
|
||||
return worker.doComplete(resource.toString(), fromPosition(position));
|
||||
})
|
||||
.then(info => {
|
||||
.then((info) => {
|
||||
if (!info) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -325,7 +325,7 @@ export class CompletionAdapter
|
|||
);
|
||||
|
||||
const items: monaco.languages.CompletionItem[] = info.items.map(
|
||||
entry => {
|
||||
(entry) => {
|
||||
const item: monaco.languages.CompletionItem = {
|
||||
label: entry.label,
|
||||
insertText: entry.insertText || entry.label,
|
||||
|
|
@ -416,10 +416,10 @@ export class HoverAdapter implements monaco.languages.HoverProvider {
|
|||
const resource = model.uri;
|
||||
|
||||
return this._worker(resource)
|
||||
.then(worker => {
|
||||
.then((worker) => {
|
||||
return worker.doHover(resource.toString(), fromPosition(position));
|
||||
})
|
||||
.then(info => {
|
||||
.then((info) => {
|
||||
if (!info) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -488,12 +488,12 @@ export class DocumentSymbolAdapter
|
|||
const resource = model.uri;
|
||||
|
||||
return this._worker(resource)
|
||||
.then(worker => worker.findDocumentSymbols(resource.toString()))
|
||||
.then(items => {
|
||||
.then((worker) => worker.findDocumentSymbols(resource.toString()))
|
||||
.then((items) => {
|
||||
if (!items) {
|
||||
return;
|
||||
}
|
||||
return items.map(item => toDocumentSymbol(item));
|
||||
return items.map((item) => toDocumentSymbol(item));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -507,7 +507,7 @@ function toDocumentSymbol(
|
|||
name: item.name,
|
||||
kind: toSymbolKind(item.kind),
|
||||
selectionRange: toRange(item.selectionRange),
|
||||
children: item.children.map(child => toDocumentSymbol(child)),
|
||||
children: item.children.map((child) => toDocumentSymbol(child)),
|
||||
tags: [],
|
||||
};
|
||||
}
|
||||
|
|
@ -533,10 +533,10 @@ export class DocumentFormattingEditProvider
|
|||
): Thenable<monaco.editor.ISingleEditOperation[]> {
|
||||
const resource = model.uri;
|
||||
|
||||
return this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then((worker) => {
|
||||
return worker
|
||||
.format(resource.toString(), null, fromFormattingOptions(options))
|
||||
.then(edits => {
|
||||
.then((edits) => {
|
||||
if (!edits || edits.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -558,14 +558,14 @@ export class DocumentRangeFormattingEditProvider
|
|||
): Thenable<monaco.editor.ISingleEditOperation[]> {
|
||||
const resource = model.uri;
|
||||
|
||||
return this._worker(resource).then(worker => {
|
||||
return this._worker(resource).then((worker) => {
|
||||
return worker
|
||||
.format(
|
||||
resource.toString(),
|
||||
fromRange(range),
|
||||
fromFormattingOptions(options)
|
||||
)
|
||||
.then(edits => {
|
||||
.then((edits) => {
|
||||
if (!edits || edits.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ export class WorkerManager {
|
|||
public getLanguageServiceWorker(...resources: Uri[]): Promise<YAMLWorker> {
|
||||
let _client: YAMLWorker;
|
||||
return this._getClient()
|
||||
.then(client => {
|
||||
.then((client) => {
|
||||
_client = client;
|
||||
})
|
||||
.then(_ => {
|
||||
.then((_) => {
|
||||
return this._worker.withSyncedResources(resources);
|
||||
})
|
||||
.then(_ => _client);
|
||||
.then((_) => _client);
|
||||
}
|
||||
|
||||
private _stopWorker(): void {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import * as yamlService from 'yaml-language-server';
|
|||
|
||||
let defaultSchemaRequestService;
|
||||
if (typeof fetch !== 'undefined') {
|
||||
defaultSchemaRequestService = function(url) {
|
||||
return fetch(url).then(response => response.text());
|
||||
defaultSchemaRequestService = function (url) {
|
||||
return fetch(url).then((response) => response.text());
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
15
yarn.lock
15
yarn.lock
|
|
@ -455,6 +455,14 @@ js-yaml@^3.13.1:
|
|||
argparse "^1.0.7"
|
||||
esprima "^4.0.0"
|
||||
|
||||
js-yaml@^3.14.1:
|
||||
version "3.14.1"
|
||||
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537"
|
||||
integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
|
||||
dependencies:
|
||||
argparse "^1.0.7"
|
||||
esprima "^4.0.0"
|
||||
|
||||
json-parse-even-better-errors@^2.3.0:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d"
|
||||
|
|
@ -662,11 +670,6 @@ prettier@2.0.5:
|
|||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
|
||||
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==
|
||||
|
||||
prettier@^1.19.1:
|
||||
version "1.19.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
|
||||
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
|
||||
|
||||
pump@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
|
||||
|
|
@ -957,7 +960,7 @@ wrappy@1:
|
|||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
||||
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
|
||||
|
||||
yaml-ast-parser-custom-tags@0.0.43:
|
||||
yaml-ast-parser-custom-tags@0.0.43, yaml-ast-parser-custom-tags@^0.0.43:
|
||||
version "0.0.43"
|
||||
resolved "https://registry.yarnpkg.com/yaml-ast-parser-custom-tags/-/yaml-ast-parser-custom-tags-0.0.43.tgz#46968145ce4e24cb03c3312057f0f141b93a7d02"
|
||||
integrity sha512-R5063FF/JSAN6qXCmylwjt9PcDH6M0ExEme/nJBzLspc6FJDmHHIqM7xh2WfEmsTJqClF79A9VkXjkAqmZw9SQ==
|
||||
|
|
|
|||
Loading…
Reference in a new issue