@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,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate the hot reload client script to inject into HTML
|
|
3
|
+
*/
|
|
4
|
+
export declare function generateHotReloadScript(wsPort: number, options?: HotReloadOptions): string;
|
|
5
|
+
/**
|
|
6
|
+
* Inject hot reload script into HTML content
|
|
7
|
+
*/
|
|
8
|
+
export declare function injectHotReload(html: string, wsPort: number, options?: HotReloadOptions): string;
|
|
9
|
+
/**
|
|
10
|
+
* Determine if a file change should trigger a CSS-only update
|
|
11
|
+
*/
|
|
12
|
+
export declare function isCssOnlyChange(filename: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Determine if a file change should trigger a reload
|
|
15
|
+
*/
|
|
16
|
+
export declare function shouldReloadOnChange(filename: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Determine if a file should be ignored
|
|
19
|
+
*/
|
|
20
|
+
export declare function shouldIgnoreFile(filename: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Get or create the global HMR server instance
|
|
23
|
+
*/
|
|
24
|
+
export declare function getHmrServer(options?: HotReloadOptions): HotReloadServer;
|
|
25
|
+
/**
|
|
26
|
+
* Stop and clear the global HMR server
|
|
27
|
+
*/
|
|
28
|
+
export declare function stopHmrServer(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Hot Reload Module
|
|
31
|
+
*
|
|
32
|
+
* Provides WebSocket-based hot module reload (HMR) for the stx dev server.
|
|
33
|
+
* When template files change, connected browsers automatically refresh.
|
|
34
|
+
*
|
|
35
|
+
* ## Features
|
|
36
|
+
*
|
|
37
|
+
* - WebSocket server for real-time browser communication
|
|
38
|
+
* - Client script injection into HTML
|
|
39
|
+
* - Full page reload on template changes
|
|
40
|
+
* - CSS-only updates without full reload (when possible)
|
|
41
|
+
* - Connection status overlay
|
|
42
|
+
* - Automatic reconnection on disconnect
|
|
43
|
+
*
|
|
44
|
+
* ## Usage
|
|
45
|
+
*
|
|
46
|
+
* The hot reload is automatically enabled when using `stx dev` or `serveStxFile()`.
|
|
47
|
+
* No additional configuration needed.
|
|
48
|
+
*
|
|
49
|
+
* ## Architecture
|
|
50
|
+
*
|
|
51
|
+
* ```
|
|
52
|
+
* File System Watch → HMR Server → WebSocket → Browser Client → Reload
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
// =============================================================================
|
|
56
|
+
// Types
|
|
57
|
+
// =============================================================================
|
|
58
|
+
export declare interface HotReloadOptions {
|
|
59
|
+
wsPort?: number
|
|
60
|
+
showOverlay?: boolean
|
|
61
|
+
reconnectInterval?: number
|
|
62
|
+
maxReconnectAttempts?: number
|
|
63
|
+
verbose?: boolean
|
|
64
|
+
}
|
|
65
|
+
export declare interface HotReloadMessage {
|
|
66
|
+
type: 'reload' | 'css-update' | 'connected' | 'error'
|
|
67
|
+
path?: string
|
|
68
|
+
content?: string
|
|
69
|
+
timestamp?: number
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Hot Reload Server
|
|
73
|
+
*
|
|
74
|
+
* Manages WebSocket connections and broadcasts reload messages to browsers.
|
|
75
|
+
*/
|
|
76
|
+
export declare class HotReloadServer {
|
|
77
|
+
private clients: Set<WebSocketClient>;
|
|
78
|
+
private server: ReturnType<typeof Bun.serve> | null;
|
|
79
|
+
private options: Required<HotReloadOptions>;
|
|
80
|
+
constructor(options?: HotReloadOptions);
|
|
81
|
+
start(port?: number): number;
|
|
82
|
+
stop(): void;
|
|
83
|
+
broadcast(message: HotReloadMessage): void;
|
|
84
|
+
reload(filePath?: string): void;
|
|
85
|
+
updateCss(filePath: string, content?: string): void;
|
|
86
|
+
error(message: string): void;
|
|
87
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate the unified hydration bootstrap script.
|
|
3
|
+
*
|
|
4
|
+
* This replaces the per-island inline scripts with a single runtime
|
|
5
|
+
* that reads data-strategy attributes and sets up appropriate triggers.
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateHydrationBootstrap(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Generate a component manifest script block that registers
|
|
10
|
+
* all discovered island component names with their import paths.
|
|
11
|
+
*
|
|
12
|
+
* @param islands - Map of component name to import path
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateComponentManifest(islands: Map<string, string>): string;
|
|
15
|
+
/**
|
|
16
|
+
* Extract component name from inner content of an island.
|
|
17
|
+
* Looks for PascalCase or kebab-case component tags.
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractComponentName(content: string): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Extract bound props from component content.
|
|
22
|
+
* Parses :prop="value" bindings.
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractBoundProps(content: string, context: Record<string, unknown>): Record<string, unknown>;
|
|
25
|
+
/**
|
|
26
|
+
* Unified Hydration Runtime for Islands Architecture
|
|
27
|
+
*
|
|
28
|
+
* Replaces the per-strategy inline scripts with a single runtime that handles
|
|
29
|
+
* all hydration strategies. Injected once per page when islands are present.
|
|
30
|
+
*
|
|
31
|
+
* The runtime:
|
|
32
|
+
* 1. Component registry — maps names to dynamic imports
|
|
33
|
+
* 2. hydrateIsland(element) — loads component, reads props, calls hydrate/mount
|
|
34
|
+
* 3. Strategy dispatcher — sets up triggers per data-strategy attribute
|
|
35
|
+
* 4. initIslands() — processes all .stx-island:not(.hydrated) on DOMContentLoaded
|
|
36
|
+
*
|
|
37
|
+
* @module hydration-runtime
|
|
38
|
+
*/
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Types
|
|
41
|
+
// ============================================================================
|
|
42
|
+
export declare interface IslandMeta {
|
|
43
|
+
id: string
|
|
44
|
+
component: string
|
|
45
|
+
strategy: string
|
|
46
|
+
props: Record<string, unknown>
|
|
47
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialize state for client hydration
|
|
3
|
+
* Called during server-side rendering
|
|
4
|
+
*/
|
|
5
|
+
export declare function serializeState(state: Partial<HydrationState>): string;
|
|
6
|
+
/**
|
|
7
|
+
* Generate the state injection script for server-rendered HTML
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateStateScript(state: Partial<HydrationState>): string;
|
|
10
|
+
/**
|
|
11
|
+
* Generate event bindings data attribute
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateEventBindings(events: EventBinding[]): string;
|
|
14
|
+
/**
|
|
15
|
+
* Extract and parse state from server-rendered HTML
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractState(): HydrationState | null;
|
|
18
|
+
/**
|
|
19
|
+
* Generate the hydration runtime script for embedding in HTML
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateHydrationScript(state?: Partial<HydrationState>): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get or create the hydration runtime
|
|
24
|
+
*/
|
|
25
|
+
export declare function getHydrationRuntime(options?: HydrationOptions): HydrationRuntime;
|
|
26
|
+
/**
|
|
27
|
+
* Start hydration (convenience function)
|
|
28
|
+
*/
|
|
29
|
+
export declare function hydrate(options?: HydrationOptions): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Generate hydration CSS
|
|
32
|
+
*/
|
|
33
|
+
export declare function generateHydrationCSS(): string;
|
|
34
|
+
/**
|
|
35
|
+
* STX Hydration Runtime
|
|
36
|
+
*
|
|
37
|
+
* Comprehensive client-side hydration system that bridges server-rendered
|
|
38
|
+
* HTML with client-side interactivity. Similar to React's hydrateRoot or
|
|
39
|
+
* Vue's createSSRApp.
|
|
40
|
+
*
|
|
41
|
+
* ## Features
|
|
42
|
+
*
|
|
43
|
+
* - Full page hydration with state restoration
|
|
44
|
+
* - Selective/partial hydration (islands architecture)
|
|
45
|
+
* - Event handler binding from server-rendered HTML
|
|
46
|
+
* - Integration with stx reactivity system
|
|
47
|
+
* - Seamless SPA router integration
|
|
48
|
+
* - Progressive enhancement support
|
|
49
|
+
* - Error boundaries for hydration failures
|
|
50
|
+
*
|
|
51
|
+
* ## Usage
|
|
52
|
+
*
|
|
53
|
+
* Server-side (stx template):
|
|
54
|
+
* ```html
|
|
55
|
+
* <script>
|
|
56
|
+
* const count = 0
|
|
57
|
+
* const user = { name: 'Alice' }
|
|
58
|
+
* </script>
|
|
59
|
+
*
|
|
60
|
+
* <button @click="count++">Count: {{ count }}</button>
|
|
61
|
+
* <p>Hello, {{ user.name }}</p>
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* The framework automatically:
|
|
65
|
+
* 1. Renders HTML on server
|
|
66
|
+
* 2. Serializes state and embeds in HTML
|
|
67
|
+
* 3. Client loads, hydrates, binds events
|
|
68
|
+
* 4. Page becomes interactive
|
|
69
|
+
*
|
|
70
|
+
* @module hydration
|
|
71
|
+
*/
|
|
72
|
+
// =============================================================================
|
|
73
|
+
// Types
|
|
74
|
+
// =============================================================================
|
|
75
|
+
export declare interface HydrationState {
|
|
76
|
+
refs: Record<string, unknown>
|
|
77
|
+
reactive: Record<string, unknown>
|
|
78
|
+
props: Record<string, unknown>
|
|
79
|
+
routeParams: Record<string, string>
|
|
80
|
+
stores: Record<string, unknown>
|
|
81
|
+
meta: {
|
|
82
|
+
title?: string
|
|
83
|
+
description?: string
|
|
84
|
+
url?: string
|
|
85
|
+
}
|
|
86
|
+
timestamp: number
|
|
87
|
+
checksum?: string
|
|
88
|
+
}
|
|
89
|
+
export declare interface HydrationOptions {
|
|
90
|
+
root?: string | HTMLElement
|
|
91
|
+
strict?: boolean
|
|
92
|
+
onHydrating?: () => void
|
|
93
|
+
onHydrated?: () => void
|
|
94
|
+
onError?: (error: Error) => void
|
|
95
|
+
performance?: boolean
|
|
96
|
+
timeout?: number
|
|
97
|
+
}
|
|
98
|
+
export declare interface EventBinding {
|
|
99
|
+
type: string
|
|
100
|
+
handler: string
|
|
101
|
+
modifiers?: string[]
|
|
102
|
+
preventDefault?: boolean
|
|
103
|
+
stopPropagation?: boolean
|
|
104
|
+
}
|
|
105
|
+
export declare interface ComponentHydrationConfig {
|
|
106
|
+
id: string
|
|
107
|
+
name: string
|
|
108
|
+
strategy: 'eager' | 'lazy' | 'idle' | 'visible' | 'interaction'
|
|
109
|
+
props: Record<string, unknown>
|
|
110
|
+
events: EventBinding[]
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Main hydration class
|
|
114
|
+
*/
|
|
115
|
+
export declare class HydrationRuntime {
|
|
116
|
+
private state: HydrationState | null;
|
|
117
|
+
private options: Required<HydrationOptions>;
|
|
118
|
+
private root: HTMLElement | null;
|
|
119
|
+
private isHydrated: any;
|
|
120
|
+
private pendingComponents: Map<string, ComponentHydrationConfig>;
|
|
121
|
+
private hydratedComponents: Set<string>;
|
|
122
|
+
constructor(options?: HydrationOptions);
|
|
123
|
+
hydrate(): Promise<void>;
|
|
124
|
+
private runHydration(): Promise<void>;
|
|
125
|
+
private restoreGlobalState(): void;
|
|
126
|
+
private hydrateComponents(): Promise<void>;
|
|
127
|
+
private hydrateComponent(el: HTMLElement, config: ComponentHydrationConfig): Promise<void>;
|
|
128
|
+
private restoreComponentState(el: HTMLElement, state: unknown): void;
|
|
129
|
+
private setupVisibleHydration(el: HTMLElement, config: ComponentHydrationConfig): void;
|
|
130
|
+
private setupIdleHydration(el: HTMLElement, config: ComponentHydrationConfig): void;
|
|
131
|
+
private setupInteractionHydration(el: HTMLElement, config: ComponentHydrationConfig): void;
|
|
132
|
+
private bindEventHandlers(): void;
|
|
133
|
+
private bindElementEvents(el: HTMLElement): void;
|
|
134
|
+
private bindDirectiveEvents(): void;
|
|
135
|
+
private parseModifiers(el: HTMLElement, eventType: string): string[];
|
|
136
|
+
private bindSingleEvent(el: HTMLElement, event: EventBinding): void;
|
|
137
|
+
private resolveHandler(handlerStr: string): ((e: Event) => void) | null;
|
|
138
|
+
private bindComponentEvents(el: HTMLElement): void;
|
|
139
|
+
private initializeComponentReactivity(el: HTMLElement, config: ComponentHydrationConfig): void;
|
|
140
|
+
private initializeReactiveBindings(): void;
|
|
141
|
+
private getTextNodesWithExpressions(root: HTMLElement): Array<{
|
|
142
|
+
node: Text
|
|
143
|
+
expressions: string[]
|
|
144
|
+
}>;
|
|
145
|
+
private setupTextNodeBinding(node: Text, expression: string): void;
|
|
146
|
+
private setupAttributeBinding(el: HTMLElement, attr: string, expression: string): void;
|
|
147
|
+
private setupReactiveBinding(el: HTMLElement, expression: string): void;
|
|
148
|
+
private setupRouterIntegration(): void;
|
|
149
|
+
getState(): HydrationState | null;
|
|
150
|
+
hydrateById(componentId: string): Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
export default {
|
|
153
|
+
HydrationRuntime,
|
|
154
|
+
serializeState,
|
|
155
|
+
generateStateScript,
|
|
156
|
+
generateHydrationScript,
|
|
157
|
+
generateHydrationCSS,
|
|
158
|
+
extractState,
|
|
159
|
+
getHydrationRuntime,
|
|
160
|
+
hydrate,
|
|
161
|
+
};
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,10 +1,220 @@
|
|
|
1
|
-
import type { StxOptions } from './types';
|
|
1
|
+
import type { I18nConfig, StxOptions } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Clear the translation cache
|
|
4
|
+
* @param locale - Optional locale to clear. If not provided, clears all.
|
|
5
|
+
*/
|
|
6
|
+
export declare function clearTranslationCache(locale?: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Get translation cache statistics
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTranslationCacheStats(): {
|
|
11
|
+
size: number
|
|
12
|
+
locales: string[]
|
|
13
|
+
entries: Array<{ locale: string, loadedAt: Date, keyCount: number }>
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Get the loading state for a locale
|
|
17
|
+
*
|
|
18
|
+
* @param locale - The locale to check
|
|
19
|
+
* @returns The current loading state
|
|
20
|
+
*/
|
|
21
|
+
export declare function getLoadingState(locale: string): LoadingState;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a locale is currently being loaded
|
|
24
|
+
*
|
|
25
|
+
* @param locale - The locale to check
|
|
26
|
+
* @returns True if the locale is currently loading
|
|
27
|
+
*/
|
|
28
|
+
export declare function isLoading(locale: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a locale has been loaded (cached)
|
|
31
|
+
*
|
|
32
|
+
* @param locale - The locale to check
|
|
33
|
+
* @returns True if the locale is loaded and cached
|
|
34
|
+
*/
|
|
35
|
+
export declare function isLoaded(locale: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Preload translations for specified locales in the background.
|
|
38
|
+
* This is non-blocking and returns immediately.
|
|
39
|
+
*
|
|
40
|
+
* @param config - Preload configuration
|
|
41
|
+
* @param options - stx options with i18n configuration
|
|
42
|
+
* @returns A promise that resolves when all preloading is complete
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Preload common locales in parallel
|
|
46
|
+
* preloadTranslations({
|
|
47
|
+
* locales: ['en', 'es', 'fr', 'de'],
|
|
48
|
+
* parallel: true,
|
|
49
|
+
* onLocaleLoaded: (locale) => console.log(`${locale} ready`),
|
|
50
|
+
* onComplete: () => console.log('All translations loaded')
|
|
51
|
+
* }, options)
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* // Preload with priority (user's locale first)
|
|
55
|
+
* preloadTranslations({
|
|
56
|
+
* locales: ['en', 'es', 'fr', 'de'],
|
|
57
|
+
* parallel: false,
|
|
58
|
+
* priority: { 'es': 10, 'en': 5 }, // Spanish first, then English
|
|
59
|
+
* }, options)
|
|
60
|
+
*/
|
|
61
|
+
export declare function preloadTranslations(config: PreloadConfig, options: StxOptions): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Start preloading translations in the background without blocking.
|
|
64
|
+
* This function returns immediately and loads in the background.
|
|
65
|
+
*
|
|
66
|
+
* @param config - Preload configuration
|
|
67
|
+
* @param options - stx options with i18n configuration
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Fire and forget background preloading
|
|
71
|
+
* preloadTranslationsBackground({
|
|
72
|
+
* locales: ['en', 'es', 'fr'],
|
|
73
|
+
* parallel: true
|
|
74
|
+
* }, options)
|
|
75
|
+
* // Execution continues immediately
|
|
76
|
+
*/
|
|
77
|
+
export declare function preloadTranslationsBackground(config: PreloadConfig, options: StxOptions): void;
|
|
78
|
+
/**
|
|
79
|
+
* Lazy load a translation file with deduplication.
|
|
80
|
+
* If a load is already in progress for this locale, returns the existing promise.
|
|
81
|
+
* This prevents multiple simultaneous loads of the same locale.
|
|
82
|
+
*
|
|
83
|
+
* @param locale - Locale code (e.g., 'en', 'fr', 'de')
|
|
84
|
+
* @param options - stx options with i18n configuration
|
|
85
|
+
* @returns Promise resolving to translation dictionary
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* // Multiple calls during loading period share the same promise
|
|
89
|
+
* const p1 = loadTranslationLazy('en', options)
|
|
90
|
+
* const p2 = loadTranslationLazy('en', options)
|
|
91
|
+
* // p1 === p2 (same promise instance)
|
|
92
|
+
*/
|
|
93
|
+
export declare function loadTranslationLazy(locale: string, options: StxOptions): Promise<Record<string, any>>;
|
|
94
|
+
/**
|
|
95
|
+
* Get a translation synchronously if already cached, otherwise return undefined.
|
|
96
|
+
* This is useful for non-blocking render patterns where you want to show
|
|
97
|
+
* a fallback while translations load.
|
|
98
|
+
*
|
|
99
|
+
* @param locale - Locale code
|
|
100
|
+
* @returns Cached translations or undefined if not loaded
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* const translations = getTranslationSync('en')
|
|
104
|
+
* if (translations) {
|
|
105
|
+
* // Use translations
|
|
106
|
+
* } else {
|
|
107
|
+
* // Show loading state or fallback
|
|
108
|
+
* loadTranslationLazy('en', options).then(handleLoaded)
|
|
109
|
+
* }
|
|
110
|
+
*/
|
|
111
|
+
export declare function getTranslationSync(locale: string): Record<string, any> | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Get translation with automatic loading.
|
|
114
|
+
* Returns cached translations immediately if available,
|
|
115
|
+
* otherwise loads them and returns.
|
|
116
|
+
*
|
|
117
|
+
* This is the recommended async API for most use cases.
|
|
118
|
+
*
|
|
119
|
+
* @param locale - Locale code
|
|
120
|
+
* @param options - stx options
|
|
121
|
+
* @returns Promise resolving to translations
|
|
122
|
+
*/
|
|
123
|
+
export declare function getTranslationAsync(locale: string, options: StxOptions): Promise<Record<string, any>>;
|
|
124
|
+
/**
|
|
125
|
+
* Wait for a locale to finish loading.
|
|
126
|
+
* Useful when you've started a background preload and need to wait for it.
|
|
127
|
+
*
|
|
128
|
+
* @param locale - Locale to wait for
|
|
129
|
+
* @param timeoutMs - Optional timeout in milliseconds
|
|
130
|
+
* @returns Promise that resolves when loaded, or rejects on timeout/error
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* preloadTranslationsBackground({ locales: ['en', 'es'] }, options)
|
|
134
|
+
* // ... later
|
|
135
|
+
* await waitForLocale('en', 5000) // Wait up to 5 seconds
|
|
136
|
+
*/
|
|
137
|
+
export declare function waitForLocale(locale: string, timeoutMs?: number): Promise<Record<string, any>>;
|
|
138
|
+
/**
|
|
139
|
+
* Get all currently loading locales
|
|
140
|
+
*
|
|
141
|
+
* @returns Array of locale codes currently being loaded
|
|
142
|
+
*/
|
|
143
|
+
export declare function getLoadingLocales(): string[];
|
|
144
|
+
/**
|
|
145
|
+
* Cancel pending translation loads (clears pending state).
|
|
146
|
+
* Note: This doesn't actually abort HTTP requests, but clears tracking state.
|
|
147
|
+
*
|
|
148
|
+
* @param locale - Optional locale to cancel. If not provided, cancels all.
|
|
149
|
+
*/
|
|
150
|
+
export declare function cancelPendingLoads(locale?: string): void;
|
|
151
|
+
/**
|
|
152
|
+
* Load a translation file.
|
|
153
|
+
*
|
|
154
|
+
* This is the main entry point for loading translations. It uses lazy loading
|
|
155
|
+
* with deduplication internally, so multiple calls for the same locale will
|
|
156
|
+
* share the same promise.
|
|
157
|
+
*
|
|
158
|
+
* For more control over loading behavior, see:
|
|
159
|
+
* - `loadTranslationLazy()` - Explicit lazy loading with deduplication
|
|
160
|
+
* - `preloadTranslations()` - Preload multiple locales
|
|
161
|
+
* - `getTranslationSync()` - Get cached translations without loading
|
|
162
|
+
* - `getTranslationAsync()` - Get with automatic loading
|
|
163
|
+
*
|
|
164
|
+
* @param locale - Locale code (e.g., 'en', 'fr', 'de')
|
|
165
|
+
* @param options - stx options with i18n configuration
|
|
166
|
+
* @returns Translation dictionary
|
|
4
167
|
*/
|
|
5
168
|
export declare function loadTranslation(locale: string, options: StxOptions): Promise<Record<string, any>>;
|
|
6
169
|
/**
|
|
7
|
-
*
|
|
170
|
+
* ICU MessageFormat parser and formatter
|
|
171
|
+
*
|
|
172
|
+
* Supports:
|
|
173
|
+
* - Simple replacement: {name}
|
|
174
|
+
* - Plural: {count, plural, =0{none} one{# item} other{# items}}
|
|
175
|
+
* - Select: {gender, select, male{He} female{She} other{They}}
|
|
176
|
+
* - SelectOrdinal: {pos, selectordinal, one{#st} two{#nd} few{#rd} other{#th}}
|
|
177
|
+
* - Number formatting: {amount, number}
|
|
178
|
+
* - Date formatting: {date, date, short|medium|long|full}
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* formatICU('{count, plural, =0{No items} one{# item} other{# items}}', { count: 5 })
|
|
182
|
+
* // => '5 items'
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* formatICU('{gender, select, male{He} female{She} other{They}} liked this', { gender: 'female' })
|
|
186
|
+
* // => 'She liked this'
|
|
187
|
+
*/
|
|
188
|
+
export declare function formatICU(message: string, params?: Record<string, unknown>): string;
|
|
189
|
+
/**
|
|
190
|
+
* Check if a message uses ICU format
|
|
191
|
+
*/
|
|
192
|
+
export declare function isICUFormat(message: string): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Get a translation by key with parameter replacement and pluralization.
|
|
195
|
+
*
|
|
196
|
+
* Supports both Laravel-style (:param, |plural) and ICU MessageFormat.
|
|
197
|
+
*
|
|
198
|
+
* @param key - Dot-notation key (e.g., 'messages.welcome')
|
|
199
|
+
* @param translations - Translation dictionary
|
|
200
|
+
* @param fallbackToKey - Return key if translation not found
|
|
201
|
+
* @param params - Parameters for replacement (use 'count' for pluralization)
|
|
202
|
+
* @returns The translated string
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* // Simple parameter replacement
|
|
206
|
+
* getTranslation('greeting', { greeting: 'Hello :name' }, true, { name: 'John' })
|
|
207
|
+
* // => 'Hello John'
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* // Pluralization (Laravel-style)
|
|
211
|
+
* getTranslation('items', { items: 'One item|:count items' }, true, { count: 5 })
|
|
212
|
+
* // => '5 items'
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // ICU MessageFormat
|
|
216
|
+
* getTranslation('items', { items: '{count, plural, one{# item} other{# items}}' }, true, { count: 5 })
|
|
217
|
+
* // => '5 items'
|
|
8
218
|
*/
|
|
9
219
|
export declare function getTranslation(key: string, translations: Record<string, any>, fallbackToKey?: boolean, params?: Record<string, any>): string;
|
|
10
220
|
/**
|
|
@@ -15,5 +225,31 @@ export declare function processTranslateDirective(template: string, context: Rec
|
|
|
15
225
|
* Create a translation filter for expressions
|
|
16
226
|
*/
|
|
17
227
|
export declare function createTranslateFilter(translations: Record<string, any>, fallbackToKey?: boolean): (value: string, params?: Record<string, any>) => string;
|
|
228
|
+
// =============================================================================
|
|
229
|
+
// Configuration
|
|
230
|
+
// =============================================================================
|
|
18
231
|
// Default i18n configuration
|
|
19
|
-
export declare const defaultI18nConfig: I18nConfig;
|
|
232
|
+
export declare const defaultI18nConfig: I18nConfig;
|
|
233
|
+
/**
|
|
234
|
+
* Pending load tracking for deduplication
|
|
235
|
+
*/
|
|
236
|
+
declare interface PendingLoad {
|
|
237
|
+
promise: Promise<Record<string, any>>
|
|
238
|
+
state: LoadingState
|
|
239
|
+
error?: Error
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Preload configuration
|
|
243
|
+
*/
|
|
244
|
+
export declare interface PreloadConfig {
|
|
245
|
+
locales: string[]
|
|
246
|
+
parallel?: boolean
|
|
247
|
+
priority?: Record<string, number>
|
|
248
|
+
onLocaleLoaded?: (locale: string) => void
|
|
249
|
+
onComplete?: () => void
|
|
250
|
+
onError?: (locale: string, error: Error) => void
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Loading state for async translation loading
|
|
254
|
+
*/
|
|
255
|
+
declare type LoadingState = 'idle' | 'loading' | 'loaded' | 'error'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type ImageOptions, } from './processor';
|
|
2
|
+
import type { BuildPlugin } from '../production-build';
|
|
3
|
+
/**
|
|
4
|
+
* Create the image optimization build plugin
|
|
5
|
+
*/
|
|
6
|
+
export declare function createImagePlugin(options?: ImageBuildOptions): BuildPlugin;
|
|
7
|
+
/**
|
|
8
|
+
* Optimize a single image
|
|
9
|
+
*/
|
|
10
|
+
export declare function optimizeImage(inputPath: string, outputDir: string, options?: ImageOptions): Promise<ProcessedImage>;
|
|
11
|
+
/**
|
|
12
|
+
* Optimize all images in a directory
|
|
13
|
+
*/
|
|
14
|
+
export declare function optimizeDirectory(inputDir: string, outputDir: string, options?: ImageBuildOptions): Promise<{
|
|
15
|
+
processed: ProcessedImage[]
|
|
16
|
+
stats: ImageBuildContext['stats']
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Generate image manifest for build
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateImageManifest(images: ProcessedImage[]): Record<string, { variants: ImageVariant[]; placeholder?: string }>;
|
|
22
|
+
/**
|
|
23
|
+
* Write image manifest to file
|
|
24
|
+
*/
|
|
25
|
+
export declare function writeImageManifest(images: ProcessedImage[], outputPath: string): Promise<void>;
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Types
|
|
28
|
+
// ============================================================================
|
|
29
|
+
export declare interface ImageBuildOptions {
|
|
30
|
+
inputDirs?: string[]
|
|
31
|
+
outputDir?: string
|
|
32
|
+
baseUrl?: string
|
|
33
|
+
defaults?: ImageOptions
|
|
34
|
+
cache?: boolean
|
|
35
|
+
cacheDir?: string
|
|
36
|
+
concurrency?: number
|
|
37
|
+
referencedOnly?: boolean
|
|
38
|
+
formats?: ImageFormat[]
|
|
39
|
+
widths?: number[]
|
|
40
|
+
quality?: number
|
|
41
|
+
placeholder?: 'blur' | 'dominant-color' | 'none'
|
|
42
|
+
verbose?: boolean
|
|
43
|
+
}
|
|
44
|
+
export declare interface ImageBuildContext {
|
|
45
|
+
imageReferences: Set<string>
|
|
46
|
+
processedImages: Map<string, ProcessedImage>
|
|
47
|
+
stats: {
|
|
48
|
+
totalImages: number
|
|
49
|
+
optimizedImages: number
|
|
50
|
+
savedBytes: number
|
|
51
|
+
variants: number
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ImageFormat, } from './processor';
|
|
2
|
+
/**
|
|
3
|
+
* Render an optimized <Image> component
|
|
4
|
+
*/
|
|
5
|
+
export declare function renderImageComponent(props: ImageComponentProps, context?: ImageRenderContext): ImageRenderResult;
|
|
6
|
+
/**
|
|
7
|
+
* Parse Image component from template
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseImageComponent(content: string): ImageComponentProps | null;
|
|
10
|
+
/**
|
|
11
|
+
* Process Image components in template content
|
|
12
|
+
*/
|
|
13
|
+
export declare function processImageComponents(content: string, processor: (props: ImageComponentProps) => Promise<ImageRenderResult>): Promise<{ html: string; preloadLinks: string[]; styles: string[] }>;
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Types
|
|
16
|
+
// ============================================================================
|
|
17
|
+
export declare interface ImageComponentProps {
|
|
18
|
+
src: string
|
|
19
|
+
alt: string
|
|
20
|
+
width?: number | string
|
|
21
|
+
height?: number | string
|
|
22
|
+
sizes?: string | Record<string, string>
|
|
23
|
+
loading?: 'lazy' | 'eager'
|
|
24
|
+
priority?: boolean
|
|
25
|
+
quality?: number
|
|
26
|
+
placeholder?: 'blur' | 'color' | 'none'
|
|
27
|
+
formats?: ImageFormat[]
|
|
28
|
+
widths?: number[]
|
|
29
|
+
class?: string
|
|
30
|
+
style?: string
|
|
31
|
+
decoding?: 'sync' | 'async' | 'auto'
|
|
32
|
+
fetchpriority?: 'high' | 'low' | 'auto'
|
|
33
|
+
objectFit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down'
|
|
34
|
+
objectPosition?: string
|
|
35
|
+
}
|
|
36
|
+
export declare interface ImageRenderContext {
|
|
37
|
+
processedImage?: ProcessedImage
|
|
38
|
+
variants?: ImageVariant[]
|
|
39
|
+
optimize?: boolean
|
|
40
|
+
isDev?: boolean
|
|
41
|
+
}
|
|
42
|
+
export declare interface ImageRenderResult {
|
|
43
|
+
html: string
|
|
44
|
+
preloadLink?: string
|
|
45
|
+
placeholderCss?: string
|
|
46
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ImageFormat, } from './processor';
|
|
2
|
+
import type { CustomDirective } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Clear the image cache
|
|
5
|
+
*/
|
|
6
|
+
export declare function clearImageCache(): void;
|
|
7
|
+
/**
|
|
8
|
+
* Create the @image directive
|
|
9
|
+
*/
|
|
10
|
+
export declare function createImageDirective(): CustomDirective;
|
|
11
|
+
/**
|
|
12
|
+
* The @image directive instance
|
|
13
|
+
*/
|
|
14
|
+
export declare const imageDirective: unknown;
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Types
|
|
17
|
+
// ============================================================================
|
|
18
|
+
export declare interface ImageDirectiveOptions {
|
|
19
|
+
width?: number
|
|
20
|
+
height?: number
|
|
21
|
+
quality?: number
|
|
22
|
+
lazy?: boolean
|
|
23
|
+
formats?: ImageFormat[]
|
|
24
|
+
widths?: number[]
|
|
25
|
+
sizes?: string
|
|
26
|
+
class?: string
|
|
27
|
+
style?: string
|
|
28
|
+
priority?: boolean
|
|
29
|
+
placeholder?: 'blur' | 'color' | 'none'
|
|
30
|
+
}
|