@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.
Files changed (277) hide show
  1. package/dist/a11y.d.ts +109 -5
  2. package/dist/analytics.d.ts +40 -0
  3. package/dist/animation.d.ts +91 -1
  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 +10885 -1203
  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 +36 -3
  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/formatter.d.ts +4 -0
  96. package/dist/forms-validation.d.ts +173 -0
  97. package/dist/forms.d.ts +157 -8
  98. package/dist/head.d.ts +225 -0
  99. package/dist/heatmap.d.ts +125 -0
  100. package/dist/hot-reload.d.ts +87 -0
  101. package/dist/hydration-runtime.d.ts +47 -0
  102. package/dist/hydration.d.ts +161 -0
  103. package/dist/i18n.d.ts +240 -4
  104. package/dist/image-optimization/build-plugin.d.ts +53 -0
  105. package/dist/image-optimization/component.d.ts +46 -0
  106. package/dist/image-optimization/directive.d.ts +30 -0
  107. package/dist/image-optimization/index.d.ts +86 -0
  108. package/dist/image-optimization/processor.d.ts +112 -0
  109. package/dist/includes.d.ts +94 -9
  110. package/dist/index.d.ts +63 -3
  111. package/dist/index.js +11604 -1318
  112. package/dist/init.d.ts +32 -2
  113. package/dist/interactive.d.ts +14 -0
  114. package/dist/internal-markdown.d.ts +22 -0
  115. package/dist/jsx-runtime.d.ts +110 -0
  116. package/dist/keep-alive.d.ts +87 -0
  117. package/dist/lazy-loader.d.ts +122 -0
  118. package/dist/loading-indicator.d.ts +40 -0
  119. package/dist/loops.d.ts +22 -1
  120. package/dist/media/client/blur-up.d.ts +65 -0
  121. package/dist/media/client/index.d.ts +77 -0
  122. package/dist/media/client/lazy-load.d.ts +73 -0
  123. package/dist/media/client/upload-handler.d.ts +79 -0
  124. package/dist/media/image/component.d.ts +46 -0
  125. package/dist/media/image/directive.d.ts +9 -0
  126. package/dist/media/image/editing.d.ts +212 -0
  127. package/dist/media/image/index.d.ts +118 -0
  128. package/dist/media/image/placeholder.d.ts +78 -0
  129. package/dist/media/image/processor/cache.d.ts +32 -0
  130. package/dist/media/image/processor/index.d.ts +12 -0
  131. package/dist/media/image/processor/optimizer.d.ts +13 -0
  132. package/dist/media/image/processor/responsive.d.ts +17 -0
  133. package/dist/media/image/srcset.d.ts +158 -0
  134. package/dist/media/index.d.ts +295 -0
  135. package/dist/media/manager/embed.d.ts +25 -0
  136. package/dist/media/protected/component.d.ts +34 -0
  137. package/dist/media/protected/index.d.ts +34 -0
  138. package/dist/media/protected/signature.d.ts +72 -0
  139. package/dist/media/shared/cache.d.ts +54 -0
  140. package/dist/media/shared/hash.d.ts +24 -0
  141. package/dist/media/shared/index.d.ts +2 -0
  142. package/dist/media/types.d.ts +1051 -0
  143. package/dist/media/upload/component.d.ts +23 -0
  144. package/dist/media/upload/index.d.ts +1 -0
  145. package/dist/media/video/directive.d.ts +9 -0
  146. package/dist/media/video/index.d.ts +47 -0
  147. package/dist/media/video/processor/cache.d.ts +33 -0
  148. package/dist/media/video/processor/index.d.ts +21 -0
  149. package/dist/media/video/processor/streaming.d.ts +19 -0
  150. package/dist/media/video/processor/thumbnail.d.ts +28 -0
  151. package/dist/media/video/processor/transcoder.d.ts +9 -0
  152. package/dist/middleware.d.ts +42 -3
  153. package/dist/native-build.d.ts +74 -0
  154. package/dist/parser/directive-parser.d.ts +79 -0
  155. package/dist/parser/expression-parser.d.ts +59 -0
  156. package/dist/parser/index.d.ts +35 -0
  157. package/dist/parser/tokenizer.d.ts +81 -0
  158. package/dist/partial-hydration.d.ts +88 -0
  159. package/dist/performance-utils.d.ts +146 -3
  160. package/dist/plugin-system.d.ts +128 -0
  161. package/dist/plugin.d.ts +1 -0
  162. package/dist/precompiler.d.ts +108 -0
  163. package/dist/production-build.d.ts +199 -0
  164. package/dist/props.d.ts +199 -0
  165. package/dist/pwa/audit.d.ts +42 -0
  166. package/dist/pwa/directives.d.ts +29 -0
  167. package/dist/pwa/icons.d.ts +39 -0
  168. package/dist/pwa/index.d.ts +59 -0
  169. package/dist/pwa/inject.d.ts +22 -0
  170. package/dist/pwa/manifest.d.ts +104 -0
  171. package/dist/pwa/offline.d.ts +8 -0
  172. package/dist/pwa/precache.d.ts +29 -0
  173. package/dist/pwa/service-worker.d.ts +21 -0
  174. package/dist/pwa/workbox-strategies.d.ts +100 -0
  175. package/dist/pwa/workbox.d.ts +52 -0
  176. package/dist/pwa.d.ts +51 -0
  177. package/dist/pwa.js +8124 -0
  178. package/dist/reactive-bindings.d.ts +24 -0
  179. package/dist/reactive.d.ts +100 -0
  180. package/dist/reactivity.d.ts +253 -0
  181. package/dist/route-middleware.d.ts +232 -0
  182. package/dist/router.d.ts +31 -0
  183. package/dist/routes.d.ts +0 -7
  184. package/dist/runtime.d.ts +140 -0
  185. package/dist/safe-evaluator.d.ts +117 -3
  186. package/dist/scaffolding.d.ts +113 -0
  187. package/dist/seo.d.ts +120 -7
  188. package/dist/server-components.d.ts +134 -0
  189. package/dist/signals.d.ts +501 -0
  190. package/dist/slots.d.ts +63 -0
  191. package/dist/source-maps.d.ts +117 -0
  192. package/dist/ssg.d.ts +157 -0
  193. package/dist/ssg.js +6831 -0
  194. package/dist/ssr.d.ts +107 -0
  195. package/dist/state-management.d.ts +324 -0
  196. package/dist/stores-client.d.ts +70 -0
  197. package/dist/story/addons.d.ts +123 -0
  198. package/dist/story/analytics.d.ts +92 -0
  199. package/dist/story/auto-stories.d.ts +38 -0
  200. package/dist/story/bookmarks.d.ts +53 -0
  201. package/dist/story/bun-test.d.ts +44 -0
  202. package/dist/story/cli.d.ts +34 -0
  203. package/dist/story/collect/analyzer.d.ts +33 -0
  204. package/dist/story/collect/index.d.ts +27 -0
  205. package/dist/story/collect/parser.d.ts +17 -0
  206. package/dist/story/collect/scanner.d.ts +13 -0
  207. package/dist/story/collect/tree.d.ts +17 -0
  208. package/dist/story/commands/build.d.ts +14 -0
  209. package/dist/story/commands/dev.d.ts +16 -0
  210. package/dist/story/commands/index.d.ts +6 -0
  211. package/dist/story/commands/preview.d.ts +15 -0
  212. package/dist/story/compiled-output.d.ts +26 -0
  213. package/dist/story/composition.d.ts +47 -0
  214. package/dist/story/config-watcher.d.ts +26 -0
  215. package/dist/story/config.d.ts +26 -0
  216. package/dist/story/context.d.ts +21 -0
  217. package/dist/story/controls/index.d.ts +54 -0
  218. package/dist/story/crosswind.d.ts +29 -0
  219. package/dist/story/desktop-preview.d.ts +34 -0
  220. package/dist/story/docs-generator.d.ts +30 -0
  221. package/dist/story/errors.d.ts +47 -0
  222. package/dist/story/figma-export.d.ts +169 -0
  223. package/dist/story/generator.d.ts +21 -0
  224. package/dist/story/hmr.d.ts +64 -0
  225. package/dist/story/hot-swap.d.ts +35 -0
  226. package/dist/story/index.d.ts +51 -0
  227. package/dist/story/interactions.d.ts +52 -0
  228. package/dist/story/keyboard-shortcuts.d.ts +34 -0
  229. package/dist/story/output.d.ts +85 -0
  230. package/dist/story/performance.d.ts +76 -0
  231. package/dist/story/presets.d.ts +62 -0
  232. package/dist/story/props-validation.d.ts +45 -0
  233. package/dist/story/renderer.d.ts +53 -0
  234. package/dist/story/search-index.d.ts +47 -0
  235. package/dist/story/search.d.ts +45 -0
  236. package/dist/story/server.d.ts +21 -0
  237. package/dist/story/setup.d.ts +47 -0
  238. package/dist/story/snapshots.d.ts +65 -0
  239. package/dist/story/testing.d.ts +58 -0
  240. package/dist/story/theme.d.ts +68 -0
  241. package/dist/story/types.d.ts +249 -0
  242. package/dist/story/ui/code-panel.d.ts +42 -0
  243. package/dist/story/ui/controls-panel.d.ts +25 -0
  244. package/dist/story/ui/index.d.ts +4 -0
  245. package/dist/story/ui/navigation.d.ts +55 -0
  246. package/dist/story/ui/preview.d.ts +46 -0
  247. package/dist/story/visual-testing.d.ts +45 -0
  248. package/dist/streaming.d.ts +82 -2
  249. package/dist/suspense.d.ts +83 -0
  250. package/dist/teleport.d.ts +9 -0
  251. package/dist/testing.d.ts +289 -0
  252. package/dist/transitions.d.ts +87 -0
  253. package/dist/type-checker.d.ts +109 -0
  254. package/dist/types/component-types.d.ts +129 -0
  255. package/dist/types/config-types.d.ts +336 -0
  256. package/dist/types/context-types.d.ts +99 -0
  257. package/dist/types/csp-types.d.ts +79 -0
  258. package/dist/types/directive-types.d.ts +259 -0
  259. package/dist/types/index.d.ts +98 -0
  260. package/dist/types/pwa-types.d.ts +218 -0
  261. package/dist/types.d.ts +1 -315
  262. package/dist/typescript-templates.d.ts +178 -0
  263. package/dist/utils.d.ts +52 -6
  264. package/dist/validator.d.ts +77 -0
  265. package/dist/variable-extractor.d.ts +39 -0
  266. package/dist/view-composers.d.ts +154 -9
  267. package/dist/virtual-scrolling.d.ts +103 -0
  268. package/dist/visual-editor.d.ts +209 -0
  269. package/dist/visual-testing.d.ts +109 -0
  270. package/dist/visual-testing.js +126 -0
  271. package/dist/vue-template.d.ts +16 -0
  272. package/dist/web-components/css-scoping.d.ts +54 -0
  273. package/dist/web-components/index.d.ts +20 -0
  274. package/dist/web-components/reactive-generator.d.ts +72 -0
  275. package/dist/web-components.d.ts +222 -2
  276. package/dist/x-element.d.ts +35 -0
  277. package/package.json +41 -10
