@stacksjs/stx 0.2.155 → 0.2.157

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 (241) hide show
  1. package/dist/a11y.d.ts +87 -46
  2. package/dist/animation.d.ts +96 -42
  3. package/dist/appearance-bootstrap.d.ts +49 -15
  4. package/dist/asset-roots.d.ts +32 -0
  5. package/dist/asset-roots.js +7 -0
  6. package/dist/assets.d.ts +9 -7
  7. package/dist/async-components.d.ts +78 -56
  8. package/dist/auth.d.ts +3 -0
  9. package/dist/build-externalize.d.ts +40 -0
  10. package/dist/build-externalize.js +63 -0
  11. package/dist/build-id.d.ts +22 -22
  12. package/dist/build-message.d.ts +73 -2
  13. package/dist/build-message.js +47 -8
  14. package/dist/builtins/attrs.d.ts +14 -0
  15. package/dist/builtins/drawer.d.ts +22 -0
  16. package/dist/builtins/icon.d.ts +16 -2
  17. package/dist/builtins/index.d.ts +5 -15
  18. package/dist/builtins/modal.d.ts +24 -0
  19. package/dist/builtins/safe-image.d.ts +42 -0
  20. package/dist/builtins/stx-image.d.ts +27 -0
  21. package/dist/builtins/stx-link.d.ts +9 -0
  22. package/dist/builtins/stx-loading-indicator.d.ts +11 -0
  23. package/dist/builtins/suspense.d.ts +28 -0
  24. package/dist/builtins/toast.d.ts +17 -0
  25. package/dist/builtins/transition-group.d.ts +25 -0
  26. package/dist/caching.d.ts +12 -15
  27. package/dist/cli.js +1798 -908
  28. package/dist/client/directive.d.ts +7 -0
  29. package/dist/client/index.d.ts +0 -1
  30. package/dist/client-script-bundler.d.ts +63 -5
  31. package/dist/client-script-bundler.js +30 -2
  32. package/dist/client-script.d.ts +102 -47
  33. package/dist/client-script.js +15 -3
  34. package/dist/codemod.d.ts +56 -0
  35. package/dist/codemod.js +192 -0
  36. package/dist/color-mode-boot.d.ts +83 -65
  37. package/dist/component-client-factories.d.ts +1 -6
  38. package/dist/component-processing.d.ts +58 -49
  39. package/dist/component-processing.js +1 -1
  40. package/dist/component-registry.d.ts +94 -31
  41. package/dist/component-renderer.d.ts +18 -0
  42. package/dist/composable-loader.d.ts +24 -0
  43. package/dist/composable-loader.js +12 -9
  44. package/dist/composables/index.d.ts +7 -0
  45. package/dist/composables/index.js +1 -0
  46. package/dist/composables/use-fetch.js +30 -2
  47. package/dist/composables/use-form.d.ts +91 -0
  48. package/dist/composables/use-form.js +112 -0
  49. package/dist/composables.d.ts +64 -60
  50. package/dist/computed.d.ts +86 -92
  51. package/dist/conditionals.d.ts +24 -8
  52. package/dist/conditionals.js +16 -0
  53. package/dist/config.d.ts +34 -21
  54. package/dist/config.js +35 -14
  55. package/dist/craft.js +1476 -768
  56. package/dist/crosswind-config.d.ts +58 -0
  57. package/dist/crosswind-config.js +40 -0
  58. package/dist/csp.d.ts +107 -41
  59. package/dist/defer.d.ts +24 -0
  60. package/dist/dev-server/crosswind.d.ts +35 -26
  61. package/dist/dev-server/crosswind.js +2 -18
  62. package/dist/dev-server/serve-app.js +4 -3
  63. package/dist/dev-server/terminal-colors.d.ts +32 -32
  64. package/dist/directive-api.d.ts +86 -43
  65. package/dist/document-shell.d.ts +54 -41
  66. package/dist/dynamic-components.d.ts +9 -0
  67. package/dist/error-boundaries.d.ts +47 -41
  68. package/dist/error-handling.d.ts +1 -1
  69. package/dist/errors/codes.d.ts +51 -43
  70. package/dist/errors/formatter.d.ts +58 -38
  71. package/dist/errors/index.d.ts +5 -61
  72. package/dist/errors/logger.d.ts +114 -40
  73. package/dist/errors/sanitizer.d.ts +53 -23
  74. package/dist/errors/types.d.ts +44 -31
  75. package/dist/events.d.ts +86 -25
  76. package/dist/expressions.d.ts +50 -42
  77. package/dist/forms-validation.d.ts +138 -123
  78. package/dist/forms-validation.js +1 -90
  79. package/dist/forms.d.ts +120 -66
  80. package/dist/forms.js +31 -11
  81. package/dist/fragment-container.d.ts +57 -0
  82. package/dist/fragment-container.js +109 -0
  83. package/dist/framework-composables.d.ts +32 -0
  84. package/dist/head.d.ts +156 -114
  85. package/dist/heatmap.d.ts +152 -72
  86. package/dist/html-masking.d.ts +40 -34
  87. package/dist/hydration-runtime.d.ts +20 -24
  88. package/dist/i18n.d.ts +93 -32
  89. package/dist/image-optimization/auto-sibling.d.ts +32 -4
  90. package/dist/includes.d.ts +69 -7
  91. package/dist/index.d.ts +66 -0
  92. package/dist/index.js +23 -0
  93. package/dist/internal-markdown.d.ts +12 -8
  94. package/dist/island-chunking.d.ts +30 -13
  95. package/dist/keep-alive.d.ts +72 -52
  96. package/dist/layout-types.d.ts +45 -0
  97. package/dist/layout-types.js +56 -0
  98. package/dist/lazy-module.d.ts +10 -0
  99. package/dist/loops.d.ts +66 -0
  100. package/dist/loops.js +47 -6
  101. package/dist/markdown.d.ts +0 -1
  102. package/dist/media/image/component.d.ts +25 -9
  103. package/dist/media/image/directive.d.ts +15 -1
  104. package/dist/media/image/placeholder.d.ts +20 -9
  105. package/dist/media/image/processor/cache.d.ts +40 -18
  106. package/dist/media/image/processor/index.d.ts +1 -10
  107. package/dist/media/image/processor/optimizer.d.ts +12 -1
  108. package/dist/media/image/processor/responsive.d.ts +16 -6
  109. package/dist/media/image/srcset.d.ts +47 -50
  110. package/dist/media/shared/cache.d.ts +51 -31
  111. package/dist/media/shared/hash.d.ts +7 -0
  112. package/dist/media/types.d.ts +1235 -754
  113. package/dist/media/video/directive.d.ts +15 -1
  114. package/dist/media/video/index.d.ts +39 -17
  115. package/dist/media/video/processor/cache.d.ts +42 -19
  116. package/dist/media/video/processor/index.d.ts +1 -18
  117. package/dist/media/video/processor/streaming.d.ts +17 -10
  118. package/dist/media/video/processor/thumbnail.d.ts +21 -15
  119. package/dist/media/video/processor/transcoder.d.ts +11 -1
  120. package/dist/method-spoofing.d.ts +7 -0
  121. package/dist/middleware.d.ts +60 -0
  122. package/dist/owned-routes.d.ts +42 -0
  123. package/dist/owned-routes.js +26 -0
  124. package/dist/page-meta.d.ts +38 -0
  125. package/dist/page-meta.js +16 -0
  126. package/dist/parser/directive-parser.d.ts +57 -45
  127. package/dist/parser/expression-parser.d.ts +33 -35
  128. package/dist/parser/index.d.ts +4 -39
  129. package/dist/parser/tokenizer.d.ts +61 -49
  130. package/dist/partial-hydration.d.ts +82 -50
  131. package/dist/performance-utils.d.ts +217 -124
  132. package/dist/placeholder.d.ts +18 -9
  133. package/dist/plugin-system.d.ts +264 -115
  134. package/dist/process.d.ts +11 -6
  135. package/dist/process.js +21 -4
  136. package/dist/production-builder.js +7 -0
  137. package/dist/prop-sentinels.d.ts +11 -11
  138. package/dist/public-env.d.ts +14 -0
  139. package/dist/pwa/directives.d.ts +12 -3
  140. package/dist/pwa/inject.d.ts +10 -0
  141. package/dist/pwa/precache.d.ts +22 -16
  142. package/dist/pwa/service-worker.d.ts +12 -0
  143. package/dist/pwa.js +1318 -610
  144. package/dist/reactive-bindings.d.ts +34 -11
  145. package/dist/reactive.d.ts +58 -30
  146. package/dist/reactive.js +56 -31
  147. package/dist/render.d.ts +0 -14
  148. package/dist/render.js +17 -0
  149. package/dist/route-middleware.d.ts +2 -35
  150. package/dist/route-types.d.ts +134 -0
  151. package/dist/route-types.js +24 -0
  152. package/dist/router.d.ts +5 -7
  153. package/dist/routes.d.ts +1 -3
  154. package/dist/runtime-globals.d.ts +147 -24
  155. package/dist/runtime-globals.js +16 -1
  156. package/dist/runtime-injection.d.ts +8 -0
  157. package/dist/runtime-injection.js +33 -24
  158. package/dist/script-emit.d.ts +30 -0
  159. package/dist/script-json.d.ts +36 -0
  160. package/dist/script-json.js +6 -0
  161. package/dist/script-validation.d.ts +21 -4
  162. package/dist/seo.d.ts +118 -47
  163. package/dist/server-bindings.d.ts +21 -0
  164. package/dist/sfc-template.d.ts +8 -8
  165. package/dist/signal-processing.d.ts +35 -15
  166. package/dist/signals-api.d.ts +117 -58
  167. package/dist/signals-api.js +7 -4
  168. package/dist/signals.d.ts +24 -17
  169. package/dist/signals.js +765 -60
  170. package/dist/site-builder/build.js +8 -0
  171. package/dist/site-url.d.ts +46 -0
  172. package/dist/site-url.js +70 -0
  173. package/dist/slots.d.ts +86 -20
  174. package/dist/source-signature.d.ts +45 -0
  175. package/dist/source-signature.js +20 -0
  176. package/dist/ssg.d.ts +285 -142
  177. package/dist/ssg.js +1268 -556
  178. package/dist/state-dir.d.ts +4 -4
  179. package/dist/state-management.d.ts +0 -12
  180. package/dist/state-management.js +8 -25
  181. package/dist/store-imports.d.ts +23 -0
  182. package/dist/store-imports.js +3 -0
  183. package/dist/store-loader.d.ts +10 -0
  184. package/dist/store-loader.js +10 -9
  185. package/dist/story/analytics.d.ts +138 -60
  186. package/dist/story/bookmarks.d.ts +87 -34
  187. package/dist/story/cli.d.ts +123 -69
  188. package/dist/story/collect/scanner.d.ts +4 -0
  189. package/dist/story/collect/tree.d.ts +8 -1
  190. package/dist/story/commands/build.d.ts +11 -6
  191. package/dist/story/commands/dev.d.ts +15 -8
  192. package/dist/story/commands/preview.d.ts +13 -7
  193. package/dist/story/config-watcher.d.ts +20 -13
  194. package/dist/story/config.d.ts +11 -8
  195. package/dist/story/context.d.ts +14 -8
  196. package/dist/story/hmr.d.ts +24 -26
  197. package/dist/story/hot-swap.d.ts +34 -23
  198. package/dist/story/keyboard-shortcuts.d.ts +23 -18
  199. package/dist/story/output.d.ts +46 -44
  200. package/dist/story/performance.d.ts +107 -45
  201. package/dist/story/presets.d.ts +107 -41
  202. package/dist/story/renderer.d.ts +41 -27
  203. package/dist/story/search.d.ts +23 -12
  204. package/dist/story/server.d.ts +21 -11
  205. package/dist/story/setup.d.ts +23 -15
  206. package/dist/story/testing.d.ts +65 -40
  207. package/dist/story/types.d.ts +262 -160
  208. package/dist/streaming.d.ts +119 -57
  209. package/dist/stx-virtual-ts.d.ts +165 -0
  210. package/dist/stx-virtual-ts.js +372 -0
  211. package/dist/stx.d.ts +78 -1
  212. package/dist/style-scoping.d.ts +17 -4
  213. package/dist/suspense.d.ts +67 -52
  214. package/dist/teleport.d.ts +22 -0
  215. package/dist/template-tag-balance.d.ts +22 -6
  216. package/dist/transitions.d.ts +66 -55
  217. package/dist/typecheck.d.ts +77 -0
  218. package/dist/typecheck.js +156 -0
  219. package/dist/types/component-types.d.ts +187 -122
  220. package/dist/types/config-types.d.ts +758 -297
  221. package/dist/types/context-types.d.ts +46 -24
  222. package/dist/types/csp-types.d.ts +70 -66
  223. package/dist/types/directive-types.d.ts +211 -155
  224. package/dist/types/index.d.ts +6 -109
  225. package/dist/types/pwa-types.d.ts +273 -148
  226. package/dist/types.d.ts +0 -1
  227. package/dist/typescript-templates.d.ts +11 -0
  228. package/dist/unresolved-identifiers.d.ts +24 -22
  229. package/dist/unresolved-identifiers.js +2 -0
  230. package/dist/utils.d.ts +24 -21
  231. package/dist/validator.d.ts +28 -26
  232. package/dist/variable-extractor.d.ts +48 -13
  233. package/dist/variable-extractor.js +27 -4
  234. package/dist/view-composers.d.ts +80 -81
  235. package/dist/virtual-scrolling.d.ts +101 -81
  236. package/dist/vue-template.d.ts +23 -0
  237. package/dist/web-components/css-scoping.d.ts +21 -11
  238. package/dist/web-components.d.ts +81 -58
  239. package/dist/x-element.d.ts +0 -1
  240. package/package.json +5 -5
  241. package/stx.d.ts +78 -1
