@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
129 lines (128 loc) • 5.49 kB
TypeScript
import { IAnnotatedValue } from "./AnnotatedValue";
import { HashCatalog } from "./HashUtilities";
import IContextIndexData from "./IContentIndexData";
export declare enum AnnotationCategory {
blockTextureReferenceSource = "a",
blockTypeDependent = "b",
entityComponentDependent = "c",
blockComponentDependent = "d",
entityTypeDependent = "e",
entityFilter = "f",
entityComponentDependentInGroup = "g",
blockTextureReferenceDependent = "h",
itemTypeDependent = "i",
itemComponentDependent = "j",
itemTextureReferenceSource = "k",
featureSource = "l",
featureDependent = "m",
featureRuleSource = "n",
blockComponentDependentInPermutation = "p",
storagePathDependent = "s",
textureFile = "t",
entityEvent = "v",
blockTypeSource = "B",
entityTypeSource = "E",
itemTypeSource = "I",
itemTextureSource = "J",
blockSounds = "L",
musicDefinitionSource = "M",
entitySounds = "N",
interactiveSounds = "R",
jsSource = "S",
terrainTextureSource = "T",
soundDefinitionSource = "U",
individualEventSoundsSource = "V",
worldProperty = "W",
experiment = "X",
geometrySource = "G",
animationSource = "A",
animationControllerSource = "C",
renderControllerSource = "D",
particleSource = "P",
fogSource = "F",
lootTableSource = "O",
recipeSource = "Q",
biomeSource = "Y",
spawnRuleSource = "Z",
structureSource = "r",
dialogueSource = "q",
functionSource = "u",
soundEventSource = "w",
biomeBehaviorComponentDependent = "x",
biomeClientComponentDependent = "y",
particleEmitterComponentDependent = "z",
particleComponentDependent = "pc"
}
export interface IAnnotatedIndexData {
n: number;
a: string;
}
export interface IContentIndex {
getDescendentStrings(term: string): Promise<{
[fullKey: string]: IAnnotatedValue[] | undefined;
} | undefined>;
getMatches(searchString: string, wholeTermSearch?: boolean, withAnnotation?: AnnotationCategory[]): Promise<IAnnotatedValue[] | undefined>;
startLength: number;
}
export default class ContentIndex implements IContentIndex {
#private;
private _processedPathsCache?;
private _hashCatalog;
private _itemIndexMap;
get hashCatalog(): HashCatalog;
get iteration(): number;
set iteration(newIteration: number);
static getAnnotationCategoryKeys(): string[];
static getAnnotationCategoryFromLongString(longStr: string): string;
get data(): IContextIndexData;
get startLength(): number;
get items(): string[];
setItems(items: string[]): void;
setTrie(trie: {}): void;
getAll(withAnnotation?: AnnotationCategory[]): {
[fullKey: string]: IAnnotatedValue[];
};
_appendToResults(prefix: string, node: any, results: {
[fullKey: string]: IAnnotatedValue[] | undefined;
}, withAnnotation?: AnnotationCategory[]): void;
mergeFrom(index: ContentIndex, newItem: string): void;
static processResultValues(annotatedValues: IAnnotatedValue[] | undefined, withAnyAnnotation?: AnnotationCategory[]): IAnnotatedValue[];
getValuesFromIndexArray(indices: (IAnnotatedIndexData | number)[], withAnnotation?: AnnotationCategory[]): IAnnotatedValue[] | undefined;
loadFromData(data: IContextIndexData): void;
private _getProcessedPaths;
hasPathMatches(pathEnd: string): boolean;
getPathMatches(pathEnd: string): string[];
getMatches(searchString: string, wholeTermSearch?: boolean, withAnyAnnotation?: AnnotationCategory[]): Promise<IAnnotatedValue[]>;
getTermMatchStrings(term: string): any;
getDescendentStrings(term: string): Promise<{
[fullKey: string]: IAnnotatedValue[];
}>;
getTermMatch(term: string): any;
static mergeResults(resultsArrA: (IAnnotatedValue | number)[], resultsArrB: (IAnnotatedValue | number)[]): (number | IAnnotatedValue)[];
aggregateIndices(curNode: any, arr: number[], seen?: Set<number>): void;
insertArray(key: string, items: IAnnotatedValue[]): void;
insert(key: string, item: string, annotationChar?: string): void;
ensureAnnotatedContentInArray(arr: (IAnnotatedIndexData | number)[], dataIndex: number, annotationChar?: string): any[];
parseJsContent(sourcePath: string, content: string): void;
parseTextContent(sourcePath: string, content: string): void;
parseJsonContent(sourcePath: string, content: string): void;
/**
* Extracts indexable tokens from a parsed JSON object by recursively walking keys and string values.
* Much faster than parseJsonContent which does character-by-character text tokenization.
* Only processes keys and string values (the same tokens that parseJsonContent would find).
*/
indexJsonObject(sourcePath: string, data: object): void;
/**
* Recursively collects indexable terms (keys and string values) from a parsed JSON object.
*/
/** Max nesting depth for JSON term collection. Most Minecraft JSON stays under 10 levels, but features can reach ~25. */
private static readonly MAX_JSON_DEPTH;
private static _collectJsonTerms;
/**
* Splits a string on common delimiters and adds qualifying terms.
* Matches the same tokenization logic as parseJsonContent's character loop.
*/
/** Characters that act as word boundaries when tokenizing strings for indexing. */
private static readonly TERM_DELIMITERS;
private static _addStringTerms;
}