UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

209 lines (208 loc) 11.5 kB
import ProjectItem from "../app/ProjectItem"; import Project from "./../app/Project"; import IProjectInfoGenerator from "./IProjectInfoGenerator"; import IProjectItemInfoGenerator from "./IProjectItemInfoGenerator"; import IProjectFileInfoGenerator from "./IProjectFileInfoGenerator"; import IProjectInfo from "./IProjectInfo"; import ProjectInfoItem from "./ProjectInfoItem"; import IFolder from "../storage/IFolder"; import IInfoItemData, { InfoItemType } from "./IInfoItemData"; import IProjectInfoGeneratorBase, { IProjectInfoTopicData } from "./IProjectInfoGeneratorBase"; import IProjectInfoData, { ProjectInfoSuite } from "./IProjectInfoData"; import ContentIndex from "../core/ContentIndex"; import IProjectMetaState from "./IProjectMetaState"; /** * Controls how aggressively generators should constrain resource consumption. * Use this to balance between thoroughness and performance/memory usage. */ export declare enum ResourceConsumptionConstraint { /** No constraints - process all data regardless of resource usage */ none = 0, /** Medium constraints - apply reasonable limits to prevent excessive resource usage */ medium = 5 } /** * Options passed to info generators to control their behavior. */ export interface IGeneratorOptions { /** * When true, generators may perform aggressive memory cleanup operations * after processing (e.g., clearing LevelDB data, chunk caches). * This is appropriate for fire-and-forget contexts like CLI validation, * but should be false when the data may be needed by other components * (e.g., world map rendering in the browser). */ performAggressiveCleanup?: boolean; /** * Controls how aggressively generators should limit resource consumption. * When set to .medium, generators may apply limits like MaxWorldRecordsToProcess * to prevent excessive memory or time usage on large datasets. * When set to .none, no such limits are applied. * Defaults to .medium if not specified. */ constrainResourceConsumption?: ResourceConsumptionConstraint; /** * Optional callback for reporting progress during generation. * Generators can call this to provide granular progress updates, * especially for long-running operations like world data validation. * @param message - A descriptive message about the current operation * @param percentComplete - Optional percentage (0-100) of completion */ onProgress?: (message: string, percentComplete?: number) => void; } export default class ProjectInfoSet { project?: Project; suite: ProjectInfoSuite; info: IProjectInfo; items: ProjectInfoItem[]; itemsByStoragePath: { [storagePath: string]: ProjectInfoItem[] | undefined; }; contentIndex: ContentIndex; performAggressiveCleanup: boolean; constrainResourceConsumption: ResourceConsumptionConstraint; static _generatorsById: { [name: string]: IProjectInfoGenerator; }; _isGenerating: boolean; _completedGeneration: boolean; _excludeTests?: string[]; private _pendingGenerateRequests; static CommonCsvHeader: string; static getSuiteFromString(suiteName: string): ProjectInfoSuite; static getSuiteString(suite: ProjectInfoSuite): "all" | "addon" | "sharing" | "sharingstrict" | "currentplatform"; get completedGeneration(): boolean; /** * Mark generation as complete. Used when results are provided externally * (e.g., from a web worker). */ markGenerationCompleteAsync(): Promise<void>; /** * Runs lightweight annotation-producing generators against the contentIndex. * This populates cross-reference annotations (geometry IDs, animation names, * entity/block/item types, etc.) that power autocomplete suggestions. * * Called after _buildContentIndexFromProject() in the web worker path, * since the worker's ContentIndex (with all annotations) is not transferred back. * The project files are already loaded in memory, so this runs quickly. */ private _populateContentIndexAnnotationsAsync; /** * Populates the contentIndex by scanning all project items and their files. * This is needed when the info set was generated via a web worker, which * doesn't build or transfer the content index. */ private _buildContentIndexFromProject; /** * Rebuilds the itemsByStoragePath index from the items array. * This is needed when items are set externally (e.g., from a web worker). */ private _rebuildItemsByStoragePath; get errorAndFailCount(): number; get errorFailWarnCount(): number; get errorFailWarnString(): string; constructor(project?: Project, suite?: ProjectInfoSuite, excludeTests?: string[], info?: IProjectInfo, items?: IInfoItemData[], index?: ContentIndex, performAggressiveCleanup?: boolean); static getTopicData(id: string, index: number): IProjectInfoTopicData | undefined; private static _getLineLocationFromIndex; static findLineLocationForItem(content: string, item: ProjectInfoItem): Promise<{ lineNumber: number; column: number; } | undefined>; getCountByType(itemType: InfoItemType): number; getSummaryByType(itemType: InfoItemType): string; matchesSuite(generator: IProjectFileInfoGenerator | IProjectInfoGenerator | IProjectItemInfoGenerator | IProjectInfoGeneratorBase): boolean; /** * Generate info items for the project. * @param force If true, regenerate even if already completed. * @param skipRelationsProcessing If true, skip the processRelations call (useful when relations * have already been processed, e.g., in a combined worker operation). * @param onProgress Optional callback for progress updates (useful for worker thread communication). */ generateForProject(force?: boolean, skipRelationsProcessing?: boolean, onProgress?: (message: string, percentComplete?: number) => void): Promise<void>; disconnectFromProject(): void; addTestSummations(genItems: ProjectInfoItem[], genItemsByStoragePath: { [storagePath: string]: ProjectInfoItem[] | undefined; }, generators: IProjectInfoGeneratorBase[], excludeTests?: string[]): void; pushItem(itemSet: ProjectInfoItem[], itemsByStoragePath: { [storagePath: string]: ProjectInfoItem[] | undefined; }, item: ProjectInfoItem): void; mergeFeatureSetsAndFieldsTo(allFeatureSets: { [setName: string]: { [measureName: string]: number | undefined; } | undefined; }, allFields: { [featureName: string]: boolean | undefined; }): void; ensureGenerators(): void; itemToString(item: ProjectInfoItem): string; static getExtendedMessageFromData(data: IProjectInfoData, item: IInfoItemData): string; static getEffectiveMessageFromData(data: IProjectInfoData, item: IInfoItemData): string; getEffectiveMessage(item: ProjectInfoItem): string; shouldIncludeInIndex(data: IInfoItemData): boolean; getDataObject(sourceName?: string, sourcePath?: string, sourceHash?: string, isIndexOnly?: boolean, subsetReports?: IProjectMetaState[]): IProjectInfoData; static isAggregableFieldName(name: string): boolean; static isAggregableFeatureMeasureName(name: string): boolean; static getSummaryCsvHeaderLine(projectInfo: IProjectInfo, allFeatures: { [setName: string]: { [measureName: string]: number | undefined; } | undefined; }): string; getIndexJson(sourceName?: string, sourcePath?: string, sourceHash?: string): string; getStrictIndexJson(sourceName?: string, sourcePath?: string, sourceHash?: string): string; getReportHtml(sourceName?: string, sourcePath?: string, sourceHash?: string): string; static getDataSummary(data: any | undefined): string; /** * Sanitizes a string value for safe inclusion inside a quoted CSV field. * Replaces double quotes with single quotes, and strips newlines/carriage returns * so that the value doesn't create phantom rows in the CSV output. */ static csvSanitize(value: string): string; static sortMinecraftFeatures(a: string, b: string): 0 | 1 | -1; getArea(title: string): "Furniture" | "Skyblock" | "One block" | "Lucky" | "Parkour" | "Survival" | "Tools" | "Roleplay" | "Mob" | "Vehicles" | "Area" | "Simulator" | "General"; getRed(): number; getSummaryCsvLine(containerName: string, title: string, allFeatures: { [setName: string]: { [measureName: string]: number | undefined; } | undefined; } | undefined): string; getItemCsvLines(): string[]; getItems(generatorId: string, itemIndex: number): ProjectInfoItem[]; getItemsByType(generatorId: string, itemType: InfoItemType): ProjectInfoItem[]; getItemsByStoragePath(path: string): ProjectInfoItem[]; static getItemsInCollection(genItems: ProjectInfoItem[], generatorId: string): ProjectInfoItem[]; static getItemsInCollectionByType(genItems: ProjectInfoItem[], generatorId: string, itemType: InfoItemType): ProjectInfoItem[]; preProcessFolder(project: Project, folder: IFolder, genItems: ProjectInfoItem[], genItemsByStoragePath: { [storagePath: string]: ProjectInfoItem[] | undefined; }, genContentIndex: ContentIndex, fileGenerators: IProjectFileInfoGenerator[], depth: number): Promise<void>; processFolder(project: Project, folder: IFolder, genItems: ProjectInfoItem[], genItemsByStoragePath: { [storagePath: string]: ProjectInfoItem[] | undefined; }, genContentIndex: ContentIndex, fileGenerators: IProjectFileInfoGenerator[], depth: number): Promise<void>; static isFolderThatShouldBeProcessed(folder: IFolder): boolean; generateProjectMetaInfo(): void; addObjectsToArray(validatorName: string, validatorId: number, parentArray: object[]): void; getFirstStringValue(validatorName: string, validatorId: number): string; removeItems(validatorName: string, validatorIds: number[]): void; getGeneratorForItem(item: ProjectInfoItem): IProjectInfoGeneratorBase | undefined; getItemSummary(item: ProjectInfoItem): string; /** * Gets a stable key for aggregation purposes based on the form.json field title. * Uses getItemSummary() which returns the form.json title (e.g., "Texture Images"), * then convertToJsonKey() transforms it to camelCase (e.g., "textureImages"). * This produces consistent JSON keys in validation reports. */ getItemAggregationKey(item: ProjectInfoItem): string; aggregateFeatures(): void; getFirstNumberDataValue(validatorName: string, validatorId: number): number; getAverageFeatureValue(validatorName: string, validatorId: number, setName: string, measureName: string): number; getSummedFeatureValue(validatorName: string, validatorId: number, setName: string, measureName: string): number; getFeaturesWithInstances(validatorName: string, validatorId: number): string[]; getSummedDataValue(validatorName: string, validatorId: number): number; getCount(validatorName: string, validatorId: number): number; getMinNumberArrayValueAsVersionString(validatorName: string, validatorId: number): any; getFirstNumberArrayValueAsVersionString(validatorName: string, validatorId: number): string; getInfoForItem(projectItem: ProjectItem, contentIndex: ContentIndex): Promise<ProjectInfoItem[]>; /** * Gets the hash catalog as JSON string */ getHashCatalogJson(): string; }