@@ -1,3 +1,52 @@
1
+ /**
2
+ * Streaming and Hydration Module
3
+ *
4
+ * This module provides:
5
+ * - Template streaming for progressive rendering
6
+ * - Island-based partial hydration support
7
+ * - Section-based template composition
8
+ *
9
+ * ## Section Pattern
10
+ *
11
+ * Sections use HTML comments for markers:
12
+ * ```html
13
+ * <!-- @section:name -->
14
+ * Content here
15
+ * <!-- @endsection:name -->
16
+ * ```
17
+ *
18
+ * **Note**: HTML comments are used because:
19
+ * - They're valid in any position in HTML
20
+ * - They don't affect the DOM structure
21
+ * - They're stripped during minification
22
+ *
23
+ * Alternative using data attributes (for JS-based extraction):
24
+ * ```html
25
+ * <template data-section="name">Content</template>
26
+ * ```
27
+ *
28
+ * ## Island Hydration
29
+ *
30
+ * Islands are client-side interactive regions in server-rendered content:
31
+ * ```html
32
+ * @island('counter', 'eager')
33
+ * <div>Count: {{ count }}</div>
34
+ * @endisland
35
+ * ```
36
+ *
37
+ * Priority levels:
38
+ * - `eager` - Hydrate immediately on page load
39
+ * - `lazy` (default) - Hydrate when visible (IntersectionObserver)
40
+ * - `idle` - Hydrate during browser idle time (requestIdleCallback)
41
+ *
42
+ * ## Streaming
43
+ *
44
+ * Current implementation returns full content in a single chunk.
45
+ * True chunked streaming requires:
46
+ * 1. HTTP/2 or chunked transfer encoding
47
+ * 2. Identifying suspense boundaries
48
+ * 3. Streaming each section as it completes
49
+ */
1
50
  import type { CustomDirective, StreamRenderer, StxOptions } from './types';
