import { Router } from './router.js'; import type { Template } from './template.js'; import { type Scope } from './scope.js'; import { LocationService as Location } from './locationService.js'; import { Event, type EventBus, type EventOptions } from '@akala/core'; /** * Represents an instance of a UI part with its associated scope and DOM element. */ export type PartInstance = { element: HTMLElement | ShadowRoot; }; /** * Unique symbol used to identify outlet definitions. */ export declare const outletDefinition: unique symbol; export declare class OutletService { private template; private location; static readonly InjectionToken: symbol; private routers; /** * Symbol used to trigger the onLoad event when a template is (re)loaded. */ static onLoad: symbol; constructor(template: Template, router: Router, location: Location); private parts; /** * Registers a new outlet part with the service. * @param partName - Unique identifier for the outlet part * @param control - Instance containing scope and DOM element for the part */ register(partName: string, control: PartInstance): void; /** * Unregisters an existing outlet part. * @param partName - Identifier of the part to remove */ unregister(partName: string): void; /** * Applies a template/controller configuration to an outlet part. * @param partInstance - Function resolving the target part instance * @param part - Outlet configuration defining template/controller * @param params - Route parameters to pass to the controller * @returns Disposable object to cleanup the applied configuration */ apply>(partInstance: () => PartInstance, part: OutletDefinition, params: unknown): Promise; /** * Registers routing configuration for an outlet part. * @param url - Route pattern to match * @param partName - Target outlet part name (default: 'body') * @param part - Outlet configuration (template/controller) */ use(url: string): OutletService; use>(url: string, partName: string, part: OutletDefined | OutletDefinition): void; } /** * Interface for outlet configurations that contain a definition object. */ export interface OutletDefined> { [outletDefinition]: OutletDefinition; } export declare function isOutletDefined>(value: unknown): value is OutletDefined; /** * Configuration interface for outlet parts. */ export interface OutletDefinition> { /** * Template name or promise resolving to the template content */ template?: string | Promise; /** * Controller function to initialize the part */ controller?(element: HTMLElement | ShadowRoot, params: unknown): { [Symbol.dispose]?(): void; templateReloaded?(): void; }; } /** * Builder class for creating outlet definitions with command handling. */ export declare class OutletDefinitionBuilder> implements OutletDefinition { private readonly commandActions?; constructor(commandActions?: EventBus>>); template?: string | Promise; controller?(element: HTMLElement | ShadowRoot, params: unknown): { [Symbol.dispose]?(): void; }; private controllerCommands; /** * Sets the template for the outlet definition. * @param template - Template name or promise * @returns This builder instance for method chaining */ useTemplate(template?: string | Promise): this; /** * Sets the controller function for the outlet. * @param controller - Initialization controller * @returns This builder instance */ useController(controller: (element: HTMLElement | ShadowRoot, params: unknown) => Disposable): void; /** * Registers a command result handler for the outlet. * @param commandName - Name of the command to listen for * @param handler - Handler function to execute when command result is received * @param options - Event listener options * @returns This builder instance */ useCommandResult(commandName: string, handler: (result: unknown) => void | Promise, options?: EventOptions>): this; }