@stacksjs/stx 0.0.9 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +69 -21
  2. package/dist/a11y.d.ts +40 -0
  3. package/dist/analyzer.d.ts +64 -0
  4. package/dist/animation.d.ts +64 -0
  5. package/dist/assets.d.ts +19 -0
  6. package/dist/auth.d.ts +11 -0
  7. package/dist/bin/cli.js +2821 -154
  8. package/dist/caching.d.ts +18 -6
  9. package/dist/chunk-2ndtnc0t.js +9822 -0
  10. package/dist/{chunk-ywm063e4.js → chunk-e11q5a3p.js} +2 -2
  11. package/dist/chunk-vsbm352h.js +670 -0
  12. package/dist/client.d.ts +19 -35
  13. package/dist/components.d.ts +6 -0
  14. package/dist/conditionals.d.ts +17 -1
  15. package/dist/config.d.ts +6 -2
  16. package/dist/csrf.d.ts +28 -0
  17. package/dist/custom-directives.d.ts +5 -6
  18. package/dist/dev-server.d.ts +21 -0
  19. package/dist/docs.d.ts +39 -3
  20. package/dist/error-handling.d.ts +101 -0
  21. package/dist/expressions.d.ts +43 -4
  22. package/dist/formatter.d.ts +16 -0
  23. package/dist/forms.d.ts +15 -25
  24. package/dist/i18n.d.ts +17 -20
  25. package/dist/includes.d.ts +21 -18
  26. package/dist/index.d.ts +30 -24
  27. package/dist/init.d.ts +9 -0
  28. package/dist/js-ts.d.ts +10 -0
  29. package/dist/loops.d.ts +4 -3
  30. package/dist/markdown.d.ts +8 -0
  31. package/dist/method-spoofing.d.ts +13 -0
  32. package/dist/middleware.d.ts +9 -1
  33. package/dist/performance-utils.d.ts +58 -0
  34. package/dist/plugin.d.ts +2 -0
  35. package/dist/process.d.ts +9 -7
  36. package/dist/release.d.ts +1 -0
  37. package/dist/routes.d.ts +36 -0
  38. package/dist/safe-evaluator.d.ts +16 -0
  39. package/dist/seo.d.ts +33 -0
  40. package/dist/serve.d.ts +35 -0
  41. package/dist/src/index.js +2893 -135
  42. package/dist/streaming.d.ts +30 -14
  43. package/dist/types.d.ts +214 -48
  44. package/dist/utils.d.ts +21 -3
  45. package/dist/view-composers.d.ts +26 -0
  46. package/dist/web-components.d.ts +7 -14
  47. package/package.json +18 -9
  48. package/dist/chunk-04bqmpzb.js +0 -7069
  49. package/dist/chunk-8ehp5m3y.js +0 -4279
  50. package/dist/chunk-9ynf73q9.js +0 -2502
package/dist/client.d.ts CHANGED
@@ -1,36 +1,20 @@
1
- declare type IslandHandlers = Record<string, () => Promise<any>>
2
-
3
- type IslandHydrationFn = (element: any, props: any) => void | Promise<void>
4
-
5
- const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined'
6
-
7
- async function hydrateIsland(
8
- element: any,
9
- name: string,
10
- handler: () => Promise<any>,
11
- ): Promise<void> {
12
- if (!isBrowser) return
13
-
14
- try {
15
- const id = element.getAttribute('data-island-id')
16
- const propsScript = document.querySelector(`script[data-island-props="${id}"]`)
17
- const props = propsScript ? JSON.parse(propsScript.textContent || '{}') : {}
18
-
19
- const module = await handler()
20
- const hydrateFn: IslandHydrationFn = module.default || module.hydrate
21
-
22
- if (typeof hydrateFn !== 'function') {
23
- console.error(`Island handler for "${name}" does not export a valid hydration function`)
24
- return
25
- }
26
-
27
- await hydrateFn(element, props)
28
-
29
- element.setAttribute('data-hydrated', 'true')
30
- }
31
- catch (error) {
32
- console.error(`Failed to hydrate island "${name}":`, error)
33
- }
34
- }
1
+ /**
2
+ * Hydrate all islands with the given handlers
3
+ */
35
4
  export declare function hydrateIslands(handlers: IslandHandlers): void;