2
51
  /**
3
52
  * Stream a template with data using chunked transfer encoding.
@@ -30,6 +79,44 @@ export declare function streamTemplate(templatePath: string, data?: Record<strin
30
79
  * cluster). See stacksjs/stx#1711.
31
80
  */
32
81
  export declare function buildSuspenseResolveScript(name: string, promise: Promise<string>): Promise<string>;
82
+ /**
83
+ * Client receiver for streamed boundaries. Emitted once, right after the shell:
84
+ * defines `window.__stxSuspense.resolve(id, html)`, which swaps the boundary's
85
+ * fallback placeholder (`[data-suspense="id"]`) for the streamed content.
86
+ * Idempotent (`|| { … }`) so multiple streamed renders on one document — or a
87
+ * re-run after SPA nav — don't clobber an in-flight receiver.
88
+ */
89
+ export declare const SUSPENSE_RESOLVER_RUNTIME: string;
90
+ /** A deferred streaming boundary: its `render` does the server-side async work. */
91
+ export interface StreamBoundary {
92
+ /** Boundary id — matches the `data-suspense="<id>"` placeholder in the shell. */
93
+ id: string;
94
+ /**
95
+ * Server-side async render for this boundary: fetch + render, resolving to the
96
+ * final HTML. Runs AFTER the shell has been flushed, so the slow data work
97
+ * here doesn't block first paint.
98
+ */
99
+ render: () => Promise<string>;
100
+ }
101
+ /**
102
+ * Render a streaming-SSR page (#1746 Phase 3). Flushes the shell — which carries
103
+ * each boundary's fallback in a `[data-suspense="<id>"]` placeholder — to the
104
+ * browser immediately, then streams each boundary's HTML as its server-side
105
+ * async `render()` resolves, in completion order. The browser paints the shell
106
+ * at once and each slow region swaps in when its data is ready.
107
+ *
108
+ * Per-boundary errors are isolated (`buildSuspenseResolveScript` emits an error
109
+ * UI into that boundary instead of failing the whole stream). Pair with
110
+ * `streamToResponse` to get a chunked HTTP `Response`.
111
+ */
112
+ export interface RenderStreamingOptions {
113
+ /**
114
+ * Per-boundary timeout in ms. A boundary whose `render()` doesn't resolve in
115
+ * time is rejected (→ an error UI in its placeholder) so a hung data source
116
+ * can't keep the stream open forever. `0` (default) = no timeout.
117
+ */
118
+ timeoutMs?: number;
119
+ }
33
120
  export declare function renderStreamingPage(shellHtml: string, boundaries?: StreamBoundary[], options?: RenderStreamingOptions): ReadableStream<string>;
