UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

161 lines (160 loc) 9.22 kB
import { FieldValueHumanify } from "../dataform/IField"; import { IErrorable } from "./IErrorable"; export declare const ObjectKeyAvoidTermList: Set<string>; export default class Utilities { static _isDebug?: boolean; static _isAppSim?: boolean; static defaultEncoding: string; static replacementChar: number; static splitUntil(stringToSplit: string, splitChar: string, untilCount: number): string[]; static parseJson(jsonString: string): object | undefined; static isScientificFloat(value: number): boolean; static isUsableAsObjectKey(term: string): boolean; /** * Returns true if the string looks like a Minecraft localization key * (e.g., "pack.name", "pack.description", "skinpack.mypack.name"). * These are dotted identifiers with no spaces, used as lookup keys * in .lang files rather than as user-visible display names. */ static isLikelyLocalizationKey(name: string): boolean; static sleep(ms: number): Promise<unknown>; static get isPreview(): boolean; static get isAppSim(): boolean; static get isDebug(): boolean; static selectJsonObject(jsonO: object, select: string, ensureObjects?: boolean): object | undefined; static removeItemInArray(objToRemove: any, stringArr: any[]): any[]; static isArrayNonNegative(arr: number[]): boolean; static arrayHasNegativeAndIsNumeric(arr: any[]): boolean; static encodeObjectWithSequentialRunLengthEncodeUsingNegative(obj: { [key: string]: any; }): void; static decodeSequentialRunLengthUsingNegative(arr: number[]): number[]; static encodeSequentialRunLengthUsingNegative(arr: number[]): number[]; static trimEllipsis(text: string, length: number): string; static makeHashFileSafe(hash: string): string; static getSimpleNumeric(num: number | undefined): string; static humanifyJsName(name: string | boolean | number): string; static getTitleFromEnum(categoryEnum: { [name: number]: string; }, topicId: number): string; static humanifyObject(sampVal: any): any; static ensureLooksLikeSentence(name: string): string; static dehumanify(val: string | boolean | number, humanify?: FieldValueHumanify): string | number | boolean; static humanify(val: string | boolean | number | number[] | string[] | object, humanify?: FieldValueHumanify): any; static ensureFirstCharIsUpperCase(name: string): string; static ensureFirstCharIsLowerCase(name: string): string; static humanifyString(val: string, humanify?: FieldValueHumanify): any; static getHumanifiedObjectNameNoSpaces(name: string | boolean | number): string; static getHumanifiedObjectName(name: string | boolean | number): string; static replaceAllCaseInsensitive(str: string, find: string, replace: string): string; static addCommasToNumber(num: number): string; static sanitizeJavascriptName(name: string): string; static wrapJavascriptNameIfNeeded(name: string, capitalizeFirst?: boolean): string; static javascriptifyName(name: string, capitalizeFirst?: boolean): string; static humanifyMinecraftNameRemoveNamespaces(name: string): string; static consistentStringifyTrimmed(value: any): string; static consistentStringify(value: any): string; static humanifyMinecraftName(name: string | boolean | number | undefined | null, doNotReverse?: boolean): string; static lowerCaseStartOfString(name: string): string; static convertToJsonKey(name: string): string; static dehumanifyMinecraftName(name: string | boolean | number): string | number | boolean; static stringFormat(templateString: string, ...vals: any[]): any; static convertToHexString(byteArray: number[]): string; static countSignificantLines(content: string): number; static stripLinesContaining(content: string, lineContains: string): string; static stripWithoutWhitespace: () => string; static stripWithWhitespace: (str: string, start: number | undefined, end: number | undefined) => string; static replaceJsonValue(jsonContent: string, attributeName: string, newValue: string): string; static makeJsonVersionAgnostic(jsonContent: string): string; static isEscaped(jsonString: string, quotePosition: number): boolean; static staticCompare(a: string, b: string): 0 | 1 | -1; static fixJsonContent(jsonString: string, { whitespace, trailingCommas }?: { whitespace?: boolean; trailingCommas?: boolean; }): string; /** * Fixes JSON content for use with comment-json parser. * Unlike fixJsonContent(), this function: * - PRESERVES comments (// and /* *\/) * - Fixes trailing commas * - Fixes control characters inside strings * * Use this when you want to parse JSON with comment-json while still * handling common JSON issues like trailing commas. * * @param jsonString The JSON string to fix * @returns Fixed JSON string with comments preserved */ static fixJsonContentForCommentJson(jsonString: string): string; static setIsDebug(boolVal: boolean): void; static getBaseUrl(url: string): string; static getDateStr(date: Date): string; static getDateFromStr(dateStr: string): Date; static monthNames: string[]; static monthShortNames: string[]; static lengthOfDictionary(d: any): number; static makeSafeForJson(content: string): string; static isAlphaNumeric(candidate: string): boolean; static getJsonObject(contents: string): any | undefined; static appendErrors(source: IErrorable, add: IErrorable, context?: string): void; static isNumeric(candidate: string): boolean; static isNumericIsh(candidate: string): boolean; static removeQuotes(candidate: string): string; static normalizeVersionString(candidate: string): string; static isVersionString(candidate: string): boolean; static isAlpha(candidate: string): boolean; static shallowCloneArray(source: any[]): any[]; static uint8ArrayToBase64(bytes: Uint8Array): string; static arrayBufferToBase64(buffer: ArrayBuffer): string; static base64ToArrayBuffer(base64buffer: string): ArrayBuffer; static base64ToUint8Array(base64buffer: string): Uint8Array<ArrayBuffer>; static _utf8ReadChar: (charStruct: { bytesRead: number; charVal: number; }, buf: DataView, readPos: number, maxBytes: number) => void; static canonicalizeId(id: string): string; static readStringUTF8(buf: DataView, byteOffset: number, bytesToRead: number): { str: string; byteLength: number; }; static readStringASCII(buf: DataView, byteOffset: number, bytesToRead: number): { str: string; byteLength: number; }; static readStringASCIIBuffer(buf: Uint8Array, byteOffset: number, bytesToRead: number): string; static _createUtf8Char(charCode: number, arr: number[]): void; static convertStringToBytes(str: string, encoding: string): any[]; static ensureNotStartsWithSlash(pathSegment: string): string; static ensureStartsWithSlash(pathSegment: string): string; static ensureEndsWithSlash(pathSegment: string): string; static ensureNotEndsWithSlash(pathSegment: string): string; static ensureStartsWithBackSlash(pathSegment: string): string; static ensureEndsWithBackSlash(pathSegment: string): string; static replaceAll(content: string, fromToken: string, toToken: string): string; static replaceAllExceptInLines(content: string, fromToken: string, toToken: string, exceptInLinesWith: string[]): string; static createRandomId(length: number): string; static createRandomLowerId(length: number): string; static canonicalizeUuid(uuidString: string): string; static isValidUuid(uuidString: string): boolean; static uuidEqual(uuidStringA: string, uuidStringB: string): boolean; static createUuid(): string; static uint8ArraysAreEqual(arrayA: Uint8Array, arrayB: Uint8Array): boolean; static throwIfUint8ArraysNotEqual(arrayA: Uint8Array, arrayB: Uint8Array): void; static getString(view: DataView, byteOffset: number, byteLength: number, encoding?: string): string; static getSimpleString(str: string): string; static getAsciiString(view: DataView, byteOffset: number, byteLength: number, encoding?: string): string; static getAsciiStringFromBytes(bytes: number[]): string; static getAsciiStringFromUint8Array(bytes: Uint8Array): string; static writeString(view: DataView, byteOffset: number, value: string, encoding: string): number; static frontPadToLength(val: string | number, length: number, pad: string): string; static getShortYear(year: number): string; static getFriendlySummaryHoursMinutesSeconds(date: Date | null): string; static getFriendlySummaryHoursMinutes(date: Date | null): string; static getFriendlySummary(date: Date): string; static getFriendlySummarySeconds(date: Date): string; static getFileFriendlySummarySeconds(date: Date): string; static getDateSummary(date: Date): string; static countChar(source: string, find: string): number; static isString(obj: any): obj is string; static isNullOrUndefined<T>(object: T | undefined | null): object is T; }