Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

893 B
Raw Blame
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
/**
 * @file presets.ts
 * @brief ESEngine loader entry point
 */

import type { EngineInstance } from './types';
import { ESEngineLoader } from './loader';

export interface LoadOptions {
    modules: string[];
    basePath: string;
    onProgress?: (module: string, progress: number) => void;
}

/**
 * Load ESEngine with specified modules.
 *
 * @example
 * ```typescript
 * const engine = await ESEngine.load({
 *     modules: ['es_ui', 'es_font_bitmap'],
 *     basePath: './modules/'
 * });
 * ```
 */
export async function load(options: LoadOptions): Promise<EngineInstance> {
    return ESEngineLoader.init({
        modules: options.modules,
        basePath: options.basePath,
        onProgress: options.onProgress,
    });
}

export const ESEngine = {
    load,
} as const;