/** * Dependency injection utilities. * * @remarks * Supports two patterns: * 1. Explicit `$inject` array (minification-safe, production) * 2. Function parameter parsing (dev convenience, breaks when minified) * * Build tools should auto-generate `$inject` arrays for production builds, * similar to how ngAnnotate worked with AngularJS. * * @packageDocumentation */ import type { ContextKey } from './context-registry.js'; import type { Expression, EvalFn } from './types.js'; /** * An injectable dependency name. * For ContextKey injection, use the `using` option on directive registration. */ export type Injectable = string; /** * Check if a value is a ContextKey. */ export declare function isContextKey(value: unknown): value is ContextKey; /** * A function with optional `$inject` annotation. */ interface InjectableFunction extends Function { $inject?: readonly string[]; } /** * Get the list of injectable dependencies for a function. * * @remarks * Checks for explicit `$inject` first, falls back to parsing params. * In production, always use `$inject` to survive minification. * * @param fn - The function to inspect * @returns Array of dependency names or context keys * * @example * ```ts * // Development - parsed from params * const myDirective = (expr, ctx, el, http, userService) => {}; * getInjectables(myDirective); // ['expr', 'ctx', 'el', 'http', 'userService'] * * // Production - explicit $inject array (survives minification) * myDirective.$inject = ['$element', '$scope']; * getInjectables(myDirective); // ['$element', '$scope'] * ``` * * For ContextKey injection, use the `using` option on directive registration. */ export declare function getInjectables(fn: InjectableFunction): Injectable[]; /** * Configuration for dependency resolution. */ export interface DependencyResolverConfig { /** Resolve a ContextKey to its value */ resolveContext: (key: ContextKey) => unknown; /** Resolve $scope injectable */ resolveState: () => Record; /** Resolve $rootState injectable (may be same as state) */ resolveRootState?: () => Record; /** Resolve custom injectable by name (services, providers) */ resolveCustom?: (name: string) => unknown | undefined; /** Current mode */ mode: 'server' | 'client'; } /** * Resolve dependencies for a directive function. * * @remarks * Unified dependency resolution used by both client and server. * Handles $inject arrays, ContextKey injection, and the `using` option. * * @param fn - The directive function (with optional $inject) * @param expr - The expression string from the directive attribute * @param element - The target DOM element * @param evalFn - Function to evaluate expressions * @param config - Resolution configuration * @param using - Optional array of context keys to append * @returns Array of resolved dependency values */ export declare function resolveDependencies(fn: InjectableFunction, expr: Expression | string, element: Element, evalFn: EvalFn, config: DependencyResolverConfig, using?: ContextKey[]): unknown[]; export {};