UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

258 lines (257 loc) 13.6 kB
import Catalog from "./ICatalog"; import BlockType from "./BlockType"; import BlockBaseType from "./BlockBaseType"; import IJavaBlockTypeData from "./IJavaBlockTypeData"; import IFolder from "../storage/IFolder"; import IFormField from "../dataform/IFormField"; import ILocalUtilities from "../core/ILocalUtilities"; import ITypeDefCatalog from "./ITypeDefCatalog"; import NpmModule from "../devproject/NpmModule"; import IFormDefinition from "../dataform/IFormDefinition"; import ContentIndex, { AnnotationCategory } from "../core/ContentIndex"; import IProjectInfoData from "../info/IProjectInfoData"; import Project from "../app/Project"; import ISnippet from "../app/ISnippet"; import IGalleryItem from "../app/IGalleryItem"; import { MinecraftTrack } from "../app/ICreatorToolsData"; import IBiomesMetadata from "./IBiomesMetadata"; import IBlocksMetadata from "./IBlocksMetadata"; import ILegacyDocumentationNode from "./docs/ILegacyDocumentation"; import IEntitiesMetadata from "./IEntitiesMetadata"; import IItemsMetadata from "./IItemsMetadata"; import IDocCommandSet from "./docs/IDocCommandSet"; import { HashCatalog } from "../core/HashUtilities"; import IFile from "../storage/IFile"; import TerrainTextureCatalogDefinition from "./TerrainTextureCatalogDefinition"; import BlocksCatalogDefinition from "./BlocksCatalogDefinition"; import IContentSource from "../app/IContentSource"; export default class Database { static isVanillaLoaded: boolean; static isScriptTypesLoaded: boolean; static isContentSourcesLoaded: boolean; static vanillaCatalog: Catalog | null; static loadedFormCount: number; static _creatorToolsIngameFile: IFile | null; static _creatorToolsIngameProject: Project | null; static uxCatalog: { [formName: string]: IFormDefinition; }; private static _missingForms; static formsFolders: { [folderName: string]: IFolder; }; static modelTemplateCatalog: { [templateName: string]: object; }; static loadedModelTemplateCount: number; static stable20TypeDefs: ITypeDefCatalog | null; static libs: ITypeDefCatalog | null; static stable10TypeDefs: ITypeDefCatalog | null; static contentFolder: IFolder | null; static snippetsFolder: IFolder | null; static previewMetadataFolder: IFolder | null; static releaseMetadataFolder: IFolder | null; static previewVanillaFolder: IFolder | null; static releaseVanillaFolder: IFolder | null; static serveVanillaFolder: IFolder | null; static samplesFolder: IFolder | null; static releaseVanillaBehaviorPackFolder: IFolder | null; static releaseVanillaResourcePackFolder: IFolder | null; static local: ILocalUtilities | null; static vanillaInfoData: IProjectInfoData | null; static vanillaContentIndex: ContentIndex | null; static blocksCatalog: BlocksCatalogDefinition | undefined; static terrainTextureCatalog: TerrainTextureCatalogDefinition | undefined; static previewVanillaInfoData: IProjectInfoData | null; static previewVanillaContentIndex: ContentIndex | null; static releaseVanillaContentHashes: HashCatalog | null; private static _isLoadingReleaseVanillaHashes; private static _pendingLoadReleaseVanillaHashRequests; static samplesInfoData: IProjectInfoData | null; static samplesContentIndex: ContentIndex | null; static addonsDocs: ILegacyDocumentationNode | null; static biomesMetadata: IBiomesMetadata | null; static blocksMetadata: IBlocksMetadata | null; static entitiesMetadata: IEntitiesMetadata | null; static itemsMetadata: IItemsMetadata | null; static commandsMetadata: IDocCommandSet | null; static latestVersion: string | undefined; static latestPreviewVersion: string | undefined; private static _isLoadingSnippets; private static _pendingLoadSnippetsRequests; private static _isLoadingVanillaResourceDefinition; private static _pendingLoadVanillaResourceDefinitionRequests; private static _isLoadingVanillaInfoData; private static _pendingLoadVanillaInfoDataRequests; private static _isLoadingPreviewVanillaInfoData; private static _pendingLoadPreviewVanillaInfoDataRequests; private static _isLoadingSamples; private static _pendingLoadSamplesRequests; static dataPath: string; static creatorToolsIngameBehaviorPackUUID: string; static creatorToolsIngameBehaviorPackVersion: number[]; static creatorToolsIngameResourcePackUUID: string; static creatorToolsIngameResourcePackVersion: number[]; static minecraftEduVersion: string; static minecraftEduPreviewVersion: string; static fallbackMinecraftVersion: string; static fallbackMinecraftPreviewVersion: string; static defaultContentSources: IContentSource[]; static contentSources: IContentSource[]; /** * Gets all known Minecraft script module names. * Delegates to ScriptModuleInfoProvider which is the single source of truth. */ static get minecraftModuleNames(): string[]; static maxMinecraftPatchVersions: { "1.19": string; "1.20": string; "1.21": string; }; static moduleDescriptors: { [id: string]: NpmModule; }; static blockTypes: { [id: string]: BlockType; }; static schemaContents: { [id: string]: object; }; static officialSchemaContents: { [id: string]: object; }; static blockBaseTypes: { [id: string]: BlockBaseType; }; static _blockTypesByLegacyId: BlockType[] | undefined; static javaBlockTypeData: { [id: string]: IJavaBlockTypeData; }; static _defaultBlockBaseType?: BlockBaseType; static get defaultBlockBaseType(): BlockBaseType; static ensureFormLoadedByPath(path: string): Promise<IFormDefinition | undefined>; /** * Clears cached folder references for bulk content (vanilla, samples) to free memory. * This should be called after bulk operations like documentation generation are complete. */ static clearBulkContentCaches(): void; /** * Reads a JSON file directly from the preview vanilla content without using the folder abstraction. * This avoids caching File/Folder objects in memory, which is important for batch processing. * @param relativePath Path relative to the vanilla preview root (e.g., "/behavior_pack/entities/pig.json") * @returns The parsed JSON object, or null if the file doesn't exist or can't be parsed */ static readPreviewVanillaJsonFile(relativePath: string): Promise<object | null>; /** * Reads a JSON file directly from the samples content without using the folder abstraction. * This avoids caching File/Folder objects in memory, which is important for batch processing. * @param relativePath Path relative to the samples root (e.g., "/behavior_packs/example/entities/pig.json") * @returns The parsed JSON object, or null if the file doesn't exist or can't be parsed */ static readSamplesJsonFile(relativePath: string): Promise<object | null>; static getFormName(subFolder: string, name: string): string; static isFormLoaded(subFolder: string, name: string): boolean; /** * Forms are loaded from a single canonical location: `data/forms/`. * * Generation: the `gulp copybedrockschemas` task lays down * `@minecraft/bedrock-schemas`'s upstream forms first, then OVERLAYS our * checked-in overrides from `app/public_supplemental/data/local_forms/` * directly on top of them (same-named files replace upstream copies). * * The result is a single merged tree at `public/data/forms/` (or * `toolbuild/vsc/data/forms/` for the VSC extension), so this loader does * not need a runtime fallback chain — there is only one place to look. * * To extend or replace an upstream form, drop a same-pathed file under * `app/public_supplemental/data/local_forms/<sub>/<name>.form.json` and * rebuild. To unsticky an override (e.g. because upstream caught up), just * delete that file and rebuild. */ private static readonly DEFAULT_FORMS_PATH; static ensureFormLoadedSync(subFolder: string, name: string): IFormDefinition | undefined; private static _tryLoadFormSync; static ensureFormLoaded(subFolder: string, name: string): Promise<IFormDefinition | undefined>; private static _tryLoadForm; static isModelTemplateLoaded(name: string): boolean; static getModelTemplate(name: string): object | undefined; static ensureModelTemplateLoaded(name: string): Promise<object | undefined>; static getModelTemplateNames(): Promise<string[]>; static getFormsFolder(subFolder: string): Promise<IFolder>; static getFormByPath(path: string): IFormDefinition | undefined; static getForm(subFolder: string, name: string): IFormDefinition | undefined; static getBlockType(name: string): BlockType; static populateBlockTypesByLegacyId(): void; static getModuleDescriptor(moduleId: string): Promise<NpmModule>; static getNextMinecraftPreviewVersion(): Promise<any>; static getLatestMinecraftPreviewVersion(): Promise<string>; static getLatestMinecraftRetailVersion(): Promise<string>; static isRecentVersionFromVersionArray(version: number[] | undefined): Promise<boolean>; static getContentFolderFile(fileRelativePath: string): Promise<IFile>; static getContentFolderContent(fileRelativePath: string): Promise<string | Uint8Array<ArrayBufferLike>>; static ensureCreatorToolsIngameFile(): Promise<IFile>; static ensureCreatorToolsIngameProject(): Promise<Project>; static getLatestVersionInfo(track: MinecraftTrack, force?: boolean): Promise<string>; static getVersionIsPreview(ver: string): boolean; static getVersionIndexFromVersionStr(ver: string): number; static getBlockTypeByLegacyId(id: number): BlockType; static getMatchingBlocks(searchTerm: string): any[]; static ensureBlockType(name: string): BlockType; static ensureBlockBaseType(name: string): BlockBaseType; static loadContentSources(): Promise<IContentSource[]>; static loadContent(): Promise<void>; static initSnippetsFolder(): Promise<void>; static itemMatchesSearch(item: IGalleryItem, searchString?: string): boolean; static getSnippet(sampleSet: string, snippetId: string): Promise<ISnippet>; static getAddonsDocs(): Promise<ILegacyDocumentationNode>; static getBiomesMetadata(): Promise<IBiomesMetadata>; static getBlocksMetadata(): Promise<IBlocksMetadata>; static getEntitiesMetadata(): Promise<IEntitiesMetadata>; static getItemsMetadata(): Promise<IItemsMetadata>; static getCommandsMetadata(): Promise<IDocCommandSet | null>; static getMetadataObject(metaPath: string): Promise<any>; static getPreviewVanillaFile(filePath: string): Promise<IFile>; static getPreviewVanillaObject(filePath: string): Promise<any>; static loadPreviewMetadataFolder(): Promise<IFolder>; static loadReleaseMetadataFolder(): Promise<IFolder>; static getReleaseVanillaFolder(): Promise<IFolder>; static getPreviewVanillaFolder(): Promise<IFolder>; static getServeVanillaFolder(): Promise<IFolder>; static getSamplesFolder(): Promise<IFolder>; static getReleaseVanillaBehaviorPackFolder(): Promise<IFolder>; static getReleaseVanillaResourcePackFolder(): Promise<IFolder>; static loadUx(): Promise<void>; static getComponentFormField(propertyName: string): IFormField | undefined; static getCommunitySchema(path: string): Promise<object>; /** * Get a schema from the official schemas folder (public/schemas) rather than * the community schemas folder (public/res/latest/schemas). */ static getOfficialSchema(path: string): Promise<object | undefined>; static loadStable20ScriptTypes(): Promise<void>; static loadStable10ScriptTypes(): Promise<void>; static getLibs(): Promise<ITypeDefCatalog>; static matchesVanillaPath(path: string): Promise<boolean>; static getVanillaPathList(): Promise<any[]>; static matchesVanillaPathFromIndex(path: string): Promise<boolean>; static isVanillaToken(path: string): Promise<boolean>; static getVanillaAll(withAnnotation?: AnnotationCategory[]): Promise<{ [fullKey: string]: import("../core/AnnotatedValue").IAnnotatedValue[]; }>; static getVanillaMatches(path: string, wholeTermSearch?: boolean, withAnnotation?: AnnotationCategory[]): Promise<import("../core/AnnotatedValue").IAnnotatedValue[]>; static getPreviewVanillaMatches(path: string, wholeTermSearch?: boolean, withAnnotation?: AnnotationCategory[]): Promise<import("../core/AnnotatedValue").IAnnotatedValue[]>; static getSamplesMatches(path: string, wholeTermSearch?: boolean, withAnnotation?: AnnotationCategory[]): Promise<import("../core/AnnotatedValue").IAnnotatedValue[]>; static loadVanillaInfoData(): Promise<void>; static loadVanillaResourceDefinitions(): Promise<void>; static loadPreviewVanillaInfoData(): Promise<void>; static loadReleaseVanillaInfoHashes(): Promise<void>; static loadSampleInfoData(): Promise<void>; static loadVanillaCatalog(): Promise<void>; /** * Normalizes a catalog from the old unabbreviated format (name, icon, mapColor, shape) * to the current abbreviated format (n, ic, mc, sh). This allows loading catalogs * produced by older tooling or external repos that haven't migrated yet. */ private static normalizeCatalog; private static extendCatalog; }