36
- export declare function preloadIslandHandlers(handlers: IslandHandlers): void;
5
+ /**
6
+ * Add preload links for island scripts
7
+ */
8
+ export declare function preloadIslandHandlers(handlers: IslandHandlers): void;
9
+ /**
10
+ * Client-side hydration functionality for stx templates
11
+ * This file is meant to be used in the browser only
12
+ */
13
+ /**
14
+ * Island handler registry
15
+ */
16
+ declare type IslandHandlers = Record<string, () => Promise<any>>
17
+ /**
18
+ * Island hydration function
19
+ */
20
+ declare type IslandHydrationFn = (element: any, props: any) => void | Promise<void>
@@ -0,0 +1,6 @@
1
+ import type { CustomDirective } from './types';
2
+ /**
3
+ * Register component directives
4
+ */
5
+ export declare function registerComponentDirectives(): CustomDirective[];
6
+ export declare const componentDirective: CustomDirective;
@@ -1,4 +1,20 @@
1
+ /**
2
+ * Process switch statements (@switch, @case, @default)
3
+ */
4
+ export declare function processSwitchStatements(template: string, context: Record<string, any>, filePath: string): string;
5
+ /**
6
+ * Process conditionals (@if, @elseif, @else, @unless)
7
+ */
1
8
  export declare function processConditionals(template: string, context: Record<string, any>, filePath: string): string;
9
+ /**
10
+ * Process @auth and permissions directives
11
+ */
2
12
  export declare function processAuthDirectives(template: string, context: Record<string, any>): string;
13
+ /**
14
+ * Process @isset and @empty directives
15
+ */
3
16
  export declare function processIssetEmptyDirectives(template: string, context: Record<string, any>, filePath?: string): string;
4
- export declare function processEnvDirective(template: string, context: Record<string, any>, filePath?: string): string;
17
+ /**
18
+ * Process @env directive to conditionally render content based on environment
19
+ */
20
+ export declare function processEnvDirective(template: string, _context: Record<string, any>, _filePath?: string): string;
package/dist/config.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- import type { StxConfig } from './types';
2
-
1
+ import type { StxOptions } from './types';
2
+ /**
3
+ * Helper function to define stx configuration
4
+ */
5
+ export declare function defineStxConfig(config: StxOptions): StxOptions;
3
6
  export declare const defaultConfig: StxConfig;
7
+ // eslint-disable-next-line antfu/no-top-level-await
4
8
  export declare const config: StxConfig;
package/dist/csrf.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Generate a CSRF token
3
+ */
4
+ export declare function generateCsrfToken(length?: number): string;
5
+ /**
6
+ * Get the current CSRF token, generating one if it doesn't exist
7
+ */
8
+ export declare function getCsrfToken(): string;
9
+ /**
10
+ * Reset the CSRF token (mainly for testing)
11
+ */
12
+ export declare function resetCsrfToken(): void;
13
+ /**
14
+ * Set a specific CSRF token (useful for server frameworks that have their own token generation)
15
+ */
16
+ export declare function setCsrfToken(token: string): void;
17
+ /**
18
+ * Generate a CSRF input field HTML
19
+ */
20
+ export declare function csrfField(inputName?: string): string;
21
+ /**
22
+ * Process @csrf directives in templates
23
+ */
24
+ export declare function processCsrfDirectives(template: string): string;
25
+ /**
26
+ * Middleware-like function to verify CSRF token
27
+ */
28
+ export declare function verifyCsrfToken(token: string): boolean;
@@ -1,6 +1,5 @@
1
- import type { CustomDirective, StxOptions } from './types';
2
-
3
- export declare function processCustomDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions): Promise<string>;
4
- declare function processDirectiveWithEndTag(template: string, directive: CustomDirective, context: Record<string, any>, filePath: string, options: StxOptions): Promise<string>;
5
- declare function processDirectiveWithoutEndTag(template: string, directive: CustomDirective, context: Record<string, any>, filePath: string, options: StxOptions): Promise<string>;
6
- declare function parseDirectiveParams(paramString: string): string[];
1
+ import type { StxOptions } from './types';
2
+ /**
3
+ * Process all custom directives registered in the app
4
+ */
5
+ export declare function processCustomDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions): Promise<string>;
@@ -0,0 +1,21 @@
1
+ import type { SyntaxHighlightTheme } from './types';
2
+ // Build and serve a specific stx file
3
+ export declare function serveStxFile(filePath: string, options?: DevServerOptions): Promise<boolean>;
4
+ // Build and serve multiple files (stx and Markdown)
5
+ export declare function serveMultipleStxFiles(filePaths: string[], options?: DevServerOptions): Promise<boolean>;
6
+ // Define types for dev server options
7
+ export declare interface DevServerOptions {
8
+ port?: number
9
+ watch?: boolean
10
+ stxOptions?: any
11
+ markdown?: {
12
+ syntaxHighlighting?: {
13
+ serverSide?: boolean
14
+ enabled?: boolean
15
+ defaultTheme?: SyntaxHighlightTheme
16
+ highlightUnknownLanguages?: boolean
17
+ additionalThemes?: SyntaxHighlightTheme[]
18
+ }
19
+ }
20
+ cache?: boolean
21
+ }
package/dist/docs.d.ts CHANGED
@@ -1,15 +1,48 @@
1
- import type { ComponentDoc, DirectiveDoc, TemplateDoc } from './types';
2
-
1
+ import { config } from './config';
2
+ import type { ComponentDoc, ComponentPropDoc, DirectiveDoc, DocGeneratorConfig, TemplateDoc } from './types';
3
+ /**
4
+ * Extract component properties from a component file
5
+ */
3
6
  export declare function extractComponentProps(componentPath: string): Promise<ComponentPropDoc[]>;
