UNPKG

@bscotch/yy

Version:

Stringify, parse, read, and write GameMaker yy and yyp files.

65 lines 3 kB
import { z } from 'zod'; import type { YyResourceType } from './YyBase.js'; import type { YypResourceId } from './Yyp.js'; export declare const nameField = "%Name"; export declare function randomString(length?: number): string; export declare class FixedNumber extends Number { readonly digits: number; constructor(value: number | FixedNumber, digits?: number); [Symbol.toPrimitive](hint: 'number' | 'default'): number; [Symbol.toPrimitive](hint: 'string'): string; toString(): string; toJSON(): number; } /** * A wrapper that transforms the wrapped value to `undefined` and marks it as optional. * Useful for fields you want to provide for extra * information when transforming parents, since the * `z.input<>` inferred type will show this field, * but that don't normally exist in the source data. */ export declare function hint<T extends z.ZodTypeAny>(schema: T): z.ZodPipe<z.ZodOptional<T>, z.ZodTransform<undefined, z.core.output<T> | undefined>>; export declare const fixed0: FixedNumber; export declare const fixed1: FixedNumber; export declare function fixedNumber(schema?: z.ZodNumber, digits?: number): z.ZodPipe<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>, z.ZodTransform<FixedNumber, number>>; /** * Schema for a number or bigint cast to a bigint */ export declare function bigNumber(): z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodBigInt]>, z.ZodTransform<bigint, number | bigint>>; /** * Ensure that an array is initialized to an array with * at least one element, allowing for defaults to be * populated in each element. */ export declare function ensureObjects<T extends z.ZodObject>(obj: T, minItems?: number): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodArray<T>>; /** * Shorthand for a `ZodObject` instance that doesn't strip * out any unknown keys, and that logs unexpected keys to * the console. */ export declare function unstable<T extends z.ZodRawShape>(shape: T): z.ZodObject<T>; export declare function getYyResourceId(yyType: YyResourceType, name: string): YypResourceId; export declare function yyResourceIdSchemaGenerator(yyType: YyResourceType): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{ name: z.ZodString; path: z.ZodString; }, z.core.$strip>>; export declare function yyIsNewFormat<T>(yyData: T): yyData is T & { '%Name': string; }; export declare function isObjectWithField<F extends string>(obj: unknown, field: F): obj is Record<string, unknown> & { [K in F]: unknown; }; export declare function assert(claim: any, message: string): asserts claim; export declare function toPosixPath(path: string): string; export declare function parsePath(path: string): { filename: string; fullpath: string; parent: string; ext: `.${string}`; }; /** * Join path parts, ensuring exactly one POSIX separator is between * each part. Maintains initial and final seps. */ export declare function joinPaths(...parts: string[]): string; //# sourceMappingURL=utility.d.ts.map