@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.
Files changed (241) hide show
  1. package/dist/a11y.d.ts +87 -46
  2. package/dist/animation.d.ts +96 -42
  3. package/dist/appearance-bootstrap.d.ts +49 -15
  4. package/dist/asset-roots.d.ts +32 -0
  5. package/dist/asset-roots.js +7 -0
  6. package/dist/assets.d.ts +9 -7
  7. package/dist/async-components.d.ts +78 -56
  8. package/dist/auth.d.ts +3 -0
  9. package/dist/build-externalize.d.ts +40 -0
  10. package/dist/build-externalize.js +63 -0
  11. package/dist/build-id.d.ts +22 -22
  12. package/dist/build-message.d.ts +73 -2
  13. package/dist/build-message.js +47 -8
  14. package/dist/builtins/attrs.d.ts +14 -0
  15. package/dist/builtins/drawer.d.ts +22 -0
  16. package/dist/builtins/icon.d.ts +16 -2
  17. package/dist/builtins/index.d.ts +5 -15
  18. package/dist/builtins/modal.d.ts +24 -0
  19. package/dist/builtins/safe-image.d.ts +42 -0
  20. package/dist/builtins/stx-image.d.ts +27 -0
  21. package/dist/builtins/stx-link.d.ts +9 -0
  22. package/dist/builtins/stx-loading-indicator.d.ts +11 -0
  23. package/dist/builtins/suspense.d.ts +28 -0
  24. package/dist/builtins/toast.d.ts +17 -0
  25. package/dist/builtins/transition-group.d.ts +25 -0
  26. package/dist/caching.d.ts +12 -15
  27. package/dist/cli.js +1798 -908
  28. package/dist/client/directive.d.ts +7 -0
  29. package/dist/client/index.d.ts +0 -1
  30. package/dist/client-script-bundler.d.ts +63 -5
  31. package/dist/client-script-bundler.js +30 -2
  32. package/dist/client-script.d.ts +102 -47
  33. package/dist/client-script.js +15 -3
  34. package/dist/codemod.d.ts +56 -0
  35. package/dist/codemod.js +192 -0
  36. package/dist/color-mode-boot.d.ts +83 -65
  37. package/dist/component-client-factories.d.ts +1 -6
  38. package/dist/component-processing.d.ts +58 -49
  39. package/dist/component-processing.js +1 -1
  40. package/dist/component-registry.d.ts +94 -31
  41. package/dist/component-renderer.d.ts +18 -0
  42. package/dist/composable-loader.d.ts +24 -0
  43. package/dist/composable-loader.js +12 -9
  44. package/dist/composables/index.d.ts +7 -0
  45. package/dist/composables/index.js +1 -0
  46. package/dist/composables/use-fetch.js +30 -2
  47. package/dist/composables/use-form.d.ts +91 -0
  48. package/dist/composables/use-form.js +112 -0
  49. package/dist/composables.d.ts +64 -60
  50. package/dist/computed.d.ts +86 -92
  51. package/dist/conditionals.d.ts +24 -8
  52. package/dist/conditionals.js +16 -0
  53. package/dist/config.d.ts +34 -21
  54. package/dist/config.js +35 -14
  55. package/dist/craft.js +1476 -768
  56. package/dist/crosswind-config.d.ts +58 -0
  57. package/dist/crosswind-config.js +40 -0
  58. package/dist/csp.d.ts +107 -41
  59. package/dist/defer.d.ts +24 -0
  60. package/dist/dev-server/crosswind.d.ts +35 -26
  61. package/dist/dev-server/crosswind.js +2 -18
  62. package/dist/dev-server/serve-app.js +4 -3
  63. package/dist/dev-server/terminal-colors.d.ts +32 -32
  64. package/dist/directive-api.d.ts +86 -43
  65. package/dist/document-shell.d.ts +54 -41
  66. package/dist/dynamic-components.d.ts +9 -0
  67. package/dist/error-boundaries.d.ts +47 -41
  68. package/dist/error-handling.d.ts +1 -1
  69. package/dist/errors/codes.d.ts +51 -43
  70. package/dist/errors/formatter.d.ts +58 -38
  71. package/dist/errors/index.d.ts +5 -61
  72. package/dist/errors/logger.d.ts +114 -40
  73. package/dist/errors/sanitizer.d.ts +53 -23
  74. package/dist/errors/types.d.ts +44 -31
  75. package/dist/events.d.ts +86 -25
  76. package/dist/expressions.d.ts +50 -42
  77. package/dist/forms-validation.d.ts +138 -123
  78. package/dist/forms-validation.js +1 -90
  79. package/dist/forms.d.ts +120 -66
  80. package/dist/forms.js +31 -11
  81. package/dist/fragment-container.d.ts +57 -0
  82. package/dist/fragment-container.js +109 -0
  83. package/dist/framework-composables.d.ts +32 -0
  84. package/dist/head.d.ts +156 -114
  85. package/dist/heatmap.d.ts +152 -72
  86. package/dist/html-masking.d.ts +40 -34
  87. package/dist/hydration-runtime.d.ts +20 -24
  88. package/dist/i18n.d.ts +93 -32
  89. package/dist/image-optimization/auto-sibling.d.ts +32 -4
  90. package/dist/includes.d.ts +69 -7
  91. package/dist/index.d.ts +66 -0
  92. package/dist/index.js +23 -0
  93. package/dist/internal-markdown.d.ts +12 -8
  94. package/dist/island-chunking.d.ts +30 -13
  95. package/dist/keep-alive.d.ts +72 -52
  96. package/dist/layout-types.d.ts +45 -0
  97. package/dist/layout-types.js +56 -0
  98. package/dist/lazy-module.d.ts +10 -0
  99. package/dist/loops.d.ts +66 -0
  100. package/dist/loops.js +47 -6
  101. package/dist/markdown.d.ts +0 -1
  102. package/dist/media/image/component.d.ts +25 -9
  103. package/dist/media/image/directive.d.ts +15 -1
  104. package/dist/media/image/placeholder.d.ts +20 -9
  105. package/dist/media/image/processor/cache.d.ts +40 -18
  106. package/dist/media/image/processor/index.d.ts +1 -10
  107. package/dist/media/image/processor/optimizer.d.ts +12 -1
  108. package/dist/media/image/processor/responsive.d.ts +16 -6
  109. package/dist/media/image/srcset.d.ts +47 -50
  110. package/dist/media/shared/cache.d.ts +51 -31
  111. package/dist/media/shared/hash.d.ts +7 -0
  112. package/dist/media/types.d.ts +1235 -754
  113. package/dist/media/video/directive.d.ts +15 -1
  114. package/dist/media/video/index.d.ts +39 -17
  115. package/dist/media/video/processor/cache.d.ts +42 -19
  116. package/dist/media/video/processor/index.d.ts +1 -18
  117. package/dist/media/video/processor/streaming.d.ts +17 -10
  118. package/dist/media/video/processor/thumbnail.d.ts +21 -15
  119. package/dist/media/video/processor/transcoder.d.ts +11 -1
  120. package/dist/method-spoofing.d.ts +7 -0
  121. package/dist/middleware.d.ts +60 -0
  122. package/dist/owned-routes.d.ts +42 -0
  123. package/dist/owned-routes.js +26 -0
  124. package/dist/page-meta.d.ts +38 -0
  125. package/dist/page-meta.js +16 -0
  126. package/dist/parser/directive-parser.d.ts +57 -45
  127. package/dist/parser/expression-parser.d.ts +33 -35
  128. package/dist/parser/index.d.ts +4 -39
  129. package/dist/parser/tokenizer.d.ts +61 -49
  130. package/dist/partial-hydration.d.ts +82 -50
  131. package/dist/performance-utils.d.ts +217 -124
  132. package/dist/placeholder.d.ts +18 -9
  133. package/dist/plugin-system.d.ts +264 -115
  134. package/dist/process.d.ts +11 -6
  135. package/dist/process.js +21 -4
  136. package/dist/production-builder.js +7 -0
  137. package/dist/prop-sentinels.d.ts +11 -11
  138. package/dist/public-env.d.ts +14 -0
  139. package/dist/pwa/directives.d.ts +12 -3
  140. package/dist/pwa/inject.d.ts +10 -0
  141. package/dist/pwa/precache.d.ts +22 -16
  142. package/dist/pwa/service-worker.d.ts +12 -0
  143. package/dist/pwa.js +1318 -610
  144. package/dist/reactive-bindings.d.ts +34 -11
  145. package/dist/reactive.d.ts +58 -30
  146. package/dist/reactive.js +56 -31
  147. package/dist/render.d.ts +0 -14
  148. package/dist/render.js +17 -0
  149. package/dist/route-middleware.d.ts +2 -35
  150. package/dist/route-types.d.ts +134 -0
  151. package/dist/route-types.js +24 -0
  152. package/dist/router.d.ts +5 -7
  153. package/dist/routes.d.ts +1 -3
  154. package/dist/runtime-globals.d.ts +147 -24
  155. package/dist/runtime-globals.js +16 -1
  156. package/dist/runtime-injection.d.ts +8 -0
  157. package/dist/runtime-injection.js +33 -24
  158. package/dist/script-emit.d.ts +30 -0
  159. package/dist/script-json.d.ts +36 -0
  160. package/dist/script-json.js +6 -0
  161. package/dist/script-validation.d.ts +21 -4
  162. package/dist/seo.d.ts +118 -47
  163. package/dist/server-bindings.d.ts +21 -0
  164. package/dist/sfc-template.d.ts +8 -8
  165. package/dist/signal-processing.d.ts +35 -15
  166. package/dist/signals-api.d.ts +117 -58
  167. package/dist/signals-api.js +7 -4
  168. package/dist/signals.d.ts +24 -17
  169. package/dist/signals.js +765 -60
  170. package/dist/site-builder/build.js +8 -0
  171. package/dist/site-url.d.ts +46 -0
  172. package/dist/site-url.js +70 -0
  173. package/dist/slots.d.ts +86 -20
  174. package/dist/source-signature.d.ts +45 -0
  175. package/dist/source-signature.js +20 -0
  176. package/dist/ssg.d.ts +285 -142
  177. package/dist/ssg.js +1268 -556
  178. package/dist/state-dir.d.ts +4 -4
  179. package/dist/state-management.d.ts +0 -12
  180. package/dist/state-management.js +8 -25
  181. package/dist/store-imports.d.ts +23 -0
  182. package/dist/store-imports.js +3 -0
  183. package/dist/store-loader.d.ts +10 -0
  184. package/dist/store-loader.js +10 -9
  185. package/dist/story/analytics.d.ts +138 -60
  186. package/dist/story/bookmarks.d.ts +87 -34
  187. package/dist/story/cli.d.ts +123 -69
  188. package/dist/story/collect/scanner.d.ts +4 -0
  189. package/dist/story/collect/tree.d.ts +8 -1
  190. package/dist/story/commands/build.d.ts +11 -6
  191. package/dist/story/commands/dev.d.ts +15 -8
  192. package/dist/story/commands/preview.d.ts +13 -7
  193. package/dist/story/config-watcher.d.ts +20 -13
  194. package/dist/story/config.d.ts +11 -8
  195. package/dist/story/context.d.ts +14 -8
  196. package/dist/story/hmr.d.ts +24 -26
  197. package/dist/story/hot-swap.d.ts +34 -23
  198. package/dist/story/keyboard-shortcuts.d.ts +23 -18
  199. package/dist/story/output.d.ts +46 -44
  200. package/dist/story/performance.d.ts +107 -45
  201. package/dist/story/presets.d.ts +107 -41
  202. package/dist/story/renderer.d.ts +41 -27
  203. package/dist/story/search.d.ts +23 -12
  204. package/dist/story/server.d.ts +21 -11
  205. package/dist/story/setup.d.ts +23 -15
  206. package/dist/story/testing.d.ts +65 -40
  207. package/dist/story/types.d.ts +262 -160
  208. package/dist/streaming.d.ts +119 -57
  209. package/dist/stx-virtual-ts.d.ts +165 -0
  210. package/dist/stx-virtual-ts.js +372 -0
  211. package/dist/stx.d.ts +78 -1
  212. package/dist/style-scoping.d.ts +17 -4
  213. package/dist/suspense.d.ts +67 -52
  214. package/dist/teleport.d.ts +22 -0
  215. package/dist/template-tag-balance.d.ts +22 -6
  216. package/dist/transitions.d.ts +66 -55
  217. package/dist/typecheck.d.ts +77 -0
  218. package/dist/typecheck.js +156 -0
  219. package/dist/types/component-types.d.ts +187 -122
  220. package/dist/types/config-types.d.ts +758 -297
  221. package/dist/types/context-types.d.ts +46 -24
  222. package/dist/types/csp-types.d.ts +70 -66
  223. package/dist/types/directive-types.d.ts +211 -155
  224. package/dist/types/index.d.ts +6 -109
  225. package/dist/types/pwa-types.d.ts +273 -148
  226. package/dist/types.d.ts +0 -1
  227. package/dist/typescript-templates.d.ts +11 -0
  228. package/dist/unresolved-identifiers.d.ts +24 -22
  229. package/dist/unresolved-identifiers.js +2 -0
  230. package/dist/utils.d.ts +24 -21
  231. package/dist/validator.d.ts +28 -26
  232. package/dist/variable-extractor.d.ts +48 -13
  233. package/dist/variable-extractor.js +27 -4
  234. package/dist/view-composers.d.ts +80 -81
  235. package/dist/virtual-scrolling.d.ts +101 -81
  236. package/dist/vue-template.d.ts +23 -0
  237. package/dist/web-components/css-scoping.d.ts +21 -11
  238. package/dist/web-components.d.ts +81 -58
  239. package/dist/x-element.d.ts +0 -1
  240. package/package.json +5 -5
  241. package/stx.d.ts +78 -1
