@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,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse all cookies from document.cookie
|
|
3
|
+
*/
|
|
4
|
+
export declare function parseCookies(): Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Get a specific cookie value
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCookie(name: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Set a cookie
|
|
11
|
+
*/
|
|
12
|
+
export declare function setCookie(name: string, value: string, options?: CookieOptions): void;
|
|
13
|
+
/**
|
|
14
|
+
* Remove a cookie
|
|
15
|
+
*/
|
|
16
|
+
export declare function removeCookie(name: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Create a reactive cookie reference
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // Simple usage
|
|
23
|
+
* const token = useCookie<string>('auth_token')
|
|
24
|
+
* token.value = 'abc123' // Automatically persists
|
|
25
|
+
*
|
|
26
|
+
* // With options
|
|
27
|
+
* const session = useCookie<SessionData>('session', {
|
|
28
|
+
* maxAge: 60 * 60 * 24 * 7, // 7 days
|
|
29
|
+
* secure: true,
|
|
30
|
+
* sameSite: 'strict'
|
|
31
|
+
* })
|
|
32
|
+
*
|
|
33
|
+
* // Subscribe to changes
|
|
34
|
+
* token.subscribe((newValue) => console.log('Token changed:', newValue))
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function useCookie<T = string>(name: string, options?: CookieOptions): CookieRef<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Get all cookies as an object
|
|
40
|
+
*/
|
|
41
|
+
export declare function useCookies(): Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* Clear all cookies (that are accessible)
|
|
44
|
+
*/
|
|
45
|
+
export declare function clearCookies(options?: Pick<CookieOptions, 'path' | 'domain'>): void;
|
|
46
|
+
/**
|
|
47
|
+
* useCookie - Reactive cookie composable
|
|
48
|
+
*
|
|
49
|
+
* Similar to Nuxt's useCookie but for STX applications.
|
|
50
|
+
* Provides a reactive, type-safe wrapper around document.cookie.
|
|
51
|
+
*/
|
|
52
|
+
export declare interface CookieOptions {
|
|
53
|
+
maxAge?: number
|
|
54
|
+
expires?: Date | number | string
|
|
55
|
+
path?: string
|
|
56
|
+
domain?: string
|
|
57
|
+
secure?: boolean
|
|
58
|
+
httpOnly?: boolean
|
|
59
|
+
sameSite?: 'strict' | 'lax' | 'none'
|
|
60
|
+
default?: unknown
|
|
61
|
+
encode?: (value: string) => string
|
|
62
|
+
decode?: (value: string) => string
|
|
63
|
+
}
|
|
64
|
+
export declare interface CookieRef<T> {
|
|
65
|
+
value: T | null
|
|
66
|
+
get: () => T | null
|
|
67
|
+
set: (value: T, options?: CookieOptions) => void
|
|
68
|
+
remove: () => void
|
|
69
|
+
subscribe: (callback: (value: T | null, prev: T | null) => void) => () => void
|
|
70
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if DeviceOrientation is supported
|
|
3
|
+
*/
|
|
4
|
+
export declare function isDeviceOrientationSupported(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Check if DeviceMotion is supported
|
|
7
|
+
*/
|
|
8
|
+
export declare function isDeviceMotionSupported(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Request permission for device orientation (required on iOS 13+)
|
|
11
|
+
*/
|
|
12
|
+
export declare function requestOrientationPermission(): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Request permission for device motion (required on iOS 13+)
|
|
15
|
+
*/
|
|
16
|
+
export declare function requestMotionPermission(): Promise<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Create a reactive device orientation tracker
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const orientation = useDeviceOrientation()
|
|
23
|
+
*
|
|
24
|
+
* // Request permission first (required on iOS)
|
|
25
|
+
* await orientation.requestPermission()
|
|
26
|
+
*
|
|
27
|
+
* // Subscribe to orientation changes
|
|
28
|
+
* orientation.subscribe((state) => {
|
|
29
|
+
* console.log('Alpha (compass):', state.alpha)
|
|
30
|
+
* console.log('Beta (front/back):', state.beta)
|
|
31
|
+
* console.log('Gamma (left/right):', state.gamma)
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function useDeviceOrientation(): DeviceOrientationRef;
|
|
36
|
+
/**
|
|
37
|
+
* Create a reactive device motion tracker
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const motion = useDeviceMotion()
|
|
42
|
+
*
|
|
43
|
+
* // Request permission first (required on iOS)
|
|
44
|
+
* await motion.requestPermission()
|
|
45
|
+
*
|
|
46
|
+
* // Subscribe to motion changes
|
|
47
|
+
* motion.subscribe((state) => {
|
|
48
|
+
* console.log('Acceleration:', state.acceleration)
|
|
49
|
+
* console.log('Rotation rate:', state.rotationRate)
|
|
50
|
+
* })
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function useDeviceMotion(): DeviceMotionRef;
|
|
54
|
+
/**
|
|
55
|
+
* Simple tilt detection for parallax effects
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const tilt = useParallax()
|
|
60
|
+
*
|
|
61
|
+
* tilt.subscribe(({ x, y }) => {
|
|
62
|
+
* element.style.transform = `translate(${x * 10}px, ${y * 10}px)`
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function useParallax(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Device Orientation & Motion Composables
|
|
69
|
+
*
|
|
70
|
+
* Reactive utilities for device orientation and motion sensors.
|
|
71
|
+
*/
|
|
72
|
+
export declare interface DeviceOrientationState {
|
|
73
|
+
isSupported: boolean
|
|
74
|
+
isAbsolute: boolean
|
|
75
|
+
alpha: number | null
|
|
76
|
+
beta: number | null
|
|
77
|
+
gamma: number | null
|
|
78
|
+
}
|
|
79
|
+
export declare interface DeviceMotionState {
|
|
80
|
+
isSupported: boolean
|
|
81
|
+
acceleration: {
|
|
82
|
+
x: number | null
|
|
83
|
+
y: number | null
|
|
84
|
+
z: number | null
|
|
85
|
+
}
|
|
86
|
+
accelerationIncludingGravity: {
|
|
87
|
+
x: number | null
|
|
88
|
+
y: number | null
|
|
89
|
+
z: number | null
|
|
90
|
+
}
|
|
91
|
+
rotationRate: {
|
|
92
|
+
alpha: number | null
|
|
93
|
+
beta: number | null
|
|
94
|
+
gamma: number | null
|
|
95
|
+
}
|
|
96
|
+
interval: number
|
|
97
|
+
}
|
|
98
|
+
export declare interface DeviceOrientationRef {
|
|
99
|
+
get: () => DeviceOrientationState
|
|
100
|
+
subscribe: (fn: (state: DeviceOrientationState) => void) => () => void
|
|
101
|
+
isSupported: () => boolean
|
|
102
|
+
requestPermission: () => Promise<boolean>
|
|
103
|
+
}
|
|
104
|
+
export declare interface DeviceMotionRef {
|
|
105
|
+
get: () => DeviceMotionState
|
|
106
|
+
subscribe: (fn: (state: DeviceMotionState) => void) => () => void
|
|
107
|
+
isSupported: () => boolean
|
|
108
|
+
requestPermission: () => Promise<boolean>
|
|
109
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if EventSource is supported
|
|
3
|
+
*/
|
|
4
|
+
export declare function isEventSourceSupported(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Create a reactive Server-Sent Events connection
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const sse = useEventSource('/api/events', {
|
|
11
|
+
* events: ['notification', 'update'],
|
|
12
|
+
* onMessage: (event) => console.log('Message:', event.data),
|
|
13
|
+
* })
|
|
14
|
+
*
|
|
15
|
+
* // Subscribe to state changes
|
|
16
|
+
* sse.subscribe((state) => {
|
|
17
|
+
* console.log('Status:', state.status)
|
|
18
|
+
* console.log('Last data:', state.data)
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* // Listen to specific events
|
|
22
|
+
* sse.on('notification', (event) => {
|
|
23
|
+
* console.log('Notification:', event.data)
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Close connection
|
|
27
|
+
* sse.close()
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function useEventSource<T = unknown>(url: string | URL, options?: EventSourceOptions): EventSourceRef<T>;
|
|
31
|
+
/**
|
|
32
|
+
* Simple SSE connection for receiving JSON data
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const { data, status, close } = useSSE<{ count: number }>('/api/counter')
|
|
37
|
+
*
|
|
38
|
+
* data.subscribe((value) => {
|
|
39
|
+
* console.log('Count:', value?.count)
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function useSSE<T = unknown>(url: string): void;
|
|
44
|
+
export declare interface EventSourceState<T = unknown> {
|
|
45
|
+
status: EventSourceStatus
|
|
46
|
+
data: T | null
|
|
47
|
+
event: string | null
|
|
48
|
+
lastEventId: string | null
|
|
49
|
+
error: Event | null
|
|
50
|
+
}
|
|
51
|
+
export declare interface EventSourceOptions {
|
|
52
|
+
withCredentials?: boolean
|
|
53
|
+
autoReconnect?: boolean | {
|
|
54
|
+
retries?: number
|
|
55
|
+
delay?: number
|
|
56
|
+
onFailed?: () => void
|
|
57
|
+
}
|
|
58
|
+
immediate?: boolean
|
|
59
|
+
events?: string[]
|
|
60
|
+
onOpen?: (event: Event) => void
|
|
61
|
+
onMessage?: (event: MessageEvent) => void
|
|
62
|
+
onError?: (event: Event) => void
|
|
63
|
+
}
|
|
64
|
+
export declare interface EventSourceRef<T = unknown> {
|
|
65
|
+
get: () => EventSourceState<T>
|
|
66
|
+
subscribe: (fn: (state: EventSourceState<T>) => void) => () => void
|
|
67
|
+
open: () => void
|
|
68
|
+
close: () => void
|
|
69
|
+
eventSource: () => EventSource | null
|
|
70
|
+
on: (eventName: string, callback: (event: MessageEvent) => void) => () => void
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Event Source (SSE) Composables
|
|
74
|
+
*
|
|
75
|
+
* Reactive utilities for Server-Sent Events.
|
|
76
|
+
*/
|
|
77
|
+
export type EventSourceStatus = 'connecting' | 'open' | 'closed' | 'error'
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if EyeDropper API is supported
|
|
3
|
+
*/
|
|
4
|
+
export declare function isEyeDropperSupported(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Create a reactive eye dropper color picker
|
|
7
|
+
*
|
|
8
|
+
* The EyeDropper API allows users to pick colors from anywhere on their
|
|
9
|
+
* screen, not just within the browser window. Great for design tools,
|
|
10
|
+
* color pickers, and accessibility features.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const eyeDropper = useEyeDropper({
|
|
15
|
+
* onPick: (color) => {
|
|
16
|
+
* console.log('Picked color:', color) // e.g., "#ff6188"
|
|
17
|
+
* }
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* // Subscribe to state changes
|
|
21
|
+
* eyeDropper.subscribe((state) => {
|
|
22
|
+
* if (state.sRGBHex) {
|
|
23
|
+
* document.body.style.backgroundColor = state.sRGBHex
|
|
24
|
+
* }
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* // Open the color picker
|
|
28
|
+
* const color = await eyeDropper.open()
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function useEyeDropper(options?: EyeDropperOptions): EyeDropperRef;
|
|
32
|
+
/**
|
|
33
|
+
* Simple color picker that returns the color
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const color = await pickColor()
|
|
38
|
+
* if (color) {
|
|
39
|
+
* console.log('Picked:', color)
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function pickColor(): Promise<string | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Convert hex color to RGB values
|
|
46
|
+
*/
|
|
47
|
+
export declare function hexToRgb(hex: string): { r: number, g: number, b: number } | null;
|
|
48
|
+
/**
|
|
49
|
+
* Convert hex color to HSL values
|
|
50
|
+
*/
|
|
51
|
+
export declare function hexToHsl(hex: string): { h: number, s: number, l: number } | null;
|
|
52
|
+
/**
|
|
53
|
+
* Pick a color with history tracking
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const colorPicker = useColorHistory({
|
|
58
|
+
* maxHistory: 10
|
|
59
|
+
* })
|
|
60
|
+
*
|
|
61
|
+
* await colorPicker.pick()
|
|
62
|
+
*
|
|
63
|
+
* colorPicker.subscribe((state) => {
|
|
64
|
+
* console.log('History:', state.history)
|
|
65
|
+
* console.log('Current:', state.current)
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function useColorHistory(options?: {
|
|
70
|
+
maxHistory?: number
|
|
71
|
+
onPick?: (color: string) => void
|
|
72
|
+
}): void;
|
|
73
|
+
/**
|
|
74
|
+
* EyeDropper Composables
|
|
75
|
+
*
|
|
76
|
+
* Reactive utilities for the EyeDropper API to pick colors from the screen.
|
|
77
|
+
*/
|
|
78
|
+
export declare interface EyeDropperState {
|
|
79
|
+
isSupported: boolean
|
|
80
|
+
isOpen: boolean
|
|
81
|
+
sRGBHex: string | null
|
|
82
|
+
error: Error | null
|
|
83
|
+
}
|
|
84
|
+
export declare interface EyeDropperResult {
|
|
85
|
+
sRGBHex: string
|
|
86
|
+
}
|
|
87
|
+
export declare interface EyeDropperOptions {
|
|
88
|
+
onPick?: (color: string) => void
|
|
89
|
+
onAbort?: () => void
|
|
90
|
+
onError?: (error: Error) => void
|
|
91
|
+
}
|
|
92
|
+
export declare interface EyeDropperRef {
|
|
93
|
+
get: () => EyeDropperState
|
|
94
|
+
subscribe: (fn: (state: EyeDropperState) => void) => () => void
|
|
95
|
+
open: () => Promise<string | null>
|
|
96
|
+
isSupported: () => boolean
|
|
97
|
+
}
|
|
98
|
+
declare interface EyeDropperConstructor {
|
|
99
|
+
new (): {
|
|
100
|
+
open: (options?: { signal?: AbortSignal }) => Promise<EyeDropperResult>
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
declare namespace global {
|
|
104
|
+
interface Window {
|
|
105
|
+
EyeDropper?: EyeDropperConstructor
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactive fetch with loading/error states
|
|
3
|
+
*/
|
|
4
|
+
export declare function useFetch<T = unknown>(url: string | (() => string), options?: FetchOptions<T>): FetchRef<T>;
|
|
5
|
+
/**
|
|
6
|
+
* Generic async data fetcher
|
|
7
|
+
*/
|
|
8
|
+
export declare function useAsyncData<T>(fetcher: () => Promise<T>, options?: {
|
|
9
|
+
immediate?: boolean
|
|
10
|
+
transform?: (data: T) => T
|
|
11
|
+
default?: T
|
|
12
|
+
key?: string
|
|
13
|
+
cacheTime?: number
|
|
14
|
+
}): FetchRef<T>;
|
|
15
|
+
/**
|
|
16
|
+
* POST request helper
|
|
17
|
+
*/
|
|
18
|
+
export declare function usePost<T = unknown, B = unknown>(url: string, options?: Omit<FetchOptions<T>, 'method' | 'body'>): {
|
|
19
|
+
execute: (body?: B) => Promise<T | null>
|
|
20
|
+
state: FetchRef<T>
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Clear fetch cache
|
|
24
|
+
*/
|
|
25
|
+
export declare function clearFetchCache(key?: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Prefetch data into cache
|
|
28
|
+
*/
|
|
29
|
+
export declare function prefetch<T>(url: string, options?: FetchOptions<T>): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* useFetch - Reactive data fetching with loading/error states
|
|
32
|
+
*
|
|
33
|
+
* Provides a streamlined API for fetching data with automatic state management.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* // Basic fetch
|
|
38
|
+
* const { data, loading, error, refresh } = useFetch('/api/users')
|
|
39
|
+
*
|
|
40
|
+
* // With options
|
|
41
|
+
* const { data } = useFetch('/api/users', {
|
|
42
|
+
* method: 'POST',
|
|
43
|
+
* body: { name: 'John' },
|
|
44
|
+
* immediate: false, // Don't fetch immediately
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* // Async data with transform
|
|
48
|
+
* const { data } = useAsyncData(
|
|
49
|
+
* () => fetch('/api/users').then(r => r.json()),
|
|
50
|
+
* { transform: (data) => data.users }
|
|
51
|
+
* )
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare interface FetchOptions<T = unknown> extends Omit<RequestInit, 'body'> {
|
|
55
|
+
body?: BodyInit | Record<string, unknown> | null
|
|
56
|
+
baseURL?: string
|
|
57
|
+
query?: Record<string, string | number | boolean | undefined>
|
|
58
|
+
immediate?: boolean
|
|
59
|
+
transform?: (data: unknown) => T
|
|
60
|
+
parseResponse?: (response: Response) => Promise<unknown>
|
|
61
|
+
timeout?: number
|
|
62
|
+
retry?: number
|
|
63
|
+
retryDelay?: number
|
|
64
|
+
key?: string
|
|
65
|
+
cacheTime?: number
|
|
66
|
+
refetchOnFocus?: boolean
|
|
67
|
+
refetchInterval?: number
|
|
68
|
+
default?: T
|
|
69
|
+
}
|
|
70
|
+
export declare interface FetchState<T> {
|
|
71
|
+
data: T | null
|
|
72
|
+
loading: boolean
|
|
73
|
+
error: Error | null
|
|
74
|
+
status: number | null
|
|
75
|
+
statusText: string | null
|
|
76
|
+
}
|
|
77
|
+
export declare interface FetchRef<T> {
|
|
78
|
+
get: () => FetchState<T>
|
|
79
|
+
subscribe: (fn: (state: FetchState<T>) => void) => () => void
|
|
80
|
+
refresh: () => Promise<void>
|
|
81
|
+
execute: () => Promise<void>
|
|
82
|
+
abort: () => void
|
|
83
|
+
isLoading: () => boolean
|
|
84
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactive fullscreen controller
|
|
3
|
+
*/
|
|
4
|
+
export declare function useFullscreen(target?: Element | (() => Element | null) | null, options?: FullscreenOptions): FullscreenRef;
|
|
5
|
+
/**
|
|
6
|
+
* Simple fullscreen toggle for document
|
|
7
|
+
*/
|
|
8
|
+
export declare function toggleFullscreen(): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Check if currently in fullscreen mode
|
|
11
|
+
*/
|
|
12
|
+
export declare function isInFullscreen(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* useFullscreen - Reactive Fullscreen API wrapper
|
|
15
|
+
*
|
|
16
|
+
* Control fullscreen mode for elements or the entire document.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Document fullscreen
|
|
21
|
+
* const { isFullscreen, toggle, enter, exit } = useFullscreen()
|
|
22
|
+
*
|
|
23
|
+
* // Element fullscreen
|
|
24
|
+
* const { isFullscreen, toggle } = useFullscreen(videoElement)
|
|
25
|
+
*
|
|
26
|
+
* // With keyboard shortcut
|
|
27
|
+
* useHotkey('f', () => toggle())
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare interface FullscreenState {
|
|
31
|
+
isFullscreen: boolean
|
|
32
|
+
isSupported: boolean
|
|
33
|
+
element: Element | null
|
|
34
|
+
}
|
|
35
|
+
export declare interface FullscreenOptions {
|
|
36
|
+
navigationUI?: 'auto' | 'hide' | 'show'
|
|
37
|
+
autoExit?: boolean
|
|
38
|
+
}
|
|
39
|
+
export declare interface FullscreenRef {
|
|
40
|
+
get: () => FullscreenState
|
|
41
|
+
subscribe: (fn: (state: FullscreenState) => void) => () => void
|
|
42
|
+
isFullscreen: () => boolean
|
|
43
|
+
isSupported: () => boolean
|
|
44
|
+
enter: () => Promise<void>
|
|
45
|
+
exit: () => Promise<void>
|
|
46
|
+
toggle: () => Promise<void>
|
|
47
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get current position as a Promise
|
|
3
|
+
*/
|
|
4
|
+
export declare function getCurrentPosition(options?: PositionOptions): Promise<GeolocationPosition>;
|
|
5
|
+
/**
|
|
6
|
+
* Calculate distance between two coordinates (Haversine formula)
|
|
7
|
+
* @returns Distance in meters
|
|
8
|
+
*/
|
|
9
|
+
export declare function calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Reactive geolocation composable with watch support
|
|
12
|
+
*/
|
|
13
|
+
export declare function useGeolocation(options?: GeolocationOptions): GeolocationRef;
|
|
14
|
+
/**
|
|
15
|
+
* Watch position changes (alias for useGeolocation with watch)
|
|
16
|
+
*/
|
|
17
|
+
export declare function useGeolocationWatch(options?: GeolocationOptions): GeolocationRef;
|
|
18
|
+
/**
|
|
19
|
+
* useGeolocation - Reactive Geolocation API wrapper
|
|
20
|
+
*
|
|
21
|
+
* Provides easy access to the browser's Geolocation API with reactive state.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const geo = useGeolocation()
|
|
26
|
+
* geo.subscribe(state => {
|
|
27
|
+
* console.log(state.coords?.latitude, state.coords?.longitude)
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* // Or get current position once
|
|
31
|
+
* const position = await getCurrentPosition()
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare interface GeolocationCoords {
|
|
35
|
+
latitude: number
|
|
36
|
+
longitude: number
|
|
37
|
+
altitude: number | null
|
|
38
|
+
accuracy: number
|
|
39
|
+
altitudeAccuracy: number | null
|
|
40
|
+
heading: number | null
|
|
41
|
+
speed: number | null
|
|
42
|
+
}
|
|
43
|
+
export declare interface GeolocationState {
|
|
44
|
+
coords: GeolocationCoords | null
|
|
45
|
+
timestamp: number | null
|
|
46
|
+
error: GeolocationPositionError | null
|
|
47
|
+
loading: boolean
|
|
48
|
+
supported: boolean
|
|
49
|
+
}
|
|
50
|
+
export declare interface GeolocationOptions {
|
|
51
|
+
enableHighAccuracy?: boolean
|
|
52
|
+
timeout?: number
|
|
53
|
+
maximumAge?: number
|
|
54
|
+
immediate?: boolean
|
|
55
|
+
}
|
|
56
|
+
export declare interface GeolocationRef {
|
|
57
|
+
get: () => GeolocationState
|
|
58
|
+
subscribe: (fn: (state: GeolocationState) => void) => () => void
|
|
59
|
+
refresh: () => void
|
|
60
|
+
pause: () => void
|
|
61
|
+
resume: () => void
|
|
62
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a reactive idle detector
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const idle = useIdle({
|
|
7
|
+
* timeout: 30000, // 30 seconds
|
|
8
|
+
* onIdle: () => console.log('User is idle'),
|
|
9
|
+
* onActive: () => console.log('User is active'),
|
|
10
|
+
* })
|
|
11
|
+
*
|
|
12
|
+
* // Subscribe to idle state changes
|
|
13
|
+
* idle.subscribe((state) => {
|
|
14
|
+
* console.log('Is idle:', state.isIdle)
|
|
15
|
+
* console.log('Idle for:', state.idleTime, 'ms')
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* // Manually reset the idle timer
|
|
19
|
+
* idle.reset()
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function useIdle(options?: IdleOptions): IdleRef;
|
|
23
|
+
/**
|
|
24
|
+
* Simple boolean idle state
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const isIdle = useIdleState(30000) // 30 seconds
|
|
29
|
+
*
|
|
30
|
+
* isIdle.subscribe((idle) => {
|
|
31
|
+
* console.log('User idle:', idle)
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function useIdleState(timeout?: any): void;
|
|
36
|
+
/**
|
|
37
|
+
* Track user's last active timestamp
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const lastActive = useLastActive()
|
|
42
|
+
*
|
|
43
|
+
* lastActive.subscribe((timestamp) => {
|
|
44
|
+
* console.log('Last active:', new Date(timestamp))
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function useLastActive(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Auto-logout after idle timeout
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* useAutoLogout(5 * 60 * 1000, () => {
|
|
55
|
+
* // Logout user after 5 minutes of inactivity
|
|
56
|
+
* window.location.href = '/logout'
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function useAutoLogout(timeout: number, onLogout: () => void, options?: { warningTime?: number, onWarning?: (remainingTime: number) => void }): void;
|
|
61
|
+
/**
|
|
62
|
+
* Idle Detection Composables
|
|
63
|
+
*
|
|
64
|
+
* Reactive utilities for detecting user idle state and activity.
|
|
65
|
+
*/
|
|
66
|
+
export declare interface IdleState {
|
|
67
|
+
isIdle: boolean
|
|
68
|
+
lastActive: number
|
|
69
|
+
idleTime: number
|
|
70
|
+
}
|
|
71
|
+
export declare interface IdleOptions {
|
|
72
|
+
timeout?: number
|
|
73
|
+
events?: string[]
|
|
74
|
+
listenTo?: EventTarget
|
|
75
|
+
initialState?: boolean
|
|
76
|
+
onIdle?: () => void
|
|
77
|
+
onActive?: () => void
|
|
78
|
+
}
|
|
79
|
+
export declare interface IdleRef {
|
|
80
|
+
get: () => IdleState
|
|
81
|
+
subscribe: (fn: (state: IdleState) => void) => () => void
|
|
82
|
+
reset: () => void
|
|
83
|
+
isIdle: () => boolean
|
|
84
|
+
}
|