UNPKG

@stacksjs/stx

Version:

A performant UI Framework. Powered by Bun.

73 lines 3.15 kB
import type { StxOptions } from './types'; export type { TemplateValidationError, TemplateValidationResult, } from './validator'; /** * Check if script should be treated as plain JavaScript (opt-out from TypeScript) * By default ALL scripts are TypeScript. Use <script js> or <script lang="js"> to opt-out. */ export declare function isJavaScriptScript(attrs: string): boolean; /** * Check if script should be transpiled as TypeScript * Default: ALL scripts are TypeScript unless explicitly marked as JS */ export declare function shouldTranspileTypeScript(attrs: string): boolean; /** * Transpile TypeScript code to JavaScript using Bun (sync version) */ export declare function transpileTypeScript(code: string): string; /** * Shared function to render a component with props and slot content */ export declare function renderComponentWithSlot(componentPath: string, props: Record<string, unknown>, slotContent: string, componentsDir: string, parentContext: Record<string, unknown>, parentFilePath: string, options: StxOptions, processedComponents?: Set<string> | undefined, dependencies: Set<string>): Promise<string>; /** * Check if a file exists */ export declare function fileExists(filePath: string): Promise<boolean>; /** * Resolve a template path based on the current file path */ export declare function resolveTemplatePath(templatePath: string, currentFilePath: string, options: StxOptions, dependencies?: Set<string>): Promise<string | null>; /** * Get source line number from an error in a template * This helps provide more precise error messages * @param template The full template string * @param errorPosition The character position of the error (if available) * @param errorPattern The pattern to locate in the template (fallback if position not available) * @returns Line number and context information */ export declare function getSourceLineInfo(template: string, errorPosition?: number, errorPattern?: string): { lineNumber: number, lineContent: string, context: string }; /** * Create a descriptive error message with line information * @param errorType Type of error (e.g., "Expression", "Directive") * @param errorMessage The base error message * @param filePath The file where the error occurred * @param template The template content * @param errorPosition The position of the error (if known) * @param errorPattern A pattern to locate the error (fallback) * @returns A formatted error message */ export declare function createDetailedErrorMessage(errorType: string, errorMessage: string, filePath: string, template: string, errorPosition?: number, errorPattern?: string): string; /** * Clear the component cache * Useful for development or testing */ export declare function clearComponentCache(): void; /** * Get component cache statistics */ export declare function getComponentCacheStats(): { size: number, maxSize: number }; export { extractDirectiveNames, getPositionInfo, hasDirectives, validateDirective, validateTemplate, } from './validator'; export { convertToCommonJS, extractScriptFromTemplate, extractVariables, hasVariables, } from './variable-extractor';