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;
/**
* 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.
*

View file

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

View file

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