@@ -1,5 +1,45 @@
1
- import type { AppHeadConfig } from './types/config-types';
1
+ /**
2
+ * Document Shell Generator
3
+ *
4
+ * Auto-generates the HTML document wrapper around page content.
5
+ * No .stx file needs to write <!DOCTYPE>, <html>, <head>, or <body>.
6
+ * The shell is configured via stx.config.ts `app.head` and enhanced
7
+ * at build/serve time with runtime scripts, CSS, and meta tags.
8
+ *
9
+ * @module document-shell
10
+ */
2
11
  import type { ColorModeBootConfig } from './color-mode-boot';
12
+ import type { AppHeadConfig } from './types/config-types';
13
+ /**
14
+ * Inline x-cloak rule shipped in the SSR <head> (stacksjs/stx#1736).
15
+ *
16
+ * Must be parsed by the browser BEFORE first paint — so it goes in the head
17
+ * as static markup, not injected by the runtime script (which runs after the
18
+ * body has already painted, the window where false `:if` branches / hidden
19
+ * `:show` elements flash). The `data-stx-cloak` marker makes injection
20
+ * idempotent. The runtime's own late injection (signals.ts) is retained as a
21
+ * belt-and-suspenders for SPA-nav fragments that arrive without SSR head
22
+ * emission.
23
+ */
24
+ export declare const CLOAK_STYLE = "<style data-stx-cloak>[x-cloak]{display:none !important}</style>";
25
+ /**
26
+ * Markers recording which `<html>` attributes stx itself wrote from `htmlAttrs`
27
+ * (stacksjs/stx#1798).
28
+ *
29
+ * The router needs them to reconcile the root element across an SPA layout
30
+ * change. It cannot just diff `<html>` against the incoming document: by then
31
+ * the color-mode boot script has added its own `dark` class / `data-theme`, and
32
+ * `animation.ts` has added `data-reduced-motion`, none of which exist in the
33
+ * server response — a blind diff would strip them on every navigation and
34
+ * flash the wrong theme. These say exactly what stx put there, so the router
35
+ * can remove precisely that much and leave runtime state alone.
36
+ *
37
+ * `class` is tracked separately because it is the one attribute that gets
38
+ * *merged* into at runtime, so it has to be reconciled token-by-token rather
39
+ * than replaced wholesale.
40
+ */
41
+ export declare const HTML_ATTRS_MARKER = "data-stx-html-attrs";
42
+ export declare const HTML_CLASS_MARKER = "data-stx-html-class";
3
43
  /** Emit `k="v"` pairs with every value attribute-escaped. */