34
121
  /**
35
122
  * Declarative streaming-SSR sugar (#1746 Phase 3). Extracts each
@@ -66,6 +153,27 @@ export declare function streamTemplateSimple(templatePath: string, data?: Record
66
153
  * @param options stx options
67
154
  */
68
155
  export declare function createStreamRenderer(templatePath: string, options?: StxOptions): Promise<StreamRenderer>;
156
+ /**
157
+ * Custom directive for marking suspense boundaries in streaming templates.
158
+ *
159
+ * Usage:
160
+ * ```html
161
+ * @suspense('heavy-content')
162
+ * <div>This content will stream after the shell</div>
163
+ * @endsuspense
164
+ * ```
165
+ *
166
+ * The content inside suspense boundaries will be:
167
+ * 1. Replaced with a placeholder in the initial shell
168
+ * 2. Processed in parallel with other suspense boundaries
169
+ * 3. Streamed to the client as it resolves
170
+ * 4. Injected into the placeholder via client-side JavaScript
171
+ */
172
+ export declare const streamingSuspenseDirective: CustomDirective;
173
+ /**
174
+ * Custom directive for creating islands (for partial hydration)
175
+ */
176
+ export declare const islandDirective: CustomDirective;
69
177
  /**
70
178
  * Register streaming and hydration directives
71
179
  */
