@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,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process @async directives in templates.
|
|
3
|
+
*
|
|
4
|
+
* Syntax:
|
|
5
|
+
* @async(component: 'ComponentName', timeout: 5000)
|
|
6
|
+
* <loading content>
|
|
7
|
+
* @error
|
|
8
|
+
* <error content>
|
|
9
|
+
* @endasync
|
|
10
|
+
*/
|
|
11
|
+
export declare function processAsyncDirectives(template: string, _context?: Record<string, unknown>, _filePath?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Define an async component.
|
|
14
|
+
*/
|
|
15
|
+
export declare function defineAsyncComponent(options: DefineAsyncComponentOptions | (() => Promise<{ default: string } | string>)): AsyncComponentDefinition;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a value is an async component definition.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isAsyncComponent(value: unknown): value is AsyncComponentDefinition;
|
|
20
|
+
/**
|
|
21
|
+
* Generate CSS for async component styling.
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateAsyncComponentCSS(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Generate client-side runtime for async components.
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateAsyncComponentRuntime(): string;
|
|
28
|
+
/**
|
|
29
|
+
* STX Async Components
|
|
30
|
+
*
|
|
31
|
+
* Provides lazy loading capabilities for components with loading and error states.
|
|
32
|
+
*
|
|
33
|
+
* @module async-components
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```html
|
|
37
|
+
* @async(component: 'HeavyChart', timeout: 5000)
|
|
38
|
+
* <div class="loading">Loading chart...</div>
|
|
39
|
+
* @error
|
|
40
|
+
* <div class="error">Failed to load chart</div>
|
|
41
|
+
* @endasync
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Or inline:
|
|
45
|
+
* ```html
|
|
46
|
+
* <AsyncComponent
|
|
47
|
+
* :component="() => import('./HeavyChart.stx')"
|
|
48
|
+
* :timeout="5000"
|
|
49
|
+
* >
|
|
50
|
+
* <template #loading>Loading...</template>
|
|
51
|
+
* <template #error="{ error }">Error: {{ error.message }}</template>
|
|
52
|
+
* </AsyncComponent>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
// =============================================================================
|
|
56
|
+
// Types
|
|
57
|
+
// =============================================================================
|
|
58
|
+
export declare interface AsyncComponentOptions {
|
|
59
|
+
component: string
|
|
60
|
+
timeout?: number
|
|
61
|
+
delay?: number
|
|
62
|
+
suspensible?: boolean
|
|
63
|
+
loadingComponent?: string
|
|
64
|
+
errorComponent?: string
|
|
65
|
+
retries?: number
|
|
66
|
+
props?: Record<string, unknown>
|
|
67
|
+
}
|
|
68
|
+
export declare interface AsyncComponentState {
|
|
69
|
+
status: 'pending' | 'loading' | 'resolved' | 'rejected'
|
|
70
|
+
component: string | null
|
|
71
|
+
error: Error | null
|
|
72
|
+
attempts: number
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Define an async component for programmatic use.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const AsyncChart = defineAsyncComponent({
|
|
80
|
+
* loader: () => import('./Chart.stx'),
|
|
81
|
+
* loadingComponent: LoadingSpinner,
|
|
82
|
+
* errorComponent: ErrorDisplay,
|
|
83
|
+
* delay: 200,
|
|
84
|
+
* timeout: 3000
|
|
85
|
+
* })
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare interface DefineAsyncComponentOptions {
|
|
89
|
+
loader: () => Promise<{ default: string } | string>
|
|
90
|
+
loadingComponent?: string
|
|
91
|
+
errorComponent?: string
|
|
92
|
+
delay?: number
|
|
93
|
+
timeout?: number
|
|
94
|
+
suspensible?: boolean
|
|
95
|
+
onLoadStart?: () => void
|
|
96
|
+
onLoadEnd?: () => void
|
|
97
|
+
onError?: (error: Error, retry: () => void, fail: () => void, attempts: number) => void
|
|
98
|
+
}
|
|
99
|
+
export declare interface AsyncComponentDefinition extends DefineAsyncComponentOptions {
|
|
100
|
+
__asyncComponent: true
|
|
101
|
+
}
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Module for handling authentication and authorization in templates
|
|
3
|
-
*/
|
|
4
1
|
/**
|
|
5
2
|
* Safely evaluates an auth expression within the given context
|
|
6
3
|
* Similar to evaluateExpression but specialized for auth conditionals
|
|
4
|
+
* Uses the safe evaluator to prevent code injection
|
|
7
5
|
*
|
|
8
6
|
* @param {string} expression - The expression to evaluate
|
|
9
7
|
* @param {Record<string, any>} context - The context object containing variables
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactive localStorage with automatic serialization.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const theme = useLocalStorage('theme', 'dark')
|
|
7
|
+
* console.log(theme.value) // 'dark'
|
|
8
|
+
* theme.value = 'light' // automatically saved
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function useLocalStorage<T>(key: string, defaultValue: T): { value: T; remove: () => void };
|
|
12
|
+
/**
|
|
13
|
+
* Reactive sessionStorage with automatic serialization.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const token = useSessionStorage('auth_token', null)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function useSessionStorage<T>(key: string, defaultValue: T): { value: T; remove: () => void };
|
|
21
|
+
/**
|
|
22
|
+
* Add an event listener with automatic cleanup.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* useEventListener('resize', () => console.log('resized'))
|
|
27
|
+
* useEventListener(buttonRef, 'click', () => console.log('clicked'))
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function useEventListener<K extends keyof WindowEventMap>(event: K, handler: (e: WindowEventMap[K]) => void, options?: AddEventListenerOptions): () => void;
|
|
31
|
+
export declare function useEventListener<K extends keyof DocumentEventMap>(target: Document, event: K, handler: (e: DocumentEventMap[K]) => void, options?: AddEventListenerOptions): () => void;
|
|
32
|
+
export declare function useEventListener<K extends keyof HTMLElementEventMap>(target: MaybeRef<HTMLElement | null>, event: K, handler: (e: HTMLElementEventMap[K]) => void, options?: AddEventListenerOptions): () => void;
|
|
33
|
+
export declare function useEventListener(...args: any[]): () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Detect clicks outside an element.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const dropdownRef = ref<HTMLElement>()
|
|
40
|
+
* useClickOutside(dropdownRef, () => {
|
|
41
|
+
* isOpen.value = false
|
|
42
|
+
* })
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function useClickOutside(target: MaybeRef<HTMLElement | null>, handler: (event: MouseEvent) => void): () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Reactive window size.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const { width, height } = useWindowSize()
|
|
52
|
+
* console.log(`${width.value}x${height.value}`)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function useWindowSize(): {
|
|
56
|
+
width: { readonly value: number }
|
|
57
|
+
height: { readonly value: number }
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Reactive media query.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const isMobile = useMediaQuery('(max-width: 768px)')
|
|
65
|
+
* const prefersDark = useMediaQuery('(prefers-color-scheme: dark)')
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function useMediaQuery(query: string): { readonly value: boolean };
|
|
69
|
+
/**
|
|
70
|
+
* Common breakpoint helpers.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const { isMobile, isTablet, isDesktop } = useBreakpoints()
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function useBreakpoints(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Detect dark mode preference.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const isDark = usePrefersDark()
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function usePrefersDark(): { readonly value: boolean };
|
|
87
|
+
/**
|
|
88
|
+
* Reactive online/offline status.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const isOnline = useOnline()
|
|
93
|
+
* if (!isOnline.value) showOfflineWarning()
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function useOnline(): { readonly value: boolean };
|
|
97
|
+
/**
|
|
98
|
+
* Reactive mouse position.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const { x, y } = useMouse()
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function useMouse(): {
|
|
106
|
+
x: { readonly value: number }
|
|
107
|
+
y: { readonly value: number }
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Reactive scroll position.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const { x, y } = useScroll()
|
|
115
|
+
* // Or for a specific element
|
|
116
|
+
* const { x, y } = useScroll(containerRef)
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function useScroll(target?: MaybeRef<HTMLElement | null>): {
|
|
120
|
+
x: { readonly value: number }
|
|
121
|
+
y: { readonly value: number }
|
|
122
|
+
isScrolling: { readonly value: boolean }
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Debounce a function.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const debouncedSearch = useDebounce((query: string) => {
|
|
130
|
+
* fetchResults(query)
|
|
131
|
+
* }, 300)
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function useDebounce<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
135
|
+
/**
|
|
136
|
+
* Debounce a value.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const searchQuery = ref('')
|
|
141
|
+
* const debouncedQuery = useDebouncedValue(() => searchQuery.value, 300)
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export declare function useDebouncedValue<T>(getter: () => T, delay: number): { readonly value: T };
|
|
145
|
+
/**
|
|
146
|
+
* Throttle a function.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const throttledScroll = useThrottle(() => {
|
|
151
|
+
* updateHeader()
|
|
152
|
+
* }, 100)
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function useThrottle<T extends (...args: any[]) => any>(fn: T, limit: number): (...args: Parameters<T>) => void;
|
|
156
|
+
/**
|
|
157
|
+
* Reactive interval.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const { counter, pause, resume, reset } = useInterval(1000)
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export declare function useInterval(interval: number, options?: { immediate?: boolean }): {
|
|
165
|
+
counter: { readonly value: number }
|
|
166
|
+
pause: () => void
|
|
167
|
+
resume: () => void
|
|
168
|
+
reset: () => void
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* One-time timeout with controls.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* const { isPending, start, stop } = useTimeout(() => {
|
|
176
|
+
* showNotification()
|
|
177
|
+
* }, 5000)
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export declare function useTimeout(callback: () => void, delay: number): {
|
|
181
|
+
isPending: { readonly value: boolean }
|
|
182
|
+
start: () => void
|
|
183
|
+
stop: () => void
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Boolean toggle.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const [isOpen, toggle, setOpen] = useToggle(false)
|
|
191
|
+
* toggle() // true
|
|
192
|
+
* setOpen(false) // false
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
export declare function useToggle(initial?: any): [{ value: boolean }, () => void, (value: boolean) => void];
|
|
196
|
+
/**
|
|
197
|
+
* Counter with controls.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const { count, inc, dec, set, reset } = useCounter(0)
|
|
202
|
+
* inc() // 1
|
|
203
|
+
* inc(5) // 6
|
|
204
|
+
* dec() // 5
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
export declare function useCounter(initial?: any, options?: { min?: number; max?: number }): {
|
|
208
|
+
count: { value: number }
|
|
209
|
+
inc: (delta?: number) => void
|
|
210
|
+
dec: (delta?: number) => void
|
|
211
|
+
set: (value: number) => void
|
|
212
|
+
reset: () => void
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Clipboard access.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* const { copy, copied, text } = useClipboard()
|
|
220
|
+
* await copy('Hello!')
|
|
221
|
+
* if (copied.value) showToast('Copied!')
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export declare function useClipboard(): {
|
|
225
|
+
text: { readonly value: string }
|
|
226
|
+
copied: { readonly value: boolean }
|
|
227
|
+
copy: (text: string) => Promise<void>
|
|
228
|
+
read: () => Promise<string>
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Document title.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const title = useTitle('My App')
|
|
236
|
+
* title.value = 'New Page - My App'
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
export declare function useTitle(initial?: string): { value: string };
|
|
240
|
+
/**
|
|
241
|
+
* Element visibility with IntersectionObserver.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* const target = ref<HTMLElement>()
|
|
246
|
+
* const { isVisible } = useIntersectionObserver(target)
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export declare function useIntersectionObserver(target: MaybeRef<HTMLElement | null>, options?: IntersectionObserverInit): {
|
|
250
|
+
isVisible: { readonly value: boolean }
|
|
251
|
+
stop: () => void
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Focus state of an element.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* const inputRef = ref<HTMLInputElement>()
|
|
259
|
+
* const { isFocused } = useFocus(inputRef)
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
export declare function useFocus(target: MaybeRef<HTMLElement | null>): {
|
|
263
|
+
isFocused: { readonly value: boolean }
|
|
264
|
+
focus: () => void
|
|
265
|
+
blur: () => void
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Fetch data with reactive state.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* const { data, error, isLoading } = useFetch('/api/users')
|
|
273
|
+
*
|
|
274
|
+
* // With options
|
|
275
|
+
* const { data, execute } = useFetch('/api/user', {
|
|
276
|
+
* immediate: false
|
|
277
|
+
* })
|
|
278
|
+
* await execute()
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
export declare function useFetch<T = unknown>(url: string | (() => string), options?: UseFetchOptions<T> & RequestInit): UseFetchReturn<T>;
|
|
282
|
+
/**
|
|
283
|
+
* Async state management.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* const { state, isLoading, error, execute } = useAsync(async () => {
|
|
288
|
+
* const res = await fetch('/api/data')
|
|
289
|
+
* return res.json()
|
|
290
|
+
* })
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
export declare function useAsync<T>(fn: () => Promise<T>, options?: { immediate?: boolean }): {
|
|
294
|
+
state: { readonly value: T | null }
|
|
295
|
+
isLoading: { readonly value: boolean }
|
|
296
|
+
error: { readonly value: Error | null }
|
|
297
|
+
execute: () => Promise<T | null>
|
|
298
|
+
};
|
|
299
|
+
declare interface UseFetchOptions<T> {
|
|
300
|
+
immediate?: boolean
|
|
301
|
+
initialData?: T
|
|
302
|
+
refetch?: boolean
|
|
303
|
+
}
|
|
304
|
+
declare interface UseFetchReturn<T> {
|
|
305
|
+
data: { readonly value: T | null }
|
|
306
|
+
error: { readonly value: Error | null }
|
|
307
|
+
isLoading: { readonly value: boolean }
|
|
308
|
+
execute: () => Promise<void>
|
|
309
|
+
abort: () => void
|
|
310
|
+
}
|
|
311
|
+
// =============================================================================
|
|
312
|
+
// Types
|
|
313
|
+
// =============================================================================
|
|
314
|
+
declare type MaybeRef<T> = T | { value: T }
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analyze which directives are used in a template.
|
|
3
|
+
*/
|
|
4
|
+
export declare function analyzeDirectiveUsage(template: string): DirectiveUsage[];
|
|
5
|
+
/**
|
|
6
|
+
* Get list of unused directives for tree-shaking.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getUnusedDirectives(template: string, preserveDirectives?: string[]): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Generate tree-shaken directive loader code.
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateTreeShakenBundle(usedDirectives: string[]): string;
|
|
13
|
+
/**
|
|
14
|
+
* Find dead code branches that can be eliminated.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findDeadBranches(template: string, constants?: Record<string, unknown>): DeadBranch[];
|
|
17
|
+
/**
|
|
18
|
+
* Remove dead code branches from template.
|
|
19
|
+
*/
|
|
20
|
+
export declare function eliminateDeadCode(template: string, constants?: Record<string, unknown>): { content: string, removed: string[] };
|
|
21
|
+
/**
|
|
22
|
+
* Evaluate a constant expression at compile time.
|
|
23
|
+
*/
|
|
24
|
+
export declare function evaluateConstant(expression: string, constants: Record<string, unknown>): unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Fold constant expressions in template.
|
|
27
|
+
*/
|
|
28
|
+
export declare function foldConstants(template: string, constants: Record<string, unknown>): { content: string, folded: string[] };
|
|
29
|
+
/**
|
|
30
|
+
* Minify HTML content while preserving template directives.
|
|
31
|
+
*/
|
|
32
|
+
export declare function minifyHtml(template: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Pool repeated string literals in template.
|
|
35
|
+
*/
|
|
36
|
+
export declare function poolStrings(template: string): {
|
|
37
|
+
content: string
|
|
38
|
+
pool: Map<string, string>
|
|
39
|
+
count: number
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Optimize a single template with all available optimizations.
|
|
43
|
+
*/
|
|
44
|
+
export declare function optimizeTemplate(template: string, options?: OptimizationOptions): OptimizationResult;
|
|
45
|
+
/**
|
|
46
|
+
* Create optimized build for multiple templates.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createOptimizedBuild(templates: Map<string, string>, options?: OptimizationOptions): Promise<BuildResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Build-Time Optimization Module
|
|
51
|
+
*
|
|
52
|
+
* Provides tree-shaking, dead code elimination, and compile-time optimizations
|
|
53
|
+
* for stx templates to reduce bundle size and improve runtime performance.
|
|
54
|
+
*
|
|
55
|
+
* ## Features
|
|
56
|
+
*
|
|
57
|
+
* 1. **Tree-Shaking** - Remove unused directive handlers from compiled output
|
|
58
|
+
* 2. **Dead Code Elimination** - Remove unreachable template branches
|
|
59
|
+
* 3. **Constant Folding** - Pre-evaluate static expressions
|
|
60
|
+
* 4. **String Pooling** - Deduplicate repeated string literals
|
|
61
|
+
* 5. **HTML Minification** - Remove whitespace and comments from static HTML
|
|
62
|
+
*
|
|
63
|
+
* ## Usage
|
|
64
|
+
*
|
|
65
|
+
* ```typescript
|
|
66
|
+
* import { optimizeTemplate, createOptimizedBuild } from 'stx/build-optimizer'
|
|
67
|
+
*
|
|
68
|
+
* // Optimize a single template
|
|
69
|
+
* const optimized = optimizeTemplate(template, { treeShake: true })
|
|
70
|
+
*
|
|
71
|
+
* // Create optimized build for multiple templates
|
|
72
|
+
* const build = await createOptimizedBuild(templates, options)
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @module build-optimizer
|
|
76
|
+
*/
|
|
77
|
+
/** Optimization options */
|
|
78
|
+
export declare interface OptimizationOptions {
|
|
79
|
+
treeShake?: boolean
|
|
80
|
+
deadCodeElimination?: boolean
|
|
81
|
+
constantFolding?: boolean
|
|
82
|
+
stringPooling?: boolean
|
|
83
|
+
minifyHtml?: boolean
|
|
84
|
+
removeDevCode?: boolean
|
|
85
|
+
constants?: Record<string, unknown>
|
|
86
|
+
preserveDirectives?: string[]
|
|
87
|
+
target?: 'production' | 'development'
|
|
88
|
+
}
|
|
89
|
+
/** Optimization result */
|
|
90
|
+
export declare interface OptimizationResult {
|
|
91
|
+
content: string
|
|
92
|
+
originalSize: number
|
|
93
|
+
optimizedSize: number
|
|
94
|
+
reduction: number
|
|
95
|
+
appliedOptimizations: string[]
|
|
96
|
+
removedDirectives: string[]
|
|
97
|
+
foldedConstants: string[]
|
|
98
|
+
pooledStrings: number
|
|
99
|
+
warnings: string[]
|
|
100
|
+
}
|
|
101
|
+
/** Build result for multiple templates */
|
|
102
|
+
export declare interface BuildResult {
|
|
103
|
+
templates: Map<string, OptimizationResult>
|
|
104
|
+
directiveBundle?: string
|
|
105
|
+
stringPool?: Map<string, string>
|
|
106
|
+
totalOriginalSize: number
|
|
107
|
+
totalOptimizedSize: number
|
|
108
|
+
overallReduction: number
|
|
109
|
+
warnings: string[]
|
|
110
|
+
}
|
|
111
|
+
/** Directive usage info */
|
|
112
|
+
declare interface DirectiveUsage {
|
|
113
|
+
name: string
|
|
114
|
+
count: number
|
|
115
|
+
locations: Array<{ line: number, column: number }>
|
|
116
|
+
}
|
|
117
|
+
/** Dead code branch */
|
|
118
|
+
declare interface DeadBranch {
|
|
119
|
+
start: number
|
|
120
|
+
end: number
|
|
121
|
+
reason: string
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
analyzeDirectiveUsage as analyzeUsage,
|
|
125
|
+
findDeadBranches as findDeadCode,
|
|
126
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { StxOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Render a single STX template to HTML
|
|
4
|
+
*/
|
|
5
|
+
export declare function renderView(templatePath: string, props?: Record<string, unknown>, options?: Partial<StxOptions>): Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Build all views in a directory
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildViews(options: ViewBuildOptions): Promise<BuildResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Watch views directory and rebuild on changes
|
|
12
|
+
*/
|
|
13
|
+
export declare function watchViews(options: ViewBuildOptions, callback?: (result: BuildResult) => void): { close: () => void };
|
|
14
|
+
export declare interface ViewBuildOptions {
|
|
15
|
+
viewsDir: string
|
|
16
|
+
outputDir: string
|
|
17
|
+
componentsDir?: string
|
|
18
|
+
layoutsDir?: string
|
|
19
|
+
partialsDir?: string
|
|
20
|
+
globalProps?: Record<string, unknown>
|
|
21
|
+
placeholders?: Record<string, string>
|
|
22
|
+
views?: ViewConfig[]
|
|
23
|
+
debug?: boolean
|
|
24
|
+
generateManifest?: boolean
|
|
25
|
+
}
|
|
26
|
+
export declare interface ViewConfig {
|
|
27
|
+
input: string
|
|
28
|
+
output?: string
|
|
29
|
+
props?: Record<string, unknown>
|
|
30
|
+
}
|
|
31
|
+
export declare interface BuildResult {
|
|
32
|
+
success: boolean
|
|
33
|
+
views: string[]
|
|
34
|
+
errors: Array<{ file: string; error: string }>
|
|
35
|
+
duration: number
|
|
36
|
+
}
|
|
37
|
+
export default buildViews;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
/**
|
|
3
|
+
* Collect bundle statistics from a build directory
|
|
4
|
+
*/
|
|
5
|
+
export declare function collectBundleStats(buildDir: string, options?: CollectorOptions): Promise<BundleStats>;
|
|
6
|
+
/**
|
|
7
|
+
* Format bytes to human readable string
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatBytes(bytes: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* Parse size string to bytes
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseSize(size: string): number;
|
|
14
|
+
/**
|
|
15
|
+
* Calculate percentage
|
|
16
|
+
*/
|
|
17
|
+
export declare function percentage(part: number, total: number): string;
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Types
|
|
20
|
+
// ============================================================================
|
|
21
|
+
export declare interface ModuleInfo {
|
|
22
|
+
id: string
|
|
23
|
+
path: string
|
|
24
|
+
size: number
|
|
25
|
+
gzipSize: number
|
|
26
|
+
parsedSize: number
|
|
27
|
+
extension: string
|
|
28
|
+
type: ModuleType
|
|
29
|
+
imports: string[]
|
|
30
|
+
importedBy: string[]
|
|
31
|
+
hash: string
|
|
32
|
+
}
|
|
33
|
+
export declare interface ChunkInfo {
|
|
34
|
+
name: string
|
|
35
|
+
files: string[]
|
|
36
|
+
modules: ModuleInfo[]
|
|
37
|
+
size: number
|
|
38
|
+
gzipSize: number
|
|
39
|
+
isEntry: boolean
|
|
40
|
+
isVendor: boolean
|
|
41
|
+
}
|
|
42
|
+
export declare interface DuplicateModule {
|
|
43
|
+
path: string
|
|
44
|
+
count: number
|
|
45
|
+
wastedBytes: number
|
|
46
|
+
locations: string[]
|
|
47
|
+
}
|
|
48
|
+
export declare interface BundleStats {
|
|
49
|
+
timestamp: number
|
|
50
|
+
buildDir: string
|
|
51
|
+
chunks: ChunkInfo[]
|
|
52
|
+
totalSize: number
|
|
53
|
+
totalGzipSize: number
|
|
54
|
+
moduleCount: number
|
|
55
|
+
duplicates: DuplicateModule[]
|
|
56
|
+
byType: Record<ModuleType, { count: number; size: number; gzipSize: number }>
|
|
57
|
+
largestModules: ModuleInfo[]
|
|
58
|
+
warnings: string[]
|
|
59
|
+
}
|
|
60
|
+
export declare interface CollectorOptions {
|
|
61
|
+
includeSourceMaps?: boolean
|
|
62
|
+
parseImports?: boolean
|
|
63
|
+
detectDuplicates?: boolean
|
|
64
|
+
topModulesCount?: number
|
|
65
|
+
}
|
|
66
|
+
export type ModuleType = 'js' | 'css' | 'html' | 'image' | 'font' | 'other'
|