@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
@@ -1,26 +1,171 @@
1
1
  /**
2
- * Register a composer for a specific view
2
+ * Register a composer for a specific view.
3
+ *
4
+ * The view can be either the full file path or just the view name (filename without extension).
5
+ * Both will be checked when determining which composers to run.
6
+ *
7
+ * @param view - The view name or full file path to match
8
+ * @param callback - Function to execute when the view is rendered
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Match by view name
13
+ * composer('profile', (context) => {
14
+ * context.tabs = ['overview', 'settings', 'security']
15
+ * })
16
+ *
17
+ * // Match by full path
18
+ * composer('/app/views/users/edit.stx', async (context) => {
19
+ * context.timezones = await loadTimezones()
20
+ * })
21
+ * ```
3
22
  */
4
23
  export declare function composer(view: string, callback: ViewComposerCallback): void;
5
24
  /**
6
- * Register a composer for all views matching a pattern
25
+ * Register a composer for all views matching a pattern.
26
+ *
27
+ * The pattern is tested against both the full file path and the view name.
28
+ * If either matches, the composer will run.
29
+ *
30
+ * @param pattern - A RegExp or string pattern (strings are converted to RegExp)
31
+ * @param callback - Function to execute when a matching view is rendered
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Match all admin views using RegExp
36
+ * composerPattern(/^admin/, (context) => {
37
+ * context.adminNav = loadAdminNavigation()
38
+ * })
39
+ *
40
+ * // Match views containing 'settings' using string pattern
41
+ * composerPattern('settings', (context) => {
42
+ * context.settingsVersion = '2.0'
43
+ * })
44
+ *
45
+ * // Match views ending with '-form'
46
+ * composerPattern(/-form$/, (context) => {
47
+ * context.csrfToken = generateCsrfToken()
48
+ * })
49
+ * ```
7
50
  */
8
51
  export declare function composerPattern(pattern: string | RegExp, callback: ViewComposerCallback): void;
9
52
  /**
10
- * Execute all composers for a given view
53
+ * Execute all composers for a given view.
54
+ *
55
+ * This function is called automatically during template processing.
56
+ * You typically don't need to call this directly.
57
+ *
58
+ * Execution order:
59
+ * 1. Exact match by full file path
60
+ * 2. Exact match by view name (filename without extension)
61
+ * 3. Pattern matches (in registration order)
62
+ *
63
+ * @param filePath - Full path to the template file being rendered
64
+ * @param context - The template context object to be modified by composers
65
+ *
66
+ * @internal
11
67
  */
12
68
  export declare function runComposers(filePath: string, context: Record<string, any>): Promise<void>;
13
69
  /**
14
- * Clear all registered composers
15
- * (Mainly for testing purposes)
70
+ * Clear all registered composers.
71
+ *
72
+ * Removes all exact match and pattern match composers.
73
+ * Primarily used for testing to reset state between tests.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * import { clearComposers, composer } from 'stx'
78
+ *
79
+ * describe('MyComponent', () => {
80
+ * beforeEach(() => {
81
+ * clearComposers() // Reset before each test
82
+ * })
83
+ *
84
+ * it('should inject user data', () => {
85
+ * composer('profile', (ctx) => { ctx.user = mockUser })
86
+ * // ... test
87
+ * })
88
+ * })
89
+ * ```
16
90
  */
17
91
  export declare function clearComposers(): void;