4
44
  /**
5
45
  * The identity of a `<meta>` tag, for deduplication.
@@ -74,7 +114,10 @@ export declare function injectCloakStyle(html: string): string;
74
114
  * comments and `<script>` blocks are stepped over, never moved), so a `<style>`
75
115
  * sitting next to the markup it styles further down the page is left alone.
76
116
  */
77
- export declare function hoistLeadingHeadTags(content: string): { body: string, hoisted: string[] };
117
+ export declare function hoistLeadingHeadTags(content: string): {
118
+ body: string;
119
+ hoisted: string[];
120
+ };
78
121
  /**
79
122
  * Generate the full HTML document shell wrapping page content.
80
123
  *
@@ -85,7 +128,7 @@ export declare function hoistLeadingHeadTags(content: string): { body: string, h
85
128
  */
86
129
  export declare function generateDocumentShell(content: string, headConfig?: AppHeadConfig, options?: {
87
130
  /** Page-specific title (overrides config) */
88
- title?: string
131
+ title?: string;
89
132
  /**
90
133
  * The title is already HTML and must NOT be escaped again.
91
134
  *
@@ -98,24 +141,24 @@ export declare function generateDocumentShell(content: string, headConfig?: AppH
98
141
  * A title from `useHead({ title })` is a plain JS string and must stay
99
142
  * escaped — that is the XSS path (#1792 item 4).
100
143
  */
101
- titleIsHtml?: boolean
144
+ titleIsHtml?: boolean;
102
145
  /** Extra styles to inject in <head> (e.g. Crosswind CSS, scoped styles) */
103
- styles?: string[]
146
+ styles?: string[];
104
147
  /** Extra scripts to inject before </body> (e.g. signals runtime, router) */
105
- bodyScripts?: string[]
148
+ bodyScripts?: string[];
106
149
  /** Extra scripts/tags for <head> */
107
- headScripts?: string[]
150
+ headScripts?: string[];
108
151
  /** Stacks to inject (from @push directives) */
109
- headStack?: string
110
- bodyStack?: string
152
+ headStack?: string;
153
+ bodyStack?: string;
111
154
  /**
112
155
  * Pre-paint color-mode config (stacksjs/stx#1794). When present, the boot
113
156
  * script is emitted at the very top of <head> — above the stylesheets,
114
157
  * because a stylesheet link ahead of it would block its execution and
115
158
  * delay the one thing it exists to do early.
116
159
  */
117
- colorMode?: ColorModeBootConfig
118
- }): string;
160
+ colorMode?: ColorModeBootConfig;
161
+ }): string;
119
162
  /**
120
163
  * Check if HTML already has a document shell (<!DOCTYPE> or <html>).
121
164
  * Templates that extend layouts with document shells should not be
@@ -196,33 +239,3 @@ export declare function injectConfigHeadTags(html: string, headConfig?: AppHeadC
196
239
  * so runtime `useHead` tags aren't double-emitted).
197
240
  */
