@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
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Get a cached regex pattern or compile and cache it
3
+ */
4
+ export declare function getCachedRegex(pattern: string, flags?: string): RegExp;
5
+ /**
6
+ * Debounce function calls to avoid excessive processing
7
+ */
8
+ export declare function debounce<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
9
+ /**
10
+ * Throttle function calls to limit execution frequency
11
+ */
12
+ export declare function throttle<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => ReturnType<T> | undefined;
13
+ /**
14
+ * Memoize function results to avoid repeated calculations
15
+ */
16
+ export declare function memoize<T extends (...args: any[]) => any>(func: T, maxCacheSize?: any): T;
17
+ /**
18
+ * Optimized string replacement that reuses regex patterns with case-preserving support
19
+ */
20
+ export declare function optimizedReplace(text: string, pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string), flags?: string): string;
21
+ // Global expression evaluator pool
22
+ export declare const expressionEvaluatorPool: ExpressionEvaluatorPool;
23
+ // Global performance monitor instance
24
+ export declare const performanceMonitor: PerformanceMonitor;
25
+ /**
26
+ * Cache for template processing results
27
+ */
28
+ export declare class TemplateCache {
29
+ private cache: any;
30
+ private maxSize: number;
31
+ private ttl: number;
32
+ constructor(maxSize?: any, ttl?: number);
33
+ get(key: string): string | null;
34
+ set(key: string, result: string, dependencies?: Set<string>): void;
35
+ invalidateDependency(filePath: string): number;
36
+ clear(): void;
37
+ getStats(): { size: number, maxSize: number, hitRate?: number };
38
+ }
39
+ /**
40
+ * Pool of worker contexts to avoid creating new Function instances
41
+ */
42
+ declare class ExpressionEvaluatorPool {
43
+ private pool: Array<{ func: (...args: any[]) => any, context: string[] }>;
44
+ private maxPoolSize: any;
45
+ getEvaluator(contextKeys: string[]): (...args: any[]) => any;
46
+ clear(): void;
47
+ }
48
+ /**
49
+ * Performance monitor for tracking processing times
50
+ */
51
+ export declare class PerformanceMonitor {
52
+ private metrics: any;
53
+ time<T>(label: string, fn: () => T): T;
54
+ timeAsync<T>(label: string, fn: () => Promise<T>): Promise<T>;
55
+ recordTime(label: string, duration: number): void;
56
+ getStats(label?: string): Record<string, any>;
57
+ clear(): void;
58
+ }
@@ -0,0 +1,2 @@
1
+ export declare const plugin: BunPlugin;
2
+ export default plugin;
package/dist/process.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import type { StxOptions } from './types';
2
-
2
+ /**
3
+ * Process all template directives with enhanced error handling and performance monitoring
4
+ */
3
5
  export declare function processDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
