UNPKG

threepipe

Version:

A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.

63 lines 2.92 kB
import { UiObjectConfig } from 'uiconfig.js'; import { AViewerPlugin, AViewerPluginSync, ThreeViewer } from '../../viewer'; import { Class } from 'ts-browser-helpers'; /** * A plugin that allows dynamic loading and unloading of other plugins at runtime, with support for hot module replacement (HMR) during development. * This plugin provides a simple UI to load and unload plugins by specifying their module paths. * It supports both direct path strings and module objects (imported or promises). * The loaded plugins are tracked and can be managed through the provided UI. * * For HMR with vite, see {@link sampleThreepipeViteHmrPlugin} * Note: This plugin is primarily intended for development and testing purposes. */ export declare class DynamicImportPlugin extends AViewerPluginSync { static readonly PluginType = "DynamicImportPlugin"; enabled: boolean; constructor(); onAdded(viewer: ThreeViewer): void; plugins: Map<string, Class<AViewerPlugin<import('../../viewer').AViewerPluginEventMap, ThreeViewer, boolean>>>; /** * Loads and adds a plugin to the viewer. * The plugin can be specified as a path string or as a module object (imported or promise). * If a path string is provided, it should point to a module that exports a default class extending AViewerPlugin. * If a module object is provided, it should either have a default export or a named export that is a class extending AViewerPlugin. * The module can also have a __tpPluginPath property to identify its path. * * Usage examples: * ```ts * // Load plugin from a path * await DynamicImportPlugin.loadPlugin('./path/to/MyPlugin.js'); * * // Load plugin from an imported module * import MyPluginModule from './path/to/MyPlugin.js'; * await DynamicImportPlugin.loadPlugin(MyPluginModule); * * // Load plugin with dynamic import * await DynamicImportPlugin.loadPlugin(import('./path/to/MyPlugin.js')); * ``` * * @returns The instance of the loaded plugin. * @param pathOrModule */ loadPlugin(pathOrModule: string | PluginModule | Promise<PluginModule>): Promise<any>; /** * Unloads and removes a plugin from the viewer by its path. * The path should match the one used when loading the plugin. * * @returns A promise that resolves when the plugin is removed. * @param path */ unloadPlugin(path: string): Promise<void>; private _path; uiConfig: UiObjectConfig; } export interface PluginModule { __tpPluginPath: string; default?: Class<AViewerPlugin>; [key: string]: Class<AViewerPlugin> | any; } export declare const sampleThreepipeViteHmrPlugin: { handleHotUpdate({ server, modules, timestamp }: any): any[]; transform(code: string, id: string): string | undefined; }; //# sourceMappingURL=../../src/plugins/extras/DynamicImportPlugin.d.ts.map