198
241
  export declare function ensureDocumentShell(html: string, headConfig?: AppHeadConfig, options?: Parameters<typeof generateDocumentShell>[2]): string;
199
- /**
200
- * Inline x-cloak rule shipped in the SSR <head> (stacksjs/stx#1736).
201
- *
202
- * Must be parsed by the browser BEFORE first paint — so it goes in the head
203
- * as static markup, not injected by the runtime script (which runs after the
204
- * body has already painted, the window where false `:if` branches / hidden
205
- * `:show` elements flash). The `data-stx-cloak` marker makes injection
206
- * idempotent. The runtime's own late injection (signals.ts) is retained as a
207
- * belt-and-suspenders for SPA-nav fragments that arrive without SSR head
208
- * emission.
209
- */
210
- export declare const CLOAK_STYLE: '<style data-stx-cloak>[x-cloak]{display:none !important}</style>';
211
- /**
212
- * Markers recording which `<html>` attributes stx itself wrote from `htmlAttrs`
213
- * (stacksjs/stx#1798).
214
- *
215
- * The router needs them to reconcile the root element across an SPA layout
216
- * change. It cannot just diff `<html>` against the incoming document: by then
217
- * the color-mode boot script has added its own `dark` class / `data-theme`, and
218
- * `animation.ts` has added `data-reduced-motion`, none of which exist in the
219
- * server response — a blind diff would strip them on every navigation and
220
- * flash the wrong theme. These say exactly what stx put there, so the router
221
- * can remove precisely that much and leave runtime state alone.
222
- *
223
- * `class` is tracked separately because it is the one attribute that gets
224
- * *merged* into at runtime, so it has to be reconciled token-by-token rather
225
- * than replaced wholesale.
226
- */
227
- export declare const HTML_ATTRS_MARKER: 'data-stx-html-attrs';
228
- export declare const HTML_CLASS_MARKER: 'data-stx-html-class';
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Dynamic Component Support
3
+ *
4
+ * Handles `<component :is="expr">` syntax for runtime component switching.
5
+ * Server-side: evaluates the expression and resolves the component.
6
+ * Client-side: signals runtime watches :is binding and swaps content.
7
+ *
8
+ * @module dynamic-components
9
+ */
1
10
  import type { StxOptions } from './types';
