export type ScriptElement = { content: string; type: string | null; /** Build-time resolved bindings supplied by precompiled component artifacts. */ resolvedImports?: Record; }; export type ExternalScriptElement = { src: string; type: string | null; external?: boolean; }; export type ExternalStyleElement = { href: string; rel: string; }; export type LadrillosComponent = { tagName: string; template: string; scripts: ScriptElement[]; externalScripts: ExternalScriptElement[]; externalStyles: ExternalStyleElement[]; styles: string; sourcePath?: string; lazy?: boolean; /** * Variable names found in template bindings (e.g., {title} -> 'title'). * Used to auto-observe attributes that map to template expressions. */ templateBindings?: string[]; }; export type ComponentRegistration = { name: string; path: string; useShadowDOM?: boolean; lazy?: boolean; }; export type RegexPatterns = { readonly bindings: RegExp; readonly comments: { readonly js: RegExp; readonly css: RegExp; readonly html: RegExp; }; }; export type BindingDescriptor = { node: Text; bindings: Array<{ raw: string; path: string[]; isFunction?: boolean; isExpression?: boolean; functionArgs?: string[]; }>; original: string; isAttribute?: boolean; attributeName?: string; }; export type TwoWayBindingDescriptor = { element: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLElement; path: string[]; raw: string; isContentEditable?: boolean; initialValue?: string; }; export type ConditionalDescriptor = { element: Element; condition: string; type: "if" | "else-if" | "else"; placeholder: Comment; group: ConditionalDescriptor[]; originalParent: Element | ShadowRoot; nextSibling: Node | null; }; export type LoopDescriptor = { template: Element; expression: string; itemName: string; indexName?: string; arrayName: string; keyAttribute?: string; placeholder: Comment; renderedElements: Element[]; originalParent: Element | ShadowRoot; /** Previous items for keyed diffing (to detect changes) */ previousItems?: unknown[]; /** Cached key getter function for performance */ keyGetter?: (item: unknown, index: number) => unknown; /** * Whether the template subtree contains any chain. Detected once at * scan time so per-row rendering can skip the conditional-resolution walk * entirely for the common conditional-free template. */ hasConditionals?: boolean; /** * Whether the template contains a nested . Those are extracted and * rendered per row, because their array expression usually depends on the * enclosing row's item. */ hasNestedLoops?: boolean; /** * Loop variable names contributed by enclosing loops, outermost first. * Empty for a top-level loop; `["group"]` for a nested one deep. */ scopeNames?: readonly string[]; }; /** * Component library types for TypeScript support */ /** * Describes the props interface for a component * Used for TypeScript type checking and documentation */ export type ComponentProps = Record; /** * Describes the events a component can emit * Maps event names to their detail payload types */ export type ComponentEvents = Record; /** * Interface definition for a LadrillosJS component * Allows TypeScript consumers to get proper type checking */ export type ComponentInterface = { /** * Component tag name (e.g., "my-button") */ tagName: string; /** * TypeScript interface for component properties/attributes */ props: Props; /** * TypeScript interface for component events */ events: Events; /** * Component methods available in TypeScript */ methods?: Record any>; /** * Documentation for the component */ documentation?: { description?: string; examples?: string[]; }; }; /** * Metadata about a component in a library * Used during component registration and discovery */ export type ComponentMetadata = { /** * Component registration details */ registration: ComponentRegistration; /** * TypeScript interface for this component */ interface: ComponentInterface; /** * Version of the component */ version?: string; /** * Component author/library name */ library?: string; }; /** * Library component with metadata and helper functions */ export type LibraryComponent = { /** * Component metadata */ metadata: ComponentMetadata; /** * HTML content of the component (as raw string) */ html?: string; /** * Helper to create a typed reference to the component element */ createElement?: (attributes?: Partial) => HTMLElement & Partial; /** * Helper to query and cast to the component type */ query?: (selector: string) => (HTMLElement & Partial) | null; };