@@ -0,0 +1,268 @@
1
+ /**
2
+ * Create a new component instance context.
3
+ * Called internally when a component script starts executing.
4
+ */
5
+ export declare function createComponentInstance(element?: Element): ComponentInstance;
6
+ /**
7
+ * Set the current component instance context.
8
+ */
9
+ export declare function setCurrentInstance(instance: ComponentInstance | null): void;
10
+ /**
11
+ * Get the current component instance context.
12
+ */
13
+ export declare function getCurrentInstance(): ComponentInstance | null;
14
+ /**
15
+ * Register a callback to run when the component is mounted to the DOM.
16
+ *
17
+ * @example
18
+ * ```html
19
+ * <script client>
20
+ * import { onMount } from 'stx'
21
+ *
22
+ * onMount(() => {
23
+ * console.log('Component mounted!')
24
+ *
25
+ * // Return cleanup function (optional)
26
+ * return () => {
27
+ * console.log('Cleanup on unmount')
28
+ * }
29
+ * })
30
+ * </script>
31
+ * ```
32
+ */
33
+ export declare function onMount(hook: LifecycleHook): void;
34
+ /**
35
+ * Register a callback to run when the component is destroyed/unmounted.
36
+ *
37
+ * @example
38
+ * ```html
39
+ * <script client>
40
+ * import { onMount, onDestroy } from 'stx'
41
+ *
42
+ * onMount(() => {
43
+ * const interval = setInterval(() => console.log('tick'), 1000)
44
+ *
45
+ * onDestroy(() => {
46
+ * clearInterval(interval)
47
+ * })
48
+ * })
49
+ * </script>
50
+ * ```
51
+ */
52
+ export declare function onDestroy(hook: CleanupFn): void;
53
+ /**
54
+ * Register a callback to run when the component updates.
55
+ *
56
+ * @example
57
+ * ```html
58
+ * <script client>
59
+ * import { onUpdate } from 'stx'
60
+ *
61
+ * onUpdate(() => {
62
+ * console.log('Component updated!')
63
+ * })
64
+ * </script>
65
+ * ```
66
+ */
67
+ export declare function onUpdate(hook: LifecycleHook): void;
68
+ /**
69
+ * Create a ref for holding a DOM element reference.
70
+ *
71
+ * @example
72
+ * ```html
73
+ * <script client>
74
+ * import { ref, onMount } from 'stx'
75
+ *
76
+ * const inputRef = ref<HTMLInputElement>()
77
+ *
78
+ * onMount(() => {
79
+ * inputRef.value?.focus()
80
+ * })
81
+ * </script>
82
+ *
83
+ * <input type="text" @ref="inputRef" />
84
+ * ```
85
+ */
86
+ export declare function ref<T = HTMLElement>(initialValue?: T | null): Ref<T>;
87
+ /**
88
+ * Create a named ref that can be bound via @ref="name" in templates.
89
+ */
90
+ export declare function namedRef<T = HTMLElement>(name: string, initialValue?: T | null): Ref<T>;
91
+ /**
92
+ * Watch a reactive source and run a callback when it changes.
93
+ *
94
+ * @example
95
+ * ```html
96
+ * <script client>
97
+ * import { watch } from 'stx'
98
+ * import { counterStore } from '@stores'
99
+ *
100
+ * watch(
101
+ * () => counterStore.count,
102
+ * (newVal, oldVal) => {
103
+ * console.log(`Count changed: ${oldVal} → ${newVal}`)
104
+ * }
105
+ * )
106
+ * </script>
107
+ * ```
108
+ */
109
+ export declare function watch<T>(source: WatchSource<T>, callback: WatchCallback<T>, options?: { immediate?: boolean }): () => void;
110
+ /**
111
+ * Create a computed value that updates when dependencies change.
112
+ *
113
+ * @example
114
+ * ```html
115
+ * <script client>
116
+ * import { computed } from 'stx'
117
+ * import { counterStore } from '@stores'
118
+ *
119
+ * const doubleCount = computed(() => counterStore.count * 2)
120
+ *
121
+ * // Access value
122
+ * console.log(doubleCount.value)
123
+ * </script>
124
+ * ```
125
+ */
126
+ export declare function computed<T>(getter: () => T): { readonly value: T };
127
+ /**
128
+ * Initialize a component and run its setup.
129
+ * This is called by the STX runtime when a component is created.
130
+ */
131
+ export declare function setupComponent(element: Element, setup: () => void): ComponentInstance;
132
+ /**
133
+ * Mount a component instance - runs onMount hooks.
134
+ */
135
+ export declare function mountComponent(instance: ComponentInstance): void;
136
+ /**
137
+ * Update a component instance - runs onUpdate hooks.
138
+ */
139
+ export declare function updateComponent(instance: ComponentInstance): void;
140
+ /**
141
+ * Destroy a component instance - runs cleanup and onDestroy hooks.
142
+ */
143
+ export declare function destroyComponent(instance: ComponentInstance): void;
144
+ /**
145
+ * Generate the client-side runtime script for lifecycle management.
146
+ */
147
+ export declare function generateLifecycleRuntime(): string;
148
+ /**
149
+ * Create a typed injection key.
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const ThemeKey = createInjectionKey<{ mode: 'dark' | 'light' }>('theme')
154
+ * ```
155
+ */
156
+ export declare function createInjectionKey<T>(description?: string): InjectionKey<T>;
157
+ /**
158
+ * Provide a value that can be injected by descendant components.
159
+ *
160
+ * @example
161
+ * ```html
162
+ * <script server>
163
+ * import { provide } from 'stx'
164
+ *
165
+ * // Provide a theme object
166
+ * provide('theme', { mode: 'dark', accent: 'purple' })
167
+ *
168
+ * // Or with a typed key
169
+ * import { ThemeKey } from './injection-keys'
170
+ * provide(ThemeKey, { mode: 'dark', accent: 'purple' })
171
+ * </script>
172
+ * ```
173
+ */
174
+ export declare function provide<T>(key: string | InjectionKey<T>, value: T): void;
175
+ /**
176
+ * Inject a value provided by an ancestor component.
177
+ *
178
+ * @example
179
+ * ```html
180
+ * <script client>
181
+ * import { inject } from 'stx'
182
+ *
183
+ * // Inject with default value
184
+ * const theme = inject('theme', { mode: 'light', accent: 'blue' })
185
+ *
186
+ * // Inject required value (throws if not provided)
187
+ * const auth = inject('auth')
188
+ * </script>
189
+ * ```
190
+ */
191
+ export declare function inject<T>(key: string | InjectionKey<T>): T | undefined;
192
+ export declare function inject<T>(key: string | InjectionKey<T>, defaultValue: T): T;
193
+ export declare function inject<T>(key: string | InjectionKey<T>, defaultValue?: T): T | undefined;
194
+ /**
195
+ * Create a new injection scope.
196
+ * Called internally when entering a component.
197
+ */
198
+ export declare function pushInjectionScope(): void;
199
+ /**
200
+ * Exit the current injection scope.
201
+ * Called internally when leaving a component.
202
+ */
203
+ export declare function popInjectionScope(): void;
204
+ /**
205
+ * Run a function within a new injection scope.
206
+ * Useful for component rendering.
207
+ */
208
+ export declare function withInjectionScope<T>(fn: () => T | Promise<T>): Promise<T>;
209
+ /**
210
+ * Clear all injections (for testing).
211
+ */
212
+ export declare function clearInjections(): void;
213
+ /**
214
+ * Alias for onMount - matches common naming conventions.
215
+ */
216
+ export declare const onMounted: unknown;
217
+ /**
218
+ * Alias for onDestroy - matches Vue naming.
219
+ */
220
+ export declare const onUnmounted: unknown;
221
+ /**
222
+ * Alias for onUpdate - matches Vue naming.
223
+ */
224
+ export declare const onUpdated: unknown;
225
+ /** Built-in injection key for theme */
226
+ export declare const ThemeKey: unknown;
227
+ /** Built-in injection key for router */
228
+ export declare const RouterKey: (createInjectionKey<{
229
+ currentRoute: string
230
+ navigate: (path: string)) => unknown;
231
+ /** Built-in injection key for i18n */
232
+ export declare const I18nKey: (createInjectionKey<{
233
+ locale: string
234
+ t: (key: string)) => unknown;
235
+ export declare interface Ref<T> {
236
+ value: T | null
237
+ current: T | null
238
+ }
239
+ export declare interface ComponentInstance {
240
+ id: string
241
+ element: Element | null
242
+ mountHooks: LifecycleHook[]
243
+ destroyHooks: CleanupFn[]
244
+ updateHooks: LifecycleHook[]
245
+ refs: Map<string, Ref<any>>
246
+ watchers: Array<{ stop: () => void }>
247
+ isMounted: boolean
248
+ }
249
+ /**
250
+ * STX Composables
251
+ *
252
+ * Vue-inspired composable utilities for STX components:
253
+ * - Lifecycle hooks (onMount, onDestroy, onUpdate)
254
+ * - Refs for DOM element references
255
+ * - Watch and computed for reactivity
256
+ *
257
+ * @module composables
258
+ */
259
+ // =============================================================================
260
+ // Types
261
+ // =============================================================================
262
+ export type LifecycleHook = () => void | (() => void)
263
+ export type CleanupFn = () => void
264
+ export type WatchCallback<T> = (newValue: T, oldValue: T | undefined) => void | CleanupFn
265
+ export type WatchSource<T> = () => T
266
+ /** Symbol for injection keys */
267
+ export type InjectionKey<T> = symbol & { __type?: T }
268
+ export { ref as createRef };
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Generate a unique scope ID.
3
+ */
4
+ export declare function generateScopeId(): string;
5
+ /**
6
+ * Create a new component instance.
7
+ */
8
+ export declare function createComponentInstance(parent?: StxComponentInstance | null): StxComponentInstance;
9
+ /**
10
+ * Set the current component instance for setup execution.
11
+ * @internal
12
+ */
13
+ export declare function setCurrentInstance(instance: StxComponentInstance | null): void;
14
+ /**
15
+ * Get the current component instance.
16
+ * Must be called during component setup (inside <script> block).
17
+ *
18
+ * ```ts
19
+ * const instance = getCurrentInstance()
20
+ * console.log(instance?.props)
21
+ * ```
22
+ */
23
+ export declare function getCurrentInstance(): StxComponentInstance | null;
24
+ /**
25
+ * Reset all component instance state.
26
+ * @internal - Used for testing to clear global state between tests.
27
+ */
28
+ export declare function resetComponentState(): void;
29
+ /**
30
+ * Provide a value for injection into descendant components.
31
+ *
32
+ * ```ts
33
+ * // Parent component
34
+ * provide('theme', 'dark')
35
+ * provide('user', { name: 'Alice' })
36
+ * ```
37
+ *
38
+ * @param key - Injection key (string or symbol)
39
+ * @param value - The value to provide
40
+ */
41
+ export declare function provide<T>(key: string | symbol, value: T): void;
42
+ /**
43
+ * Inject a value provided by an ancestor component.
44
+ *
45
+ * ```ts
46
+ * // Child component
47
+ * const theme = inject('theme', 'light') // 'dark' if provided, 'light' as fallback
48
+ * const user = inject<{ name: string }>('user')
49
+ * ```
50
+ *
51
+ * @param key - Injection key to look up
52
+ * @param defaultValue - Fallback value if not provided by any ancestor
53
+ * @returns The injected value, or defaultValue if not found
54
+ */
55
+ export declare function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
56
+ /**
57
+ * Set a global provide value (used by createApp().provide()).
58
+ * @internal
59
+ */
60
+ export declare function setGlobalProvide<T>(key: string | symbol, value: T): void;
61
+ /**
62
+ * Define the events a component can emit.
63
+ * Returns a typed emit function.
64
+ *
65
+ * ```ts
66
+ * const emit = defineEmits<{
67
+ * change: [value: string]
68
+ * 'update:modelValue': [value: any]
69
+ * }>()
70
+ *
71
+ * // Or with string array
72
+ * const emit = defineEmits(['change', 'update:modelValue'])
73
+ *
74
+ * emit('change', 'newValue')
75
+ * ```
76
+ */
77
+ export declare function defineEmits<T extends Record<string, any[]> = Record<string, any[]>>(_events?: string[] | T): EmitFn<Extract<keyof T, string>>;
78
+ /**
79
+ * Expose public properties from a component instance.
80
+ * These properties become accessible via template refs from the parent.
81
+ *
82
+ * ```ts
83
+ * const count = ref(0)
84
+ * const increment = () => count.value++
85
+ *
86
+ * defineExpose({ count, increment })
87
+ * ```
88
+ *
89
+ * @param exposed - Object of properties to expose
90
+ */
91
+ export declare function defineExpose(exposed: Record<string, unknown>): void;
92
+ /**
93
+ * Wait for the next DOM update cycle.
94
+ *
95
+ * ```ts
96
+ * await nextTick()
97
+ * // DOM is now updated
98
+ *
99
+ * // Or with callback:
100
+ * nextTick(() => {
101
+ * // DOM is now updated
102
+ * })
103
+ * ```
104
+ *
105
+ * @param fn - Optional callback to run after the tick
106
+ * @returns Promise that resolves after the next microtask
107
+ */
108
+ export declare function nextTick(fn?: () => void): Promise<void>;
109
+ /**
110
+ * Register an error captured hook.
111
+ * Called when an error is captured from a descendant component.
112
+ *
113
+ * ```ts
114
+ * onErrorCaptured((error, instance, info) => {
115
+ * console.error('Caught error:', error, info)
116
+ * return false // prevents further propagation
117
+ * })
118
+ * ```
119
+ *
120
+ * @param hook - Error handler function. Return false to stop propagation.
121
+ */
122
+ export declare function onErrorCaptured(hook: (error: Error, instance: StxComponentInstance | null, info: string) => boolean | void): void;
123
+ /**
124
+ * Propagate an error up the component tree.
125
+ * Calls onErrorCaptured hooks on each ancestor.
126
+ * @internal
127
+ */
128
+ export declare function handleError(error: Error, instance: StxComponentInstance | null, info: string): void;
129
+ /**
130
+ * Get the current component's slots.
131
+ *
132
+ * ```ts
133
+ * const slots = useSlots()
134
+ * if (slots.header) {
135
+ * // render header slot
136
+ * }
137
+ * ```
138
+ */
139
+ export declare function useSlots(): Record<string, any>;
140
+ /**
141
+ * Get the current component's non-prop attributes.
142
+ *
143
+ * ```ts
144
+ * const attrs = useAttrs()
145
+ * // attrs contains all attributes not declared as props
146
+ * ```
147
+ */
148
+ export declare function useAttrs(): Record<string, unknown>;
149
+ /**
150
+ * Integrate provide/inject with the server-side template context.
151
+ * Called during component rendering in process.ts.
152
+ * @internal
153
+ */
154
+ export declare function createProvideContext(parentContext: Record<string, any>): Record<string, any>;
155
+ /**
156
+ * Generate the client-side runtime code for the Composition API.
157
+ * This is injected into the page's runtime script.
158
+ * @internal
159
+ */
160
+ export declare function generateCompositionRuntime(): string;
161
+ /**
162
+ * STX Composition API
163
+ *
164
+ * Provides Vue-compatible Composition API features:
165
+ * - provide() / inject() for dependency injection across components
166
+ * - defineEmits() for typed event emission
167
+ * - defineExpose() for exposing component internals to template refs
168
+ * - nextTick() for waiting on DOM updates
169
+ * - getCurrentInstance() for accessing the current component instance
170
+ * - onErrorCaptured() for error boundary handling
171
+ *
172
+ * @module composition-api
173
+ */
174
+ /** Represents a component instance in the stx component tree */
175
+ export declare interface StxComponentInstance {
176
+ scopeId: string
177
+ parent: StxComponentInstance | null
178
+ provides: Map<string | symbol, unknown>
179
+ exposed: Record<string, unknown> | null
180
+ refs: Record<string, Element | null>
181
+ props: Record<string, unknown>
182
+ attrs: Record<string, unknown>
183
+ slots: Record<string, any>
184
+ emit: EmitFn
185
+ el: Element | null
186
+ errorCapturedHooks: Array<(error: Error, instance: StxComponentInstance | null, info: string) => boolean | void>
187
+ isMounted: boolean
188
+ }
189
+ /** Type-safe emit function */
190
+ export type EmitFn<T extends string = string> = (event: T, ...args: any[]) => void
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Create a reactive reference
3
+ */
4
+ export declare function ref<T>(initialValue: T): Ref<T>;
5
+ /**
6
+ * Check if a value is a ref
7
+ */
8
+ export declare function isRef<T>(value: unknown): value is Ref<T>;
9
+ /**
10
+ * Unwrap a ref to get its value
11
+ */
12
+ export declare function unref<T>(value: T | Ref<T>): T;
13
+ /**
14
+ * Convert all properties of an object to refs
15
+ */
16
+ export declare function toRefs<T extends object>(obj: T): { [K in keyof T]: Ref<T[K]> };
17
+ /**
18
+ * Create a shallow reactive object
19
+ */
20
+ export declare function shallowRef<T>(initialValue: T): Ref<T>;
21
+ /**
22
+ * Create a computed property with automatic dependency tracking
23
+ */
24
+ export declare function computed<T>(getter: () => T): ComputedRef<T>;
25
+ export declare function computed<T>(options: ComputedOptions<T>): WritableComputedRef<T>;
26
+ export declare function computed<T>(getterOrOptions: (() => T) | ComputedOptions<T>): ComputedRef<T> | WritableComputedRef<T>;
27
+ /**
28
+ * Watch a reactive source and run a callback when it changes
29
+ */
30
+ export declare function watch<T>(source: Ref<T> | (() => T), callback: (newValue: T, oldValue: T | undefined) => void, options?: WatchOptions): WatchStopHandle;
31
+ /**
32
+ * Watch multiple sources
33
+ */
34
+ export declare function watchMultiple<T extends readonly Ref<unknown>[]>(sources: [...T], callback: (
35
+ newValues: { [K in keyof T]: T[K] extends Ref<infer V> ? V : never },
36
+ oldValues: { [K in keyof T]: T[K] extends Ref<infer V> ? V | undefined : never }
37
+ ) => void, options?: WatchOptions): WatchStopHandle;
38
+ /**
39
+ * Watch and run effect immediately, auto-tracking dependencies
40
+ */
41
+ export declare function watchEffect(effect: () => void | (() => void), options?: Pick<WatchOptions, 'flush'>): WatchStopHandle;
42
+ /**
43
+ * Process @computed directives in templates
44
+ */
45
+ export declare function processComputedDirectives(template: string, context?: Record<string, unknown>, _filePath?: string): string;
46
+ /**
47
+ * Process @watch directives in templates
48
+ */
49
+ export declare function processWatchDirectives(template: string, _context?: Record<string, unknown>, _filePath?: string): string;
50
+ /**
51
+ * Create a debounced computed
52
+ */
53
+ export declare function debouncedComputed<T>(getter: () => T, delay?: number): ComputedRef<T>;
54
+ /**
55
+ * Create a throttled computed
56
+ */
57
+ export declare function throttledComputed<T>(getter: () => T, limit?: number): ComputedRef<T>;
58
+ /**
59
+ * Computed Properties Module
60
+ *
61
+ * Provides reactive computed values with automatic dependency tracking.
62
+ * Computed properties automatically update when their dependencies change,
63
+ * and are cached until dependencies are modified.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const firstName = ref('John')
68
+ * const lastName = ref('Doe')
69
+ *
70
+ * const fullName = computed(() => `${firstName.value} ${lastName.value}`)
71
+ *
72
+ * console.log(fullName.value) // 'John Doe'
73
+ * firstName.value = 'Jane'
74
+ * console.log(fullName.value) // 'Jane Doe'
75
+ * ```
76
+ */
77
+ // ============================================================================
78
+ // Types
79
+ // ============================================================================
80
+ export declare interface Ref<T> {
81
+ value: T
82
+ subscribe: (callback: (value: T) => void) => () => void
83
+ peek: () => T
84
+ }
85
+ export declare interface ComputedRef<T> extends Ref<T> {
86
+ invalidate: () => void
87
+ dirty: boolean
88
+ deps: Set<Ref<unknown>>
89
+ }
90
+ export declare interface WritableComputedRef<T> extends ComputedRef<T> {
91
+ value: T
92
+ }
93
+ export declare interface ComputedOptions<T> {
94
+ get: () => T
95
+ set?: (value: T) => void
96
+ lazy?: boolean
97
+ equals?: (a: T, b: T) => boolean
98
+ }
99
+ export declare interface WatchOptions {
100
+ immediate?: boolean
101
+ deep?: boolean
102
+ flush?: 'pre' | 'post' | 'sync'
103
+ once?: boolean
104
+ }
105
+ export declare interface WatchStopHandle {
106
+ (): void
107
+ pause: () => void
108
+ resume: () => void
109
+ }
110
+ export {
111
+ ref as stxRef,
112
+ computed as stxComputed,
113
+ watch as stxWatch,
114
+ watchMultiple as stxWatchMultiple,
115
+ watchEffect as stxWatchEffect,
116
+ isRef as stxIsRef,
117
+ unref as stxUnref,
118
+ toRefs as stxToRefs,
119
+ shallowRef as stxShallowRef,
120
+ debouncedComputed as stxDebouncedComputed,
121
+ throttledComputed as stxThrottledComputed,
122
+ };
123
+ export default {
124
+ ref,
125
+ computed,
126
+ watch,
127
+ watchMultiple,
128
+ watchEffect,
129
+ isRef,
130
+ unref,
131
+ toRefs,
132
+ shallowRef,
133
+ debouncedComputed,
134
+ throttledComputed,
135
+ processComputedDirectives,
136
+ processWatchDirectives,
137
+ };
@@ -1,19 +1,31 @@
1
1
  /**
2
2
  * Process switch statements (@switch, @case, @default)
3
+ *
4
+ * Uses the parser module for proper handling of:
5
+ * - Nested parentheses in expressions (e.g., @switch(fn(a, fn(b))))
6
+ * - Nested @switch blocks
7
+ * - @break directives
3
8
  */
4
- export declare function processSwitchStatements(template: string, context: Record<string, any>, filePath: string): string;
9
+ export declare function processSwitchStatements(template: string, context: Record<string, any>, _filePath: string): string;
5
10
  /**
6
11
  * Process conditionals (@if, @elseif, @else, @unless)
12
+ *
13
+ * Uses the parser module for proper handling of:
14
+ * - Nested parentheses in conditions (e.g., @if(fn(a, fn(b))))
15
+ * - Nested @if blocks
16
+ * - Multiple @elseif branches
7
17
  */
8
18
  export declare function processConditionals(template: string, context: Record<string, any>, filePath: string): string;
9
19
  /**
10
20
  * Process @auth and permissions directives
21
+ *
22
+ * @see Authentication Directive Documentation above for required context shapes
11
23
  */
12
24
  export declare function processAuthDirectives(template: string, context: Record<string, any>): string;
13
25
  /**
14
26
  * Process @isset and @empty directives
15
27
  */
16
- export declare function processIssetEmptyDirectives(template: string, context: Record<string, any>, filePath?: string): string;
28
+ export declare function processIssetEmptyDirectives(template: string, context: Record<string, any>, _filePath?: string): string;
17
29
  /**
18
30
  * Process @env directive to conditionally render content based on environment
19
31
  */
package/dist/config.d.ts CHANGED
@@ -1,8 +1,41 @@
1
- import type { StxOptions } from './types';
1
+ import type { StxConfig, StxOptions } from './types';
2
+ export declare function loadStxConfig(): Promise<StxConfig>;
2
3
  /**
3
4
  * Helper function to define stx configuration
4
5
  */
5
6
  export declare function defineStxConfig(config: StxOptions): StxOptions;
7
+ /**
8
+ * Validate stx configuration
9
+ *
10
+ * @param config - Configuration to validate
11
+ * @returns Validation result with errors and warnings
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const result = validateConfig(myConfig)
16
+ * if (!result.valid) {
17
+ * console.error('Config errors:', result.errors)
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function validateConfig(config: StxOptions): ConfigValidationResult;
6
22
  export declare const defaultConfig: StxConfig;
7
- // eslint-disable-next-line antfu/no-top-level-await
8
- export declare const config: StxConfig;
23
+ // Export a synchronous getter that returns defaults immediately, then loads async
24
+ // This allows the module to be imported instantly without blocking
25
+ export declare const config: StxConfig;
26
+ /**
27
+ * Configuration validation error
28
+ */
29
+ export declare interface ConfigValidationError {
30
+ path: string
31
+ message: string
32
+ severity: 'error' | 'warning'
33
+ }
34
+ /**
35
+ * Configuration validation result
36
+ */
37
+ export declare interface ConfigValidationResult {
38
+ valid: boolean
39
+ errors: ConfigValidationError[]
40
+ warnings: ConfigValidationError[]
41
+ }