@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
package/dist/types.d.ts CHANGED
@@ -1,315 +1 @@
1
- /**
2
- * Custom directive definition
3
- */
4
- export declare interface CustomDirective {
5
- name: string
6
- handler: CustomDirectiveHandler
7
- hasEndTag?: boolean
8
- description?: string
9
- }
10
- /**
11
- * Middleware definition
12
- */
13
- export declare interface Middleware {
14
- name: string
15
- handler: MiddlewareHandler
16
- timing: 'before' | 'after'
17
- description?: string
18
- }
19
- /**
20
- * Internationalization (i18n) configuration
21
- */
22
- export declare interface I18nConfig {
23
- defaultLocale: string
24
- locale: string
25
- translationsDir: string
26
- format: 'json' | 'yaml' | 'yml' | 'js'
27
- fallbackToKey: boolean
28
- cache: boolean
29
- }
30
- /**
31
- * Web component definition
32
- */
33
- export declare interface WebComponent {
34
- name: string
35
- tag: string
36
- file: string
37
- extends?: string
38
- shadowDOM?: boolean
39
- template?: boolean
40
- styleSource?: string
41
- attributes?: string[]
42
- description?: string
43
- }
44
- /**
45
- * Web components configuration
46
- */
47
- export declare interface WebComponentConfig {
48
- enabled: boolean
49
- outputDir: string
50
- components: WebComponent[]
51
- }
52
- /**
53
- * Component property documentation
54
- */
55
- export declare interface ComponentPropDoc {
56
- name: string
57
- type?: string
58
- required?: boolean
59
- default?: string
60
- description?: string
61
- }
62
- /**
63
- * Component documentation
64
- */
65
- export declare interface ComponentDoc {
66
- name: string
67
- path: string
68
- description?: string
69
- props: ComponentPropDoc[]
70
- example?: string
71
- isWebComponent?: boolean
72
- tag?: string
73
- }
74
- /**
75
- * Template documentation
76
- */
77
- export declare interface TemplateDoc {
78
- name: string
79
- path: string
80
- description?: string
81
- components?: string[]
82
- directives?: string[]
83
- }
84
- /**
85
- * Directive documentation
86
- */
87
- export declare interface DirectiveDoc {
88
- name: string
89
- description?: string
90
- hasEndTag: boolean
91
- example?: string
92
- }
93
- /**
94
- * Documentation generator configuration
95
- */
96
- export declare interface DocGeneratorConfig {
97
- enabled: boolean
98
- outputDir: string
99
- format: DocFormat
100
- components: boolean
101
- templates: boolean
102
- directives: boolean
103
- extraContent?: string
104
- template?: string
105
- }
106
- /**
107
- * Streaming configuration
108
- */
109
- export declare interface StreamingConfig {
110
- enabled: boolean
111
- bufferSize: number
112
- strategy: 'auto' | 'manual' | 'sections'
113
- timeout: number
114
- }
115
- /**
116
- * Stream renderer for progressive loading
117
- */
118
- export declare interface StreamRenderer {
119
- renderShell: (data?: Record<string, any>) => Promise<string>
120
- renderSection: (section: string, data?: Record<string, any>) => Promise<string>
121
- getSections: () => string[]
122
- getTemplate: () => string
123
- }
124
- /**
125
- * Hydration configuration
126
- */
127
- export declare interface HydrationConfig {
128
- enabled: boolean
129
- mode: 'progressive' | 'islands'
130
- clientEntry: string
131
- autoMarkers: boolean
132
- preload: 'none' | 'eager' | 'lazy'
133
- }
134
- /**
135
- * Island definition for partial hydration
136
- */
137
- export declare interface Island {
138
- id: string
139
- component: string
140
- props?: Record<string, any>
141
- priority?: 'eager' | 'lazy'
142
- shadowDOM?: boolean
143
- }
144
- /**
145
- * Accessibility configuration
146
- */
147
- export declare interface A11yConfig {
148
- enabled: boolean
149
- addSrOnlyStyles: boolean
150
- level: 'AA' | 'AAA'
151
- ignoreChecks?: string[]
152
- autoFix: boolean
153
- }
154
- /**
155
- * SEO OpenGraph configuration
156
- */
157
- export declare interface OpenGraphConfig {
158
- type?: string
159
- title?: string
160
- description?: string
161
- url?: string
162
- image?: string
163
- imageAlt?: string
164
- imageWidth?: number
165
- imageHeight?: number
166
- siteName?: string
167
- }
168
- /**
169
- * SEO Twitter card configuration
170
- */
171
- export declare interface TwitterConfig {
172
- card?: 'summary' | 'summary_large_image' | 'app' | 'player'
173
- title?: string
174
- description?: string
175
- image?: string
176
- site?: string
177
- creator?: string
178
- }
179
- /**
180
- * SEO configuration
181
- */
182
- export declare interface SeoConfig {
183
- title?: string
184
- description?: string
185
- keywords?: string[] | string
186
- robots?: string
187
- canonical?: string
188
- openGraph?: OpenGraphConfig
189
- twitter?: TwitterConfig
190
- structuredData?: Record<string, any>
191
- }
192
- /**
193
- * SEO features configuration
194
- */
195
- export declare interface SeoFeatureConfig {
196
- enabled: boolean
197
- defaultConfig?: SeoConfig
198
- socialPreview?: boolean
199
- defaultImage?: string
200
- }
201
- /**
202
- * Animation configuration
203
- */
204
- export declare interface AnimationConfig {
205
- enabled: boolean
206
- defaultDuration: number
207
- defaultEase: string
208
- respectMotionPreferences: boolean
209
- staggerDelay: number
210
- }
211
- /**
212
- * Syntax highlighting configuration
213
- */
214
- export declare interface SyntaxHighlightingConfig {
215
- enabled: boolean
216
- serverSide: boolean
217
- defaultTheme: SyntaxHighlightTheme
218
- highlightUnknownLanguages: boolean
219
- additionalThemes?: SyntaxHighlightTheme[]
220
- }
221
- /**
222
- * Markdown configuration
223
- */
224
- export declare interface MarkdownConfig {
225
- enabled: boolean
226
- dir?: string
227
- syntaxHighlighting?: Partial<SyntaxHighlightingConfig>
228
- }
229
- /**
230
- * stx configuration options
231
- */
232
- export declare interface StxConfig {
233
- templatesDir?: string
234
- defaultTitle?: string
235
- defaultDescription?: string
236
- defaultImage?: string
237
- cache?: boolean
238
- cacheDir?: string
239
- cacheVersion?: string
240
- enabled: boolean
241
- partialsDir: string
242
- componentsDir: string
243
- debug: boolean
244
- cachePath: string
245
- customDirectives?: CustomDirective[]
246
- middleware?: Middleware[]
247
- i18n?: Partial<I18nConfig>
248
- webComponents?: Partial<WebComponentConfig>
249
- docs?: Partial<DocGeneratorConfig>
250
- streaming?: Partial<StreamingConfig>
251
- hydration?: Partial<HydrationConfig>
252
- a11y?: Partial<A11yConfig>
253
- seo?: Partial<SeoFeatureConfig>
254
- animation?: Partial<AnimationConfig>
255
- skipDefaultSeoTags?: boolean
256
- markdown?: Partial<MarkdownConfig>
257
- }
258
- /**
259
- * stx Config
260
- */
261
- /**
262
- * Custom directive handler function
263
- */
264
- export type CustomDirectiveHandler = (
265
- content: string,
266
- params: string[],
267
- context: Record<string, any>,
268
- filePath: string
269
- ) => string | Promise<string>
270
- /**
271
- * Middleware handler function
272
- */
273
- export type MiddlewareHandler = (
274
- template: string,
275
- context: Record<string, any>,
276
- filePath: string,
277
- options: StxOptions
278
- ) => string | Promise<string>
279
- /**
280
- * Documentation format options
281
- */
282
- export type DocFormat = 'markdown' | 'html' | 'json'
283
- /**
284
- * Available syntax highlighting themes
285
- */
286
- export type SyntaxHighlightTheme = | 'css-variables'
287
- | 'dark-plus'
288
- | 'dracula'
289
- | 'dracula-soft'
290
- | 'github-dark'
291
- | 'github-dark-dimmed'
292
- | 'github-light'
293
- | 'hc_light'
294
- | 'light-plus'
295
- | 'material-theme'
296
- | 'material-theme-darker'
297
- | 'material-theme-lighter'
298
- | 'material-theme-ocean'
299
- | 'material-theme-palenight'
300
- | 'min-dark'
301
- | 'min-light'
302
- | 'monokai'
303
- | 'nord'
304
- | 'one-dark-pro'
305
- | 'poimandres'
306
- | 'rose-pine'
307
- | 'rose-pine-dawn'
308
- | 'rose-pine-moon'
309
- | 'slack-dark'
310
- | 'slack-ochin'
311
- | 'solarized-dark'
312
- | 'solarized-light'
313
- | 'vitesse-dark'
314
- | 'vitesse-light'
315
- export type StxOptions = Partial<StxConfig>
1
+ export * from './types/index';
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Parse a TypeScript type annotation string into a TSType structure.
3
+ *
4
+ * @example
5
+ * parseTypeAnnotation('string') // { kind: 'primitive', value: 'string' }
6
+ * parseTypeAnnotation('string[]') // { kind: 'array', elementType: { kind: 'primitive', value: 'string' } }
7
+ * parseTypeAnnotation('{ name: string }') // { kind: 'object', properties: { name: { type: ..., optional: false } } }
8
+ */
9
+ export declare function parseTypeAnnotation(typeStr: string): TSType;
10
+ /**
11
+ * Extract type definitions from a template's @types block.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const result = extractTypesFromTemplate(`
16
+ * @types
17
+ * interface PageContext {
18
+ * title: string
19
+ * }
20
+ * @endtypes
21
+ * <h1>{{ title }}</h1>
22
+ * `)
23
+ * // result.interfaces[0].name === 'PageContext'
24
+ * ```
25
+ */
26
+ export declare function extractTypesFromTemplate(template: string): TypeExtractionResult;
27
+ /**
28
+ * Create a type context from extracted types and runtime context.
29
+ */
30
+ export declare function createTypeContext(extracted: TypeExtractionResult, runtimeContext?: Record<string, unknown>): TemplateTypeContext;
31
+ /**
32
+ * Infer a TSType from a runtime value.
33
+ */
34
+ export declare function inferTypeFromValue(value: unknown): TSType;
35
+ /**
36
+ * Type-check an expression against the type context.
37
+ *
38
+ * @returns The inferred type of the expression, or an error
39
+ */
40
+ export declare function typeCheckExpression(expression: string, context: TemplateTypeContext): TSType | TypeCheckError;
41
+ /**
42
+ * Validate all expressions in a template.
43
+ */
44
+ export declare function validateTemplateTypes(template: string, context: TemplateTypeContext): TypeCheckError[];
45
+ /**
46
+ * Generate TypeScript definition file for a template.
47
+ *
48
+ * This creates a .d.ts file that provides type information for IDE support.
49
+ */
50
+ export declare function generateTypeDefinitions(templatePath: string, extracted: TypeExtractionResult): GeneratedTypes;
51
+ /**
52
+ * Convert a TSType back to a TypeScript string representation.
53
+ */
54
+ export declare function typeToString(type: TSType): string;
55
+ /**
56
+ * Process @types directive - extracts and removes type definitions.
57
+ */
58
+ export declare function processTypesDirective(template: string): {
59
+ template: string
60
+ types: TypeExtractionResult
61
+ };
62
+ /**
63
+ * Compile-time type check a template.
64
+ *
65
+ * @returns Array of errors/warnings, empty if valid
66
+ */
67
+ export declare function compileTimeTypeCheck(template: string, runtimeContext?: Record<string, unknown>): { errors: TypeCheckError[], warnings: TypeCheckWarning[] };
68
+ /** TypeScript type representation */
69
+ export declare interface TSType {
70
+ kind: 'primitive' | 'array' | 'object' | 'union' | 'intersection' | 'literal' | 'function' | 'generic' | 'reference'
71
+ value?: TSPrimitiveType | string
72
+ elementType?: TSType
73
+ properties?: Record<string, TSTypeProperty>
74
+ types?: TSType[]
75
+ literalValue?: string | number | boolean
76
+ parameters?: TSFunctionParam[]
77
+ returnType?: TSType
78
+ typeArguments?: TSType[]
79
+ optional?: boolean
80
+ }
81
+ /** Object property with type */
82
+ export declare interface TSTypeProperty {
83
+ type: TSType
84
+ optional: boolean
85
+ readonly: boolean
86
+ description?: string
87
+ }
88
+ /** Function parameter */
89
+ export declare interface TSFunctionParam {
90
+ name: string
91
+ type: TSType
92
+ optional: boolean
93
+ rest: boolean
94
+ }
95
+ /** Interface definition */
96
+ export declare interface TSInterface {
97
+ name: string
98
+ properties: Record<string, TSTypeProperty>
99
+ extends?: string[]
100
+ description?: string
101
+ }
102
+ /** Type alias definition */
103
+ export declare interface TSTypeAlias {
104
+ name: string
105
+ type: TSType
106
+ description?: string
107
+ }
108
+ /** Template type context */
109
+ export declare interface TemplateTypeContext {
110
+ interfaces: Map<string, TSInterface>
111
+ typeAliases: Map<string, TSTypeAlias>
112
+ variables: Map<string, TSType>
113
+ errors: TypeCheckError[]
114
+ warnings: TypeCheckWarning[]
115
+ }
116
+ /** Type check error */
117
+ export declare interface TypeCheckError {
118
+ message: string
119
+ line?: number
120
+ column?: number
121
+ expression?: string
122
+ expectedType?: string
123
+ actualType?: string
124
+ }
125
+ /** Type check warning */
126
+ export declare interface TypeCheckWarning {
127
+ message: string
128
+ line?: number
129
+ column?: number
130
+ suggestion?: string
131
+ }
132
+ /** Type extraction result */
133
+ export declare interface TypeExtractionResult {
134
+ interfaces: TSInterface[]
135
+ typeAliases: TSTypeAlias[]
136
+ contextType?: TSInterface
137
+ errors: string[]
138
+ }
139
+ /** Generated type definition file content */
140
+ export declare interface GeneratedTypes {
141
+ content: string
142
+ filename: string
143
+ }
144
+ /**
145
+ * TypeScript-First Templates Module
146
+ *
147
+ * Provides compile-time type checking and TypeScript support for stx templates.
148
+ *
149
+ * ## Features
150
+ *
151
+ * 1. **Type-Safe Context** - Define typed interfaces for template context
152
+ * 2. **Compile-Time Checking** - Validate expressions against context types
153
+ * 3. **Type Inference** - Infer types from script blocks
154
+ * 4. **Type Generation** - Generate TypeScript definitions from templates
155
+ * 5. **IDE Support** - Enable autocomplete and type hints in editors
156
+ *
157
+ * ## Usage
158
+ *
159
+ * ```html
160
+ * <!-- Define context type at top of template -->
161
+ * @types
162
+ * interface PageContext {
163
+ * title: string
164
+ * items: Array<{ id: number; name: string }>
165
+ * user?: { name: string; role: 'admin' | 'user' }
166
+ * }
167
+ * @endtypes
168
+ *
169
+ * <h1>{{ title }}</h1>
170
+ * @foreach(items as item)
171
+ * <p>{{ item.name }}</p> <!-- Type-checked! -->
172
+ * @endforeach
173
+ * ```
174
+ *
175
+ * @module typescript-templates
176
+ */
177
+ /** Supported TypeScript primitive types */
178
+ export type TSPrimitiveType = 'string' | 'number' | 'boolean' | 'null' | 'undefined' | 'any' | 'unknown' | 'never' | 'void'
package/dist/utils.d.ts CHANGED
@@ -1,16 +1,30 @@
1
1
  import type { StxOptions } from './types';
