Merge pull request #142 from remcohaszing/remove-prefix-support

Remove support for the prefix option
This commit is contained in:
Remco Haszing 2021-11-23 14:51:19 +01:00 committed by GitHub
commit a18a75d137
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 17 deletions

8
index.d.ts vendored
View file

@ -70,14 +70,6 @@ declare module 'monaco-editor/esm/vs/editor/editor.api' {
*/ */
readonly isKubernetes?: boolean; readonly isKubernetes?: boolean;
/**
* If specified, this prefix will be added to all on demand schema requests
*
* @default undefined
* @deprecated
*/
readonly prefix?: string;
/** /**
* A list of known schemas and/or associations of schemas to file names. * A list of known schemas and/or associations of schemas to file names.
* *

View file

@ -48,7 +48,6 @@ export function createWorkerManager(
createData: { createData: {
languageSettings: defaults.diagnosticsOptions, languageSettings: defaults.diagnosticsOptions,
enableSchemaRequest: defaults.diagnosticsOptions.enableSchemaRequest, enableSchemaRequest: defaults.diagnosticsOptions.enableSchemaRequest,
prefix: defaults.diagnosticsOptions.prefix,
isKubernetes: defaults.diagnosticsOptions.isKubernetes, isKubernetes: defaults.diagnosticsOptions.isKubernetes,
customTags: defaults.diagnosticsOptions.customTags, customTags: defaults.diagnosticsOptions.customTags,
}, },

View file

@ -10,10 +10,12 @@ import {
import { languageId } from './constants'; import { languageId } from './constants';
let defaultSchemaRequestService: (url: string) => Promise<string>; async function schemaRequestService(uri: string): Promise<string> {
const response = await fetch(uri);
if (typeof fetch !== 'undefined') { if (response.ok) {
defaultSchemaRequestService = (url) => fetch(url).then((response) => response.text()); return response.text();
}
throw new Error(`Schema request failed for ${uri}`);
} }
export interface YAMLWorker { export interface YAMLWorker {
@ -36,10 +38,14 @@ export interface YAMLWorker {
export function createYAMLWorker( export function createYAMLWorker(
ctx: worker.IWorkerContext, ctx: worker.IWorkerContext,
{ enableSchemaRequest, languageSettings, prefix = '' }: ICreateData, { enableSchemaRequest, languageSettings }: ICreateData,
): YAMLWorker { ): YAMLWorker {
const service = (url: string): Promise<string> => defaultSchemaRequestService(`${prefix}${url}`); const languageService = getLanguageService(
const languageService = getLanguageService(enableSchemaRequest && service, null, null, null); enableSchemaRequest ? schemaRequestService : null,
null,
null,
null,
);
languageService.configure(languageSettings); languageService.configure(languageSettings);
const getTextDocument = (uri: string): TextDocument => { const getTextDocument = (uri: string): TextDocument => {
@ -100,6 +106,5 @@ export function createYAMLWorker(
export interface ICreateData { export interface ICreateData {
languageSettings: LanguageSettings; languageSettings: LanguageSettings;
enableSchemaRequest: boolean; enableSchemaRequest: boolean;
prefix?: string;
isKubernetes?: boolean; isKubernetes?: boolean;
} }