@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/document-shell.d.ts
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
|
-
|
|
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): {
|
|
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
|
-
|
|
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
|
-
}
|
package/dist/error-handling.d.ts
CHANGED
package/dist/errors/codes.d.ts
CHANGED
|
@@ -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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
*
|
|
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
|
|
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';
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -5,64 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module errors
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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';
|