@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,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default image configuration
|
|
3
|
+
*/
|
|
4
|
+
export declare const defaultImageConfig: ImageConfig;
|
|
5
|
+
/**
|
|
6
|
+
* Image optimization configuration for stx.config.ts
|
|
7
|
+
*/
|
|
8
|
+
export declare interface ImageConfig {
|
|
9
|
+
enabled?: boolean
|
|
10
|
+
widths?: number[]
|
|
11
|
+
formats?: ('webp' | 'avif' | 'jpeg' | 'png')[]
|
|
12
|
+
quality?: number
|
|
13
|
+
devOptimize?: boolean
|
|
14
|
+
cacheDir?: string
|
|
15
|
+
placeholder?: 'blur' | 'dominant-color' | 'none'
|
|
16
|
+
inputDirs?: string[]
|
|
17
|
+
outputDir?: string
|
|
18
|
+
baseUrl?: string
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
// Core processing
|
|
22
|
+
processImage,
|
|
23
|
+
getImageMetadata,
|
|
24
|
+
isSharpAvailable,
|
|
25
|
+
|
|
26
|
+
// HTML helpers
|
|
27
|
+
generateSrcSet,
|
|
28
|
+
generateSizes,
|
|
29
|
+
getFallbackVariant,
|
|
30
|
+
groupVariantsByFormat,
|
|
31
|
+
|
|
32
|
+
// Utilities
|
|
33
|
+
isImageFile,
|
|
34
|
+
getMimeType,
|
|
35
|
+
getTotalSize,
|
|
36
|
+
formatSize,
|
|
37
|
+
|
|
38
|
+
// Error class
|
|
39
|
+
ImageProcessingError,
|
|
40
|
+
|
|
41
|
+
// Constants
|
|
42
|
+
DEFAULT_WIDTHS,
|
|
43
|
+
DEFAULT_FORMATS,
|
|
44
|
+
DEFAULT_QUALITY,
|
|
45
|
+
|
|
46
|
+
// Types
|
|
47
|
+
type ImageOptions,
|
|
48
|
+
type ImageFormat,
|
|
49
|
+
type ProcessedImage,
|
|
50
|
+
type ImageVariant,
|
|
51
|
+
type ImageMetadata,
|
|
52
|
+
} from './processor';
|
|
53
|
+
export {
|
|
54
|
+
// Rendering
|
|
55
|
+
renderImageComponent,
|
|
56
|
+
parseImageComponent,
|
|
57
|
+
processImageComponents,
|
|
58
|
+
|
|
59
|
+
// Types
|
|
60
|
+
type ImageComponentProps,
|
|
61
|
+
type ImageRenderContext,
|
|
62
|
+
type ImageRenderResult,
|
|
63
|
+
} from './component';
|
|
64
|
+
export {
|
|
65
|
+
// Directive
|
|
66
|
+
imageDirective,
|
|
67
|
+
createImageDirective,
|
|
68
|
+
clearImageCache,
|
|
69
|
+
|
|
70
|
+
// Types
|
|
71
|
+
type ImageDirectiveOptions,
|
|
72
|
+
} from './directive';
|
|
73
|
+
export {
|
|
74
|
+
// Plugin
|
|
75
|
+
createImagePlugin,
|
|
76
|
+
|
|
77
|
+
// Standalone functions
|
|
78
|
+
optimizeImage,
|
|
79
|
+
optimizeDirectory,
|
|
80
|
+
generateImageManifest,
|
|
81
|
+
writeImageManifest,
|
|
82
|
+
|
|
83
|
+
// Types
|
|
84
|
+
type ImageBuildOptions,
|
|
85
|
+
type ImageBuildContext,
|
|
86
|
+
} from './build-plugin';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
/**
|
|
3
|
+
* Check if sharp is available
|
|
4
|
+
*/
|
|
5
|
+
export declare function isSharpAvailable(): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* Process an image and generate responsive variants
|
|
8
|
+
*/
|
|
9
|
+
export declare function processImage(input: string | Buffer, options?: ImageOptions): Promise<ProcessedImage>;
|
|
10
|
+
/**
|
|
11
|
+
* Get image metadata
|
|
12
|
+
*/
|
|
13
|
+
export declare function getImageMetadata(input: Buffer | string): Promise<ImageMetadata>;
|
|
14
|
+
/**
|
|
15
|
+
* Generate srcset attribute from variants
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateSrcSet(variants: ImageVariant[], format?: ImageFormat): string;
|
|
18
|
+
/**
|
|
19
|
+
* Generate sizes attribute
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateSizes(breakpoints?: Record<string, string>): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get best fallback variant (middle resolution JPEG)
|
|
24
|
+
*/
|
|
25
|
+
export declare function getFallbackVariant(variants: ImageVariant[]): ImageVariant | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Group variants by format
|
|
28
|
+
*/
|
|
29
|
+
export declare function groupVariantsByFormat(variants: ImageVariant[]): Map<ImageFormat, ImageVariant[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if file is an image
|
|
32
|
+
*/
|
|
33
|
+
export declare function isImageFile(filePath: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get MIME type for format
|
|
36
|
+
*/
|
|
37
|
+
export declare function getMimeType(format: ImageFormat): string;
|
|
38
|
+
/**
|
|
39
|
+
* Calculate total size of variants
|
|
40
|
+
*/
|
|
41
|
+
export declare function getTotalSize(variants: ImageVariant[]): number;
|
|
42
|
+
/**
|
|
43
|
+
* Format file size for display
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatSize(bytes: number): string;
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Constants
|
|
48
|
+
// ============================================================================
|
|
49
|
+
export declare const DEFAULT_WIDTHS: readonly [320, 640, 768, 1024, 1280, 1536, 1920];
|
|
50
|
+
export declare const DEFAULT_FORMATS: ImageFormat[];
|
|
51
|
+
export declare const DEFAULT_QUALITY: 80;
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Types
|
|
54
|
+
// ============================================================================
|
|
55
|
+
export declare interface ImageOptions {
|
|
56
|
+
widths?: number[]
|
|
57
|
+
formats?: ImageFormat[]
|
|
58
|
+
quality?: number
|
|
59
|
+
fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside'
|
|
60
|
+
placeholder?: 'blur' | 'dominant-color' | 'none'
|
|
61
|
+
outputDir?: string
|
|
62
|
+
baseUrl?: string
|
|
63
|
+
}
|
|
64
|
+
export declare interface ProcessedImage {
|
|
65
|
+
src: string
|
|
66
|
+
variants: ImageVariant[]
|
|
67
|
+
placeholder?: string
|
|
68
|
+
width: number
|
|
69
|
+
height: number
|
|
70
|
+
aspectRatio: number
|
|
71
|
+
hash: string
|
|
72
|
+
}
|
|
73
|
+
export declare interface ImageVariant {
|
|
74
|
+
path: string
|
|
75
|
+
url: string
|
|
76
|
+
width: number
|
|
77
|
+
height: number
|
|
78
|
+
format: ImageFormat
|
|
79
|
+
size: number
|
|
80
|
+
}
|
|
81
|
+
export declare interface ImageMetadata {
|
|
82
|
+
width: number
|
|
83
|
+
height: number
|
|
84
|
+
format: string
|
|
85
|
+
hasAlpha?: boolean
|
|
86
|
+
}
|
|
87
|
+
export type ImageFormat = 'webp' | 'avif' | 'jpeg' | 'png'
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// Sharp Integration
|
|
90
|
+
// ============================================================================
|
|
91
|
+
declare type SharpInstance = {
|
|
92
|
+
metadata(): Promise<ImageMetadata>
|
|
93
|
+
resize(width: number, height?: number, options?: { fit?: string }): SharpInstance
|
|
94
|
+
webp(options?: { quality?: number }): SharpInstance
|
|
95
|
+
avif(options?: { quality?: number }): SharpInstance
|
|
96
|
+
jpeg(options?: { quality?: number }): SharpInstance
|
|
97
|
+
png(options?: { quality?: number }): SharpInstance
|
|
98
|
+
toBuffer(): Promise<Buffer>
|
|
99
|
+
blur(sigma: number): SharpInstance
|
|
100
|
+
toFormat(format: string, options?: { quality?: number }): SharpInstance
|
|
101
|
+
}
|
|
102
|
+
declare type SharpModule = {
|
|
103
|
+
(input: Buffer | string): SharpInstance
|
|
104
|
+
default?: (input: Buffer | string) => SharpInstance
|
|
105
|
+
}
|
|
106
|
+
// ============================================================================
|
|
107
|
+
// Error Handling
|
|
108
|
+
// ============================================================================
|
|
109
|
+
export declare class ImageProcessingError extends Error {
|
|
110
|
+
code: string;
|
|
111
|
+
constructor(message: string, code: string);
|
|
112
|
+
}
|
package/dist/includes.d.ts
CHANGED
|
@@ -1,24 +1,109 @@
|
|
|
1
|
+
import { LRUCache } from './performance-utils';
|
|
1
2
|
import type { StxOptions } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Clear the @once store - useful for testing and resetting state
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: In server environments, call this at the start of each request
|
|
7
|
+
* to prevent @once content from being incorrectly skipped across requests.
|
|
8
|
+
*
|
|
9
|
+
* Alternatively, use request-scoped tracking by setting `context.__onceStore = new Set()`
|
|
10
|
+
* before processing templates. The processor will use context.__onceStore if available.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Option 1: Clear global store per request
|
|
15
|
+
* app.use((req, res, next) => {
|
|
16
|
+
* clearOnceStore()
|
|
17
|
+
* next()
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* // Option 2: Use request-scoped store (preferred)
|
|
21
|
+
* const context = {
|
|
22
|
+
* __onceStore: new Set<string>(),
|
|
23
|
+
* ...otherData
|
|
24
|
+
* }
|
|
25
|
+
* await processDirectives(template, context, filePath, options)
|
|
26
|
+
* ```
|
|
4
27
|
*/
|
|
5
28
|
export declare function clearOnceStore(): void;
|
|
6
29
|
/**
|
|
7
|
-
* Process @include
|
|
30
|
+
* Process @include, @partial, @includeIf, @includeWhen, @includeUnless,
|
|
31
|
+
* @includeFirst, and @once directives.
|
|
32
|
+
*
|
|
33
|
+
* This is the main function for include processing. It handles all include
|
|
34
|
+
* variants and the @once directive for deduplication.
|
|
35
|
+
*
|
|
36
|
+
* @param template - The template string to process
|
|
37
|
+
* @param context - Template context with variables
|
|
38
|
+
* @param filePath - Path to the current template file
|
|
39
|
+
* @param options - STX processing options
|
|
40
|
+
* @param dependencies - Set to track included file dependencies (for caching)
|
|
41
|
+
* @returns The processed template with includes resolved
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const deps = new Set<string>()
|
|
46
|
+
* const result = await processIncludes(
|
|
47
|
+
* '@include("header") <main>Content</main> @include("footer")',
|
|
48
|
+
* { title: 'My Page' },
|
|
49
|
+
* '/app/views/home.stx',
|
|
50
|
+
* options,
|
|
51
|
+
* deps
|
|
52
|
+
* )
|
|
53
|
+
* // deps now contains paths to header.stx and footer.stx
|
|
54
|
+
* ```
|
|
8
55
|
*/
|
|
9
|
-
export declare function processIncludes(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
|
|
56
|
+
export declare function processIncludes(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>, includeStack?: Set<string>): Promise<string>;
|
|
10
57
|
/**
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
58
|
+
* Process @push and @prepend directives to collect content into named stacks.
|
|
59
|
+
*
|
|
60
|
+
* This function extracts stack content and removes the directives from output.
|
|
61
|
+
* The collected content is stored in the `stacks` object for later rendering.
|
|
62
|
+
*
|
|
63
|
+
* @param template - The template string to process
|
|
64
|
+
* @param stacks - Object to collect stack content (mutated)
|
|
65
|
+
* @returns Template with @push/@prepend directives removed
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const stacks: Record<string, string[]> = {}
|
|
70
|
+
* const result = processStackPushDirectives(`
|
|
71
|
+
* @push('scripts')
|
|
72
|
+
* <script src="app.js"></script>
|
|
73
|
+
* @endpush
|
|
74
|
+
* <div>Content</div>
|
|
75
|
+
* `, stacks)
|
|
76
|
+
* // result = '\n <div>Content</div>\n'
|
|
77
|
+
* // stacks = { scripts: ['<script src="app.js"></script>'] }
|
|
78
|
+
* ```
|
|
15
79
|
*/
|
|
16
80
|
export declare function processStackPushDirectives(template: string, stacks: Record<string, string[]>): string;
|
|
17
81
|
/**
|
|
18
|
-
* Process @stack directives by replacing them with
|
|
82
|
+
* Process @stack directives by replacing them with collected stack content.
|
|
83
|
+
*
|
|
84
|
+
* This should be called AFTER `processStackPushDirectives` has collected
|
|
85
|
+
* all @push and @prepend content.
|
|
86
|
+
*
|
|
87
|
+
* @param template - The template string with @stack directives
|
|
88
|
+
* @param stacks - Object containing collected stack content
|
|
89
|
+
* @returns Template with @stack directives replaced by their content
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const stacks = {
|
|
94
|
+
* scripts: ['<script src="a.js"></script>', '<script src="b.js"></script>'],
|
|
95
|
+
* styles: ['<link rel="stylesheet" href="app.css">']
|
|
96
|
+
* }
|
|
97
|
+
* const result = processStackReplacements(`
|
|
98
|
+
* <head>@stack('styles')</head>
|
|
99
|
+
* <body>...@stack('scripts')</body>
|
|
100
|
+
* `, stacks)
|
|
101
|
+
* ```
|
|
19
102
|
*/
|
|
20
103
|
export declare function processStackReplacements(template: string, stacks: Record<string, string[]>): string;
|
|
21
|
-
// Cache for partials to avoid repeated file reads
|
|
22
|
-
export declare const partialsCache:
|
|
104
|
+
// Cache for partials to avoid repeated file reads (LRU with max 500 entries)
|
|
105
|
+
export declare const partialsCache: LRUCache<string, string>;
|
|
23
106
|
// Global store to track what has been included via @once
|
|
107
|
+
// WARNING: This persists across requests in long-running servers!
|
|
108
|
+
// Use clearOnceStore() at the start of each request, or use request-scoped tracking via context.__onceStore
|
|
24
109
|
export declare const onceStore: Set<string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,90 @@
|
|
|
1
|
+
export type { StxComponentInstance, EmitFn } from './composition-api';
|
|
2
|
+
export type { VNode } from './jsx-runtime';
|
|
3
|
+
export type { StxApp, StxAppPlugin, StxPluginInput, StxAppConfig } from './app';
|
|
4
|
+
export { type BuildResult } from './build-optimizer';
|
|
5
|
+
export { type ComponentInstance } from './reactivity';
|
|
6
|
+
export { type HydrationOptions } from './hydration';
|
|
7
|
+
export { type CookieOptions } from './route-middleware';
|
|
8
|
+
export { formatSize, getTotalSize } from './deploy';
|
|
9
|
+
export { type ImageRenderResult, type ImageVariant, type ProcessedImage, clearImageCache, getFallbackVariant, getMimeType, groupVariantsByFormat, optimizeImage, processImage } from './image-optimization';
|
|
10
|
+
export { type AnalysisResult } from './analyzer';
|
|
11
|
+
export { type AnalyzeOptions, type ChunkInfo } from './production-build';
|
|
12
|
+
export { fileExists } from './utils';
|
|
13
|
+
export { type StreamingConfig } from './types';
|
|
14
|
+
export { type Middleware } from './ssr';
|
|
15
|
+
export * from './reactivity';
|
|
16
|
+
export * from './head';
|
|
17
|
+
export * from './route-middleware';
|
|
18
|
+
export * from './runtime';
|
|
19
|
+
export * from './forms';
|
|
20
|
+
export * from './env';
|
|
1
21
|
export * from './a11y';
|
|
22
|
+
export * from './analytics';
|
|
2
23
|
export * from './analyzer';
|
|
3
24
|
export * from './animation';
|
|
4
25
|
export * from './assets';
|
|
26
|
+
export * from './async-components';
|
|
5
27
|
export * from './auth';
|
|
28
|
+
export * from './build-optimizer';
|
|
6
29
|
export * from './caching';
|
|
7
30
|
export * from './components';
|
|
8
31
|
export * from './config';
|
|
32
|
+
export * from './csp';
|
|
9
33
|
export * from './custom-directives';
|
|
34
|
+
export * from './defer';
|
|
35
|
+
export * from './deploy';
|
|
10
36
|
export * from './dev-server';
|
|
37
|
+
export * from './directive-api';
|
|
11
38
|
export * from './docs';
|
|
39
|
+
export * from './edge-runtime';
|
|
12
40
|
export * from './error-handling';
|
|
41
|
+
export * from './events';
|
|
13
42
|
export * from './expressions';
|
|
14
43
|
export * from './formatter';
|
|
15
|
-
export * from './
|
|
44
|
+
export * from './heatmap';
|
|
45
|
+
export * from './hot-reload';
|
|
16
46
|
export * from './i18n';
|
|
17
47
|
export * from './includes';
|
|
18
48
|
export * from './init';
|
|
49
|
+
export * from './interactive';
|
|
50
|
+
export * from './keep-alive';
|
|
19
51
|
export * from './loops';
|
|
20
52
|
export * from './markdown';
|
|
21
53
|
export * from './middleware';
|
|
54
|
+
export * from './parser';
|
|
22
55
|
export * from './process';
|
|
56
|
+
export * from './production-build';
|
|
23
57
|
export * from './release';
|
|
58
|
+
export * from './router';
|
|
59
|
+
export * from './scaffolding';
|
|
24
60
|
export * from './seo';
|
|
25
61
|
export * from './serve';
|
|
26
62
|
export * from './streaming';
|
|
27
|
-
export * from './
|
|
28
|
-
export * from './
|
|
63
|
+
export * from './suspense';
|
|
64
|
+
export * from './teleport';
|
|
65
|
+
export * from './transitions';
|
|
66
|
+
export * from './type-checker';
|
|
29
67
|
export * from './web-components';
|
|
68
|
+
export * from './virtual-scrolling';
|
|
69
|
+
export * from './partial-hydration';
|
|
70
|
+
export * from './hydration-runtime';
|
|
71
|
+
export * from './client';
|
|
72
|
+
export * from './loading-indicator';
|
|
73
|
+
export * from './reactive-bindings';
|
|
74
|
+
export * from './client-script';
|
|
75
|
+
export * from './component-hmr';
|
|
76
|
+
export * from './hydration';
|
|
77
|
+
export * from './ssr';
|
|
78
|
+
export * from './image-optimization';
|
|
79
|
+
export * from './media';
|
|
80
|
+
export * from './build-views';
|
|
81
|
+
export * from './signals';
|
|
82
|
+
export * from './vue-template';
|
|
83
|
+
export { provide, inject, setGlobalProvide, defineEmits, defineExpose, nextTick, onErrorCaptured, handleError, useSlots, useAttrs, createProvideContext, generateCompositionRuntime } from './composition-api';
|
|
84
|
+
export { jsx, jsxs, jsxDEV, Fragment, renderToString, renderToStream, renderToDOM, Show, For, Portal, h } from './jsx-runtime';
|
|
85
|
+
export { createApp as createStxApp } from './app';
|
|
86
|
+
export * from './dynamic-components';
|
|
87
|
+
export * from './utils';
|
|
88
|
+
export * from './slots';
|
|
89
|
+
export * from './types';
|
|
30
90
|
export default {};
|