import { App, Component } from 'vue'; /** * Interface representing the properties that can be passed during lifecycle methods. * These properties are used to configure the mounting and behavior of the micro app. */ export interface MicroAppProps { /** * An explicit DOM element where the app should mount. * Takes precedence over the el option if provided. */ domElement?: HTMLElement; /** * Name identifier for the micro app. * Used to create a custom element if no mount target is specified. */ name?: string; /** * Additional custom properties that can be passed to the micro app. */ [key: string]: any; } /** * Options used to configure a Vue micro app during creation. * * @template TProps - Type of props accepted by the root component */ export interface CreateVueMicroAppOptions { /** * CSS selector string or DOM element where the app will mount. * Falls back to creating a custom element if not provided. */ el?: string | HTMLElement; /** * Hook to customize the Vue app instance before mounting. * Can perform async operations like plugin installation. * * @param instance - The Vue app instance to customize * @param props - The props passed during mounting */ setupInstance?: (instance: App, props: MicroAppProps) => Promise | void; } /** * TODO: import from core package * Defines the standard lifecycle methods that a micro app must implement. * These methods manage the app's lifecycle from bootstrap to unmount. */ export interface MicroAppLifecycle { /** * Initializes the micro app. * Currently, it resolves immediately but can be extended for setup needs. */ bootstrap: () => Promise; /** * Mounts the micro app into the DOM. * Creates and configures a Vue app instance, determines mount target, * and handles instance customization. * * @param props - Configuration properties for mounting * @returns Promise resolving to the mounted Vue app instance */ mount: (props?: MicroAppProps) => Promise>; /** * Updates the micro app with new properties. * Merges new props into the Vue app's global properties. * * @param props - New properties to apply */ update: (props?: MicroAppProps) => void; /** * Unmounts the micro app and cleans up resources. * Removes the app from DOM and clears the stored instance. */ unmount: () => void; } /** * Creates a Vue 3 micro app with standardized lifecycle methods. * Provides support for standalone execution and allows custom instance configuration. * * @param {Component} rootComponent - The root Vue component (e.g., App.vue). * @param {CreateVueMicroAppOptions} [opts={}] - Optional configuration settings. * @returns {MicroAppLifecycle} Object implementing micro-app lifecycle methods (`bootstrap`, `mount`, `update`, `unmount`). */ export default function createVueMicroApp(rootComponent: Component, opts?: CreateVueMicroAppOptions): MicroAppLifecycle; declare global { interface Window { __MICROTSM_STANDALONE__: boolean; } interface WindowEventMap { 'microtsm:navigation-event': CustomEvent<{ to: URL; from: URL; }>; } }