18
92
  /**
19
- * View Composers functionality for stx templating
20
- * Similar to Laravel's View Composers, this allows registering
21
- * callbacks that should run whenever a specific view is rendered.
93
+ * View Composers Module
94
+ *
95
+ * Similar to Laravel's View Composers, this module allows registering callbacks
96
+ * that automatically run whenever a specific view (or views matching a pattern)
97
+ * is rendered. Use this to inject data into templates without manually passing
98
+ * it every time.
99
+ *
100
+ * ## Use Cases
101
+ *
102
+ * - Inject user data into all views
103
+ * - Add navigation data to layout templates
104
+ * - Load settings for specific page types
105
+ * - Populate dropdown options across forms
106
+ *
107
+ * ## Registration Methods
108
+ *
109
+ * ### Exact Match
110
+ * ```typescript
111
+ * import { composer } from 'stx'
112
+ *
113
+ * // Match by exact view name
114
+ * composer('dashboard', async (context) => {
115
+ * context.stats = await fetchDashboardStats()
116
+ * })
117
+ *
118
+ * // Match by full file path
119
+ * composer('/views/admin/users.stx', (context) => {
120
+ * context.roles = ['admin', 'editor', 'viewer']
121
+ * })
122
+ * ```
123
+ *
124
+ * ### Pattern Match
125
+ * ```typescript
126
+ * import { composerPattern } from 'stx'
127
+ *
128
+ * // Match all admin views
129
+ * composerPattern(/^admin/, (context) => {
130
+ * context.isAdmin = true
131
+ * })
132
+ *
133
+ * // Match with string pattern (converted to RegExp)
134
+ * composerPattern('.*\\.settings\\.', (context) => {
135
+ * context.settingsMenu = loadSettingsMenu()
136
+ * })
137
+ * ```
138
+ *
139
+ * ## Execution Order
140
+ *
141
+ * 1. Exact match composers (by full file path)
142
+ * 2. Exact match composers (by view name only)
143
+ * 3. Pattern match composers (in registration order)
144
+ *
145
+ * All composers for a matching view run in sequence.
146
+ * Async composers are awaited before the next runs.
147
+ *
148
+ * ## Important Notes
149
+ *
150
+ * - Composers modify the context object directly (no return value needed)
151
+ * - Composers are global and persist for the application lifetime
152
+ * - Use `clearComposers()` to reset in tests
153
+ *
154
+ * @module view-composers
22
155
  */
23
156
  /**
24
- * Type definition for view composer callback function
157
+ * Callback function type for view composers.
158
+ *
159
+ * @param context - The template context object (modify this directly)
160
+ * @param filePath - Full path to the template file being rendered
161
+ * @returns void or a Promise that resolves to void
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const myComposer: ViewComposerCallback = async (context, filePath) => {
166
+ * context.user = await getCurrentUser()
167
+ * context.viewPath = filePath
168
+ * }
169
+ * ```
25
170
  */
