@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/heatmap.d.ts
CHANGED
|
@@ -1,25 +1,4 @@
|
|
|
1
1
|
import type { CustomDirective, StxOptions } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Generate heatmap tracking script based on configuration
|
|
4
|
-
*/
|
|
5
|
-
export declare function generateHeatmapScript(options: StxOptions): string;
|
|
6
|
-
/**
|
|
7
|
-
* Inject heatmap script into HTML
|
|
8
|
-
* Scripts are injected just before </body> for optimal loading
|
|
9
|
-
*/
|
|
10
|
-
export declare function injectHeatmap(html: string, options: StxOptions): string;
|
|
11
|
-
/**
|
|
12
|
-
* Create a heatmap aggregator instance
|
|
13
|
-
*/
|
|
14
|
-
export declare function createHeatmapAggregator(): HeatmapAggregator;
|
|
15
|
-
/**
|
|
16
|
-
* Default heatmap configuration
|
|
17
|
-
*/
|
|
18
|
-
export declare const defaultHeatmapConfig: HeatmapConfig;
|
|
19
|
-
/**
|
|
20
|
-
* Custom @heatmap directive for explicit placement
|
|
21
|
-
*/
|
|
22
|
-
export declare const heatmapDirective: CustomDirective;
|
|
23
2
|
/**
|
|
24
3
|
* Heatmap Module
|
|
25
4
|
*
|
|
@@ -54,73 +33,174 @@ export declare const heatmapDirective: CustomDirective;
|
|
|
54
33
|
/**
|
|
55
34
|
* Heatmap tracking configuration
|
|
56
35
|
*/
|
|
57
|
-
export
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
36
|
+
export interface HeatmapConfig {
|
|
37
|
+
/** Enable heatmap tracking */
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
/** Track mouse movements */
|
|
40
|
+
trackMouse?: boolean;
|
|
41
|
+
/** Track click events */
|
|
42
|
+
trackClicks?: boolean;
|
|
43
|
+
/** Track scroll depth */
|
|
44
|
+
trackScroll?: boolean;
|
|
45
|
+
/** Sampling rate in milliseconds for mouse tracking (default: 100ms) */
|
|
46
|
+
samplingRate?: number;
|
|
47
|
+
/** Honor Do Not Track browser setting */
|
|
48
|
+
honorDnt?: boolean;
|
|
49
|
+
/** API endpoint for sending heatmap data */
|
|
50
|
+
endpoint?: string;
|
|
51
|
+
/** Batch size before sending data (default: 50) */
|
|
52
|
+
batchSize?: number;
|
|
53
|
+
/** Maximum data points to store locally (default: 1000) */
|
|
54
|
+
maxDataPoints?: number;
|
|
55
|
+
/** Session timeout in minutes (default: 30) */
|
|
56
|
+
sessionTimeout?: number;
|
|
57
|
+
/** Enable local storage for offline data */
|
|
58
|
+
persistData?: boolean;
|
|
59
|
+
/** Storage key prefix (default: 'stx_heatmap') */
|
|
60
|
+
storagePrefix?: string;
|
|
61
|
+
/** Custom data attributes to capture on clicks */
|
|
62
|
+
captureAttributes?: string[];
|
|
63
|
+
/** Element selectors to ignore */
|
|
64
|
+
ignoreSelectors?: string[];
|
|
65
|
+
/** Zone definitions for grouped tracking */
|
|
66
|
+
zones?: HeatmapZone[];
|
|
67
|
+
/** Enable visual overlay for development */
|
|
68
|
+
debugOverlay?: boolean;
|
|
69
|
+
/** Minimum viewport width to track (mobile optimization) */
|
|
70
|
+
minViewportWidth?: number;
|
|
71
|
+
/** Maximum viewport width to track */
|
|
72
|
+
maxViewportWidth?: number;
|
|
76
73
|
}
|
|
77
74
|
/**
|
|
78
75
|
* Zone definition for grouped tracking
|
|
79
76
|
*/
|
|
80
|
-
export
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
export interface HeatmapZone {
|
|
78
|
+
/** Zone identifier */
|
|
79
|
+
id: string;
|
|
80
|
+
/** CSS selector for the zone */
|
|
81
|
+
selector: string;
|
|
82
|
+
/** Zone label for reports */
|
|
83
|
+
label?: string;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Heatmap data point
|
|
87
87
|
*/
|
|
88
|
-
export
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
export interface HeatmapDataPoint {
|
|
89
|
+
/** X coordinate (percentage of viewport) */
|
|
90
|
+
x: number;
|
|
91
|
+
/** Y coordinate (percentage of viewport) */
|
|
92
|
+
y: number;
|
|
93
|
+
/** Type of interaction */
|
|
94
|
+
type: 'move' | 'click' | 'scroll';
|
|
95
|
+
/** Timestamp */
|
|
96
|
+
t: number;
|
|
97
|
+
/** Element selector (for clicks) */
|
|
98
|
+
el?: string;
|
|
99
|
+
/** Zone ID if within a defined zone */
|
|
100
|
+
zone?: string;
|
|
101
|
+
/** Scroll depth percentage (for scroll events) */
|
|
102
|
+
depth?: number;
|
|
103
|
+
/** Custom attributes captured */
|
|
104
|
+
attrs?: Record<string, string>;
|
|
97
105
|
}
|
|
98
106
|
/**
|
|
99
107
|
* Heatmap session data
|
|
100
108
|
*/
|
|
101
|
-
export
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
export interface HeatmapSession {
|
|
110
|
+
/** Anonymous session ID */
|
|
111
|
+
sid: string;
|
|
112
|
+
/** Page URL (path only, no query params for privacy) */
|
|
113
|
+
page: string;
|
|
114
|
+
/** Viewport width */
|
|
115
|
+
vw: number;
|
|
116
|
+
/** Viewport height */
|
|
117
|
+
vh: number;
|
|
118
|
+
/** Data points */
|
|
119
|
+
points: HeatmapDataPoint[];
|
|
120
|
+
/** Session start time */
|
|
121
|
+
started: number;
|
|
122
|
+
/** Last activity time */
|
|
123
|
+
lastActivity: number;
|
|
109
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Default heatmap configuration
|
|
127
|
+
*/
|
|
128
|
+
export declare const defaultHeatmapConfig: HeatmapConfig;
|
|
129
|
+
/**
|
|
130
|
+
* Generate heatmap tracking script based on configuration
|
|
131
|
+
*/
|
|
132
|
+
export declare function generateHeatmapScript(options: StxOptions): string;
|
|
133
|
+
/**
|
|
134
|
+
* Inject heatmap script into HTML
|
|
135
|
+
* Scripts are injected just before </body> for optimal loading
|
|
136
|
+
*/
|
|
137
|
+
export declare function injectHeatmap(html: string, options: StxOptions): string;
|
|
138
|
+
/**
|
|
139
|
+
* Custom @heatmap directive for explicit placement
|
|
140
|
+
*/
|
|
141
|
+
export declare const heatmapDirective: CustomDirective;
|
|
110
142
|
/**
|
|
111
143
|
* Server-side heatmap data aggregator
|
|
112
144
|
* For processing collected heatmap data into visualizations
|
|
113
145
|
*/
|
|
114
146
|
export declare class HeatmapAggregator {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
147
|
+
private sessions;
|
|
148
|
+
/**
|
|
149
|
+
* Add session data
|
|
150
|
+
*/
|
|
151
|
+
addSession(data: HeatmapSession): void;
|
|
152
|
+
/**
|
|
153
|
+
* Get aggregated data for a page
|
|
154
|
+
*/
|
|
155
|
+
getPageData(page: string): HeatmapDataPoint[];
|
|
156
|
+
/**
|
|
157
|
+
* Get click heatmap data
|
|
158
|
+
*/
|
|
159
|
+
getClickData(page: string): HeatmapDataPoint[];
|
|
160
|
+
/**
|
|
161
|
+
* Get movement heatmap data
|
|
162
|
+
*/
|
|
163
|
+
getMovementData(page: string): HeatmapDataPoint[];
|
|
164
|
+
/**
|
|
165
|
+
* Get scroll depth data
|
|
166
|
+
*/
|
|
167
|
+
getScrollData(page: string): {
|
|
168
|
+
depth: number;
|
|
169
|
+
count: number;
|
|
170
|
+
}[];
|
|
171
|
+
/**
|
|
172
|
+
* Get zone interaction statistics
|
|
173
|
+
*/
|
|
174
|
+
getZoneStats(page: string): Map<string, {
|
|
175
|
+
clicks: number;
|
|
176
|
+
hovers: number;
|
|
177
|
+
}>;
|
|
178
|
+
/**
|
|
179
|
+
* Generate heatmap grid data (for server-side rendering)
|
|
180
|
+
*/
|
|
181
|
+
generateGridData(page: string, gridSize?: number): {
|
|
182
|
+
x: number;
|
|
183
|
+
y: number;
|
|
184
|
+
intensity: number;
|
|
185
|
+
}[][];
|
|
186
|
+
/**
|
|
187
|
+
* Export all data as JSON
|
|
188
|
+
*/
|
|
189
|
+
exportJSON(): string;
|
|
190
|
+
/**
|
|
191
|
+
* Clear all data
|
|
192
|
+
*/
|
|
193
|
+
clear(): void;
|
|
194
|
+
/**
|
|
195
|
+
* Get session count
|
|
196
|
+
*/
|
|
197
|
+
get sessionCount(): number;
|
|
198
|
+
/**
|
|
199
|
+
* Get total data points
|
|
200
|
+
*/
|
|
201
|
+
get totalPoints(): number;
|
|
126
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Create a heatmap aggregator instance
|
|
205
|
+
*/
|
|
206
|
+
export declare function createHeatmapAggregator(): HeatmapAggregator;
|
package/dist/html-masking.d.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element-position-aware masking.
|
|
3
|
+
*
|
|
4
|
+
* Several pipeline stages temporarily replace `<script>…</script>` bodies or
|
|
5
|
+
* `<!-- … -->` comments with sentinel placeholders so later passes don't process
|
|
6
|
+
* their contents, then restore them at the end. A naive global regex
|
|
7
|
+
* (`/<script…>…<\/script>/g`, `/<!--…-->/g`) also matches such a token when it
|
|
8
|
+
* appears INSIDE a quoted attribute value — e.g. `aria-label="<script>x</script>"`
|
|
9
|
+
* or `title="<!-- "><img onerror=alert(1)> -->"`. The renderer's HTML-escaping
|
|
10
|
+
* then runs against the harmless placeholder, and the raw token is restored into
|
|
11
|
+
* the attribute afterward, breaking out of it — an XSS.
|
|
12
|
+
*
|
|
13
|
+
* `maskAtElementPosition` walks the string tracking tag/attribute/quote state and
|
|
14
|
+
* only masks tokens that begin at *element position* (not within an open tag, not
|
|
15
|
+
* inside a quoted attribute value). A token embedded in an attribute is left in
|
|
16
|
+
* place to be escaped normally.
|
|
17
|
+
*
|
|
18
|
+
* This is a leaf module (no stx imports) so any stage can use it without risking
|
|
19
|
+
* an import cycle.
|
|
20
|
+
*
|
|
21
|
+
* @module html-masking
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Locate a maskable token starting at `html[i]`.
|
|
25
|
+
* @returns the end index (exclusive) of the token, or -1 if none starts here.
|
|
26
|
+
*/
|
|
27
|
+
export type TokenMatcher = (html: string, i: number) => number;
|
|
28
|
+
export interface ElementPositionToken {
|
|
29
|
+
start: number;
|
|
30
|
+
end: number;
|
|
31
|
+
token: string;
|
|
32
|
+
}
|
|
1
33
|
/** Matches a real `<script…>…</script>` element (through the first `</script>`). */
|
|
2
34
|
export declare function matchScriptElement(html: string, i: number): number;
|
|
3
35
|
/** Matches a real `<style…>…</style>` element (through the first `</style>`). */
|
|
@@ -19,45 +51,19 @@ export declare function scanAtElementPosition(html: string, match: TokenMatcher)
|
|
|
19
51
|
* Note: HTML attributes do not use backslash escaping, so a `"`/`'` always
|
|
20
52
|
* toggles the surrounding quote — matching how browsers parse attribute values.
|
|
21
53
|
*/
|
|
22
|
-
export declare function maskAtElementPosition(html: string, match: TokenMatcher, placeholder: (token: string, index: number) => string): {
|
|
54
|
+
export declare function maskAtElementPosition(html: string, match: TokenMatcher, placeholder: (token: string, index: number) => string): {
|
|
55
|
+
output: string;
|
|
56
|
+
tokens: string[];
|
|
57
|
+
};
|
|
23
58
|
/**
|
|
24
59
|
* Stash genuine `<script>…</script>` ELEMENTS behind NUL-byte sentinels so a
|
|
25
60
|
* component scanner doesn't mis-resolve tag-like JS string literals (e.g.
|
|
26
61
|
* `div.innerHTML = '<v:shape>'`) as component references (stacksjs/stx#1730), and
|
|
27
62
|
* so an attribute-embedded `<script>` is never pulled out and restored unescaped.
|
|
28
63
|
*/
|
|
29
|
-
export declare function stashScriptElements(html: string): {
|
|
64
|
+
export declare function stashScriptElements(html: string): {
|
|
65
|
+
output: string;
|
|
66
|
+
scripts: string[];
|
|
67
|
+
};
|
|
30
68
|
/** Restore scripts stashed by {@link stashScriptElements}. */
|
|
31
69
|
export declare function restoreStashedScripts(html: string, scripts: string[]): string;
|
|
32
|
-
export declare interface ElementPositionToken {
|
|
33
|
-
start: number
|
|
34
|
-
end: number
|
|
35
|
-
token: string
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Element-position-aware masking.
|
|
39
|
-
*
|
|
40
|
-
* Several pipeline stages temporarily replace `<script>…</script>` bodies or
|
|
41
|
-
* `<!-- … -->` comments with sentinel placeholders so later passes don't process
|
|
42
|
-
* their contents, then restore them at the end. A naive global regex
|
|
43
|
-
* (`/<script…>…<\/script>/g`, `/<!--…-->/g`) also matches such a token when it
|
|
44
|
-
* appears INSIDE a quoted attribute value — e.g. `aria-label="<script>x</script>"`
|
|
45
|
-
* or `title="<!-- "><img onerror=alert(1)> -->"`. The renderer's HTML-escaping
|
|
46
|
-
* then runs against the harmless placeholder, and the raw token is restored into
|
|
47
|
-
* the attribute afterward, breaking out of it — an XSS.
|
|
48
|
-
*
|
|
49
|
-
* `maskAtElementPosition` walks the string tracking tag/attribute/quote state and
|
|
50
|
-
* only masks tokens that begin at *element position* (not within an open tag, not
|
|
51
|
-
* inside a quoted attribute value). A token embedded in an attribute is left in
|
|
52
|
-
* place to be escaped normally.
|
|
53
|
-
*
|
|
54
|
-
* This is a leaf module (no stx imports) so any stage can use it without risking
|
|
55
|
-
* an import cycle.
|
|
56
|
-
*
|
|
57
|
-
* @module html-masking
|
|
58
|
-
*/
|
|
59
|
-
/**
|
|
60
|
-
* Locate a maskable token starting at `html[i]`.
|
|
61
|
-
* @returns the end index (exclusive) of the token, or -1 if none starts here.
|
|
62
|
-
*/
|
|
63
|
-
export type TokenMatcher = (html: string, i: number) => number;
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Hydration Runtime for Islands Architecture
|
|
3
|
+
*
|
|
4
|
+
* Replaces the per-strategy inline scripts with a single runtime that handles
|
|
5
|
+
* all hydration strategies. Injected once per page when islands are present.
|
|
6
|
+
*
|
|
7
|
+
* The runtime:
|
|
8
|
+
* 1. Component registry — maps names to dynamic imports
|
|
9
|
+
* 2. hydrateIsland(element) — loads component, reads props, calls hydrate/mount
|
|
10
|
+
* 3. Strategy dispatcher — sets up triggers per data-strategy attribute
|
|
11
|
+
* 4. initIslands() — processes all .stx-island:not(.hydrated) on DOMContentLoaded
|
|
12
|
+
*
|
|
13
|
+
* @module hydration-runtime
|
|
14
|
+
*/
|
|
15
|
+
export interface IslandMeta {
|
|
16
|
+
id: string;
|
|
17
|
+
component: string;
|
|
18
|
+
strategy: string;
|
|
19
|
+
props: Record<string, unknown>;
|
|
20
|
+
}
|
|
1
21
|
/**
|
|
2
22
|
* Generate the unified hydration bootstrap script.
|
|
3
23
|
*
|
|
@@ -22,27 +42,3 @@ export declare function extractComponentName(content: string): string | null;
|
|
|
22
42
|
* Parses :prop="value" bindings.
|
|
23
43
|
*/
|
|
24
44
|
export declare function extractBoundProps(content: string, context: Record<string, unknown>): Record<string, unknown>;
|
|
25
|
-
/* eslint-disable prefer-const, style/max-statements-per-line, no-super-linear-backtracking, regexp/no-unused-capturing-group */
|
|
26
|
-
/**
|
|
27
|
-
* Unified Hydration Runtime for Islands Architecture
|
|
28
|
-
*
|
|
29
|
-
* Replaces the per-strategy inline scripts with a single runtime that handles
|
|
30
|
-
* all hydration strategies. Injected once per page when islands are present.
|
|
31
|
-
*
|
|
32
|
-
* The runtime:
|
|
33
|
-
* 1. Component registry — maps names to dynamic imports
|
|
34
|
-
* 2. hydrateIsland(element) — loads component, reads props, calls hydrate/mount
|
|
35
|
-
* 3. Strategy dispatcher — sets up triggers per data-strategy attribute
|
|
36
|
-
* 4. initIslands() — processes all .stx-island:not(.hydrated) on DOMContentLoaded
|
|
37
|
-
*
|
|
38
|
-
* @module hydration-runtime
|
|
39
|
-
*/
|
|
40
|
-
// ============================================================================
|
|
41
|
-
// Types
|
|
42
|
-
// ============================================================================
|
|
43
|
-
export declare interface IslandMeta {
|
|
44
|
-
id: string
|
|
45
|
-
component: string
|
|
46
|
-
strategy: string
|
|
47
|
-
props: Record<string, unknown>
|
|
48
|
-
}
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,4 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module for internationalization (i18n) support
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Translation file loading (JSON, YAML, JS)
|
|
6
|
+
* - Lazy loading with deduplication
|
|
7
|
+
* - Background preloading for multiple locales
|
|
8
|
+
* - Nested key access (e.g., 'messages.welcome')
|
|
9
|
+
* - Parameter replacement (e.g., ':name' → 'John')
|
|
10
|
+
* - Basic pluralization support
|
|
11
|
+
* - ICU MessageFormat support
|
|
12
|
+
* - Translation caching with invalidation
|
|
13
|
+
*
|
|
14
|
+
* ## Lazy Loading
|
|
15
|
+
*
|
|
16
|
+
* Translations are loaded lazily with request deduplication:
|
|
17
|
+
* ```ts
|
|
18
|
+
* // Multiple simultaneous calls share the same promise
|
|
19
|
+
* const [t1, t2] = await Promise.all([
|
|
20
|
+
* loadTranslation('en', options),
|
|
21
|
+
* loadTranslation('en', options), // Reuses same request
|
|
22
|
+
* ])
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ## Background Preloading
|
|
26
|
+
*
|
|
27
|
+
* Preload translations in the background:
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Fire and forget - doesn't block
|
|
30
|
+
* preloadTranslationsBackground({
|
|
31
|
+
* locales: ['en', 'es', 'fr', 'de'],
|
|
32
|
+
* parallel: true,
|
|
33
|
+
* onLocaleLoaded: (locale) => console.log(`${locale} ready`)
|
|
34
|
+
* }, options)
|
|
35
|
+
*
|
|
36
|
+
* // Later, check if loaded or wait
|
|
37
|
+
* if (isLoaded('es')) {
|
|
38
|
+
* const translations = getTranslationSync('es')
|
|
39
|
+
* }
|
|
40
|
+
else {
|
|
41
|
+
* await waitForLocale('es', 5000) // Wait up to 5s
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* ## Pluralization
|
|
46
|
+
*
|
|
47
|
+
* Use the `|` separator to define plural forms:
|
|
48
|
+
* ```yaml
|
|
49
|
+
* items: "One item|:count items"
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Or for more complex pluralization:
|
|
53
|
+
* ```yaml
|
|
54
|
+
* apples: "{0} No apples|{1} One apple|[2,*] :count apples"
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* ## Cache Management
|
|
58
|
+
*
|
|
59
|
+
* The translation cache can be managed via:
|
|
60
|
+
* - `clearTranslationCache()` - Clear all cached translations
|
|
61
|
+
* - `clearTranslationCache('en')` - Clear specific locale
|
|
62
|
+
* - `getTranslationCacheStats()` - Get cache statistics
|
|
63
|
+
*/
|
|
1
64
|
import type { I18nConfig, StxOptions } from './types';
|
|
65
|
+
export declare const defaultI18nConfig: I18nConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Loading state for async translation loading
|
|
68
|
+
*/
|
|
69
|
+
type LoadingState = 'idle' | 'loading' | 'loaded' | 'error';
|
|
70
|
+
/**
|
|
71
|
+
* Preload configuration
|
|
72
|
+
*/
|
|
73
|
+
export interface PreloadConfig {
|
|
74
|
+
/** Locales to preload */
|
|
75
|
+
locales: string[];
|
|
76
|
+
/** Whether to load in parallel (true) or sequentially (false) */
|
|
77
|
+
parallel?: boolean;
|
|
78
|
+
/** Priority order - higher priority locales load first in sequential mode */
|
|
79
|
+
priority?: Record<string, number>;
|
|
80
|
+
/** Callback when a locale finishes loading */
|
|
81
|
+
onLocaleLoaded?: (locale: string) => void;
|
|
82
|
+
/** Callback when all locales are loaded */
|
|
83
|
+
onComplete?: () => void;
|
|
84
|
+
/** Callback on error */
|
|
85
|
+
onError?: (locale: string, error: Error) => void;
|
|
86
|
+
}
|
|
2
87
|
/**
|
|
3
88
|
* Clear the translation cache
|
|
4
89
|
* @param locale - Optional locale to clear. If not provided, clears all.
|
|
@@ -8,9 +93,13 @@ export declare function clearTranslationCache(locale?: string): void;
|
|
|
8
93
|
* Get translation cache statistics
|
|
9
94
|
*/
|
|
10
95
|
export declare function getTranslationCacheStats(): {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
96
|
+
size: number;
|
|
97
|
+
locales: string[];
|
|
98
|
+
entries: Array<{
|
|
99
|
+
locale: string;
|
|
100
|
+
loadedAt: Date;
|
|
101
|
+
keyCount: number;
|
|
102
|
+
}>;
|
|
14
103
|
};
|
|
15
104
|
/**
|
|
16
105
|
* Get the loading state for a locale
|
|
@@ -221,37 +310,9 @@ export declare function getTranslation(key: string, translations: Record<string,
|
|
|
221
310
|
/**
|
|
222
311
|
* Process @translate directive
|
|
223
312
|
*/
|
|
224
|
-
// eslint-disable-next-line pickier/no-unused-vars
|
|
225
313
|
export declare function processTranslateDirective(template: string, context: Record<string, any>, filePath: string, options: StxOptions): Promise<string>;
|
|
226
314
|
/**
|
|
227
315
|
* Create a translation filter for expressions
|
|
228
316
|
*/
|
|
229
317
|
export declare function createTranslateFilter(translations: Record<string, any>, fallbackToKey?: boolean): (value: string, params?: Record<string, any>) => string;
|
|
230
|
-
|
|
231
|
-
// Configuration
|
|
232
|
-
// =============================================================================
|
|
233
|
-
// Default i18n configuration
|
|
234
|
-
export declare const defaultI18nConfig: I18nConfig;
|
|
235
|
-
/**
|
|
236
|
-
* Preload configuration
|
|
237
|
-
*/
|
|
238
|
-
export declare interface PreloadConfig {
|
|
239
|
-
locales: string[]
|
|
240
|
-
parallel?: boolean
|
|
241
|
-
priority?: Record<string, number>
|
|
242
|
-
onLocaleLoaded?: (locale: string) => void
|
|
243
|
-
onComplete?: () => void
|
|
244
|
-
onError?: (locale: string, error: Error) => void
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Signature of ts-i18n's `loadLocale`. Returns the merged translation tree for
|
|
248
|
-
* a locale, or `undefined` when no file exists for it.
|
|
249
|
-
*/
|
|
250
|
-
declare type LoadLocaleFn = (
|
|
251
|
-
locale: string,
|
|
252
|
-
options: { translationsDir: string, defaultLocale?: string, sources?: Array<'ts' | 'yaml' | 'json'> },
|
|
253
|
-
) => Promise<Record<string, any> | undefined>;
|
|
254
|
-
/**
|
|
255
|
-
* Loading state for async translation loading
|
|
256
|
-
*/
|
|
257
|
-
declare type LoadingState = 'idle' | 'loading' | 'loaded' | 'error';
|
|
318
|
+
export {};
|
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-Sibling Image Discovery
|
|
3
|
+
*
|
|
4
|
+
* NuxtImage-style sugar: if a `.webp` (or `.avif`) sits next to a `.jpg`/
|
|
5
|
+
* `.png` on disk, rewrite plain `<img src="hero.jpg">` into
|
|
6
|
+
*
|
|
7
|
+
* <picture>
|
|
8
|
+
* <source type="image/avif" srcset="/images/hero.avif">
|
|
9
|
+
* <source type="image/webp" srcset="/images/hero.webp">
|
|
10
|
+
* <img src="/images/hero.jpg" alt="…">
|
|
11
|
+
* </picture>
|
|
12
|
+
*
|
|
13
|
+
* No consumer change required — drop the optimized format next to the
|
|
14
|
+
* original asset and capable browsers pick it up.
|
|
15
|
+
*
|
|
16
|
+
* Skipped intentionally:
|
|
17
|
+
* - `<img>` already inside a `<picture>` (don't double-wrap)
|
|
18
|
+
* - Remote URLs (http://, https://, protocol-relative `//cdn/…`)
|
|
19
|
+
* - data: URIs
|
|
20
|
+
* - sources whose extension isn't a known raster format
|
|
21
|
+
* - images whose resolved path is outside `publicDir` (we don't probe
|
|
22
|
+
* arbitrary paths on disk)
|
|
23
|
+
*/
|
|
24
|
+
export interface AutoSiblingOptions {
|
|
25
|
+
/** Filesystem root for resolving src URLs (typically the stx config's `publicDir`). */
|
|
26
|
+
publicDir: string;
|
|
27
|
+
/** Sibling formats to probe for, in priority order (most-preferred first). */
|
|
28
|
+
formats?: Array<{
|
|
29
|
+
ext: string;
|
|
30
|
+
mime: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
1
33
|
/**
|
|
2
34
|
* Scan `html` for plain `<img>` tags whose src resolves to a real file
|
|
3
35
|
* inside `publicDir`, probe for sibling-format files (e.g. `hero.webp`
|
|
@@ -8,7 +40,3 @@
|
|
|
8
40
|
* found, returns the input unchanged (no allocations beyond the scan).
|
|
9
41
|
*/
|
|
10
42
|
export declare function rewriteImagesWithSiblings(html: string, options: AutoSiblingOptions): Promise<string>;
|
|
11
|
-
export declare interface AutoSiblingOptions {
|
|
12
|
-
publicDir: string
|
|
13
|
-
formats?: Array<{ ext: string, mime: string }>
|
|
14
|
-
}
|
package/dist/includes.d.ts
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Includes Module
|
|
3
|
+
*
|
|
4
|
+
* Processes include, partial, and stack directives for template composition.
|
|
5
|
+
* This module enables building complex templates from reusable pieces.
|
|
6
|
+
*
|
|
7
|
+
* ## Include Directives
|
|
8
|
+
*
|
|
9
|
+
* | Directive | Description |
|
|
10
|
+
* |-----------|-------------|
|
|
11
|
+
* | `@include('path')` | Include a partial template |
|
|
12
|
+
* | `@include('path', { vars })` | Include with local variables |
|
|
13
|
+
* | `@partial('path')` | Alias for @include |
|
|
14
|
+
* | `@includeIf('path')` | Include only if file exists |
|
|
15
|
+
* | `@includeWhen(cond, 'path')` | Include if condition is true |
|
|
16
|
+
* | `@includeUnless(cond, 'path')` | Include if condition is false |
|
|
17
|
+
* | `@includeFirst(['a','b'])` | Include first existing file |
|
|
18
|
+
* | `@once...@endonce` | Include content only once per request |
|
|
19
|
+
*
|
|
20
|
+
* ## Stack Directives
|
|
21
|
+
*
|
|
22
|
+
* | Directive | Description |
|
|
23
|
+
* |-----------|-------------|
|
|
24
|
+
* | `@push('name')...@endpush` | Add content to end of stack |
|
|
25
|
+
* | `@prepend('name')...@endprepend` | Add content to start of stack |
|
|
26
|
+
* | `@stack('name')` | Output stack contents |
|
|
27
|
+
*
|
|
28
|
+
* ## Path Resolution
|
|
29
|
+
*
|
|
30
|
+
* Paths are resolved in this order:
|
|
31
|
+
* 1. If path starts with `./` or `../`: Relative to current template
|
|
32
|
+
* 2. Otherwise: Relative to `partialsDir` (from config)
|
|
33
|
+
*
|
|
34
|
+
* Paths without `.stx` extension automatically get it appended.
|
|
35
|
+
*
|
|
36
|
+
* ## Security
|
|
37
|
+
*
|
|
38
|
+
* Path traversal attacks are blocked. Includes must resolve to:
|
|
39
|
+
* - The configured partials directory, OR
|
|
40
|
+
* - The directory containing the current template
|
|
41
|
+
*
|
|
42
|
+
* Uses safe evaluation for expression evaluation to prevent code injection.
|
|
43
|
+
*
|
|
44
|
+
* ## @once Directive
|
|
45
|
+
*
|
|
46
|
+
* The `@once` directive ensures content is only rendered once per request.
|
|
47
|
+
* This is useful for including scripts or styles that should not be duplicated.
|
|
48
|
+
*
|
|
49
|
+
* **Important**: In server environments, use request-scoped tracking:
|
|
50
|
+
*
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // Option 1: Clear global store per request
|
|
53
|
+
* app.use((req, res, next) => {
|
|
54
|
+
* clearOnceStore()
|
|
55
|
+
* next()
|
|
56
|
+
* })
|
|
57
|
+
*
|
|
58
|
+
* // Option 2: Use request-scoped store (recommended)
|
|
59
|
+
* const context = {
|
|
60
|
+
* __onceStore: new Set<string>(),
|
|
61
|
+
* ...otherData
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @module includes
|
|
66
|
+
*/
|
|
2
67
|
import type { StxOptions } from './types';
|
|
68
|
+
import { LRUCache } from './performance-utils';
|
|
69
|
+
export declare const partialsCache: LRUCache<string, string>;
|
|
70
|
+
export declare const onceStore: Set<string>;
|
|
3
71
|
/**
|
|
4
72
|
* Clear the @once store - useful for testing and resetting state
|
|
5
73
|
*
|
|
@@ -101,9 +169,3 @@ export declare function processStackPushDirectives(template: string, stacks: Rec
|
|
|
101
169
|
* ```
|
|
102
170
|
*/
|
|
103
171
|
export declare function processStackReplacements(template: string, stacks: Record<string, string[]>): string;
|
|
104
|
-
// Cache for partials to avoid repeated file reads (LRU with max 500 entries)
|
|
105
|
-
export declare const partialsCache: LRUCache<string, string>;
|
|
106
|
-
// Global store to track what has been included via @once
|
|
107
|
-
// WARNING: This persists across requests in long-running servers!
|
|
108
|
-
// Use clearOnceStore() at the start of each request, or use request-scoped tracking via context.__onceStore
|
|
109
|
-
export declare const onceStore: Set<string>;
|