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

@microsoft/compose-language-service

Package Overview
Dependencies
Maintainers
10
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/compose-language-service - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

lib/client/AlternateYamlLanguageServiceClientCapabilities.d.ts

7

CHANGELOG.md

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

## 0.2.0 - 10 May 2023
### Breaking Changes
* The `ComposeLanguageClientCapabilities` type has been moved from `lib/client/DocumentSettings` to `lib/client/ClientCapabilities`
### Added
* The client can now specify whether an alternative YAML language service is present (e.g., from the YAML extension), selectively disabling features of this language service. [#122](https://github.com/microsoft/compose-language-service/issues/122)
## 0.1.3 - 13 February 2023

@@ -2,0 +9,0 @@ ### Added

18

lib/client/DocumentSettings.d.ts

@@ -5,15 +5,11 @@ /*!--------------------------------------------------------------------------------------------

*--------------------------------------------------------------------------------------------*/
import { ClientCapabilities, NotificationType, RequestType } from 'vscode-languageserver-protocol';
import { NotificationType, RequestType } from 'vscode-languageserver-protocol';
import { TextDocumentParams } from '../service/ExtendedParams';
export declare type ComposeLanguageClientCapabilities = ClientCapabilities & {
experimental?: {
documentSettings?: {
request: boolean;
notify: boolean;
};
};
export type DocumentSettingsClientCapabilities = {
readonly request: boolean;
readonly notify: boolean;
};
export declare const LF = 1;
export declare const CRLF = 2;
declare type EndOfLine = typeof LF | typeof CRLF;
type EndOfLine = typeof LF | typeof CRLF;
export interface DocumentSettings {

@@ -23,3 +19,3 @@ tabSize: number;

}
export declare type DocumentSettingsParams = TextDocumentParams;
export type DocumentSettingsParams = TextDocumentParams;
export declare namespace DocumentSettingsRequest {

@@ -29,3 +25,3 @@ const method: "$/textDocument/documentSettings";

}
export declare type DocumentSettingsNotificationParams = DocumentSettingsParams & DocumentSettings;
export type DocumentSettingsNotificationParams = DocumentSettingsParams & DocumentSettings;
export declare namespace DocumentSettingsNotification {

@@ -32,0 +28,0 @@ const method: "$/textDocument/documentSettings/didChange";

@@ -13,3 +13,3 @@ /*!--------------------------------------------------------------------------------------------

#private;
readonly yamlDocument: Lazy<YamlDocument<YamlNode<unknown>>>;
readonly yamlDocument: Lazy<YamlDocument<YamlNode>>;
private documentSettings;

@@ -16,0 +16,0 @@ get textDocument(): TextDocument;

@@ -6,2 +6,7 @@ "use strict";

*--------------------------------------------------------------------------------------------*/
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

@@ -13,7 +18,2 @@ if (kind === "m") throw new TypeError("Private method is not writable");

};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _ComposeDocument_textDocument;

@@ -31,7 +31,2 @@ Object.defineProperty(exports, "__esModule", { value: true });

class ComposeDocument {
constructor(doc) {
this.yamlDocument = new Lazy_1.Lazy(() => this.buildYamlDocument());
/* private */ _ComposeDocument_textDocument.set(this, void 0);
__classPrivateFieldSet(this, _ComposeDocument_textDocument, doc, "f");
}
get textDocument() {

@@ -48,2 +43,7 @@ return __classPrivateFieldGet(this, _ComposeDocument_textDocument, "f");

}
constructor(doc) {
this.yamlDocument = new Lazy_1.Lazy(() => this.buildYamlDocument());
/* private */ _ComposeDocument_textDocument.set(this, void 0);
__classPrivateFieldSet(this, _ComposeDocument_textDocument, doc, "f");
}
update(doc) {

@@ -299,3 +299,2 @@ __classPrivateFieldSet(this, _ComposeDocument_textDocument, doc, "f");

}
exports.ComposeDocument = ComposeDocument;
_ComposeDocument_textDocument = new WeakMap();

@@ -306,2 +305,3 @@ ComposeDocument.DocumentManagerConfig = {

};
exports.ComposeDocument = ComposeDocument;
// IMPORTANT: For all of these regular expressions, the groups present *and* their names are very important.

@@ -308,0 +308,0 @@ // Removal or alteration would break `getPositionInfo` and `getFirstLinePositionInfo`

@@ -12,2 +12,3 @@ /*!--------------------------------------------------------------------------------------------

private readonly telemetryAggregator;
private readonly _capabilities;
constructor(connection: Connection, clientParams: InitializeParams);

@@ -14,0 +15,0 @@ dispose(): void;

@@ -19,5 +19,44 @@ "use strict";

const TelemetryAggregator_1 = require("./utils/telemetry/TelemetryAggregator");
const DefaultCapabilities = {
// Text document synchronization
textDocumentSync: {
openClose: true,
change: vscode_languageserver_1.TextDocumentSyncKind.Incremental,
willSave: false,
willSaveWaitUntil: false,
save: false,
},
// Both basic and advanced completions
completionProvider: {
triggerCharacters: ['-', ':', ' ', '"'],
resolveProvider: false,
},
// Hover over YAML keys
hoverProvider: true,
// Links to Docker Hub on image names
documentLinkProvider: {
resolveProvider: false,
},
// YAML formatting
documentFormattingProvider: true,
// Workspace features
workspace: {
workspaceFolders: {
supported: true,
},
},
};
// Default settings for a client with no alternate YAML language service
const DefaultAlternateYamlLanguageServiceClientCapabilities = {
syntaxValidation: false,
schemaValidation: false,
basicCompletions: false,
advancedCompletions: false,
hover: false,
imageLinks: false,
formatting: false,
};
class ComposeLanguageService {
constructor(connection, clientParams) {
var _a, _b;
var _a, _b, _c;
this.connection = connection;

@@ -27,9 +66,44 @@ this.clientParams = clientParams;

this.subscriptions = [];
this._capabilities = DefaultCapabilities;
let altYamlCapabilities = (_a = clientParams.capabilities.experimental) === null || _a === void 0 ? void 0 : _a.alternateYamlLanguageService;
if (altYamlCapabilities) {
connection.console.info('An alternate YAML language service is present. The Compose language service will not enable features already provided by the alternate.');
}
else {
altYamlCapabilities = DefaultAlternateYamlLanguageServiceClientCapabilities;
}
// Hook up the document listeners, which create a Disposable which will be added to this.subscriptions
this.createDocumentManagerHandler(this.documentManager.onDidChangeContent, new DiagnosticProvider_1.DiagnosticProvider((_a = clientParams.initializationOptions) === null || _a === void 0 ? void 0 : _a.diagnosticDelay));
// Hook up all the LSP listeners, which do not create Disposables for some reason
this.createLspHandler(this.connection.onCompletion, new MultiCompletionProvider_1.MultiCompletionProvider());
this.createLspHandler(this.connection.onHover, new KeyHoverProvider_1.KeyHoverProvider());
this.createLspHandler(this.connection.onDocumentLinks, new ImageLinkProvider_1.ImageLinkProvider());
this.createLspHandler(this.connection.onDocumentFormatting, new DocumentFormattingProvider_1.DocumentFormattingProvider());
if (altYamlCapabilities.syntaxValidation && altYamlCapabilities.schemaValidation) {
// Noop. No server-side capability needs to be set for diagnostics because it is based on pushing from server to client.
}
else {
this.createDocumentManagerHandler(this.documentManager.onDidChangeContent, new DiagnosticProvider_1.DiagnosticProvider((_b = clientParams.initializationOptions) === null || _b === void 0 ? void 0 : _b.diagnosticDelay, !altYamlCapabilities.syntaxValidation, !altYamlCapabilities.schemaValidation));
}
// End of document listeners
// Hook up all the applicable LSP listeners, which do not create Disposables for some reason
if (altYamlCapabilities.basicCompletions && altYamlCapabilities.advancedCompletions) {
this._capabilities.completionProvider = undefined;
}
else {
this.createLspHandler(this.connection.onCompletion, new MultiCompletionProvider_1.MultiCompletionProvider(!altYamlCapabilities.basicCompletions, !altYamlCapabilities.advancedCompletions));
}
if (altYamlCapabilities.hover) {
this._capabilities.hoverProvider = undefined;
}
else {
this.createLspHandler(this.connection.onHover, new KeyHoverProvider_1.KeyHoverProvider());
}
if (altYamlCapabilities.imageLinks) {
this._capabilities.documentLinkProvider = undefined;
}
else {
this.createLspHandler(this.connection.onDocumentLinks, new ImageLinkProvider_1.ImageLinkProvider());
}
if (altYamlCapabilities.formatting) {
this._capabilities.documentFormattingProvider = undefined;
}
else {
this.createLspHandler(this.connection.onDocumentFormatting, new DocumentFormattingProvider_1.DocumentFormattingProvider());
}
// End of LSP listeners
// Hook up one additional notification handler

@@ -40,3 +114,3 @@ this.connection.onNotification(DocumentSettings_1.DocumentSettingsNotification.method, (params) => this.onDidChangeDocumentSettings(params));

// Start the telemetry aggregator
this.subscriptions.push(this.telemetryAggregator = new TelemetryAggregator_1.TelemetryAggregator(this.connection, (_b = clientParams.initializationOptions) === null || _b === void 0 ? void 0 : _b.telemetryAggregationInterval));
this.subscriptions.push(this.telemetryAggregator = new TelemetryAggregator_1.TelemetryAggregator(this.connection, (_c = clientParams.initializationOptions) === null || _c === void 0 ? void 0 : _c.telemetryAggregationInterval));
}

@@ -49,25 +123,3 @@ dispose() {

get capabilities() {
return {
textDocumentSync: {
openClose: true,
change: vscode_languageserver_1.TextDocumentSyncKind.Incremental,
willSave: false,
willSaveWaitUntil: false,
save: false,
},
completionProvider: {
triggerCharacters: ['-', ':', ' ', '"'],
resolveProvider: false,
},
hoverProvider: true,
documentLinkProvider: {
resolveProvider: false,
},
documentFormattingProvider: true,
workspace: {
workspaceFolders: {
supported: true,
},
},
};
return this._capabilities;
}

@@ -74,0 +126,0 @@ onDidChangeDocumentSettings(params) {

@@ -21,2 +21,4 @@ /*!--------------------------------------------------------------------------------------------

positionInfo: PositionInfo;
basicCompletions: boolean;
advancedCompletions: boolean;
}

@@ -34,2 +34,3 @@ "use strict";

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -40,2 +41,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
},

@@ -46,2 +48,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
},

@@ -53,2 +56,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -59,2 +63,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
},

@@ -65,4 +70,5 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
},
]);
//# sourceMappingURL=BuildCompletionCollection.js.map

@@ -16,2 +16,6 @@ /*!--------------------------------------------------------------------------------------------

insertText: string;
/**
* Whether a completion is an advanced compose completion
*/
isAdvancedComposeCompletion: boolean;
}

@@ -18,0 +22,0 @@ export declare class CompletionCollection extends Array<ExtendedCompletionItem> {

@@ -22,3 +22,5 @@ "use strict";

const line = params.document.lineAt(params.position);
return this.filter(eci => !eci.matcher || eci.matcher.test(line));
return this
.filter(eci => (params.basicCompletions && !eci.isAdvancedComposeCompletion) || (params.advancedCompletions && eci.isAdvancedComposeCompletion))
.filter(eci => !eci.matcher || eci.matcher.test(line));
}

@@ -25,0 +27,0 @@ }

@@ -14,5 +14,7 @@ /*!--------------------------------------------------------------------------------------------

export declare class MultiCompletionProvider extends ProviderBase<CompletionParams & ExtendedParams, CompletionItem[] | undefined, never, never> {
private readonly basicCompletions;
private readonly advancedCompletions;
private readonly completionCollections;
constructor();
constructor(basicCompletions: boolean, advancedCompletions: boolean);
on(params: CompletionParams & ExtendedPositionParams, token: CancellationToken, workDoneProgress: WorkDoneProgressReporter): Promise<CompletionItem[] | undefined>;
}

@@ -21,4 +21,6 @@ "use strict";

class MultiCompletionProvider extends ProviderBase_1.ProviderBase {
constructor() {
constructor(basicCompletions, advancedCompletions) {
super();
this.basicCompletions = basicCompletions;
this.advancedCompletions = advancedCompletions;
this.completionCollections = [

@@ -37,2 +39,4 @@ RootCompletionCollection_1.RootCompletionCollection,

positionInfo: await params.document.getPositionInfo(params),
basicCompletions: this.basicCompletions,
advancedCompletions: this.advancedCompletions,
};

@@ -39,0 +43,0 @@ const results = [];

@@ -18,2 +18,3 @@ "use strict";

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
},

@@ -25,2 +26,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: true,
},

@@ -32,2 +34,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: true,
},

@@ -39,2 +42,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: true,
},

@@ -47,2 +51,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
documentation: 'target: <containerPort>\n published: <hostPort>\n protocol: <udp, tcp>\n mode: <host, ingress>',

@@ -49,0 +54,0 @@ sortText: 'zzz', // Force this to sort to the bottom

@@ -31,2 +31,3 @@ "use strict";

insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
isAdvancedComposeCompletion: false,
},

@@ -37,2 +38,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
isAdvancedComposeCompletion: false,
},

@@ -43,2 +45,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
isAdvancedComposeCompletion: false,
},

@@ -49,2 +52,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
isAdvancedComposeCompletion: false,
},

@@ -55,2 +59,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
},

@@ -61,4 +66,5 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
isAdvancedComposeCompletion: false,
},
]);
//# sourceMappingURL=RootCompletionCollection.js.map

@@ -31,2 +31,3 @@ "use strict";

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
detail: 'Short form',

@@ -40,2 +41,3 @@ documentation: 'build: <path>',

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
detail: 'Long form',

@@ -48,2 +50,3 @@ documentation: 'build:\n\tcontext: <contextPath>\n\tdockerfile: <Dockerfile>',

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
detail: 'String form',

@@ -56,2 +59,3 @@ documentation: 'command: echo hello'

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: true,
detail: 'List form',

@@ -64,2 +68,3 @@ documentation: 'command: ["echo", "hello"]'

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
},

@@ -71,2 +76,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -77,2 +83,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
detail: 'String form',

@@ -85,2 +92,3 @@ documentation: 'entrypoint: /app/start.sh'

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: true,
detail: 'List form',

@@ -94,2 +102,3 @@ documentation: 'entrypoint: ["echo", "hello"]'

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -101,2 +110,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -108,2 +118,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -115,2 +126,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -121,2 +133,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: false,
},

@@ -128,2 +141,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -135,2 +149,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -142,2 +157,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: false,
},

@@ -149,2 +165,3 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: true,
},

@@ -156,4 +173,5 @@ {

insertTextMode: vscode_languageserver_1.InsertTextMode.adjustIndentation,
isAdvancedComposeCompletion: false,
},
]);
//# sourceMappingURL=ServiceCompletionCollection.js.map

@@ -17,2 +17,3 @@ "use strict";

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: true,
},

@@ -25,2 +26,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: true,
},

@@ -33,2 +35,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
isAdvancedComposeCompletion: true,
},

@@ -41,2 +44,3 @@ {

insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
isAdvancedComposeCompletion: true,
detail: 'Read-only',

@@ -50,2 +54,3 @@ },

insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
isAdvancedComposeCompletion: true,
detail: 'Read-write',

@@ -52,0 +57,0 @@ },

@@ -11,4 +11,6 @@ /*!--------------------------------------------------------------------------------------------

private readonly diagnosticDelay;
constructor(diagnosticDelay?: number);
private readonly syntaxValidation;
private readonly schemaValidation;
constructor(diagnosticDelay: number, syntaxValidation: boolean, schemaValidation: boolean);
on(params: TextDocumentChangeEvent<ComposeDocument> & ExtendedParams): void;
}

@@ -16,8 +16,14 @@ "use strict";

class DiagnosticProvider extends ProviderBase_1.ProviderBase {
constructor(diagnosticDelay = DiagnosticDelay) {
constructor(diagnosticDelay = DiagnosticDelay, syntaxValidation, schemaValidation) {
super();
this.diagnosticDelay = diagnosticDelay;
this.syntaxValidation = syntaxValidation;
this.schemaValidation = schemaValidation;
}
on(params) {
var _a;
if (!this.syntaxValidation) {
// Do nothing if syntax validation is disabled. At present schema validation is not supported, https://github.com/microsoft/compose-language-service/issues/84
return;
}
const ctx = (0, ActionContext_1.getCurrentContext)();

@@ -24,0 +30,0 @@ ctx.telemetry.suppressAll = true; // Diagnostics is async and telemetry won't really work

@@ -6,3 +6,3 @@ /*!--------------------------------------------------------------------------------------------

import { Connection } from 'vscode-languageserver';
import { ComposeLanguageClientCapabilities } from '../../client/DocumentSettings';
import type { ComposeLanguageClientCapabilities } from '../../client/ClientCapabilities';
import { TelemetryEvent } from '../../client/TelemetryEvent';

@@ -9,0 +9,0 @@ export interface ActionContext {

{
"name": "@microsoft/compose-language-service",
"author": "Microsoft Corporation",
"version": "0.1.3",
"version": "0.2.0",
"publisher": "ms-azuretools",

@@ -43,3 +43,3 @@ "description": "Language service for Docker Compose documents",

"mocha": "^10.0.0",
"typescript": "^4.7.4"
"typescript": "^5.0.4"
},

@@ -49,4 +49,4 @@ "dependencies": {

"vscode-languageserver-textdocument": "^1.0.3",
"yaml": "^2.1.1"
"yaml": "^2.2.2"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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