@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,501 @@
1
+ /**
2
+ * Creates a reactive state signal.
3
+ *
4
+ * State signals are the foundation of STX reactivity. They hold a value that,
5
+ * when changed, automatically updates any derived signals or effects that
6
+ * depend on it.
7
+ *
8
+ * @param initialValue - The initial value for the signal
9
+ * @returns A signal that can be read, set, and subscribed to
10
+ *
11
+ * @example Basic usage
12
+ * ```typescript
13
+ * const count = state(0)
14
+ *
15
+ * // Read the value
16
+ * console.log(count()) // 0
17
+ *
18
+ * // Set a new value
19
+ * count.set(5)
20
+ * console.log(count()) // 5
21
+ *
22
+ * // Update based on current value
23
+ * count.update(n => n + 1)
24
+ * console.log(count()) // 6
25
+ * ```
26
+ *
27
+ * @example With objects
28
+ * ```typescript
29
+ * const user = state({ name: 'Alice', age: 30 })
30
+ *
31
+ * // Update the whole object
32
+ * user.set({ name: 'Bob', age: 25 })
33
+ *
34
+ * // Or update a property (creates new object for immutability)
35
+ * user.update(u => ({ ...u, age: u.age + 1 }))
36
+ * ```
37
+ *
38
+ * @example With arrays
39
+ * ```typescript
40
+ * const items = state<string[]>([])
41
+ *
42
+ * // Add an item
43
+ * items.update(arr => [...arr, 'new item'])
44
+ *
45
+ * // Remove an item
46
+ * items.update(arr => arr.filter(i => i !== 'remove me'))
47
+ * ```
48
+ */
49
+ export declare function state<T>(initialValue: T): Signal<T>;
50
+ /**
51
+ * Creates a derived signal that automatically computes its value from other signals.
52
+ *
53
+ * Derived signals are lazy - they only recompute when read after a dependency
54
+ * has changed. They're perfect for computed values that depend on other state.
55
+ *
56
+ * @param compute - A function that computes the derived value
57
+ * @returns A read-only signal with the computed value
58
+ *
59
+ * @example Basic derived value
60
+ * ```typescript
61
+ * const count = state(5)
62
+ * const doubled = derived(() => count() * 2)
63
+ *
64
+ * console.log(doubled()) // 10
65
+ * count.set(10)
66
+ * console.log(doubled()) // 20
67
+ * ```
68
+ *
69
+ * @example Combining multiple signals
70
+ * ```typescript
71
+ * const firstName = state('John')
72
+ * const lastName = state('Doe')
73
+ *
74
+ * const fullName = derived(() => `${firstName()} ${lastName()}`)
75
+ * console.log(fullName()) // "John Doe"
76
+ * ```
77
+ *
78
+ * @example Filtering and transforming
79
+ * ```typescript
80
+ * const items = state([1, 2, 3, 4, 5])
81
+ * const filter = state('even')
82
+ *
83
+ * const filteredItems = derived(() => {
84
+ * const list = items()
85
+ * return filter() === 'even'
86
+ * ? list.filter(n => n % 2 === 0)
87
+ * : list.filter(n => n % 2 !== 0)
88
+ * })
89
+ * ```
90
+ */
91
+ export declare function derived<T>(compute: () => T): DerivedSignal<T>;
92
+ /**
93
+ * Creates a side effect that runs when its dependencies change.
94
+ *
95
+ * Effects automatically track which signals they read and re-run whenever
96
+ * those signals change. They're perfect for syncing state with external
97
+ * systems, logging, or triggering side effects.
98
+ *
99
+ * @param fn - The effect function to run
100
+ * @param options - Optional configuration
101
+ * @returns A cleanup function to stop the effect
102
+ *
103
+ * @example Basic effect
104
+ * ```typescript
105
+ * const count = state(0)
106
+ *
107
+ * effect(() => {
108
+ * console.log(`Count changed to: ${count()}`)
109
+ * })
110
+ *
111
+ * count.set(1) // Logs: "Count changed to: 1"
112
+ * count.set(2) // Logs: "Count changed to: 2"
113
+ * ```
114
+ *
115
+ * @example Effect with cleanup
116
+ * ```typescript
117
+ * const isActive = state(true)
118
+ *
119
+ * effect(() => {
120
+ * if (isActive()) {
121
+ * const interval = setInterval(() => console.log('tick'), 1000)
122
+ * // Return cleanup function
123
+ * return () => clearInterval(interval)
124
+ * }
125
+ * })
126
+ * ```
127
+ *
128
+ * @example Fetching data
129
+ * ```typescript
130
+ * const userId = state(1)
131
+ * const user = state(null)
132
+ *
133
+ * effect(async () => {
134
+ * const id = userId()
135
+ * const response = await fetch(`/api/users/${id}`)
136
+ * user.set(await response.json())
137
+ * })
138
+ * ```
139
+ */
140
+ export declare function effect(fn: () => void | CleanupFn, options?: EffectOptions): CleanupFn;
141
+ /**
142
+ * Batches multiple signal updates into a single effect run.
143
+ *
144
+ * Use this when updating multiple signals at once to avoid redundant
145
+ * effect executions.
146
+ *
147
+ * @param fn - Function containing multiple signal updates
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * const firstName = state('John')
152
+ * const lastName = state('Doe')
153
+ *
154
+ * // Without batch: effect runs twice
155
+ * // With batch: effect runs once
156
+ * batch(() => {
157
+ * firstName.set('Jane')
158
+ * lastName.set('Smith')
159
+ * })
160
+ * ```
161
+ */
162
+ export declare function batch(fn: () => void): void;
163
+ /**
164
+ * Registers a callback to run when the component mounts (is inserted into the DOM).
165
+ *
166
+ * @param callback - Function to run on mount. Can return a cleanup function.
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * onMount(() => {
171
+ * console.log('Component is now in the DOM')
172
+ *
173
+ * // Optional: return cleanup function
174
+ * return () => console.log('Cleanup on unmount')
175
+ * })
176
+ * ```
177
+ *
178
+ * @example Fetching initial data
179
+ * ```typescript
180
+ * const data = state(null)
181
+ *
182
+ * onMount(async () => {
183
+ * data.set(await fetchInitialData())
184
+ * })
185
+ * ```
186
+ */
187
+ export declare function onMount(callback: LifecycleCallback): void;
188
+ /**
189
+ * Registers a callback to run when the component is destroyed (removed from the DOM).
190
+ *
191
+ * @param callback - Function to run on destroy
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * onDestroy(() => {
196
+ * console.log('Component is being removed')
197
+ * // Clean up subscriptions, timers, etc.
198
+ * })
199
+ * ```
200
+ */
201
+ export declare function onDestroy(callback: LifecycleCallback): void;
202
+ /**
203
+ * Checks if a value is a signal.
204
+ *
205
+ * @param value - Value to check
206
+ * @returns True if the value is a signal
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * const count = state(0)
211
+ * isSignal(count) // true
212
+ * isSignal(5) // false
213
+ * ```
214
+ */
215
+ export declare function isSignal(value: unknown): value is Signal<unknown>;
216
+ /**
217
+ * Checks if a value is a derived signal.
218
+ *
219
+ * @param value - Value to check
220
+ * @returns True if the value is a derived signal
221
+ */
222
+ export declare function isDerived(value: unknown): value is DerivedSignal<unknown>;
223
+ /**
224
+ * Unwraps a signal to get its raw value.
225
+ * If the value is not a signal, returns it as-is.
226
+ *
227
+ * @param value - A signal or plain value
228
+ * @returns The unwrapped value
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * const count = state(5)
233
+ * untrack(count) // 5
234
+ * untrack(10) // 10
235
+ * ```
236
+ */
237
+ export declare function untrack<T>(value: T | Signal<T> | DerivedSignal<T>): T;
238
+ /**
239
+ * Reads a signal's value without tracking it as a dependency.
240
+ *
241
+ * Use this when you need to read a signal inside an effect but don't want
242
+ * the effect to re-run when that signal changes.
243
+ *
244
+ * @param fn - Function to run without tracking
245
+ * @returns The function's return value
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * const count = state(0)
250
+ * const other = state(0)
251
+ *
252
+ * effect(() => {
253
+ * // This effect only re-runs when `count` changes
254
+ * console.log(count())
255
+ *
256
+ * // Reading `other` without tracking
257
+ * const otherValue = peek(() => other())
258
+ * })
259
+ * ```
260
+ */
261
+ export declare function peek<T>(fn: () => T): T;
262
+ /**
263
+ * Generates the browser runtime for STX signals.
264
+ *
265
+ * This runtime is automatically injected into pages that use signals.
266
+ * It provides the full reactivity system and template binding.
267
+ *
268
+ * @returns Minified JavaScript runtime code
269
+ */
270
+ export declare function generateSignalsRuntime(): string;
271
+ /**
272
+ * Generates readable (non-minified) runtime for development.
273
+ *
274
+ * @returns Human-readable JavaScript runtime code
275
+ */
276
+ export declare function generateSignalsRuntimeDev(): string;
277
+ /**
278
+ * STX Signals - Reactive State Management
279
+ * =========================================
280
+ *
281
+ * A simple, intuitive reactivity system for STX templates.
282
+ * Signals provide fine-grained reactivity with automatic dependency tracking
283
+ * and seamless template integration.
284
+ *
285
+ * ## Why Signals?
286
+ *
287
+ * - **No `.value` needed** - Read with `count()`, write with `count.set(5)`
288
+ * - **Automatic tracking** - Dependencies are tracked automatically in effects
289
+ * - **Fine-grained updates** - Only affected DOM nodes update, not the whole component
290
+ * - **Simple API** - Just `state`, `derived`, and `effect`
291
+ * - **Seamless syntax** - Same `@if`, `@for` directives work on server and client
292
+ *
293
+ * ## Quick Start
294
+ *
295
+ * ```html
296
+ * <script>
297
+ * const count = state(0)
298
+ * const items = state(['Apple', 'Banana', 'Cherry'])
299
+ * const showList = state(true)
300
+ *
301
+ * function increment() {
302
+ * count.update(n => n + 1)
303
+ * }
304
+ *
305
+ * function addItem() {
306
+ * items.update(list => [...list, 'New Item'])
307
+ * }
308
+ * </script>
309
+ *
310
+ * <button @click="increment">Count: {{ count }}</button>
311
+ *
312
+ * <button @click="showList.set(!showList())">Toggle List</button>
313
+ *
314
+ * @if="showList()"
315
+ * <ul>
316
+ * <li @for="item in items()">{{ item }}</li>
317
+ * </ul>
318
+ * @endif
319
+ *
320
+ * <button @click="addItem">Add Item</button>
321
+ * ```
322
+ *
323
+ * ## Core Concepts
324
+ *
325
+ * ### State
326
+ * A state signal holds a reactive value. Read it by calling it as a function,
327
+ * write it using `.set()` or `.update()`.
328
+ *
329
+ * ```typescript
330
+ * const count = state(0) // Create with initial value
331
+ * console.log(count()) // Read: 0
332
+ * count.set(5) // Write: set to 5
333
+ * count.update(n => n + 1) // Update: increment by 1
334
+ * ```
335
+ *
336
+ * ### Derived
337
+ * A derived signal computes its value from other signals. It automatically
338
+ * updates when its dependencies change.
339
+ *
340
+ * ```typescript
341
+ * const firstName = state('John')
342
+ * const lastName = state('Doe')
343
+ * const fullName = derived(() => `${firstName()} ${lastName()}`)
344
+ *
345
+ * console.log(fullName()) // "John Doe"
346
+ * firstName.set('Jane')
347
+ * console.log(fullName()) // "Jane Doe"
348
+ * ```
349
+ *
350
+ * ### Effect
351
+ * Effects run side effects when their dependencies change. They're perfect
352
+ * for logging, API calls, or DOM manipulation.
353
+ *
354
+ * ```typescript
355
+ * const searchQuery = state('')
356
+ *
357
+ * effect(() => {
358
+ * // This runs whenever searchQuery changes
359
+ * fetchResults(searchQuery())
360
+ * })
361
+ * ```
362
+ *
363
+ * ## Template Syntax (all use @ prefix)
364
+ *
365
+ * All directives work seamlessly on both server-side and client-side.
366
+ * Server-side directives are processed at build time. Reactive directives
367
+ * (those using signals) are handled by the client runtime.
368
+ *
369
+ * ### Text Interpolation
370
+ * ```html
371
+ * <p>{{ message }}</p>
372
+ * <p>{{ user.name }}</p>
373
+ * <p>{{ items().length }} items</p>
374
+ * ```
375
+ *
376
+ * ### Conditional Rendering
377
+ * ```html
378
+ * <div @if="isVisible()">Shown when true</div>
379
+ * <div @if="user()">Welcome, {{ user().name }}</div>
380
+ * ```
381
+ *
382
+ * ### List Rendering
383
+ * ```html
384
+ * <ul>
385
+ * <li @for="item in items()">{{ item.name }}</li>
386
+ * </ul>
387
+ *
388
+ * <div @for="item, index in items()">
389
+ * {{ index }}: {{ item }}
390
+ * </div>
391
+ * ```
392
+ *
393
+ * ### Visibility Toggle
394
+ * ```html
395
+ * <!-- @show keeps element in DOM but toggles display -->
396
+ * <p @show="hasContent()">Toggles visibility</p>
397
+ * ```
398
+ *
399
+ * ### Attribute Binding
400
+ * ```html
401
+ * <img @bind:src="imageUrl()" @bind:alt="imageAlt()">
402
+ * <button @bind:disabled="isLoading()">Submit</button>
403
+ * <div @class="{ active: isActive(), hidden: !visible() }">
404
+ * ```
405
+ *
406
+ * ### Event Handling
407
+ * ```html
408
+ * <button @click="handleClick">Click me</button>
409
+ * <input @input="updateValue" @keydown.enter="submit">
410
+ * <form @submit.prevent="handleSubmit">
411
+ * ```
412
+ *
413
+ * ### Two-Way Binding
414
+ * ```html
415
+ * <input @model="username">
416
+ * <textarea @model="message"></textarea>
417
+ * <select @model="selectedOption">
418
+ * ```
419
+ *
420
+ * ### Text and HTML Content
421
+ * ```html
422
+ * <span @text="message()"></span>
423
+ * <div @html="richContent()"></div>
424
+ * ```
425
+ *
426
+ * ## Lifecycle Hooks
427
+ *
428
+ * ```typescript
429
+ * onMount(() => {
430
+ * console.log('Component mounted')
431
+ * })
432
+ *
433
+ * onDestroy(() => {
434
+ * console.log('Component destroyed')
435
+ * })
436
+ * ```
437
+ *
438
+ * @module signals
439
+ */
440
+ /**
441
+ * A reactive state signal.
442
+ *
443
+ * Call it to read the value, use `.set()` to write, or `.update()` to transform.
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * const count = state(0)
448
+ * count() // Read: 0
449
+ * count.set(5) // Write: 5
450
+ * count.update(n => n + 1) // Update: 6
451
+ * ```
452
+ */
453
+ export declare interface Signal<T> {
454
+ (): T
455
+ set(value: T): void
456
+ update(fn: (current: T) => T): void
457
+ subscribe(callback: (value: T, prev: T) => void): () => void
458
+ _isSignal: true
459
+ }
460
+ /**
461
+ * A derived (computed) signal that automatically updates when dependencies change.
462
+ *
463
+ * @example
464
+ * ```typescript
465
+ * const doubled = derived(() => count() * 2)
466
+ * doubled() // Read the computed value
467
+ * ```
468
+ */
469
+ export declare interface DerivedSignal<T> {
470
+ (): T
471
+ _isDerived: true
472
+ }
473
+ /**
474
+ * Options for creating effects.
475
+ */
476
+ export declare interface EffectOptions {
477
+ immediate?: boolean
478
+ name?: string
479
+ }
480
+ /**
481
+ * Cleanup function returned by effects.
482
+ */
483
+ export type CleanupFn = () => void
484
+ /**
485
+ * Lifecycle hook callback.
486
+ */
487
+ export type LifecycleCallback = () => void | CleanupFn | Promise<void>
488
+ export default {
489
+ state,
490
+ derived,
491
+ effect,
492
+ batch,
493
+ onMount,
494
+ onDestroy,
495
+ isSignal,
496
+ isDerived,
497
+ untrack,
498
+ peek,
499
+ generateSignalsRuntime,
500
+ generateSignalsRuntimeDev
501
+ };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Parse slot content from component children.
3
+ *
4
+ * Extracts:
5
+ * - Default slot content (anything not in a template#name)
6
+ * - Named slots from <template #name> or <template v-slot:name>
7
+ * - Scoped slot bindings from <template #name="{ props }">
8
+ */
9
+ export declare function parseSlots(childContent: string): ParsedSlots;
10
+ /**
11
+ * Parse slot props from a slot element.
12
+ *
13
+ * Parses: <slot name="row" :item="item" :index="index" />
14
+ * Returns: { name: 'row', props: { item: 'item', index: 'index' } }
15
+ */
16
+ export declare function parseSlotElement(slotTag: string): {
17
+ name: string
18
+ props: Record<string, string>
19
+ defaultContent: string
20
+ };
21
+ /**
22
+ * Render a slot with its content and props.
23
+ *
24
+ * @param slotDef - The slot definition from the parent
25
+ * @param slotProps - Props passed from the child's <slot :prop="value">
26
+ * @param defaultContent - Default content if no slot provided
27
+ * @param context - The current template context
28
+ */
29
+ export declare function renderSlot(slotDef: SlotDefinition | undefined, slotProps: SlotProps, defaultContent: string, context: Record<string, unknown>): Promise<string>;
30
+ /**
31
+ * Process all slots in a component template.
32
+ *
33
+ * Replaces <slot> elements with the appropriate content from parsed slots.
34
+ */
35
+ export declare function processSlots(template: string, parsedSlots: ParsedSlots, context: Record<string, unknown>): Promise<string>;
36
+ /**
37
+ * Extract named slots from component children content.
38
+ * This is called when processing a component to separate slot content.
39
+ */
40
+ export declare function extractSlotContent(childContent: string): {
41
+ defaultSlot: string
42
+ namedSlots: Map<string, SlotDefinition>
43
+ };
44
+ /**
45
+ * Apply slots to a component template.
46
+ * This replaces <slot> elements with the provided slot content.
47
+ */
48
+ export declare function applySlots(componentTemplate: string, defaultSlotContent: string, namedSlots: Map<string, SlotDefinition>, context: Record<string, unknown>): Promise<string>;
49
+ // =============================================================================
50
+ // Types
51
+ // =============================================================================
52
+ export declare interface SlotDefinition {
53
+ name: string
54
+ content: string
55
+ propsBinding?: string
56
+ }
57
+ export declare interface SlotProps {
58
+
59
+ }
60
+ export declare interface ParsedSlots {
61
+ default: string
62
+ named: Map<string, SlotDefinition>
63
+ }
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Decode Base64 VLQ to number
3
+ */
4
+ export declare function decodeVLQ(encoded: string): { value: number, rest: string };
5
+ /**
6
+ * Parse an inline source map comment from content
7
+ */
8
+ export declare function extractInlineSourceMap(content: string): SourceMapV3 | null;
9
+ /**
10
+ * Remove inline source map comments from content
11
+ */
12
+ export declare function removeInlineSourceMap(content: string): string;
13
+ /**
14
+ * Calculate line and column from an offset in content
15
+ */
16
+ export declare function offsetToPosition(content: string, offset: number): Position;
17
+ /**
18
+ * Calculate offset from line and column in content
19
+ */
20
+ export declare function positionToOffset(content: string, position: Position): number;
21
+ /**
22
+ * Position in source or generated code
23
+ */
24
+ export declare interface Position {
25
+ line: number
26
+ column: number
27
+ }
28
+ /**
29
+ * A single mapping from generated to original position
30
+ */
31
+ export declare interface Mapping {
32
+ generated: Position
33
+ source?: string
34
+ original?: Position
35
+ name?: string
36
+ }
37
+ /**
38
+ * V3 Source Map format
39
+ * @see https://sourcemaps.info/spec.html
40
+ */
41
+ export declare interface SourceMapV3 {
42
+ version: 3
43
+ file?: string
44
+ sourceRoot?: string
45
+ sources: string[]
46
+ sourcesContent?: (string | null)[]
47
+ names: string[]
48
+ mappings: string
49
+ }
50
+ /**
51
+ * Source map generator for stx templates
52
+ */
53
+ export declare class SourceMapGenerator {
54
+ private file: string;
55
+ private sourceRoot?: string;
56
+ private sources: string[];
57
+ private sourcesContent: Map<string, string>;
58
+ private names: string[];
59
+ private mappings: Mapping[];
60
+ constructor(file: string, sourceRoot?: string);
61
+ addSource(path: string, content?: string): number;
62
+ addName(name: string): number;
63
+ addMapping(mapping: Mapping): void;
64
+ addMappingRange(generatedStart: Position, source: string, originalStart: Position, lineCount: number): void;
65
+ private generateMappings(): string;
66
+ toJSON(): SourceMapV3;
67
+ toString(): string;
68
+ toDataURL(): string;
69
+ toInlineComment(): string;
70
+ toJSInlineComment(): string;
71
+ toCSSInlineComment(): string;
72
+ }
73
+ /**
74
+ * Source map consumer for parsing and querying source maps
75
+ */
76
+ export declare class SourceMapConsumer {
77
+ private sourceMap: SourceMapV3;
78
+ private decodedMappings: Array<{
79
+ generatedLine: number
80
+ generatedColumn: number
81
+ sourceIndex: number
82
+ originalLine: number
83
+ originalColumn: number
84
+ nameIndex: number
85
+ }>;
86
+ constructor(sourceMap: SourceMapV3 | string);
87
+ private decodeMappings(): void;
88
+ originalPositionFor(generated: Position): {
89
+ source: string | null
90
+ line: number | null
91
+ column: number | null
92
+ name: string | null
93
+ };
94
+ generatedPositionFor(original: { source: string, line: number, column?: number }): {
95
+ line: number | null
96
+ column: number | null
97
+ };
98
+ sourceContentFor(source: string): string | null;
99
+ }
100
+ /**
101
+ * Tracks positions during template transformation for source map generation
102
+ */
103
+ export declare class TemplateTracker {
104
+ private generator: SourceMapGenerator;
105
+ private currentGeneratedLine: any;
106
+ private currentGeneratedColumn: any;
107
+ private sourceFile: string;
108
+ constructor(outputFile: string, sourceFile: string, sourceContent?: string);
109
+ trackReplacement(originalLine: number, originalColumn: number, generatedContent: string): void;
110
+ trackInclude(includeFile: string, includeContent: string, generatedContent: string): void;
111
+ trackGenerated(content: string): void;
112
+ newLine(): void;
113
+ getCurrentPosition(): Position;
114
+ getGenerator(): SourceMapGenerator;
115
+ toJSON(): SourceMapV3;
116
+ toInlineComment(): string;
117
+ }