7
+ /**
8
+ * Extract component description from a component file
9
+ */
4
10
  export declare function extractComponentDescription(componentPath: string): Promise<string>;
5
- export declare function generateComponentDoc(componentPath: string, isWebComponent?: boolean, webComponentTag?: string): Promise<ComponentDoc>;
11
+ /**
12
+ * Generate documentation for a component
13
+ */
14
+ export declare function generateComponentDoc(componentPath: string, isWebComponent?: any, webComponentTag?: string): Promise<ComponentDoc>;
15
+ /**
16
+ * Find all component files in a directory
17
+ */
6
18
  export declare function findComponentFiles(componentsDir: string): Promise<string[]>;
19
+ /**
20
+ * Generate documentation for all components
21
+ */
7
22
  export declare function generateComponentsDocs(componentsDir: string, webComponentsConfig?: any): Promise<ComponentDoc[]>;
23
+ /**
24
+ * Generate documentation for templates
25
+ */
8
26
  export declare function generateTemplatesDocs(templatesDir: string): Promise<TemplateDoc[]>;
27
+ /**
28
+ * Generate documentation for directives
29
+ */
9
30
  export declare function generateDirectivesDocs(customDirectives?: any[]): Promise<DirectiveDoc[]>;
31
+ /**
32
+ * Format documentation as Markdown
33
+ */
10
34
  export declare function formatDocsAsMarkdown(componentDocs?: ComponentDoc[], templateDocs?: TemplateDoc[], directiveDocs?: DirectiveDoc[], extraContent?: string): string;
35
+ /**
36
+ * Format documentation as HTML
37
+ */
11
38
  export declare function formatDocsAsHtml(componentDocs?: ComponentDoc[], templateDocs?: TemplateDoc[], directiveDocs?: DirectiveDoc[], extraContent?: string): string;
39
+ /**
40
+ * Format documentation as JSON
41
+ */
12
42
  export declare function formatDocsAsJson(componentDocs?: ComponentDoc[], templateDocs?: TemplateDoc[], directiveDocs?: DirectiveDoc[], extraContent?: string): string;