4
- declare function processOtherDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
5
- declare function processComponentDirectives(template: string, context: Record<string, any>, filePath: string, componentsDir: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
6
- declare let props: {};
7
- declare const propsFn: unknown;
8
- declare const processedContent: unknown;
9
- declare function processCustomElements(template: string, context: Record<string, any>, filePath: string, componentsDir: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
6
+ /**
7
+ * Process @json directive to output JSON
8
+ */
10
9
  export declare function processJsonDirective(template: string, context: Record<string, any>): string;
10
+ /**
11
+ * Process @once directive blocks
12
+ */
11
13
  export declare function processOnceDirective(template: string): string;
@@ -0,0 +1 @@
1
+ export declare const gitHash: string;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Set the base URL for the application
3
+ */
4
+ export declare function setAppUrl(url: string): void;
5
+ /**
6
+ * Register a route with a name
7
+ */
8
+ export declare function defineRoute(name: string, path: string, params?: Record<string, any>): void;
9
+ /**
10
+ * Define multiple routes at once
11
+ */
12
+ export declare function defineRoutes(routeDefinitions: Record<string, string | RouteDefinition>): void;
13
+ /**
14
+ * Generate a URL for a named route with parameters
15
+ */
16
+ export declare function route(name: string, params?: Record<string, any>, absolute?: any): string;
17
+ /**
18
+ * Create a route URL directive processor for stx templates
19
+ */
20
+ export declare function processRouteDirectives(template: string): string;
21
+ /**
22
+ * Reset all routes (mainly for testing)
23
+ */
24
+ export declare function resetRoutes(): void;
25
+ /**
26
+ * Laravel-like named routes system for stx
27
+ *
28
+ * This provides the ability to define routes with names and generate URLs for them,
29
+ * similar to Laravel's route naming and the route() helper.
30
+ */
31
+ /* eslint-disable no-new-func */
32
+ declare interface RouteDefinition {
33
+ path: string
34
+ name?: string
35
+ params?: Record<string, any>
36
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Sanitize an expression by checking for dangerous patterns
3
+ */
4
+ export declare function sanitizeExpression(expression: string): string;
5
+ /**
6
+ * Create a safer context object that only exposes safe properties
7
+ */
8
+ export declare function createSafeContext(context: Record<string, any>): Record<string, any>;
9
+ /**
10
+ * Safely evaluate an expression with the given context
11
+ */
12
+ export declare function safeEvaluate(expression: string, context: Record<string, any>): any;
13
+ /**
14
+ * Check if an expression is safe to evaluate
15
+ */
16
+ export declare function isExpressionSafe(expression: string): boolean;
package/dist/seo.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ import type { CustomDirective, StxOptions } from './types';
2
+ /**
3
+ * Process @meta directive for generating meta tags
4
+ */
5
+ export declare function processMetaDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions): string;
6
+ /**
7
+ * Process @structuredData directive for JSON-LD
8
+ */
9
+ export declare function processStructuredData(template: string, context: Record<string, any>, filePath: string): string;
10
+ /**
11
+ * Process @seo directive for automatic meta tag generation
12
+ */
13
+ export declare function processSeoDirective(template: string, context: Record<string, any>, filePath: string, options: StxOptions): string;
14
+ /**
15
+ * Injects default SEO tags if no @seo directive is used
16
+ */
17
+ export declare function injectSeoTags(html: string, context: Record<string, any>, options: StxOptions): string;
18
+ /**
19
+ * Register SEO directives
20
+ */
21
+ export declare function registerSeoDirectives(): CustomDirective[];
22
+ /**
23
+ * SEO meta directive for basic meta tag generation
24
+ */
25
+ export declare const metaDirective: CustomDirective;
26
+ /**
27
+ * SEO structured data directive for JSON-LD generation
28
+ */
29
+ export declare const structuredDataDirective: CustomDirective;
30
+ declare interface StructuredData {
31
+ '@context': string
32
+ '@type': string
33
+ }
@@ -0,0 +1,35 @@
1
+ import type { Server } from 'bun';
2
+ import type { StxOptions } from './types';
3
+ /**
4
+ * Serve a directory of stx templates and markdown files
5
+ * This is the main function for programmatic usage
6
+ */
7
+ export declare function serve(options?: ServeOptions): Promise<ServeResult>;
8
+ /**
9
+ * Serve a single stx or markdown file
10
+ */
11
+ export declare function serveFile(filePath: string, options?: Omit<ServeOptions, 'root'>): Promise<ServeResult>;
12
+ /**
13
+ * Create a middleware function
14
+ */
15
+ export declare function createMiddleware(handler: (request: Request, next: () => Response | Promise<Response>) => Response | Promise<Response>): (request: Request, next: () => Response | Promise<Response>) => Response | Promise<Response>;
16
+ /**
17
+ * Helper to create a route handler
18
+ */
19
+ export declare function createRoute(handler: (request: Request) => Response | Promise<Response>): (request: Request) => Response | Promise<Response>;
20
+ export declare interface ServeOptions {
21
+ port?: number
22
+ root?: string
23
+ stxOptions?: StxOptions
24
+ watch?: boolean
25
+ onRequest?: (request: Request) => Response | Promise<Response> | null | undefined
26
+ routes?: Record<string, (request: Request) => Response | Promise<Response>>
27
+ middleware?: Array<(request: Request, next: () => Response | Promise<Response>) => Response | Promise<Response>>
28
+ on404?: (request: Request) => Response | Promise<Response>
29
+ onError?: (error: Error, request: Request) => Response | Promise<Response>
30
+ }
31
+ export declare interface ServeResult {
32
+ server: Server
33
+ stop: () => void
34
+ url: string
35
+ }