@@ -77,7 +185,6 @@ export declare function registerStreamingDirectives(options?: StxOptions): Custo
77
185
  * @param filePath Template file path
78
186
  * @param _options stx options
79
187
  */
80
- // eslint-disable-next-line pickier/no-unused-vars
81
188
  export declare function processSectionDirectives(content: string, context: Record<string, any>, filePath: string, _options?: StxOptions): Promise<string>;
82
189
  /**
83
190
  * Wrap a ReadableStream<string> in a proper Response with chunked transfer encoding headers.
@@ -99,6 +206,17 @@ export declare function processSectionDirectives(content: string, context: Recor
99
206
  * @returns A Response with proper streaming headers
100
207
  */
101
208
  export declare function streamToResponse(stream: ReadableStream<string>, init?: ResponseInit): Response;
209
+ /**
210
+ * Configuration for hydration runtime generation
211
+ */
212
+ export interface HydrationRuntimeConfig {
213
+ /** Include full runtime or just the loader */
214
+ mode: 'full' | 'loader';
215
+ /** Component registry mapping island names to component paths */
216
+ components?: Record<string, string>;
217
+ /** Whether to use dynamic imports */
218
+ dynamicImports?: boolean;
219
+ }
102
220
  /**
103
221
  * Generate client-side hydration runtime script.
104
222
  *
@@ -118,59 +236,3 @@ export declare function streamToResponse(stream: ReadableStream<string>, init?:
118
236
  * ```
119
237
  */
