mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-06-18 22:11:26 +00:00
feat: revert back custom request service
This commit is contained in:
parent
5476403375
commit
5169f3e1fd
6 changed files with 8 additions and 31 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "monaco-yaml",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"description": "YAML plugin for the Monaco Editor",
|
||||
"scripts": {
|
||||
"compile": "rimraf ./out && yarn compile:umd && yarn compile:esm",
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ export class LanguageServiceDefaultsImpl implements monaco.languages.yaml.Langua
|
|||
const diagnosticDefault: monaco.languages.yaml.DiagnosticsOptions = {
|
||||
validate: true,
|
||||
schemas: [],
|
||||
enableSchemaRequest: false
|
||||
}
|
||||
|
||||
const yamlDefaults = new LanguageServiceDefaultsImpl('yaml', diagnosticDefault);
|
||||
|
|
|
|||
5
src/monaco.d.ts
vendored
5
src/monaco.d.ts
vendored
|
|
@ -29,10 +29,9 @@ declare module monaco.languages.yaml {
|
|||
}[];
|
||||
|
||||
/**
|
||||
* If not set, the schema service would load schema content on-demand with 'fetch' if available,
|
||||
* otherwise, it will try to load with the custom schema request.
|
||||
* If set, the schema service would load schema content on-demand with 'fetch' if available
|
||||
*/
|
||||
readonly schemaRequestService?: (url: string) => Promise<string>;
|
||||
readonly enableSchemaRequest?: boolean;
|
||||
}
|
||||
|
||||
export interface LanguageServiceDefaults {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export class WorkerManager {
|
|||
createData: {
|
||||
languageSettings: this._defaults.diagnosticsOptions,
|
||||
languageId: this._defaults.languageId,
|
||||
schemaRequestService: this._defaults.diagnosticsOptions.schemaRequestService
|
||||
enableSchemaRequest: this._defaults.diagnosticsOptions.enableSchemaRequest
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -18,30 +18,6 @@ if (typeof fetch !== 'undefined'){
|
|||
defaultSchemaRequestService = function (url) { return fetch(url).then(response => response.text())};
|
||||
}
|
||||
|
||||
class PromiseAdapter<T> implements yamlService.Thenable<T> {
|
||||
private wrapped: monaco.Promise<T>;
|
||||
|
||||
constructor(executor: (resolve: (value?: T | yamlService.Thenable<T>) => void, reject: (reason?: any) => void) => void) {
|
||||
this.wrapped = new monaco.Promise<T>(executor);
|
||||
}
|
||||
public then<TResult>(onfulfilled?: (value: T) => TResult | yamlService.Thenable<TResult>, onrejected?: (reason: any) => void): yamlService.Thenable<TResult> {
|
||||
let thenable: yamlService.Thenable<T> = this.wrapped;
|
||||
return thenable.then(onfulfilled, onrejected);
|
||||
}
|
||||
public getWrapped(): monaco.Thenable<T> {
|
||||
return this.wrapped;
|
||||
}
|
||||
public static resolve<T>(v: T | Thenable<T>): yamlService.Thenable<T> {
|
||||
return <monaco.Thenable<T>>monaco.Promise.as(v);
|
||||
}
|
||||
public static reject<T>(v: T): yamlService.Thenable<T> {
|
||||
return monaco.Promise.wrapError(<any>v);
|
||||
}
|
||||
public static all<T>(values: yamlService.Thenable<T>[]): yamlService.Thenable<T[]> {
|
||||
return monaco.Promise.join(values);
|
||||
}
|
||||
}
|
||||
|
||||
export class YAMLWorker {
|
||||
|
||||
private _ctx: IWorkerContext;
|
||||
|
|
@ -54,7 +30,7 @@ export class YAMLWorker {
|
|||
this._languageSettings = createData.languageSettings;
|
||||
this._languageId = createData.languageId;
|
||||
this._languageService = yamlService.getLanguageService(
|
||||
createData.schemaRequestService || defaultSchemaRequestService, null, []);
|
||||
createData.enableSchemaRequest && defaultSchemaRequestService, null, []);
|
||||
this._languageService.configure({ ...this._languageSettings, hover: true, isKubernetes: true });
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +83,7 @@ export class YAMLWorker {
|
|||
export interface ICreateData {
|
||||
languageId: string;
|
||||
languageSettings: yamlService.LanguageSettings;
|
||||
schemaRequestService: (url: string) => Promise<string>;
|
||||
enableSchemaRequest: boolean;
|
||||
}
|
||||
|
||||
export function create(ctx: IWorkerContext, createData: ICreateData): YAMLWorker {
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ spec:
|
|||
});
|
||||
|
||||
monaco.languages.yaml.yamlDefaults.setDiagnosticsOptions({
|
||||
enableSchemaRequest: true,
|
||||
validate: true,
|
||||
schemas: [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue