node_modules ignore

This commit is contained in:
oier committed 2025-05-08 23:43:47 +02:00
1 parent e19d52f172
commit 4574544c9f
65041 files changed
+10593536

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
export declare const DebugFlags: {
InDebugMode: boolean;
};
export declare const UseOnigurumaFindOptions = false;
@@ -0,0 +1,31 @@
import { FontStyle } from "./theme";
export declare type EncodedTokenAttributes = number;
export declare namespace EncodedTokenAttributes {
function toBinaryStr(encodedTokenAttributes: EncodedTokenAttributes): string;
function print(encodedTokenAttributes: EncodedTokenAttributes): void;
function getLanguageId(encodedTokenAttributes: EncodedTokenAttributes): number;
function getTokenType(encodedTokenAttributes: EncodedTokenAttributes): StandardTokenType;
function containsBalancedBrackets(encodedTokenAttributes: EncodedTokenAttributes): boolean;
function getFontStyle(encodedTokenAttributes: EncodedTokenAttributes): number;
function getForeground(encodedTokenAttributes: EncodedTokenAttributes): number;
function getBackground(encodedTokenAttributes: EncodedTokenAttributes): number;
/**
* Updates the fields in `metadata`.
* A value of `0`, `NotSet` or `null` indicates that the corresponding field should be left as is.
*/
function set(encodedTokenAttributes: EncodedTokenAttributes, languageId: number, tokenType: OptionalStandardTokenType, containsBalancedBrackets: boolean | null, fontStyle: FontStyle, foreground: number, background: number): number;
}
export declare const enum StandardTokenType {
Other = 0,
Comment = 1,
String = 2,
RegEx = 3
}
export declare function toOptionalTokenType(standardType: StandardTokenType): OptionalStandardTokenType;
export declare const enum OptionalStandardTokenType {
Other = 0,
Comment = 1,
String = 2,
RegEx = 3,
NotSet = 8
}
@@ -0,0 +1,24 @@
import { OptionalStandardTokenType } from "../encodedTokenAttributes";
import { IEmbeddedLanguagesMap } from "../main";
import { ScopeName } from "../theme";
export declare class BasicScopeAttributes {
readonly languageId: number;
readonly tokenType: OptionalStandardTokenType;
constructor(languageId: number, tokenType: OptionalStandardTokenType);
}
export declare class BasicScopeAttributesProvider {
private readonly _defaultAttributes;
private readonly _embeddedLanguagesMatcher;
constructor(initialLanguageId: number, embeddedLanguages: IEmbeddedLanguagesMap | null);
getDefaultAttributes(): BasicScopeAttributes;
getBasicScopeAttributes(scopeName: ScopeName | null): BasicScopeAttributes;
private static readonly _NULL_SCOPE_METADATA;
private readonly _getBasicScopeAttributes;
/**
* Given a produced TM scope, return the language that token describes or null if unknown.
* e.g. source.html => html, source.css.embedded.html => css, punctuation.definition.tag.html => null
*/
private _scopeToLanguage;
private _toStandardTokenType;
private static STANDARD_TOKEN_TYPE_REGEXP;
}
+198
View File
@@ -0,0 +1,198 @@
import { EncodedTokenAttributes, StandardTokenType } from '../encodedTokenAttributes';
import { IEmbeddedLanguagesMap, IGrammar, IToken, ITokenizeLineResult, ITokenizeLineResult2, ITokenTypeMap, StateStack as StackElementDef } from '../main';
import { Matcher } from '../matcher';
import { IOnigLib, OnigScanner, OnigString } from '../onigLib';
import { IRawGrammar, IRawRepository } from '../rawGrammar';
import { IRuleFactoryHelper, IRuleRegistry, Rule, RuleId } from '../rule';
import { ScopeName, ScopePath, ScopeStack, StyleAttributes } from '../theme';
import { BasicScopeAttributes } from './basicScopesAttributeProvider';
export declare function createGrammar(scopeName: ScopeName, grammar: IRawGrammar, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null, grammarRepository: IGrammarRepository & IThemeProvider, onigLib: IOnigLib): Grammar;
export interface IThemeProvider {
themeMatch(scopePath: ScopeStack): StyleAttributes | null;
getDefaults(): StyleAttributes;
}
export interface IGrammarRepository {
lookup(scopeName: ScopeName): IRawGrammar | undefined;
injections(scopeName: ScopeName): ScopeName[];
}
export interface Injection {
readonly debugSelector: string;
readonly matcher: Matcher<string[]>;
readonly priority: -1 | 0 | 1;
readonly ruleId: RuleId;
readonly grammar: IRawGrammar;
}
export declare class Grammar implements IGrammar, IRuleFactoryHelper, IOnigLib {
private readonly _rootScopeName;
private readonly balancedBracketSelectors;
private readonly _onigLib;
private _rootId;
private _lastRuleId;
private readonly _ruleId2desc;
private readonly _includedGrammars;
private readonly _grammarRepository;
private readonly _grammar;
private _injections;
private readonly _basicScopeAttributesProvider;
private readonly _tokenTypeMatchers;
get themeProvider(): IThemeProvider;
constructor(_rootScopeName: ScopeName, grammar: IRawGrammar, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null, grammarRepository: IGrammarRepository & IThemeProvider, _onigLib: IOnigLib);
dispose(): void;
createOnigScanner(sources: string[]): OnigScanner;
createOnigString(sources: string): OnigString;
getMetadataForScope(scope: string): BasicScopeAttributes;
private _collectInjections;
getInjections(): Injection[];
registerRule<T extends Rule>(factory: (id: RuleId) => T): T;
getRule(ruleId: RuleId): Rule;
getExternalGrammar(scopeName: string, repository?: IRawRepository): IRawGrammar | undefined;
tokenizeLine(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult;
tokenizeLine2(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult2;
private _tokenize;
}
export declare class AttributedScopeStack {
readonly parent: AttributedScopeStack | null;
readonly scopePath: ScopeStack;
readonly tokenAttributes: EncodedTokenAttributes;
static createRoot(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes): AttributedScopeStack;
static createRootAndLookUpScopeName(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes, grammar: Grammar): AttributedScopeStack;
get scopeName(): ScopeName;
private constructor();
equals(other: AttributedScopeStack): boolean;
private static _equals;
private static mergeAttributes;
pushAttributed(scopePath: ScopePath | null, grammar: Grammar): AttributedScopeStack;
private static _pushAttributed;
getScopeNames(): string[];
}
/**
* Represents a "pushed" state on the stack (as a linked list element).
*/
export declare class StateStack implements StackElementDef {
/**
* The previous state on the stack (or null for the root state).
*/
readonly parent: StateStack | null;
/**
* The state (rule) that this element represents.
*/
private readonly ruleId;
/**
* The state has entered and captured \n. This means that the next line should have an anchorPosition of 0.
*/
readonly beginRuleCapturedEOL: boolean;
/**
* The "pop" (end) condition for this state in case that it was dynamically generated through captured text.
*/
readonly endRule: string | null;
/**
* The list of scopes containing the "name" for this state.
*/
readonly nameScopesList: AttributedScopeStack;
/**
* The list of scopes containing the "contentName" (besides "name") for this state.
* This list **must** contain as an element `scopeName`.
*/
readonly contentNameScopesList: AttributedScopeStack;
_stackElementBrand: void;
static NULL: StateStack;
/**
* The position on the current line where this state was pushed.
* This is relevant only while tokenizing a line, to detect endless loops.
* Its value is meaningless across lines.
*/
private _enterPos;
/**
* The captured anchor position when this stack element was pushed.
* This is relevant only while tokenizing a line, to restore the anchor position when popping.
* Its value is meaningless across lines.
*/
private _anchorPos;
/**
* The depth of the stack.
*/
readonly depth: number;
constructor(
/**
* The previous state on the stack (or null for the root state).
*/
parent: StateStack | null,
/**
* The state (rule) that this element represents.
*/
ruleId: RuleId, enterPos: number, anchorPos: number,
/**
* The state has entered and captured \n. This means that the next line should have an anchorPosition of 0.
*/
beginRuleCapturedEOL: boolean,
/**
* The "pop" (end) condition for this state in case that it was dynamically generated through captured text.
*/
endRule: string | null,
/**
* The list of scopes containing the "name" for this state.
*/
nameScopesList: AttributedScopeStack,
/**
* The list of scopes containing the "contentName" (besides "name") for this state.
* This list **must** contain as an element `scopeName`.
*/
contentNameScopesList: AttributedScopeStack);
equals(other: StateStack): boolean;
private static _equals;
/**
* A structural equals check. Does not take into account `scopes`.
*/
private static _structuralEquals;
clone(): StateStack;
private static _reset;
reset(): void;
pop(): StateStack | null;
safePop(): StateStack;
push(ruleId: RuleId, enterPos: number, anchorPos: number, beginRuleCapturedEOL: boolean, endRule: string | null, nameScopesList: AttributedScopeStack, contentNameScopesList: AttributedScopeStack): StateStack;
getEnterPos(): number;
getAnchorPos(): number;
getRule(grammar: IRuleRegistry): Rule;
toString(): string;
private _writeString;
withContentNameScopesList(contentNameScopeStack: AttributedScopeStack): StateStack;
withEndRule(endRule: string): StateStack;
hasSameRuleAs(other: StateStack): boolean;
}
interface TokenTypeMatcher {
readonly matcher: Matcher<string[]>;
readonly type: StandardTokenType;
}
export declare class BalancedBracketSelectors {
private readonly balancedBracketScopes;
private readonly unbalancedBracketScopes;
private allowAny;
constructor(balancedBracketScopes: string[], unbalancedBracketScopes: string[]);
get matchesAlways(): boolean;
get matchesNever(): boolean;
match(scopes: string[]): boolean;
}
export declare class LineTokens {
private readonly balancedBracketSelectors;
private readonly _emitBinaryTokens;
/**
* defined only if `DebugFlags.InDebugMode`.
*/
private readonly _lineText;
/**
* used only if `_emitBinaryTokens` is false.
*/
private readonly _tokens;
/**
* used only if `_emitBinaryTokens` is true.
*/
private readonly _binaryTokens;
private _lastTokenEndIndex;
private readonly _tokenTypeOverrides;
constructor(emitBinaryTokens: boolean, lineText: string, tokenTypeOverrides: TokenTypeMatcher[], balancedBracketSelectors: BalancedBracketSelectors | null);
produce(stack: StateStack, endIndex: number): void;
produceFromScopes(scopesList: AttributedScopeStack, endIndex: number): void;
getResult(stack: StateStack, lineLength: number): IToken[];
getBinaryResult(stack: StateStack, lineLength: number): Uint32Array;
}
export {};
@@ -0,0 +1,68 @@
import { IRawRule } from '../rawGrammar';
import { ScopeName } from '../theme';
import { IGrammarRepository } from './grammar';
export declare type AbsoluteRuleReference = TopLevelRuleReference | TopLevelRepositoryRuleReference;
/**
* References the top level rule of a grammar with the given scope name.
*/
export declare class TopLevelRuleReference {
readonly scopeName: ScopeName;
constructor(scopeName: ScopeName);
toKey(): string;
}
/**
* References a rule of a grammar in the top level repository section with the given name.
*/
export declare class TopLevelRepositoryRuleReference {
readonly scopeName: ScopeName;
readonly ruleName: string;
constructor(scopeName: ScopeName, ruleName: string);
toKey(): string;
}
export declare class ExternalReferenceCollector {
private readonly _references;
private readonly _seenReferenceKeys;
get references(): readonly AbsoluteRuleReference[];
readonly visitedRule: Set<IRawRule>;
add(reference: AbsoluteRuleReference): void;
}
export declare class ScopeDependencyProcessor {
readonly repo: IGrammarRepository;
readonly initialScopeName: ScopeName;
readonly seenFullScopeRequests: Set<string>;
readonly seenPartialScopeRequests: Set<string>;
Q: AbsoluteRuleReference[];
constructor(repo: IGrammarRepository, initialScopeName: ScopeName);
processQueue(): void;
}
export declare type IncludeReference = BaseReference | SelfReference | RelativeReference | TopLevelReference | TopLevelRepositoryReference;
export declare const enum IncludeReferenceKind {
Base = 0,
Self = 1,
RelativeReference = 2,
TopLevelReference = 3,
TopLevelRepositoryReference = 4
}
export declare class BaseReference {
readonly kind = IncludeReferenceKind.Base;
}
export declare class SelfReference {
readonly kind = IncludeReferenceKind.Self;
}
export declare class RelativeReference {
readonly ruleName: string;
readonly kind = IncludeReferenceKind.RelativeReference;
constructor(ruleName: string);
}
export declare class TopLevelReference {
readonly scopeName: ScopeName;
readonly kind = IncludeReferenceKind.TopLevelReference;
constructor(scopeName: ScopeName);
}
export declare class TopLevelRepositoryReference {
readonly scopeName: ScopeName;
readonly ruleName: string;
readonly kind = IncludeReferenceKind.TopLevelRepositoryReference;
constructor(scopeName: ScopeName, ruleName: string);
}
export declare function parseInclude(include: string): IncludeReference;
+1
View File
@@ -0,0 +1 @@
export * from './grammar';
@@ -0,0 +1,27 @@
import type { LineTokens, StateStack } from './grammar';
import { OnigString } from '../onigLib';
import type { AttributedScopeStack, Grammar } from './grammar';
declare class TokenizeStringResult {
readonly stack: StateStack;
readonly stoppedEarly: boolean;
constructor(stack: StateStack, stoppedEarly: boolean);
}
/**
* Tokenize a string
* @param grammar
* @param lineText
* @param isFirstLine
* @param linePos
* @param stack
* @param lineTokens
* @param checkWhileConditions
* @param timeLimit Use `0` to indicate no time limit
* @returns the StackElement or StackElement.TIME_LIMIT_REACHED if the time limit has been reached
*/
export declare function _tokenizeString(grammar: Grammar, lineText: OnigString, isFirstLine: boolean, linePos: number, stack: StateStack, lineTokens: LineTokens, checkWhileConditions: boolean, timeLimit: number): TokenizeStringResult;
export declare class LocalStackElement {
readonly scopes: AttributedScopeStack;
readonly endPos: number;
constructor(scopes: AttributedScopeStack, endPos: number);
}
export {};
+6
View File
@@ -0,0 +1,6 @@
export interface ILocation {
readonly filename: string | null;
readonly line: number;
readonly char: number;
}
export declare function parseJSON(source: string, filename: string | null, withMetadata: boolean): any;
+141
View File
@@ -0,0 +1,141 @@
import { IOnigLib } from './onigLib';
import { IRawGrammar } from './rawGrammar';
import { IRawTheme, ScopeName } from './theme';
import { StandardTokenType } from './encodedTokenAttributes';
export * from './onigLib';
export { IRawTheme } from './theme';
/**
* A registry helper that can locate grammar file paths given scope names.
*/
export interface RegistryOptions {
onigLib: Promise<IOnigLib>;
theme?: IRawTheme;
colorMap?: string[];
loadGrammar(scopeName: ScopeName): Promise<IRawGrammar | undefined | null>;
getInjections?(scopeName: ScopeName): ScopeName[] | undefined;
}
/**
* A map from scope name to a language id. Please do not use language id 0.
*/
export interface IEmbeddedLanguagesMap {
[scopeName: string]: number;
}
/**
* A map from selectors to token types.
*/
export interface ITokenTypeMap {
[selector: string]: StandardTokenType;
}
export interface IGrammarConfiguration {
embeddedLanguages?: IEmbeddedLanguagesMap;
tokenTypes?: ITokenTypeMap;
balancedBracketSelectors?: string[];
unbalancedBracketSelectors?: string[];
}
/**
* The registry that will hold all grammars.
*/
export declare class Registry {
private readonly _options;
private readonly _syncRegistry;
private readonly _ensureGrammarCache;
constructor(options: RegistryOptions);
dispose(): void;
/**
* Change the theme. Once called, no previous `ruleStack` should be used anymore.
*/
setTheme(theme: IRawTheme, colorMap?: string[]): void;
/**
* Returns a lookup array for color ids.
*/
getColorMap(): string[];
/**
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
* Please do not use language id 0.
*/
loadGrammarWithEmbeddedLanguages(initialScopeName: ScopeName, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap): Promise<IGrammar | null>;
/**
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
* Please do not use language id 0.
*/
loadGrammarWithConfiguration(initialScopeName: ScopeName, initialLanguage: number, configuration: IGrammarConfiguration): Promise<IGrammar | null>;
/**
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
*/
loadGrammar(initialScopeName: ScopeName): Promise<IGrammar | null>;
private _loadGrammar;
private _loadSingleGrammar;
private _doLoadSingleGrammar;
/**
* Adds a rawGrammar.
*/
addGrammar(rawGrammar: IRawGrammar, injections?: string[], initialLanguage?: number, embeddedLanguages?: IEmbeddedLanguagesMap | null): Promise<IGrammar>;
/**
* Get the grammar for `scopeName`. The grammar must first be created via `loadGrammar` or `addGrammar`.
*/
private _grammarForScopeName;
}
/**
* A grammar
*/
export interface IGrammar {
/**
* Tokenize `lineText` using previous line state `prevState`.
*/
tokenizeLine(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult;
/**
* Tokenize `lineText` using previous line state `prevState`.
* The result contains the tokens in binary format, resolved with the following information:
* - language
* - token type (regex, string, comment, other)
* - font style
* - foreground color
* - background color
* e.g. for getting the languageId: `(metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET`
*/
tokenizeLine2(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult2;
}
export interface ITokenizeLineResult {
readonly tokens: IToken[];
/**
* The `prevState` to be passed on to the next line tokenization.
*/
readonly ruleStack: StateStack;
/**
* Did tokenization stop early due to reaching the time limit.
*/
readonly stoppedEarly: boolean;
}
export interface ITokenizeLineResult2 {
/**
* The tokens in binary format. Each token occupies two array indices. For token i:
* - at offset 2*i => startIndex
* - at offset 2*i + 1 => metadata
*
*/
readonly tokens: Uint32Array;
/**
* The `prevState` to be passed on to the next line tokenization.
*/
readonly ruleStack: StateStack;
/**
* Did tokenization stop early due to reaching the time limit.
*/
readonly stoppedEarly: boolean;
}
export interface IToken {
startIndex: number;
readonly endIndex: number;
readonly scopes: string[];
}
/**
* **IMPORTANT** - Immutable!
*/
export interface StateStack {
_stackElementBrand: void;
readonly depth: number;
clone(): StateStack;
equals(other: StateStack): boolean;
}
export declare const INITIAL: StateStack;
export declare const parseRawGrammar: (content: string, filePath?: string) => IRawGrammar;
+2
View File
@@ -0,0 +1,2 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vscodetextmate=t():e.vscodetextmate=t()}(this,(function(){return(()=>{"use strict";var e={350:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UseOnigurumaFindOptions=t.DebugFlags=void 0,t.DebugFlags={InDebugMode:"undefined"!=typeof process&&!!process.env.VSCODE_TEXTMATE_DEBUG},t.UseOnigurumaFindOptions=!1},36:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.toOptionalTokenType=t.EncodedTokenAttributes=void 0,(n=t.EncodedTokenAttributes||(t.EncodedTokenAttributes={})).toBinaryStr=function(e){let t=e.toString(2);for(;t.length<32;)t="0"+t;return t},n.print=function(e){const t=n.getLanguageId(e),s=n.getTokenType(e),r=n.getFontStyle(e),i=n.getForeground(e),o=n.getBackground(e);console.log({languageId:t,tokenType:s,fontStyle:r,foreground:i,background:o})},n.getLanguageId=function(e){return(255&e)>>>0},n.getTokenType=function(e){return(768&e)>>>8},n.containsBalancedBrackets=function(e){return 0!=(1024&e)},n.getFontStyle=function(e){return(30720&e)>>>11},n.getForeground=function(e){return(16744448&e)>>>15},n.getBackground=function(e){return(4278190080&e)>>>24},n.set=function(e,t,s,r,i,o,c){let a=n.getLanguageId(e),l=n.getTokenType(e),u=n.containsBalancedBrackets(e)?1:0,h=n.getFontStyle(e),p=n.getForeground(e),d=n.getBackground(e);return 0!==t&&(a=t),8!==s&&(l=s),null!==r&&(u=r?1:0),-1!==i&&(h=i),0!==o&&(p=o),0!==c&&(d=c),(a<<0|l<<8|u<<10|h<<11|p<<15|d<<24)>>>0},t.toOptionalTokenType=function(e){return e}},996:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BasicScopeAttributesProvider=t.BasicScopeAttributes=void 0;const s=n(878);class r{constructor(e,t){this.languageId=e,this.tokenType=t}}t.BasicScopeAttributes=r;class i{constructor(e,t){this._getBasicScopeAttributes=new s.CachedFn((e=>{const t=this._scopeToLanguage(e),n=this._toStandardTokenType(e);return new r(t,n)})),this._defaultAttributes=new r(e,8),this._embeddedLanguagesMatcher=new o(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return null===e?i._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const t=e.match(i.STANDARD_TOKEN_TYPE_REGEXP);if(!t)return 8;switch(t[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}}t.BasicScopeAttributesProvider=i,i._NULL_SCOPE_METADATA=new r(0,0),i.STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/;class o{constructor(e){if(0===e.length)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map((([e,t])=>s.escapeRegExpCharacters(e)));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);return t?this.values.get(t[1]):void 0}}},947:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineTokens=t.BalancedBracketSelectors=t.StateStack=t.AttributedScopeStack=t.Grammar=t.createGrammar=void 0;const s=n(350),r=n(36),i=n(736),o=n(44),c=n(792),a=n(583),l=n(878),u=n(996),h=n(47);function p(e,t,n,s,r){const o=i.createMatchers(t,d),a=c.RuleFactory.getCompiledRuleId(n,s,r.repository);for(const n of o)e.push({debugSelector:t,matcher:n.matcher,ruleId:a,grammar:r,priority:n.priority})}function d(e,t){if(t.length<e.length)return!1;let n=0;return e.every((e=>{for(let s=n;s<t.length;s++)if(f(t[s],e))return n=s+1,!0;return!1}))}function f(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&"."===e[n]}t.createGrammar=function(e,t,n,s,r,i,o,c){return new g(e,t,n,s,r,i,o,c)};class g{constructor(e,t,n,s,r,o,c,a){if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=a,this._basicScopeAttributesProvider=new u.BasicScopeAttributesProvider(n,s),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=c,this._grammar=m(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(const e of Object.keys(r)){const t=i.createMatchers(e,d);for(const n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:r[e]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e=[],t=this._rootScopeName,n=(e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e))(t);if(n){const s=n.injections;if(s)for(let t in s)p(e,t,s[t],this,n);const r=this._grammarRepository.injections(t);r&&r.forEach((t=>{const n=this.getExternalGrammar(t);Line truncated
//# sourceMappingURL=main.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"main.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAwB,eAAID,IAE5BD,EAAqB,eAAIC,GAC1B,CATD,CASGK,MAAM,WACT,M,sCCNAC,OAAOC,eAAeN,EAAS,aAAc,CAAEO,OAAO,IACtDP,EAAQQ,wBAA0BR,EAAQS,gBAAa,EACvDT,EAAQS,WAAa,CACjBC,YAAiC,oBAAZC,WAA6BA,QAAQC,IAA2B,uBAEzFZ,EAAQQ,yBAA0B,C,aCFlC,IAAWK,EAHXR,OAAOC,eAAeN,EAAS,aAAc,CAAEO,OAAO,IACtDP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AAa,CAC5C,MAAMtB,EAAWZ,EAAUa,eAAeL,EAAUM,GACpD,IAAK,MAAMK,KAAWP,EAClB7F,KAAKkI,mBAAmB7B,KAAK,CACzBD,QAASA,EAAQA,QACjBgC,KAAMjB,EAAW1B,IAG7B,CAER,CACI4C,oBAAkB,OAAOrI,KAAK8H,kBAAoB,CACtDQ,UACI,IAAK,MAAM5C,KAAQ1F,KAAK4H,aAChBlC,GACAA,EAAK4C,SAGjB,CACAC,kBAAkBC,GACd,OAAOxI,KAAKwH,SAASe,kBAAkBC,EAC3C,CACAC,iBAAiBD,GACb,OAAOxI,KAAKwH,Line truncated
+8
View File
@@ -0,0 +1,8 @@
export interface MatcherWithPriority<T> {
matcher: Matcher<T>;
priority: -1 | 0 | 1;
}
export interface Matcher<T> {
(matcherInput: T): boolean;
}
export declare function createMatchers<T>(selector: string, matchesName: (names: string[], matcherInput: T) => boolean): MatcherWithPriority<T>[];
+42
View File
@@ -0,0 +1,42 @@
import { OrMask } from "./utils";
export interface IOnigLib {
createOnigScanner(sources: string[]): OnigScanner;
createOnigString(str: string): OnigString;
}
export interface IOnigCaptureIndex {
start: number;
end: number;
length: number;
}
export interface IOnigMatch {
index: number;
captureIndices: IOnigCaptureIndex[];
}
export declare const enum FindOption {
None = 0,
/**
* equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
*/
NotBeginString = 1,
/**
* equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
*/
NotEndString = 2,
/**
* equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
*/
NotBeginPosition = 4,
/**
* used for debugging purposes.
*/
DebugCall = 8
}
export interface OnigScanner {
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
dispose?(): void;
}
export interface OnigString {
readonly content: string;
dispose?(): void;
}
export declare function disposeOnigString(str: OnigString): void;
+2
View File
@@ -0,0 +1,2 @@
import { IRawGrammar } from './rawGrammar';
export declare function parseRawGrammar(content: string, filePath?: string | null): IRawGrammar;
+5
View File
@@ -0,0 +1,5 @@
export declare function parseWithLocation(content: string, filename: string | null, locationKeyName: string | null): any;
/**
* A very fast plist parser
*/
export declare function parsePLIST(content: string): any;
+48
View File
@@ -0,0 +1,48 @@
import { RuleId } from "./rule";
export interface ILocation {
readonly filename: string;
readonly line: number;
readonly char: number;
}
export interface ILocatable {
readonly $vscodeTextmateLocation?: ILocation;
}
export interface IRawGrammar extends ILocatable {
repository: IRawRepository;
readonly scopeName: string;
readonly patterns: IRawRule[];
readonly injections?: {
[expression: string]: IRawRule;
};
readonly injectionSelector?: string;
readonly fileTypes?: string[];
readonly name?: string;
readonly firstLineMatch?: string;
}
export interface IRawRepositoryMap {
[name: string]: IRawRule;
$self: IRawRule;
$base: IRawRule;
}
export declare type IRawRepository = IRawRepositoryMap & ILocatable;
export interface IRawRule extends ILocatable {
id?: RuleId;
readonly include?: string;
readonly name?: string;
readonly contentName?: string;
readonly match?: string;
readonly captures?: IRawCaptures;
readonly begin?: string;
readonly beginCaptures?: IRawCaptures;
readonly end?: string;
readonly endCaptures?: IRawCaptures;
readonly while?: string;
readonly whileCaptures?: IRawCaptures;
readonly patterns?: IRawRule[];
readonly repository?: IRawRepository;
readonly applyEndPatternLast?: boolean;
}
export interface IRawCapturesMap {
[captureId: string]: IRawRule;
}
export declare type IRawCaptures = IRawCapturesMap & ILocatable;
+40
View File
@@ -0,0 +1,40 @@
import { BalancedBracketSelectors, IGrammarRepository, IThemeProvider } from './grammar';
import { IRawGrammar } from './rawGrammar';
import { IGrammar, IEmbeddedLanguagesMap, ITokenTypeMap } from './main';
import { ScopeStack, Theme, StyleAttributes, ScopeName } from './theme';
import { IOnigLib } from './onigLib';
export declare class SyncRegistry implements IGrammarRepository, IThemeProvider {
private readonly _onigLibPromise;
private readonly _grammars;
private readonly _rawGrammars;
private readonly _injectionGrammars;
private _theme;
constructor(theme: Theme, _onigLibPromise: Promise<IOnigLib>);
dispose(): void;
setTheme(theme: Theme): void;
getColorMap(): string[];
/**
* Add `grammar` to registry and return a list of referenced scope names
*/
addGrammar(grammar: IRawGrammar, injectionScopeNames?: ScopeName[]): void;
/**
* Lookup a raw grammar.
*/
lookup(scopeName: ScopeName): IRawGrammar | undefined;
/**
* Returns the injections for the given grammar
*/
injections(targetScope: ScopeName): ScopeName[];
/**
* Get the default theme settings
*/
getDefaults(): StyleAttributes;
/**
* Match a scope in the theme.
*/
themeMatch(scopePath: ScopeStack): StyleAttributes | null;
/**
* Lookup a grammar.
*/
grammarForScopeName(scopeName: ScopeName, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null): Promise<IGrammar | null>;
}
+163
View File
@@ -0,0 +1,163 @@
import { OrMask } from './utils';
import { IOnigLib, IOnigCaptureIndex, FindOption, OnigString } from './onigLib';
import { ILocation, IRawGrammar, IRawRepository, IRawRule } from './rawGrammar';
declare const ruleIdSymbol: unique symbol;
export declare type RuleId = {
__brand: typeof ruleIdSymbol;
};
export declare const endRuleId = -1;
export declare const whileRuleId = -2;
export declare function ruleIdFromNumber(id: number): RuleId;
export declare function ruleIdToNumber(id: RuleId): number;
export interface IRuleRegistry {
getRule(ruleId: RuleId): Rule;
registerRule<T extends Rule>(factory: (id: RuleId) => T): T;
}
export interface IGrammarRegistry {
getExternalGrammar(scopeName: string, repository: IRawRepository): IRawGrammar | null | undefined;
}
export interface IRuleFactoryHelper extends IRuleRegistry, IGrammarRegistry {
}
export declare abstract class Rule {
readonly $location: ILocation | undefined;
readonly id: RuleId;
private readonly _nameIsCapturing;
private readonly _name;
private readonly _contentNameIsCapturing;
private readonly _contentName;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined);
abstract dispose(): void;
get debugName(): string;
getName(lineText: string | null, captureIndices: IOnigCaptureIndex[] | null): string | null;
getContentName(lineText: string, captureIndices: IOnigCaptureIndex[]): string | null;
abstract collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
abstract compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null): CompiledRule;
abstract compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null, allowA: boolean, allowG: boolean): CompiledRule;
}
export interface ICompilePatternsResult {
readonly patterns: RuleId[];
readonly hasMissingPatterns: boolean;
}
export declare class CaptureRule extends Rule {
readonly retokenizeCapturedWithRuleId: RuleId | 0;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, retokenizeCapturedWithRuleId: RuleId | 0);
dispose(): void;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
}
export declare class MatchRule extends Rule {
private readonly _match;
readonly captures: (CaptureRule | null)[];
private _cachedCompiledPatterns;
constructor($location: ILocation | undefined, id: RuleId, name: string | undefined, match: string, captures: (CaptureRule | null)[]);
dispose(): void;
get debugMatchRegExp(): string;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
private _getCachedCompiledPatterns;
}
export declare class IncludeOnlyRule extends Rule {
readonly hasMissingPatterns: boolean;
readonly patterns: RuleId[];
private _cachedCompiledPatterns;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, patterns: ICompilePatternsResult);
dispose(): void;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
private _getCachedCompiledPatterns;
}
export declare class BeginEndRule extends Rule {
private readonly _begin;
readonly beginCaptures: (CaptureRule | null)[];
private readonly _end;
readonly endHasBackReferences: boolean;
readonly endCaptures: (CaptureRule | null)[];
readonly applyEndPatternLast: boolean;
readonly hasMissingPatterns: boolean;
readonly patterns: RuleId[];
private _cachedCompiledPatterns;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, begin: string, beginCaptures: (CaptureRule | null)[], end: string | undefined, endCaptures: (CaptureRule | null)[], applyEndPatternLast: boolean | undefined, patterns: ICompilePatternsResult);
dispose(): void;
get debugBeginRegExp(): string;
get debugEndRegExp(): string;
getEndWithResolvedBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
private _getCachedCompiledPatterns;
}
export declare class BeginWhileRule extends Rule {
private readonly _begin;
readonly beginCaptures: (CaptureRule | null)[];
readonly whileCaptures: (CaptureRule | null)[];
private readonly _while;
readonly whileHasBackReferences: boolean;
readonly hasMissingPatterns: boolean;
readonly patterns: RuleId[];
private _cachedCompiledPatterns;
private _cachedCompiledWhilePatterns;
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, begin: string, beginCaptures: (CaptureRule | null)[], _while: string, whileCaptures: (CaptureRule | null)[], patterns: ICompilePatternsResult);
dispose(): void;
get debugBeginRegExp(): string;
get debugWhileRegExp(): string;
getWhileWithResolvedBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string;
collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule;
compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule;
private _getCachedCompiledPatterns;
compileWhile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null): CompiledRule<RuleId | typeof whileRuleId>;
compileWhileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null, allowA: boolean, allowG: boolean): CompiledRule<RuleId | typeof whileRuleId>;
private _getCachedCompiledWhilePatterns;
}
export declare class RuleFactory {
static createCaptureRule(helper: IRuleFactoryHelper, $location: ILocation | undefined, name: string | null | undefined, contentName: string | null | undefined, retokenizeCapturedWithRuleId: RuleId | 0): CaptureRule;
static getCompiledRuleId(desc: IRawRule, helper: IRuleFactoryHelper, repository: IRawRepository): RuleId;
private static _compileCaptures;
private static _compilePatterns;
}
export declare class RegExpSource<TRuleId = RuleId | typeof endRuleId> {
source: string;
readonly ruleId: TRuleId;
hasAnchor: boolean;
readonly hasBackReferences: boolean;
private _anchorCache;
constructor(regExpSource: string, ruleId: TRuleId);
clone(): RegExpSource<TRuleId>;
setSource(newSource: string): void;
resolveBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string;
private _buildAnchorCache;
resolveAnchors(allowA: boolean, allowG: boolean): string;
}
export declare class RegExpSourceList<TRuleId = RuleId | typeof endRuleId> {
private readonly _items;
private _hasAnchors;
private _cached;
private _anchorCache;
constructor();
dispose(): void;
private _disposeCaches;
push(item: RegExpSource<TRuleId>): void;
unshift(item: RegExpSource<TRuleId>): void;
length(): number;
setSource(index: number, newSource: string): void;
compile(onigLib: IOnigLib): CompiledRule<TRuleId>;
compileAG(onigLib: IOnigLib, allowA: boolean, allowG: boolean): CompiledRule<TRuleId>;
private _resolveAnchors;
}
export declare class CompiledRule<TRuleId = RuleId | typeof endRuleId> {
private readonly regExps;
private readonly rules;
private readonly scanner;
constructor(onigLib: IOnigLib, regExps: string[], rules: TRuleId[]);
dispose(): void;
toString(): string;
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IFindNextMatchResult<TRuleId> | null;
}
export interface IFindNextMatchResult<TRuleId = RuleId | typeof endRuleId> {
ruleId: TRuleId;
captureIndices: IOnigCaptureIndex[];
}
export {};
+5
View File
@@ -0,0 +1,5 @@
import './grammar.test';
import './json.test';
import './matcher.test';
import './themes.test';
import './tokenization.test';
+1
View File
@@ -0,0 +1 @@
export {};
+1
View File
@@ -0,0 +1 @@
export {};
+1
View File
@@ -0,0 +1 @@
export {};
+1
View File
@@ -0,0 +1 @@
export {};
+2
View File
@@ -0,0 +1,2 @@
import { IOnigLib } from '../onigLib';
export declare function getOniguruma(): Promise<IOnigLib>;
+33
View File
@@ -0,0 +1,33 @@
import { IOnigLib } from '../onigLib';
import { RegistryOptions } from '../main';
import { IRawGrammar } from '../rawGrammar';
export interface ILanguageRegistration {
id: string;
extensions: string[];
filenames: string[];
}
export interface IGrammarRegistration {
language: string;
scopeName: string;
path: string;
embeddedLanguages: {
[scopeName: string]: string;
};
grammar?: Promise<IRawGrammar>;
}
export declare class Resolver implements RegistryOptions {
readonly language2id: {
[languages: string]: number;
};
private _lastLanguageId;
private _id2language;
private readonly _grammars;
private readonly _languages;
readonly onigLib: Promise<IOnigLib>;
constructor(grammars: IGrammarRegistration[], languages: ILanguageRegistration[], onigLibPromise: Promise<IOnigLib>);
findLanguageByExtension(fileExtension: string): string | null;
findLanguageByFilename(filename: string): string | null;
findScopeByFilename(filename: string): string | null;
findGrammarByLanguage(language: string): IGrammarRegistration;
loadGrammar(scopeName: string): Promise<IRawGrammar | null>;
}
+14
View File
@@ -0,0 +1,14 @@
import { ThemeData } from './themes.test';
import { Resolver } from './resolver';
export declare class ThemeTest {
private static _readFile;
private static _normalizeNewLines;
private readonly EXPECTED_FILE_PATH;
private readonly tests;
readonly expected: string;
readonly testName: string;
actual: string | null;
constructor(THEMES_TEST_PATH: string, testFile: string, themeDatas: ThemeData[], resolver: Resolver);
evaluate(): Promise<any>;
writeExpected(): void;
}
@@ -0,0 +1,6 @@
import { IGrammar } from '../main';
export interface IThemedToken {
content: string;
color: string;
}
export declare function tokenizeWithTheme(colorMap: string[], fileContents: string, grammar: IGrammar): IThemedToken[];
+7
View File
@@ -0,0 +1,7 @@
import { Registry } from '../main';
import { IRawTheme } from '../theme';
export interface ThemeData {
themeName: string;
theme: IRawTheme;
registry: Registry;
}
@@ -0,0 +1 @@
export {};
+119
View File
@@ -0,0 +1,119 @@
import { OrMask } from './utils';
export declare class Theme {
private readonly _colorMap;
private readonly _defaults;
private readonly _root;
static createFromRawTheme(source: IRawTheme | undefined, colorMap?: string[]): Theme;
static createFromParsedTheme(source: ParsedThemeRule[], colorMap?: string[]): Theme;
private readonly _cachedMatchRoot;
constructor(_colorMap: ColorMap, _defaults: StyleAttributes, _root: ThemeTrieElement);
getColorMap(): string[];
getDefaults(): StyleAttributes;
match(scopePath: ScopeStack | null): StyleAttributes | null;
}
/**
* Identifiers with a binary dot operator.
* Examples: `baz` or `foo.bar`
*/
export declare type ScopeName = string;
/**
* An expression language of ScopeNames with a binary space (to indicate nesting) operator.
* Examples: `foo.bar boo.baz`
*/
export declare type ScopePath = string;
/**
* An expression language of ScopePathStr with a binary comma (to indicate alternatives) operator.
* Examples: `foo.bar boo.baz,quick quack`
*/
export declare type ScopePattern = string;
/**
* A TextMate theme.
*/
export interface IRawTheme {
readonly name?: string;
readonly settings: IRawThemeSetting[];
}
/**
* A single theme setting.
*/
export interface IRawThemeSetting {
readonly name?: string;
readonly scope?: ScopePattern | ScopePattern[];
readonly settings: {
readonly fontStyle?: string;
readonly foreground?: string;
readonly background?: string;
};
}
export declare class ScopeStack {
readonly parent: ScopeStack | null;
readonly scopeName: ScopeName;
static from(first: ScopeName, ...segments: ScopeName[]): ScopeStack;
static from(...segments: ScopeName[]): ScopeStack | null;
constructor(parent: ScopeStack | null, scopeName: ScopeName);
push(scopeName: ScopeName): ScopeStack;
getSegments(): ScopeName[];
toString(): string;
}
export declare class StyleAttributes {
readonly fontStyle: OrMask<FontStyle>;
readonly foregroundId: number;
readonly backgroundId: number;
constructor(fontStyle: OrMask<FontStyle>, foregroundId: number, backgroundId: number);
}
/**
* Parse a raw theme into rules.
*/
export declare function parseTheme(source: IRawTheme | undefined): ParsedThemeRule[];
export declare class ParsedThemeRule {
readonly scope: ScopeName;
readonly parentScopes: ScopeName[] | null;
readonly index: number;
readonly fontStyle: OrMask<FontStyle>;
readonly foreground: string | null;
readonly background: string | null;
constructor(scope: ScopeName, parentScopes: ScopeName[] | null, index: number, fontStyle: OrMask<FontStyle>, foreground: string | null, background: string | null);
}
export declare const enum FontStyle {
NotSet = -1,
None = 0,
Italic = 1,
Bold = 2,
Underline = 4,
Strikethrough = 8
}
export declare function fontStyleToString(fontStyle: OrMask<FontStyle>): string;
export declare class ColorMap {
private readonly _isFrozen;
private _lastColorId;
private _id2color;
private _color2id;
constructor(_colorMap?: string[]);
getId(color: string | null): number;
getColorMap(): string[];
}
export declare class ThemeTrieElementRule {
scopeDepth: number;
parentScopes: ScopeName[] | null;
fontStyle: number;
foreground: number;
background: number;
constructor(scopeDepth: number, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number);
clone(): ThemeTrieElementRule;
static cloneArr(arr: ThemeTrieElementRule[]): ThemeTrieElementRule[];
acceptOverwrite(scopeDepth: number, fontStyle: number, foreground: number, background: number): void;
}
export interface ITrieChildrenMap {
[segment: string]: ThemeTrieElement;
}
export declare class ThemeTrieElement {
private readonly _mainRule;
private readonly _children;
private readonly _rulesWithParentScopes;
constructor(_mainRule: ThemeTrieElementRule, rulesWithParentScopes?: ThemeTrieElementRule[], _children?: ITrieChildrenMap);
private static _sortBySpecificity;
private static _cmpBySpecificity;
match(scope: ScopeName): ThemeTrieElementRule[];
insert(scopeDepth: number, scope: ScopeName, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number): void;
private _doInsertHere;
}
+26
View File
@@ -0,0 +1,26 @@
import { IOnigCaptureIndex } from './onigLib';
export declare function clone<T>(something: T): T;
export declare function mergeObjects(target: any, ...sources: any[]): any;
export declare function basename(path: string): string;
export declare class RegexSource {
static hasCaptures(regexSource: string | null): boolean;
static replaceCaptures(regexSource: string, captureSource: string, captureIndices: IOnigCaptureIndex[]): string;
}
/**
* A union of given const enum values.
*/
export declare type OrMask<T extends number> = number;
export declare function strcmp(a: string, b: string): number;
export declare function strArrCmp(a: string[] | null, b: string[] | null): number;
export declare function isValidHexColor(hex: string): boolean;
/**
* Escapes regular expression characters in a given string
*/
export declare function escapeRegExpCharacters(value: string): string;
export declare class CachedFn<TKey, TValue> {
private readonly fn;
private readonly cache;
constructor(fn: (key: TKey) => TValue);
get(key: TKey): TValue;
}
export declare const performanceNow: () => number;