43
+ /**
44
+ * Generate documentation
45
+ */
13
46
  export declare function generateDocs(options: {
14
47
  componentsDir?: string
15
48
  templatesDir?: string
@@ -17,4 +50,7 @@ export declare function generateDocs(options: {
17
50
  customDirectives?: any[]
18
51
  config: Partial<DocGeneratorConfig>
19
52
  }): Promise<boolean>;
53
+ /**
54
+ * Documentation generation command handler for CLI
55
+ */
20
56
  export declare function docsCommand(options: any): Promise<boolean>;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Enhanced error reporting with better context
3
+ */
4
+ export declare function createEnhancedError(type: string, message: string, context: ErrorContext): string;
5
+ /**
6
+ * Safe wrapper for potentially dangerous operations
7
+ */
8
+ export declare function safeExecute<T>(operation: () => T, fallback: T, errorHandler?: (error: Error) => void): T;
9
+ /**
10
+ * Async version of safe wrapper
11
+ */
12
+ export declare function safeExecuteAsync<T>(operation: () => Promise<T>, fallback: T, errorHandler?: (error: Error) => void): Promise<T>;
13
+ /**
14
+ * Validation utilities
15
+ */
16
+ export declare const validators: {
17
+ /**
18
+ * Validate file path is safe
19
+ */
20
+ isValidFilePath(filePath: string): unknown
21
+ };
22
+ /**
23
+ * Error recovery strategies
24
+ */
25
+ export declare const errorRecovery: {
26
+ /**
27
+ * Attempt to fix common template syntax errors
28
+ */
29
+ fixCommonSyntaxErrors(template: string): unknown;
30
+ /**
31
+ * Create fallback content for failed template sections
32
+ */
33
+ createFallbackContent(sectionType: string, error: Error): unknown
34
+ };
35
+ // Global error logger instance
36
+ export declare const errorLogger: ErrorLogger;
37
+ /**
38
+ * Development mode helpers
39
+ */
40
+ export declare const devHelpers: {
41
+ /**
42
+ * Check if we're in development mode
43
+ */
44
+ isDevelopment(): boolean {
45
+ return process.env.NODE_ENV === 'development' || process.env.stx_DEBUG === 'true'
46
+ },
47
+
48
+ /**
49
+ * Log detailed error information in development
50
+ */
51
+ logDetailedError(error: Error, context?: any): void {
52
+ if (!this.isDevelopment())
53
+ return
54
+
55
+ console.error('=== stx Detailed Error ===')
56
+ console.error('Error: unknown
57
+ };
58
+ /**
59
+ * Error context information
60
+ */
61
+ export declare interface ErrorContext {
62
+ filePath: string
63
+ template: string
64
+ offset: number
65
+ match: string
66
+ }
67
+ /**
68
+ * Custom error types for better error classification
69
+ */
70
+ export declare class StxError extends Error {
71
+ public code: string;
72
+ public filePath?: string;
73
+ public line?: number;
74
+ public column?: number;
75
+ public context?: string;
76
+ constructor(message: string, code: string, filePath?: string, line?: number, column?: number, context?: string);
77
+ }
78
+ export declare class StxSyntaxError extends StxError {
79
+ constructor(message: string, filePath?: string, line?: number, column?: number, context?: string);
80
+ }
81
+ export declare class StxRuntimeError extends StxError {
82
+ constructor(message: string, filePath?: string, line?: number, column?: number, context?: string);
83
+ }
84
+ export declare class StxSecurityError extends StxError {
85
+ constructor(message: string, filePath?: string, line?: number, column?: number, context?: string);
86
+ }
87
+ export declare class StxFileError extends StxError {
88
+ constructor(message: string, filePath?: string, line?: number, column?: number, context?: string);
89
+ }
90
+ /**
91
+ * Error logging and monitoring
92
+ */
93
+ export declare class ErrorLogger {
94
+ private errors: Array<{ timestamp: Date, error: Error, context?: any }>;
95
+ private maxErrors: any;
96
+ log(error: Error, context?: any): void;
97
+ getRecentErrors(limit?: any): Array<{ timestamp: Date, error: Error, context?: any }>;
98
+ getErrorsByType(errorType: string): Array<{ timestamp: Date, error: Error, context?: any }>;
99
+ clear(): void;
100
+ getStats(): { total: number, byType: Record<string, number> };
101
+ }
@@ -1,9 +1,48 @@
1
- export declare type FilterFunction = (value: any, ...args: any[]) => any
2
-
3
- let globalContext: Record<string, any> = {}
1
+ /**
2
+ * Set global context for filters
3
+ */
4
4
  export declare function setGlobalContext(context: Record<string, any>): void;
5
+ /**
6
+ * HTML escape function to prevent XSS
7
+ */
5
8
  export declare function escapeHtml(unsafe: string): string;
9
+ /**
10
+ * Process template expressions including variables, filters, and operations
11
+ */
6
12
  export declare function processExpressions(template: string, context: Record<string, any>, filePath: string): string;
13
+ /**
14
+ * Apply filters to a value
15
+ */
7
16
  export declare function applyFilters(value: any, filterExpression: string, context: Record<string, any>): any;
17
+ /**
18
+ * Evaluate an expression within the given context
19
+ * @param {string} expression - The expression to evaluate
20
+ * @param {Record<string, any>} context - The context object containing variables
21
+ * @param {boolean} silent - Whether to silently handle errors (return undefined) or throw
22
+ * @returns The evaluated result
23
+ */
8
24
  export declare function evaluateExpression(expression: string, context: Record<string, any>, silent?: boolean): any;
9
- export declare function unescapeHtml(html: string): string;
25
+ /**
26
+ * HTML unescape function to reverse escapeHtml
27
+ */
28
+ export declare function unescapeHtml(html: string): string;
29
+ export declare const defaultFilters: {
30
+ // String transformation filters
31
+ uppercase: (value: any) => unknown;
32
+ lowercase: (value: any) => unknown;
33
+ capitalize: (value: any) => unknown;
34
+ // Number filters
35
+ number: (value: any, decimals: number?) => unknown;
36
+ // Array filters
37
+ join: () => unknown;
38
+ // Safety filters
39
+ escape: (value: any) => unknown;
40
+ // Translation filter
41
+ translate: (value: any, params: Record<string, any> = {}) => unknown;
42
+ // Short alias for translate
43
+ t: (value: any, params: Record<string, any> = {}) => unknown
44
+ };
45
+ /**
46
+ * Add basic filter support to expressions
47
+ */
48
+ export type FilterFunction = (value: any, ...args: any[]) => any
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Format stx file content
3
+ */
4
+ export declare function formatStxContent(content: string, options?: FormatterOptions): string;
5
+ /**
6
+ * stx file formatter for automatically formatting .stx files
7
+ */
8
+ /* eslint-disable regexp/no-super-linear-backtracking */
9
+ export declare interface FormatterOptions {
10
+ indentSize?: number
11
+ useTabs?: boolean
12
+ maxLineLength?: number
13
+ normalizeWhitespace?: boolean
14
+ sortAttributes?: boolean
15
+ trimTrailingWhitespace?: boolean
16
+ }
package/dist/forms.d.ts CHANGED
@@ -1,31 +1,21 @@
1
1
  import type { StxOptions } from './types';
2
-
3
- declare function genId(): string;
2
+ /**
3
+ * Process all form-related directives
4
+ */
4
5
  export declare function processForms(template: string, context: Record<string, any>, _filePath: string, _options: StxOptions): string;
6
+ /**
7
+ * Process basic form directives (@csrf, @method)
8
+ */
5
9
  export declare function processBasicFormDirectives(template: string, context: Record<string, any>): string;
10
+ /**
11
+ * Process form input directives
12
+ */
6
13
  export declare function processFormInputDirectives(template: string, context: Record<string, any>): string;
7
- declare const name: unknown;
8
- declare const attrs: unknown;
9
- declare const type: unknown;
10
- declare const existingClass: unknown;
11
- declare const attrs: unknown;
12
- declare const hasError: unknown;
13
- declare const existingClass: unknown;
14
- declare const attrs: unknown;
15
- declare const hasError: unknown;
16
- declare const existingClass: unknown;
17
- declare const isSelected: oldValue;
18
- declare const attrs: unknown;
19
- declare const isChecked: oldValues;
20
- declare const existingClass: unknown;
21
- declare const attrs: unknown;
22
- declare const isChecked: unknown;
23
- declare const className: unknown;
24
- declare const attrs: unknown;
25
- declare const className: unknown;
14
+ /**
15
+ * Process @error directive for form validation
16
+ */
26
17
  export declare function processErrorDirective(template: string, context: Record<string, any>): string;
27
- declare function hasFieldError(field: string, context: Record<string, any>): boolean;
28
- declare function getErrorMessage(field: string, context: Record<string, any>): string;
29
- declare function getOldValue(field: string, context: Record<string, any>): any;
30
- declare function parseAttributes(attributesStr: string): string;
18
+ /**
19
+ * Process @form directives for forms
20
+ */
31
21
  export declare function processFormDirectives(template: string, context: Record<string, any>): string;
package/dist/i18n.d.ts CHANGED
@@ -1,22 +1,19 @@
1
- import type { I18nConfig, StxOptions } from './types';
2
-
3
- export declare const defaultI18nConfig: I18nConfig;
4
- declare const translationsCache: Record<string, Record<string, any>>;
1
+ import type { StxOptions } from './types';
2
+ /**
3
+ * Load a translation file
4
+ */
5
5
  export declare function loadTranslation(locale: string, options: StxOptions): Promise<Record<string, any>>;
6
- declare function parseYaml(content: string): Promise<Record<string, any>>;
7
- declare function getFileExtension(format: string): string;
8
- export declare function getTranslation(key: string,
9
- translations: Record<string, any>,
10
- fallbackToKey: boolean = true,
11
- params: Record<string, any> = {},): string;
6
+ /**
7
+ * Get a translation by key
8
+ */
9
+ export declare function getTranslation(key: string, translations: Record<string, any>, fallbackToKey?: boolean, params?: Record<string, any>): string;
10
+ /**
11
+ * Process @translate directive
12
+ */
12
13
  export declare function processTranslateDirective(template: string, context: Record<string, any>, filePath: string, options: StxOptions): Promise<string>;
13
- declare const i18nConfig: {};
14
- declare const translations: unknown;
15
- declare const approaches: Array<(() => unknown) | (() => unknown) | (() => unknown)>;
16
- declare const translation: unknown;
17
- declare const matches: Array<((...args: any[]) => unknown)>;
18
- declare const approaches: Array<(() => unknown) | (() => unknown) | (() => unknown)>;
19
- declare function replaceAsync(str: string, regex: RegExp, asyncFn: (
20
- match, ...groups?: any[]
21
- )): Promise<string>;
22
- export declare function createTranslateFilter(translations: Record<string, any>, fallbackToKey?: boolean): (value: string, params?: Record<string, any>) => string;
14
+ /**
15
+ * Create a translation filter for expressions
16
+ */
17
+ export declare function createTranslateFilter(translations: Record<string, any>, fallbackToKey?: boolean): (value: string, params?: Record<string, any>) => string;
18
+ // Default i18n configuration
19
+ export declare const defaultI18nConfig: I18nConfig;
@@ -1,21 +1,24 @@
1
1
  import type { StxOptions } from './types';
2
-
3
- export declare const partialsCache: Map<string, string>;
2
+ /**
3
+ * Clear the @once store - useful for testing and resetting state
4
+ */
5
+ export declare function clearOnceStore(): void;
6
+ /**
7
+ * Process @include and @partial directives
8
+ */
4
9
  export declare function processIncludes(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
5
- declare const includeFilePath: unknown;
6
- declare const conditionFn: unknown;
7
- declare const includeFilePath: unknown;
8
- declare const conditionFn: unknown;
9
- declare const includeFilePath: unknown;
10
- declare const matchOffset: unknown;
11
- declare let pathArray: unknown;
12
- declare const varsFn: unknown;
13
- declare const includeFilePath: unknown;
14
- declare const processed: unknown;
15
- declare function resolvePath(includePath: string, partialsDir: string, filePath: string): string | null;
16
- declare let processedIncludes: (...args: any[]) => unknown;
17
- declare let matchOffset: unknown;
18
- declare const varsFn: unknown;
19
- declare const processedContent: unknown;
10
+ /**
11
+ * Stack related functions for @push, @stack, @prepend directives
12
+ */
13
+ /**
14
+ * Process @push and @prepend directives to collect content
15
+ */
20
16
  export declare function processStackPushDirectives(template: string, stacks: Record<string, string[]>): string;
21
- export declare function processStackReplacements(template: string, stacks: Record<string, string[]>): string;
17
+ /**
18
+ * Process @stack directives by replacing them with their content
19
+ */
20
+ export declare function processStackReplacements(template: string, stacks: Record<string, string[]>): string;
21
+ // Cache for partials to avoid repeated file reads
22
+ export declare const partialsCache: Map<string, string>;
23
+ // Global store to track what has been included via @once
24
+ export declare const onceStore: Set<string>;
package/dist/index.d.ts CHANGED
@@ -1,24 +1,30 @@
1
- import { plugin } from 'bun-plugin-stx';
2
-
3
- export type { ComponentDoc, ComponentPropDoc, CustomDirective, DirectiveDoc, DocFormat, DocGeneratorConfig, HydrationConfig, I18nConfig, Island, Middleware, StreamingConfig, StreamRenderer, StxConfig, StxOptions, TemplateDoc, WebComponent, WebComponentConfig } from './types'
4
-
5
- export { createTranslateFilter, getTranslation, loadTranslation, processTranslateDirective } from './i18n'
6
- export { markdownDirectiveHandler, processMarkdownDirectives } from './markdown'
7
- export { createStreamRenderer, islandDirective, processSectionDirectives, registerStreamingDirectives, streamTemplate } from './streaming'
8
- export { buildWebComponents, webComponentDirectiveHandler } from './web-components'
9
-
10
- export * from './auth'
11
- export * from './caching'
12
- export * from './config'
13
- export * from './custom-directives'
14
- export * from './docs'
15
- export * from './expressions'
16
- export * from './forms'
17
- export * from './includes'
18
- export * from './loops'
19
- export * from './middleware'
20
- export * from './process'
21
- export * from './types'
22
- export * from './utils'
23
-
24
- export default plugin;
1
+ export * from './a11y';
2
+ export * from './analyzer';
3
+ export * from './animation';
4
+ export * from './assets';
5
+ export * from './auth';
6
+ export * from './caching';
7
+ export * from './components';
8
+ export * from './config';
9
+ export * from './custom-directives';
10
+ export * from './dev-server';
11
+ export * from './docs';
12
+ export * from './error-handling';
13
+ export * from './expressions';
14
+ export * from './formatter';
15
+ export * from './forms';
16
+ export * from './i18n';
17
+ export * from './includes';
18
+ export * from './init';
19
+ export * from './loops';
20
+ export * from './markdown';
21
+ export * from './middleware';
22
+ export * from './process';
23
+ export * from './release';
24
+ export * from './seo';
25
+ export * from './serve';
26
+ export * from './streaming';
27
+ export * from './types';
28
+ export * from './utils';
29
+ export * from './web-components';
30
+ export default {};
package/dist/init.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Initialize a new stx file with the specified name
3
+ */
4
+ export declare function initFile(fileName?: string, options?: InitOptions): Promise<boolean>;
5
+ // Interface for init options
6
+ declare interface InitOptions {
7
+ force?: boolean
8
+ template?: string
9
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Process JavaScript directives in templates
3
+ * Executes JavaScript code on the server and removes the code blocks from output
4
+ */
5
+ export declare function processJsDirectives(template: string, context: Record<string, any>, filePath?: string): Promise<string>;
6
+ /**
7
+ * Process TypeScript directives in templates
8
+ * Executes TypeScript code on the server and removes the code blocks from output
9
+ */
10
+ export declare function processTsDirectives(template: string, context: Record<string, any>, filePath?: string): Promise<string>;
package/dist/loops.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export declare function processLoops(template: string, context: Record<string, any>, filePath: string): string;
2
- declare const loopKeys: unknown;
3
- declare let whileFn: (...args: any[]) => unknown;
1
+ /**
2
+ * Process loops (@foreach, @for, @while, @forelse)
3
+ */
4
+ export declare function processLoops(template: string, context: Record<string, any>, filePath: string): string;
@@ -1,2 +1,10 @@
1
+ /**
2
+ * Process markdown directives in templates
3
+ * Converts markdown content to HTML
4
+ */
1
5
  export declare function processMarkdownDirectives(template: string, context: Record<string, any>, filePath?: string): Promise<string>;
6
+ /**
7
+ * Custom directive handler for markdown
8
+ * Can be registered as a custom directive
9
+ */
2
10
  export declare function markdownDirectiveHandler(content: string, params: string[], _context: Record<string, any>, _filePath: string): Promise<string>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generate a method spoofing input field
3
+ */
4
+ export declare function methodField(method: string, fieldName?: string): string;
5
+ /**
6
+ * Process @method directives in templates
7
+ */
8
+ export declare function processMethodDirectives(template: string): string;
9
+ /**
10
+ * Helper to get the original method from a request
11
+ * For middleware implementations
12
+ */
13
+ export declare function getOriginalMethod(body: Record<string, any>, methodField?: string): string | null;
@@ -1,5 +1,13 @@
1
1
  import type { StxOptions } from './types';
2
-
2
+ /**
3
+ * Process middleware registered in the application
4
+ */
3
5
  export declare function processMiddleware(template: string, context: Record<string, any>, filePath: string, options: StxOptions, timing: 'before' | 'after'): Promise<string>;
6
+ /**
7
+ * Run pre-processing middleware
8
+ */
4
9
  export declare function runPreProcessingMiddleware(template: string, context: Record<string, any>, filePath: string, options: StxOptions): Promise<string>;
10
+ /**
11
+ * Run post-processing middleware
12
+ */
5
13
  export declare function runPostProcessingMiddleware(template: string, context: Record<string, any>, filePath: string, options: StxOptions): Promise<string>;