26
171
  export type ViewComposerCallback = (context: Record<string, any>, filePath: string) => void | Promise<void>
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Creates a virtual scroll instance for a list of items
3
+ */
4
+ export declare function createVirtualList<T>(items: T[], options: VirtualListOptions): VirtualScrollInstance;
5
+ /**
6
+ * Process @virtualList directives in templates
7
+ */
8
+ export declare function processVirtualListDirectives(template: string, context?: Record<string, unknown>, _filePath?: string): string;
9
+ /**
10
+ * Generate CSS for virtual list styling
11
+ */
12
+ export declare function generateVirtualListCSS(): string;
13
+ /**
14
+ * Hook to create a reactive virtual list
15
+ */
16
+ export declare function useVirtualList<T>(items: () => T[], options: VirtualListOptions): {
17
+ visibleItems: () => T[]
18
+ totalHeight: () => number
19
+ containerProps: () => Record<string, unknown>
20
+ itemProps: (index: number) => Record<string, unknown>
21
+ scrollToIndex: (index: number) => void
22
+ };
23
+ /**
24
+ * Process @infiniteList directives for infinite scrolling
25
+ */
26
+ export declare function processInfiniteListDirectives(template: string, context?: Record<string, unknown>, _filePath?: string): string;
27
+ /**
28
+ * Process @virtualGrid directives for grid virtualization
29
+ */
30
+ export declare function processVirtualGridDirectives(template: string, context?: Record<string, unknown>, _filePath?: string): string;
31
+ /**
32
+ * Virtual Scrolling Module
33
+ *
34
+ * Provides efficient rendering of large lists using windowing/virtualization.
35
+ * Only renders items that are visible in the viewport, dramatically improving
36
+ * performance for lists with thousands of items.
37
+ *
38
+ * @example
39
+ * ```html
40
+ * @virtualList(items, { itemHeight: 50, containerHeight: 400 })
41
+ * <div class="item">{{ item.name }}</div>
42
+ * @endvirtualList
43
+ * ```
44
+ */
45
+ // ============================================================================
46
+ // Types
47
+ // ============================================================================
48
+ export declare interface VirtualListOptions {
49
+ itemHeight: number
50
+ containerHeight: number
51
+ overscan?: number
52
+ keyProperty?: string
53
+ dynamicHeight?: boolean
54
+ estimatedItemHeight?: number
55
+ scrollBehavior?: 'auto' | 'smooth'
56
+ direction?: 'vertical' | 'horizontal'
57
+ containerClass?: string
58
+ viewportClass?: string
59
+ itemClass?: string
60
+ }
61
+ export declare interface VirtualListState {
62
+ startIndex: number
63
+ endIndex: number
64
+ scrollTop: number
65
+ totalHeight: number
66
+ visibleItems: unknown[]
67
+ itemHeights: Map<number, number>
68
+ }
69
+ export declare interface VirtualScrollInstance {
70
+ scrollToIndex: (index: number, behavior?: ScrollBehavior) => void
71
+ scrollToOffset: (offset: number, behavior?: ScrollBehavior) => void
72
+ getState: () => VirtualListState
73
+ refresh: () => void
74
+ setItems: (items: unknown[]) => void
75
+ destroy: () => void
76
+ }
77
+ // ============================================================================
78
+ // Infinite Scroll Support
79
+ // ============================================================================
80
+ export declare interface InfiniteScrollOptions extends VirtualListOptions {
81
+ threshold?: number
82
+ onLoadMore?: () => Promise<void>
83
+ hasMore?: boolean
84
+ isLoading?: boolean
85
+ }
86
+ // ============================================================================
87
+ // Grid Virtualization
88
+ // ============================================================================
89
+ export declare interface VirtualGridOptions {
90
+ columns: number
91
+ rowHeight: number
92
+ containerHeight: number
93
+ gap?: number
94
+ overscan?: number
95
+ }
96
+ export default {
97
+ createVirtualList,
98
+ processVirtualListDirectives,
99
+ processInfiniteListDirectives,
100
+ processVirtualGridDirectives,
101
+ generateVirtualListCSS,
102
+ useVirtualList,
103
+ };
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Generate a hierarchical outline of the template.
3
+ * Used for document outline view in IDEs.
4
+ */
5
+ export declare function getTemplateOutline(template: string): OutlineNode;
6
+ /**
7
+ * Analyze a template for visual editor purposes
8
+ * (Alias: analyzeTemplateContent)
9
+ */
10
+ export declare function analyzeVisualEditorTemplate(template: string): TemplateAnalysis;
11
+ /**
12
+ * Analyze a template string and extract all relevant information
13
+ * Use this for analyzing template content directly (not from a file path)
14
+ */
15
+ export declare function analyzeTemplateContent(template: string): TemplateAnalysis;
16
+ /**
17
+ * Generate preview HTML for a template.
18
+ * This is a simplified preview for editor integration.
19
+ */
20
+ export declare function generatePreview(template: string, options?: VisualEditorPreviewOptions): Promise<string>;
21
+ /**
22
+ * Get default component palette items.
23
+ */
24
+ export declare function getDefaultPalette(): PaletteItem[];
25
+ /**
26
+ * Generate insert result for a palette item.
27
+ */
28
+ export declare function insertPaletteItem(item: PaletteItem, position: EditorPosition, indentation?: string): InsertResult;
29
+ /** Template outline node */
30
+ export declare interface OutlineNode {
31
+ type: OutlineNodeType
32
+ name: string
33
+ label: string
34
+ range: { start: number, end: number, line: number, column: number }
35
+ children: OutlineNode[]
36
+ attributes?: Record<string, string | true>
37
+ directiveCategory?: DirectiveCategory
38
+ isClosable?: boolean
39
+ icon?: string
40
+ description?: string
41
+ }
42
+ /** Template analysis result */
43
+ export declare interface TemplateAnalysis {
44
+ variables: VariableUsage[]
45
+ components: ComponentReference[]
46
+ directives: VisualEditorDirectiveUsage[]
47
+ slots: SlotDefinition[]
48
+ sections: SectionDefinition[]
49
+ scripts: ScriptBlock[]
50
+ styles: StyleBlock[]
51
+ layout?: LayoutInfo
52
+ metrics: VisualEditorMetrics
53
+ }
54
+ /** Variable usage info */
55
+ export declare interface VariableUsage {
56
+ name: string
57
+ line: number
58
+ column: number
59
+ context: 'expression' | 'directive' | 'attribute'
60
+ inferredType?: string
61
+ }
62
+ /** Component reference info */
63
+ export declare interface ComponentReference {
64
+ name: string
65
+ path?: string
66
+ line: number
67
+ props: Record<string, string | true>
68
+ hasSlot: boolean
69
+ }
70
+ /** Visual editor directive usage info */
71
+ export declare interface VisualEditorDirectiveUsage {
72
+ name: string
73
+ category: DirectiveCategory
74
+ line: number
75
+ params?: string
76
+ hasEndTag: boolean
77
+ }
78
+ /** Slot definition */
79
+ export declare interface SlotDefinition {
80
+ name: string
81
+ line: number
82
+ isNamed: boolean
83
+ defaultContent?: string
84
+ }
85
+ /** Section definition */
86
+ export declare interface SectionDefinition {
87
+ name: string
88
+ line: number
89
+ content: string
90
+ }
91
+ /** Script block info */
92
+ export declare interface ScriptBlock {
93
+ type: 'typescript' | 'javascript'
94
+ line: number
95
+ content: string
96
+ exports: string[]
97
+ }
98
+ /** Style block info */
99
+ export declare interface StyleBlock {
100
+ type: 'css' | 'scss' | 'less'
101
+ line: number
102
+ content: string
103
+ scoped: boolean
104
+ }
105
+ /** Layout info */
106
+ export declare interface LayoutInfo {
107
+ extends: string
108
+ line: number
109
+ sections: string[]
110
+ }
111
+ /** Visual editor template complexity metrics */
112
+ export declare interface VisualEditorMetrics {
113
+ lines: number
114
+ characters: number
115
+ maxNestingDepth: number
116
+ directiveCount: number
117
+ componentCount: number
118
+ expressionCount: number
119
+ complexity: number
120
+ }
121
+ /** Visual editor preview options */
122
+ export declare interface VisualEditorPreviewOptions {
123
+ context?: Record<string, unknown>
124
+ includeStyles?: boolean
125
+ includeScripts?: boolean
126
+ wrapInDocument?: boolean
127
+ baseUrl?: string
128
+ customCss?: string
129
+ }
130
+ /** Component palette item */
131
+ export declare interface PaletteItem {
132
+ name: string
133
+ displayName: string
134
+ category: string
135
+ description: string
136
+ icon?: string
137
+ snippet: string
138
+ props?: VisualEditorPropDefinition[]
139
+ slots?: string[]
140
+ }
141
+ /** Visual editor prop definition for palette */
142
+ export declare interface VisualEditorPropDefinition {
143
+ name: string
144
+ type: string
145
+ required: boolean
146
+ default?: string
147
+ description?: string
148
+ }
149
+ /** Editor selection/position */
150
+ export declare interface EditorPosition {
151
+ line: number
152
+ column: number
153
+ offset: number
154
+ }
155
+ /** Insert operation result */
156
+ export declare interface InsertResult {
157
+ content: string
158
+ cursorPosition: EditorPosition
159
+ }
160
+ /**
161
+ * Visual Editor Integration Module
162
+ *
163
+ * Provides APIs for visual template editing in IDEs and editors.
164
+ * This module enables:
165
+ * - Template AST visualization
166
+ * - Component outline/structure view
167
+ * - Drag-and-drop component editing
168
+ * - Live preview support
169
+ * - Template property inspection
170
+ *
171
+ * ## Usage
172
+ *
173
+ * ```typescript
174
+ * import { analyzeTemplate, getTemplateOutline, generatePreview } from 'stx/visual-editor'
175
+ *
176
+ * // Analyze template structure
177
+ * const analysis = analyzeTemplate(templateContent)
178
+ *
179
+ * // Get hierarchical outline
180
+ * const outline = getTemplateOutline(templateContent)
181
+ *
182
+ * // Generate preview HTML
183
+ * const preview = await generatePreview(templateContent, context)
184
+ * ```
185
+ *
186
+ * @module visual-editor
187
+ */
188
+ /** Node types in template outline */
189
+ export type OutlineNodeType = | 'document'
190
+ | 'element'
191
+ | 'component'
192
+ | 'directive'
193
+ | 'slot'
194
+ | 'section'
195
+ | 'expression'
196
+ | 'script'
197
+ | 'style'
198
+ | 'comment'
199
+ | 'text'
200
+ /** Directive category for visual grouping */
201
+ export type DirectiveCategory = | 'control-flow'
202
+ | 'loop'
203
+ | 'layout'
204
+ | 'component'
205
+ | 'auth'
206
+ | 'form'
207
+ | 'seo'
208
+ | 'i18n'
209
+ | 'custom'
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Create a snapshot tester
3
+ */
4
+ export declare function createSnapshotTester(config?: VisualTestConfig): void;
5
+ /**
6
+ * Create a visual regression tester
7
+ */
8
+ export declare function createVisualRegressionTester(config?: VisualTestConfig): void;
9
+ /**
10
+ * Create a story-based visual tester
11
+ */
12
+ export declare function createStoryTester(config?: VisualTestConfig): void;
13
+ /**
14
+ * Generate visual test report
15
+ */
16
+ export declare function generateReport(results: VisualTestResult[], config?: ReportConfig): Promise<string>;
17
+ /**
18
+ * Quick snapshot test
19
+ */
20
+ export declare function snapshot(html: string, name: string): Promise<SnapshotResult>;
21
+ /**
22
+ * Quick JSON snapshot test
23
+ */
24
+ export declare function snapshotJson(data: unknown, name: string): Promise<SnapshotResult>;
25
+ /**
26
+ * Reset default tester (for testing)
27
+ */
28
+ export declare function resetDefaultTester(): void;
29
+ // =============================================================================
30
+ // Default Viewports
31
+ // =============================================================================
32
+ export declare const defaultViewports: Viewport[];
33
+ // =============================================================================
34
+ // Types
35
+ // =============================================================================
36
+ export declare interface VisualTestConfig {
37
+ snapshotDir?: string
38
+ screenshotDir?: string
39
+ updateSnapshots?: boolean
40
+ threshold?: number
41
+ viewports?: Viewport[]
42
+ generateDiff?: boolean
43
+ diffDir?: string
44
+ compare?: (actual: Buffer, expected: Buffer) => Promise<ComparisonResult>
45
+ ci?: boolean
46
+ retries?: number
47
+ }
48
+ export declare interface Viewport {
49
+ name: string
50
+ width: number
51
+ height: number
52
+ deviceScaleFactor?: number
53
+ isMobile?: boolean
54
+ hasTouch?: boolean
55
+ }
56
+ export declare interface SnapshotResult {
57
+ passed: boolean
58
+ snapshotPath: string
59
+ actualPath?: string
60
+ diffPath?: string
61
+ message?: string
62
+ }
63
+ export declare interface ComparisonResult {
64
+ match: boolean
65
+ diffPercentage: number
66
+ diffPixels: number
67
+ diffImage?: Buffer
68
+ }
69
+ export declare interface VisualTestResult {
70
+ name: string
71
+ passed: boolean
72
+ duration: number
73
+ snapshots: SnapshotResult[]
74
+ screenshots: ScreenshotResult[]
75
+ errors: Error[]
76
+ }
77
+ export declare interface ScreenshotResult {
78
+ viewport: string
79
+ passed: boolean
80
+ baselinePath: string
81
+ actualPath?: string
82
+ diffPath?: string
83
+ diffPercentage?: number
84
+ }
85
+ export declare interface Story {
86
+ name: string
87
+ component: string
88
+ render: () => string | Promise<string>
89
+ args?: Record<string, unknown>
90
+ viewports?: Viewport[]
91
+ }
92
+ // =============================================================================
93
+ // Test Reporter
94
+ // =============================================================================
95
+ export declare interface ReportConfig {
96
+ outputDir?: string
97
+ format?: 'html' | 'json' | 'markdown'
98
+ title?: string
99
+ includeScreenshots?: boolean
100
+ }
101
+ export default {
102
+ createSnapshotTester,
103
+ createVisualRegressionTester,
104
+ createStoryTester,
105
+ generateReport,
106
+ snapshot,
107
+ snapshotJson,
108
+ defaultViewports,
109
+ };