Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monaco-yaml

Package Overview
Dependencies
Maintainers
5
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monaco-yaml - npm Package Compare versions

Comparing version 2.5.1 to 3.0.0

index.d.ts

23

lib/esm/fillers/vscode-nls.js

@@ -1,17 +0,8 @@

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
function format(message, args) {
let result;
if (args.length === 0) {
result = message;
}
else {
result = message.replace(/\{(\d+)\}/g, (match, rest) => {
const index = rest[0];
return typeof args[index] !== 'undefined' ? args[index] : match;
return args.length === 0
? message
: message.replace(/{(\d+)}/g, (match, rest) => {
const [index] = rest;
return typeof args[index] === 'undefined' ? match : args[index];
});
}
return result;
}

@@ -21,8 +12,8 @@ function localize(key, message, ...args) {

}
export function loadMessageBundle(file) {
export function loadMessageBundle() {
return localize;
}
export function config(opt) {
export function config() {
return loadMessageBundle;
}
//# sourceMappingURL=vscode-nls.js.map

@@ -1,9 +0,31 @@

/*---------------------------------------------------------------------------------------------
* 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 { editor, languages, MarkerSeverity, Range, } from 'monaco-editor/esm/vs/editor/editor.api';
import * as ls from './_deps/vscode-languageserver-types/main';
var Range = monaco.Range;
// --- diagnostics --- ---
function toSeverity(lsSeverity) {
switch (lsSeverity) {
case ls.DiagnosticSeverity.Error:
return MarkerSeverity.Error;
case ls.DiagnosticSeverity.Warning:
return MarkerSeverity.Warning;
case ls.DiagnosticSeverity.Information:
return MarkerSeverity.Info;
case ls.DiagnosticSeverity.Hint:
return MarkerSeverity.Hint;
default:
return MarkerSeverity.Info;
}
}
function toDiagnostics(resource, diag) {
const code = typeof diag.code === 'number' ? String(diag.code) : diag.code;
return {
severity: toSeverity(diag.severity),
startLineNumber: diag.range.start.line + 1,
startColumn: diag.range.start.character + 1,
endLineNumber: diag.range.end.line + 1,
endColumn: diag.range.end.character + 1,
message: diag.message,
code,
source: diag.source,
};
}
export class DiagnosticsAdapter {

@@ -21,3 +43,3 @@ constructor(_languageId, _worker, defaults) {

let handle;
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
this._listener[String(toString)] = model.onDidChangeContent(() => {
clearTimeout(handle);

@@ -29,4 +51,4 @@ handle = setTimeout(() => this._doValidate(model.uri, modeId), 500);

const onModelRemoved = (model) => {
monaco.editor.setModelMarkers(model, this._languageId, []);
const uriStr = model.uri.toString();
editor.setModelMarkers(model, this._languageId, []);
const uriStr = String(model.uri);
const listener = this._listener[uriStr];

@@ -38,14 +60,11 @@ if (listener) {

};
this._disposables.push(monaco.editor.onDidCreateModel(onModelAdd));
this._disposables.push(monaco.editor.onWillDisposeModel(model => {
this._disposables.push(editor.onDidCreateModel(onModelAdd), editor.onWillDisposeModel((model) => {
onModelRemoved(model);
this._resetSchema(model.uri);
}));
this._disposables.push(monaco.editor.onDidChangeModelLanguage(event => {
}), editor.onDidChangeModelLanguage((event) => {
onModelRemoved(event.model);
onModelAdd(event.model);
this._resetSchema(event.model.uri);
}));
this._disposables.push(defaults.onDidChange(_ => {
monaco.editor.getModels().forEach(model => {
}), defaults.onDidChange(() => {
editor.getModels().forEach((model) => {
if (model.getModeId() === this._languageId) {

@@ -56,20 +75,19 @@ onModelRemoved(model);

});
}));
this._disposables.push({
}), {
dispose: () => {
monaco.editor.getModels().forEach(onModelRemoved);
for (const key in this._listener) {
this._listener[key].dispose();
editor.getModels().forEach(onModelRemoved);
for (const disposable of Object.values(this._listener)) {
disposable.dispose();
}
},
});
monaco.editor.getModels().forEach(onModelAdd);
editor.getModels().forEach(onModelAdd);
}
dispose() {
this._disposables.forEach(d => d && d.dispose());
this._disposables.forEach((d) => d && d.dispose());
this._disposables = [];
}
_resetSchema(resource) {
this._worker().then(worker => {
worker.resetSchema(resource.toString());
this._worker().then((worker) => {
worker.resetSchema(String(resource));
});

@@ -79,12 +97,10 @@ }

this._worker(resource)
.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((worker) => worker.doValidation(String(resource)).then((diagnostics) => {
const markers = diagnostics.map((d) => toDiagnostics(resource, d));
const model = editor.getModel(resource);
if (model.getModeId() === languageId) {
editor.setModelMarkers(model, languageId, markers);
}
}))
.then(undefined, (err) => {
console.error(err);

@@ -94,33 +110,6 @@ });

}
function toSeverity(lsSeverity) {
switch (lsSeverity) {
case ls.DiagnosticSeverity.Error:
return monaco.MarkerSeverity.Error;
case ls.DiagnosticSeverity.Warning:
return monaco.MarkerSeverity.Warning;
case ls.DiagnosticSeverity.Information:
return monaco.MarkerSeverity.Info;
case ls.DiagnosticSeverity.Hint:
return monaco.MarkerSeverity.Hint;
default:
return monaco.MarkerSeverity.Info;
}
}
function toDiagnostics(resource, diag) {
const code = typeof diag.code === 'number' ? String(diag.code) : diag.code;
return {
severity: toSeverity(diag.severity),
startLineNumber: diag.range.start.line + 1,
startColumn: diag.range.start.character + 1,
endLineNumber: diag.range.end.line + 1,
endColumn: diag.range.end.character + 1,
message: diag.message,
code,
source: diag.source,
};
}
// --- completion ------
function fromPosition(position) {
if (!position) {
return void 0;
return;
}

@@ -131,3 +120,3 @@ return { character: position.column - 1, line: position.lineNumber - 1 };

if (!range) {
return void 0;
return;
}

@@ -144,3 +133,3 @@ return {

if (!range) {
return void 0;
return;
}

@@ -150,3 +139,3 @@ return new Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);

function toCompletionItemKind(kind) {
const mItemKind = monaco.languages.CompletionItemKind;
const mItemKind = languages.CompletionItemKind;
switch (kind) {

@@ -189,50 +178,9 @@ case ls.CompletionItemKind.Text:

return mItemKind.Reference;
default:
return mItemKind.Property;
}
return mItemKind.Property;
}
function fromCompletionItemKind(kind) {
const mItemKind = monaco.languages.CompletionItemKind;
switch (kind) {
case mItemKind.Text:
return ls.CompletionItemKind.Text;
case mItemKind.Method:
return ls.CompletionItemKind.Method;
case mItemKind.Function:
return ls.CompletionItemKind.Function;
case mItemKind.Constructor:
return ls.CompletionItemKind.Constructor;
case mItemKind.Field:
return ls.CompletionItemKind.Field;
case mItemKind.Variable:
return ls.CompletionItemKind.Variable;
case mItemKind.Class:
return ls.CompletionItemKind.Class;
case mItemKind.Interface:
return ls.CompletionItemKind.Interface;
case mItemKind.Module:
return ls.CompletionItemKind.Module;
case mItemKind.Property:
return ls.CompletionItemKind.Property;
case mItemKind.Unit:
return ls.CompletionItemKind.Unit;
case mItemKind.Value:
return ls.CompletionItemKind.Value;
case mItemKind.Enum:
return ls.CompletionItemKind.Enum;
case mItemKind.Keyword:
return ls.CompletionItemKind.Keyword;
case mItemKind.Snippet:
return ls.CompletionItemKind.Snippet;
case mItemKind.Color:
return ls.CompletionItemKind.Color;
case mItemKind.File:
return ls.CompletionItemKind.File;
case mItemKind.Reference:
return ls.CompletionItemKind.Reference;
}
return ls.CompletionItemKind.Property;
}
function toTextEdit(textEdit) {
if (!textEdit) {
return void 0;
return;
}

@@ -247,13 +195,9 @@ return {

this._worker = _worker;
this.triggetCharacters = [' ', ':'];
}
get triggerCharacters() {
return [' ', ':'];
}
provideCompletionItems(model, position, context, token) {
provideCompletionItems(model, position) {
const resource = model.uri;
return this._worker(resource)
.then(worker => {
return worker.doComplete(resource.toString(), fromPosition(position));
})
.then(info => {
.then((worker) => worker.doComplete(String(resource), fromPosition(position)))
.then((info) => {
if (!info) {

@@ -264,3 +208,3 @@ return;

const wordRange = new Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
const items = info.items.map(entry => {
const items = info.items.map((entry) => {
const item = {

@@ -277,3 +221,3 @@ label: entry.label,

if (entry.textEdit) {
item.range = toRange(entry.textEdit.range);
item.range = toRange('range' in entry.textEdit ? entry.textEdit.range : entry.textEdit.replace);
item.insertText = entry.textEdit.newText;

@@ -285,4 +229,3 @@ }

if (entry.insertTextFormat === ls.InsertTextFormat.Snippet) {
item.insertTextRules =
monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet;
}

@@ -299,5 +242,3 @@ return item;

function isMarkupContent(thing) {
return (thing &&
typeof thing === 'object' &&
typeof thing.kind === 'string');
return thing && typeof thing === 'object' && typeof thing.kind === 'string';
}

@@ -313,3 +254,3 @@ function toMarkdownString(entry) {

return {
value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'),
value: entry.value.replace(/[!#()*+.[\\\]_`{}-]/g, '\\$&'),
};

@@ -321,7 +262,7 @@ }

}
return { value: '```' + entry.language + '\n' + entry.value + '\n```\n' };
return { value: `\`\`\`${entry.language}\n${entry.value}\n\`\`\`\n` };
}
function toMarkedStringArray(contents) {
if (!contents) {
return void 0;
return;
}

@@ -338,9 +279,7 @@ if (Array.isArray(contents)) {

}
provideHover(model, position, token) {
provideHover(model, position) {
const resource = model.uri;
return this._worker(resource)
.then(worker => {
return worker.doHover(resource.toString(), fromPosition(position));
})
.then(info => {
.then((worker) => worker.doHover(String(resource), fromPosition(position)))
.then((info) => {
if (!info) {

@@ -358,3 +297,3 @@ return;

function toSymbolKind(kind) {
const mKind = monaco.languages.SymbolKind;
const mKind = languages.SymbolKind;
switch (kind) {

@@ -397,5 +336,17 @@ case ls.SymbolKind.File:

return mKind.Array;
default:
return mKind.Function;
}
return mKind.Function;
}
function toDocumentSymbol(item) {
return {
detail: '',
range: toRange(item.range),
name: item.name,
kind: toSymbolKind(item.kind),
selectionRange: toRange(item.selectionRange),
children: item.children.map((child) => toDocumentSymbol(child)),
tags: [],
};
}
export class DocumentSymbolAdapter {

@@ -405,25 +356,14 @@ constructor(_worker) {

}
provideDocumentSymbols(model, token) {
provideDocumentSymbols(model) {
const resource = model.uri;
return this._worker(resource)
.then(worker => worker.findDocumentSymbols(resource.toString()))
.then(items => {
.then((worker) => worker.findDocumentSymbols(String(resource)))
.then((items) => {
if (!items) {
return;
}
return items.map(item => toDocumentSymbol(item));
return items.map((item) => toDocumentSymbol(item));
});
}
}
function toDocumentSymbol(item) {
return {
detail: '',
range: toRange(item.range),
name: item.name,
kind: toSymbolKind(item.kind),
selectionRange: toRange(item.selectionRange),
children: item.children.map(child => toDocumentSymbol(child)),
tags: [],
};
}
function fromFormattingOptions(options) {

@@ -436,14 +376,10 @@ return Object.assign({ tabSize: options.tabSize, insertSpaces: options.insertSpaces }, options);

}
provideDocumentFormattingEdits(model, options, token) {
provideDocumentFormattingEdits(model, options) {
const resource = model.uri;
return this._worker(resource).then(worker => {
return worker
.format(resource.toString(), null, fromFormattingOptions(options))
.then(edits => {
if (!edits || edits.length === 0) {
return;
}
return edits.map(toTextEdit);
});
});
return this._worker(resource).then((worker) => worker.format(String(resource), null, fromFormattingOptions(options)).then((edits) => {
if (!edits || edits.length === 0) {
return;
}
return edits.map(toTextEdit);
}));
}

@@ -455,16 +391,14 @@ }

}
provideDocumentRangeFormattingEdits(model, range, options, token) {
provideDocumentRangeFormattingEdits(model, range, options) {
const resource = model.uri;
return this._worker(resource).then(worker => {
return worker
.format(resource.toString(), fromRange(range), fromFormattingOptions(options))
.then(edits => {
if (!edits || edits.length === 0) {
return;
}
return edits.map(toTextEdit);
});
});
return this._worker(resource).then((worker) => worker
.format(String(resource), fromRange(range), fromFormattingOptions(options))
.then((edits) => {
if (!edits || edits.length === 0) {
return;
}
return edits.map(toTextEdit);
}));
}
}
//# sourceMappingURL=languageFeatures.js.map

@@ -1,8 +0,3 @@

/*---------------------------------------------------------------------------------------------
* 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 { Emitter, languages } from 'monaco-editor/esm/vs/editor/editor.api';
import { setupMode } from './yamlMode';
var Emitter = monaco.Emitter;
// --- YAML configuration and defaults ---------

@@ -41,5 +36,5 @@ export class LanguageServiceDefaultsImpl {

}
monaco.languages.yaml = createAPI();
languages.yaml = createAPI();
// --- Registration to monaco editor ---
monaco.languages.register({
languages.register({
id: 'yaml',

@@ -50,5 +45,13 @@ extensions: ['.yaml', '.yml'],

});
monaco.languages.onLanguage('yaml', () => {
languages.onLanguage('yaml', () => {
setupMode(yamlDefaults);
});
/**
* Configure `monaco-yaml` diagnostics options.
*
* @param options - The options to set.
*/
export function setDiagnosticsOptions(options = {}) {
languages.yaml.yamlDefaults.setDiagnosticsOptions(options);
}
//# sourceMappingURL=monaco.contribution.js.map

@@ -1,7 +0,4 @@

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
import { editor } from 'monaco-editor/esm/vs/editor/editor.api';
// 2min
const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000;
export class WorkerManager {

@@ -23,9 +20,7 @@ constructor(defaults) {

return this._getClient()
.then(client => {
.then((client) => {
_client = client;
})
.then(_ => {
return this._worker.withSyncedResources(resources);
})
.then(_ => _client);
.then(() => this._worker.withSyncedResources(resources))
.then(() => _client);
}

@@ -51,12 +46,11 @@ _stopWorker() {

if (!this._client) {
this._worker = monaco.editor.createWebWorker({
// module that exports the create() method and returns a `YAMLWorker` instance
this._worker = editor.createWebWorker({
// Module that exports the create() method and returns a `YAMLWorker` instance
moduleId: 'vs/language/yaml/yamlWorker',
label: this._defaults.languageId,
// passed in to the create() method
// Passed in to the create() method
createData: {
languageSettings: this._defaults.diagnosticsOptions,
languageId: this._defaults.languageId,
enableSchemaRequest: this._defaults.diagnosticsOptions
.enableSchemaRequest,
enableSchemaRequest: this._defaults.diagnosticsOptions.enableSchemaRequest,
prefix: this._defaults.diagnosticsOptions.prefix,

@@ -63,0 +57,0 @@ isKubernetes: this._defaults.diagnosticsOptions.isKubernetes,

@@ -1,14 +0,7 @@

/*---------------------------------------------------------------------------------------------
* 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 worker from 'monaco-editor/esm/vs/editor/editor.worker';
import { YAMLWorker } from './yamlWorker';
self.onmessage = () => {
// ignore the first message
worker.initialize((ctx, createData) => {
return new YAMLWorker(ctx, createData);
});
// Ignore the first message
worker.initialize((ctx, createData) => new YAMLWorker(ctx, createData));
};
//# sourceMappingURL=yaml.worker.js.map

@@ -1,26 +0,4 @@

/*---------------------------------------------------------------------------------------------
* 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 { languages } from 'monaco-editor/esm/vs/editor/editor.api';
import * as languageFeatures from './languageFeatures';
import { WorkerManager } from './workerManager';
export function setupMode(defaults) {
const disposables = [];
const client = new WorkerManager(defaults);
disposables.push(client);
const worker = (...uris) => {
return client.getLanguageServiceWorker(...uris);
};
const languageId = defaults.languageId;
disposables.push(monaco.languages.registerCompletionItemProvider(languageId, new languageFeatures.CompletionAdapter(worker)));
disposables.push(monaco.languages.registerHoverProvider(languageId, new languageFeatures.HoverAdapter(worker)));
disposables.push(monaco.languages.registerDocumentSymbolProvider(languageId, new languageFeatures.DocumentSymbolAdapter(worker)));
disposables.push(monaco.languages.registerDocumentFormattingEditProvider(languageId, new languageFeatures.DocumentFormattingEditProvider(worker)));
disposables.push(monaco.languages.registerDocumentRangeFormattingEditProvider(languageId, new languageFeatures.DocumentRangeFormattingEditProvider(worker)));
disposables.push(new languageFeatures.DiagnosticsAdapter(languageId, worker, defaults));
disposables.push(monaco.languages.setLanguageConfiguration(languageId, richEditConfiguration));
// Color adapter should be necessary most of the time:
// disposables.push(monaco.languages.registerColorProvider(languageId, new languageFeatures.DocumentColorAdapter(worker)));
}
const richEditConfiguration = {

@@ -52,6 +30,21 @@ comments: {

beforeText: /:\s*$/,
action: { indentAction: monaco.languages.IndentAction.Indent },
action: { indentAction: languages.IndentAction.Indent },
},
],
};
export function setupMode(defaults) {
const disposables = [];
const client = new WorkerManager(defaults);
disposables.push(client);
const worker = (...uris) => client.getLanguageServiceWorker(...uris);
const { languageId } = defaults;
disposables.push(languages.registerCompletionItemProvider(languageId, new languageFeatures.CompletionAdapter(worker)), languages.registerHoverProvider(languageId, new languageFeatures.HoverAdapter(worker)), languages.registerDocumentSymbolProvider(languageId, new languageFeatures.DocumentSymbolAdapter(worker)), languages.registerDocumentFormattingEditProvider(languageId, new languageFeatures.DocumentFormattingEditProvider(worker)), languages.registerDocumentRangeFormattingEditProvider(languageId, new languageFeatures.DocumentRangeFormattingEditProvider(worker)), new languageFeatures.DiagnosticsAdapter(languageId, worker, defaults), languages.setLanguageConfiguration(languageId, richEditConfiguration));
// Color adapter should be necessary most of the time:
// disposables.push(
// languages.registerColorProvider(
// languageId,
// new languageFeatures.DocumentColorAdapter(worker)
// )
// );
}
//# sourceMappingURL=yamlMode.js.map

@@ -1,8 +0,1 @@

/*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Copyright (c) Adam Voss. All rights reserved.
* 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 ls from './_deps/vscode-languageserver-types/main';

@@ -12,5 +5,3 @@ import * as yamlService from './_deps/yaml-language-server/lib/esm/languageservice/yamlLanguageService';

if (typeof fetch !== 'undefined') {
defaultSchemaRequestService = function (url) {
return fetch(url).then(response => response.text());
};
defaultSchemaRequestService = (url) => fetch(url).then((response) => response.text());
}

@@ -62,3 +53,3 @@ export class YAMLWorker {

for (const model of models) {
if (model.uri.toString() === uri) {
if (String(model.uri) === uri) {
return ls.TextDocument.create(uri, this._languageId, model.version, model.getValue());

@@ -65,0 +56,0 @@ }

@@ -5,18 +5,15 @@ The MIT License (MIT)

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
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 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.
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.
{
"name": "monaco-yaml",
"version": "2.5.1",
"version": "3.0.0",
"description": "YAML plugin for the Monaco Editor",
"scripts": {
"watch": "tsc -p ./src --watch",
"compile": "rimraf ./out && yarn compile:umd && yarn compile:esm",
"compile:umd": "tsc -p ./tsconfig.json",
"compile:esm": "tsc -p ./tsconfig.esm.json",
"bundle": "rimraf ./lib && yarn bundle:umd && yarn bundle:esm && mcopy ./src/monaco.d.ts ./lib/monaco.d.ts",
"bundle:umd": "node ./scripts/bundle-umd",
"bundle:esm": "node ./scripts/bundle-esm",
"build": "yarn compile && yarn bundle",
"prepare": "yarn build",
"lint": "prettier \"{src,test}/**/*.{json,scss,html,ts}\" --write",
"test": "jest --verbose"
"compile": "rimraf ./out && tsc",
"bundle": "rimraf ./lib && node ./scripts/bundle-esm",
"prepack": "npm run compile && npm run bundle",
"prepare": "husky install",
"lint": "eslint . && prettier --check ."
},
"main": "./lib/esm/monaco.contribution.js",
"module": "./lib/esm/monaco.contribution.js",
"typings": "./lib/monaco.d.ts",
"directories": {
"lib": "./lib"
},
"typings": "./index.d.ts",
"files": [
"lib",
"index.d.ts"
],
"workspaces": [
"examples/*"
],
"author": "Kevin Decker <kpdecker@gmail.com> (http://incaseofstairs.com)",

@@ -38,55 +37,31 @@ "maintainers": [

"dependencies": {
"yaml-language-server": "^0.11.1"
"@types/json-schema": "^7.0.8",
"js-yaml": "^3.14.1",
"yaml-ast-parser-custom-tags": "^0.0.43"
},
"peerDependencies": {
"monaco-editor": ">=0.22"
},
"devDependencies": {
"@types/jest": "^23.3.10",
"@types/node": "^12.12.6",
"husky": "^1.2.1",
"jest": "^23.6.0",
"lint-staged": "^10.1.2",
"monaco-editor": "^0.21.2",
"monaco-editor-core": "^0.21.2",
"monaco-languages": "^2.1.1",
"@typescript-eslint/eslint-plugin": "^4.28.3",
"@typescript-eslint/parser": "^4.28.3",
"eslint": "^7.30.0",
"eslint-config-remcohaszing": "^3.4.0",
"husky": "^7.0.1",
"lint-staged": "^10.5.4",
"monaco-editor": "^0.26.1",
"monaco-plugin-helpers": "^1.0.3",
"prettier": "^1.19.1",
"requirejs": "^2.3.6",
"rimraf": "^2.6.2",
"ts-jest": "^23.10.5",
"typescript": "^3.8.3",
"typescript-tslint-plugin": "^0.5.5",
"eslint": "^6.8.0",
"uglify-es": "^3.3.9"
"prettier": "2.0.5",
"rimraf": "^3.0.2",
"typescript": "^4.3.5",
"yaml-language-server": "^0.11.1"
},
"prettier": {
"singleQuote": true,
"trailingComma": "es5",
"semi": true
},
"lint-staged": {
"src/*.{json,scss,html,ts,js,jsx}|scripts/*.js": [
"*.{css,json,md,html,yaml}": [
"prettier --write"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"jest": {
"globals": {
"ts-jest": {
"tsConfig": "./test/tsconfig.json"
}
},
"moduleFileExtensions": [
"js",
"ts"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
"testMatch": [
"**/test/*.test.+(ts|js)"
"*.{js,ts}": [
"eslint"
]
}
}
# Monaco YAML
YAML language plugin for the Monaco Editor. It provides the following features when editing YAML files:
* Code completion, based on JSON schemas or by looking at similar objects in the same file
* Hovers, based on JSON schemas
* Validation: Syntax errors and schema validation
* Formatting
* Document Symbols
* Syntax highlighting
* Automatically load remote schema files (by enabling DiagnosticsOptions.enableSchemaRequest)
YAML language plugin for the Monaco Editor. It provides the following features when editing YAML
files:
Schemas can also be provided by configuration. See [here](https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts)
for the API that the JSON plugin offers to configure the JSON language support.
- Code completion, based on JSON schemas or by looking at similar objects in the same file
- Hovers, based on JSON schemas
- Validation: Syntax errors and schema validation
- Formatting
- Document Symbols
- Syntax highlighting
- Automatically load remote schema files (by enabling DiagnosticsOptions.enableSchemaRequest)
## Installing
Schemas can also be provided by configuration. See
[here](https://github.com/Microsoft/monaco-json/blob/master/index.d.ts) for the API that the JSON
plugin offers to configure the JSON language support.
`yarn add monaco-yaml`
Both vs loader and ESM are supported.
See `examples` directory for esm and umd examples.
## Installation
```sh
npm install monaco-yaml
```
## Usage
Import `monaco-yaml` and configure it before an editor instance is created.
```ts
import { editor, Uri } from 'monaco-editor';
import { setDiagnosticsOptions } from 'monaco-yaml';
// The uri is used for the schema file match.
const modelUri = Uri.parse('a://b/foo.yaml');
setDiagnosticsOptions({
enableSchemaRequest: true,
hover: true,
completion: true,
validate: true,
format: true,
schemas: [
{
// Id of the first schema
uri: 'http://myserver/foo-schema.json',
// Associate with our model
fileMatch: [String(modelUri)],
schema: {
type: 'object',
properties: {
p1: {
enum: ['v1', 'v2'],
},
p2: {
// Reference the second schema
$ref: 'http://myserver/bar-schema.json',
},
},
},
},
{
// Id of the first schema
uri: 'http://myserver/bar-schema.json',
schema: {
type: 'object',
properties: {
q1: {
enum: ['x1', 'x2'],
},
},
},
},
],
});
editor.create(document.createElement('editor'), {
// Monaco-yaml features should just work if the editor language is set to 'yaml'.
language: 'yaml',
model: editor.createModel('p1: \n', 'yaml', modelUri),
});
```
Also make sure to register the service worker. See the
[examples](https://github.com/pengx17/monaco-yaml/tree/master/examples) directory for full fledged
examples.
## Development
* `git clone https://github.com/pengx17/monaco-yaml`
* `cd monaco-yaml`
* `yarn`
- `git clone https://github.com/pengx17/monaco-yaml`
- `cd monaco-yaml`
- `npm ci`
A running example:
![demo-image](test-demo.png)
A running example: ![demo-image](test-demo.png)
## Credits
- https://github.com/redhat-developer/yaml-language-server
## License
[MIT](https://github.com/pengx17/monaco-yaml/blob/master/LICENSE.md)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc