@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
56 lines (55 loc) • 2.59 kB
TypeScript
import IFormDefinition from "../dataform/IFormDefinition";
import { IProjectInfoTopicData } from "./IProjectInfoGeneratorBase";
/**
* Utility class for managing info generator topic data from form.json files.
* Topic metadata (titles, descriptions, updaters) is stored in form.json files
* in the public/data/forms/mctoolsval/ folder, with each generator having its own form file.
*/
export default class InfoGeneratorTopicUtilities {
private static _topicFormsByGeneratorId;
private static _loadingPromises;
/**
* Gets topic data for a specific generator and topic ID from form.json files.
* Returns undefined if no form file exists for the generator or if the topic is not found.
* @param generatorId The ID of the generator (e.g., "CADDONREQ", "MCFUNCTION")
* @param topicId The numeric topic ID (typically from an enum like 101, 102, etc.)
* @returns The topic data including title and optional updaters, or undefined if not found
*/
static getTopicData(generatorId: string, topicId: number): Promise<IProjectInfoTopicData | undefined>;
/**
* Gets topic data synchronously from already-loaded form data.
* Returns undefined if the form hasn't been loaded yet or if the topic is not found.
* @param generatorId The ID of the generator
* @param topicId The numeric topic ID
* @returns The topic data or undefined
*/
static getTopicDataSync(generatorId: string, topicId: number): IProjectInfoTopicData | undefined;
/**
* Extracts topic data from a form definition for a given topic ID.
* For summary items (topicId 0 or 1), returns the form's root title/description if no specific field is found.
*/
private static getTopicDataFromForm;
/**
* Ensures that the form.json file for a generator is loaded.
* @param generatorId The ID of the generator
* @returns The form definition or undefined if not found
*/
static ensureFormLoaded(generatorId: string): Promise<IFormDefinition | undefined>;
/**
* Loads a form.json file for a generator.
*/
private static loadForm;
/**
* Checks if a form is loaded for a generator.
*/
static isFormLoaded(generatorId: string): boolean;
/**
* Preloads forms for all known generators.
* This can be called at startup to ensure all forms are available synchronously later.
*/
static preloadAllForms(generatorIds: string[]): Promise<void>;
/**
* Clears all cached forms. Useful for testing or hot-reloading.
*/
static clearCache(): void;
}