@stacksjs/stx 0.2.0 → 0.2.3
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 +109 -5
- package/dist/analytics.d.ts +40 -0
- package/dist/animation.d.ts +90 -0
- package/dist/app.d.ts +51 -0
- package/dist/ast.d.ts +286 -0
- package/dist/async-components.d.ts +101 -0
- package/dist/auth.d.ts +1 -3
- package/dist/browser-composables.d.ts +314 -0
- package/dist/build-optimizer.d.ts +126 -0
- package/dist/build-views.d.ts +37 -0
- package/dist/bundle-analyzer/collector.d.ts +66 -0
- package/dist/bundle-analyzer/index.d.ts +60 -0
- package/dist/bundle-analyzer/report.d.ts +39 -0
- package/dist/bundle-analyzer/treemap.d.ts +19 -0
- package/dist/bundle-analyzer.js +499 -0
- package/dist/caching.d.ts +7 -0
- package/dist/cli.js +10880 -1199
- package/dist/client/directive.d.ts +10 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/router.d.ts +36 -0
- package/dist/client/stx-router.browser.d.ts +0 -0
- package/dist/client-script.d.ts +22 -0
- package/dist/component-hmr.d.ts +120 -0
- package/dist/components.d.ts +23 -1
- package/dist/composables/index.d.ts +277 -0
- package/dist/composables/use-battery.d.ts +46 -0
- package/dist/composables/use-broadcast-channel.d.ts +58 -0
- package/dist/composables/use-clipboard.d.ts +34 -0
- package/dist/composables/use-cookie.d.ts +70 -0
- package/dist/composables/use-device-orientation.d.ts +109 -0
- package/dist/composables/use-event-source.d.ts +77 -0
- package/dist/composables/use-eye-dropper.d.ts +107 -0
- package/dist/composables/use-fetch.d.ts +84 -0
- package/dist/composables/use-fullscreen.d.ts +47 -0
- package/dist/composables/use-geolocation.d.ts +62 -0
- package/dist/composables/use-idle.d.ts +84 -0
- package/dist/composables/use-intersection-observer.d.ts +81 -0
- package/dist/composables/use-keyboard.d.ts +100 -0
- package/dist/composables/use-media-query.d.ts +56 -0
- package/dist/composables/use-mouse.d.ts +64 -0
- package/dist/composables/use-mutation-observer.d.ts +101 -0
- package/dist/composables/use-network.d.ts +40 -0
- package/dist/composables/use-notification.d.ts +89 -0
- package/dist/composables/use-permissions.d.ts +109 -0
- package/dist/composables/use-resize-observer.d.ts +60 -0
- package/dist/composables/use-share.d.ts +70 -0
- package/dist/composables/use-speech.d.ts +117 -0
- package/dist/composables/use-storage.d.ts +64 -0
- package/dist/composables/use-text-selection.d.ts +97 -0
- package/dist/composables/use-wake-lock.d.ts +85 -0
- package/dist/composables/use-websocket.d.ts +69 -0
- package/dist/composables/use-window.d.ts +84 -0
- package/dist/composables.d.ts +268 -0
- package/dist/composition-api.d.ts +190 -0
- package/dist/computed.d.ts +137 -0
- package/dist/conditionals.d.ts +14 -2
- package/dist/config.d.ts +35 -2
- package/dist/craft-bridge.d.ts +319 -0
- package/dist/craft-compiler.d.ts +229 -0
- package/dist/craft-components.d.ts +411 -0
- package/dist/craft-entry.d.ts +5 -0
- package/dist/craft-ssr.d.ts +134 -0
- package/dist/craft.js +1553 -0
- package/dist/csp.d.ts +229 -0
- package/dist/database.d.ts +407 -0
- package/dist/database.js +5 -0
- package/dist/defer.d.ts +4 -0
- package/dist/deploy/config-generators.d.ts +75 -0
- package/dist/deploy/index.d.ts +84 -0
- package/dist/deploy/netlify.d.ts +109 -0
- package/dist/dev-server/crosswind.d.ts +54 -0
- package/dist/dev-server/index.d.ts +7 -0
- package/dist/dev-server/keyboard-shortcuts.d.ts +34 -0
- package/dist/dev-server/native-window.d.ts +40 -0
- package/dist/dev-server/port-utils.d.ts +27 -0
- package/dist/dev-server/terminal-colors.d.ts +60 -0
- package/dist/dev-server/theme-selector.d.ts +32 -0
- package/dist/dev-server/types.d.ts +92 -0
- package/dist/dev-server.d.ts +21 -0
- package/dist/devtools.d.ts +142 -0
- package/dist/directive-api.d.ts +111 -0
- package/dist/dynamic-components.d.ts +14 -0
- package/dist/edge-runtime.d.ts +200 -0
- package/dist/env.d.ts +9 -0
- package/dist/error-boundaries.d.ts +71 -0
- package/dist/error-handling.d.ts +1 -101
- package/dist/errors/codes.d.ts +99 -0
- package/dist/errors/formatter.d.ts +64 -0
- package/dist/errors/index.d.ts +56 -0
- package/dist/errors/logger.d.ts +74 -0
- package/dist/errors/sanitizer.d.ts +43 -0
- package/dist/errors/types.d.ts +79 -0
- package/dist/events.d.ts +106 -0
- package/dist/expressions.d.ts +86 -11
- package/dist/forms-validation.d.ts +173 -0
- package/dist/forms.d.ts +157 -8
- package/dist/head.d.ts +225 -0
- package/dist/heatmap.d.ts +125 -0
- package/dist/hot-reload.d.ts +87 -0
- package/dist/hydration-runtime.d.ts +47 -0
- package/dist/hydration.d.ts +161 -0
- package/dist/i18n.d.ts +239 -3
- package/dist/image-optimization/build-plugin.d.ts +53 -0
- package/dist/image-optimization/component.d.ts +46 -0
- package/dist/image-optimization/directive.d.ts +30 -0
- package/dist/image-optimization/index.d.ts +86 -0
- package/dist/image-optimization/processor.d.ts +112 -0
- package/dist/includes.d.ts +94 -9
- package/dist/index.d.ts +63 -3
- package/dist/index.js +11603 -1318
- package/dist/init.d.ts +32 -2
- package/dist/interactive.d.ts +14 -0
- package/dist/internal-markdown.d.ts +22 -0
- package/dist/jsx-runtime.d.ts +110 -0
- package/dist/keep-alive.d.ts +87 -0
- package/dist/lazy-loader.d.ts +122 -0
- package/dist/loading-indicator.d.ts +40 -0
- package/dist/loops.d.ts +22 -1
- package/dist/media/client/blur-up.d.ts +65 -0
- package/dist/media/client/index.d.ts +77 -0
- package/dist/media/client/lazy-load.d.ts +73 -0
- package/dist/media/client/upload-handler.d.ts +79 -0
- package/dist/media/image/component.d.ts +46 -0
- package/dist/media/image/directive.d.ts +9 -0
- package/dist/media/image/editing.d.ts +212 -0
- package/dist/media/image/index.d.ts +118 -0
- package/dist/media/image/placeholder.d.ts +78 -0
- package/dist/media/image/processor/cache.d.ts +32 -0
- package/dist/media/image/processor/index.d.ts +12 -0
- package/dist/media/image/processor/optimizer.d.ts +13 -0
- package/dist/media/image/processor/responsive.d.ts +17 -0
- package/dist/media/image/srcset.d.ts +158 -0
- package/dist/media/index.d.ts +295 -0
- package/dist/media/manager/embed.d.ts +25 -0
- package/dist/media/protected/component.d.ts +34 -0
- package/dist/media/protected/index.d.ts +34 -0
- package/dist/media/protected/signature.d.ts +72 -0
- package/dist/media/shared/cache.d.ts +54 -0
- package/dist/media/shared/hash.d.ts +24 -0
- package/dist/media/shared/index.d.ts +2 -0
- package/dist/media/types.d.ts +1051 -0
- package/dist/media/upload/component.d.ts +23 -0
- package/dist/media/upload/index.d.ts +1 -0
- package/dist/media/video/directive.d.ts +9 -0
- package/dist/media/video/index.d.ts +47 -0
- package/dist/media/video/processor/cache.d.ts +33 -0
- package/dist/media/video/processor/index.d.ts +21 -0
- package/dist/media/video/processor/streaming.d.ts +19 -0
- package/dist/media/video/processor/thumbnail.d.ts +28 -0
- package/dist/media/video/processor/transcoder.d.ts +9 -0
- package/dist/middleware.d.ts +42 -3
- package/dist/native-build.d.ts +74 -0
- package/dist/parser/directive-parser.d.ts +79 -0
- package/dist/parser/expression-parser.d.ts +59 -0
- package/dist/parser/index.d.ts +35 -0
- package/dist/parser/tokenizer.d.ts +81 -0
- package/dist/partial-hydration.d.ts +88 -0
- package/dist/performance-utils.d.ts +146 -3
- package/dist/plugin-system.d.ts +128 -0
- package/dist/precompiler.d.ts +108 -0
- package/dist/production-build.d.ts +199 -0
- package/dist/props.d.ts +199 -0
- package/dist/pwa/audit.d.ts +42 -0
- package/dist/pwa/directives.d.ts +29 -0
- package/dist/pwa/icons.d.ts +39 -0
- package/dist/pwa/index.d.ts +59 -0
- package/dist/pwa/inject.d.ts +22 -0
- package/dist/pwa/manifest.d.ts +104 -0
- package/dist/pwa/offline.d.ts +8 -0
- package/dist/pwa/precache.d.ts +29 -0
- package/dist/pwa/service-worker.d.ts +21 -0
- package/dist/pwa/workbox-strategies.d.ts +100 -0
- package/dist/pwa/workbox.d.ts +52 -0
- package/dist/pwa.d.ts +51 -0
- package/dist/pwa.js +8124 -0
- package/dist/reactive-bindings.d.ts +24 -0
- package/dist/reactive.d.ts +100 -0
- package/dist/reactivity.d.ts +253 -0
- package/dist/route-middleware.d.ts +232 -0
- package/dist/router.d.ts +31 -0
- package/dist/routes.d.ts +0 -7
- package/dist/runtime.d.ts +140 -0
- package/dist/safe-evaluator.d.ts +117 -3
- package/dist/scaffolding.d.ts +113 -0
- package/dist/seo.d.ts +120 -7
- package/dist/server-components.d.ts +134 -0
- package/dist/signals.d.ts +501 -0
- package/dist/slots.d.ts +63 -0
- package/dist/source-maps.d.ts +117 -0
- package/dist/ssg.d.ts +157 -0
- package/dist/ssg.js +6831 -0
- package/dist/ssr.d.ts +107 -0
- package/dist/state-management.d.ts +324 -0
- package/dist/stores-client.d.ts +70 -0
- package/dist/story/addons.d.ts +123 -0
- package/dist/story/analytics.d.ts +92 -0
- package/dist/story/auto-stories.d.ts +38 -0
- package/dist/story/bookmarks.d.ts +53 -0
- package/dist/story/bun-test.d.ts +44 -0
- package/dist/story/cli.d.ts +34 -0
- package/dist/story/collect/analyzer.d.ts +33 -0
- package/dist/story/collect/index.d.ts +27 -0
- package/dist/story/collect/parser.d.ts +17 -0
- package/dist/story/collect/scanner.d.ts +13 -0
- package/dist/story/collect/tree.d.ts +17 -0
- package/dist/story/commands/build.d.ts +14 -0
- package/dist/story/commands/dev.d.ts +16 -0
- package/dist/story/commands/index.d.ts +6 -0
- package/dist/story/commands/preview.d.ts +15 -0
- package/dist/story/compiled-output.d.ts +26 -0
- package/dist/story/composition.d.ts +47 -0
- package/dist/story/config-watcher.d.ts +26 -0
- package/dist/story/config.d.ts +26 -0
- package/dist/story/context.d.ts +21 -0
- package/dist/story/controls/index.d.ts +54 -0
- package/dist/story/crosswind.d.ts +29 -0
- package/dist/story/desktop-preview.d.ts +34 -0
- package/dist/story/docs-generator.d.ts +30 -0
- package/dist/story/errors.d.ts +47 -0
- package/dist/story/figma-export.d.ts +169 -0
- package/dist/story/generator.d.ts +21 -0
- package/dist/story/hmr.d.ts +64 -0
- package/dist/story/hot-swap.d.ts +35 -0
- package/dist/story/index.d.ts +51 -0
- package/dist/story/interactions.d.ts +52 -0
- package/dist/story/keyboard-shortcuts.d.ts +34 -0
- package/dist/story/output.d.ts +85 -0
- package/dist/story/performance.d.ts +76 -0
- package/dist/story/presets.d.ts +62 -0
- package/dist/story/props-validation.d.ts +45 -0
- package/dist/story/renderer.d.ts +53 -0
- package/dist/story/search-index.d.ts +47 -0
- package/dist/story/search.d.ts +45 -0
- package/dist/story/server.d.ts +21 -0
- package/dist/story/setup.d.ts +47 -0
- package/dist/story/snapshots.d.ts +65 -0
- package/dist/story/testing.d.ts +58 -0
- package/dist/story/theme.d.ts +68 -0
- package/dist/story/types.d.ts +249 -0
- package/dist/story/ui/code-panel.d.ts +42 -0
- package/dist/story/ui/controls-panel.d.ts +25 -0
- package/dist/story/ui/index.d.ts +4 -0
- package/dist/story/ui/navigation.d.ts +55 -0
- package/dist/story/ui/preview.d.ts +46 -0
- package/dist/story/visual-testing.d.ts +45 -0
- package/dist/streaming.d.ts +82 -2
- package/dist/suspense.d.ts +83 -0
- package/dist/teleport.d.ts +9 -0
- package/dist/testing.d.ts +289 -0
- package/dist/transitions.d.ts +87 -0
- package/dist/type-checker.d.ts +109 -0
- package/dist/types/component-types.d.ts +129 -0
- package/dist/types/config-types.d.ts +336 -0
- package/dist/types/context-types.d.ts +99 -0
- package/dist/types/csp-types.d.ts +79 -0
- package/dist/types/directive-types.d.ts +259 -0
- package/dist/types/index.d.ts +98 -0
- package/dist/types/pwa-types.d.ts +218 -0
- package/dist/types.d.ts +1 -315
- package/dist/typescript-templates.d.ts +178 -0
- package/dist/utils.d.ts +52 -6
- package/dist/validator.d.ts +77 -0
- package/dist/variable-extractor.d.ts +39 -0
- package/dist/view-composers.d.ts +154 -9
- package/dist/virtual-scrolling.d.ts +103 -0
- package/dist/visual-editor.d.ts +209 -0
- package/dist/visual-testing.d.ts +109 -0
- package/dist/visual-testing.js +126 -0
- package/dist/vue-template.d.ts +16 -0
- package/dist/web-components/css-scoping.d.ts +54 -0
- package/dist/web-components/index.d.ts +20 -0
- package/dist/web-components/reactive-generator.d.ts +72 -0
- package/dist/web-components.d.ts +222 -2
- package/dist/x-element.d.ts +35 -0
- package/package.json +41 -11
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export type { ValidatorFn, AsyncValidatorFn, ValidatorRule, FieldState, FormState };
|
|
2
|
+
/**
|
|
3
|
+
* Define a form with validation schema.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const form = defineForm({
|
|
8
|
+
* email: v.required().email(),
|
|
9
|
+
* password: v.required().min(8),
|
|
10
|
+
* age: v.number().between(18, 100)
|
|
11
|
+
* })
|
|
12
|
+
*
|
|
13
|
+
* // Access form state
|
|
14
|
+
* form.values.email
|
|
15
|
+
* form.errors.email
|
|
16
|
+
* form.isValid
|
|
17
|
+
*
|
|
18
|
+
* // Validate
|
|
19
|
+
* await form.validate()
|
|
20
|
+
*
|
|
21
|
+
* // Handle submit
|
|
22
|
+
* form.handleSubmit((values) => {
|
|
23
|
+
* console.log(values)
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function defineForm<T extends Record<string, Validator>>(schema: T, initialValues?: Partial<{ [K in keyof T]: unknown }>): FormState<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Process @error directive in templates
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```html
|
|
33
|
+
* @error(form.email)
|
|
34
|
+
* <span class="text-red-500">{{ message }}</span>
|
|
35
|
+
* @enderror
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function processErrorDirective(content: string, context: Record<string, unknown>, _filePath?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Process @errors directive (shows all errors for a field)
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```html
|
|
44
|
+
* @errors(form.password)
|
|
45
|
+
* <li>{{ message }}</li>
|
|
46
|
+
* @enderrors
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function processErrorsDirective(content: string, context: Record<string, unknown>, _filePath?: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Process @hasErrors directive (conditional block if field has errors)
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```html
|
|
55
|
+
* @hasErrors(form.email)
|
|
56
|
+
* <div class="error-container">
|
|
57
|
+
* ...
|
|
58
|
+
* </div>
|
|
59
|
+
* @endhasErrors
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function processHasErrorsDirective(content: string, context: Record<string, unknown>, _filePath?: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Process all form validation directives
|
|
65
|
+
*/
|
|
66
|
+
export declare function processFormValidationDirectives(content: string, context: Record<string, unknown>, filePath?: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Starting point for building validation rules.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* v.required().email()
|
|
73
|
+
* v.required().min(8).hasUppercase()
|
|
74
|
+
* v.number().between(1, 100)
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare const v: Validator;
|
|
78
|
+
declare interface ValidatorRule {
|
|
79
|
+
name: string
|
|
80
|
+
validate: ValidatorFn | AsyncValidatorFn
|
|
81
|
+
message: string
|
|
82
|
+
async?: boolean
|
|
83
|
+
}
|
|
84
|
+
declare interface FieldState {
|
|
85
|
+
value: unknown
|
|
86
|
+
errors: string[]
|
|
87
|
+
touched: boolean
|
|
88
|
+
dirty: boolean
|
|
89
|
+
valid: boolean
|
|
90
|
+
validating: boolean
|
|
91
|
+
}
|
|
92
|
+
declare interface FormState<T extends Record<string, Validator>> {
|
|
93
|
+
values: { [K in keyof T]: unknown }
|
|
94
|
+
errors: { [K in keyof T]: string[] }
|
|
95
|
+
touched: { [K in keyof T]: boolean }
|
|
96
|
+
dirty: { [K in keyof T]: boolean }
|
|
97
|
+
isValid: boolean
|
|
98
|
+
isValidating: boolean
|
|
99
|
+
isDirty: boolean
|
|
100
|
+
validate: () => Promise<boolean>
|
|
101
|
+
validateField: (field: keyof T) => Promise<boolean>
|
|
102
|
+
reset: () => void
|
|
103
|
+
setValues: (values: Partial<{ [K in keyof T]: unknown }>) => void
|
|
104
|
+
setFieldValue: (field: keyof T, value: unknown) => void
|
|
105
|
+
setFieldTouched: (field: keyof T, touched?: boolean) => void
|
|
106
|
+
getFieldState: (field: keyof T) => FieldState
|
|
107
|
+
handleSubmit: (onSubmit: (values: { [K in keyof T]: unknown }) => void | Promise<void>) => (e?: Event) => Promise<void>
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* STX Form Validation
|
|
111
|
+
*
|
|
112
|
+
* A simple, chainable form validation API.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* import { defineForm, v } from 'stx'
|
|
117
|
+
*
|
|
118
|
+
* const form = defineForm({
|
|
119
|
+
* email: v.required().email(),
|
|
120
|
+
* password: v.required().min(8),
|
|
121
|
+
* age: v.number().between(18, 100)
|
|
122
|
+
* })
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
// =============================================================================
|
|
126
|
+
// Types
|
|
127
|
+
// =============================================================================
|
|
128
|
+
declare type ValidatorFn = (value: unknown, formValues?: Record<string, unknown>) => true | string
|
|
129
|
+
declare type AsyncValidatorFn = (value: unknown, formValues?: Record<string, unknown>) => Promise<true | string>
|
|
130
|
+
// =============================================================================
|
|
131
|
+
// Validator Class
|
|
132
|
+
// =============================================================================
|
|
133
|
+
declare class Validator {
|
|
134
|
+
private rules: ValidatorRule[];
|
|
135
|
+
private defaultValue: unknown;
|
|
136
|
+
private addRule(rule: ValidatorRule): Validator;
|
|
137
|
+
required(message?: any): Validator;
|
|
138
|
+
email(message?: any): Validator;
|
|
139
|
+
url(message?: any): Validator;
|
|
140
|
+
min(length: number, message?: string): Validator;
|
|
141
|
+
max(length: number, message?: string): Validator;
|
|
142
|
+
length(min: number, max: number, message?: string): Validator;
|
|
143
|
+
pattern(regex: RegExp, message?: any): Validator;
|
|
144
|
+
hasUppercase(message?: any): Validator;
|
|
145
|
+
hasLowercase(message?: any): Validator;
|
|
146
|
+
hasNumber(message?: any): Validator;
|
|
147
|
+
hasSpecial(message?: any): Validator;
|
|
148
|
+
alphanumeric(message?: any): Validator;
|
|
149
|
+
startsWithLetter(message?: any): Validator;
|
|
150
|
+
noSpaces(message?: any): Validator;
|
|
151
|
+
number(message?: any): Validator;
|
|
152
|
+
integer(message?: any): Validator;
|
|
153
|
+
positive(message?: any): Validator;
|
|
154
|
+
negative(message?: any): Validator;
|
|
155
|
+
minValue(min: number, message?: string): Validator;
|
|
156
|
+
maxValue(max: number, message?: string): Validator;
|
|
157
|
+
between(min: number, max: number, message?: string): Validator;
|
|
158
|
+
matches(fieldName: string, message?: string): Validator;
|
|
159
|
+
oneOf(values: unknown[], message?: string): Validator;
|
|
160
|
+
notOneOf(values: unknown[], message?: string): Validator;
|
|
161
|
+
date(message?: any): Validator;
|
|
162
|
+
before(date: Date | string, message?: string): Validator;
|
|
163
|
+
after(date: Date | string, message?: string): Validator;
|
|
164
|
+
custom(fn: ValidatorFn, message?: any): Validator;
|
|
165
|
+
async(fn: AsyncValidatorFn, message?: any): Validator;
|
|
166
|
+
when(condition: (value: unknown, formValues: Record<string, unknown>) => boolean, thenValidator: Validator): Validator;
|
|
167
|
+
getRules(): ValidatorRule[];
|
|
168
|
+
getDefaultValue(): unknown;
|
|
169
|
+
default(value: unknown): Validator;
|
|
170
|
+
validate(value: unknown, formValues?: Record<string, unknown>): Promise<string[]>;
|
|
171
|
+
validateSync(value: unknown, formValues?: Record<string, unknown>): string[];
|
|
172
|
+
}
|
|
173
|
+
export { Validator };
|
package/dist/forms.d.ts
CHANGED
|
@@ -1,21 +1,170 @@
|
|
|
1
1
|
import type { StxOptions } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Process all form-related directives
|
|
3
|
+
* Process all form-related directives.
|
|
4
|
+
*
|
|
5
|
+
* Processing order:
|
|
6
|
+
* 1. Validation setup (@validate - generates HTML5 attributes)
|
|
7
|
+
* 2. Basic directives (@csrf, @method)
|
|
8
|
+
* 3. Form input directives (@form, @input, @textarea, etc.)
|
|
9
|
+
* 4. Error display directives (@error)
|
|
4
10
|
*/
|
|
5
|
-
export declare function processForms(template: string, context: Record<string, any>, _filePath: string,
|
|
11
|
+
export declare function processForms(template: string, context: Record<string, any>, _filePath: string, options: StxOptions): string;
|
|
6
12
|
/**
|
|
7
13
|
* Process basic form directives (@csrf, @method)
|
|
8
14
|
*/
|
|
9
15
|
export declare function processBasicFormDirectives(template: string, context: Record<string, any>): string;
|
|
10
16
|
/**
|
|
11
|
-
* Process form input directives
|
|
17
|
+
* Process form input directives.
|
|
18
|
+
* Handles @form, @input, @textarea, @select, @checkbox, @radio, @label.
|
|
12
19
|
*/
|
|
13
|
-
export declare function processFormInputDirectives(template: string, context: Record<string, any
|
|
20
|
+
export declare function processFormInputDirectives(template: string, context: Record<string, any>, classes?: FormClassConfig): string;
|
|
14
21
|
/**
|
|
15
|
-
* Process @error directive for form validation
|
|
22
|
+
* Process @error directive for form validation.
|
|
23
|
+
* Renders content only when the specified field has validation errors.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```html
|
|
27
|
+
* @error('email')
|
|
28
|
+
* <span class="error">{{ $message }}</span>
|
|
29
|
+
* @enderror
|
|
30
|
+
* ```
|
|
16
31
|
*/
|
|
17
|
-
export declare function processErrorDirective(template: string, context: Record<string, any
|
|
32
|
+
export declare function processErrorDirective(template: string, context: Record<string, any>, _classes?: FormClassConfig): string;
|
|
18
33
|
/**
|
|
19
|
-
*
|
|
34
|
+
* Register a custom validation rule.
|
|
35
|
+
*
|
|
36
|
+
* @param name - Rule name
|
|
37
|
+
* @param validator - Validation function returning error message or null
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* registerValidationRule('phone', (value, params, field) => {
|
|
42
|
+
* if (!/^\+?[\d\s-]+$/.test(value)) {
|
|
43
|
+
* return `The ${field} field must be a valid phone number.`
|
|
44
|
+
* }
|
|
45
|
+
* return null
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
20
48
|
*/
|
|
21
|
-
export declare function
|
|
49
|
+
export declare function registerValidationRule(name: string, validator: (value: any, params: string[], field: string) => string | null): void;
|
|
50
|
+
/**
|
|
51
|
+
* Validate a single field value against rules.
|
|
52
|
+
*
|
|
53
|
+
* @param field - Field name
|
|
54
|
+
* @param value - Field value
|
|
55
|
+
* @param rules - Pipe-separated rules (e.g., 'required|email|max:255')
|
|
56
|
+
* @param context - Context for accessing other field values (for confirmed rule)
|
|
57
|
+
* @returns Validation result
|
|
58
|
+
*/
|
|
59
|
+
export declare function validateField(field: string, value: any, rules: string, context?: Record<string, any>): FieldValidationResult;
|
|
60
|
+
/**
|
|
61
|
+
* Validate multiple fields.
|
|
62
|
+
*
|
|
63
|
+
* @param data - Object with field values
|
|
64
|
+
* @param rules - Object mapping field names to rule strings
|
|
65
|
+
* @returns Object with errors per field (empty if valid)
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const errors = validateFields(
|
|
70
|
+
* { email: 'test', password: '123' },
|
|
71
|
+
* { email: 'required|email', password: 'required|min:8' }
|
|
72
|
+
* )
|
|
73
|
+
* // => { email: ['The email field must be a valid email address.'], password: ['The password field must be at least 8 characters.'] }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function validateFields(data: Record<string, any>, rules: Record<string, string>): Record<string, string[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Process @validate directive.
|
|
79
|
+
* Adds validation attributes to the next form element.
|
|
80
|
+
*
|
|
81
|
+
* Usage:
|
|
82
|
+
* ```html
|
|
83
|
+
* @validate('email', 'required|email|max:255')
|
|
84
|
+
* @input('email')
|
|
85
|
+
*
|
|
86
|
+
* @validate('password', 'required|min:8', { message: 'Password too short' })
|
|
87
|
+
* @input('password', '', { type: 'password' })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function processValidateDirective(template: string, _context: Record<string, any>): string;
|
|
91
|
+
/**
|
|
92
|
+
* Register a custom enhanced validation rule
|
|
93
|
+
*/
|
|
94
|
+
export declare function registerEnhancedValidationRule(rule: EnhancedValidationRule): void;
|
|
95
|
+
/**
|
|
96
|
+
* Validate a single value against enhanced rules
|
|
97
|
+
*/
|
|
98
|
+
export declare function validateValueEnhanced(value: unknown, rules: string, allValues?: Record<string, unknown>): { valid: boolean, errors: string[] };
|
|
99
|
+
/**
|
|
100
|
+
* Validate multiple values with enhanced validation
|
|
101
|
+
*/
|
|
102
|
+
export declare function validateFormEnhanced(values: Record<string, unknown>, rules: Record<string, string>): { valid: boolean, errors: Record<string, string[]> };
|
|
103
|
+
/**
|
|
104
|
+
* Generate client-side validation script for a form
|
|
105
|
+
*/
|
|
106
|
+
export declare function generateValidationScript(formId: string, rules: Record<string, string>): string;
|
|
107
|
+
/**
|
|
108
|
+
* Default form class configuration (Bootstrap-compatible)
|
|
109
|
+
*/
|
|
110
|
+
export declare const defaultFormClasses: FormClassConfig;
|
|
111
|
+
/**
|
|
112
|
+
* Enhanced validation rules registry with full validation support
|
|
113
|
+
*/
|
|
114
|
+
export declare const enhancedValidationRules: {
|
|
115
|
+
required: { name: 'required'; validate: (value) => unknown; toHtml5: () => unknown; message: 'This field is required' };
|
|
116
|
+
email: { name: 'email'; validate: (value) => unknown };
|
|
117
|
+
url: { name: 'url'; validate: (value) => unknown };
|
|
118
|
+
numeric: { name: 'numeric'; validate: (value) => unknown; toHtml5: () => unknown };
|
|
119
|
+
integer: { name: 'integer'; validate: (value) => unknown; message: 'Please enter a whole number' };
|
|
120
|
+
alpha: { name: 'alpha'; validate: (value) => unknown; toHtml5: () => unknown };
|
|
121
|
+
alphanumeric: { name: 'alphanumeric'; validate: (value) => unknown; toHtml5: () => unknown };
|
|
122
|
+
min: { name: 'min'; validate: (value, params) => unknown };
|
|
123
|
+
max: { name: 'max'; validate: (value, params) => unknown };
|
|
124
|
+
between: { name: 'between'; validate: (value, params) => unknown; toHtml5: unknown };
|
|
125
|
+
confirmed: { name: 'confirmed'; validate: (value, _params, allValues) => unknown };
|
|
126
|
+
in: { name: 'in'; validate: (value, params) => unknown; message: 'Must be one of: {{values}}' };
|
|
127
|
+
notIn: { name: 'notIn'; validate: (value, params) => unknown; message: 'Must not be: {{values}}' };
|
|
128
|
+
regex: { name: 'regex'; validate: (value, params) => unknown };
|
|
129
|
+
date: { name: 'date'; validate: (value) => unknown };
|
|
130
|
+
before: { name: 'before'; validate: (value, params) => unknown };
|
|
131
|
+
after: { name: 'after'; validate: (value, params) => unknown };
|
|
132
|
+
size: { name: 'size'; validate: (value, params) => unknown };
|
|
133
|
+
phone: { name: 'phone'; validate: (value) => unknown }
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Default CSS class names for form elements.
|
|
137
|
+
* Based on Bootstrap conventions but fully customizable.
|
|
138
|
+
*/
|
|
139
|
+
export declare interface FormClassConfig {
|
|
140
|
+
input: string
|
|
141
|
+
inputError: string
|
|
142
|
+
checkInput: string
|
|
143
|
+
label: string
|
|
144
|
+
errorFeedback: string
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Validation rule definition
|
|
148
|
+
*/
|
|
149
|
+
export declare interface ValidationRule {
|
|
150
|
+
name: string
|
|
151
|
+
params?: string[]
|
|
152
|
+
message?: string
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Validation result for a single field
|
|
156
|
+
*/
|
|
157
|
+
export declare interface FieldValidationResult {
|
|
158
|
+
field: string
|
|
159
|
+
valid: boolean
|
|
160
|
+
errors: string[]
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Enhanced validation rule definition with HTML5 support
|
|
164
|
+
*/
|
|
165
|
+
export declare interface EnhancedValidationRule {
|
|
166
|
+
name: string
|
|
167
|
+
validate: (value: unknown, params: string[], allValues: Record<string, unknown>) => true | string
|
|
168
|
+
toHtml5?: (params: string[]) => string[]
|
|
169
|
+
message: string
|
|
170
|
+
}
|
package/dist/head.d.ts
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the current accumulated head config.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getHead(): HeadConfig;
|
|
5
|
+
/**
|
|
6
|
+
* Get current page meta.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPageMeta(): PageMeta;
|
|
9
|
+
/**
|
|
10
|
+
* Reset head state (for SSR).
|
|
11
|
+
*/
|
|
12
|
+
export declare function resetHead(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Set document head configuration.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* useHead({
|
|
19
|
+
* title: 'My Page',
|
|
20
|
+
* meta: [
|
|
21
|
+
* { name: 'description', content: 'Page description' },
|
|
22
|
+
* { property: 'og:image', content: '/og.png' }
|
|
23
|
+
* ],
|
|
24
|
+
* link: [
|
|
25
|
+
* { rel: 'canonical', href: 'https://example.com/page' }
|
|
26
|
+
* ],
|
|
27
|
+
* script: [
|
|
28
|
+
* { src: 'https://example.com/analytics.js', async: true }
|
|
29
|
+
* ]
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function useHead(config: HeadConfig): void;
|
|
34
|
+
/**
|
|
35
|
+
* Set SEO meta tags with a simplified API.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* useSeoMeta({
|
|
40
|
+
* title: 'My Page',
|
|
41
|
+
* description: 'This is my awesome page',
|
|
42
|
+
* ogImage: 'https://example.com/og.png',
|
|
43
|
+
* twitterCard: 'summary_large_image'
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function useSeoMeta(config: SeoMeta): void;
|
|
48
|
+
/**
|
|
49
|
+
* Define page-level metadata.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* definePageMeta({
|
|
54
|
+
* title: 'Dashboard',
|
|
55
|
+
* layout: 'admin',
|
|
56
|
+
* middleware: ['auth', 'admin'],
|
|
57
|
+
* keepAlive: true
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function definePageMeta(config: PageMeta): void;
|
|
62
|
+
/**
|
|
63
|
+
* Set just the page title.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* useTitle('My Page')
|
|
68
|
+
* useTitle(() => `${productName} - My Store`)
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function usePageTitle(title: string | (() => string)): void;
|
|
72
|
+
/**
|
|
73
|
+
* Render head config to HTML string.
|
|
74
|
+
*/
|
|
75
|
+
export declare function renderHead(config?: HeadConfig): string;
|
|
76
|
+
/**
|
|
77
|
+
* Get HTML attributes string.
|
|
78
|
+
*/
|
|
79
|
+
export declare function renderHtmlAttrs(config?: HeadConfig): string;
|
|
80
|
+
/**
|
|
81
|
+
* Get body attributes string.
|
|
82
|
+
*/
|
|
83
|
+
export declare function renderBodyAttrs(config?: HeadConfig): string;
|
|
84
|
+
/**
|
|
85
|
+
* Apply head config to the actual document (client-side).
|
|
86
|
+
*/
|
|
87
|
+
export declare function applyHead(config?: HeadConfig): void;
|
|
88
|
+
/**
|
|
89
|
+
* Process @head directive.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```html
|
|
93
|
+
* @head
|
|
94
|
+
* <title>My Page</title>
|
|
95
|
+
* <meta name="description" content="...">
|
|
96
|
+
* @endhead
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare function processHeadDirective(content: string): { content: string; headContent: string };
|
|
100
|
+
/**
|
|
101
|
+
* Process @title directive.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```html
|
|
105
|
+
* @title('My Page Title')
|
|
106
|
+
* @title(pageTitle)
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function processTitleDirective(content: string, context: Record<string, unknown>): string;
|
|
110
|
+
/**
|
|
111
|
+
* Process @meta directive.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```html
|
|
115
|
+
* @meta('description', 'Page description')
|
|
116
|
+
* @meta('og:image', ogImageUrl)
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function processMetaDirective(content: string, context: Record<string, unknown>): string;
|
|
120
|
+
/**
|
|
121
|
+
* STX Head Management
|
|
122
|
+
*
|
|
123
|
+
* Manage document head (title, meta, links, scripts) with a simple API.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* import { useHead, useSeoMeta, definePageMeta } from 'stx'
|
|
128
|
+
*
|
|
129
|
+
* // Full control
|
|
130
|
+
* useHead({
|
|
131
|
+
* title: 'My Page',
|
|
132
|
+
* meta: [{ name: 'description', content: '...' }]
|
|
133
|
+
* })
|
|
134
|
+
*
|
|
135
|
+
* // SEO shorthand
|
|
136
|
+
* useSeoMeta({
|
|
137
|
+
* title: 'My Page',
|
|
138
|
+
* description: 'Page description',
|
|
139
|
+
* ogImage: '/og.png'
|
|
140
|
+
* })
|
|
141
|
+
*
|
|
142
|
+
* // Page configuration
|
|
143
|
+
* definePageMeta({
|
|
144
|
+
* title: 'My Page',
|
|
145
|
+
* layout: 'default'
|
|
146
|
+
* })
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
// =============================================================================
|
|
150
|
+
// Types
|
|
151
|
+
// =============================================================================
|
|
152
|
+
export declare interface MetaTag {
|
|
153
|
+
name?: string
|
|
154
|
+
property?: string
|
|
155
|
+
content: string
|
|
156
|
+
httpEquiv?: string
|
|
157
|
+
charset?: string
|
|
158
|
+
}
|
|
159
|
+
export declare interface LinkTag {
|
|
160
|
+
rel: string
|
|
161
|
+
href: string
|
|
162
|
+
type?: string
|
|
163
|
+
sizes?: string
|
|
164
|
+
crossorigin?: string
|
|
165
|
+
as?: string
|
|
166
|
+
media?: string
|
|
167
|
+
}
|
|
168
|
+
export declare interface ScriptTag {
|
|
169
|
+
src?: string
|
|
170
|
+
type?: string
|
|
171
|
+
async?: boolean
|
|
172
|
+
defer?: boolean
|
|
173
|
+
content?: string
|
|
174
|
+
id?: string
|
|
175
|
+
}
|
|
176
|
+
export declare interface HeadConfig {
|
|
177
|
+
title?: string
|
|
178
|
+
titleTemplate?: string | ((title: string) => string)
|
|
179
|
+
base?: { href?: string; target?: string }
|
|
180
|
+
meta?: MetaTag[]
|
|
181
|
+
link?: LinkTag[]
|
|
182
|
+
script?: ScriptTag[]
|
|
183
|
+
style?: { content: string; type?: string }[]
|
|
184
|
+
htmlAttrs?: Record<string, string>
|
|
185
|
+
bodyAttrs?: Record<string, string>
|
|
186
|
+
}
|
|
187
|
+
export declare interface SeoMeta {
|
|
188
|
+
title?: string
|
|
189
|
+
titleTemplate?: string
|
|
190
|
+
description?: string
|
|
191
|
+
keywords?: string | string[]
|
|
192
|
+
author?: string
|
|
193
|
+
robots?: string
|
|
194
|
+
canonical?: string
|
|
195
|
+
ogTitle?: string
|
|
196
|
+
ogDescription?: string
|
|
197
|
+
ogImage?: string
|
|
198
|
+
ogUrl?: string
|
|
199
|
+
ogType?: string
|
|
200
|
+
ogSiteName?: string
|
|
201
|
+
ogLocale?: string
|
|
202
|
+
twitterCard?: 'summary' | 'summary_large_image' | 'app' | 'player'
|
|
203
|
+
twitterTitle?: string
|
|
204
|
+
twitterDescription?: string
|
|
205
|
+
twitterImage?: string
|
|
206
|
+
twitterSite?: string
|
|
207
|
+
twitterCreator?: string
|
|
208
|
+
articleAuthor?: string
|
|
209
|
+
articlePublishedTime?: string
|
|
210
|
+
articleModifiedTime?: string
|
|
211
|
+
articleSection?: string
|
|
212
|
+
articleTags?: string[]
|
|
213
|
+
}
|
|
214
|
+
export declare interface PageMeta {
|
|
215
|
+
title?: string
|
|
216
|
+
description?: string
|
|
217
|
+
layout?: string | false
|
|
218
|
+
middleware?: string | string[]
|
|
219
|
+
transition?: string | { name: string; mode?: string }
|
|
220
|
+
keepAlive?: boolean
|
|
221
|
+
key?: string | ((route: unknown) => string)
|
|
222
|
+
}
|
|
223
|
+
export {
|
|
224
|
+
usePageTitle as useTitle
|
|
225
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
/**
|
|
24
|
+
* Heatmap Module
|
|
25
|
+
*
|
|
26
|
+
* Privacy-compliant heatmap tracking library that tracks user interactions
|
|
27
|
+
* without collecting personally identifiable information (PII).
|
|
28
|
+
*
|
|
29
|
+
* ## Features
|
|
30
|
+
* - Mouse movement tracking
|
|
31
|
+
* - Click tracking
|
|
32
|
+
* - Scroll depth tracking
|
|
33
|
+
* - Privacy compliant (no PII, no cookies by default)
|
|
34
|
+
* - Configurable sampling rates
|
|
35
|
+
* - Export data for analysis
|
|
36
|
+
*
|
|
37
|
+
* ## Configuration
|
|
38
|
+
*
|
|
39
|
+
* Heatmap can be configured in `stx.config.ts`:
|
|
40
|
+
* ```typescript
|
|
41
|
+
* export default {
|
|
42
|
+
* heatmap: {
|
|
43
|
+
* enabled: true,
|
|
44
|
+
* trackMouse: true,
|
|
45
|
+
* trackClicks: true,
|
|
46
|
+
* trackScroll: true,
|
|
47
|
+
* samplingRate: 100, // Track every 100ms
|
|
48
|
+
* honorDnt: true,
|
|
49
|
+
* endpoint: '/api/heatmap'
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* Heatmap tracking configuration
|
|
56
|
+
*/
|
|
57
|
+
export declare interface HeatmapConfig {
|
|
58
|
+
enabled: boolean
|
|
59
|
+
trackMouse?: boolean
|
|
60
|
+
trackClicks?: boolean
|
|
61
|
+
trackScroll?: boolean
|
|
62
|
+
samplingRate?: number
|
|
63
|
+
honorDnt?: boolean
|
|
64
|
+
endpoint?: string
|
|
65
|
+
batchSize?: number
|
|
66
|
+
maxDataPoints?: number
|
|
67
|
+
sessionTimeout?: number
|
|
68
|
+
persistData?: boolean
|
|
69
|
+
storagePrefix?: string
|
|
70
|
+
captureAttributes?: string[]
|
|
71
|
+
ignoreSelectors?: string[]
|
|
72
|
+
zones?: HeatmapZone[]
|
|
73
|
+
debugOverlay?: boolean
|
|
74
|
+
minViewportWidth?: number
|
|
75
|
+
maxViewportWidth?: number
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Zone definition for grouped tracking
|
|
79
|
+
*/
|
|
80
|
+
export declare interface HeatmapZone {
|
|
81
|
+
id: string
|
|
82
|
+
selector: string
|
|
83
|
+
label?: string
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Heatmap data point
|
|
87
|
+
*/
|
|
88
|
+
export declare interface HeatmapDataPoint {
|
|
89
|
+
x: number
|
|
90
|
+
y: number
|
|
91
|
+
type: 'move' | 'click' | 'scroll'
|
|
92
|
+
t: number
|
|
93
|
+
el?: string
|
|
94
|
+
zone?: string
|
|
95
|
+
depth?: number
|
|
96
|
+
attrs?: Record<string, string>
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Heatmap session data
|
|
100
|
+
*/
|
|
101
|
+
export declare interface HeatmapSession {
|
|
102
|
+
sid: string
|
|
103
|
+
page: string
|
|
104
|
+
vw: number
|
|
105
|
+
vh: number
|
|
106
|
+
points: HeatmapDataPoint[]
|
|
107
|
+
started: number
|
|
108
|
+
lastActivity: number
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Server-side heatmap data aggregator
|
|
112
|
+
* For processing collected heatmap data into visualizations
|
|
113
|
+
*/
|
|
114
|
+
export declare class HeatmapAggregator {
|
|
115
|
+
private sessions: Map<string, HeatmapSession>;
|
|
116
|
+
addSession(data: HeatmapSession): void;
|
|
117
|
+
getPageData(page: string): HeatmapDataPoint[];
|
|
118
|
+
getClickData(page: string): HeatmapDataPoint[];
|
|
119
|
+
getMovementData(page: string): HeatmapDataPoint[];
|
|
120
|
+
getScrollData(page: string): { depth: number, count: number }[];
|
|
121
|
+
getZoneStats(page: string): Map<string, { clicks: number, hovers: number }>;
|
|
122
|
+
generateGridData(page: string, gridSize?: number): { x: number, y: number, intensity: number }[][];
|
|
123
|
+
exportJSON(): string;
|
|
124
|
+
clear(): void;
|
|
125
|
+
}
|