2
+ export type {
3
+ TemplateValidationError,
4
+ TemplateValidationResult,
5
+ } from './validator';
6
+ /**
7
+ * Check if script should be treated as plain JavaScript (opt-out from TypeScript)
8
+ * By default ALL scripts are TypeScript. Use <script js> or <script lang="js"> to opt-out.
9
+ */
10
+ export declare function isJavaScriptScript(attrs: string): boolean;
11
+ /**
12
+ * Check if script should be transpiled as TypeScript
13
+ * Default: ALL scripts are TypeScript unless explicitly marked as JS
14
+ */
15
+ export declare function shouldTranspileTypeScript(attrs: string): boolean;
16
+ /**
17
+ * Transpile TypeScript code to JavaScript using Bun (sync version)
18
+ */
19
+ export declare function transpileTypeScript(code: string): string;
2
20
  /**
3
21
  * Shared function to render a component with props and slot content
4
22
  */
5
- export declare function renderComponent(componentPath: string, props: Record<string, any>, slotContent: string, componentsDir: string, parentContext: Record<string, any>, parentFilePath: string, options: StxOptions, processedComponents?: Set<string> | undefined, dependencies: Set<string>): Promise<string>;
23
+ export declare function renderComponentWithSlot(componentPath: string, props: Record<string, unknown>, slotContent: string, componentsDir: string, parentContext: Record<string, unknown>, parentFilePath: string, options: StxOptions, processedComponents?: Set<string> | undefined, dependencies: Set<string>): Promise<string>;
6
24
  /**
7
25
  * Check if a file exists
8
26
  */
