@stacksjs/stx 0.1.16 → 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 +91 -1
- 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 +10885 -1203
- 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 +36 -3
- 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/formatter.d.ts +4 -0
- 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 +240 -4
- 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 +11604 -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/plugin.d.ts +1 -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 -10
package/dist/a11y.d.ts
CHANGED
|
@@ -1,20 +1,97 @@
|
|
|
1
1
|
import type { CustomDirective, StxOptions } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Process accessibility directives
|
|
3
|
+
* Process accessibility directives.
|
|
4
|
+
* Handles @a11y hints, @screenReader content, and @ariaDescribe.
|
|
4
5
|
*/
|
|
5
|
-
export declare function processA11yDirectives(template: string,
|
|
6
|
+
export declare function processA11yDirectives(template: string, _context: Record<string, any>, _filePath: string, _options: StxOptions): string;
|
|
6
7
|
/**
|
|
7
|
-
* Create the screen reader only style
|
|
8
|
+
* Create the screen reader only CSS style.
|
|
9
|
+
* Add this to your stylesheet or inject via `<style>` tag.
|
|
8
10
|
*/
|
|
9
11
|
export declare function getScreenReaderOnlyStyle(): string;
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
13
|
+
* Check if DOM environment is available.
|
|
14
|
+
* Useful for determining which accessibility checking mode will be used.
|
|
15
|
+
*
|
|
16
|
+
* @returns true if DOM APIs are available (happy-dom, jsdom, browser)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* if (hasDOMSupport()) {
|
|
21
|
+
* console.log('Using full DOM-based a11y checking')
|
|
22
|
+
* } else {
|
|
23
|
+
* console.log('Using regex-based a11y checking (limited)')
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function hasDOMSupport(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Automatically check template for accessibility issues.
|
|
30
|
+
*
|
|
31
|
+
* This function works in both DOM and non-DOM environments:
|
|
32
|
+
* - With DOM (happy-dom/jsdom): Full accessibility checking with element traversal
|
|
33
|
+
* - Without DOM: Regex-based checking for common issues
|
|
34
|
+
*
|
|
35
|
+
* @param html - HTML content to check
|
|
36
|
+
* @param filePath - File path for error reporting
|
|
37
|
+
* @returns Array of accessibility violations found
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const violations = await checkA11y('<img src="photo.jpg">', 'page.html')
|
|
42
|
+
* // violations[0].type === 'missing-alt'
|
|
43
|
+
* ```
|
|
12
44
|
*/
|
|
13
45
|
export declare function checkA11y(html: string, filePath: string): Promise<A11yViolation[]>;
|
|
14
46
|
/**
|
|
15
|
-
* Scan a directory of stx files for accessibility issues
|
|
47
|
+
* Scan a directory of stx files for accessibility issues.
|
|
48
|
+
* Returns a map of file paths to their violations.
|
|
16
49
|
*/
|
|
17
50
|
export declare function scanA11yIssues(directory: string, options?: { recursive?: boolean, ignorePaths?: string[] }): Promise<Record<string, A11yViolation[]>>;
|
|
51
|
+
/**
|
|
52
|
+
* Auto-fix accessibility issues in HTML content.
|
|
53
|
+
*
|
|
54
|
+
* This function attempts to automatically fix common accessibility issues.
|
|
55
|
+
* Note that some fixes may require manual review to ensure they make sense
|
|
56
|
+
* in context (e.g., alt text should be descriptive, not just present).
|
|
57
|
+
*
|
|
58
|
+
* @param html - HTML content to fix
|
|
59
|
+
* @param config - Auto-fix configuration
|
|
60
|
+
* @returns Fixed HTML and details of changes made
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* const result = autoFixA11y('<img src="photo.jpg">')
|
|
64
|
+
* // result.fixed = '<img src="photo.jpg" alt="">'
|
|
65
|
+
* // result.fixCount = 1
|
|
66
|
+
*/
|
|
67
|
+
export declare function autoFixA11y(html: string, config?: A11yAutoFixConfig): A11yFixResult;
|
|
68
|
+
/**
|
|
69
|
+
* Auto-fix accessibility issues in a file and optionally write back.
|
|
70
|
+
*
|
|
71
|
+
* @param filePath - Path to the file to fix
|
|
72
|
+
* @param config - Auto-fix configuration
|
|
73
|
+
* @param writeBack - Whether to write the fixed content back to the file
|
|
74
|
+
* @returns Fix result
|
|
75
|
+
*/
|
|
76
|
+
export declare function autoFixA11yFile(filePath: string, config?: A11yAutoFixConfig, writeBack?: any): Promise<A11yFixResult>;
|
|
77
|
+
/**
|
|
78
|
+
* Auto-fix accessibility issues in a directory of files.
|
|
79
|
+
*
|
|
80
|
+
* @param directory - Directory to scan
|
|
81
|
+
* @param config - Auto-fix configuration
|
|
82
|
+
* @param options - Scan options
|
|
83
|
+
* @param options.recursive - Whether to scan recursively (default: true)
|
|
84
|
+
* @param options.ignorePaths - Paths to ignore
|
|
85
|
+
* @param options.writeBack - Whether to write fixes back to files (default: false)
|
|
86
|
+
* @param options.extensions - File extensions to process (default: ['.stx', '.html', '.htm'])
|
|
87
|
+
* @returns Map of file paths to fix results
|
|
88
|
+
*/
|
|
89
|
+
export declare function autoFixA11yDirectory(directory: string, config?: A11yAutoFixConfig, options?: {
|
|
90
|
+
recursive?: boolean
|
|
91
|
+
ignorePaths?: string[]
|
|
92
|
+
writeBack?: boolean
|
|
93
|
+
extensions?: string[]
|
|
94
|
+
}): Promise<Record<string, A11yFixResult>>;
|
|
18
95
|
/**
|
|
19
96
|
* Register all a11y directives
|
|
20
97
|
*/
|
|
@@ -37,4 +114,31 @@ export declare interface A11yViolation {
|
|
|
37
114
|
impact: 'critical' | 'serious' | 'moderate' | 'minor'
|
|
38
115
|
help: string
|
|
39
116
|
helpUrl?: string
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Auto-fix result
|
|
120
|
+
*/
|
|
121
|
+
export declare interface A11yFixResult {
|
|
122
|
+
original: string
|
|
123
|
+
fixed: string
|
|
124
|
+
fixCount: number
|
|
125
|
+
fixes: Array<{
|
|
126
|
+
type: string
|
|
127
|
+
description: string
|
|
128
|
+
before: string
|
|
129
|
+
after: string
|
|
130
|
+
}>
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Auto-fix configuration
|
|
134
|
+
*/
|
|
135
|
+
export declare interface A11yAutoFixConfig {
|
|
136
|
+
fixMissingAlt?: boolean
|
|
137
|
+
fixMissingLabels?: boolean
|
|
138
|
+
fixMissingFormLabels?: boolean
|
|
139
|
+
fixTableHeaders?: boolean
|
|
140
|
+
fixMissingLang?: boolean
|
|
141
|
+
fixPositiveTabindex?: boolean
|
|
142
|
+
fixButtonFocusable?: boolean
|
|
143
|
+
defaultLang?: string
|
|
40
144
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CustomDirective, StxOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Analytics Module
|
|
4
|
+
*
|
|
5
|
+
* Provides automatic analytics script injection for various providers:
|
|
6
|
+
* - Fathom Analytics (privacy-focused)
|
|
7
|
+
* - Google Analytics (GA4)
|
|
8
|
+
* - Plausible Analytics (privacy-focused, open source)
|
|
9
|
+
* - Self-hosted analytics (using dynamodb-tooling)
|
|
10
|
+
* - Custom analytics scripts
|
|
11
|
+
*
|
|
12
|
+
* ## Configuration
|
|
13
|
+
*
|
|
14
|
+
* Analytics can be configured in `stx.config.ts`:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* export default {
|
|
17
|
+
* analytics: {
|
|
18
|
+
* enabled: true,
|
|
19
|
+
* driver: 'fathom',
|
|
20
|
+
* fathom: {
|
|
21
|
+
* siteId: 'ABCDEFGH',
|
|
22
|
+
* honorDnt: true,
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Generate analytics tracking script based on configuration
|
|
30
|
+
*/
|
|
31
|
+
export declare function generateAnalyticsScript(options: StxOptions): string;
|
|
32
|
+
/**
|
|
33
|
+
* Inject analytics script into HTML
|
|
34
|
+
* Scripts are injected just before </head> for optimal loading
|
|
35
|
+
*/
|
|
36
|
+
export declare function injectAnalytics(html: string, options: StxOptions): string;
|
|
37
|
+
/**
|
|
38
|
+
* Custom @analytics directive for explicit placement
|
|
39
|
+
*/
|
|
40
|
+
export declare const analyticsDirective: CustomDirective;
|
package/dist/animation.d.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import type { StxOptions } from './types';
|
|
1
|
+
import type { CustomDirective, StxOptions } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Process animation directives in the template
|
|
4
4
|
*/
|
|
5
5
|
export declare function processAnimationDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions): string;
|
|
6
|
+
/**
|
|
7
|
+
* Create an animation timeline for coordinated animations
|
|
8
|
+
*/
|
|
9
|
+
export declare function createAnimationTimeline(entries: TimelineEntry[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* Generate CSS for a custom animation
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateAnimationCSS(name: string, keyframes: Keyframe[], options: KeyframeAnimationOptions): string;
|
|
14
|
+
/**
|
|
15
|
+
* Parse animation shorthand string
|
|
16
|
+
* Format: "duration [delay] [easing] [iterations] [direction] [fill]"
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseAnimationShorthand(shorthand: string): KeyframeAnimationOptions;
|
|
19
|
+
/**
|
|
20
|
+
* Generate client-side animation runtime
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateAnimationRuntime(): string;
|
|
6
23
|
/**
|
|
7
24
|
* Register animation directives
|
|
8
25
|
*/
|
|
@@ -32,6 +49,79 @@ export declare const animationGroupDirective: CustomDirective;
|
|
|
32
49
|
* Motion preferences directive for controlling animation preferences
|
|
33
50
|
*/
|
|
34
51
|
export declare const motionDirective: CustomDirective;
|
|
52
|
+
/** Preset spring configurations */
|
|
53
|
+
export declare const SPRING_PRESETS: {
|
|
54
|
+
default: {
|
|
55
|
+
stiffness: 100;
|
|
56
|
+
damping: 10;
|
|
57
|
+
mass: 1
|
|
58
|
+
};
|
|
59
|
+
gentle: {
|
|
60
|
+
stiffness: 120;
|
|
61
|
+
damping: 14;
|
|
62
|
+
mass: 1
|
|
63
|
+
};
|
|
64
|
+
wobbly: {
|
|
65
|
+
stiffness: 180;
|
|
66
|
+
damping: 12;
|
|
67
|
+
mass: 1
|
|
68
|
+
};
|
|
69
|
+
stiff: {
|
|
70
|
+
stiffness: 210;
|
|
71
|
+
damping: 20;
|
|
72
|
+
mass: 1
|
|
73
|
+
};
|
|
74
|
+
slow: {
|
|
75
|
+
stiffness: 280;
|
|
76
|
+
damping: 60;
|
|
77
|
+
mass: 1
|
|
78
|
+
};
|
|
79
|
+
molasses: {
|
|
80
|
+
stiffness: 280;
|
|
81
|
+
damping: 120;
|
|
82
|
+
mass: 1
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* @keyframe directive for custom keyframe animations
|
|
87
|
+
*/
|
|
88
|
+
export declare const keyframeDirective: CustomDirective;
|
|
89
|
+
/**
|
|
90
|
+
* @stagger directive for staggered child animations
|
|
91
|
+
*/
|
|
92
|
+
export declare const staggerDirective: CustomDirective;
|
|
93
|
+
/**
|
|
94
|
+
* @spring directive for spring physics animations
|
|
95
|
+
*/
|
|
96
|
+
export declare const springDirective: CustomDirective;
|
|
97
|
+
/** Keyframe definition */
|
|
98
|
+
export declare interface Keyframe {
|
|
99
|
+
offset?: number
|
|
100
|
+
properties: Record<string, string | number>
|
|
101
|
+
easing?: string
|
|
102
|
+
}
|
|
103
|
+
/** Animation timeline entry */
|
|
104
|
+
export declare interface TimelineEntry {
|
|
105
|
+
selector: string
|
|
106
|
+
keyframes: Keyframe[]
|
|
107
|
+
options: KeyframeAnimationOptions
|
|
108
|
+
}
|
|
109
|
+
/** Keyframe animation options */
|
|
110
|
+
export declare interface KeyframeAnimationOptions {
|
|
111
|
+
duration: number
|
|
112
|
+
delay?: number
|
|
113
|
+
easing?: string
|
|
114
|
+
iterations?: number | 'infinite'
|
|
115
|
+
direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse'
|
|
116
|
+
fill?: 'none' | 'forwards' | 'backwards' | 'both'
|
|
117
|
+
}
|
|
118
|
+
/** Spring animation config */
|
|
119
|
+
export declare interface SpringConfig {
|
|
120
|
+
stiffness: number
|
|
121
|
+
damping: number
|
|
122
|
+
mass: number
|
|
123
|
+
velocity?: number
|
|
124
|
+
}
|
|
35
125
|
/**
|
|
36
126
|
* Available transition types that can be used with @transition directive
|
|
37
127
|
*/
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CustomDirective } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create an stx application instance.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { createApp } from '@stacksjs/stx'
|
|
7
|
+
*
|
|
8
|
+
* const app = createApp()
|
|
9
|
+
*
|
|
10
|
+
* app.use(myPlugin)
|
|
11
|
+
* app.provide('theme', 'dark')
|
|
12
|
+
* app.component('MyButton', MyButton)
|
|
13
|
+
* app.mount('#app')
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param rootComponent - Optional root component definition
|
|
17
|
+
* @param rootProps - Optional props for the root component
|
|
18
|
+
*/
|
|
19
|
+
export declare function createApp(_rootComponent?: any, _rootProps?: Record<string, any>): StxApp;
|
|
20
|
+
/** A Vue-compatible plugin with install method */
|
|
21
|
+
export declare interface StxAppPlugin {
|
|
22
|
+
install: (app: StxApp, ...options: any[]) => void
|
|
23
|
+
}
|
|
24
|
+
/** The stx application instance */
|
|
25
|
+
export declare interface StxApp {
|
|
26
|
+
use(plugin: StxPluginInput, ...options: any[]): StxApp
|
|
27
|
+
provide(key: string | symbol, value: T): StxApp
|
|
28
|
+
component(name: string, definition?: any): StxApp | any
|
|
29
|
+
directive(name: string, definition?: CustomDirective | Record<string, any>): StxApp | any
|
|
30
|
+
mount(rootContainer?: string | Element): StxApp
|
|
31
|
+
unmount(): void
|
|
32
|
+
config: StxAppConfig
|
|
33
|
+
_components: Map<string, any>
|
|
34
|
+
_directives: Map<string, any>
|
|
35
|
+
_installedPlugins: Set<StxPluginInput>
|
|
36
|
+
}
|
|
37
|
+
/** Application configuration */
|
|
38
|
+
export declare interface StxAppConfig {
|
|
39
|
+
errorHandler?: (error: Error, instance: any, info: string) => void
|
|
40
|
+
warnHandler?: (msg: string, instance: any, trace: string) => void
|
|
41
|
+
globalProperties: Record<string, any>
|
|
42
|
+
performance: boolean
|
|
43
|
+
compilerOptions: {
|
|
44
|
+
/** Custom element tag pattern */
|
|
45
|
+
isCustomElement?: (tag: string) => boolean
|
|
46
|
+
/** Whitespace handling */
|
|
47
|
+
whitespace?: 'condense' | 'preserve'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Plugin can be an object with install() or a plain function */
|
|
51
|
+
export type StxPluginInput = StxAppPlugin | ((app: StxApp, ...options: any[]) => void)
|
package/dist/ast.d.ts
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type { Position } from './source-maps';
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Node Guards
|
|
4
|
+
// =============================================================================
|
|
5
|
+
export declare function isDocumentNode(node: ASTNode): node is DocumentNode;
|
|
6
|
+
export declare function isTextNode(node: ASTNode): node is TextNode;
|
|
7
|
+
export declare function isExpressionNode(node: ASTNode): node is ExpressionNode;
|
|
8
|
+
export declare function isDirectiveNode(node: ASTNode): node is DirectiveNode;
|
|
9
|
+
export declare function isComponentNode(node: ASTNode): node is ComponentNode;
|
|
10
|
+
export declare function isElementNode(node: ASTNode): node is ElementNode;
|
|
11
|
+
export declare function isAttributeNode(node: ASTNode): node is AttributeNode;
|
|
12
|
+
export declare function isCommentNode(node: ASTNode): node is CommentNode;
|
|
13
|
+
export declare function isScriptNode(node: ASTNode): node is ScriptNode;
|
|
14
|
+
export declare function isStyleNode(node: ASTNode): node is StyleNode;
|
|
15
|
+
/**
|
|
16
|
+
* Create a document node
|
|
17
|
+
*/
|
|
18
|
+
export declare function createDocument(children?: ASTNode[], loc?: SourceLocation): DocumentNode;
|
|
19
|
+
/**
|
|
20
|
+
* Create a text node
|
|
21
|
+
*/
|
|
22
|
+
export declare function createText(value: string, loc?: SourceLocation): TextNode;
|
|
23
|
+
/**
|
|
24
|
+
* Create an expression node
|
|
25
|
+
*/
|
|
26
|
+
export declare function createExpression(expression: string, escaped?: boolean, loc?: SourceLocation): ExpressionNode;
|
|
27
|
+
/**
|
|
28
|
+
* Create a directive node
|
|
29
|
+
*/
|
|
30
|
+
export declare function createDirective(name: string, params?: string | null, body?: ASTNode[] | null, loc?: SourceLocation): DirectiveNode;
|
|
31
|
+
/**
|
|
32
|
+
* Create a component node
|
|
33
|
+
*/
|
|
34
|
+
export declare function createComponent(name: string, attributes?: AttributeNode[], children?: ASTNode[], selfClosing?: boolean, loc?: SourceLocation): ComponentNode;
|
|
35
|
+
/**
|
|
36
|
+
* Create an element node
|
|
37
|
+
*/
|
|
38
|
+
export declare function createElement(tag: string, attributes?: AttributeNode[], children?: ASTNode[], loc?: SourceLocation): ElementNode;
|
|
39
|
+
/**
|
|
40
|
+
* Create an attribute node
|
|
41
|
+
*/
|
|
42
|
+
export declare function createAttribute(name: string, value?: string | ExpressionNode | null, loc?: SourceLocation): AttributeNode;
|
|
43
|
+
/**
|
|
44
|
+
* Create a comment node
|
|
45
|
+
*/
|
|
46
|
+
export declare function createComment(value: string, style?: 'html' | 'stx', loc?: SourceLocation): CommentNode;
|
|
47
|
+
/**
|
|
48
|
+
* Create a script node
|
|
49
|
+
*/
|
|
50
|
+
export declare function createScript(content: string, attributes?: AttributeNode[], loc?: SourceLocation): ScriptNode;
|
|
51
|
+
/**
|
|
52
|
+
* Create a style node
|
|
53
|
+
*/
|
|
54
|
+
export declare function createStyle(content: string, attributes?: AttributeNode[], scoped?: boolean, loc?: SourceLocation): StyleNode;
|
|
55
|
+
/**
|
|
56
|
+
* Walk the AST and call visitor callbacks
|
|
57
|
+
*/
|
|
58
|
+
export declare function walkAST(node: ASTNode, visitor: ASTVisitor, parent?: ASTNode | null): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get child nodes of a node
|
|
61
|
+
*/
|
|
62
|
+
export declare function getChildren(node: ASTNode): ASTNode[];
|
|
63
|
+
/**
|
|
64
|
+
* Clone an AST node deeply
|
|
65
|
+
*/
|
|
66
|
+
export declare function cloneNode<T extends ASTNode>(node: T): T;
|
|
67
|
+
/**
|
|
68
|
+
* Replace a node in the AST
|
|
69
|
+
*/
|
|
70
|
+
export declare function replaceNode(root: DocumentNode, target: ASTNode, replacement: ASTNode | ASTNode[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* Remove a node from the AST
|
|
73
|
+
*/
|
|
74
|
+
export declare function removeNode(root: DocumentNode, target: ASTNode): void;
|
|
75
|
+
/**
|
|
76
|
+
* Find all nodes matching a predicate
|
|
77
|
+
*/
|
|
78
|
+
export declare function findNodes(root: ASTNode, predicate: (node: ASTNode) => boolean): ASTNode[];
|
|
79
|
+
/**
|
|
80
|
+
* Find all nodes of a specific type
|
|
81
|
+
*/
|
|
82
|
+
export declare function findNodesByType<T extends ASTNode['type']>(root: ASTNode, type: T): Extract<ASTNode, { type: T }>[];
|
|
83
|
+
/**
|
|
84
|
+
* Find all directives by name
|
|
85
|
+
*/
|
|
86
|
+
export declare function findDirectives(root: ASTNode, name: string): DirectiveNode[];
|
|
87
|
+
/**
|
|
88
|
+
* Find all components by name
|
|
89
|
+
*/
|
|
90
|
+
export declare function findComponents(root: ASTNode, name: string): ComponentNode[];
|
|
91
|
+
/**
|
|
92
|
+
* Find all elements by tag name
|
|
93
|
+
*/
|
|
94
|
+
export declare function findElements(root: ASTNode, tag: string): ElementNode[];
|
|
95
|
+
/**
|
|
96
|
+
* Get all expression nodes in the AST
|
|
97
|
+
*/
|
|
98
|
+
export declare function getExpressions(root: ASTNode): ExpressionNode[];
|
|
99
|
+
/**
|
|
100
|
+
* Get all directive names used in the template
|
|
101
|
+
*/
|
|
102
|
+
export declare function getDirectiveNames(root: ASTNode): Set<string>;
|
|
103
|
+
/**
|
|
104
|
+
* Get all component names used in the template
|
|
105
|
+
*/
|
|
106
|
+
export declare function getComponentNames(root: ASTNode): Set<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Generate code from AST
|
|
109
|
+
*/
|
|
110
|
+
export declare function generateCode(node: ASTNode): string;
|
|
111
|
+
/**
|
|
112
|
+
* Source location in template
|
|
113
|
+
*/
|
|
114
|
+
export declare interface SourceLocation {
|
|
115
|
+
start: Position
|
|
116
|
+
end: Position
|
|
117
|
+
source?: string
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Base interface for all AST nodes
|
|
121
|
+
*/
|
|
122
|
+
export declare interface BaseNode {
|
|
123
|
+
type: string
|
|
124
|
+
loc?: SourceLocation
|
|
125
|
+
parent?: ASTNode
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Document root node
|
|
129
|
+
*/
|
|
130
|
+
export declare interface DocumentNode extends BaseNode {
|
|
131
|
+
type: 'Document'
|
|
132
|
+
children: ASTNode[]
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Plain text content
|
|
136
|
+
*/
|
|
137
|
+
export declare interface TextNode extends BaseNode {
|
|
138
|
+
type: 'Text'
|
|
139
|
+
value: string
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Expression interpolation: {{ expr }} or {!! expr !!}
|
|
143
|
+
*/
|
|
144
|
+
export declare interface ExpressionNode extends BaseNode {
|
|
145
|
+
type: 'Expression'
|
|
146
|
+
expression: string
|
|
147
|
+
escaped: boolean
|
|
148
|
+
raw: string
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Directive: @name(params) ... @endname
|
|
152
|
+
*/
|
|
153
|
+
export declare interface DirectiveNode extends BaseNode {
|
|
154
|
+
type: 'Directive'
|
|
155
|
+
name: string
|
|
156
|
+
params: string | null
|
|
157
|
+
body: ASTNode[] | null
|
|
158
|
+
selfClosing: boolean
|
|
159
|
+
raw: string
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Component: <ComponentName attr="value">...</ComponentName>
|
|
163
|
+
*/
|
|
164
|
+
export declare interface ComponentNode extends BaseNode {
|
|
165
|
+
type: 'Component'
|
|
166
|
+
name: string
|
|
167
|
+
attributes: AttributeNode[]
|
|
168
|
+
children: ASTNode[]
|
|
169
|
+
selfClosing: boolean
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* HTML Element: <tag attr="value">...</tag>
|
|
173
|
+
*/
|
|
174
|
+
export declare interface ElementNode extends BaseNode {
|
|
175
|
+
type: 'Element'
|
|
176
|
+
tag: string
|
|
177
|
+
attributes: AttributeNode[]
|
|
178
|
+
children: ASTNode[]
|
|
179
|
+
selfClosing: boolean
|
|
180
|
+
void: boolean
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Attribute on element or component
|
|
184
|
+
*/
|
|
185
|
+
export declare interface AttributeNode extends BaseNode {
|
|
186
|
+
type: 'Attribute'
|
|
187
|
+
name: string
|
|
188
|
+
value: string | ExpressionNode | null
|
|
189
|
+
dynamic: boolean
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Comment: <!-- comment --> or {{-- comment --}}
|
|
193
|
+
*/
|
|
194
|
+
export declare interface CommentNode extends BaseNode {
|
|
195
|
+
type: 'Comment'
|
|
196
|
+
value: string
|
|
197
|
+
style: 'html' | 'stx'
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Script block: <script>...</script>
|
|
201
|
+
*/
|
|
202
|
+
export declare interface ScriptNode extends BaseNode {
|
|
203
|
+
type: 'Script'
|
|
204
|
+
content: string
|
|
205
|
+
attributes: AttributeNode[]
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Style block: <style>...</style>
|
|
209
|
+
*/
|
|
210
|
+
export declare interface StyleNode extends BaseNode {
|
|
211
|
+
type: 'Style'
|
|
212
|
+
content: string
|
|
213
|
+
attributes: AttributeNode[]
|
|
214
|
+
scoped: boolean
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Visitor callbacks for AST traversal
|
|
218
|
+
*/
|
|
219
|
+
export declare interface ASTVisitor {
|
|
220
|
+
enter?: (node: ASTNode, parent: ASTNode | null) => void | false
|
|
221
|
+
leave?: (node: ASTNode, parent: ASTNode | null) => void
|
|
222
|
+
Document?: { enter?: (node: DocumentNode) => void | false, leave?: (node: DocumentNode) => void }
|
|
223
|
+
Text?: { enter?: (node: TextNode) => void | false, leave?: (node: TextNode) => void }
|
|
224
|
+
Expression?: { enter?: (node: ExpressionNode) => void | false, leave?: (node: ExpressionNode) => void }
|
|
225
|
+
Directive?: { enter?: (node: DirectiveNode) => void | false, leave?: (node: DirectiveNode) => void }
|
|
226
|
+
Component?: { enter?: (node: ComponentNode) => void | false, leave?: (node: ComponentNode) => void }
|
|
227
|
+
Element?: { enter?: (node: ElementNode) => void | false, leave?: (node: ElementNode) => void }
|
|
228
|
+
Attribute?: { enter?: (node: AttributeNode) => void | false, leave?: (node: AttributeNode) => void }
|
|
229
|
+
Comment?: { enter?: (node: CommentNode) => void | false, leave?: (node: CommentNode) => void }
|
|
230
|
+
Script?: { enter?: (node: ScriptNode) => void | false, leave?: (node: ScriptNode) => void }
|
|
231
|
+
Style?: { enter?: (node: StyleNode) => void | false, leave?: (node: StyleNode) => void }
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Union of all AST node types
|
|
235
|
+
*/
|
|
236
|
+
export type ASTNode = | DocumentNode
|
|
237
|
+
| TextNode
|
|
238
|
+
| ExpressionNode
|
|
239
|
+
| DirectiveNode
|
|
240
|
+
| ComponentNode
|
|
241
|
+
| ElementNode
|
|
242
|
+
| AttributeNode
|
|
243
|
+
| CommentNode
|
|
244
|
+
| ScriptNode
|
|
245
|
+
| StyleNode
|
|
246
|
+
/**
|
|
247
|
+
* Token types for lexer (reserved for future tokenizer implementation)
|
|
248
|
+
*/
|
|
249
|
+
declare type _TokenType = | 'TEXT'
|
|
250
|
+
| 'EXPRESSION_ESCAPED'
|
|
251
|
+
| 'EXPRESSION_UNESCAPED'
|
|
252
|
+
| 'DIRECTIVE_START'
|
|
253
|
+
| 'DIRECTIVE_END'
|
|
254
|
+
| 'COMMENT_HTML'
|
|
255
|
+
| 'COMMENT_STX'
|
|
256
|
+
| 'TAG_OPEN'
|
|
257
|
+
| 'TAG_CLOSE'
|
|
258
|
+
| 'TAG_SELF_CLOSE'
|
|
259
|
+
| 'EOF'
|
|
260
|
+
/**
|
|
261
|
+
* Simple template parser
|
|
262
|
+
*/
|
|
263
|
+
export declare class TemplateParser {
|
|
264
|
+
private source: string;
|
|
265
|
+
private pos: number;
|
|
266
|
+
private line: number;
|
|
267
|
+
private column: number;
|
|
268
|
+
private filePath?: string;
|
|
269
|
+
parse(template: string, filePath?: string): DocumentNode;
|
|
270
|
+
private parseChildren(stopAt?: RegExp): ASTNode[];
|
|
271
|
+
private parseNext(): ASTNode | null;
|
|
272
|
+
private parseText(): TextNode | null;
|
|
273
|
+
private parseExpression(escaped: boolean): ExpressionNode;
|
|
274
|
+
private parseDirective(): DirectiveNode;
|
|
275
|
+
private parseParenthesized(): string;
|
|
276
|
+
private parseStxComment(): CommentNode;
|
|
277
|
+
private parseHtmlComment(): CommentNode;
|
|
278
|
+
private parseTag(): ElementNode | ComponentNode;
|
|
279
|
+
private parseAttributes(): AttributeNode[];
|
|
280
|
+
private parseAttribute(): AttributeNode | null;
|
|
281
|
+
private parseScript(): ScriptNode;
|
|
282
|
+
private parseStyle(): StyleNode;
|
|
283
|
+
private advance(count?: number): void;
|
|
284
|
+
private skipWhitespace(): void;
|
|
285
|
+
private getPosition(): Position;
|
|
286
|
+
}
|