@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/init.d.ts CHANGED
@@ -2,8 +2,38 @@
2
2
  * Initialize a new stx file with the specified name
3
3
  */
4
4
  export declare function initFile(fileName?: string, options?: InitOptions): Promise<boolean>;
5
- // Interface for init options
5
+ /**
6
+ * Available template presets with descriptions
7
+ */
8
+ export declare const TEMPLATE_PRESETS: {
9
+ basic: {
10
+ description: 'Simple page with script, style, and template sections'
11
+ };
12
+ component: {
13
+ description: 'Reusable component with props and slots'
14
+ };
15
+ layout: {
16
+ description: 'Layout template with sections and yields'
17
+ };
18
+ blog: {
19
+ description: 'Blog post with frontmatter-style variables'
20
+ };
21
+ api: {
22
+ description: 'API endpoint template with JSON response'
23
+ };
24
+ app: {
25
+ description: 'Full app with stores and components'
26
+ }
27
+ };
28
+ /**
29
+ * Options for initializing a new stx file
30
+ */
6
31
  declare interface InitOptions {
7
32
  force?: boolean
8
33
  template?: string
9
- }
34
+ preset?: TemplatePreset
35
+ }
36
+ /**
37
+ * Built-in template presets
38
+ */
39
+ declare type TemplatePreset = 'basic' | 'component' | 'layout' | 'blog' | 'api' | 'app'
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Start interactive CLI mode
3
+ */
4
+ export declare function startInteractive(options?: InteractiveOptions): Promise<void>;
5
+ // =============================================================================
6
+ // Types
7
+ // =============================================================================
8
+ export declare interface InteractiveOptions {
9
+ context?: Record<string, any>
10
+ cwd?: string
11
+ verbose?: boolean
12
+ historyFile?: string
13
+ maxHistory?: number
14
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Parse YAML frontmatter from markdown content
3
+ * Frontmatter is delimited by --- at the start of the file
4
+ */
5
+ export declare function parseFrontmatter(content: string): FrontmatterResult;
6
+ /**
7
+ * Convert markdown to HTML
8
+ * Simple implementation that handles common markdown patterns
9
+ */
10
+ export declare function parseMarkdown(content: string, options?: MarkdownOptions): string;
11
+ /**
12
+ * Internal markdown utilities to replace ts-md dependency
13
+ * Provides frontmatter parsing and markdown to HTML conversion
14
+ */
15
+ export declare interface FrontmatterResult {
16
+ data: Record<string, unknown>
17
+ content: string
18
+ }
19
+ export declare interface MarkdownOptions {
20
+ gfm?: boolean
21
+ breaks?: boolean
22
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Create a VNode. This is the function Bun's JSX transpiler calls.
3
+ *
4
+ * @param type - Tag name string, component function, or Fragment symbol
5
+ * @param props - Props object (may include children)
6
+ * @param key - Optional key for list reconciliation
7
+ */
8
+ export declare function jsx(type: string | ComponentFunction | typeof Fragment, props: Record<string, any> | null, key?: string | number | null): VNode;
9
+ /**
10
+ * Render a VNode tree to an HTML string.
11
+ * This is the primary SSR function.
12
+ *
13
+ * @param vnode - The VNode or string to render
14
+ * @returns HTML string
15
+ */
16
+ export declare function renderToString(vnode: VNode | string | null | undefined | boolean | number): string;
17
+ /**
18
+ * Render a VNode tree to a readable stream for streaming SSR.
19
+ */
20
+ export declare function renderToStream(vnode: VNode | string): ReadableStream<string>;
21
+ /**
22
+ * Render a VNode tree to real DOM nodes.
23
+ *
24
+ * @param vnode - The VNode or string to render
25
+ * @param container - The parent DOM element to append to
26
+ */
27
+ export declare function renderToDOM(vnode: VNode | string | null | undefined | boolean | number, container: Element): void;
28
+ /**
29
+ * Conditional rendering component — equivalent to v-if / @if.
30
+ *
31
+ * ```tsx
32
+ * <Show when={isVisible} fallback={<p>Hidden</p>}>
33
+ * <div>Visible content</div>
34
+ * </Show>
35
+ * ```
36
+ */
37
+ export declare function Show(props: { when: any, fallback?: VNode | string | null, children?: any }): VNode | string | null;
38
+ /**
39
+ * List rendering component — equivalent to v-for / @foreach.
40
+ *
41
+ * ```tsx
42
+ * <For each={items}>
43
+ * {(item, index) => <div key={item.id}>{item.name}</div>}
44
+ * </For>
45
+ * ```
46
+ */
47
+ export declare function For<T>(props: { each: T[] | undefined | null, fallback?: VNode | string | null, children: ((item: T, index: number) => VNode | string) | Array<(item: T, index: number) => VNode | string> }): VNode | string | null;
48
+ /**
49
+ * Portal/Teleport component — renders children to a different DOM target.
50
+ * Only effective on client-side; SSR renders children inline.
51
+ *
52
+ * ```tsx
53
+ * <Portal to="body">
54
+ * <div class="modal">Modal content</div>
55
+ * </Portal>
56
+ * ```
57
+ */
58
+ export declare function Portal(props: { to: string, children?: any }): VNode | string | null;
59
+ /**
60
+ * Create a VNode using the h() function syntax (alternative to JSX).
61
+ *
62
+ * ```ts
63
+ * import { h } from '@stacksjs/stx/jsx-runtime'
64
+ *
65
+ * const vnode = h('div', { class: 'container' },
66
+ * h('h1', null, 'Hello'),
67
+ * h('p', null, 'World')
68
+ * )
69
+ * ```
70
+ */
71
+ export declare function h(type: string | ComponentFunction | typeof Fragment, props?: Record<string, any> | null, ...children: any[]): VNode;
72
+ /** Fragment symbol - renders children without a wrapper element */
73
+ export declare const Fragment: unique symbol;
74
+ /**
75
+ * Same as jsx — Bun's transpiler uses jsxs when there are multiple static children.
76
+ */
77
+ export declare const jsxs: unknown;
78
+ /**
79
+ * Development version of jsx with extra validation.
80
+ */
81
+ export declare const jsxDEV: unknown;
82
+ /**
83
+ * STX JSX Runtime
84
+ *
85
+ * Self-made JSX runtime for stx — no React, no Preact, no external dependencies.
86
+ * This module provides the jsx/jsxs/Fragment functions that Bun's JSX transpiler calls,
87
+ * plus renderToString() for SSR and renderToDOM() for client-side rendering.
88
+ *
89
+ * Usage in tsconfig.json:
90
+ * ```json
91
+ * {
92
+ * "compilerOptions": {
93
+ * "jsx": "react-jsx",
94
+ * "jsxImportSource": "@stacksjs/stx"
95
+ * }
96
+ * }
97
+ * ```
98
+ *
99
+ * @module jsx-runtime
100
+ */
101
+ /** Virtual DOM node representation */
102
+ export declare interface VNode {
103
+ type: string | ComponentFunction | typeof Fragment
104
+ props: Record<string, any> | null
105
+ children: Array<VNode | string>
106
+ key?: string | number | null
107
+ ref?: string | ((el: any) => void) | null
108
+ }
109
+ /** Function component type */
110
+ export type ComponentFunction = (props: Record<string, any>) => VNode | string | null
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Process @keepAlive directives in templates.
3
+ *
4
+ * Syntax:
5
+ * @keepAlive
6
+ * <content to cache>
7
+ * @endkeepAlive
8
+ *
9
+ * With options:
10
+ * @keepAlive(max: 10, include: 'ComponentA,ComponentB')
11
+ */
12
+ export declare function processKeepAliveDirectives(template: string, _context?: Record<string, unknown>, _filePath?: string): string;
13
+ /**
14
+ * Create a keep-alive cache programmatically.
15
+ */
16
+ export declare function createKeepAliveCache(options?: KeepAliveOptions): KeepAliveCache;
17
+ /**
18
+ * Check if a component should be cached based on filters.
19
+ */
20
+ export declare function shouldCacheComponent(componentName: string, cache: KeepAliveCache): boolean;
21
+ /**
22
+ * Generate CSS for keep-alive styling.
23
+ */
24
+ export declare function generateKeepAliveCSS(): string;
25
+ /**
26
+ * Generate client-side runtime for keep-alive.
27
+ */
28
+ export declare function generateKeepAliveRuntime(): string;
29
+ /**
30
+ * Hook called when a component is activated from cache.
31
+ * Use in client-side scripts.
32
+ */
33
+ export declare function onActivated(callback: (detail: { key: string; keepAliveId: string; cachedAt: number }) => void): void;
34
+ /**
35
+ * Hook called when a component is deactivated and cached.
36
+ * Use in client-side scripts.
37
+ */
38
+ export declare function onDeactivated(callback: (detail: { key: string; keepAliveId: string }) => void): void;
39
+ /**
40
+ * STX Keep-Alive
41
+ *
42
+ * Caches component instances to preserve state when toggling visibility.
43
+ * Similar to Vue's <KeepAlive> component.
44
+ *
45
+ * @module keep-alive
46
+ *
47
+ * @example
48
+ * ```html
49
+ * @keepAlive
50
+ * @if (currentTab === 'settings')
51
+ * <SettingsPanel />
52
+ * @elseif (currentTab === 'profile')
53
+ * <ProfilePanel />
54
+ * @endif
55
+ * @endkeepAlive
56
+ * ```
57
+ *
58
+ * With options:
59
+ * ```html
60
+ * @keepAlive(max: 10, include: 'Settings,Profile', exclude: 'Debug')
61
+ * <component :is="currentComponent" />
62
+ * @endkeepAlive
63
+ * ```
64
+ */
65
+ // =============================================================================
66
+ // Types
67
+ // =============================================================================
68
+ export declare interface KeepAliveOptions {
69
+ max?: number
70
+ include?: string
71
+ exclude?: string
72
+ id?: string
73
+ }
74
+ export declare interface CachedComponent {
75
+ key: string
76
+ html: string
77
+ state: Record<string, unknown>
78
+ cachedAt: number
79
+ scrollPositions: Map<string, { top: number; left: number }>
80
+ }
81
+ export declare interface KeepAliveCache {
82
+ id: string
83
+ cache: Map<string, CachedComponent>
84
+ max: number
85
+ include: string[] | null
86
+ exclude: string[] | null
87
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Default lazy-loaded directive registry
3
+ */
4
+ export declare function createDirectiveRegistry(): DirectiveLoaderRegistry;
5
+ /**
6
+ * Create a lazy module that loads on first access
7
+ */
8
+ export declare function createLazyModule<T>(loader: ModuleLoader<T>): {
9
+ get: () => Promise<T>
10
+ isLoaded: () => boolean
11
+ preload: () => Promise<void>
12
+ };
13
+ /**
14
+ * Batch load multiple modules with progress callback
15
+ */
16
+ export declare function batchLoad<T>(loader: LazyLoader<T>, names: string[], onProgress?: (loaded: number, total: number, name: string) => void): Promise<Map<string, T>>;
17
+ /**
18
+ * Global lazy loader instance
19
+ */
20
+ export declare const globalLoader: LazyLoader<unknown>;
21
+ /**
22
+ * Global directive registry
23
+ */
24
+ export declare const directiveRegistry: DirectiveLoaderRegistry;
25
+ /**
26
+ * Lazy loader options
27
+ */
28
+ export declare interface LazyLoaderOptions {
29
+ preload?: string[]
30
+ timeout?: number
31
+ debug?: boolean
32
+ onError?: (name: string, error: Error) => void
33
+ }
34
+ /**
35
+ * Directive processor interface
36
+ */
37
+ export declare interface DirectiveProcessor {
38
+ process: (content: string, params?: string, context?: Record<string, unknown>) => string | Promise<string>
39
+ name?: string
40
+ hasEndTag?: boolean
41
+ }
42
+ /**
43
+ * Lazy Loading for Directive Processors
44
+ *
45
+ * Provides lazy loading capabilities for directive processors to reduce
46
+ * initial load time and memory usage.
47
+ *
48
+ * ## Features
49
+ *
50
+ * - On-demand loading of directive processors
51
+ * - Module caching to prevent re-imports
52
+ * - Support for both sync and async loading
53
+ * - Automatic dependency resolution
54
+ *
55
+ * ## Usage
56
+ *
57
+ * ```typescript
58
+ * const loader = new LazyLoader()
59
+ *
60
+ * // Register lazy directive
61
+ * loader.register('markdown', () => import('./markdown'))
62
+ *
63
+ * // Load when needed
64
+ * const markdown = await loader.load('markdown')
65
+ * ```
66
+ *
67
+ * @module lazy-loader
68
+ */
69
+ /**
70
+ * Module loader function
71
+ */
72
+ export type ModuleLoader<T = unknown> = () => Promise<T> | T
73
+ /**
74
+ * Module status
75
+ */
76
+ export type ModuleStatus = 'pending' | 'loading' | 'loaded' | 'error'
77
+ /**
78
+ * Lazy loader for directive processors
79
+ */
80
+ export declare class LazyLoader<T = unknown> {
81
+ private modules: Map<string, ModuleInfo<T>>;
82
+ private options: LazyLoaderOptions;
83
+ constructor(options?: LazyLoaderOptions);
84
+ register(name: string, loader: ModuleLoader<T>, dependencies?: string[]): void;
85
+ registerAll(modules: Record<string, ModuleLoader<T>>): void;
86
+ has(name: string): boolean;
87
+ getStatus(name: string): ModuleStatus | null;
88
+ isLoaded(name: string): boolean;
89
+ load(name: string): Promise<T>;
90
+ loadAll(names: string[]): Promise<T[]>;
91
+ loadSync(name: string): T;
92
+ preload(names: string[]): Promise<void>;
93
+ unload(name: string): boolean;
94
+ unloadAll(): void;
95
+ getStats(): {
96
+ registered: number
97
+ loaded: number
98
+ pending: number
99
+ errors: number
100
+ totalLoadTime: number
101
+ modules: Array<{
102
+ name: string
103
+ status: ModuleStatus
104
+ loadCount: number
105
+ loadTime?: number
106
+ }>
107
+ };
108
+ private loadWithTimeout(name: string, loader: ModuleLoader<T>): Promise<T>;
109
+ }
110
+ /**
111
+ * Lazy loader specifically for directive processors
112
+ */
113
+ export declare class DirectiveLoaderRegistry {
114
+ private loader: LazyLoader<DirectiveProcessor | { default: DirectiveProcessor }>;
115
+ private directiveMap: Map<string, string>;
116
+ constructor(options?: LazyLoaderOptions);
117
+ registerDirective(directiveName: string, moduleName: string, loader: ModuleLoader<DirectiveProcessor | { default: DirectiveProcessor }>): void;
118
+ getProcessor(directiveName: string): Promise<DirectiveProcessor | null>;
119
+ hasDirective(directiveName: string): boolean;
120
+ getDirectiveNames(): string[];
121
+ preloadDirectives(directiveNames: string[]): Promise<void>;
122
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Create a loading indicator instance (composable-style)
3
+ */
4
+ export declare function useLoadingIndicator(userOptions?: LoadingIndicatorOptions): LoadingIndicatorInstance;
5
+ /**
6
+ * Initialize automatic loading indicator for page navigation
7
+ * Call this once in your app to enable automatic loading on route changes
8
+ */
9
+ export declare function initLoadingIndicator(userOptions?: LoadingIndicatorOptions): void;
10
+ /**
11
+ * Generate the HTML for the loading indicator component
12
+ * This is used by the STX compiler for <stx-loading-indicator />
13
+ */
14
+ export declare function generateLoadingIndicatorHtml(options?: LoadingIndicatorOptions): string;
15
+ export declare interface LoadingIndicatorOptions {
16
+ color?: string
17
+ initialColor?: string
18
+ height?: string
19
+ duration?: number
20
+ throttle?: number
21
+ autoFinish?: boolean
22
+ zIndex?: number
23
+ }
24
+ export declare interface LoadingIndicatorState {
25
+ isLoading: boolean
26
+ progress: number
27
+ error: boolean
28
+ }
29
+ export declare interface LoadingIndicatorInstance {
30
+ start: () => void
31
+ set: (value: number) => void
32
+ finish: () => void
33
+ clear: () => void
34
+ state: LoadingIndicatorState
35
+ }
36
+ export default {
37
+ useLoadingIndicator,
38
+ initLoadingIndicator,
39
+ generateLoadingIndicatorHtml,
40
+ };
package/dist/loops.d.ts CHANGED
@@ -1,4 +1,25 @@
1
+ import type { StxOptions } from './types';
1
2
  /**
2
3
  * Process loops (@foreach, @for, @while, @forelse)
4
+ *
5
+ * Loop Configuration (via options.loops):
6
+ * - maxWhileIterations: Safety limit for @while loops (default: 1000)
7
+ * - useAltLoopVariable: Use $loop instead of loop (default: false)
8
+ *
9
+ * Loop Context Variables:
10
+ * Within @foreach loops, a loop context object is available:
11
+ * - loop.index: Current zero-based index
12
+ * - loop.iteration: Current one-based iteration count
13
+ * - loop.first: Boolean, true if first iteration
14
+ * - loop.last: Boolean, true if last iteration
15
+ * - loop.count: Total number of items
16
+ *
17
+ * If options.loops.useAltLoopVariable is true, use $loop instead of loop
18
+ * to avoid conflicts with user variables named 'loop'.
19
+ *
20
+ * @param template - Template string to process
21
+ * @param context - Template context with variables
22
+ * @param filePath - Path to template file for error messages
23
+ * @param options - Optional stx configuration
3
24
  */
4
- export declare function processLoops(template: string, context: Record<string, any>, filePath: string): string;
25
+ export declare function processLoops(template: string, context: Record<string, any>, filePath: string, options?: StxOptions): string;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Initialize blur-up effect for an image
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const img = document.querySelector('img.has-placeholder')
7
+ * initBlurUp(img, { duration: 500 })
8
+ * ```
9
+ */
10
+ export declare function initBlurUp(img: HTMLImageElement, options?: BlurUpOptions): void;
11
+ /**
12
+ * Render a thumbhash to a canvas element
13
+ *
14
+ * Based on https://github.com/evanw/thumbhash
15
+ */
16
+ export declare function renderThumbhashToCanvas(hash: Uint8Array, canvas: HTMLCanvasElement): void;
17
+ /**
18
+ * Decode a thumbhash to RGBA pixel data
19
+ *
20
+ * This is a minimal decoder based on the thumbhash spec.
21
+ * Returns a 32x32 RGBA image.
22
+ */
23
+ export declare function thumbHashToRGBA(hash: Uint8Array): { w: number; h: number; rgba: Uint8ClampedArray };
24
+ /**
25
+ * Convert a thumbhash to a data URL
26
+ */
27
+ export declare function thumbHashToDataURL(hash: Uint8Array): string;
28
+ /**
29
+ * Parse a base64-encoded thumbhash string
30
+ */
31
+ export declare function parseThumbhashString(base64: string): Uint8Array;
32
+ /**
33
+ * Crossfade transition between two elements
34
+ */
35
+ export declare function crossfadeTransition(from: HTMLElement, to: HTMLElement, duration?: number): Promise<void>;
36
+ /**
37
+ * Initialize blur-up for all elements with data-stx-blur-up
38
+ */
39
+ export declare function initAllBlurUp(options?: BlurUpOptions): void;
40
+ /**
41
+ * Generate the client-side blur-up runtime script
42
+ */
43
+ export declare function generateBlurUpRuntime(): string;
44
+ /**
45
+ * Generate CSS for blur-up effect
46
+ */
47
+ export declare function generateBlurUpCSS(): string;
48
+ /**
49
+ * STX Media - Client-Side Blur-Up Animation
50
+ *
51
+ * Smooth blur-up transition from placeholder to full image.
52
+ * Supports thumbhash, blur LQIP, and color placeholders.
53
+ *
54
+ * @module media/client/blur-up
55
+ */
56
+ // =============================================================================
57
+ // Types
58
+ // =============================================================================
59
+ export declare interface BlurUpOptions {
60
+ duration?: number
61
+ easing?: string
62
+ removePlaceholder?: boolean
63
+ loadedClass?: string
64
+ loadingClass?: string
65
+ }
@@ -0,0 +1,77 @@
1
+ import { generateBlurUpRuntime, generateBlurUpCSS } from './blur-up';
2
+ import { generateLazyLoadRuntime } from './lazy-load';
3
+ import { generateUploadRuntime } from './upload-handler';
4
+ /**
5
+ * Generate the complete media client runtime
6
+ */
7
+ export declare function generateMediaRuntime(): { script: string; css: string };
8
+ /**
9
+ * Generate minified media runtime for production
10
+ */
11
+ export declare function generateMinifiedMediaRuntime(): { script: string; css: string };
12
+ export {
13
+ // Types
14
+ type LazyLoadOptions,
15
+
16
+ // Feature detection
17
+ isNativeLazySupported,
18
+ isIntersectionObserverSupported,
19
+
20
+ // Initialization
21
+ initLazyLoading,
22
+ loadElement,
23
+
24
+ // Manual loading
25
+ lazyLoad,
26
+ lazyLoadAll,
27
+
28
+ // Observer utilities
29
+ createLazyObserver,
30
+ observeElement,
31
+ disconnectObserver,
32
+
33
+ // Runtime generation
34
+ generateLazyLoadRuntime,
35
+ } from './lazy-load';
36
+ export {
37
+ // Types
38
+ type BlurUpOptions,
39
+
40
+ // Initialization
41
+ initBlurUp,
42
+ initAllBlurUp,
43
+
44
+ // Thumbhash utilities
45
+ renderThumbhashToCanvas,
46
+ thumbHashToRGBA,
47
+ thumbHashToDataURL,
48
+ parseThumbhashString,
49
+
50
+ // Transitions
51
+ crossfadeTransition,
52
+
53
+ // Runtime generation
54
+ generateBlurUpRuntime,
55
+ generateBlurUpCSS,
56
+ } from './blur-up';
57
+ export {
58
+ // Types
59
+ type UploadHandlerOptions,
60
+ type UploadProgress,
61
+ type UploadResult,
62
+ type FileValidationResult,
63
+
64
+ // Validation
65
+ validateFile,
66
+
67
+ // Upload functions
68
+ uploadFile,
69
+ uploadFiles,
70
+
71
+ // Preview generation
72
+ generateImagePreview,
73
+ generateVideoPreview,
74
+
75
+ // Runtime generation
76
+ generateUploadRuntime,
77
+ } from './upload-handler';
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Check if native lazy loading is supported
3
+ */
4
+ export declare function isNativeLazySupported(): boolean;
5
+ /**
6
+ * Check if IntersectionObserver is supported
7
+ */
8
+ export declare function isIntersectionObserverSupported(): boolean;
9
+ /**
10
+ * Initialize lazy loading for all matching elements
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Initialize with default options
15
+ * initLazyLoading()
16
+ *
17
+ * // Initialize with custom options
18
+ * initLazyLoading({
19
+ * rootMargin: '100px',
20
+ * onLoaded: (el) => console.log('Loaded:', el)
21
+ * })
22
+ * ```
23
+ */
24
+ export declare function initLazyLoading(options?: LazyLoadOptions): () => void;
25
+ /**
26
+ * Load a single lazy element
27
+ */
28
+ export declare function loadElement(element: HTMLElement, options?: LazyLoadOptions): void;
29
+ /**
30
+ * Manually trigger loading for a specific element
31
+ */
32
+ export declare function lazyLoad(element: HTMLElement): void;
33
+ /**
34
+ * Manually trigger loading for all matching elements
35
+ */
36
+ export declare function lazyLoadAll(selector?: string): void;
37
+ /**
38
+ * Create a reusable intersection observer
39
+ */
40
+ export declare function createLazyObserver(options?: LazyLoadOptions): IntersectionObserver;
41
+ /**
42
+ * Observe a new element with an existing observer
43
+ */
44
+ export declare function observeElement(observer: IntersectionObserver, element: HTMLElement): void;
45
+ /**
46
+ * Unobserve all elements and disconnect
47
+ */
48
+ export declare function disconnectObserver(observer: IntersectionObserver): void;
49
+ /**
50
+ * Generate the client-side lazy loading runtime script
51
+ */
52
+ export declare function generateLazyLoadRuntime(): string;
53
+ /**
54
+ * STX Media - Client-Side Lazy Loading
55
+ *
56
+ * IntersectionObserver-based lazy loading for images and media.
57
+ * Supports native loading="lazy" with intelligent fallback.
58
+ *
59
+ * @module media/client/lazy-load
60
+ */
61
+ // =============================================================================
62
+ // Types
63
+ // =============================================================================
64
+ export declare interface LazyLoadOptions {
65
+ root?: Element | null
66
+ rootMargin?: string
67
+ threshold?: number | number[]
68
+ useNative?: boolean
69
+ selector?: string
70
+ onLoad?: (element: HTMLElement) => void
71
+ onLoaded?: (element: HTMLElement) => void
72
+ onError?: (element: HTMLElement, error: Error) => void
73
+ }