@stacksjs/stx 0.2.155 → 0.2.157
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.
- package/dist/a11y.d.ts +87 -46
- package/dist/animation.d.ts +96 -42
- package/dist/appearance-bootstrap.d.ts +49 -15
- package/dist/asset-roots.d.ts +32 -0
- package/dist/asset-roots.js +7 -0
- package/dist/assets.d.ts +9 -7
- package/dist/async-components.d.ts +78 -56
- package/dist/auth.d.ts +3 -0
- package/dist/build-externalize.d.ts +40 -0
- package/dist/build-externalize.js +63 -0
- package/dist/build-id.d.ts +22 -22
- package/dist/build-message.d.ts +73 -2
- package/dist/build-message.js +47 -8
- package/dist/builtins/attrs.d.ts +14 -0
- package/dist/builtins/drawer.d.ts +22 -0
- package/dist/builtins/icon.d.ts +16 -2
- package/dist/builtins/index.d.ts +5 -15
- package/dist/builtins/modal.d.ts +24 -0
- package/dist/builtins/safe-image.d.ts +42 -0
- package/dist/builtins/stx-image.d.ts +27 -0
- package/dist/builtins/stx-link.d.ts +9 -0
- package/dist/builtins/stx-loading-indicator.d.ts +11 -0
- package/dist/builtins/suspense.d.ts +28 -0
- package/dist/builtins/toast.d.ts +17 -0
- package/dist/builtins/transition-group.d.ts +25 -0
- package/dist/caching.d.ts +12 -15
- package/dist/cli.js +1798 -908
- package/dist/client/directive.d.ts +7 -0
- package/dist/client/index.d.ts +0 -1
- package/dist/client-script-bundler.d.ts +63 -5
- package/dist/client-script-bundler.js +30 -2
- package/dist/client-script.d.ts +102 -47
- package/dist/client-script.js +15 -3
- package/dist/codemod.d.ts +56 -0
- package/dist/codemod.js +192 -0
- package/dist/color-mode-boot.d.ts +83 -65
- package/dist/component-client-factories.d.ts +1 -6
- package/dist/component-processing.d.ts +58 -49
- package/dist/component-processing.js +1 -1
- package/dist/component-registry.d.ts +94 -31
- package/dist/component-renderer.d.ts +18 -0
- package/dist/composable-loader.d.ts +24 -0
- package/dist/composable-loader.js +12 -9
- package/dist/composables/index.d.ts +7 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-fetch.js +30 -2
- package/dist/composables/use-form.d.ts +91 -0
- package/dist/composables/use-form.js +112 -0
- package/dist/composables.d.ts +64 -60
- package/dist/computed.d.ts +86 -92
- package/dist/conditionals.d.ts +24 -8
- package/dist/conditionals.js +16 -0
- package/dist/config.d.ts +34 -21
- package/dist/config.js +35 -14
- package/dist/craft.js +1476 -768
- package/dist/crosswind-config.d.ts +58 -0
- package/dist/crosswind-config.js +40 -0
- package/dist/csp.d.ts +107 -41
- package/dist/defer.d.ts +24 -0
- package/dist/dev-server/crosswind.d.ts +35 -26
- package/dist/dev-server/crosswind.js +2 -18
- package/dist/dev-server/serve-app.js +4 -3
- package/dist/dev-server/terminal-colors.d.ts +32 -32
- package/dist/directive-api.d.ts +86 -43
- package/dist/document-shell.d.ts +54 -41
- package/dist/dynamic-components.d.ts +9 -0
- package/dist/error-boundaries.d.ts +47 -41
- package/dist/error-handling.d.ts +1 -1
- package/dist/errors/codes.d.ts +51 -43
- package/dist/errors/formatter.d.ts +58 -38
- package/dist/errors/index.d.ts +5 -61
- package/dist/errors/logger.d.ts +114 -40
- package/dist/errors/sanitizer.d.ts +53 -23
- package/dist/errors/types.d.ts +44 -31
- package/dist/events.d.ts +86 -25
- package/dist/expressions.d.ts +50 -42
- package/dist/forms-validation.d.ts +138 -123
- package/dist/forms-validation.js +1 -90
- package/dist/forms.d.ts +120 -66
- package/dist/forms.js +31 -11
- package/dist/fragment-container.d.ts +57 -0
- package/dist/fragment-container.js +109 -0
- package/dist/framework-composables.d.ts +32 -0
- package/dist/head.d.ts +156 -114
- package/dist/heatmap.d.ts +152 -72
- package/dist/html-masking.d.ts +40 -34
- package/dist/hydration-runtime.d.ts +20 -24
- package/dist/i18n.d.ts +93 -32
- package/dist/image-optimization/auto-sibling.d.ts +32 -4
- package/dist/includes.d.ts +69 -7
- package/dist/index.d.ts +66 -0
- package/dist/index.js +23 -0
- package/dist/internal-markdown.d.ts +12 -8
- package/dist/island-chunking.d.ts +30 -13
- package/dist/keep-alive.d.ts +72 -52
- package/dist/layout-types.d.ts +45 -0
- package/dist/layout-types.js +56 -0
- package/dist/lazy-module.d.ts +10 -0
- package/dist/loops.d.ts +66 -0
- package/dist/loops.js +47 -6
- package/dist/markdown.d.ts +0 -1
- package/dist/media/image/component.d.ts +25 -9
- package/dist/media/image/directive.d.ts +15 -1
- package/dist/media/image/placeholder.d.ts +20 -9
- package/dist/media/image/processor/cache.d.ts +40 -18
- package/dist/media/image/processor/index.d.ts +1 -10
- package/dist/media/image/processor/optimizer.d.ts +12 -1
- package/dist/media/image/processor/responsive.d.ts +16 -6
- package/dist/media/image/srcset.d.ts +47 -50
- package/dist/media/shared/cache.d.ts +51 -31
- package/dist/media/shared/hash.d.ts +7 -0
- package/dist/media/types.d.ts +1235 -754
- package/dist/media/video/directive.d.ts +15 -1
- package/dist/media/video/index.d.ts +39 -17
- package/dist/media/video/processor/cache.d.ts +42 -19
- package/dist/media/video/processor/index.d.ts +1 -18
- package/dist/media/video/processor/streaming.d.ts +17 -10
- package/dist/media/video/processor/thumbnail.d.ts +21 -15
- package/dist/media/video/processor/transcoder.d.ts +11 -1
- package/dist/method-spoofing.d.ts +7 -0
- package/dist/middleware.d.ts +60 -0
- package/dist/owned-routes.d.ts +42 -0
- package/dist/owned-routes.js +26 -0
- package/dist/page-meta.d.ts +38 -0
- package/dist/page-meta.js +16 -0
- package/dist/parser/directive-parser.d.ts +57 -45
- package/dist/parser/expression-parser.d.ts +33 -35
- package/dist/parser/index.d.ts +4 -39
- package/dist/parser/tokenizer.d.ts +61 -49
- package/dist/partial-hydration.d.ts +82 -50
- package/dist/performance-utils.d.ts +217 -124
- package/dist/placeholder.d.ts +18 -9
- package/dist/plugin-system.d.ts +264 -115
- package/dist/process.d.ts +11 -6
- package/dist/process.js +21 -4
- package/dist/production-builder.js +7 -0
- package/dist/prop-sentinels.d.ts +11 -11
- package/dist/public-env.d.ts +14 -0
- package/dist/pwa/directives.d.ts +12 -3
- package/dist/pwa/inject.d.ts +10 -0
- package/dist/pwa/precache.d.ts +22 -16
- package/dist/pwa/service-worker.d.ts +12 -0
- package/dist/pwa.js +1318 -610
- package/dist/reactive-bindings.d.ts +34 -11
- package/dist/reactive.d.ts +58 -30
- package/dist/reactive.js +56 -31
- package/dist/render.d.ts +0 -14
- package/dist/render.js +17 -0
- package/dist/route-middleware.d.ts +2 -35
- package/dist/route-types.d.ts +134 -0
- package/dist/route-types.js +24 -0
- package/dist/router.d.ts +5 -7
- package/dist/routes.d.ts +1 -3
- package/dist/runtime-globals.d.ts +147 -24
- package/dist/runtime-globals.js +16 -1
- package/dist/runtime-injection.d.ts +8 -0
- package/dist/runtime-injection.js +33 -24
- package/dist/script-emit.d.ts +30 -0
- package/dist/script-json.d.ts +36 -0
- package/dist/script-json.js +6 -0
- package/dist/script-validation.d.ts +21 -4
- package/dist/seo.d.ts +118 -47
- package/dist/server-bindings.d.ts +21 -0
- package/dist/sfc-template.d.ts +8 -8
- package/dist/signal-processing.d.ts +35 -15
- package/dist/signals-api.d.ts +117 -58
- package/dist/signals-api.js +7 -4
- package/dist/signals.d.ts +24 -17
- package/dist/signals.js +765 -60
- package/dist/site-builder/build.js +8 -0
- package/dist/site-url.d.ts +46 -0
- package/dist/site-url.js +70 -0
- package/dist/slots.d.ts +86 -20
- package/dist/source-signature.d.ts +45 -0
- package/dist/source-signature.js +20 -0
- package/dist/ssg.d.ts +285 -142
- package/dist/ssg.js +1268 -556
- package/dist/state-dir.d.ts +4 -4
- package/dist/state-management.d.ts +0 -12
- package/dist/state-management.js +8 -25
- package/dist/store-imports.d.ts +23 -0
- package/dist/store-imports.js +3 -0
- package/dist/store-loader.d.ts +10 -0
- package/dist/store-loader.js +10 -9
- package/dist/story/analytics.d.ts +138 -60
- package/dist/story/bookmarks.d.ts +87 -34
- package/dist/story/cli.d.ts +123 -69
- package/dist/story/collect/scanner.d.ts +4 -0
- package/dist/story/collect/tree.d.ts +8 -1
- package/dist/story/commands/build.d.ts +11 -6
- package/dist/story/commands/dev.d.ts +15 -8
- package/dist/story/commands/preview.d.ts +13 -7
- package/dist/story/config-watcher.d.ts +20 -13
- package/dist/story/config.d.ts +11 -8
- package/dist/story/context.d.ts +14 -8
- package/dist/story/hmr.d.ts +24 -26
- package/dist/story/hot-swap.d.ts +34 -23
- package/dist/story/keyboard-shortcuts.d.ts +23 -18
- package/dist/story/output.d.ts +46 -44
- package/dist/story/performance.d.ts +107 -45
- package/dist/story/presets.d.ts +107 -41
- package/dist/story/renderer.d.ts +41 -27
- package/dist/story/search.d.ts +23 -12
- package/dist/story/server.d.ts +21 -11
- package/dist/story/setup.d.ts +23 -15
- package/dist/story/testing.d.ts +65 -40
- package/dist/story/types.d.ts +262 -160
- package/dist/streaming.d.ts +119 -57
- package/dist/stx-virtual-ts.d.ts +165 -0
- package/dist/stx-virtual-ts.js +372 -0
- package/dist/stx.d.ts +78 -1
- package/dist/style-scoping.d.ts +17 -4
- package/dist/suspense.d.ts +67 -52
- package/dist/teleport.d.ts +22 -0
- package/dist/template-tag-balance.d.ts +22 -6
- package/dist/transitions.d.ts +66 -55
- package/dist/typecheck.d.ts +77 -0
- package/dist/typecheck.js +156 -0
- package/dist/types/component-types.d.ts +187 -122
- package/dist/types/config-types.d.ts +758 -297
- package/dist/types/context-types.d.ts +46 -24
- package/dist/types/csp-types.d.ts +70 -66
- package/dist/types/directive-types.d.ts +211 -155
- package/dist/types/index.d.ts +6 -109
- package/dist/types/pwa-types.d.ts +273 -148
- package/dist/types.d.ts +0 -1
- package/dist/typescript-templates.d.ts +11 -0
- package/dist/unresolved-identifiers.d.ts +24 -22
- package/dist/unresolved-identifiers.js +2 -0
- package/dist/utils.d.ts +24 -21
- package/dist/validator.d.ts +28 -26
- package/dist/variable-extractor.d.ts +48 -13
- package/dist/variable-extractor.js +27 -4
- package/dist/view-composers.d.ts +80 -81
- package/dist/virtual-scrolling.d.ts +101 -81
- package/dist/vue-template.d.ts +23 -0
- package/dist/web-components/css-scoping.d.ts +21 -11
- package/dist/web-components.d.ts +81 -58
- package/dist/x-element.d.ts +0 -1
- package/package.json +5 -5
- package/stx.d.ts +78 -1
package/dist/errors/logger.d.ts
CHANGED
|
@@ -1,61 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Error Logger and Recovery
|
|
3
|
+
*
|
|
4
|
+
* Provides error logging, recovery strategies, and development helpers.
|
|
5
|
+
*
|
|
6
|
+
* @module errors/logger
|
|
7
|
+
*/
|
|
6
8
|
/**
|
|
7
9
|
* Error recovery strategies
|
|
8
10
|
*
|
|
9
11
|
* NOTE: Auto-recovery is opt-in via configuration.
|
|
10
12
|
* Use configureErrorHandling({ enableAutoRecovery: true }) to enable.
|
|
11
13
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
export interface ErrorRecovery {
|
|
15
|
+
isEnabled(): boolean;
|
|
16
|
+
fixCommonSyntaxErrors(template: string): {
|
|
17
|
+
fixed: string;
|
|
18
|
+
fixes: string[];
|
|
19
|
+
};
|
|
20
|
+
createFallbackContent(sectionType: string, error: Error): string;
|
|
16
21
|
}
|
|
22
|
+
export declare const errorRecovery: ErrorRecovery;
|
|
17
23
|
/**
|
|
18
24
|
* Error logger configuration options
|
|
19
25
|
*/
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
export interface ErrorLoggerOptions {
|
|
27
|
+
/** Maximum number of errors to keep in memory (default: 1000) */
|
|
28
|
+
maxErrors?: number;
|
|
29
|
+
/** Enable file logging */
|
|
30
|
+
enableFileLogging?: boolean;
|
|
31
|
+
/** Path to log file (default: '.stx/errors.log') */
|
|
32
|
+
logFilePath?: string;
|
|
33
|
+
/** Log format: 'json' for structured logs, 'text' for human-readable (default: 'json') */
|
|
34
|
+
logFormat?: 'json' | 'text';
|
|
35
|
+
/** Maximum log file size in bytes before rotation (default: 10MB) */
|
|
36
|
+
maxFileSize?: number;
|
|
37
|
+
/** Number of rotated log files to keep (default: 5) */
|
|
38
|
+
maxLogFiles?: number;
|
|
39
|
+
/** Minimum error level to log to file: 'all', 'error', 'warning' (default: 'all') */
|
|
40
|
+
minLevel?: 'all' | 'error' | 'warning';
|
|
28
41
|
}
|
|
29
42
|
/**
|
|
30
43
|
* Error log entry structure
|
|
31
44
|
*/
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
export interface ErrorLogEntry {
|
|
46
|
+
timestamp: Date;
|
|
47
|
+
error: Error;
|
|
48
|
+
context?: unknown;
|
|
49
|
+
level?: 'error' | 'warning' | 'info';
|
|
37
50
|
}
|
|
38
51
|
/**
|
|
39
|
-
*
|
|
52
|
+
* Error logging and monitoring with optional file persistence
|
|
40
53
|
*/
|
|
41
|
-
export declare
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
export declare class ErrorLogger {
|
|
55
|
+
private errors;
|
|
56
|
+
private maxErrors;
|
|
57
|
+
private enableFileLogging;
|
|
58
|
+
private logFilePath;
|
|
59
|
+
private logFormat;
|
|
60
|
+
private maxFileSize;
|
|
61
|
+
private maxLogFiles;
|
|
62
|
+
private minLevel;
|
|
63
|
+
private writeQueue;
|
|
64
|
+
constructor(options?: ErrorLoggerOptions);
|
|
65
|
+
/**
|
|
66
|
+
* Configure the error logger
|
|
67
|
+
*/
|
|
68
|
+
configure(options: ErrorLoggerOptions): void;
|
|
69
|
+
/**
|
|
70
|
+
* Log an error with optional context
|
|
71
|
+
*/
|
|
72
|
+
log(error: Error, context?: unknown, level?: 'error' | 'warning' | 'info'): void;
|
|
73
|
+
/**
|
|
74
|
+
* Check if error level should be logged based on minLevel setting
|
|
75
|
+
*/
|
|
76
|
+
private shouldLog;
|
|
77
|
+
/**
|
|
78
|
+
* Format an error entry for logging
|
|
79
|
+
*/
|
|
80
|
+
private formatEntry;
|
|
81
|
+
/**
|
|
82
|
+
* Write error entry to file (async, non-blocking)
|
|
83
|
+
*/
|
|
84
|
+
private writeToFile;
|
|
85
|
+
/**
|
|
86
|
+
* Rotate log files if current file exceeds max size
|
|
87
|
+
*/
|
|
88
|
+
private rotateIfNeeded;
|
|
89
|
+
/**
|
|
90
|
+
* Get recent errors from memory
|
|
91
|
+
*/
|
|
92
|
+
getRecentErrors(limit?: number): ErrorLogEntry[];
|
|
93
|
+
/**
|
|
94
|
+
* Get errors filtered by type
|
|
95
|
+
*/
|
|
96
|
+
getErrorsByType(errorType: string): ErrorLogEntry[];
|
|
97
|
+
/**
|
|
98
|
+
* Get errors filtered by level
|
|
99
|
+
*/
|
|
100
|
+
getErrorsByLevel(level: 'error' | 'warning' | 'info'): ErrorLogEntry[];
|
|
101
|
+
/**
|
|
102
|
+
* Clear all errors from memory
|
|
103
|
+
*/
|
|
104
|
+
clear(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Clear log file
|
|
107
|
+
*/
|
|
108
|
+
clearLogFile(): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Get error statistics
|
|
111
|
+
*/
|
|
112
|
+
getStats(): {
|
|
113
|
+
total: number;
|
|
114
|
+
byType: Record<string, number>;
|
|
115
|
+
byLevel: Record<string, number>;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Export errors to a file (for debugging/reporting)
|
|
119
|
+
*/
|
|
120
|
+
exportToFile(filePath: string, format?: 'json' | 'text'): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Wait for all pending writes to complete
|
|
123
|
+
*/
|
|
124
|
+
flush(): Promise<void>;
|
|
45
125
|
}
|
|
126
|
+
export declare const errorLogger: ErrorLogger;
|
|
46
127
|
/**
|
|
47
|
-
*
|
|
128
|
+
* Development mode helpers
|
|
48
129
|
*/
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
getRecentErrors(limit?: number): ErrorLogEntry[];
|
|
54
|
-
getErrorsByType(errorType: string): ErrorLogEntry[];
|
|
55
|
-
getErrorsByLevel(level: 'error' | 'warning' | 'info'): ErrorLogEntry[];
|
|
56
|
-
clear(): void;
|
|
57
|
-
clearLogFile(): Promise<void>;
|
|
58
|
-
getStats(): { total: number, byType: Record<string, number>, byLevel: Record<string, number> };
|
|
59
|
-
exportToFile(filePath: string, format?: 'json' | 'text'): Promise<void>;
|
|
60
|
-
flush(): Promise<void>;
|
|
130
|
+
export interface DevHelpers {
|
|
131
|
+
isDevelopment(): boolean;
|
|
132
|
+
logDetailedError(error: Error, context?: unknown): void;
|
|
133
|
+
createErrorReport(error: Error, context?: unknown): string;
|
|
61
134
|
}
|
|
135
|
+
export declare const devHelpers: DevHelpers;
|
|
@@ -1,3 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameter and Content Sanitization
|
|
3
|
+
*
|
|
4
|
+
* Provides sanitization utilities for directive parameters, file paths,
|
|
5
|
+
* expressions, and component props.
|
|
6
|
+
*
|
|
7
|
+
* @module errors/sanitizer
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Options for parameter sanitization
|
|
11
|
+
*/
|
|
12
|
+
export interface SanitizeOptions {
|
|
13
|
+
/** Allow HTML in parameter values (default: false) */
|
|
14
|
+
allowHtml?: boolean;
|
|
15
|
+
/** Maximum length for string parameters (default: 10000) */
|
|
16
|
+
maxLength?: number;
|
|
17
|
+
/** Allow special characters (default: true for most, false for paths) */
|
|
18
|
+
allowSpecialChars?: boolean;
|
|
19
|
+
/** Custom sanitization function */
|
|
20
|
+
customSanitizer?: (value: string) => string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Result of parameter sanitization
|
|
24
|
+
*/
|
|
25
|
+
export interface SanitizedParam {
|
|
26
|
+
/** Sanitized value */
|
|
27
|
+
value: string;
|
|
28
|
+
/** Whether the value was modified */
|
|
29
|
+
modified: boolean;
|
|
30
|
+
/** Warnings generated during sanitization */
|
|
31
|
+
warnings: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validation utilities
|
|
35
|
+
*/
|
|
36
|
+
export declare const validators: {
|
|
37
|
+
/**
|
|
38
|
+
* Validate file path is safe and doesn't escape the allowed directory
|
|
39
|
+
*/
|
|
40
|
+
isValidFilePath(filePath: string, allowedDir?: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Validate template variable name
|
|
43
|
+
*/
|
|
44
|
+
isValidVariableName(name: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Validate directive name
|
|
47
|
+
*/
|
|
48
|
+
isValidDirectiveName(name: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Check if string contains potentially malicious content
|
|
51
|
+
*/
|
|
52
|
+
isSafeContent(content: string): boolean;
|
|
53
|
+
};
|
|
1
54
|
/**
|
|
2
55
|
* Sanitize a directive parameter value
|
|
3
56
|
*/
|
|
@@ -18,26 +71,3 @@ export declare function sanitizeDirectiveParams(params: string[], options?: Sani
|
|
|
18
71
|
* Validate and sanitize component props
|
|
19
72
|
*/
|
|
20
73
|
export declare function sanitizeComponentProps(props: Record<string, unknown>): Record<string, unknown>;
|
|
21
|
-
/**
|
|
22
|
-
* Validation utilities
|
|
23
|
-
*/
|
|
24
|
-
export declare const validators: {
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Options for parameter sanitization
|
|
29
|
-
*/
|
|
30
|
-
export declare interface SanitizeOptions {
|
|
31
|
-
allowHtml?: boolean
|
|
32
|
-
maxLength?: number
|
|
33
|
-
allowSpecialChars?: boolean
|
|
34
|
-
customSanitizer?: (value: string) => string
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Result of parameter sanitization
|
|
38
|
-
*/
|
|
39
|
-
export declare interface SanitizedParam {
|
|
40
|
-
value: string
|
|
41
|
-
modified: boolean
|
|
42
|
-
warnings: string[]
|
|
43
|
-
}
|
package/dist/errors/types.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Types and Classes
|
|
3
|
+
*
|
|
4
|
+
* Custom error classes for better error classification and handling.
|
|
5
|
+
*
|
|
6
|
+
* @module errors/types
|
|
7
|
+
*/
|
|
1
8
|
import type { ErrorCode } from './codes';
|
|
9
|
+
/**
|
|
10
|
+
* Error handling configuration
|
|
11
|
+
*/
|
|
12
|
+
export interface ErrorConfig {
|
|
13
|
+
/** Show relative paths instead of absolute (default: false) */
|
|
14
|
+
showRelativePaths: boolean;
|
|
15
|
+
/** Base directory for relative path calculation */
|
|
16
|
+
baseDir?: string;
|
|
17
|
+
/** Enable auto-recovery for common syntax errors (default: false in production) */
|
|
18
|
+
enableAutoRecovery: boolean;
|
|
19
|
+
/** Log warnings when auto-recovery is applied */
|
|
20
|
+
logRecoveryWarnings: boolean;
|
|
21
|
+
}
|
|
2
22
|
/**
|
|
3
23
|
* Configure error handling behavior
|
|
4
24
|
*/
|
|
@@ -15,65 +35,58 @@ export declare function resetErrorConfig(): void;
|
|
|
15
35
|
* Format file path based on configuration
|
|
16
36
|
*/
|
|
17
37
|
export declare function formatFilePath(filePath: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Error handling configuration
|
|
20
|
-
*/
|
|
21
|
-
export declare interface ErrorConfig {
|
|
22
|
-
showRelativePaths: boolean
|
|
23
|
-
baseDir?: string
|
|
24
|
-
enableAutoRecovery: boolean
|
|
25
|
-
logRecoveryWarnings: boolean
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Error context information
|
|
29
|
-
*/
|
|
30
|
-
export declare interface ErrorContext {
|
|
31
|
-
filePath: string
|
|
32
|
-
template: string
|
|
33
|
-
offset: number
|
|
34
|
-
match: string
|
|
35
|
-
}
|
|
36
38
|
/**
|
|
37
39
|
* Base STX error class
|
|
38
40
|
*/
|
|
39
41
|
export declare class StxError extends Error {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
code: string;
|
|
43
|
+
filePath?: string | undefined;
|
|
44
|
+
line?: number | undefined;
|
|
45
|
+
column?: number | undefined;
|
|
46
|
+
context?: string | undefined;
|
|
47
|
+
/** Numeric error code for programmatic handling */
|
|
48
|
+
numericCode: ErrorCode;
|
|
49
|
+
constructor(message: string, code: string, filePath?: string | undefined, line?: number | undefined, column?: number | undefined, context?: string | undefined, numericCode?: ErrorCode);
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
52
|
* Syntax error in template
|
|
50
53
|
*/
|
|
51
54
|
export declare class StxSyntaxError extends StxError {
|
|
52
|
-
|
|
55
|
+
constructor(message: string, filePath?: string, line?: number, column?: number, context?: string, numericCode?: ErrorCode);
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
58
|
* Runtime error during template processing
|
|
56
59
|
*/
|
|
57
60
|
export declare class StxRuntimeError extends StxError {
|
|
58
|
-
|
|
61
|
+
constructor(message: string, filePath?: string, line?: number, column?: number, context?: string, numericCode?: ErrorCode);
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
61
64
|
* Security-related error
|
|
62
65
|
*/
|
|
63
66
|
export declare class StxSecurityError extends StxError {
|
|
64
|
-
|
|
67
|
+
constructor(message: string, filePath?: string, line?: number, column?: number, context?: string, numericCode?: ErrorCode);
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
70
|
* File operation error
|
|
68
71
|
*/
|
|
69
72
|
export declare class StxFileError extends StxError {
|
|
70
|
-
|
|
73
|
+
constructor(message: string, filePath?: string, line?: number, column?: number, context?: string, numericCode?: ErrorCode);
|
|
71
74
|
}
|
|
72
75
|
/**
|
|
73
76
|
* Validation error - these are ALWAYS fatal and cannot be recovered from.
|
|
74
77
|
* Used for enforcing coding standards like prohibited DOM API usage.
|
|
75
78
|
*/
|
|
76
79
|
export declare class StxValidationError extends StxError {
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
/** Validation errors are always fatal and should never be caught/recovered */
|
|
81
|
+
readonly isFatal: boolean;
|
|
82
|
+
constructor(message: string, filePath?: string, line?: number, column?: number, context?: string, numericCode?: ErrorCode);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Error context information
|
|
86
|
+
*/
|
|
87
|
+
export interface ErrorContext {
|
|
88
|
+
filePath: string;
|
|
89
|
+
template: string;
|
|
90
|
+
offset: number;
|
|
91
|
+
match: string;
|
|
79
92
|
}
|
package/dist/events.d.ts
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Directives Module
|
|
3
|
+
*
|
|
4
|
+
* Provides Alpine.js-style event handling for STX templates.
|
|
5
|
+
* Transforms `@click`, `@keydown.enter`, etc. into client-side event listeners.
|
|
6
|
+
*
|
|
7
|
+
* ## Supported Syntax
|
|
8
|
+
*
|
|
9
|
+
* ### Basic Events
|
|
10
|
+
* ```html
|
|
11
|
+
* <button @click="count++">Increment</button>
|
|
12
|
+
* <button @click="handleClick()">Click me</button>
|
|
13
|
+
* <form @submit="handleSubmit()">...</form>
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ### Event Modifiers
|
|
17
|
+
* ```html
|
|
18
|
+
* <form @submit.prevent="handleSubmit()">...</form>
|
|
19
|
+
* <a @click.prevent.stop="navigate()">Link</a>
|
|
20
|
+
* <button @click.once="initialize()">Init</button>
|
|
21
|
+
* <div @click.self="onlyThis()">...</div>
|
|
22
|
+
* <input @keydown.capture="log()">
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ### Key Modifiers
|
|
26
|
+
* ```html
|
|
27
|
+
* <input @keydown.enter="submit()">
|
|
28
|
+
* <input @keyup.escape="cancel()">
|
|
29
|
+
* <input @keydown.space="toggle()">
|
|
30
|
+
* <input @keydown.ctrl.s="save()">
|
|
31
|
+
* <input @keydown.meta.enter="send()">
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ### Mouse Modifiers
|
|
35
|
+
* ```html
|
|
36
|
+
* <div @click.left="handleLeft()">
|
|
37
|
+
* <div @click.right="handleRight()">
|
|
38
|
+
* <div @click.middle="handleMiddle()">
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* ### Special Variables
|
|
42
|
+
* ```html
|
|
43
|
+
* <input @input="value = $event.target.value">
|
|
44
|
+
* <button @click="handleClick($el)">Uses element</button>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @module events
|
|
48
|
+
*/
|
|
49
|
+
export interface ParsedEvent {
|
|
50
|
+
/** Original attribute string (e.g., "@click.prevent") */
|
|
51
|
+
attribute: string;
|
|
52
|
+
/** Event name (e.g., "click", "keydown") */
|
|
53
|
+
event: string;
|
|
54
|
+
/** Handler expression (e.g., "count++", "handleClick()") */
|
|
55
|
+
handler: string;
|
|
56
|
+
/** Event modifiers */
|
|
57
|
+
modifiers: EventModifiers;
|
|
58
|
+
/** Unique element ID for binding */
|
|
59
|
+
elementId: string;
|
|
60
|
+
}
|
|
61
|
+
export interface EventModifiers {
|
|
62
|
+
/** Call preventDefault() */
|
|
63
|
+
prevent: boolean;
|
|
64
|
+
/** Call stopPropagation() */
|
|
65
|
+
stop: boolean;
|
|
66
|
+
/** Only fire once */
|
|
67
|
+
once: boolean;
|
|
68
|
+
/** Use capture mode */
|
|
69
|
+
capture: boolean;
|
|
70
|
+
/** Only fire if event.target === element */
|
|
71
|
+
self: boolean;
|
|
72
|
+
/** Passive event listener */
|
|
73
|
+
passive: boolean;
|
|
74
|
+
/** Key modifiers (enter, escape, space, etc.) */
|
|
75
|
+
keys: string[];
|
|
76
|
+
/** System modifiers (ctrl, alt, shift, meta) */
|
|
77
|
+
systemKeys: string[];
|
|
78
|
+
/** Mouse button (left, right, middle) */
|
|
79
|
+
mouse: string | null;
|
|
80
|
+
/** Debounce delay in ms */
|
|
81
|
+
debounce: number | null;
|
|
82
|
+
/** Throttle delay in ms */
|
|
83
|
+
throttle: number | null;
|
|
84
|
+
}
|
|
1
85
|
/**
|
|
2
86
|
* `@click="doThing"` names a function, so it must be INVOKED — not evaluated.
|
|
3
87
|
*
|
|
@@ -36,8 +120,8 @@ export declare function generateRuntimeScript(events: ParsedEvent[]): string;
|
|
|
36
120
|
* @returns Object with processed template and collected bindings
|
|
37
121
|
*/
|
|
38
122
|
export declare function extractAndProcessEvents(template: string): {
|
|
39
|
-
|
|
40
|
-
|
|
123
|
+
template: string;
|
|
124
|
+
bindings: ParsedEvent[];
|
|
41
125
|
};
|
|
42
126
|
/**
|
|
43
127
|
* Process event directives in a template.
|
|
@@ -59,26 +143,3 @@ export declare function processEventDirectives(template: string, context: Record
|
|
|
59
143
|
* Check if a template contains event directives
|
|
60
144
|
*/
|
|
61
145
|
export declare function hasEventDirectives(template: string): boolean;
|
|
62
|
-
// =============================================================================
|
|
63
|
-
// Types
|
|
64
|
-
// =============================================================================
|
|
65
|
-
export declare interface ParsedEvent {
|
|
66
|
-
attribute: string
|
|
67
|
-
event: string
|
|
68
|
-
handler: string
|
|
69
|
-
modifiers: EventModifiers
|
|
70
|
-
elementId: string
|
|
71
|
-
}
|
|
72
|
-
export declare interface EventModifiers {
|
|
73
|
-
prevent: boolean
|
|
74
|
-
stop: boolean
|
|
75
|
-
once: boolean
|
|
76
|
-
capture: boolean
|
|
77
|
-
self: boolean
|
|
78
|
-
passive: boolean
|
|
79
|
-
keys: string[]
|
|
80
|
-
systemKeys: string[]
|
|
81
|
-
mouse: string | null
|
|
82
|
-
debounce: number | null
|
|
83
|
-
throttle: number | null
|
|
84
|
-
}
|
package/dist/expressions.d.ts
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module for processing template expressions and filters
|
|
3
|
+
*
|
|
4
|
+
* Expression Syntax:
|
|
5
|
+
* ==================
|
|
6
|
+
* - `{{ expression }}` - Escaped output (HTML entities escaped)
|
|
7
|
+
* - `{!! expression !!}` - Raw/unescaped output
|
|
8
|
+
* - `{{ expression | filter }}` - Apply filter to expression
|
|
9
|
+
* - `{{ expression | filter:arg1,arg2 }}` - Filter with arguments
|
|
10
|
+
* - `{{ expression | filter1 | filter2 }}` - Filter chain
|
|
11
|
+
*
|
|
12
|
+
* Filter Parsing:
|
|
13
|
+
* ===============
|
|
14
|
+
* The filter parser uses character-by-character parsing to handle:
|
|
15
|
+
* - Pipe `|` as filter separator (but not `||` logical OR)
|
|
16
|
+
* - Colon `:` as argument separator
|
|
17
|
+
* - Quoted strings with proper escape handling
|
|
18
|
+
* - Nested parentheses in expressions
|
|
19
|
+
*
|
|
20
|
+
* Key parsing rules:
|
|
21
|
+
* - `||` (double pipe) is preserved as logical OR, not filter separator
|
|
22
|
+
* - Arguments after `:` are split by `,` respecting quotes and parens
|
|
23
|
+
* - Filter names must be alphanumeric with underscores
|
|
24
|
+
*
|
|
25
|
+
* Available Built-in Filters:
|
|
26
|
+
* ===========================
|
|
27
|
+
* String: uppercase, lowercase, capitalize, truncate, replace, stripTags
|
|
28
|
+
* Number: number, currency, abs, round
|
|
29
|
+
* Array: join, first, last, length, reverse, slice
|
|
30
|
+
* Utility: escape, json, default, urlencode
|
|
31
|
+
* i18n: translate, pluralize, date
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Add basic filter support to expressions
|
|
35
|
+
* Filter functions receive the value to transform, optional args, and the context object
|
|
36
|
+
*/
|
|
37
|
+
export type FilterFunction = (value: any, context: Record<string, any>, ...args: any[]) => any;
|
|
38
|
+
export declare const defaultFilters: Record<string, FilterFunction>;
|
|
1
39
|
/**
|
|
2
40
|
* Register a custom filter
|
|
3
41
|
*
|
|
@@ -68,6 +106,18 @@ export declare function usesSignalsInScript(template: string): boolean;
|
|
|
68
106
|
* attributes and surrounding HTML are left alone.
|
|
69
107
|
*/
|
|
70
108
|
export declare function interpolateScriptExpressions(scriptBody: string, context: Record<string, any>): string;
|
|
109
|
+
/**
|
|
110
|
+
* Options for {@link interpolateScriptsInTemplate}.
|
|
111
|
+
*/
|
|
112
|
+
export interface InterpolateScriptsOptions {
|
|
113
|
+
/**
|
|
114
|
+
* Skip `<script server>` tags. Useful when the template still contains
|
|
115
|
+
* unstripped server scripts (e.g. inside `processDirectives`) whose bodies
|
|
116
|
+
* are executed rather than embedded — running `{{ }}` substitution on
|
|
117
|
+
* them would produce invalid JS. Default: `false`.
|
|
118
|
+
*/
|
|
119
|
+
skipServer?: boolean;
|
|
120
|
+
}
|
|
71
121
|
/**
|
|
72
122
|
* Interpolate server expressions inside every `<script>` tag in a template,
|
|
73
123
|
* skipping any script that opts out via `data-raw`, `type="application/json"`,
|
|
@@ -97,45 +147,3 @@ export declare function evaluateExpression(expression: string, context: Record<s
|
|
|
97
147
|
* HTML unescape function to reverse escapeHtml
|
|
98
148
|
*/
|
|
99
149
|
export declare function unescapeHtml(html: string): string;
|
|
100
|
-
// =============================================================================
|
|
101
|
-
// Built-in Filters
|
|
102
|
-
// =============================================================================
|
|
103
|
-
export declare const defaultFilters: {
|
|
104
|
-
uppercase: (value: any, _context: Record<string, any>) => unknown;
|
|
105
|
-
lowercase: (value: any, _context: Record<string, any>) => unknown;
|
|
106
|
-
capitalize: (value: any, _context: Record<string, any>) => unknown;
|
|
107
|
-
number: (value: any, _context: Record<string, any>, decimals?: number) => unknown;
|
|
108
|
-
fmt: (value: any, _context: Record<string, any>, locale?: string) => unknown;
|
|
109
|
-
join: (value: any, _context: Record<string, any>, separator?: string) => unknown;
|
|
110
|
-
escape: (value: any, _context: Record<string, any>) => unknown;
|
|
111
|
-
translate: (value: any, context: Record<string, any>, params?: Record<string, any>) => unknown;
|
|
112
|
-
t: (value: any, context: Record<string, any>, params?: Record<string, any>) => unknown;
|
|
113
|
-
truncate: (value: any, _context: Record<string, any>, length?: number, suffix?: string) => unknown;
|
|
114
|
-
date: (value: any, _context: Record<string, any>, format?: string, locale?: string) => unknown;
|
|
115
|
-
currency: (value: any, _context: Record<string, any>, currencyCode?: string, locale?: string) => unknown;
|
|
116
|
-
pluralize: (value: any, _context: Record<string, any>, singular: string, plural?: string) => unknown;
|
|
117
|
-
first: (value: any, _context: Record<string, any>) => unknown;
|
|
118
|
-
last: (value: any, _context: Record<string, any>) => unknown;
|
|
119
|
-
length: (value: any, _context: Record<string, any>) => unknown;
|
|
120
|
-
json: (value: any, _context: Record<string, any>, pretty?: boolean) => unknown;
|
|
121
|
-
default: (value: any, _context: Record<string, any>, defaultValue?: any) => unknown;
|
|
122
|
-
reverse: (value: any, _context: Record<string, any>) => unknown;
|
|
123
|
-
slice: (value: any, _context: Record<string, any>, start?: number, end?: number) => unknown;
|
|
124
|
-
replace: (value: any, _context: Record<string, any>, search: string, replacement?: string) => unknown;
|
|
125
|
-
stripTags: (value: any, _context: Record<string, any>) => unknown;
|
|
126
|
-
urlencode: (value: any, _context: Record<string, any>) => unknown;
|
|
127
|
-
abs: (value: any, _context: Record<string, any>) => unknown;
|
|
128
|
-
round: (value: any, _context: Record<string, any>, decimals?: number) => unknown
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Options for {@link interpolateScriptsInTemplate}.
|
|
132
|
-
*/
|
|
133
|
-
export declare interface InterpolateScriptsOptions {
|
|
134
|
-
skipServer?: boolean
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Add basic filter support to expressions
|
|
138
|
-
* Filter functions receive the value to transform, optional args, and the context object
|
|
139
|
-
*/
|
|
140
|
-
// eslint-disable-next-line pickier/no-unused-vars
|
|
141
|
-
export type FilterFunction = (value: any, context: Record<string, any>, ...args: any[]) => any;
|