UNPKG

@bscotch/yy

Version:

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

72 lines 2.97 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.ZodEffects<z.ZodOptional<T>, undefined, T["_input"] | undefined>; export declare function fixedNumber(schema?: z.ZodNumber, digits?: number): z.ZodEffects<z.ZodEffects<z.ZodNumber, number, number | FixedNumber>, FixedNumber, number | FixedNumber>; /** * Schema for a number or bigint cast to a bigint */ export declare function bigNumber(): z.ZodEffects<z.ZodUnion<[z.ZodNumber, z.ZodBigInt]>, bigint, number | bigint>; /** * Ensure that an object is initialized to an empty * object, allowing for default fields to be populated. */ export declare function ensureObject<T extends z.ZodTypeAny>(obj: T): z.ZodEffects<T, T["_output"], unknown>; /** * 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.AnyZodObject | z.ZodEffects<any, any>>(obj: T, minItems?: number): z.ZodEffects<z.ZodArray<z.ZodTypeAny, "many">, any[], unknown>; /** * 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.ZodEffects<z.ZodEffects<z.ZodObject<{ /** Object name */ name: z.ZodString; /** Object resource path, e.g. "objects/{name}/{name}.yy" */ path: z.ZodString; }, "strip", z.ZodTypeAny, { path: string; name: string; }, { path: string; name: string; }>, { path: string; name: string; }, { path: string; name: string; }>, { path: string; name: string; }, unknown>; 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; }; //# sourceMappingURL=utility.d.ts.map