2
11
  /**
3
12
  * Process `<component :is="expr">` tags in the template.
@@ -1,3 +1,50 @@
1
+ /**
2
+ * STX Error Boundaries
3
+ *
4
+ * Provides graceful error handling for component trees.
5
+ * When an error occurs within an error boundary, the fallback content is shown
6
+ * instead of crashing the entire application.
7
+ *
8
+ * @module error-boundaries
9
+ *
10
+ * @example
11
+ * ```html
12
+ * @errorBoundary
13
+ * <RiskyComponent />
14
+ * @fallback
15
+ * <div class="error-state">
16
+ * <p>Something went wrong</p>
17
+ * <button @click="$retry()">Retry</button>
18
+ * </div>
19
+ * @enderrorBoundary
20
+ * ```
21
+ */
22
+ export interface ErrorBoundaryOptions {
23
+ /** Custom error handler */
24
+ onError?: (error: Error, info: ErrorInfo) => void;
25
+ /** Whether to log errors to console (default: true) */
26
+ logErrors?: boolean;
27
+ /** Custom error ID for tracking */
28
+ id?: string;
29
+ }
30
+ export interface ErrorInfo {
31
+ /** Component name where error occurred */
32
+ componentName?: string;
33
+ /** Stack trace */
34
+ stack?: string;
35
+ /** Timestamp */
36
+ timestamp: number;
37
+ /** Boundary ID */
38
+ boundaryId: string;
39
+ }
40
+ export interface ErrorBoundaryState {
41
+ /** Whether an error has occurred */
42
+ hasError: boolean;
43
+ /** The captured error */
44
+ error: Error | null;
45
+ /** Error info */
46
+ info: ErrorInfo | null;
47
+ }
1
48
  /**
2
49
  * Process @errorBoundary directives in templates.
3
50
  *
@@ -11,7 +58,6 @@
11
58
  * Or with options:
12
59
  * @errorBoundary(id: 'my-boundary', logErrors: false)
13
60
  */
