@arcgis/coding-components
Version:
Contains components for editing code in different languages. The currently supported languages are html, css, json, TypeScript, JavaScript, and Arcade.
77 lines (76 loc) • 3.8 kB
TypeScript
import { Emitter, Uri } from '../utils/monaco-importer';
import { IEvent } from 'monaco-editor';
import { EditorProfile } from './profile/editor-profile';
import { ApiCategory, ApiContext, ApiSnippet } from '@arcgis/languages-api-utils';
import { IEditorProfileDefinition, IPredefinedProfile } from './profile/types';
export interface WorkerHost {
getApiLibrary: (locale: string) => Promise<ApiCategory[]>;
}
export interface ApiConfig {
apiPath: string;
apiPrefix: string;
}
export declare abstract class LanguageDefaultsBase<TApiContext extends ApiContext = ApiContext> {
readonly languageId: string;
private _apiConfig;
protected _onDidChange: Emitter<this>;
protected _modelToProfileMap: Map<string, EditorProfile>;
protected _modelToApiContextMap: Map<string, TApiContext>;
protected _localeToApiLibraryPromiseMap: Map<"id" | "en" | "ar" | "bg" | "bs" | "ca" | "cs" | "da" | "de" | "el" | "es" | "et" | "fi" | "fr" | "he" | "hr" | "hu" | "it" | "ja" | "ko" | "lt" | "lv" | "nl" | "nb" | "no" | "pl" | "pt-BR" | "pt-PT" | "ro" | "ru" | "sk" | "sl" | "sr" | "sv" | "th" | "tr" | "uk" | "vi" | "zh-CN" | "zh-HK" | "zh-TW", Promise<ApiCategory[]>>;
protected _onModelContextDidChange: Emitter<string>;
protected _onDidModelContextChangeTimeout: number;
constructor(languageId: string, _apiConfig: ApiConfig);
protected _fireModelContextDidChange(key: string): void;
protected _getApiKey(modelId: Uri | string): string;
get onDidChange(): IEvent<this>;
/**
* Dispose any cached resources for the model
*/
disposeForModel(modelId: Uri | string): void;
/**
* Returns the editor profile for the given model id.
* @param modelId The model id for which to get the editor profile.
* @returns The editor profile for the model.
*/
getEditorProfileForModel(modelId: Uri | string): EditorProfile | undefined;
/**
* Returns the API context for the given model id.
* Returns the default context if the model has no context.
* @param modelId The model id for which to get the API context.
* @returns The API context for the model.
*/
getApiContextForModel(contextId: Uri | string): TApiContext;
/**
* Set or update api context for the given model id.
* @param modelId The model id for which to set the context.
* @param apiContext The api context to set.
*/
updateApiContextForModel(modelId: Uri | string, apiContext: TApiContext): void;
get onModelContextDidChange(): IEvent<string>;
/**
* Gets the API library for the given model id.
* @param modelId The model id for which to get the API library.
* @returns The API library for the model.
*/
getApiLibraryForModel(modelId: string): Promise<ApiCategory[]>;
/**
* The worker host is used by the worker to invoke methods on the main thread.
*/
workerHost: WorkerHost;
private fetchApiLibrary;
private getApiLibrary;
/**
* Create an EditorProfile for the given model id using the given definition and locale.
* The EditorProfile is used by the the Language service as well by the components.
* The definition can be a pre-defined profile or an editor profile definition.
* If the locale is not provided then the 'en' locale is used.
* @param modelId The model id for which to create the context.
* @param definition The definition to use for the model context.
* @param locale The locale to use for the model context.
* @returns The EditorProfile for the model.
*/
abstract setProfileForModel(modelId: Uri | string, definition: IEditorProfileDefinition | IPredefinedProfile | undefined, apiContext: {
locale: string;
snippets?: ApiSnippet[];
}): Promise<void>;
}