UNPKG

@slugkit/sdk

Version:

SlugKit SDK for JavaScript/TypeScript applications

73 lines (72 loc) 1.97 kB
import { DictionaryStats, DictionaryTag } from './types'; export interface Suggestion { text: string; description?: string; type: 'generator' | 'tag' | 'operator' | 'symbol' | 'language' | 'base'; replaceRange: { start: number; end: number; }; } export interface SuggestionContext { pattern: string; cursorPosition: number; placeholderStart: number; placeholderEnd: number; placeholderContent: string; isInSettings: boolean; isInTags: boolean; isInLengthConstraint: boolean; isInOptions: boolean; } interface SlugKitInterface { getDictionaries(): Promise<DictionaryStats[]>; getDictionaryTags(): Promise<DictionaryTag[]>; } export declare class PatternSuggestions { private slugkit; private parser; private suggestionProvider; constructor(slugkit: SlugKitInterface); /** * Get suggestions based on pattern and cursor position */ getSuggestions(pattern: string, cursorPosition: number): Promise<Suggestion[]>; /** * Enrich a basic suggestion with description and correct replace range */ private enrichSuggestion; /** * Get description for a suggestion based on its type and content */ private getSuggestionDescription; /** * Calculate replace range for a suggestion */ private calculateReplaceRangeForSuggestion; /** * Determine if we should replace the last token */ private shouldReplaceLastToken; /** * Get generator description */ private getGeneratorDescription; /** * Get tag description */ private getTagDescription; /** * Get operator description */ private getOperatorDescription; /** * Get symbol description */ private getSymbolDescription; /** * Adjust cursor position to the end of current token if inside placeholder or global settings */ private adjustCursorToTokenEnd; } export {};