120
238
  export declare function generateHydrationRuntime(config?: HydrationRuntimeConfig): string;
121
- /**
122
- * Client receiver for streamed boundaries. Emitted once, right after the shell:
123
- * defines `window.__stxSuspense.resolve(id, html)`, which swaps the boundary's
124
- * fallback placeholder (`[data-suspense="id"]`) for the streamed content.
125
- * Idempotent (`|| { … }`) so multiple streamed renders on one document — or a
126
- * re-run after SPA nav — don't clobber an in-flight receiver.
127
- */
128
- export declare const SUSPENSE_RESOLVER_RUNTIME: string;
129
- /**
130
- * Custom directive for marking suspense boundaries in streaming templates.
131
- *
132
- * Usage:
133
- * ```html
134
- * @suspense('heavy-content')
135
- * <div>This content will stream after the shell</div>
136
- * @endsuspense
137
- * ```
138
- *
139
- * The content inside suspense boundaries will be:
140
- * 1. Replaced with a placeholder in the initial shell
141
- * 2. Processed in parallel with other suspense boundaries
142
- * 3. Streamed to the client as it resolves
143
- * 4. Injected into the placeholder via client-side JavaScript
144
- */
145
- export declare const streamingSuspenseDirective: CustomDirective;
146
- /**
147
- * Custom directive for creating islands (for partial hydration)
148
- */
149
- export declare const islandDirective: CustomDirective;
150
- /** A deferred streaming boundary: its `render` does the server-side async work. */
151
- export declare interface StreamBoundary {
152
- id: string
153
- render: () => Promise<string>
154
- }
155
- /**
156
- * Render a streaming-SSR page (#1746 Phase 3). Flushes the shell — which carries
157
- * each boundary's fallback in a `[data-suspense="<id>"]` placeholder — to the
158
- * browser immediately, then streams each boundary's HTML as its server-side
159
- * async `render()` resolves, in completion order. The browser paints the shell
160
- * at once and each slow region swaps in when its data is ready.
161
- *
162
- * Per-boundary errors are isolated (`buildSuspenseResolveScript` emits an error
163
- * UI into that boundary instead of failing the whole stream). Pair with
164
- * `streamToResponse` to get a chunked HTTP `Response`.
165
- */
166
- export declare interface RenderStreamingOptions {
167
- timeoutMs?: number
168
- }
169
- /**
170
- * Configuration for hydration runtime generation
171
- */
172
- export declare interface HydrationRuntimeConfig {
173
- mode: 'full' | 'loader'
174
- components?: Record<string, string>
175
- dynamicImports?: boolean
176
- }
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Pull the script blocks out of a `.stx` source, with the line each body starts on.
3
+ *
4
+ * `<script server>` and `<script client>` are recognised by attribute. A bare
5
+ * `<script>` is reported as `plain`: it ships to the browser verbatim without
6
+ * the auto-import preamble, so it is a different checking context and callers
7
+ * may want to skip it.
8
+ */
9
+ export declare function extractScriptBlocks(source: string): ScriptBlock[];
10
+ /**
11
+ * Blank out everything an expression cannot appear in, preserving offsets.
12
+ *
13
+ * Scripts, styles, HTML comments and `@verbatim` blocks are replaced with
14
+ * spaces so that scanning for `{{ }}` never has to reason about nesting, while
15
+ * every surviving character keeps its original line and column.
16
+ */
17
+ export declare function maskNonTemplateRegions(source: string): string;
18
+ /**
19
+ * Split a filter chain off an interpolation, returning the head expression.
20
+ *
21
+ * `{{ name | upper }}` is stx syntax, not TypeScript — the pipe is a filter
22
+ * separator (`expressions.ts`). Only the part before the first top-level `|`
23
+ * is TypeScript, and `||` is a real operator that must survive.
24
+ */
25
+ export declare function stripFilterChain(expression: string): string;
26
+ export declare function substituteInterpolations(value: string): string;
27
+ /**
28
+ * Every checkable expression in the markup, with the position it occupies.
29
+ *
30
+ * Interpolations escaped as `@{{ … }}` are skipped: that syntax exists to emit
31
+ * the braces literally.
32
+ */
33
+ export declare function extractTemplateExpressions(source: string): TemplateExpression[];
34
+ export declare function collectTemplateBindings(source: string): TemplateBinding[];
35
+ /**
36
+ * Top-level names a script block declares.
37
+ *
38
+ * Used to give template expressions a scope without inlining a block that
39
+ * would collide with another one.
40
+ */
41
+ export declare function collectBlockDeclarations(code: string): string[];
42
+ /** Ambient declarations for the globals the stx runtime injects. */
43
+ export declare function runtimeGlobalDeclarations(): string;
44
+ export declare function serverContextDeclarations(): string;
45
+ /**
46
+ * Names declared by both a server block and a client/plain block.
47
+ *
48
+ * The editor gets one buffer per file, so blocks cannot be given separate
49
+ * modules the way the CLI does — they all land at top level and a name declared
50
+ * on both sides reads as a redeclaration. That is a false signal, and this is
51
+ * what lets the plugin suppress exactly those and nothing else.
52
+ */
53
+ export declare function crossScopeCollisions(blocks: readonly ScriptBlock[]): string[];
54
+ /**
55
+ * Render one template expression as a checkable statement.
56
+ *
57
+ * Returns `null` for the shapes that cannot be modelled without inventing
58
+ * errors — `@click="open = !open"` assigns to what TypeScript sees as a
59
+ * `const`, and that form is documented stx syntax, not a mistake.
60
+ */
61
+ export declare function expressionStatement(expression: TemplateExpression): { text: string, prefixLength: number } | null;
62
+ /**
63
+ * Build one line-aligned TypeScript buffer for a whole `.stx` file.
64
+ *
65
+ * Every script body is written at the line index it already occupies, so a
66
+ * diagnostic's line and column are the `.stx` file's line and column with no
67
+ * translation. Synthetic content is appended past the end of the file and
68
+ * carried by {@link VirtualFile.lineMap}, so a diagnostic there still resolves
69
+ * to a real position — or to nothing, for the ambient declarations, which is
70
+ * how the caller knows to drop it.
71
+ */
72
+ export declare function buildVirtualTypeScript(source: string, options?: BuildVirtualOptions): VirtualFile;
73
+ /** Offsets at which each 1-based line starts. */
74
+ export declare function lineStarts(text: string): number[];
75
+ /** Offset → 1-based line and column. */
76
+ export declare function offsetToPosition(starts: readonly number[], offset: number): { line: number, column: number };
77
+ /** 1-based line and column → offset, clamped to the line. */
78
+ export declare function positionToOffset(starts: readonly number[], line: number, column: number): number;
79
+ /**
80
+ * Translate a position in a virtual buffer back to the `.stx` file.
81
+ *
82
+ * Returns `null` for the ambient declarations appended past the end of the
83
+ * file — they correspond to nothing the author wrote, so a diagnostic there
84
+ * must be dropped rather than pointed at an arbitrary line.
85
+ */
86
+ export declare function resolvePosition(virtual: VirtualFile, line: number, column: number): ResolvedPosition | null;
87
+ /**
88
+ * Placeholder for a server interpolation spliced into a client expression.
89
+ *
90
+ * `:show="photos()[{{ idx }}]"` is real stx — the server fills `{{ idx }}` in
91
+ * before the client ever parses the attribute. Left in place it is a syntax
92
+ * error, so it is replaced with a declared `any`; the interpolation itself is
93
+ * still extracted and checked on its own.
94
+ */
95
+ export declare const INTERPOLATION_PLACEHOLDER: '__stx_interpolated';
96
+ /** Name of the generated helper that reads an iterable's element type. */
97
+ export declare const ELEMENT_HELPER: '__StxElement';
98
+ /** Name of the generated helper that models a template's signal auto-unwrap. */
99
+ export declare const UNWRAP_HELPER: '__StxTemplateValue';
100
+ /**
101
+ * Context the server injects into a `<script server>` block.
102
+ *
103
+ * Mirrors what `serve.ts` puts in scope. Declaring these is what lets the
104
+ * checker report a genuine typo instead of suppressing every unresolved name.
105
+ */
106
+ export declare const STX_SERVER_CONTEXT: readonly ['params', 'query', 'cookies', 'host', 'ip', 'setResponseStatus', 'setResponseHeader', 'request', 'url', 'definePageMeta'];
107
+ /**
108
+ * Names the template engine puts in scope for every page.
109
+ *
110
+ * Declared rather than suppressed. The editor plugin used to drop every
111
+ * "Cannot find name" whose message mentioned one of a hardcoded list, which
112
+ * also dropped genuine typos; giving the names a declaration means an
113
+ * unrecognised one is still an error (#1852 ask 3).
114
+ */
115
+ export declare const STX_TEMPLATE_GLOBALS: readonly ['$env', '$user', '$slot', '$slots', '$attrs', '$props', '$page', '$route', '$loop', '$errors', '$csrf', 'props', 'slot'];
116
+ export declare interface ScriptBlock {
117
+ kind: ScriptKind
118
+ code: string
119
+ startLine: number
120
+ attrs: string
121
+ }
122
+ /** A `{{ }}` interpolation or a directive attribute value. */
123
+ export declare interface TemplateExpression {
124
+ code: string
125
+ line: number
126
+ column: number
127
+ kind: 'interpolation' | 'directive'
128
+ attribute?: string
129
+ }
130
+ /** A synthetic line's origin, for diagnostics that land outside the source. */
131
+ export declare interface MappedLine {
132
+ line: number
133
+ column: number
134
+ expression?: TemplateExpression
135
+ prefixLength?: number
136
+ }
137
+ export declare interface VirtualFile {
138
+ text: string
139
+ lineMap: Map<number, MappedLine>
140
+ sourceLineCount: number
141
+ }
142
+ /**
143
+ * Names a template introduces that no script block declares.
144
+ *
145
+ * Loop bindings are collected for the whole file rather than tracked per
146
+ * subtree. That is deliberately over-permissive: using a loop variable outside
147
+ * its loop goes unreported, which is a missing error, whereas scoping it
148
+ * precisely without an HTML parser would invent errors that are not there.
149
+ */
150
+ export declare interface TemplateBinding {
151
+ name: string
152
+ iterable?: string
153
+ }
154
+ export declare interface BuildVirtualOptions {
155
+ templateExpressions?: boolean
156
+ globals?: boolean
157
+ runtimeGlobals?: boolean
158
+ }
159
+ /** Where a diagnostic in a virtual buffer belongs in the `.stx` file. */
160
+ export declare interface ResolvedPosition {
161
+ line: number
162
+ column: number
163
+ expression?: TemplateExpression
164
+ }
165
+ export type ScriptKind = 'server' | 'client' | 'plain';