@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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CustomDirective } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Handler for @stxRouter directive
|
|
4
|
+
* Injects the SPA router script into the page
|
|
5
|
+
*/
|
|
6
|
+
export declare function stxRouterHandler(_content: string, params: string[], _context: Record<string, unknown>, _filePath: string): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Custom directive for @stxRouter
|
|
9
|
+
*/
|
|
10
|
+
export declare const stxRouterDirective: CustomDirective;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare function initRouter(options?: RouterOptions): STXRouter;
|
|
2
|
+
export declare function getRouter(): STXRouter | null;
|
|
3
|
+
/**
|
|
4
|
+
* STX Client-Side Router
|
|
5
|
+
*
|
|
6
|
+
* Lightweight SPA router for STX applications.
|
|
7
|
+
* Intercepts navigation, fetches pages via AJAX, and swaps content.
|
|
8
|
+
*/
|
|
9
|
+
export declare interface RouterOptions {
|
|
10
|
+
container?: string
|
|
11
|
+
linkSelector?: string
|
|
12
|
+
loadingClass?: string
|
|
13
|
+
viewTransitions?: boolean
|
|
14
|
+
cache?: boolean
|
|
15
|
+
scrollToTop?: boolean
|
|
16
|
+
onBeforeNavigate?: (url: string) => boolean | void
|
|
17
|
+
onAfterNavigate?: (url: string) => void
|
|
18
|
+
onError?: (error: Error, url: string) => void
|
|
19
|
+
}
|
|
20
|
+
declare class STXRouter {
|
|
21
|
+
private options: Required<RouterOptions>;
|
|
22
|
+
private cache: Map<string, CacheEntry>;
|
|
23
|
+
private isNavigating: any;
|
|
24
|
+
private currentUrl: string;
|
|
25
|
+
constructor(options?: RouterOptions);
|
|
26
|
+
init(): void;
|
|
27
|
+
navigate(url: string, pushState?: any): Promise<void>;
|
|
28
|
+
prefetch(url: string): Promise<void>;
|
|
29
|
+
clearCache(): void;
|
|
30
|
+
private handleClick(event: MouseEvent): void;
|
|
31
|
+
private handlePopState(event: PopStateEvent): void;
|
|
32
|
+
private fetchPage(url: string): Promise<{ html: string; title: string } | null>;
|
|
33
|
+
private swapContent(content: { html: string; title: string }): Promise<void>;
|
|
34
|
+
private cacheCurrentPage(): void;
|
|
35
|
+
}
|
|
36
|
+
export { STXRouter };
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ParsedEvent } from './events';
|
|
2
|
+
/**
|
|
3
|
+
* Transform a <script client> block's content into a fully processed <script> tag.
|
|
4
|
+
*
|
|
5
|
+
* - Auto-imports from 'stx' and '@stacksjs/browser' (no explicit imports needed)
|
|
6
|
+
* - Resolves `import { x } from '@stores'` to runtime store access
|
|
7
|
+
* - Appends event binding code inside the script scope
|
|
8
|
+
* - Wraps everything in a scoped IIFE
|
|
9
|
+
*
|
|
10
|
+
* @param scriptContent - The raw content inside <script client>...</script>
|
|
11
|
+
* @param options - Event bindings and other processing options
|
|
12
|
+
* @returns A complete `<script>...</script>` tag ready for browser injection
|
|
13
|
+
*/
|
|
14
|
+
export declare function processClientScript(scriptContent: string, options?: ClientScriptOptions): string;
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// Types
|
|
17
|
+
// =============================================================================
|
|
18
|
+
export declare interface ClientScriptOptions {
|
|
19
|
+
eventBindings?: ParsedEvent[]
|
|
20
|
+
autoImports?: boolean
|
|
21
|
+
attrs?: string
|
|
22
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate the HMR client script for browser
|
|
3
|
+
*/
|
|
4
|
+
export declare function generateHMRClientScript(wsPort: number): string;
|
|
5
|
+
/**
|
|
6
|
+
* Generate component wrapper code for HMR support
|
|
7
|
+
*/
|
|
8
|
+
export declare function wrapComponentForHMR(componentId: string, componentName: string, html: string, script: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Get or create global HMR handler
|
|
11
|
+
*/
|
|
12
|
+
export declare function getHMRHandler(config?: ComponentHMRConfig): ComponentHMRHandler;
|
|
13
|
+
/**
|
|
14
|
+
* Reset global HMR handler
|
|
15
|
+
*/
|
|
16
|
+
export declare function resetHMRHandler(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Component HMR (Hot Module Replacement)
|
|
19
|
+
*
|
|
20
|
+
* Provides React Fast Refresh / Vue HMR-style hot reloading for stx components.
|
|
21
|
+
* Updates component code without losing component state or unmounting.
|
|
22
|
+
*
|
|
23
|
+
* ## Features
|
|
24
|
+
*
|
|
25
|
+
* - State preservation during component updates
|
|
26
|
+
* - Selective component re-rendering
|
|
27
|
+
* - Error recovery with state restoration
|
|
28
|
+
* - Integration with stx reactivity system
|
|
29
|
+
* - Support for nested component updates
|
|
30
|
+
*
|
|
31
|
+
* ## Usage
|
|
32
|
+
*
|
|
33
|
+
* Component HMR is automatically enabled in development mode. No configuration needed.
|
|
34
|
+
*
|
|
35
|
+
* @module component-hmr
|
|
36
|
+
*/
|
|
37
|
+
// =============================================================================
|
|
38
|
+
// Types
|
|
39
|
+
// =============================================================================
|
|
40
|
+
export declare interface ComponentState {
|
|
41
|
+
refs: Record<string, unknown>
|
|
42
|
+
reactiveObjects: Record<string, unknown>
|
|
43
|
+
custom: Record<string, unknown>
|
|
44
|
+
timestamp: number
|
|
45
|
+
}
|
|
46
|
+
export declare interface ComponentInstance {
|
|
47
|
+
id: string
|
|
48
|
+
name: string
|
|
49
|
+
element: HTMLElement | null
|
|
50
|
+
state: ComponentState
|
|
51
|
+
isMounted: boolean
|
|
52
|
+
props: Record<string, unknown>
|
|
53
|
+
children: Map<string, ComponentInstance>
|
|
54
|
+
setup?: () => void | Promise<void>
|
|
55
|
+
render?: () => string
|
|
56
|
+
cleanup?: () => void
|
|
57
|
+
}
|
|
58
|
+
export declare interface HMRUpdate {
|
|
59
|
+
file: string
|
|
60
|
+
code: string
|
|
61
|
+
type: 'full' | 'partial' | 'style'
|
|
62
|
+
timestamp: number
|
|
63
|
+
}
|
|
64
|
+
export declare interface ComponentHMRConfig {
|
|
65
|
+
preserveState?: boolean
|
|
66
|
+
maxStateAge?: number
|
|
67
|
+
errorRecovery?: boolean
|
|
68
|
+
verbose?: boolean
|
|
69
|
+
serializeState?: (instance: ComponentInstance) => ComponentState
|
|
70
|
+
deserializeState?: (state: ComponentState, instance: ComponentInstance) => void
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Global registry of component instances for HMR
|
|
74
|
+
*/
|
|
75
|
+
declare class ComponentRegistry {
|
|
76
|
+
private instances: Map<string, ComponentInstance>;
|
|
77
|
+
private componentsByFile: Map<string, Set<string>>;
|
|
78
|
+
private stateSnapshots: Map<string, ComponentState>;
|
|
79
|
+
private config: Required<ComponentHMRConfig>;
|
|
80
|
+
constructor(config?: ComponentHMRConfig);
|
|
81
|
+
register(instance: ComponentInstance): void;
|
|
82
|
+
unregister(instanceId: string): void;
|
|
83
|
+
getInstancesByFile(file: string): ComponentInstance[];
|
|
84
|
+
getInstance(id: string): ComponentInstance | undefined;
|
|
85
|
+
captureState(instanceId: string): void;
|
|
86
|
+
restoreState(instanceId: string): boolean;
|
|
87
|
+
private defaultSerializeState(instance: ComponentInstance): ComponentState;
|
|
88
|
+
private defaultDeserializeState(state: ComponentState, instance: ComponentInstance): void;
|
|
89
|
+
getAllInstances(): ComponentInstance[];
|
|
90
|
+
clear(): void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* HMR Handler - processes component updates
|
|
94
|
+
*/
|
|
95
|
+
export declare class ComponentHMRHandler {
|
|
96
|
+
private registry: ComponentRegistry;
|
|
97
|
+
private config: Required<ComponentHMRConfig>;
|
|
98
|
+
private pendingUpdates: Map<string, HMRUpdate>;
|
|
99
|
+
private updateQueue: Promise<void>;
|
|
100
|
+
constructor(config?: ComponentHMRConfig);
|
|
101
|
+
register(instance: ComponentInstance): void;
|
|
102
|
+
unregister(instanceId: string): void;
|
|
103
|
+
handleUpdate(update: HMRUpdate): Promise<void>;
|
|
104
|
+
private processUpdate(update: HMRUpdate): Promise<void>;
|
|
105
|
+
private updateInstance(instance: ComponentInstance, update: HMRUpdate): Promise<void>;
|
|
106
|
+
private updateComponent(instance: ComponentInstance, update: HMRUpdate): Promise<void>;
|
|
107
|
+
private updateStyles(instance: ComponentInstance, update: HMRUpdate): Promise<void>;
|
|
108
|
+
private parseComponentCode(code: string): { html: string; script: string; style: string };
|
|
109
|
+
private executeScript(script: string, instance: ComponentInstance): Promise<void>;
|
|
110
|
+
private reinitializeInteractivity(instance: ComponentInstance): void;
|
|
111
|
+
getRegistry(): ComponentRegistry;
|
|
112
|
+
refresh(componentName: string): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
export default {
|
|
115
|
+
ComponentHMRHandler,
|
|
116
|
+
getHMRHandler,
|
|
117
|
+
resetHMRHandler,
|
|
118
|
+
generateHMRClientScript,
|
|
119
|
+
wrapComponentForHMR,
|
|
120
|
+
};
|
package/dist/components.d.ts
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
import type { CustomDirective } from './types';
|
|
1
|
+
import type { ComponentPropsSchema, CustomDirective } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Validate component props against a schema
|
|
4
|
+
*
|
|
5
|
+
* @param props - The props to validate
|
|
6
|
+
* @param schema - The props schema
|
|
7
|
+
* @param componentName - Component name for error messages
|
|
8
|
+
* @returns Array of validation errors (empty if valid)
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const schema: ComponentPropsSchema = {
|
|
13
|
+
* title: { type: 'string', required: true },
|
|
14
|
+
* count: { type: 'number', default: 0 }
|
|
15
|
+
* }
|
|
16
|
+
* const errors = validateComponentProps({ title: 'Hello' }, schema, 'MyComponent')
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateComponentProps(props: Record<string, any>, schema: ComponentPropsSchema, componentName: string): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Apply default values to props from schema
|
|
22
|
+
*/
|
|
23
|
+
export declare function applyPropDefaults(props: Record<string, any>, schema: ComponentPropsSchema): Record<string, any>;
|
|
2
24
|
/**
|
|
3
25
|
* Register component directives
|
|
4
26
|
*/
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
export {
|
|
2
|
+
useStorage,
|
|
3
|
+
useLocalStorage,
|
|
4
|
+
useSessionStorage,
|
|
5
|
+
clearStorage,
|
|
6
|
+
getStorageKeys,
|
|
7
|
+
getStorageSize,
|
|
8
|
+
type StorageType,
|
|
9
|
+
type UseStorageOptions,
|
|
10
|
+
type StorageRef,
|
|
11
|
+
} from './use-storage';
|
|
12
|
+
export {
|
|
13
|
+
useCookie,
|
|
14
|
+
useCookies,
|
|
15
|
+
getCookie,
|
|
16
|
+
setCookie,
|
|
17
|
+
removeCookie,
|
|
18
|
+
parseCookies,
|
|
19
|
+
clearCookies,
|
|
20
|
+
type CookieOptions,
|
|
21
|
+
type CookieRef,
|
|
22
|
+
} from './use-cookie';
|
|
23
|
+
export {
|
|
24
|
+
useClipboard,
|
|
25
|
+
copyToClipboard,
|
|
26
|
+
type ClipboardRef,
|
|
27
|
+
} from './use-clipboard';
|
|
28
|
+
export {
|
|
29
|
+
useMediaQuery,
|
|
30
|
+
usePreferredDark,
|
|
31
|
+
usePreferredLight,
|
|
32
|
+
usePreferredReducedMotion,
|
|
33
|
+
usePreferredContrast,
|
|
34
|
+
useBreakpoint,
|
|
35
|
+
useIsMobile,
|
|
36
|
+
useIsTablet,
|
|
37
|
+
useIsDesktop,
|
|
38
|
+
breakpoints,
|
|
39
|
+
type MediaQueryRef,
|
|
40
|
+
} from './use-media-query';
|
|
41
|
+
export {
|
|
42
|
+
useNetwork,
|
|
43
|
+
useOnline,
|
|
44
|
+
type NetworkState,
|
|
45
|
+
type NetworkRef,
|
|
46
|
+
} from './use-network';
|
|
47
|
+
export {
|
|
48
|
+
useWindowSize,
|
|
49
|
+
useScroll,
|
|
50
|
+
useVisibility,
|
|
51
|
+
useTitle,
|
|
52
|
+
useFavicon,
|
|
53
|
+
type WindowSize,
|
|
54
|
+
type ScrollPosition,
|
|
55
|
+
type WindowSizeRef,
|
|
56
|
+
type ScrollRef,
|
|
57
|
+
type VisibilityRef,
|
|
58
|
+
} from './use-window';
|
|
59
|
+
export {
|
|
60
|
+
useGeolocation,
|
|
61
|
+
useGeolocationWatch,
|
|
62
|
+
getCurrentPosition,
|
|
63
|
+
calculateDistance,
|
|
64
|
+
type GeolocationCoords,
|
|
65
|
+
type GeolocationState,
|
|
66
|
+
type GeolocationOptions,
|
|
67
|
+
type GeolocationRef,
|
|
68
|
+
} from './use-geolocation';
|
|
69
|
+
export {
|
|
70
|
+
useMouse,
|
|
71
|
+
useMouseInElement,
|
|
72
|
+
usePointer,
|
|
73
|
+
type MouseState,
|
|
74
|
+
type MouseOptions,
|
|
75
|
+
type MouseRef,
|
|
76
|
+
type ElementMouseState,
|
|
77
|
+
type ElementMouseRef,
|
|
78
|
+
} from './use-mouse';
|
|
79
|
+
export {
|
|
80
|
+
useKeyboard,
|
|
81
|
+
useHotkey,
|
|
82
|
+
useKeyPressed,
|
|
83
|
+
useKeySequence,
|
|
84
|
+
shortcuts,
|
|
85
|
+
type KeyboardState,
|
|
86
|
+
type KeyboardOptions,
|
|
87
|
+
type KeyboardRef,
|
|
88
|
+
type HotkeyOptions,
|
|
89
|
+
} from './use-keyboard';
|
|
90
|
+
export {
|
|
91
|
+
useIntersectionObserver,
|
|
92
|
+
useElementVisibility,
|
|
93
|
+
useLazyLoad,
|
|
94
|
+
useInfiniteScroll,
|
|
95
|
+
useIntersectionObserverMultiple,
|
|
96
|
+
type IntersectionObserverOptions,
|
|
97
|
+
type IntersectionState,
|
|
98
|
+
type IntersectionObserverRef,
|
|
99
|
+
} from './use-intersection-observer';
|
|
100
|
+
export {
|
|
101
|
+
useFetch,
|
|
102
|
+
useAsyncData,
|
|
103
|
+
usePost,
|
|
104
|
+
clearFetchCache,
|
|
105
|
+
prefetch,
|
|
106
|
+
type FetchOptions,
|
|
107
|
+
type FetchState,
|
|
108
|
+
type FetchRef,
|
|
109
|
+
} from './use-fetch';
|
|
110
|
+
export {
|
|
111
|
+
useFullscreen,
|
|
112
|
+
toggleFullscreen,
|
|
113
|
+
isInFullscreen,
|
|
114
|
+
type FullscreenState,
|
|
115
|
+
type FullscreenOptions,
|
|
116
|
+
type FullscreenRef,
|
|
117
|
+
} from './use-fullscreen';
|
|
118
|
+
export {
|
|
119
|
+
useNotification,
|
|
120
|
+
notify,
|
|
121
|
+
canNotify,
|
|
122
|
+
requestNotificationPermission,
|
|
123
|
+
notifications,
|
|
124
|
+
type NotificationPermission,
|
|
125
|
+
type NotificationState,
|
|
126
|
+
type NotificationOptions,
|
|
127
|
+
type NotificationRef,
|
|
128
|
+
} from './use-notification';
|
|
129
|
+
export {
|
|
130
|
+
useShare,
|
|
131
|
+
share,
|
|
132
|
+
shareURL,
|
|
133
|
+
shareText,
|
|
134
|
+
shareFiles,
|
|
135
|
+
shareCurrentPage,
|
|
136
|
+
shareWithFallback,
|
|
137
|
+
createShareableFile,
|
|
138
|
+
type ShareData,
|
|
139
|
+
type ShareResult,
|
|
140
|
+
type ShareRef,
|
|
141
|
+
} from './use-share';
|
|
142
|
+
export {
|
|
143
|
+
usePermission,
|
|
144
|
+
usePermissions,
|
|
145
|
+
isPermissionGranted,
|
|
146
|
+
hasCameraPermission,
|
|
147
|
+
hasMicrophonePermission,
|
|
148
|
+
hasGeolocationPermission,
|
|
149
|
+
hasNotificationPermission,
|
|
150
|
+
requestMediaPermissions,
|
|
151
|
+
permissionGroups,
|
|
152
|
+
type PermissionName,
|
|
153
|
+
type PermissionState,
|
|
154
|
+
type PermissionStatus,
|
|
155
|
+
type PermissionRef,
|
|
156
|
+
type MultiPermissionRef,
|
|
157
|
+
} from './use-permissions';
|
|
158
|
+
export {
|
|
159
|
+
useResizeObserver,
|
|
160
|
+
useResizeObserverMultiple,
|
|
161
|
+
useElementSize,
|
|
162
|
+
hasResizeObserver,
|
|
163
|
+
type ResizeObserverSize,
|
|
164
|
+
type ResizeObserverState,
|
|
165
|
+
type ResizeObserverOptions,
|
|
166
|
+
type ResizeObserverRef,
|
|
167
|
+
} from './use-resize-observer';
|
|
168
|
+
export {
|
|
169
|
+
useBattery,
|
|
170
|
+
getBatteryLevel,
|
|
171
|
+
isCharging,
|
|
172
|
+
hasBattery,
|
|
173
|
+
type BatteryState,
|
|
174
|
+
type BatteryRef,
|
|
175
|
+
} from './use-battery';
|
|
176
|
+
export {
|
|
177
|
+
useSpeechRecognition,
|
|
178
|
+
useSpeechSynthesis,
|
|
179
|
+
isSpeechRecognitionSupported,
|
|
180
|
+
isSpeechSynthesisSupported,
|
|
181
|
+
speak,
|
|
182
|
+
stopSpeaking,
|
|
183
|
+
getVoices,
|
|
184
|
+
type SpeechRecognitionOptions,
|
|
185
|
+
type SpeechRecognitionState,
|
|
186
|
+
type SpeechRecognitionResult,
|
|
187
|
+
type SpeechRecognitionRef,
|
|
188
|
+
type SpeechSynthesisOptions,
|
|
189
|
+
type SpeechSynthesisState,
|
|
190
|
+
type SpeechSynthesisRef,
|
|
191
|
+
} from './use-speech';
|
|
192
|
+
export {
|
|
193
|
+
useBroadcastChannel,
|
|
194
|
+
broadcast,
|
|
195
|
+
isBroadcastChannelSupported,
|
|
196
|
+
type BroadcastChannelState,
|
|
197
|
+
type BroadcastChannelOptions,
|
|
198
|
+
type BroadcastChannelRef,
|
|
199
|
+
} from './use-broadcast-channel';
|
|
200
|
+
export {
|
|
201
|
+
useWebSocket,
|
|
202
|
+
isWebSocketSupported,
|
|
203
|
+
type WebSocketStatus,
|
|
204
|
+
type WebSocketState,
|
|
205
|
+
type WebSocketOptions,
|
|
206
|
+
type WebSocketRef,
|
|
207
|
+
} from './use-websocket';
|
|
208
|
+
export {
|
|
209
|
+
useDeviceOrientation,
|
|
210
|
+
useDeviceMotion,
|
|
211
|
+
useParallax,
|
|
212
|
+
isDeviceOrientationSupported,
|
|
213
|
+
isDeviceMotionSupported,
|
|
214
|
+
requestOrientationPermission,
|
|
215
|
+
requestMotionPermission,
|
|
216
|
+
type DeviceOrientationState,
|
|
217
|
+
type DeviceMotionState,
|
|
218
|
+
type DeviceOrientationRef,
|
|
219
|
+
type DeviceMotionRef,
|
|
220
|
+
} from './use-device-orientation';
|
|
221
|
+
export {
|
|
222
|
+
useMutationObserver,
|
|
223
|
+
useAttributeObserver,
|
|
224
|
+
useChildListObserver,
|
|
225
|
+
useTextObserver,
|
|
226
|
+
isMutationObserverSupported,
|
|
227
|
+
type MutationObserverState,
|
|
228
|
+
type MutationObserverOptions,
|
|
229
|
+
type MutationObserverRef,
|
|
230
|
+
} from './use-mutation-observer';
|
|
231
|
+
export {
|
|
232
|
+
useEventSource,
|
|
233
|
+
useSSE,
|
|
234
|
+
isEventSourceSupported,
|
|
235
|
+
type EventSourceStatus,
|
|
236
|
+
type EventSourceState,
|
|
237
|
+
type EventSourceOptions,
|
|
238
|
+
type EventSourceRef,
|
|
239
|
+
} from './use-event-source';
|
|
240
|
+
export {
|
|
241
|
+
useIdle,
|
|
242
|
+
useIdleState,
|
|
243
|
+
useLastActive,
|
|
244
|
+
useAutoLogout,
|
|
245
|
+
type IdleState,
|
|
246
|
+
type IdleOptions,
|
|
247
|
+
type IdleRef,
|
|
248
|
+
} from './use-idle';
|
|
249
|
+
export {
|
|
250
|
+
useTextSelection,
|
|
251
|
+
useElementTextSelection,
|
|
252
|
+
useSelectionPopup,
|
|
253
|
+
useCopySelection,
|
|
254
|
+
type TextSelectionState,
|
|
255
|
+
type TextSelectionOptions,
|
|
256
|
+
type TextSelectionRef,
|
|
257
|
+
} from './use-text-selection';
|
|
258
|
+
export {
|
|
259
|
+
useWakeLock,
|
|
260
|
+
useAutoWakeLock,
|
|
261
|
+
useConditionalWakeLock,
|
|
262
|
+
isWakeLockSupported,
|
|
263
|
+
type WakeLockState,
|
|
264
|
+
type WakeLockRef,
|
|
265
|
+
} from './use-wake-lock';
|
|
266
|
+
export {
|
|
267
|
+
useEyeDropper,
|
|
268
|
+
useColorHistory,
|
|
269
|
+
pickColor,
|
|
270
|
+
hexToRgb,
|
|
271
|
+
hexToHsl,
|
|
272
|
+
isEyeDropperSupported,
|
|
273
|
+
type EyeDropperState,
|
|
274
|
+
type EyeDropperResult,
|
|
275
|
+
type EyeDropperOptions,
|
|
276
|
+
type EyeDropperRef,
|
|
277
|
+
} from './use-eye-dropper';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monitor battery status
|
|
3
|
+
*/
|
|
4
|
+
export declare function useBattery(): BatteryRef;
|
|
5
|
+
/**
|
|
6
|
+
* Get battery level as percentage
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBatteryLevel(): Promise<number | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Check if device is charging
|
|
11
|
+
*/
|
|
12
|
+
export declare function isCharging(): Promise<boolean | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Check if Battery API is available
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasBattery(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* useBattery - Battery Status API wrapper
|
|
19
|
+
*
|
|
20
|
+
* Monitor device battery status reactively.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const battery = useBattery()
|
|
25
|
+
* battery.subscribe(state => {
|
|
26
|
+
* console.log('Battery level:', state.level * 100 + '%')
|
|
27
|
+
* console.log('Charging:', state.charging)
|
|
28
|
+
* console.log('Time to full:', state.chargingTime)
|
|
29
|
+
* console.log('Time to empty:', state.dischargingTime)
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare interface BatteryState {
|
|
34
|
+
charging: boolean
|
|
35
|
+
chargingTime: number
|
|
36
|
+
dischargingTime: number
|
|
37
|
+
level: number
|
|
38
|
+
}
|
|
39
|
+
export declare interface BatteryRef {
|
|
40
|
+
get: () => BatteryState
|
|
41
|
+
subscribe: (fn: (state: BatteryState) => void) => () => void
|
|
42
|
+
isSupported: () => boolean
|
|
43
|
+
getPercentage: () => number
|
|
44
|
+
isLow: (threshold?: number) => boolean
|
|
45
|
+
isCritical: () => boolean
|
|
46
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if BroadcastChannel is supported
|
|
3
|
+
*/
|
|
4
|
+
export declare function isBroadcastChannelSupported(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Create a reactive BroadcastChannel for cross-tab communication
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const channel = useBroadcastChannel('my-channel')
|
|
11
|
+
*
|
|
12
|
+
* // Subscribe to state changes
|
|
13
|
+
* channel.subscribe((state) => {
|
|
14
|
+
* console.log('Last message:', state.lastMessage)
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* // Post a message to all tabs
|
|
18
|
+
* channel.post({ type: 'sync', data: { user: 'John' } })
|
|
19
|
+
*
|
|
20
|
+
* // Close when done
|
|
21
|
+
* channel.close()
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useBroadcastChannel<T = unknown>(channelName: string, options?: BroadcastChannelOptions): BroadcastChannelRef<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Simple one-shot broadcast to all tabs
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* broadcast('app-events', { type: 'logout' })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function broadcast<T = unknown>(channelName: string, message: T): void;
|
|
34
|
+
/**
|
|
35
|
+
* Broadcast Channel Composables
|
|
36
|
+
*
|
|
37
|
+
* Reactive utilities for cross-tab/window communication using the BroadcastChannel API.
|
|
38
|
+
*/
|
|
39
|
+
export declare interface BroadcastChannelState<T = unknown> {
|
|
40
|
+
isSupported: boolean
|
|
41
|
+
isClosed: boolean
|
|
42
|
+
channel: BroadcastChannel | null
|
|
43
|
+
lastMessage: T | null
|
|
44
|
+
error: Error | null
|
|
45
|
+
}
|
|
46
|
+
export declare interface BroadcastChannelOptions {
|
|
47
|
+
onMessage?: (event: MessageEvent) => void
|
|
48
|
+
onError?: (event: MessageEvent) => void
|
|
49
|
+
}
|
|
50
|
+
export declare interface BroadcastChannelRef<T = unknown> {
|
|
51
|
+
get: () => BroadcastChannelState<T>
|
|
52
|
+
subscribe: (fn: (state: BroadcastChannelState<T>) => void) => () => void
|
|
53
|
+
post: (message: T) => void
|
|
54
|
+
close: () => void
|
|
55
|
+
isSupported: () => boolean
|
|
56
|
+
}
|
|
57
|
+
declare type BroadcastEventType = 'message' | 'error'
|
|
58
|
+
declare type BroadcastEventCallback = (data: MessageEvent) => void
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a clipboard helper
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const clipboard = useClipboard()
|
|
7
|
+
*
|
|
8
|
+
* // Copy text
|
|
9
|
+
* await clipboard.copy('Hello World')
|
|
10
|
+
*
|
|
11
|
+
* // Check if copy was successful
|
|
12
|
+
* if (clipboard.copied) {
|
|
13
|
+
* console.log('Copied!')
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function useClipboard(options?: { timeout?: number }): ClipboardRef;
|
|
18
|
+
/**
|
|
19
|
+
* Copy text to clipboard (one-shot helper)
|
|
20
|
+
*/
|
|
21
|
+
export declare function copyToClipboard(text: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* useClipboard - Reactive clipboard composable
|
|
24
|
+
*
|
|
25
|
+
* Provides easy access to the Clipboard API with fallbacks.
|
|
26
|
+
*/
|
|
27
|
+
export declare interface ClipboardRef {
|
|
28
|
+
text: string
|
|
29
|
+
isSupported: boolean
|
|
30
|
+
copied: boolean
|
|
31
|
+
copy: (text: string) => Promise<boolean>
|
|
32
|
+
read: () => Promise<string>
|
|
33
|
+
subscribe: (callback: (text: string) => void) => () => void
|
|
34
|
+
}
|