14
- // eslint-disable-next-line pickier/no-unused-vars
15
61
  export declare function processErrorBoundaryDirectives(template: string, context?: Record<string, unknown>, _filePath?: string): string;
16
62
  /**
17
63
  * Wrap content in a try/catch for SSR error handling.
@@ -30,43 +76,3 @@ export declare function generateErrorBoundaryCSS(): string;
30
76
  * Generate client-side runtime for error boundaries.
31
77
  */
32
78
  export declare function generateErrorBoundaryRuntime(): string;
33
- /**
34
- * STX Error Boundaries
35
- *
36
- * Provides graceful error handling for component trees.
37
- * When an error occurs within an error boundary, the fallback content is shown
38
- * instead of crashing the entire application.
39
- *
40
- * @module error-boundaries
41
- *
42
- * @example
43
- * ```html
44
- * @errorBoundary
45
- * <RiskyComponent />
46
- * @fallback
47
- * <div class="error-state">
48
- * <p>Something went wrong</p>
49
- * <button @click="$retry()">Retry</button>
50
- * </div>
51
- * @enderrorBoundary
52
- * ```
53
- */
54
- // =============================================================================
55
- // Types
56
- // =============================================================================
57
- export declare interface ErrorBoundaryOptions {
58
- onError?: (error: Error, info: ErrorInfo) => void
59
- logErrors?: boolean
60
- id?: string
61
- }
62
- export declare interface ErrorInfo {
63
- componentName?: string
64
- stack?: string
65
- timestamp: number
66
- boundaryId: string
67
- }
68
- export declare interface ErrorBoundaryState {
69
- hasError: boolean
70
- error: Error | null
71
- info: ErrorInfo | null
72
- }
@@ -11,4 +11,4 @@
11
11
  * @see ./errors/sanitizer.ts - Parameter sanitization
12
12
  * @see ./errors/logger.ts - Error logging and recovery
13
13
  */
14
- export * from './errors/index';
14
+ export * from './errors';
@@ -1,3 +1,23 @@
1
+ /**
2
+ * Error Codes and Localized Messages
3
+ *
4
+ * Provides numeric error codes for programmatic error handling
5
+ * and localized error message templates.
6
+ *
7
+ * @module errors/codes
8
+ */
9
+ /**
10
+ * Error message template with placeholder support
11
+ * Placeholders use {{name}} syntax
12
+ */
13
+ export interface ErrorMessageTemplate {
14
+ message: string;
15
+ help?: string;
16
+ }
17
+ /**
18
+ * Localized error messages by error code
19
+ */
20
+ export type ErrorMessages = Record<number, ErrorMessageTemplate>;
1
21
  /**
2
22
  * Set the locale for error messages
3
23
  */
