@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.
Files changed (275) hide show
  1. package/dist/a11y.d.ts +109 -5
  2. package/dist/analytics.d.ts +40 -0
  3. package/dist/animation.d.ts +90 -0
  4. package/dist/app.d.ts +51 -0
  5. package/dist/ast.d.ts +286 -0
  6. package/dist/async-components.d.ts +101 -0
  7. package/dist/auth.d.ts +1 -3
  8. package/dist/browser-composables.d.ts +314 -0
  9. package/dist/build-optimizer.d.ts +126 -0
  10. package/dist/build-views.d.ts +37 -0
  11. package/dist/bundle-analyzer/collector.d.ts +66 -0
  12. package/dist/bundle-analyzer/index.d.ts +60 -0
  13. package/dist/bundle-analyzer/report.d.ts +39 -0
  14. package/dist/bundle-analyzer/treemap.d.ts +19 -0
  15. package/dist/bundle-analyzer.js +499 -0
  16. package/dist/caching.d.ts +7 -0
  17. package/dist/cli.js +10880 -1199
  18. package/dist/client/directive.d.ts +10 -0
  19. package/dist/client/index.d.ts +7 -0
  20. package/dist/client/router.d.ts +36 -0
  21. package/dist/client/stx-router.browser.d.ts +0 -0
  22. package/dist/client-script.d.ts +22 -0
  23. package/dist/component-hmr.d.ts +120 -0
  24. package/dist/components.d.ts +23 -1
  25. package/dist/composables/index.d.ts +277 -0
  26. package/dist/composables/use-battery.d.ts +46 -0
  27. package/dist/composables/use-broadcast-channel.d.ts +58 -0
  28. package/dist/composables/use-clipboard.d.ts +34 -0
  29. package/dist/composables/use-cookie.d.ts +70 -0
  30. package/dist/composables/use-device-orientation.d.ts +109 -0
  31. package/dist/composables/use-event-source.d.ts +77 -0
  32. package/dist/composables/use-eye-dropper.d.ts +107 -0
  33. package/dist/composables/use-fetch.d.ts +84 -0
  34. package/dist/composables/use-fullscreen.d.ts +47 -0
  35. package/dist/composables/use-geolocation.d.ts +62 -0
  36. package/dist/composables/use-idle.d.ts +84 -0
  37. package/dist/composables/use-intersection-observer.d.ts +81 -0
  38. package/dist/composables/use-keyboard.d.ts +100 -0
  39. package/dist/composables/use-media-query.d.ts +56 -0
  40. package/dist/composables/use-mouse.d.ts +64 -0
  41. package/dist/composables/use-mutation-observer.d.ts +101 -0
  42. package/dist/composables/use-network.d.ts +40 -0
  43. package/dist/composables/use-notification.d.ts +89 -0
  44. package/dist/composables/use-permissions.d.ts +109 -0
  45. package/dist/composables/use-resize-observer.d.ts +60 -0
  46. package/dist/composables/use-share.d.ts +70 -0
  47. package/dist/composables/use-speech.d.ts +117 -0
  48. package/dist/composables/use-storage.d.ts +64 -0
  49. package/dist/composables/use-text-selection.d.ts +97 -0
  50. package/dist/composables/use-wake-lock.d.ts +85 -0
  51. package/dist/composables/use-websocket.d.ts +69 -0
  52. package/dist/composables/use-window.d.ts +84 -0
  53. package/dist/composables.d.ts +268 -0
  54. package/dist/composition-api.d.ts +190 -0
  55. package/dist/computed.d.ts +137 -0
  56. package/dist/conditionals.d.ts +14 -2
  57. package/dist/config.d.ts +35 -2
  58. package/dist/craft-bridge.d.ts +319 -0
  59. package/dist/craft-compiler.d.ts +229 -0
  60. package/dist/craft-components.d.ts +411 -0
  61. package/dist/craft-entry.d.ts +5 -0
  62. package/dist/craft-ssr.d.ts +134 -0
  63. package/dist/craft.js +1553 -0
  64. package/dist/csp.d.ts +229 -0
  65. package/dist/database.d.ts +407 -0
  66. package/dist/database.js +5 -0
  67. package/dist/defer.d.ts +4 -0
  68. package/dist/deploy/config-generators.d.ts +75 -0
  69. package/dist/deploy/index.d.ts +84 -0
  70. package/dist/deploy/netlify.d.ts +109 -0
  71. package/dist/dev-server/crosswind.d.ts +54 -0
  72. package/dist/dev-server/index.d.ts +7 -0
  73. package/dist/dev-server/keyboard-shortcuts.d.ts +34 -0
  74. package/dist/dev-server/native-window.d.ts +40 -0
  75. package/dist/dev-server/port-utils.d.ts +27 -0
  76. package/dist/dev-server/terminal-colors.d.ts +60 -0
  77. package/dist/dev-server/theme-selector.d.ts +32 -0
  78. package/dist/dev-server/types.d.ts +92 -0
  79. package/dist/dev-server.d.ts +21 -0
  80. package/dist/devtools.d.ts +142 -0
  81. package/dist/directive-api.d.ts +111 -0
  82. package/dist/dynamic-components.d.ts +14 -0
  83. package/dist/edge-runtime.d.ts +200 -0
  84. package/dist/env.d.ts +9 -0
  85. package/dist/error-boundaries.d.ts +71 -0
  86. package/dist/error-handling.d.ts +1 -101
  87. package/dist/errors/codes.d.ts +99 -0
  88. package/dist/errors/formatter.d.ts +64 -0
  89. package/dist/errors/index.d.ts +56 -0
  90. package/dist/errors/logger.d.ts +74 -0
  91. package/dist/errors/sanitizer.d.ts +43 -0
  92. package/dist/errors/types.d.ts +79 -0
  93. package/dist/events.d.ts +106 -0
  94. package/dist/expressions.d.ts +86 -11
  95. package/dist/forms-validation.d.ts +173 -0
  96. package/dist/forms.d.ts +157 -8
  97. package/dist/head.d.ts +225 -0
  98. package/dist/heatmap.d.ts +125 -0
  99. package/dist/hot-reload.d.ts +87 -0
  100. package/dist/hydration-runtime.d.ts +47 -0
  101. package/dist/hydration.d.ts +161 -0
  102. package/dist/i18n.d.ts +239 -3
  103. package/dist/image-optimization/build-plugin.d.ts +53 -0
  104. package/dist/image-optimization/component.d.ts +46 -0
  105. package/dist/image-optimization/directive.d.ts +30 -0
  106. package/dist/image-optimization/index.d.ts +86 -0
  107. package/dist/image-optimization/processor.d.ts +112 -0
  108. package/dist/includes.d.ts +94 -9
  109. package/dist/index.d.ts +63 -3
  110. package/dist/index.js +11603 -1318
  111. package/dist/init.d.ts +32 -2
  112. package/dist/interactive.d.ts +14 -0
  113. package/dist/internal-markdown.d.ts +22 -0
  114. package/dist/jsx-runtime.d.ts +110 -0
  115. package/dist/keep-alive.d.ts +87 -0
  116. package/dist/lazy-loader.d.ts +122 -0
  117. package/dist/loading-indicator.d.ts +40 -0
  118. package/dist/loops.d.ts +22 -1
  119. package/dist/media/client/blur-up.d.ts +65 -0
  120. package/dist/media/client/index.d.ts +77 -0
  121. package/dist/media/client/lazy-load.d.ts +73 -0
  122. package/dist/media/client/upload-handler.d.ts +79 -0
  123. package/dist/media/image/component.d.ts +46 -0
  124. package/dist/media/image/directive.d.ts +9 -0
  125. package/dist/media/image/editing.d.ts +212 -0
  126. package/dist/media/image/index.d.ts +118 -0
  127. package/dist/media/image/placeholder.d.ts +78 -0
  128. package/dist/media/image/processor/cache.d.ts +32 -0
  129. package/dist/media/image/processor/index.d.ts +12 -0
  130. package/dist/media/image/processor/optimizer.d.ts +13 -0
  131. package/dist/media/image/processor/responsive.d.ts +17 -0
  132. package/dist/media/image/srcset.d.ts +158 -0
  133. package/dist/media/index.d.ts +295 -0
  134. package/dist/media/manager/embed.d.ts +25 -0
  135. package/dist/media/protected/component.d.ts +34 -0
  136. package/dist/media/protected/index.d.ts +34 -0
  137. package/dist/media/protected/signature.d.ts +72 -0
  138. package/dist/media/shared/cache.d.ts +54 -0
  139. package/dist/media/shared/hash.d.ts +24 -0
  140. package/dist/media/shared/index.d.ts +2 -0
  141. package/dist/media/types.d.ts +1051 -0
  142. package/dist/media/upload/component.d.ts +23 -0
  143. package/dist/media/upload/index.d.ts +1 -0
  144. package/dist/media/video/directive.d.ts +9 -0
  145. package/dist/media/video/index.d.ts +47 -0
  146. package/dist/media/video/processor/cache.d.ts +33 -0
  147. package/dist/media/video/processor/index.d.ts +21 -0
  148. package/dist/media/video/processor/streaming.d.ts +19 -0
  149. package/dist/media/video/processor/thumbnail.d.ts +28 -0
  150. package/dist/media/video/processor/transcoder.d.ts +9 -0
  151. package/dist/middleware.d.ts +42 -3
  152. package/dist/native-build.d.ts +74 -0
  153. package/dist/parser/directive-parser.d.ts +79 -0
  154. package/dist/parser/expression-parser.d.ts +59 -0
  155. package/dist/parser/index.d.ts +35 -0
  156. package/dist/parser/tokenizer.d.ts +81 -0
  157. package/dist/partial-hydration.d.ts +88 -0
  158. package/dist/performance-utils.d.ts +146 -3
  159. package/dist/plugin-system.d.ts +128 -0
  160. package/dist/precompiler.d.ts +108 -0
  161. package/dist/production-build.d.ts +199 -0
  162. package/dist/props.d.ts +199 -0
  163. package/dist/pwa/audit.d.ts +42 -0
  164. package/dist/pwa/directives.d.ts +29 -0
  165. package/dist/pwa/icons.d.ts +39 -0
  166. package/dist/pwa/index.d.ts +59 -0
  167. package/dist/pwa/inject.d.ts +22 -0
  168. package/dist/pwa/manifest.d.ts +104 -0
  169. package/dist/pwa/offline.d.ts +8 -0
  170. package/dist/pwa/precache.d.ts +29 -0
  171. package/dist/pwa/service-worker.d.ts +21 -0
  172. package/dist/pwa/workbox-strategies.d.ts +100 -0
  173. package/dist/pwa/workbox.d.ts +52 -0
  174. package/dist/pwa.d.ts +51 -0
  175. package/dist/pwa.js +8124 -0
  176. package/dist/reactive-bindings.d.ts +24 -0
  177. package/dist/reactive.d.ts +100 -0
  178. package/dist/reactivity.d.ts +253 -0
  179. package/dist/route-middleware.d.ts +232 -0
  180. package/dist/router.d.ts +31 -0
  181. package/dist/routes.d.ts +0 -7
  182. package/dist/runtime.d.ts +140 -0
  183. package/dist/safe-evaluator.d.ts +117 -3
  184. package/dist/scaffolding.d.ts +113 -0
  185. package/dist/seo.d.ts +120 -7
  186. package/dist/server-components.d.ts +134 -0
  187. package/dist/signals.d.ts +501 -0
  188. package/dist/slots.d.ts +63 -0
  189. package/dist/source-maps.d.ts +117 -0
  190. package/dist/ssg.d.ts +157 -0
  191. package/dist/ssg.js +6831 -0
  192. package/dist/ssr.d.ts +107 -0
  193. package/dist/state-management.d.ts +324 -0
  194. package/dist/stores-client.d.ts +70 -0
  195. package/dist/story/addons.d.ts +123 -0
  196. package/dist/story/analytics.d.ts +92 -0
  197. package/dist/story/auto-stories.d.ts +38 -0
  198. package/dist/story/bookmarks.d.ts +53 -0
  199. package/dist/story/bun-test.d.ts +44 -0
  200. package/dist/story/cli.d.ts +34 -0
  201. package/dist/story/collect/analyzer.d.ts +33 -0
  202. package/dist/story/collect/index.d.ts +27 -0
  203. package/dist/story/collect/parser.d.ts +17 -0
  204. package/dist/story/collect/scanner.d.ts +13 -0
  205. package/dist/story/collect/tree.d.ts +17 -0
  206. package/dist/story/commands/build.d.ts +14 -0
  207. package/dist/story/commands/dev.d.ts +16 -0
  208. package/dist/story/commands/index.d.ts +6 -0
  209. package/dist/story/commands/preview.d.ts +15 -0
  210. package/dist/story/compiled-output.d.ts +26 -0
  211. package/dist/story/composition.d.ts +47 -0
  212. package/dist/story/config-watcher.d.ts +26 -0
  213. package/dist/story/config.d.ts +26 -0
  214. package/dist/story/context.d.ts +21 -0
  215. package/dist/story/controls/index.d.ts +54 -0
  216. package/dist/story/crosswind.d.ts +29 -0
  217. package/dist/story/desktop-preview.d.ts +34 -0
  218. package/dist/story/docs-generator.d.ts +30 -0
  219. package/dist/story/errors.d.ts +47 -0
  220. package/dist/story/figma-export.d.ts +169 -0
  221. package/dist/story/generator.d.ts +21 -0
  222. package/dist/story/hmr.d.ts +64 -0
  223. package/dist/story/hot-swap.d.ts +35 -0
  224. package/dist/story/index.d.ts +51 -0
  225. package/dist/story/interactions.d.ts +52 -0
  226. package/dist/story/keyboard-shortcuts.d.ts +34 -0
  227. package/dist/story/output.d.ts +85 -0
  228. package/dist/story/performance.d.ts +76 -0
  229. package/dist/story/presets.d.ts +62 -0
  230. package/dist/story/props-validation.d.ts +45 -0
  231. package/dist/story/renderer.d.ts +53 -0
  232. package/dist/story/search-index.d.ts +47 -0
  233. package/dist/story/search.d.ts +45 -0
  234. package/dist/story/server.d.ts +21 -0
  235. package/dist/story/setup.d.ts +47 -0
  236. package/dist/story/snapshots.d.ts +65 -0
  237. package/dist/story/testing.d.ts +58 -0
  238. package/dist/story/theme.d.ts +68 -0
  239. package/dist/story/types.d.ts +249 -0
  240. package/dist/story/ui/code-panel.d.ts +42 -0
  241. package/dist/story/ui/controls-panel.d.ts +25 -0
  242. package/dist/story/ui/index.d.ts +4 -0
  243. package/dist/story/ui/navigation.d.ts +55 -0
  244. package/dist/story/ui/preview.d.ts +46 -0
  245. package/dist/story/visual-testing.d.ts +45 -0
  246. package/dist/streaming.d.ts +82 -2
  247. package/dist/suspense.d.ts +83 -0
  248. package/dist/teleport.d.ts +9 -0
  249. package/dist/testing.d.ts +289 -0
  250. package/dist/transitions.d.ts +87 -0
  251. package/dist/type-checker.d.ts +109 -0
  252. package/dist/types/component-types.d.ts +129 -0
  253. package/dist/types/config-types.d.ts +336 -0
  254. package/dist/types/context-types.d.ts +99 -0
  255. package/dist/types/csp-types.d.ts +79 -0
  256. package/dist/types/directive-types.d.ts +259 -0
  257. package/dist/types/index.d.ts +98 -0
  258. package/dist/types/pwa-types.d.ts +218 -0
  259. package/dist/types.d.ts +1 -315
  260. package/dist/typescript-templates.d.ts +178 -0
  261. package/dist/utils.d.ts +52 -6
  262. package/dist/validator.d.ts +77 -0
  263. package/dist/variable-extractor.d.ts +39 -0
  264. package/dist/view-composers.d.ts +154 -9
  265. package/dist/virtual-scrolling.d.ts +103 -0
  266. package/dist/visual-editor.d.ts +209 -0
  267. package/dist/visual-testing.d.ts +109 -0
  268. package/dist/visual-testing.js +126 -0
  269. package/dist/vue-template.d.ts +16 -0
  270. package/dist/web-components/css-scoping.d.ts +54 -0
  271. package/dist/web-components/index.d.ts +20 -0
  272. package/dist/web-components/reactive-generator.d.ts +72 -0
  273. package/dist/web-components.d.ts +222 -2
  274. package/dist/x-element.d.ts +35 -0
  275. package/package.json +41 -11
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Enable STX DevTools.
3
+ */
4
+ export declare function enableDevTools(options?: {
5
+ maxEvents?: number
6
+ maxPerformance?: number
7
+ }): void;
8
+ /**
9
+ * Disable STX DevTools.
10
+ */
11
+ export declare function disableDevTools(): void;
12
+ /**
13
+ * Register a component with DevTools.
14
+ */
15
+ export declare function registerComponent(name: string, element: HTMLElement, props?: Record<string, unknown>, state?: Record<string, unknown>, file?: string): string;
16
+ /**
17
+ * Update component state in DevTools.
18
+ */
19
+ export declare function updateComponentState(id: string, state: Record<string, unknown>): void;
20
+ /**
21
+ * Update component props in DevTools.
22
+ */
23
+ export declare function updateComponentProps(id: string, props: Record<string, unknown>): void;
24
+ /**
25
+ * Unregister a component from DevTools.
26
+ */
27
+ export declare function unregisterComponent(id: string): void;
28
+ /**
29
+ * Register a store with DevTools.
30
+ */
31
+ export declare function registerStore(id: string, initialState: Record<string, unknown>, getters?: Record<string, unknown>, actions?: string[]): void;
32
+ /**
33
+ * Record a store mutation.
34
+ */
35
+ export declare function recordStoreMutation(storeId: string, name: string, oldValue: unknown, newValue: unknown, type?: 'state' | 'action'): void;
36
+ /**
37
+ * Update store getters.
38
+ */
39
+ export declare function updateStoreGetters(storeId: string, getters: Record<string, unknown>): void;
40
+ /**
41
+ * Record an event in the timeline.
42
+ */
43
+ export declare function recordEvent(event: EventRecord): void;
44
+ /**
45
+ * Record a performance metric.
46
+ */
47
+ export declare function recordPerformance(metric: PerformanceMetric): void;
48
+ /**
49
+ * Measure execution time of a function.
50
+ */
51
+ export declare function measurePerformance<T>(name: string, fn: () => T, componentId?: string): T;
52
+ /**
53
+ * Measure async execution time.
54
+ */
55
+ export declare function measurePerformanceAsync<T>(name: string, fn: () => Promise<T>, componentId?: string): Promise<T>;
56
+ /**
57
+ * STX DevTools Integration
58
+ *
59
+ * Provides debugging and inspection tools for STX applications.
60
+ *
61
+ * @module devtools
62
+ *
63
+ * @example
64
+ * ```html
65
+ * <script>
66
+ * import { enableDevTools } from 'stx'
67
+ *
68
+ * // Enable DevTools in development
69
+ * if (process.env.NODE_ENV === 'development') {
70
+ * enableDevTools()
71
+ * }
72
+ * </script>
73
+ * ```
74
+ */
75
+ // =============================================================================
76
+ // Types
77
+ // =============================================================================
78
+ export declare interface ComponentInfo {
79
+ id: string
80
+ name: string
81
+ file?: string
82
+ parentId?: string
83
+ children: string[]
84
+ props: Record<string, unknown>
85
+ state: Record<string, unknown>
86
+ exposed: string[]
87
+ element?: HTMLElement
88
+ renderCount: number
89
+ lastRenderTime: number
90
+ createdAt: number
91
+ }
92
+ export declare interface StoreInfo {
93
+ id: string
94
+ state: Record<string, unknown>
95
+ getters: Record<string, unknown>
96
+ actions: string[]
97
+ history: MutationRecord[]
98
+ }
99
+ export declare interface MutationRecord {
100
+ timestamp: number
101
+ type: 'state' | 'action'
102
+ name: string
103
+ oldValue?: unknown
104
+ newValue?: unknown
105
+ stack?: string
106
+ }
107
+ export declare interface EventRecord {
108
+ timestamp: number
109
+ type: string
110
+ componentId?: string
111
+ payload: unknown
112
+ target?: string
113
+ }
114
+ export declare interface PerformanceMetric {
115
+ name: string
116
+ duration: number
117
+ timestamp: number
118
+ componentId?: string
119
+ metadata?: Record<string, unknown>
120
+ }
121
+ export declare interface DevToolsState {
122
+ enabled: boolean
123
+ components: Map<string, ComponentInfo>
124
+ stores: Map<string, StoreInfo>
125
+ events: EventRecord[]
126
+ performance: PerformanceMetric[]
127
+ selectedComponent: string | null
128
+ selectedStore: string | null
129
+ maxEvents: number
130
+ maxPerformance: number
131
+ }
132
+ export {
133
+ devToolsState,
134
+ selectComponent,
135
+ selectStore,
136
+ inspectElement,
137
+ highlightComponent,
138
+ clearHighlight,
139
+ logComponentTree,
140
+ logStoreState,
141
+ timeTravel,
142
+ };
@@ -0,0 +1,111 @@
1
+ import type { CustomDirective } from './types';
2
+ /**
3
+ * Register a directive globally.
4
+ */
5
+ export declare function registerDirective<P extends DirectiveParams = DirectiveParams>(definition: FullDirectiveDefinition<P>): void;
6
+ /**
7
+ * Get a registered directive.
8
+ */
9
+ export declare function getDirective(name: string): FullDirectiveDefinition | undefined;
10
+ /**
11
+ * Get all registered directives.
12
+ */
13
+ export declare function getDirectives(): FullDirectiveDefinition[];
14
+ /**
15
+ * Unregister a directive.
16
+ */
17
+ export declare function unregisterDirective(name: string): boolean;
18
+ /**
19
+ * Define a custom directive.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Simple transform directive
24
+ * const uppercase = defineDirective({
25
+ * name: 'uppercase',
26
+ * transform: (content) => content.toUpperCase()
27
+ * })
28
+ *
29
+ * // Directive with parameters and validation
30
+ * const truncate = defineDirective({
31
+ * name: 'truncate',
32
+ * defaults: { length: 100, suffix: '...' },
33
+ * validate: ({ length }) => length > 0 || 'Length must be positive',
34
+ * transform: (content, { length, suffix }) =>
35
+ * content.length > length
36
+ * ? content.slice(0, length) + suffix
37
+ * : content
38
+ * })
39
+ *
40
+ * // Client-side directive
41
+ * const tooltip = defineDirective({
42
+ * name: 'tooltip',
43
+ * transform: (content, { text }) =>
44
+ * `<span data-tooltip="${text}">${content}</span>`,
45
+ * client: {
46
+ * mounted(el, { value }) {
47
+ * el.title = value
48
+ * }
49
+ * }
50
+ * })
51
+ * ```
52
+ */
53
+ export declare function defineDirective<P extends DirectiveParams = DirectiveParams, T = unknown>(definition: FullDirectiveDefinition<P, T>): CustomDirective;
54
+ /**
55
+ * Define a client-only directive.
56
+ */
57
+ export declare function defineClientDirective<T = unknown>(name: string, definition: ClientDirectiveDefinition<T> | ((el: HTMLElement, binding: DirectiveBinding<T>) => void)): ClientDirectiveDefinition<T>;
58
+ /**
59
+ * Create common built-in directives.
60
+ */
61
+ export declare function createBuiltinDirectives(): CustomDirective[];
62
+ /**
63
+ * Generate client-side directive runtime.
64
+ */
65
+ export declare function generateDirectiveRuntime(): string;
66
+ /**
67
+ * Process v-directive attributes in templates.
68
+ * Converts v-directive:arg.mod="value" to data attributes and client setup.
69
+ */
70
+ export declare function processDirectiveAttributes(template: string): string;
71
+ /** Directive binding for client-side directives */
72
+ export declare interface DirectiveBinding<T = unknown> {
73
+ value: T
74
+ oldValue?: T
75
+ arg?: string
76
+ modifiers: Record<string, boolean>
77
+ instance: unknown
78
+ dir: ClientDirectiveDefinition<T>
79
+ }
80
+ /** Server-side directive definition */
81
+ export declare interface DirectiveDefinition<P extends DirectiveParams = DirectiveParams> {
82
+ name: string
83
+ hasEndTag?: boolean
84
+ description?: string
85
+ transform?: (
86
+ content: string,
87
+ params: P,
88
+ context: Record<string, unknown>,
89
+ filePath: string,
90
+ ) => string | Promise<string>
91
+ validate?: (params: P) => boolean | string
92
+ defaults?: Partial<P>
93
+ clientScript?: (params: P) => string
94
+ css?: (params: P) => string
95
+ }
96
+ /** Client-side directive hooks */
97
+ export declare interface ClientDirectiveDefinition<T = unknown> {
98
+ created?: (el: HTMLElement, binding: DirectiveBinding<T>) => void
99
+ beforeMount?: (el: HTMLElement, binding: DirectiveBinding<T>) => void
100
+ mounted?: (el: HTMLElement, binding: DirectiveBinding<T>) => void
101
+ beforeUpdate?: (el: HTMLElement, binding: DirectiveBinding<T>) => void
102
+ updated?: (el: HTMLElement, binding: DirectiveBinding<T>) => void
103
+ beforeUnmount?: (el: HTMLElement, binding: DirectiveBinding<T>) => void
104
+ unmounted?: (el: HTMLElement, binding: DirectiveBinding<T>) => void
105
+ }
106
+ /** Combined directive (server + client) */
107
+ export declare interface FullDirectiveDefinition<P extends DirectiveParams = DirectiveParams, T = unknown> extends DirectiveDefinition<P> {
108
+ client?: ClientDirectiveDefinition<T>
109
+ }
110
+ /** Directive parameter types */
111
+ export type DirectiveParams = Record<string, unknown>
@@ -0,0 +1,14 @@
1
+ import type { StxOptions } from './types';
2
+ /**
3
+ * Process `<component :is="expr">` tags in the template.
4
+ * Evaluates the :is expression against the context to determine which
5
+ * component to render, then resolves and renders that component inline.
6
+ *
7
+ * @param template - The template string
8
+ * @param context - Current template context
9
+ * @param filePath - Current file path
10
+ * @param options - stx options
11
+ * @param dependencies - Dependency tracking set
12
+ * @returns Processed template with dynamic components resolved
13
+ */
14
+ export declare function processDynamicComponents(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies?: Set<string>): Promise<string>;
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Detect the current edge runtime platform.
3
+ */
4
+ export declare function detectRuntime(): RuntimeInfo;
5
+ /**
6
+ * Check if running in an edge environment.
7
+ */
8
+ export declare function isEdgeEnvironment(): boolean;
9
+ /**
10
+ * Check if running in a server environment (including edge).
11
+ */
12
+ export declare function isServerEnvironment(): boolean;
13
+ /**
14
+ * Create a platform-agnostic environment accessor.
15
+ */
16
+ export declare function createEnvAccessor(platformEnv?: Record<string, unknown>): EnvAccessor;
17
+ /**
18
+ * Create a platform-agnostic KV namespace.
19
+ */
20
+ export declare function createKVNamespace(platformKV?: unknown): KVNamespace | undefined;
21
+ /**
22
+ * Create a platform-agnostic cache.
23
+ */
24
+ export declare function createEdgeCache(): EdgeCache | undefined;
25
+ /**
26
+ * Create an edge handler.
27
+ */
28
+ export declare function createEdgeHandler(config: EdgeHandlerConfig): void;
29
+ /**
30
+ * Create a streaming response for edge platforms.
31
+ */
32
+ export declare function createStreamingResponse(stream: ReadableStream<Uint8Array>, options?: ResponseInit): Response;
33
+ /**
34
+ * Create a text encoder stream.
35
+ */
36
+ export declare function createTextEncoderStream(): TransformStream<string, Uint8Array>;
37
+ /**
38
+ * Pipe strings to a streaming response.
39
+ */
40
+ export declare function stringToStream(strings: AsyncIterable<string>): ReadableStream<Uint8Array>;
41
+ /**
42
+ * Create a Cloudflare Workers handler.
43
+ */
44
+ export declare function createCloudflareHandler(config: EdgeHandlerConfig): {
45
+ fetch: (request: Request, env: Record<string, unknown>, ctx: { waitUntil: (p: Promise<unknown>) => void }) => Promise<Response>
46
+ };
47
+ /**
48
+ * Create a Deno Deploy handler.
49
+ */
50
+ export declare function createDenoHandler(config: EdgeHandlerConfig): (request: Request) => Promise<Response>;
51
+ /**
52
+ * Create a Vercel Edge handler.
53
+ */
54
+ export declare function createVercelHandler(config: EdgeHandlerConfig): (request: Request) => Promise<Response>;
55
+ /**
56
+ * Create a Netlify Edge handler.
57
+ */
58
+ export declare function createNetlifyHandler(config: EdgeHandlerConfig): (request: Request, context: { geo?: GeoInfo }) => Promise<Response>;
59
+ /**
60
+ * Parse cookies from request.
61
+ */
62
+ export declare function parseCookies(request: Request): Record<string, string>;
63
+ /**
64
+ * Create a Set-Cookie header value.
65
+ */
66
+ export declare function createCookie(name: string, value: string, options?: {
67
+ maxAge?: number
68
+ expires?: Date
69
+ path?: string
70
+ domain?: string
71
+ secure?: boolean
72
+ httpOnly?: boolean
73
+ sameSite?: 'Strict' | 'Lax' | 'None'
74
+ }): string;
75
+ /**
76
+ * JSON response helper.
77
+ */
78
+ export declare function jsonResponse(data: unknown, init?: ResponseInit): Response;
79
+ /**
80
+ * Redirect response helper.
81
+ */
82
+ export declare function redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): Response;
83
+ /**
84
+ * Not found response helper.
85
+ */
86
+ export declare function notFound(message?: any): Response;
87
+ /** Edge runtime detection result */
88
+ export declare interface RuntimeInfo {
89
+ platform: EdgePlatform
90
+ version?: string
91
+ supportsStreaming: boolean
92
+ supportsCrypto: boolean
93
+ supportsKV: boolean
94
+ supportsCache: boolean
95
+ capabilities: string[]
96
+ }
97
+ /** Edge handler configuration */
98
+ export declare interface EdgeHandlerConfig {
99
+ render: (request: Request, context: EdgeContext) => Promise<Response | string>
100
+ onError?: (error: Error, request: Request) => Response
101
+ middleware?: EdgeMiddleware[]
102
+ cache?: EdgeCacheConfig
103
+ cors?: CorsConfig
104
+ }
105
+ /** Edge context passed to handlers */
106
+ export declare interface EdgeContext {
107
+ runtime: RuntimeInfo
108
+ platform: Record<string, unknown>
109
+ requestId: string
110
+ geo?: GeoInfo
111
+ timing: {
112
+ start: number
113
+ getElapsed: () => number
114
+ }
115
+ kv?: KVNamespace
116
+ cache?: EdgeCache
117
+ env: EnvAccessor
118
+ }
119
+ /** Geographic information */
120
+ export declare interface GeoInfo {
121
+ city?: string
122
+ country?: string
123
+ countryCode?: string
124
+ region?: string
125
+ latitude?: number
126
+ longitude?: number
127
+ timezone?: string
128
+ }
129
+ /** Cache configuration */
130
+ export declare interface EdgeCacheConfig {
131
+ enabled: boolean
132
+ ttl?: number
133
+ keyGenerator?: (request: Request) => string
134
+ includePaths?: RegExp[]
135
+ excludePaths?: RegExp[]
136
+ staleWhileRevalidate?: number
137
+ }
138
+ /** CORS configuration */
139
+ export declare interface CorsConfig {
140
+ origins?: string[] | '*'
141
+ methods?: string[]
142
+ headers?: string[]
143
+ exposeHeaders?: string[]
144
+ credentials?: boolean
145
+ maxAge?: number
146
+ }
147
+ /** KV namespace interface (platform-agnostic) */
148
+ export declare interface KVNamespace {
149
+ get: (key: string) => Promise<string | null>
150
+ getWithMetadata: <T>(key: string) => Promise<{ value: string | null, metadata: T | null }>
151
+ put: (key: string, value: string, options?: KVPutOptions) => Promise<void>
152
+ delete: (key: string) => Promise<void>
153
+ list: (options?: KVListOptions) => Promise<KVListResult>
154
+ }
155
+ /** KV put options */
156
+ export declare interface KVPutOptions {
157
+ expiration?: number
158
+ expirationTtl?: number
159
+ metadata?: Record<string, unknown>
160
+ }
161
+ /** KV list options */
162
+ export declare interface KVListOptions {
163
+ prefix?: string
164
+ limit?: number
165
+ cursor?: string
166
+ }
167
+ /** KV list result */
168
+ export declare interface KVListResult {
169
+ keys: { name: string, expiration?: number, metadata?: Record<string, unknown> }[]
170
+ cursor?: string
171
+ list_complete: boolean
172
+ }
173
+ /** Edge cache interface */
174
+ export declare interface EdgeCache {
175
+ match: (request: Request) => Promise<Response | undefined>
176
+ put: (request: Request, response: Response) => Promise<void>
177
+ delete: (request: Request) => Promise<boolean>
178
+ }
179
+ /** Environment variable accessor */
180
+ export declare interface EnvAccessor {
181
+ get: (key: string) => string | undefined
182
+ getOrThrow: (key: string) => string
183
+ has: (key: string) => boolean
184
+ all: () => Record<string, string>
185
+ }
186
+ /** Supported edge runtime platforms */
187
+ export type EdgePlatform = | 'cloudflare'
188
+ | 'deno'
189
+ | 'vercel'
190
+ | 'netlify'
191
+ | 'fastly'
192
+ | 'node'
193
+ | 'bun'
194
+ | 'unknown'
195
+ /** Middleware function */
196
+ export type EdgeMiddleware = (
197
+ request: Request,
198
+ context: EdgeContext,
199
+ next: () => Promise<Response>
200
+ ) => Promise<Response>
package/dist/env.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns true when running in production mode
3
+ */
4
+ export declare function isProduction(): boolean;
5
+ /**
6
+ * Returns true when NOT in production mode, or when debug is enabled.
7
+ * This covers development, test, and unset environments.
8
+ */
9
+ export declare function isDevelopment(): boolean;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Process @errorBoundary directives in templates.
3
+ *
4
+ * Syntax:
5
+ * @errorBoundary
6
+ * <content that might error>
7
+ * @fallback
8
+ * <fallback content shown on error>
9
+ * @enderrorBoundary
10
+ *
11
+ * Or with options:
12
+ * @errorBoundary(id: 'my-boundary', logErrors: false)
13
+ */
14
+ export declare function processErrorBoundaryDirectives(template: string, context?: Record<string, unknown>, _filePath?: string): string;
15
+ /**
16
+ * Wrap content in a try/catch for SSR error handling.
17
+ * Returns the fallback if an error occurs during rendering.
18
+ */
19
+ export declare function withErrorBoundary<T>(render: () => T | Promise<T>, fallback: T, onError?: (error: Error) => void): Promise<T>;
20
+ /**
21
+ * Create an error boundary wrapper function.
22
+ */
23
+ export declare function createErrorBoundary<T>(fallback: T, options?: ErrorBoundaryOptions): (render: () => T | Promise<T>) => Promise<T>;
24
+ /**
25
+ * Generate CSS for error boundary styling.
26
+ */
27
+ export declare function generateErrorBoundaryCSS(): string;
28
+ /**
29
+ * Generate client-side runtime for error boundaries.
30
+ */
31
+ export declare function generateErrorBoundaryRuntime(): string;
32
+ /**
33
+ * STX Error Boundaries
34
+ *
35
+ * Provides graceful error handling for component trees.
36
+ * When an error occurs within an error boundary, the fallback content is shown
37
+ * instead of crashing the entire application.
38
+ *
39
+ * @module error-boundaries
40
+ *
41
+ * @example
42
+ * ```html
43
+ * @errorBoundary
44
+ * <RiskyComponent />
45
+ * @fallback
46
+ * <div class="error-state">
47
+ * <p>Something went wrong</p>
48
+ * <button @click="$retry()">Retry</button>
49
+ * </div>
50
+ * @enderrorBoundary
51
+ * ```
52
+ */
53
+ // =============================================================================
54
+ // Types
55
+ // =============================================================================
56
+ export declare interface ErrorBoundaryOptions {
57
+ onError?: (error: Error, info: ErrorInfo) => void
58
+ logErrors?: boolean
59
+ id?: string
60
+ }
61
+ export declare interface ErrorInfo {
62
+ componentName?: string
63
+ stack?: string
64
+ timestamp: number
65
+ boundaryId: string
66
+ }
67
+ export declare interface ErrorBoundaryState {
68
+ hasError: boolean
69
+ error: Error | null
70
+ info: ErrorInfo | null
71
+ }
@@ -1,101 +1 @@
1
- /**
2
- * Enhanced error reporting with better context
3
- */
4
- export declare function createEnhancedError(type: string, message: string, context: ErrorContext): string;
5
- /**
6
- * Safe wrapper for potentially dangerous operations
7
- */
8
- export declare function safeExecute<T>(operation: () => T, fallback: T, errorHandler?: (error: Error) => void): T;
9
- /**
10
- * Async version of safe wrapper
11
- */
12
- export declare function safeExecuteAsync<T>(operation: () => Promise<T>, fallback: T, errorHandler?: (error: Error) => void): Promise<T>;
13
- /**
14
- * Validation utilities
15
- */
16
- export declare const validators: {
17
- /**
18
- * Validate file path is safe
19
- */
20
- isValidFilePath(filePath: string): unknown
21
- };
22
- /**
23
- * Error recovery strategies
24
- */
25
- export declare const errorRecovery: {
26
- /**
27
- * Attempt to fix common template syntax errors
28
- */
29
- fixCommonSyntaxErrors(template: string): unknown;
30
- /**
31
- * Create fallback content for failed template sections
32
- */
33
- createFallbackContent(sectionType: string, error: Error): unknown
34
- };
35
- // Global error logger instance
36
- export declare const errorLogger: ErrorLogger;
37
- /**
38
- * Development mode helpers
39
- */
40
- export declare const devHelpers: {
41
- /**
42
- * Check if we're in development mode
43
- */
44
- isDevelopment(): boolean {
45
- return process.env.NODE_ENV === 'development' || process.env.stx_DEBUG === 'true'
46
- },
47
-
48
- /**
49
- * Log detailed error information in development
50
- */
51
- logDetailedError(error: Error, context?: any): void {
52
- if (!this.isDevelopment())
53
- return
54
-
55
- console.error('=== stx Detailed Error ===')
56
- console.error('Error: unknown
57
- };
58
- /**
59
- * Error context information
60
- */
61
- export declare interface ErrorContext {
62
- filePath: string
63
- template: string
64
- offset: number
65
- match: string
66
- }
67
- /**
68
- * Custom error types for better error classification
69
- */
70
- export declare class StxError extends Error {
71
- public code: string;
72
- public filePath?: string;
73
- public line?: number;
74
- public column?: number;
75
- public context?: string;
76
- constructor(message: string, code: string, filePath?: string, line?: number, column?: number, context?: string);
77
- }
78
- export declare class StxSyntaxError extends StxError {
79
- constructor(message: string, filePath?: string, line?: number, column?: number, context?: string);
80
- }
81
- export declare class StxRuntimeError extends StxError {
82
- constructor(message: string, filePath?: string, line?: number, column?: number, context?: string);
83
- }
84
- export declare class StxSecurityError extends StxError {
85
- constructor(message: string, filePath?: string, line?: number, column?: number, context?: string);
86
- }
87
- export declare class StxFileError extends StxError {
88
- constructor(message: string, filePath?: string, line?: number, column?: number, context?: string);
89
- }
90
- /**
91
- * Error logging and monitoring
92
- */
93
- export declare class ErrorLogger {
94
- private errors: Array<{ timestamp: Date, error: Error, context?: any }>;
95
- private maxErrors: any;
96
- log(error: Error, context?: any): void;
97
- getRecentErrors(limit?: any): Array<{ timestamp: Date, error: Error, context?: any }>;
98
- getErrorsByType(errorType: string): Array<{ timestamp: Date, error: Error, context?: any }>;
99
- clear(): void;
100
- getStats(): { total: number, byType: Record<string, number> };
101
- }
1
+ export * from './errors';