@stacksjs/stx 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a11y.d.ts +109 -5
- package/dist/analytics.d.ts +40 -0
- package/dist/animation.d.ts +90 -0
- package/dist/app.d.ts +51 -0
- package/dist/ast.d.ts +286 -0
- package/dist/async-components.d.ts +101 -0
- package/dist/auth.d.ts +1 -3
- package/dist/browser-composables.d.ts +314 -0
- package/dist/build-optimizer.d.ts +126 -0
- package/dist/build-views.d.ts +37 -0
- package/dist/bundle-analyzer/collector.d.ts +66 -0
- package/dist/bundle-analyzer/index.d.ts +60 -0
- package/dist/bundle-analyzer/report.d.ts +39 -0
- package/dist/bundle-analyzer/treemap.d.ts +19 -0
- package/dist/bundle-analyzer.js +499 -0
- package/dist/caching.d.ts +7 -0
- package/dist/cli.js +10880 -1199
- package/dist/client/directive.d.ts +10 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/router.d.ts +36 -0
- package/dist/client/stx-router.browser.d.ts +0 -0
- package/dist/client-script.d.ts +22 -0
- package/dist/component-hmr.d.ts +120 -0
- package/dist/components.d.ts +23 -1
- package/dist/composables/index.d.ts +277 -0
- package/dist/composables/use-battery.d.ts +46 -0
- package/dist/composables/use-broadcast-channel.d.ts +58 -0
- package/dist/composables/use-clipboard.d.ts +34 -0
- package/dist/composables/use-cookie.d.ts +70 -0
- package/dist/composables/use-device-orientation.d.ts +109 -0
- package/dist/composables/use-event-source.d.ts +77 -0
- package/dist/composables/use-eye-dropper.d.ts +107 -0
- package/dist/composables/use-fetch.d.ts +84 -0
- package/dist/composables/use-fullscreen.d.ts +47 -0
- package/dist/composables/use-geolocation.d.ts +62 -0
- package/dist/composables/use-idle.d.ts +84 -0
- package/dist/composables/use-intersection-observer.d.ts +81 -0
- package/dist/composables/use-keyboard.d.ts +100 -0
- package/dist/composables/use-media-query.d.ts +56 -0
- package/dist/composables/use-mouse.d.ts +64 -0
- package/dist/composables/use-mutation-observer.d.ts +101 -0
- package/dist/composables/use-network.d.ts +40 -0
- package/dist/composables/use-notification.d.ts +89 -0
- package/dist/composables/use-permissions.d.ts +109 -0
- package/dist/composables/use-resize-observer.d.ts +60 -0
- package/dist/composables/use-share.d.ts +70 -0
- package/dist/composables/use-speech.d.ts +117 -0
- package/dist/composables/use-storage.d.ts +64 -0
- package/dist/composables/use-text-selection.d.ts +97 -0
- package/dist/composables/use-wake-lock.d.ts +85 -0
- package/dist/composables/use-websocket.d.ts +69 -0
- package/dist/composables/use-window.d.ts +84 -0
- package/dist/composables.d.ts +268 -0
- package/dist/composition-api.d.ts +190 -0
- package/dist/computed.d.ts +137 -0
- package/dist/conditionals.d.ts +14 -2
- package/dist/config.d.ts +35 -2
- package/dist/craft-bridge.d.ts +319 -0
- package/dist/craft-compiler.d.ts +229 -0
- package/dist/craft-components.d.ts +411 -0
- package/dist/craft-entry.d.ts +5 -0
- package/dist/craft-ssr.d.ts +134 -0
- package/dist/craft.js +1553 -0
- package/dist/csp.d.ts +229 -0
- package/dist/database.d.ts +407 -0
- package/dist/database.js +5 -0
- package/dist/defer.d.ts +4 -0
- package/dist/deploy/config-generators.d.ts +75 -0
- package/dist/deploy/index.d.ts +84 -0
- package/dist/deploy/netlify.d.ts +109 -0
- package/dist/dev-server/crosswind.d.ts +54 -0
- package/dist/dev-server/index.d.ts +7 -0
- package/dist/dev-server/keyboard-shortcuts.d.ts +34 -0
- package/dist/dev-server/native-window.d.ts +40 -0
- package/dist/dev-server/port-utils.d.ts +27 -0
- package/dist/dev-server/terminal-colors.d.ts +60 -0
- package/dist/dev-server/theme-selector.d.ts +32 -0
- package/dist/dev-server/types.d.ts +92 -0
- package/dist/dev-server.d.ts +21 -0
- package/dist/devtools.d.ts +142 -0
- package/dist/directive-api.d.ts +111 -0
- package/dist/dynamic-components.d.ts +14 -0
- package/dist/edge-runtime.d.ts +200 -0
- package/dist/env.d.ts +9 -0
- package/dist/error-boundaries.d.ts +71 -0
- package/dist/error-handling.d.ts +1 -101
- package/dist/errors/codes.d.ts +99 -0
- package/dist/errors/formatter.d.ts +64 -0
- package/dist/errors/index.d.ts +56 -0
- package/dist/errors/logger.d.ts +74 -0
- package/dist/errors/sanitizer.d.ts +43 -0
- package/dist/errors/types.d.ts +79 -0
- package/dist/events.d.ts +106 -0
- package/dist/expressions.d.ts +86 -11
- package/dist/forms-validation.d.ts +173 -0
- package/dist/forms.d.ts +157 -8
- package/dist/head.d.ts +225 -0
- package/dist/heatmap.d.ts +125 -0
- package/dist/hot-reload.d.ts +87 -0
- package/dist/hydration-runtime.d.ts +47 -0
- package/dist/hydration.d.ts +161 -0
- package/dist/i18n.d.ts +239 -3
- package/dist/image-optimization/build-plugin.d.ts +53 -0
- package/dist/image-optimization/component.d.ts +46 -0
- package/dist/image-optimization/directive.d.ts +30 -0
- package/dist/image-optimization/index.d.ts +86 -0
- package/dist/image-optimization/processor.d.ts +112 -0
- package/dist/includes.d.ts +94 -9
- package/dist/index.d.ts +63 -3
- package/dist/index.js +11603 -1318
- package/dist/init.d.ts +32 -2
- package/dist/interactive.d.ts +14 -0
- package/dist/internal-markdown.d.ts +22 -0
- package/dist/jsx-runtime.d.ts +110 -0
- package/dist/keep-alive.d.ts +87 -0
- package/dist/lazy-loader.d.ts +122 -0
- package/dist/loading-indicator.d.ts +40 -0
- package/dist/loops.d.ts +22 -1
- package/dist/media/client/blur-up.d.ts +65 -0
- package/dist/media/client/index.d.ts +77 -0
- package/dist/media/client/lazy-load.d.ts +73 -0
- package/dist/media/client/upload-handler.d.ts +79 -0
- package/dist/media/image/component.d.ts +46 -0
- package/dist/media/image/directive.d.ts +9 -0
- package/dist/media/image/editing.d.ts +212 -0
- package/dist/media/image/index.d.ts +118 -0
- package/dist/media/image/placeholder.d.ts +78 -0
- package/dist/media/image/processor/cache.d.ts +32 -0
- package/dist/media/image/processor/index.d.ts +12 -0
- package/dist/media/image/processor/optimizer.d.ts +13 -0
- package/dist/media/image/processor/responsive.d.ts +17 -0
- package/dist/media/image/srcset.d.ts +158 -0
- package/dist/media/index.d.ts +295 -0
- package/dist/media/manager/embed.d.ts +25 -0
- package/dist/media/protected/component.d.ts +34 -0
- package/dist/media/protected/index.d.ts +34 -0
- package/dist/media/protected/signature.d.ts +72 -0
- package/dist/media/shared/cache.d.ts +54 -0
- package/dist/media/shared/hash.d.ts +24 -0
- package/dist/media/shared/index.d.ts +2 -0
- package/dist/media/types.d.ts +1051 -0
- package/dist/media/upload/component.d.ts +23 -0
- package/dist/media/upload/index.d.ts +1 -0
- package/dist/media/video/directive.d.ts +9 -0
- package/dist/media/video/index.d.ts +47 -0
- package/dist/media/video/processor/cache.d.ts +33 -0
- package/dist/media/video/processor/index.d.ts +21 -0
- package/dist/media/video/processor/streaming.d.ts +19 -0
- package/dist/media/video/processor/thumbnail.d.ts +28 -0
- package/dist/media/video/processor/transcoder.d.ts +9 -0
- package/dist/middleware.d.ts +42 -3
- package/dist/native-build.d.ts +74 -0
- package/dist/parser/directive-parser.d.ts +79 -0
- package/dist/parser/expression-parser.d.ts +59 -0
- package/dist/parser/index.d.ts +35 -0
- package/dist/parser/tokenizer.d.ts +81 -0
- package/dist/partial-hydration.d.ts +88 -0
- package/dist/performance-utils.d.ts +146 -3
- package/dist/plugin-system.d.ts +128 -0
- package/dist/precompiler.d.ts +108 -0
- package/dist/production-build.d.ts +199 -0
- package/dist/props.d.ts +199 -0
- package/dist/pwa/audit.d.ts +42 -0
- package/dist/pwa/directives.d.ts +29 -0
- package/dist/pwa/icons.d.ts +39 -0
- package/dist/pwa/index.d.ts +59 -0
- package/dist/pwa/inject.d.ts +22 -0
- package/dist/pwa/manifest.d.ts +104 -0
- package/dist/pwa/offline.d.ts +8 -0
- package/dist/pwa/precache.d.ts +29 -0
- package/dist/pwa/service-worker.d.ts +21 -0
- package/dist/pwa/workbox-strategies.d.ts +100 -0
- package/dist/pwa/workbox.d.ts +52 -0
- package/dist/pwa.d.ts +51 -0
- package/dist/pwa.js +8124 -0
- package/dist/reactive-bindings.d.ts +24 -0
- package/dist/reactive.d.ts +100 -0
- package/dist/reactivity.d.ts +253 -0
- package/dist/route-middleware.d.ts +232 -0
- package/dist/router.d.ts +31 -0
- package/dist/routes.d.ts +0 -7
- package/dist/runtime.d.ts +140 -0
- package/dist/safe-evaluator.d.ts +117 -3
- package/dist/scaffolding.d.ts +113 -0
- package/dist/seo.d.ts +120 -7
- package/dist/server-components.d.ts +134 -0
- package/dist/signals.d.ts +501 -0
- package/dist/slots.d.ts +63 -0
- package/dist/source-maps.d.ts +117 -0
- package/dist/ssg.d.ts +157 -0
- package/dist/ssg.js +6831 -0
- package/dist/ssr.d.ts +107 -0
- package/dist/state-management.d.ts +324 -0
- package/dist/stores-client.d.ts +70 -0
- package/dist/story/addons.d.ts +123 -0
- package/dist/story/analytics.d.ts +92 -0
- package/dist/story/auto-stories.d.ts +38 -0
- package/dist/story/bookmarks.d.ts +53 -0
- package/dist/story/bun-test.d.ts +44 -0
- package/dist/story/cli.d.ts +34 -0
- package/dist/story/collect/analyzer.d.ts +33 -0
- package/dist/story/collect/index.d.ts +27 -0
- package/dist/story/collect/parser.d.ts +17 -0
- package/dist/story/collect/scanner.d.ts +13 -0
- package/dist/story/collect/tree.d.ts +17 -0
- package/dist/story/commands/build.d.ts +14 -0
- package/dist/story/commands/dev.d.ts +16 -0
- package/dist/story/commands/index.d.ts +6 -0
- package/dist/story/commands/preview.d.ts +15 -0
- package/dist/story/compiled-output.d.ts +26 -0
- package/dist/story/composition.d.ts +47 -0
- package/dist/story/config-watcher.d.ts +26 -0
- package/dist/story/config.d.ts +26 -0
- package/dist/story/context.d.ts +21 -0
- package/dist/story/controls/index.d.ts +54 -0
- package/dist/story/crosswind.d.ts +29 -0
- package/dist/story/desktop-preview.d.ts +34 -0
- package/dist/story/docs-generator.d.ts +30 -0
- package/dist/story/errors.d.ts +47 -0
- package/dist/story/figma-export.d.ts +169 -0
- package/dist/story/generator.d.ts +21 -0
- package/dist/story/hmr.d.ts +64 -0
- package/dist/story/hot-swap.d.ts +35 -0
- package/dist/story/index.d.ts +51 -0
- package/dist/story/interactions.d.ts +52 -0
- package/dist/story/keyboard-shortcuts.d.ts +34 -0
- package/dist/story/output.d.ts +85 -0
- package/dist/story/performance.d.ts +76 -0
- package/dist/story/presets.d.ts +62 -0
- package/dist/story/props-validation.d.ts +45 -0
- package/dist/story/renderer.d.ts +53 -0
- package/dist/story/search-index.d.ts +47 -0
- package/dist/story/search.d.ts +45 -0
- package/dist/story/server.d.ts +21 -0
- package/dist/story/setup.d.ts +47 -0
- package/dist/story/snapshots.d.ts +65 -0
- package/dist/story/testing.d.ts +58 -0
- package/dist/story/theme.d.ts +68 -0
- package/dist/story/types.d.ts +249 -0
- package/dist/story/ui/code-panel.d.ts +42 -0
- package/dist/story/ui/controls-panel.d.ts +25 -0
- package/dist/story/ui/index.d.ts +4 -0
- package/dist/story/ui/navigation.d.ts +55 -0
- package/dist/story/ui/preview.d.ts +46 -0
- package/dist/story/visual-testing.d.ts +45 -0
- package/dist/streaming.d.ts +82 -2
- package/dist/suspense.d.ts +83 -0
- package/dist/teleport.d.ts +9 -0
- package/dist/testing.d.ts +289 -0
- package/dist/transitions.d.ts +87 -0
- package/dist/type-checker.d.ts +109 -0
- package/dist/types/component-types.d.ts +129 -0
- package/dist/types/config-types.d.ts +336 -0
- package/dist/types/context-types.d.ts +99 -0
- package/dist/types/csp-types.d.ts +79 -0
- package/dist/types/directive-types.d.ts +259 -0
- package/dist/types/index.d.ts +98 -0
- package/dist/types/pwa-types.d.ts +218 -0
- package/dist/types.d.ts +1 -315
- package/dist/typescript-templates.d.ts +178 -0
- package/dist/utils.d.ts +52 -6
- package/dist/validator.d.ts +77 -0
- package/dist/variable-extractor.d.ts +39 -0
- package/dist/view-composers.d.ts +154 -9
- package/dist/virtual-scrolling.d.ts +103 -0
- package/dist/visual-editor.d.ts +209 -0
- package/dist/visual-testing.d.ts +109 -0
- package/dist/visual-testing.js +126 -0
- package/dist/vue-template.d.ts +16 -0
- package/dist/web-components/css-scoping.d.ts +54 -0
- package/dist/web-components/index.d.ts +20 -0
- package/dist/web-components/reactive-generator.d.ts +72 -0
- package/dist/web-components.d.ts +222 -2
- package/dist/x-element.d.ts +35 -0
- package/package.json +41 -11
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Get a cached regex pattern or compile and cache it
|
|
2
|
+
* Get a cached regex pattern or compile and cache it.
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: For global patterns (flags include 'g'), this function returns
|
|
5
|
+
* a NEW RegExp instance each time to avoid shared `lastIndex` state issues.
|
|
6
|
+
* Only non-global patterns are cached.
|
|
7
|
+
*
|
|
8
|
+
* @param pattern - The regex pattern string
|
|
9
|
+
* @param flags - Optional regex flags (e.g., 'i', 'g', 'gi')
|
|
10
|
+
* @returns A RegExp instance (cached for non-global, new for global)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Safe to cache - non-global pattern
|
|
15
|
+
* const pattern = getCachedRegex('@if\\s*\\(', 'i')
|
|
16
|
+
*
|
|
17
|
+
* // Not cached - global patterns always return new instance
|
|
18
|
+
* const global = getCachedRegex('@directive', 'g')
|
|
19
|
+
* ```
|
|
3
20
|
*/
|
|
4
21
|
export declare function getCachedRegex(pattern: string, flags?: string): RegExp;
|
|
22
|
+
/**
|
|
23
|
+
* Clear the regex cache (useful for testing)
|
|
24
|
+
*/
|
|
25
|
+
export declare function clearRegexCache(): void;
|
|
5
26
|
/**
|
|
6
27
|
* Debounce function calls to avoid excessive processing
|
|
7
28
|
*/
|
|
@@ -18,10 +39,113 @@ export declare function memoize<T extends (...args: any[]) => any>(func: T, maxC
|
|
|
18
39
|
* Optimized string replacement that reuses regex patterns with case-preserving support
|
|
19
40
|
*/
|
|
20
41
|
export declare function optimizedReplace(text: string, pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string), flags?: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the global performance monitor instance (lazy-loaded)
|
|
44
|
+
* This avoids instantiating the monitor until it's actually needed
|
|
45
|
+
*/
|
|
46
|
+
export declare function getPerformanceMonitor(): PerformanceMonitor;
|
|
47
|
+
/**
|
|
48
|
+
* Apply default performance budgets to the monitor
|
|
49
|
+
*/
|
|
50
|
+
export declare function applyDefaultBudgets(monitor?: PerformanceMonitor): void;
|
|
51
|
+
/**
|
|
52
|
+
* Reset the performance monitor instance (useful for testing)
|
|
53
|
+
*/
|
|
54
|
+
export declare function resetPerformanceMonitor(): void;
|
|
21
55
|
// Global expression evaluator pool
|
|
22
56
|
export declare const expressionEvaluatorPool: ExpressionEvaluatorPool;
|
|
23
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Default performance budgets for common operations
|
|
59
|
+
*/
|
|
60
|
+
export declare const defaultPerformanceBudgets: {
|
|
61
|
+
processDirectives: {
|
|
62
|
+
maxTime: 500;
|
|
63
|
+
warnThreshold: 0.8;
|
|
64
|
+
action: 'warn'
|
|
65
|
+
};
|
|
66
|
+
processTemplate: {
|
|
67
|
+
maxTime: 200;
|
|
68
|
+
warnThreshold: 0.8;
|
|
69
|
+
action: 'warn'
|
|
70
|
+
};
|
|
71
|
+
processIncludes: {
|
|
72
|
+
maxTime: 100;
|
|
73
|
+
warnThreshold: 0.8;
|
|
74
|
+
action: 'warn'
|
|
75
|
+
};
|
|
76
|
+
processLoops: {
|
|
77
|
+
maxTime: 50;
|
|
78
|
+
warnThreshold: 0.8;
|
|
79
|
+
action: 'warn'
|
|
80
|
+
};
|
|
81
|
+
processConditionals: {
|
|
82
|
+
maxTime: 50;
|
|
83
|
+
warnThreshold: 0.8;
|
|
84
|
+
action: 'warn'
|
|
85
|
+
};
|
|
86
|
+
processExpressions: {
|
|
87
|
+
maxTime: 100;
|
|
88
|
+
warnThreshold: 0.8;
|
|
89
|
+
action: 'warn'
|
|
90
|
+
};
|
|
91
|
+
renderComponent: {
|
|
92
|
+
maxTime: 150;
|
|
93
|
+
warnThreshold: 0.8;
|
|
94
|
+
action: 'warn'
|
|
95
|
+
};
|
|
96
|
+
buildWebComponents: {
|
|
97
|
+
maxTime: 1000;
|
|
98
|
+
warnThreshold: 0.8;
|
|
99
|
+
action: 'warn'
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Global performance monitor instance
|
|
104
|
+
* @deprecated Use getPerformanceMonitor() for lazy loading
|
|
105
|
+
*/
|
|
24
106
|
export declare const performanceMonitor: PerformanceMonitor;
|
|
107
|
+
/**
|
|
108
|
+
* Performance budget configuration
|
|
109
|
+
*/
|
|
110
|
+
export declare interface PerformanceBudget {
|
|
111
|
+
maxTime: number
|
|
112
|
+
warnThreshold?: number
|
|
113
|
+
action?: 'log' | 'warn' | 'error' | 'throw'
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Performance budget violation event
|
|
117
|
+
*/
|
|
118
|
+
export declare interface BudgetViolation {
|
|
119
|
+
label: string
|
|
120
|
+
actualTime: number
|
|
121
|
+
budgetTime: number
|
|
122
|
+
exceedancePercent: number
|
|
123
|
+
timestamp: Date
|
|
124
|
+
isWarning: boolean
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Performance budget violation handler type
|
|
128
|
+
*/
|
|
129
|
+
export type BudgetViolationHandler = (violation: BudgetViolation) => void
|
|
130
|
+
/**
|
|
131
|
+
* Performance optimization utilities for stx
|
|
132
|
+
*/
|
|
133
|
+
/**
|
|
134
|
+
* Generic LRU (Least Recently Used) cache implementation
|
|
135
|
+
* Automatically evicts least recently used items when capacity is reached
|
|
136
|
+
*/
|
|
137
|
+
export declare class LRUCache<K, V> {
|
|
138
|
+
private cache: any;
|
|
139
|
+
readonly private maxSize: number;
|
|
140
|
+
constructor(maxSize?: number);
|
|
141
|
+
get(key: K): V | undefined;
|
|
142
|
+
set(key: K, value: V): void;
|
|
143
|
+
has(key: K): boolean;
|
|
144
|
+
delete(key: K): boolean;
|
|
145
|
+
clear(): void;
|
|
146
|
+
keys(): IterableIterator<K>;
|
|
147
|
+
values(): IterableIterator<V>;
|
|
148
|
+
}
|
|
25
149
|
/**
|
|
26
150
|
* Cache for template processing results
|
|
27
151
|
*/
|
|
@@ -46,13 +170,32 @@ declare class ExpressionEvaluatorPool {
|
|
|
46
170
|
clear(): void;
|
|
47
171
|
}
|
|
48
172
|
/**
|
|
49
|
-
* Performance monitor for tracking processing times
|
|
173
|
+
* Performance monitor for tracking processing times with budget support
|
|
50
174
|
*/
|
|
51
175
|
export declare class PerformanceMonitor {
|
|
52
176
|
private metrics: any;
|
|
177
|
+
private budgets: any;
|
|
178
|
+
private violations: BudgetViolation[];
|
|
179
|
+
private maxViolations: any;
|
|
180
|
+
private violationHandlers: BudgetViolationHandler[];
|
|
181
|
+
private enabled: any;
|
|
182
|
+
setEnabled(enabled: boolean): void;
|
|
183
|
+
isEnabled(): boolean;
|
|
184
|
+
setBudget(label: string, budget: PerformanceBudget): void;
|
|
185
|
+
setBudgets(budgets: Record<string, PerformanceBudget>): void;
|
|
186
|
+
removeBudget(label: string): void;
|
|
187
|
+
getBudgets(): Record<string, PerformanceBudget>;
|
|
188
|
+
onViolation(handler: BudgetViolationHandler): void;
|
|
189
|
+
offViolation(handler: BudgetViolationHandler): void;
|
|
53
190
|
time<T>(label: string, fn: () => T): T;
|
|
54
191
|
timeAsync<T>(label: string, fn: () => Promise<T>): Promise<T>;
|
|
192
|
+
private checkBudget(label: string, duration: number): void;
|
|
55
193
|
recordTime(label: string, duration: number): void;
|
|
56
194
|
getStats(label?: string): Record<string, any>;
|
|
195
|
+
getViolations(label?: string): BudgetViolation[];
|
|
196
|
+
getViolationStats(): { total: number, byLabel: Record<string, number>, warnings: number, errors: number };
|
|
57
197
|
clear(): void;
|
|
198
|
+
clearViolations(): void;
|
|
199
|
+
clearBudgets(): void;
|
|
200
|
+
reset(): void;
|
|
58
201
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { CustomDirective, StxOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create a plugin with type safety
|
|
4
|
+
*/
|
|
5
|
+
export declare function definePlugin(plugin: StxPlugin): StxPlugin;
|
|
6
|
+
/**
|
|
7
|
+
* Create a simple directive plugin
|
|
8
|
+
*/
|
|
9
|
+
export declare function createDirectivePlugin(name: string, directives: CustomDirective[], options?: Partial<Omit<StxPlugin, 'name' | 'registerDirectives'>>): StxPlugin;
|
|
10
|
+
/**
|
|
11
|
+
* Create a simple filter plugin
|
|
12
|
+
*/
|
|
13
|
+
export declare function createFilterPlugin(name: string, filters: Record<string, (value: unknown, ...args: unknown[]) => unknown>, options?: Partial<Omit<StxPlugin, 'name' | 'registerFilters'>>): StxPlugin;
|
|
14
|
+
/**
|
|
15
|
+
* Variables plugin that adds common variables to context
|
|
16
|
+
*/
|
|
17
|
+
export declare function createVariablesPlugin(variables: Record<string, unknown>): StxPlugin;
|
|
18
|
+
/**
|
|
19
|
+
* Global plugin manager instance
|
|
20
|
+
*/
|
|
21
|
+
export declare const pluginManager: PluginManager;
|
|
22
|
+
/**
|
|
23
|
+
* Debug plugin that logs all lifecycle events
|
|
24
|
+
*/
|
|
25
|
+
export declare const debugPlugin: StxPlugin;
|
|
26
|
+
/**
|
|
27
|
+
* Timing plugin that measures processing time
|
|
28
|
+
*/
|
|
29
|
+
export declare const timingPlugin: StxPlugin;
|
|
30
|
+
/**
|
|
31
|
+
* Context passed to lifecycle hooks
|
|
32
|
+
*/
|
|
33
|
+
export declare interface PluginContext {
|
|
34
|
+
template: string
|
|
35
|
+
context: Record<string, unknown>
|
|
36
|
+
filePath: string
|
|
37
|
+
options: StxOptions
|
|
38
|
+
dependencies: Set<string>
|
|
39
|
+
metadata: Record<string, unknown>
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result from a lifecycle hook
|
|
43
|
+
*/
|
|
44
|
+
export declare interface PluginHookResult {
|
|
45
|
+
template?: string
|
|
46
|
+
context?: Record<string, unknown>
|
|
47
|
+
skip?: boolean
|
|
48
|
+
metadata?: Record<string, unknown>
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Error context passed to onError hook
|
|
52
|
+
*/
|
|
53
|
+
export declare interface PluginErrorContext extends PluginContext {
|
|
54
|
+
error: Error
|
|
55
|
+
phase: string
|
|
56
|
+
directive?: string
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Plugin definition interface
|
|
60
|
+
*/
|
|
61
|
+
export declare interface StxPlugin {
|
|
62
|
+
name: string
|
|
63
|
+
version?: string
|
|
64
|
+
description?: string
|
|
65
|
+
dependencies?: string[]
|
|
66
|
+
priority?: number
|
|
67
|
+
beforeProcess?: (ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
|
|
68
|
+
afterParse?: (ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
|
|
69
|
+
beforeDirective?: (phase: DirectivePhase, ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
|
|
70
|
+
afterDirective?: (phase: DirectivePhase, ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
|
|
71
|
+
beforeRender?: (ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
|
|
72
|
+
afterRender?: (ctx: PluginContext) => PluginHookResult | Promise<PluginHookResult> | void
|
|
73
|
+
onError?: (ctx: PluginErrorContext) => PluginHookResult | Promise<PluginHookResult> | void
|
|
74
|
+
registerDirectives?: () => CustomDirective[]
|
|
75
|
+
registerFilters?: () => Record<string, (value: unknown, ...args: unknown[]) => unknown>
|
|
76
|
+
onRegister?: (options: StxOptions) => void | Promise<void>
|
|
77
|
+
onUnregister?: () => void | Promise<void>
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Directive type identifier for beforeDirective/afterDirective hooks
|
|
81
|
+
*/
|
|
82
|
+
export type DirectivePhase = | 'comments'
|
|
83
|
+
| 'escaped'
|
|
84
|
+
| 'stacks'
|
|
85
|
+
| 'layouts'
|
|
86
|
+
| 'includes'
|
|
87
|
+
| 'js'
|
|
88
|
+
| 'ts'
|
|
89
|
+
| 'custom'
|
|
90
|
+
| 'components'
|
|
91
|
+
| 'animation'
|
|
92
|
+
| 'routes'
|
|
93
|
+
| 'auth'
|
|
94
|
+
| 'csrf'
|
|
95
|
+
| 'method'
|
|
96
|
+
| 'loops'
|
|
97
|
+
| 'conditionals'
|
|
98
|
+
| 'forms'
|
|
99
|
+
| 'markdown'
|
|
100
|
+
| 'i18n'
|
|
101
|
+
| 'a11y'
|
|
102
|
+
| 'seo'
|
|
103
|
+
| 'expressions'
|
|
104
|
+
/**
|
|
105
|
+
* Plugin manager that handles registration, lifecycle, and execution
|
|
106
|
+
*/
|
|
107
|
+
export declare class PluginManager {
|
|
108
|
+
private plugins: Map<string, StxPlugin>;
|
|
109
|
+
private sortedPlugins: StxPlugin[];
|
|
110
|
+
private initialized: any;
|
|
111
|
+
register(plugin: StxPlugin, options: StxOptions): Promise<void>;
|
|
112
|
+
unregister(name: string): Promise<boolean>;
|
|
113
|
+
get(name: string): StxPlugin | undefined;
|
|
114
|
+
has(name: string): boolean;
|
|
115
|
+
getAll(): StxPlugin[];
|
|
116
|
+
getAllDirectives(): CustomDirective[];
|
|
117
|
+
getAllFilters(): Record<string, (value: unknown, ...args: unknown[]) => unknown>;
|
|
118
|
+
runBeforeProcess(ctx: PluginContext): Promise<PluginContext>;
|
|
119
|
+
runAfterParse(ctx: PluginContext): Promise<PluginContext>;
|
|
120
|
+
runBeforeDirective(phase: DirectivePhase, ctx: PluginContext): Promise<PluginContext>;
|
|
121
|
+
runAfterDirective(phase: DirectivePhase, ctx: PluginContext): Promise<PluginContext>;
|
|
122
|
+
runBeforeRender(ctx: PluginContext): Promise<PluginContext>;
|
|
123
|
+
runAfterRender(ctx: PluginContext): Promise<PluginContext>;
|
|
124
|
+
runOnError(ctx: PluginErrorContext): Promise<PluginContext | null>;
|
|
125
|
+
private sortPlugins(): void;
|
|
126
|
+
private runHooks(hookName: 'beforeProcess' | 'afterParse' | 'beforeRender' | 'afterRender', ctx: PluginContext): Promise<PluginContext>;
|
|
127
|
+
private runDirectiveHooks(hookName: 'beforeDirective' | 'afterDirective', phase: DirectivePhase, ctx: PluginContext): Promise<PluginContext>;
|
|
128
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { SourceMapGenerator } from './source-maps';
|
|
2
|
+
import { TemplateParser, } from './ast';
|
|
3
|
+
import type { ASTNode, AttributeNode, ComponentNode, DirectiveNode, DocumentNode, ElementNode, ExpressionNode, } from './ast';
|
|
4
|
+
import type { SourceMapV3 } from './source-maps';
|
|
5
|
+
// Export singleton instance
|
|
6
|
+
export declare const compiler: TemplateCompiler;
|
|
7
|
+
/**
|
|
8
|
+
* Compilation options
|
|
9
|
+
*/
|
|
10
|
+
export declare interface CompileOptions {
|
|
11
|
+
filename?: string
|
|
12
|
+
mode?: CompileMode
|
|
13
|
+
optimize?: boolean
|
|
14
|
+
sourceMaps?: boolean
|
|
15
|
+
module?: 'esm' | 'cjs' | 'iife'
|
|
16
|
+
functionName?: string
|
|
17
|
+
includeRuntime?: boolean
|
|
18
|
+
dev?: boolean
|
|
19
|
+
inlineDirectives?: string[]
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Compilation result
|
|
23
|
+
*/
|
|
24
|
+
export declare interface CompileResult {
|
|
25
|
+
code: string
|
|
26
|
+
map?: SourceMapV3
|
|
27
|
+
analysis: {
|
|
28
|
+
/** Variables used in expressions */
|
|
29
|
+
usedVariables: Set<string>
|
|
30
|
+
/** Directives used */
|
|
31
|
+
usedDirectives: Set<string>
|
|
32
|
+
/** Components used */
|
|
33
|
+
usedComponents: Set<string>
|
|
34
|
+
/** Whether template has dynamic content */
|
|
35
|
+
isDynamic: boolean
|
|
36
|
+
/** Whether template uses slots */
|
|
37
|
+
hasSlots: boolean
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
declare interface CodegenContext {
|
|
41
|
+
code: string
|
|
42
|
+
indentLevel: number
|
|
43
|
+
sourceMapGenerator?: SourceMapGenerator
|
|
44
|
+
currentLine: number
|
|
45
|
+
currentColumn: number
|
|
46
|
+
sourceFile: string
|
|
47
|
+
mode: CompileMode
|
|
48
|
+
optimize: boolean
|
|
49
|
+
dev: boolean
|
|
50
|
+
usedVariables: Set<string>
|
|
51
|
+
usedDirectives: Set<string>
|
|
52
|
+
usedComponents: Set<string>
|
|
53
|
+
hasSlots: boolean
|
|
54
|
+
varCounter: number
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Compilation mode
|
|
58
|
+
*/
|
|
59
|
+
export type CompileMode = 'ssr' | 'client' | 'universal'
|
|
60
|
+
/**
|
|
61
|
+
* Template pre-compiler
|
|
62
|
+
*/
|
|
63
|
+
export declare class TemplateCompiler {
|
|
64
|
+
private parser: TemplateParser;
|
|
65
|
+
constructor();
|
|
66
|
+
compile(template: string, options?: CompileOptions): CompileResult;
|
|
67
|
+
compileFile(filePath: string, options?: CompileOptions): Promise<CompileResult>;
|
|
68
|
+
private createContext(options: {
|
|
69
|
+
sourceFile: string
|
|
70
|
+
mode: CompileMode
|
|
71
|
+
optimize: boolean
|
|
72
|
+
dev: boolean
|
|
73
|
+
sourceMaps: boolean
|
|
74
|
+
}): CodegenContext;
|
|
75
|
+
private generateRenderFunction(ast: DocumentNode, ctx: CodegenContext): string;
|
|
76
|
+
private analyzeAST(ast: DocumentNode, ctx: CodegenContext): void;
|
|
77
|
+
private generateNode(node: ASTNode, ctx: CodegenContext): string;
|
|
78
|
+
private generateText(text: string, _ctx: CodegenContext): string;
|
|
79
|
+
private generateExpression(node: ExpressionNode, _ctx: CodegenContext): string;
|
|
80
|
+
private generateDirective(node: DirectiveNode, ctx: CodegenContext): string;
|
|
81
|
+
private generateIf(condition: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
82
|
+
private generateUnless(condition: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
83
|
+
private generateForeach(params: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
84
|
+
private generateFor(params: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
85
|
+
private generateWhile(condition: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
86
|
+
private generateIsset(params: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
87
|
+
private generateEmpty(params: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
88
|
+
private generateAuth(body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
89
|
+
private generateGuest(body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
90
|
+
private generateEnv(params: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
91
|
+
private generateSwitch(params: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
92
|
+
private generateSlot(params: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
93
|
+
private generateSection(params: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
94
|
+
private generatePush(params: string | null, body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
95
|
+
private generateOnce(body: ASTNode[] | null, ctx: CodegenContext): string;
|
|
96
|
+
private generateScript(body: ASTNode[] | null, _ctx: CodegenContext): string;
|
|
97
|
+
private generateStyle(node: { content: string, scoped: boolean }, _ctx: CodegenContext): string;
|
|
98
|
+
private generateElement(node: ElementNode, ctx: CodegenContext): string;
|
|
99
|
+
private generateAttribute(attr: AttributeNode, ctx: CodegenContext): string;
|
|
100
|
+
private parseAttributeValue(value: string, ctx: CodegenContext): string;
|
|
101
|
+
private generateComponent(node: ComponentNode, ctx: CodegenContext): string;
|
|
102
|
+
private splitConditionalBody(body: ASTNode[]): {
|
|
103
|
+
ifBody: ASTNode[]
|
|
104
|
+
elseifs: Array<{ condition: string, body: ASTNode[] }>
|
|
105
|
+
elseBody: ASTNode[]
|
|
106
|
+
};
|
|
107
|
+
private wrapModule(functionCode: string, functionName: string, format: 'esm' | 'cjs' | 'iife', _ctx: CodegenContext): string;
|
|
108
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create and run a production build
|
|
3
|
+
*/
|
|
4
|
+
export declare function build(config: ProductionBuildConfig): Promise<BuildResult>;
|
|
5
|
+
/**
|
|
6
|
+
* Create a production build instance
|
|
7
|
+
*/
|
|
8
|
+
export declare function createProductionBuild(config: ProductionBuildConfig): ProductionBuild;
|
|
9
|
+
/**
|
|
10
|
+
* Default production config
|
|
11
|
+
*/
|
|
12
|
+
export declare function defineConfig(config: ProductionBuildConfig): ProductionBuildConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Production build configuration
|
|
15
|
+
*/
|
|
16
|
+
export declare interface ProductionBuildConfig {
|
|
17
|
+
entry: string | string[] | Record<string, string>
|
|
18
|
+
outDir: string
|
|
19
|
+
publicPath?: string
|
|
20
|
+
sourcemaps?: boolean | 'inline' | 'external' | 'hidden'
|
|
21
|
+
minify?: boolean | MinifyOptions
|
|
22
|
+
splitting?: boolean | SplittingOptions
|
|
23
|
+
css?: CssOptions
|
|
24
|
+
assets?: AssetOptions
|
|
25
|
+
compression?: CompressionOptions
|
|
26
|
+
analyze?: boolean | AnalyzeOptions
|
|
27
|
+
target?: string | string[]
|
|
28
|
+
define?: Record<string, string>
|
|
29
|
+
external?: string[]
|
|
30
|
+
plugins?: BuildPlugin[]
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Minification options
|
|
34
|
+
*/
|
|
35
|
+
export declare interface MinifyOptions {
|
|
36
|
+
js?: boolean
|
|
37
|
+
css?: boolean
|
|
38
|
+
html?: boolean
|
|
39
|
+
dropConsole?: boolean
|
|
40
|
+
dropDebugger?: boolean
|
|
41
|
+
mangle?: boolean
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Code splitting options
|
|
45
|
+
*/
|
|
46
|
+
export declare interface SplittingOptions {
|
|
47
|
+
vendor?: boolean
|
|
48
|
+
minSize?: number
|
|
49
|
+
maxSize?: number
|
|
50
|
+
chunkNames?: 'hash' | 'named' | 'deterministic'
|
|
51
|
+
manualChunks?: Record<string, string[]>
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* CSS options
|
|
55
|
+
*/
|
|
56
|
+
export declare interface CssOptions {
|
|
57
|
+
extract?: boolean
|
|
58
|
+
modules?: boolean | CssModulesOptions
|
|
59
|
+
postcss?: boolean | object
|
|
60
|
+
minify?: boolean
|
|
61
|
+
filename?: string
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* CSS modules options
|
|
65
|
+
*/
|
|
66
|
+
export declare interface CssModulesOptions {
|
|
67
|
+
pattern?: string
|
|
68
|
+
sourcemap?: boolean
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Asset options
|
|
72
|
+
*/
|
|
73
|
+
export declare interface AssetOptions {
|
|
74
|
+
inlineLimit?: number
|
|
75
|
+
filename?: string
|
|
76
|
+
hash?: boolean
|
|
77
|
+
hashLength?: number
|
|
78
|
+
include?: string[]
|
|
79
|
+
exclude?: string[]
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Compression options
|
|
83
|
+
*/
|
|
84
|
+
export declare interface CompressionOptions {
|
|
85
|
+
gzip?: boolean
|
|
86
|
+
brotli?: boolean
|
|
87
|
+
threshold?: number
|
|
88
|
+
deleteOriginal?: boolean
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Bundle analysis options
|
|
92
|
+
*/
|
|
93
|
+
export declare interface AnalyzeOptions {
|
|
94
|
+
format?: 'html' | 'json' | 'text'
|
|
95
|
+
filename?: string
|
|
96
|
+
open?: boolean
|
|
97
|
+
gzipSize?: boolean
|
|
98
|
+
brotliSize?: boolean
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Build plugin interface
|
|
102
|
+
*/
|
|
103
|
+
export declare interface BuildPlugin {
|
|
104
|
+
name: string
|
|
105
|
+
setup?: (build: ProductionBuild) => void | Promise<void>
|
|
106
|
+
buildStart?: () => void | Promise<void>
|
|
107
|
+
transform?: (code: string, id: string) => string | Promise<string> | null
|
|
108
|
+
buildEnd?: (result: BuildResult) => void | Promise<void>
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Build result
|
|
112
|
+
*/
|
|
113
|
+
export declare interface BuildResult {
|
|
114
|
+
outputs: OutputFile[]
|
|
115
|
+
duration: number
|
|
116
|
+
totalSize: number
|
|
117
|
+
gzipSize: number
|
|
118
|
+
chunks: ChunkInfo[]
|
|
119
|
+
assets: AssetInfo[]
|
|
120
|
+
warnings: string[]
|
|
121
|
+
errors: string[]
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Output file info
|
|
125
|
+
*/
|
|
126
|
+
export declare interface OutputFile {
|
|
127
|
+
path: string
|
|
128
|
+
type: 'js' | 'css' | 'html' | 'asset' | 'map'
|
|
129
|
+
size: number
|
|
130
|
+
gzipSize?: number
|
|
131
|
+
hash?: string
|
|
132
|
+
sources?: string[]
|
|
133
|
+
isEntry?: boolean
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Chunk info
|
|
137
|
+
*/
|
|
138
|
+
export declare interface ChunkInfo {
|
|
139
|
+
name: string
|
|
140
|
+
file: string
|
|
141
|
+
size: number
|
|
142
|
+
modules: string[]
|
|
143
|
+
isVendor?: boolean
|
|
144
|
+
imports: string[]
|
|
145
|
+
dynamicImports: string[]
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Asset info
|
|
149
|
+
*/
|
|
150
|
+
export declare interface AssetInfo {
|
|
151
|
+
name: string
|
|
152
|
+
file: string
|
|
153
|
+
size: number
|
|
154
|
+
source: string
|
|
155
|
+
mimeType?: string
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Production Build orchestrator
|
|
159
|
+
*/
|
|
160
|
+
export declare class ProductionBuild {
|
|
161
|
+
private config: ProductionBuildConfig;
|
|
162
|
+
private startTime: number;
|
|
163
|
+
private outputs: OutputFile[];
|
|
164
|
+
private chunks: ChunkInfo[];
|
|
165
|
+
private assets: AssetInfo[];
|
|
166
|
+
private warnings: string[];
|
|
167
|
+
private errors: string[];
|
|
168
|
+
private moduleGraph: Map<string, Set<string>>;
|
|
169
|
+
private assetHashes: Map<string, string>;
|
|
170
|
+
constructor(config: ProductionBuildConfig);
|
|
171
|
+
build(): Promise<BuildResult>;
|
|
172
|
+
private collectEntries(): Map<string, string>;
|
|
173
|
+
private buildEntry(name: string, entryPath: string): Promise<void>;
|
|
174
|
+
private resolveRelativePath(from: string, to: string): string;
|
|
175
|
+
private processTemplate(content: string, filePath: string): Promise<string>;
|
|
176
|
+
private processCss(content: string, filePath: string): Promise<string>;
|
|
177
|
+
private processScript(content: string, filePath: string): Promise<string>;
|
|
178
|
+
private extractCss(): Promise<void>;
|
|
179
|
+
private processAssets(): Promise<void>;
|
|
180
|
+
private performCodeSplitting(): Promise<void>;
|
|
181
|
+
private minifyOutputs(): Promise<void>;
|
|
182
|
+
private minifyJs(code: string): string;
|
|
183
|
+
private minifyCss(css: string): string;
|
|
184
|
+
private minifyHtml(html: string): string;
|
|
185
|
+
private generateSourceMaps(): Promise<void>;
|
|
186
|
+
private fingerprintAssets(): Promise<void>;
|
|
187
|
+
private compressOutputs(): Promise<void>;
|
|
188
|
+
private analyzeBundle(): Promise<void>;
|
|
189
|
+
private generateAnalysisHtml(analysis: any): string;
|
|
190
|
+
private generateAnalysisText(analysis: any): string;
|
|
191
|
+
private runPluginHook(hook: string, arg?: any): Promise<void>;
|
|
192
|
+
private runPluginTransform(code: string, id: string): Promise<string>;
|
|
193
|
+
private generateHash(content: string | Buffer): string;
|
|
194
|
+
private getOutputName(name: string, type: OutputFile['type'], hash: string): string;
|
|
195
|
+
private formatSize(bytes: number): string;
|
|
196
|
+
private ensureDir(dir: string): void;
|
|
197
|
+
private walkDir(dir: string, callback: (path: string) => void): void;
|
|
198
|
+
private getResult(): BuildResult;
|
|
199
|
+
}
|