@@ -23,10 +43,6 @@ export declare function getErrorMessage(code: number, params?: Record<string, st
23
43
  * Format an error with localized message
24
44
  */
25
45
  export declare function formatLocalizedError(code: number, params?: Record<string, string>): string;
26
- /**
27
- * Get error code name from numeric code
28
- */
29
- export declare function getErrorCodeName(code: number): string | undefined;
30
46
  /**
31
47
  * Numeric error codes for programmatic error handling
32
48
  *
@@ -40,45 +56,37 @@ export declare function getErrorCodeName(code: number): string | undefined;
40
56
  * - 1600-1699: Expression errors
41
57
  */
42
58
  export declare const ErrorCodes: {
43
- UNCLOSED_DIRECTIVE: 1001;
44
- UNCLOSED_EXPRESSION: 1002;
45
- INVALID_DIRECTIVE_SYNTAX: 1003;
46
- MALFORMED_EXPRESSION: 1004;
47
- UNEXPECTED_TOKEN: 1005;
48
- UNDEFINED_VARIABLE: 1101;
49
- TYPE_ERROR: 1102;
50
- EVALUATION_ERROR: 1103;
51
- INFINITE_LOOP: 1104;
52
- CIRCULAR_REFERENCE: 1105;
53
- UNSAFE_EXPRESSION: 1201;
54
- PATH_TRAVERSAL: 1202;
55
- XSS_ATTEMPT: 1203;
56
- CODE_INJECTION: 1204;
57
- DOM_API_VIOLATION: 1205;
58
- FILE_NOT_FOUND: 1301;
59
- FILE_READ_ERROR: 1302;
60
- INVALID_FILE_PATH: 1303;
61
- PERMISSION_DENIED: 1304;
62
- INVALID_CONFIG: 1401;
63
- MISSING_REQUIRED_CONFIG: 1402;
64
- DEPRECATED_CONFIG: 1403;
65
- COMPONENT_NOT_FOUND: 1501;
66
- INVALID_PROPS: 1502;
67
- COMPONENT_RENDER_ERROR: 1503;
68
- FILTER_NOT_FOUND: 1601;
69
- INVALID_FILTER_ARGS: 1602;
70
- EXPRESSION_TIMEOUT: 1603
59
+ readonly UNCLOSED_DIRECTIVE: 1001;
60
+ readonly UNCLOSED_EXPRESSION: 1002;
61
+ readonly INVALID_DIRECTIVE_SYNTAX: 1003;
62
+ readonly MALFORMED_EXPRESSION: 1004;
63
+ readonly UNEXPECTED_TOKEN: 1005;
64
+ readonly UNDEFINED_VARIABLE: 1101;
65
+ readonly TYPE_ERROR: 1102;
66
+ readonly EVALUATION_ERROR: 1103;
67
+ readonly INFINITE_LOOP: 1104;
68
+ readonly CIRCULAR_REFERENCE: 1105;
69
+ readonly UNSAFE_EXPRESSION: 1201;
70
+ readonly PATH_TRAVERSAL: 1202;
71
+ readonly XSS_ATTEMPT: 1203;
72
+ readonly CODE_INJECTION: 1204;
73
+ readonly DOM_API_VIOLATION: 1205;
74
+ readonly FILE_NOT_FOUND: 1301;
75
+ readonly FILE_READ_ERROR: 1302;
76
+ readonly INVALID_FILE_PATH: 1303;
77
+ readonly PERMISSION_DENIED: 1304;
78
+ readonly INVALID_CONFIG: 1401;
79
+ readonly MISSING_REQUIRED_CONFIG: 1402;
80
+ readonly DEPRECATED_CONFIG: 1403;
81
+ readonly COMPONENT_NOT_FOUND: 1501;
82
+ readonly INVALID_PROPS: 1502;
83
+ readonly COMPONENT_RENDER_ERROR: 1503;
84
+ readonly FILTER_NOT_FOUND: 1601;
85
+ readonly INVALID_FILTER_ARGS: 1602;
86
+ readonly EXPRESSION_TIMEOUT: 1603;
71
87
  };
88
+ export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
72
89
  /**
73
- * Error message template with placeholder support
74
- * Placeholders use {{name}} syntax
75
- */
76
- export declare interface ErrorMessageTemplate {
77
- message: string
78
- help?: string
79
- }
80
- /**
81
- * Localized error messages by error code
90
+ * Get error code name from numeric code
82
91
  */
83
- export type ErrorMessages = Record<number, ErrorMessageTemplate>;
84
- export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
92
+ export declare function getErrorCodeName(code: number): string | undefined;
@@ -1,5 +1,63 @@
1
+ /**
2
+ * Error Formatting Utilities
3
+ *
4
+ * Provides standardized error message formatting for different output formats.
5
+ *
6
+ * @module errors/formatter
7
+ */
1
8
  import type { ErrorCode } from './codes';
2
9
  import type { ErrorContext } from './types';
10
+ /**
11
+ * Error output format options
12
+ */
13
+ export type ErrorOutputFormat = 'html' | 'text' | 'json' | 'console';
14
+ /**
15
+ * Standardized error message options
16
+ */
17
+ export interface ErrorMessageOptions {
18
+ /** Error type/category (e.g., 'Directive', 'Expression', 'Syntax') */
19
+ type: string;
20
+ /** The error message */
21
+ message: string;
22
+ /** Numeric error code */
23
+ code?: ErrorCode;
24
+ /** File path where error occurred */
25
+ filePath?: string;
26
+ /** Line number */
27
+ line?: number;
28
+ /** Column number */
29
+ column?: number;
30
+ /** Template content for context */
31
+ template?: string;
32
+ /** Position offset in template */
33
+ offset?: number;
34
+ /** The problematic code snippet */
35
+ snippet?: string;
36
+ /** Suggestion for fixing the error */
37
+ suggestion?: string;
38
+ /** Output format */
39
+ format?: ErrorOutputFormat;
40
+ }
41
+ /**
42
+ * Standardized error message result
43
+ */
44
+ export interface StandardizedError {
45
+ /** Formatted error message for display */
46
+ formatted: string;
47
+ /** Raw error data */
48
+ data: {
49
+ type: string;
50
+ code: number | undefined;
51
+ codeName: string | undefined;
52
+ message: string;
53
+ filePath: string | undefined;
54
+ line: number | undefined;
55
+ column: number | undefined;
56
+ snippet: string | undefined;
57
+ suggestion: string | undefined;
58
+ timestamp: string;
59
+ };
60
+ }
3
61
  /**
4
62
  * Create a standardized error message in any format
5
63
  */
@@ -24,41 +82,3 @@ export declare function safeExecute<T>(operation: () => T, fallback: T, errorHan
24
82
  * Async version of safe wrapper
25
83
  */
26
84
  export declare function safeExecuteAsync<T>(operation: () => Promise<T>, fallback: T, errorHandler?: (error: Error) => void): Promise<T>;
27
- /**
28
- * Standardized error message options
29
- */
30
- export declare interface ErrorMessageOptions {
31
- type: string
32
- message: string
33
- code?: ErrorCode
34
- filePath?: string
35
- line?: number
36
- column?: number
37
- template?: string
38
- offset?: number
39
- snippet?: string
40
- suggestion?: string
41
- format?: ErrorOutputFormat
42
- }
43
- /**
44
- * Standardized error message result
45
- */
46
- export declare interface StandardizedError {
47
- formatted: string
48
- data: {
49
- type: string
50
- code: number | undefined
51
- codeName: string | undefined
52
- message: string
53
- filePath: string | undefined
54
- line: number | undefined
55
- column: number | undefined
56
- snippet: string | undefined
57
- suggestion: string | undefined
58
- timestamp: string
59
- }
60
- }
61
- /**
62
- * Error output format options
63
- */
64
- export type ErrorOutputFormat = 'html' | 'text' | 'json' | 'console';
@@ -5,64 +5,8 @@
5
5
  *
6
6
  * @module errors
7
7
  */
8
- // Error codes and localization
9
- export {
10
- clearErrorMessages,
11
- type ErrorCode,
12
- ErrorCodes,
13
- type ErrorMessages,
14
- type ErrorMessageTemplate,
15
- formatLocalizedError,
16
- getErrorCodeName,
17
- getErrorLocale,
18
- getErrorMessage,
19
- registerErrorMessages,
20
- setErrorLocale,
21
- } from './codes';
22
- // Error formatting
23
- export {
24
- consoleError,
25
- createEnhancedError,
26
- type ErrorMessageOptions,
27
- type ErrorOutputFormat,
28
- formatError,
29
- inlineError,
30
- safeExecute,
31
- safeExecuteAsync,
32
- type StandardizedError,
33
- } from './formatter';
34
- // Logger and recovery
35
- export {
36
- devHelpers,
37
- type ErrorLogEntry,
38
- ErrorLogger,
39
- errorLogger,
40
- type ErrorLoggerOptions,
41
- errorRecovery,
42
- } from './logger';
43
- // Sanitization
44
- export {
45
- sanitizeComponentProps,
46
- sanitizeDirectiveParam,
47
- sanitizeDirectiveParams,
48
- type SanitizedParam,
49
- sanitizeExpression,
50
- sanitizeFilePath,
51
- type SanitizeOptions,
52
- validators,
53
- } from './sanitizer';
54
- // Error types and classes
55
- export {
56
- configureErrorHandling,
57
- type ErrorConfig,
58
- type ErrorContext,
59
- formatFilePath,
60
- getErrorConfig,
61
- resetErrorConfig,
62
- StxError,
63
- StxFileError,
64
- StxRuntimeError,
65
- StxSecurityError,
66
- StxSyntaxError,
67
- StxValidationError,
68
- } from './types';
8
+ export { clearErrorMessages, type ErrorCode, ErrorCodes, type ErrorMessages, type ErrorMessageTemplate, formatLocalizedError, getErrorCodeName, getErrorLocale, getErrorMessage, registerErrorMessages, setErrorLocale, } from './codes';
9
+ export { consoleError, createEnhancedError, type ErrorMessageOptions, type ErrorOutputFormat, formatError, inlineError, safeExecute, safeExecuteAsync, type StandardizedError, } from './formatter';
10
+ export { devHelpers, type ErrorLogEntry, ErrorLogger, errorLogger, type ErrorLoggerOptions, errorRecovery, } from './logger';
11
+ export { sanitizeComponentProps, sanitizeDirectiveParam, sanitizeDirectiveParams, type SanitizedParam, sanitizeExpression, sanitizeFilePath, type SanitizeOptions, validators, } from './sanitizer';
12
+ export { configureErrorHandling, type ErrorConfig, type ErrorContext, formatFilePath, getErrorConfig, resetErrorConfig, StxError, StxFileError, StxRuntimeError, StxSecurityError, StxSyntaxError, StxValidationError, } from './types';