9
27
  export declare function fileExists(filePath: string): Promise<boolean>;
10
- /**
11
- * Extract variables from script content
12
- */
13
- export declare function extractVariables(scriptContent: string, context: Record<string, any>, filePath: string): Promise<void>;
14
28
  /**
15
29
  * Resolve a template path based on the current file path
16
30
  */
@@ -24,4 +38,36 @@ export declare function resolveTemplatePath(templatePath: string, currentFilePat
24
38
  * @returns Line number and context information
25
39
  */
26
40
  export declare function getSourceLineInfo(template: string, errorPosition?: number, errorPattern?: string): { lineNumber: number, lineContent: string, context: string };
27
- export declare function createDetailedErrorMessage(errorType: string, errorMessage: string, filePath: string, template: string, errorPosition?: number, errorPattern?: string): string;
41
+ /**
42
+ * Create a descriptive error message with line information
43
+ * @param errorType Type of error (e.g., "Expression", "Directive")
44
+ * @param errorMessage The base error message
45
+ * @param filePath The file where the error occurred
46
+ * @param template The template content
47
+ * @param errorPosition The position of the error (if known)
48
+ * @param errorPattern A pattern to locate the error (fallback)
49
+ * @returns A formatted error message
50
+ */
51
+ export declare function createDetailedErrorMessage(errorType: string, errorMessage: string, filePath: string, template: string, errorPosition?: number, errorPattern?: string): string;
52
+ /**
53
+ * Clear the component cache
54
+ * Useful for development or testing
55
+ */
56
+ export declare function clearComponentCache(): void;
57
+ /**
58
+ * Get component cache statistics
59
+ */
60
+ export declare function getComponentCacheStats(): { size: number, maxSize: number };
61
+ export {
62
+ extractDirectiveNames,
63
+ getPositionInfo,
64
+ hasDirectives,
65
+ validateDirective,
66
+ validateTemplate,
67
+ } from './validator';
68
+ export {
69
+ convertToCommonJS,
70
+ extractScriptFromTemplate,
71
+ extractVariables,
72
+ hasVariables,
73
+ } from './variable-extractor';
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Validate a template before processing
3
+ *
4
+ * Checks for common syntax errors and structural issues:
5
+ * - Unclosed directive blocks (@if without @endif)
6
+ * - Unclosed expression brackets
7
+ * - Invalid directive syntax
8
+ * - Nested quote issues
9
+ * - Security-related patterns
10
+ *
11
+ * @param template - The template string to validate
12
+ * @returns Validation result with errors and warnings
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const result = validateTemplate(templateString)
17
+ * if (!result.valid) {
18
+ * console.error('Template errors:', result.errors)
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function validateTemplate(template: string): TemplateValidationResult;
23
+ /**
24
+ * Get line and column information for a position in the template
25
+ *
26
+ * @param template - The template string
27
+ * @param position - Character position
28
+ * @returns Line and column numbers (1-indexed)
29
+ */
30
+ export declare function getPositionInfo(template: string, position: number): { line: number, column: number };
31
+ /**
32
+ * Validate a specific directive's syntax
33
+ *
34
+ * @param directiveName - Name of the directive (without @)
35
+ * @param content - Content between directive tags
36
+ * @param params - Parameters passed to the directive
37
+ * @returns Validation errors, if any
38
+ */
39
+ export declare function validateDirective(directiveName: string, content: string, params: string[]): TemplateValidationError[];
40
+ /**
41
+ * Check if a template has any directives
42
+ *
43
+ * @param template - The template string
44
+ * @returns Whether the template contains any stx directives
45
+ */
46
+ export declare function hasDirectives(template: string): boolean;
47
+ /**
48
+ * Extract all directive names used in a template
49
+ *
50
+ * @param template - The template string
51
+ * @returns Array of directive names (without @ prefix)
52
+ */
53
+ export declare function extractDirectiveNames(template: string): string[];
54
+ /**
55
+ * Template Validation
56
+ *
57
+ * Provides validation utilities for stx templates before processing.
58
+ * Checks for common syntax errors, structural issues, and potential security problems.
59
+ */
60
+ /**
61
+ * Template validation error
62
+ */
63
+ export declare interface TemplateValidationError {
64
+ type: 'syntax' | 'directive' | 'expression' | 'structure'
65
+ message: string
66
+ line?: number
67
+ column?: number
68
+ suggestion?: string
69
+ }
70
+ /**
71
+ * Template validation result
72
+ */
73
+ export declare interface TemplateValidationResult {
74
+ valid: boolean
75
+ errors: TemplateValidationError[]
76
+ warnings: TemplateValidationError[]
77
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Strip TypeScript-specific syntax to make it executable as JavaScript
3
+ *
4
+ * @param scriptContent - TypeScript/JavaScript code
5
+ * @returns JavaScript code with TypeScript syntax stripped
6
+ */
7
+ export declare function stripTypeScript(scriptContent: string): string;
8
+ /**
9
+ * Extract variables from script content and add them to context
10
+ *
11
+ * @param scriptContent - The JavaScript/TypeScript code from a <script> tag
12
+ * @param context - The context object to populate with extracted variables
13
+ * @param filePath - Path to the file (for error messages)
14
+ */
15
+ export declare function extractVariables(scriptContent: string, context: Record<string, unknown>, filePath: string): Promise<void>;
16
+ /**
17
+ * Convert ES module syntax to CommonJS
18
+ *
19
+ * @param scriptContent - ES module style script content
20
+ * @returns CommonJS compatible script
21
+ */
22
+ export declare function convertToCommonJS(scriptContent: string): string;
23
+ /**
24
+ * Extract script content from an HTML template
25
+ *
26
+ * @param template - The template string
27
+ * @returns Object with script content and template without script tags
28
+ */
29
+ export declare function extractScriptFromTemplate(template: string): {
30
+ scriptContent: string
31
+ templateWithoutScript: string
32
+ };
33
+ /**
34
+ * Check if script content has any variables to extract
35
+ *
36
+ * @param scriptContent - The script content
37
+ * @returns Whether variables are present
38
+ */
39
+ export declare function hasVariables(scriptContent: string): boolean;