@stacksjs/stx
Version:
A Bun plugin that allows for using Laravel Blade-like syntax.
149 lines (131 loc) • 3.08 kB
TypeScript
export declare type CustomDirectiveHandler = (
content: string,
params: string[],
context: Record<string, any>,
filePath: string
) => string | Promise<string>
export interface CustomDirective {
name: string
handler: CustomDirectiveHandler
hasEndTag?: boolean
description?: string
}
export type MiddlewareHandler = (
template: string,
context: Record<string, any>,
filePath: string,
options: StxOptions
) => string | Promise<string>
export interface Middleware {
name: string
handler: MiddlewareHandler
timing: 'before' | 'after'
description?: string
}
export interface I18nConfig {
defaultLocale: string
locale: string
translationsDir: string
format: 'json' | 'yaml' | 'yml' | 'js'
fallbackToKey: boolean
cache: boolean
}
export interface WebComponent {
name: string
tag: string
file: string
extends?: string
shadowDOM?: boolean
template?: boolean
styleSource?: string
attributes?: string[]
description?: string
}
export interface WebComponentConfig {
enabled: boolean
outputDir: string
components: WebComponent[]
}
export type DocFormat = 'markdown' | 'html' | 'json'
export interface ComponentPropDoc {
name: string
type?: string
required?: boolean
default?: string
description?: string
}
export interface ComponentDoc {
name: string
path: string
description?: string
props: ComponentPropDoc[]
example?: string
isWebComponent?: boolean
tag?: string
}
export interface TemplateDoc {
name: string
path: string
description?: string
components?: string[]
directives?: string[]
}
export interface DirectiveDoc {
name: string
description?: string
hasEndTag: boolean
example?: string
}
export interface DocGeneratorConfig {
enabled: boolean
outputDir: string
format: DocFormat
components: boolean
templates: boolean
directives: boolean
extraContent?: string
template?: string
}
export interface StreamingConfig {
enabled: boolean
bufferSize: number
strategy: 'auto' | 'manual' | 'sections'
timeout: number
}
export interface StreamRenderer {
renderShell: (data?: Record<string, any>) => Promise<string>
renderSection: (section: string, data?: Record<string, any>) => Promise<string>
getSections: () => string[]
getTemplate: () => string
}
export interface HydrationConfig {
enabled: boolean
mode: 'progressive' | 'islands'
clientEntry: string
autoMarkers: boolean
preload: 'none' | 'eager' | 'lazy'
}
export interface Island {
id: string
component: string
props?: Record<string, any>
priority?: 'eager' | 'lazy'
shadowDOM?: boolean
}
export interface StxConfig {
enabled: boolean
partialsDir: string
componentsDir: string
debug: boolean
cache: boolean
cachePath: string
cacheVersion: string
customDirectives?: CustomDirective[]
middleware?: Middleware[]
i18n?: Partial<I18nConfig>
webComponents?: Partial<WebComponentConfig>
docs?: Partial<DocGeneratorConfig>
streaming?: Partial<StreamingConfig>
hydration?: Partial<HydrationConfig>
}
export type StxOptions = Partial<StxConfig>