// @internal declare module '~sdk/all-composites' { export const compositeFromLoader: Record } // @internal declare module '~sdk/script-utils' { type Entity = number; // this will get replaced with the proper import at scene build time /** * Registry interface that maps script paths to their types. * This interface is populated at build time with actual script paths. * It starts empty and gets augmented during scene builds. */ export interface ScriptRegistry {} /** * Type utility to extract the instance type from a script module. * For class-based scripts, extracts the class instance type. * For functional scripts, returns the module type itself. */ export type ExtractScriptType = T extends Record ? { [K in keyof T]: T[K] extends new (...args: any[]) => infer Instance ? Instance : never }[keyof T] extends never ? T : { [K in keyof T]: T[K] extends new (...args: any[]) => infer Instance ? Instance : never }[keyof T] : never /** * A callback function that triggers an action on an entity. * Use this type for script parameters that should trigger actions configured in the editor. * * @example * ```typescript * import type { ActionCallback } from '~sdk/script-utils' * * export class Padlock { * constructor( * public src: string, * public entity: Entity, * public onUnlock: ActionCallback * ) {} * * solve() { * this.onUnlock() // Triggers the action selected in the editor * } * } * ``` */ export type ActionCallback = () => void /** * @deprecated * @internal This function is called automatically by the SDK entry point. * Users should not call this function directly. */ export function _initializeScripts(engine: any): void /** * Get a specific script instance by entity and script path. * TypeScript will automatically infer the return type based on the script path. */ export function getScriptInstance(entity: Entity, scriptPath: K): ScriptRegistry[K] | null export function getScriptInstance(entity: Entity, scriptPath: string): T | null /** * Get all instances of a specific script (across all entities). * TypeScript will automatically infer the instance type based on the script path. */ export function getScriptInstancesByPath(scriptPath: K): Array<{ entity: Entity; instance: ScriptRegistry[K] }> export function getScriptInstancesByPath(scriptPath: string): Array<{ entity: Entity; instance: T }> /** * Get all script instances attached to a specific entity */ export function getAllScriptInstances(entity: Entity): Array<{ path: string; instance: any }> /** * Call a method on a script instance (with safety checks). * TypeScript will automatically infer method names, parameter types, and return types. */ export function callScriptMethod< K extends keyof ScriptRegistry, M extends keyof ScriptRegistry[K] >( entity: Entity, scriptPath: K, methodName: M, ...args: ScriptRegistry[K][M] extends (...args: infer P) => any ? P : never ): ScriptRegistry[K][M] extends (...args: any[]) => infer R ? R : never export function callScriptMethod(entity: Entity, scriptPath: string, methodName: string, ...args: any[]): any }