@stacksjs/stx 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/dist/a11y.d.ts +109 -5
  2. package/dist/analytics.d.ts +40 -0
  3. package/dist/animation.d.ts +90 -0
  4. package/dist/app.d.ts +51 -0
  5. package/dist/ast.d.ts +286 -0
  6. package/dist/async-components.d.ts +101 -0
  7. package/dist/auth.d.ts +1 -3
  8. package/dist/browser-composables.d.ts +314 -0
  9. package/dist/build-optimizer.d.ts +126 -0
  10. package/dist/build-views.d.ts +37 -0
  11. package/dist/bundle-analyzer/collector.d.ts +66 -0
  12. package/dist/bundle-analyzer/index.d.ts +60 -0
  13. package/dist/bundle-analyzer/report.d.ts +39 -0
  14. package/dist/bundle-analyzer/treemap.d.ts +19 -0
  15. package/dist/bundle-analyzer.js +499 -0
  16. package/dist/caching.d.ts +7 -0
  17. package/dist/cli.js +10880 -1199
  18. package/dist/client/directive.d.ts +10 -0
  19. package/dist/client/index.d.ts +7 -0
  20. package/dist/client/router.d.ts +36 -0
  21. package/dist/client/stx-router.browser.d.ts +0 -0
  22. package/dist/client-script.d.ts +22 -0
  23. package/dist/component-hmr.d.ts +120 -0
  24. package/dist/components.d.ts +23 -1
  25. package/dist/composables/index.d.ts +277 -0
  26. package/dist/composables/use-battery.d.ts +46 -0
  27. package/dist/composables/use-broadcast-channel.d.ts +58 -0
  28. package/dist/composables/use-clipboard.d.ts +34 -0
  29. package/dist/composables/use-cookie.d.ts +70 -0
  30. package/dist/composables/use-device-orientation.d.ts +109 -0
  31. package/dist/composables/use-event-source.d.ts +77 -0
  32. package/dist/composables/use-eye-dropper.d.ts +107 -0
  33. package/dist/composables/use-fetch.d.ts +84 -0
  34. package/dist/composables/use-fullscreen.d.ts +47 -0
  35. package/dist/composables/use-geolocation.d.ts +62 -0
  36. package/dist/composables/use-idle.d.ts +84 -0
  37. package/dist/composables/use-intersection-observer.d.ts +81 -0
  38. package/dist/composables/use-keyboard.d.ts +100 -0
  39. package/dist/composables/use-media-query.d.ts +56 -0
  40. package/dist/composables/use-mouse.d.ts +64 -0
  41. package/dist/composables/use-mutation-observer.d.ts +101 -0
  42. package/dist/composables/use-network.d.ts +40 -0
  43. package/dist/composables/use-notification.d.ts +89 -0
  44. package/dist/composables/use-permissions.d.ts +109 -0
  45. package/dist/composables/use-resize-observer.d.ts +60 -0
  46. package/dist/composables/use-share.d.ts +70 -0
  47. package/dist/composables/use-speech.d.ts +117 -0
  48. package/dist/composables/use-storage.d.ts +64 -0
  49. package/dist/composables/use-text-selection.d.ts +97 -0
  50. package/dist/composables/use-wake-lock.d.ts +85 -0
  51. package/dist/composables/use-websocket.d.ts +69 -0
  52. package/dist/composables/use-window.d.ts +84 -0
  53. package/dist/composables.d.ts +268 -0
  54. package/dist/composition-api.d.ts +190 -0
  55. package/dist/computed.d.ts +137 -0
  56. package/dist/conditionals.d.ts +14 -2
  57. package/dist/config.d.ts +35 -2
  58. package/dist/craft-bridge.d.ts +319 -0
  59. package/dist/craft-compiler.d.ts +229 -0
  60. package/dist/craft-components.d.ts +411 -0
  61. package/dist/craft-entry.d.ts +5 -0
  62. package/dist/craft-ssr.d.ts +134 -0
  63. package/dist/craft.js +1553 -0
  64. package/dist/csp.d.ts +229 -0
  65. package/dist/database.d.ts +407 -0
  66. package/dist/database.js +5 -0
  67. package/dist/defer.d.ts +4 -0
  68. package/dist/deploy/config-generators.d.ts +75 -0
  69. package/dist/deploy/index.d.ts +84 -0
  70. package/dist/deploy/netlify.d.ts +109 -0
  71. package/dist/dev-server/crosswind.d.ts +54 -0
  72. package/dist/dev-server/index.d.ts +7 -0
  73. package/dist/dev-server/keyboard-shortcuts.d.ts +34 -0
  74. package/dist/dev-server/native-window.d.ts +40 -0
  75. package/dist/dev-server/port-utils.d.ts +27 -0
  76. package/dist/dev-server/terminal-colors.d.ts +60 -0
  77. package/dist/dev-server/theme-selector.d.ts +32 -0
  78. package/dist/dev-server/types.d.ts +92 -0
  79. package/dist/dev-server.d.ts +21 -0
  80. package/dist/devtools.d.ts +142 -0
  81. package/dist/directive-api.d.ts +111 -0
  82. package/dist/dynamic-components.d.ts +14 -0
  83. package/dist/edge-runtime.d.ts +200 -0
  84. package/dist/env.d.ts +9 -0
  85. package/dist/error-boundaries.d.ts +71 -0
  86. package/dist/error-handling.d.ts +1 -101
  87. package/dist/errors/codes.d.ts +99 -0
  88. package/dist/errors/formatter.d.ts +64 -0
  89. package/dist/errors/index.d.ts +56 -0
  90. package/dist/errors/logger.d.ts +74 -0
  91. package/dist/errors/sanitizer.d.ts +43 -0
  92. package/dist/errors/types.d.ts +79 -0
  93. package/dist/events.d.ts +106 -0
  94. package/dist/expressions.d.ts +86 -11
  95. package/dist/forms-validation.d.ts +173 -0
  96. package/dist/forms.d.ts +157 -8
  97. package/dist/head.d.ts +225 -0
  98. package/dist/heatmap.d.ts +125 -0
  99. package/dist/hot-reload.d.ts +87 -0
  100. package/dist/hydration-runtime.d.ts +47 -0
  101. package/dist/hydration.d.ts +161 -0
  102. package/dist/i18n.d.ts +239 -3
  103. package/dist/image-optimization/build-plugin.d.ts +53 -0
  104. package/dist/image-optimization/component.d.ts +46 -0
  105. package/dist/image-optimization/directive.d.ts +30 -0
  106. package/dist/image-optimization/index.d.ts +86 -0
  107. package/dist/image-optimization/processor.d.ts +112 -0
  108. package/dist/includes.d.ts +94 -9
  109. package/dist/index.d.ts +63 -3
  110. package/dist/index.js +11603 -1318
  111. package/dist/init.d.ts +32 -2
  112. package/dist/interactive.d.ts +14 -0
  113. package/dist/internal-markdown.d.ts +22 -0
  114. package/dist/jsx-runtime.d.ts +110 -0
  115. package/dist/keep-alive.d.ts +87 -0
  116. package/dist/lazy-loader.d.ts +122 -0
  117. package/dist/loading-indicator.d.ts +40 -0
  118. package/dist/loops.d.ts +22 -1
  119. package/dist/media/client/blur-up.d.ts +65 -0
  120. package/dist/media/client/index.d.ts +77 -0
  121. package/dist/media/client/lazy-load.d.ts +73 -0
  122. package/dist/media/client/upload-handler.d.ts +79 -0
  123. package/dist/media/image/component.d.ts +46 -0
  124. package/dist/media/image/directive.d.ts +9 -0
  125. package/dist/media/image/editing.d.ts +212 -0
  126. package/dist/media/image/index.d.ts +118 -0
  127. package/dist/media/image/placeholder.d.ts +78 -0
  128. package/dist/media/image/processor/cache.d.ts +32 -0
  129. package/dist/media/image/processor/index.d.ts +12 -0
  130. package/dist/media/image/processor/optimizer.d.ts +13 -0
  131. package/dist/media/image/processor/responsive.d.ts +17 -0
  132. package/dist/media/image/srcset.d.ts +158 -0
  133. package/dist/media/index.d.ts +295 -0
  134. package/dist/media/manager/embed.d.ts +25 -0
  135. package/dist/media/protected/component.d.ts +34 -0
  136. package/dist/media/protected/index.d.ts +34 -0
  137. package/dist/media/protected/signature.d.ts +72 -0
  138. package/dist/media/shared/cache.d.ts +54 -0
  139. package/dist/media/shared/hash.d.ts +24 -0
  140. package/dist/media/shared/index.d.ts +2 -0
  141. package/dist/media/types.d.ts +1051 -0
  142. package/dist/media/upload/component.d.ts +23 -0
  143. package/dist/media/upload/index.d.ts +1 -0
  144. package/dist/media/video/directive.d.ts +9 -0
  145. package/dist/media/video/index.d.ts +47 -0
  146. package/dist/media/video/processor/cache.d.ts +33 -0
  147. package/dist/media/video/processor/index.d.ts +21 -0
  148. package/dist/media/video/processor/streaming.d.ts +19 -0
  149. package/dist/media/video/processor/thumbnail.d.ts +28 -0
  150. package/dist/media/video/processor/transcoder.d.ts +9 -0
  151. package/dist/middleware.d.ts +42 -3
  152. package/dist/native-build.d.ts +74 -0
  153. package/dist/parser/directive-parser.d.ts +79 -0
  154. package/dist/parser/expression-parser.d.ts +59 -0
  155. package/dist/parser/index.d.ts +35 -0
  156. package/dist/parser/tokenizer.d.ts +81 -0
  157. package/dist/partial-hydration.d.ts +88 -0
  158. package/dist/performance-utils.d.ts +146 -3
  159. package/dist/plugin-system.d.ts +128 -0
  160. package/dist/precompiler.d.ts +108 -0
  161. package/dist/production-build.d.ts +199 -0
  162. package/dist/props.d.ts +199 -0
  163. package/dist/pwa/audit.d.ts +42 -0
  164. package/dist/pwa/directives.d.ts +29 -0
  165. package/dist/pwa/icons.d.ts +39 -0
  166. package/dist/pwa/index.d.ts +59 -0
  167. package/dist/pwa/inject.d.ts +22 -0
  168. package/dist/pwa/manifest.d.ts +104 -0
  169. package/dist/pwa/offline.d.ts +8 -0
  170. package/dist/pwa/precache.d.ts +29 -0
  171. package/dist/pwa/service-worker.d.ts +21 -0
  172. package/dist/pwa/workbox-strategies.d.ts +100 -0
  173. package/dist/pwa/workbox.d.ts +52 -0
  174. package/dist/pwa.d.ts +51 -0
  175. package/dist/pwa.js +8124 -0
  176. package/dist/reactive-bindings.d.ts +24 -0
  177. package/dist/reactive.d.ts +100 -0
  178. package/dist/reactivity.d.ts +253 -0
  179. package/dist/route-middleware.d.ts +232 -0
  180. package/dist/router.d.ts +31 -0
  181. package/dist/routes.d.ts +0 -7
  182. package/dist/runtime.d.ts +140 -0
  183. package/dist/safe-evaluator.d.ts +117 -3
  184. package/dist/scaffolding.d.ts +113 -0
  185. package/dist/seo.d.ts +120 -7
  186. package/dist/server-components.d.ts +134 -0
  187. package/dist/signals.d.ts +501 -0
  188. package/dist/slots.d.ts +63 -0
  189. package/dist/source-maps.d.ts +117 -0
  190. package/dist/ssg.d.ts +157 -0
  191. package/dist/ssg.js +6831 -0
  192. package/dist/ssr.d.ts +107 -0
  193. package/dist/state-management.d.ts +324 -0
  194. package/dist/stores-client.d.ts +70 -0
  195. package/dist/story/addons.d.ts +123 -0
  196. package/dist/story/analytics.d.ts +92 -0
  197. package/dist/story/auto-stories.d.ts +38 -0
  198. package/dist/story/bookmarks.d.ts +53 -0
  199. package/dist/story/bun-test.d.ts +44 -0
  200. package/dist/story/cli.d.ts +34 -0
  201. package/dist/story/collect/analyzer.d.ts +33 -0
  202. package/dist/story/collect/index.d.ts +27 -0
  203. package/dist/story/collect/parser.d.ts +17 -0
  204. package/dist/story/collect/scanner.d.ts +13 -0
  205. package/dist/story/collect/tree.d.ts +17 -0
  206. package/dist/story/commands/build.d.ts +14 -0
  207. package/dist/story/commands/dev.d.ts +16 -0
  208. package/dist/story/commands/index.d.ts +6 -0
  209. package/dist/story/commands/preview.d.ts +15 -0
  210. package/dist/story/compiled-output.d.ts +26 -0
  211. package/dist/story/composition.d.ts +47 -0
  212. package/dist/story/config-watcher.d.ts +26 -0
  213. package/dist/story/config.d.ts +26 -0
  214. package/dist/story/context.d.ts +21 -0
  215. package/dist/story/controls/index.d.ts +54 -0
  216. package/dist/story/crosswind.d.ts +29 -0
  217. package/dist/story/desktop-preview.d.ts +34 -0
  218. package/dist/story/docs-generator.d.ts +30 -0
  219. package/dist/story/errors.d.ts +47 -0
  220. package/dist/story/figma-export.d.ts +169 -0
  221. package/dist/story/generator.d.ts +21 -0
  222. package/dist/story/hmr.d.ts +64 -0
  223. package/dist/story/hot-swap.d.ts +35 -0
  224. package/dist/story/index.d.ts +51 -0
  225. package/dist/story/interactions.d.ts +52 -0
  226. package/dist/story/keyboard-shortcuts.d.ts +34 -0
  227. package/dist/story/output.d.ts +85 -0
  228. package/dist/story/performance.d.ts +76 -0
  229. package/dist/story/presets.d.ts +62 -0
  230. package/dist/story/props-validation.d.ts +45 -0
  231. package/dist/story/renderer.d.ts +53 -0
  232. package/dist/story/search-index.d.ts +47 -0
  233. package/dist/story/search.d.ts +45 -0
  234. package/dist/story/server.d.ts +21 -0
  235. package/dist/story/setup.d.ts +47 -0
  236. package/dist/story/snapshots.d.ts +65 -0
  237. package/dist/story/testing.d.ts +58 -0
  238. package/dist/story/theme.d.ts +68 -0
  239. package/dist/story/types.d.ts +249 -0
  240. package/dist/story/ui/code-panel.d.ts +42 -0
  241. package/dist/story/ui/controls-panel.d.ts +25 -0
  242. package/dist/story/ui/index.d.ts +4 -0
  243. package/dist/story/ui/navigation.d.ts +55 -0
  244. package/dist/story/ui/preview.d.ts +46 -0
  245. package/dist/story/visual-testing.d.ts +45 -0
  246. package/dist/streaming.d.ts +82 -2
  247. package/dist/suspense.d.ts +83 -0
  248. package/dist/teleport.d.ts +9 -0
  249. package/dist/testing.d.ts +289 -0
  250. package/dist/transitions.d.ts +87 -0
  251. package/dist/type-checker.d.ts +109 -0
  252. package/dist/types/component-types.d.ts +129 -0
  253. package/dist/types/config-types.d.ts +336 -0
  254. package/dist/types/context-types.d.ts +99 -0
  255. package/dist/types/csp-types.d.ts +79 -0
  256. package/dist/types/directive-types.d.ts +259 -0
  257. package/dist/types/index.d.ts +98 -0
  258. package/dist/types/pwa-types.d.ts +218 -0
  259. package/dist/types.d.ts +1 -315
  260. package/dist/typescript-templates.d.ts +178 -0
  261. package/dist/utils.d.ts +52 -6
  262. package/dist/validator.d.ts +77 -0
  263. package/dist/variable-extractor.d.ts +39 -0
  264. package/dist/view-composers.d.ts +154 -9
  265. package/dist/virtual-scrolling.d.ts +103 -0
  266. package/dist/visual-editor.d.ts +209 -0
  267. package/dist/visual-testing.d.ts +109 -0
  268. package/dist/visual-testing.js +126 -0
  269. package/dist/vue-template.d.ts +16 -0
  270. package/dist/web-components/css-scoping.d.ts +54 -0
  271. package/dist/web-components/index.d.ts +20 -0
  272. package/dist/web-components/reactive-generator.d.ts +72 -0
  273. package/dist/web-components.d.ts +222 -2
  274. package/dist/x-element.d.ts +35 -0
  275. package/package.json +41 -11
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Get a store by name
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const appStore = useStore('appStore')
7
+ * console.log(appStore.state.count)
8
+ *
9
+ * appStore.setState({ count: appStore.state.count + 1 })
10
+ * ```
11
+ */
12
+ export declare function useStore<T = unknown>(name: string): StoreRef<T> | null;
13
+ /**
14
+ * Get a store, throwing if not found
15
+ */
16
+ export declare function useStoreOrThrow<T = unknown>(name: string): StoreRef<T>;
17
+ /**
18
+ * Check if a store exists
19
+ */
20
+ export declare function hasStore(name: string): boolean;
21
+ /**
22
+ * Get all store names
23
+ */
24
+ export declare function getStoreNames(): string[];
25
+ /**
26
+ * Wait for a store to be ready (for async initialization)
27
+ */
28
+ export declare function waitForStore<T = unknown>(name: string, timeout?: any): Promise<StoreRef<T>>;
29
+ /**
30
+ * Get current route parameters
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * // URL: /users/123
35
+ * const params = useRouteParams()
36
+ * console.log(params.id) // '123'
37
+ * ```
38
+ */
39
+ export declare function useRouteParams(): RouteParams;
40
+ /**
41
+ * Get a specific route parameter
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const userId = useRouteParam('id')
46
+ * ```
47
+ */
48
+ export declare function useRouteParam(name: string): string | undefined;
49
+ /**
50
+ * Get a route parameter or throw if missing
51
+ */
52
+ export declare function useRouteParamOrThrow(name: string): string;
53
+ /**
54
+ * Get state passed from middleware
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * // In middleware:
59
+ * ctx.state.user = { id: 1, name: 'John' }
60
+ *
61
+ * // In component:
62
+ * const state = useMiddlewareState()
63
+ * console.log(state.user)
64
+ * ```
65
+ */
66
+ export declare function useMiddlewareState<T = MiddlewareState>(): T;
67
+ /**
68
+ * Get a specific middleware state value
69
+ */
70
+ export declare function useMiddlewareValue<T = unknown>(key: string): T | undefined;
71
+ /**
72
+ * @internal
73
+ * Initialize the store registry
74
+ */
75
+ export declare function initStoreRegistry(): void;
76
+ /**
77
+ * @internal
78
+ * Register a store in the registry
79
+ */
80
+ export declare function registerStore(name: string, store: StoreRef): void;
81
+ /**
82
+ * @internal
83
+ * Get serialized store state for hydration
84
+ */
85
+ export declare function getHydratedStoreState(): Record<string, unknown> | null;
86
+ /**
87
+ * @internal
88
+ * Set route params (called by router)
89
+ */
90
+ export declare function setRouteParams(params: RouteParams): void;
91
+ /**
92
+ * @internal
93
+ * Set middleware state (called by middleware runner)
94
+ */
95
+ export declare function setMiddlewareState(state: MiddlewareState): void;
96
+ /**
97
+ * Check if running on the server
98
+ */
99
+ export declare function isServer(): boolean;
100
+ /**
101
+ * Check if running on the client
102
+ */
103
+ export declare function isClient(): boolean;
104
+ /**
105
+ * Run callback only on client
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * onClient(() => {
110
+ * document.title = 'Hello'
111
+ * })
112
+ * ```
113
+ */
114
+ export declare function onClient(callback: () => void): void;
115
+ /**
116
+ * Run callback only on server
117
+ */
118
+ export declare function onServer(callback: () => void): void;
119
+ // =============================================================================
120
+ // Store Access
121
+ // =============================================================================
122
+ export declare interface StoreRef<T = unknown> {
123
+ state: T
124
+ getState: () => T
125
+ setState: (updater: Partial<T> | ((state: T) => Partial<T>)) => void
126
+ subscribe: (listener: (state: T) => void) => () => void
127
+ reset: () => void
128
+ }
129
+ // =============================================================================
130
+ // Route Params
131
+ // =============================================================================
132
+ export declare interface RouteParams {
133
+
134
+ }
135
+ // =============================================================================
136
+ // Middleware State
137
+ // =============================================================================
138
+ export declare interface MiddlewareState {
139
+
140
+ }
@@ -1,3 +1,23 @@
1
+ /**
2
+ * Configure the safe evaluator
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * configureSafeEvaluator({
7
+ * maxSanitizeDepth: 20,
8
+ * allowBracketNotation: true
9
+ * })
10
+ * ```
11
+ */
12
+ export declare function configureSafeEvaluator(config: Partial<SafeEvaluatorConfig>): void;
13
+ /**
14
+ * Reset configuration to defaults
15
+ */
16
+ export declare function resetSafeEvaluatorConfig(): void;
17
+ /**
18
+ * Get current configuration
19
+ */
20
+ export declare function getSafeEvaluatorConfig(): SafeEvaluatorConfig;
1
21
  /**
2
22
  * Sanitize an expression by checking for dangerous patterns
3
23
  */
@@ -5,12 +25,106 @@ export declare function sanitizeExpression(expression: string): string;
5
25
  /**
6
26
  * Create a safer context object that only exposes safe properties
7
27
  */
8
- export declare function createSafeContext(context: Record<string, any>): Record<string, any>;
28
+ export declare function createSafeContext(context: Record<string, unknown>): Record<string, unknown>;
9
29
  /**
10
30
  * Safely evaluate an expression with the given context
31
+ *
32
+ * @param expression - The JavaScript expression to evaluate
33
+ * @param context - Variables available during evaluation
34
+ * @returns The result of the expression evaluation, or undefined on error
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Basic usage
39
+ * const result = safeEvaluate('name.toUpperCase()', { name: 'hello' })
40
+ *
41
+ * // With type parameter for typed result
42
+ * const count = safeEvaluate<number>('items.length', { items: [1, 2, 3] })
43
+ * ```
11
44
  */
12
- export declare function safeEvaluate(expression: string, context: Record<string, any>): any;
45
+ export declare function safeEvaluate<T = unknown>(expression: string, context: Record<string, unknown>): T | undefined;
13
46
  /**
14
47
  * Check if an expression is safe to evaluate
15
48
  */
16
- export declare function isExpressionSafe(expression: string): boolean;
49
+ export declare function isExpressionSafe(expression: string): boolean;
50
+ /**
51
+ * Safely evaluate an expression and return a boolean result
52
+ * Used for conditional expressions in @if, @unless, etc.
53
+ *
54
+ * @param expression - The condition expression to evaluate
55
+ * @param context - Variables available during evaluation
56
+ * @returns Boolean result, defaults to false on error
57
+ */
58
+ export declare function safeEvaluateCondition(expression: string, context: Record<string, unknown>): boolean;
59
+ /**
60
+ * Safely evaluate an expression that returns an array
61
+ * Used for loop iterations in @foreach, @for, etc.
62
+ *
63
+ * @param expression - The array expression to evaluate
64
+ * @param context - Variables available during evaluation
65
+ * @returns Array result, defaults to empty array on error
66
+ */
67
+ export declare function safeEvaluateArray(expression: string, context: Record<string, unknown>): unknown[];
68
+ /**
69
+ * Safely evaluate an expression that returns an object
70
+ * Used for props, attributes, configuration objects
71
+ *
72
+ * @param expression - The object expression to evaluate
73
+ * @param context - Variables available during evaluation
74
+ * @returns Object result, defaults to empty object on error
75
+ */
76
+ export declare function safeEvaluateObject(expression: string, context: Record<string, unknown>): Record<string, unknown>;
77
+ /**
78
+ * Create a sandboxed function that can only access the provided context
79
+ * This is a safer alternative to `new Function()` that validates expressions first
80
+ *
81
+ * @param expression - The expression to compile into a function
82
+ * @param contextKeys - Variable names that will be available
83
+ * @returns A function that takes context values and returns the result
84
+ * @throws Error if expression contains dangerous patterns
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const fn = createSafeFunction('x + y', ['x', 'y'])
89
+ * const result = fn(1, 2) // returns 3
90
+ * ```
91
+ */
92
+ export declare function createSafeFunction(expression: string, contextKeys: string[]): (...args: unknown[]) => unknown;
93
+ /**
94
+ * Safely evaluate a return expression (e.g., "return x + y")
95
+ * Used for script block execution
96
+ *
97
+ * @param code - Code that may contain return statements
98
+ * @param context - Variables available during evaluation
99
+ * @returns The result of the code execution
100
+ */
101
+ export declare function safeEvaluateCode(code: string, context: Record<string, unknown>): unknown;
102
+ /**
103
+ * Validate a for loop expression for safety
104
+ * Checks for dangerous patterns like eval, Function, import, etc.
105
+ *
106
+ * @param expression - The for loop expression (e.g., "let i = 0; i < n; i++")
107
+ * @returns true if safe, false if potentially dangerous
108
+ */
109
+ export declare function isForExpressionSafe(expression: string): boolean;
110
+ /**
111
+ * Create a safe loop function with iteration limits
112
+ *
113
+ * @param loopType - 'for' or 'while'
114
+ * @param expression - The loop expression or condition
115
+ * @param body - The loop body template
116
+ * @param contextKeys - Variable names available in context
117
+ * @param maxIterations - Maximum iterations allowed (for while loops)
118
+ * @returns A function that executes the loop safely
119
+ */
120
+ export declare function createSafeLoopFunction(loopType: 'for' | 'while', expression: string, body: string, contextKeys: string[], maxIterations?: number): (...args: unknown[]) => string;
121
+ /**
122
+ * Safe expression evaluator that reduces security risks from using new Function()
123
+ */
124
+ /**
125
+ * Safe evaluator configuration options
126
+ */
127
+ export declare interface SafeEvaluatorConfig {
128
+ maxSanitizeDepth: number
129
+ allowBracketNotation: boolean
130
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Create a new stx project
3
+ */
4
+ export declare function createProject(projectName: string, options?: CreateProjectOptions): Promise<ScaffoldResult>;
5
+ /**
6
+ * Add a component
7
+ */
8
+ export declare function addComponent(name: string, options?: AddComponentOptions): Promise<ScaffoldResult>;
9
+ /**
10
+ * Add a page
11
+ */
12
+ export declare function addPage(name: string, options?: AddPageOptions): Promise<ScaffoldResult>;
13
+ /**
14
+ * Add a store
15
+ */
16
+ export declare function addStore(name: string, options?: AddStoreOptions): Promise<ScaffoldResult>;
17
+ /**
18
+ * Add a layout
19
+ */
20
+ export declare function addLayout(name: string, options?: AddLayoutOptions): Promise<ScaffoldResult>;
21
+ /**
22
+ * Project template definitions
23
+ */
24
+ export declare const PROJECT_TEMPLATES: {
25
+ default: {
26
+ description: 'Standard stx project with pages, components, and stores';
27
+ features: readonly ['Pages', 'Components', 'Layouts', 'Stores', 'Dev server']
28
+ };
29
+ minimal: {
30
+ description: 'Minimal setup with just the essentials';
31
+ features: readonly ['Single page', 'Basic styles']
32
+ };
33
+ full: {
34
+ description: 'Full-featured project with all stx capabilities';
35
+ features: readonly ['Pages', 'Components', 'Layouts', 'Stores', 'API routes', 'PWA', 'i18n', 'Testing']
36
+ };
37
+ blog: {
38
+ description: 'Blog template with markdown support';
39
+ features: readonly ['Blog layout', 'Post pages', 'Tags', 'RSS feed', 'Markdown']
40
+ };
41
+ dashboard: {
42
+ description: 'Admin dashboard template';
43
+ features: readonly ['Sidebar', 'Charts', 'Tables', 'Forms', 'Auth pages']
44
+ };
45
+ landing: {
46
+ description: 'Marketing landing page template';
47
+ features: readonly ['Hero section', 'Features', 'Pricing', 'CTA', 'Contact form']
48
+ }
49
+ };
50
+ /**
51
+ * Project creation options
52
+ */
53
+ export declare interface CreateProjectOptions {
54
+ template?: ProjectTemplate
55
+ skipGit?: boolean
56
+ skipInstall?: boolean
57
+ packageManager?: 'bun' | 'npm' | 'pnpm' | 'yarn'
58
+ typescript?: boolean
59
+ examples?: boolean
60
+ pwa?: boolean
61
+ tailwind?: boolean
62
+ }
63
+ /**
64
+ * Add component options
65
+ */
66
+ export declare interface AddComponentOptions {
67
+ dir?: string
68
+ props?: boolean
69
+ styles?: boolean
70
+ script?: boolean
71
+ force?: boolean
72
+ }
73
+ /**
74
+ * Add page options
75
+ */
76
+ export declare interface AddPageOptions {
77
+ dir?: string
78
+ layout?: string
79
+ dynamic?: boolean
80
+ loader?: boolean
81
+ force?: boolean
82
+ }
83
+ /**
84
+ * Add store options
85
+ */
86
+ export declare interface AddStoreOptions {
87
+ dir?: string
88
+ persist?: boolean
89
+ actions?: boolean
90
+ force?: boolean
91
+ }
92
+ /**
93
+ * Add layout options
94
+ */
95
+ export declare interface AddLayoutOptions {
96
+ dir?: string
97
+ nav?: boolean
98
+ footer?: boolean
99
+ force?: boolean
100
+ }
101
+ /**
102
+ * Scaffolding result
103
+ */
104
+ export declare interface ScaffoldResult {
105
+ success: boolean
106
+ message: string
107
+ files: string[]
108
+ errors: string[]
109
+ }
110
+ /**
111
+ * Project template options
112
+ */
113
+ export type ProjectTemplate = 'default' | 'minimal' | 'full' | 'blog' | 'dashboard' | 'landing'
package/dist/seo.d.ts CHANGED
@@ -1,24 +1,102 @@
1
1
  import type { CustomDirective, StxOptions } from './types';
2
2
  /**
3
- * Process @meta directive for generating meta tags
3
+ * Process @meta directive for generating meta tags.
4
+ * Supports both simple `@meta('name', 'content')` and
5
+ * OpenGraph `@meta('og:title')` formats.
4
6
  */
5
- export declare function processMetaDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions): string;
7
+ export declare function processMetaDirectives(template: string, context: Record<string, any>, _filePath: string, _options: StxOptions): string;
6
8
  /**
7
- * Process @structuredData directive for JSON-LD
9
+ * Process @structuredData directive for JSON-LD.
10
+ * Automatically adds schema.org context if not provided.
8
11
  */
9
- export declare function processStructuredData(template: string, context: Record<string, any>, filePath: string): string;
12
+ export declare function processStructuredData(template: string, context: Record<string, any>, _filePath: string): string;
10
13
  /**
11
- * Process @seo directive for automatic meta tag generation
14
+ * Process @seo directive for automatic meta tag generation.
15
+ * Generates title, description, Open Graph, Twitter, and structured data tags.
12
16
  */
13
- export declare function processSeoDirective(template: string, context: Record<string, any>, filePath: string, options: StxOptions): string;
17
+ export declare function processSeoDirective(template: string, context: Record<string, any>, _filePath: string, _options: StxOptions): string;
14
18
  /**
15
- * Injects default SEO tags if no @seo directive is used
19
+ * Injects default SEO tags if no @seo directive is used.
20
+ * Respects seo.enabled config and skipDefaultSeoTags option.
16
21
  */
17
22
  export declare function injectSeoTags(html: string, context: Record<string, any>, options: StxOptions): string;
18
23
  /**
19
24
  * Register SEO directives
20
25
  */
21
26
  export declare function registerSeoDirectives(): CustomDirective[];
27
+ /**
28
+ * Generate an XML sitemap from a list of URL entries.
29
+ *
30
+ * @param entries - Array of sitemap entries
31
+ * @param options - Sitemap generation options
32
+ * @returns XML sitemap string
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const sitemap = generateSitemap([
37
+ * { loc: '/', priority: 1.0 },
38
+ * { loc: '/about', priority: 0.8 },
39
+ * { loc: '/blog', changefreq: 'daily' },
40
+ * ], { baseUrl: 'https://example.com' })
41
+ * ```
42
+ */
43
+ export declare function generateSitemap(entries: SitemapEntry[], options: SitemapOptions): string;
44
+ /**
45
+ * Generate a sitemap index for multiple sitemaps.
46
+ *
47
+ * @param sitemaps - Array of sitemap URLs
48
+ * @param baseUrl - Base URL for the site
49
+ * @returns XML sitemap index string
50
+ */
51
+ export declare function generateSitemapIndex(sitemaps: string[], baseUrl: string): string;
52
+ /**
53
+ * Scan a directory and generate sitemap entries.
54
+ *
55
+ * @param directory - Directory to scan for .stx/.html files
56
+ * @param options - Scan options
57
+ * @param options.extensions - File extensions to include
58
+ * @param options.ignore - Patterns to ignore
59
+ * @param options.baseUrl - Base URL for the sitemap
60
+ * @returns Array of sitemap entries
61
+ */
62
+ export declare function scanForSitemapEntries(directory: string, options: {
63
+ extensions?: string[]
64
+ ignore?: string[]
65
+ baseUrl: string
66
+ }): Promise<SitemapEntry[]>;
67
+ /**
68
+ * Generate a robots.txt file content.
69
+ *
70
+ * @param options - Robots.txt options
71
+ * @returns robots.txt content string
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const robotsTxt = generateRobotsTxt({
76
+ * rules: [
77
+ * {
78
+ * userAgent: '*',
79
+ * allow: ['/'],
80
+ * disallow: ['/admin', '/private'],
81
+ * },
82
+ * {
83
+ * userAgent: 'Googlebot',
84
+ * allow: ['/'],
85
+ * crawlDelay: 1,
86
+ * },
87
+ * ],
88
+ * sitemap: 'https://example.com/sitemap.xml',
89
+ * })
90
+ * ```
91
+ */
92
+ export declare function generateRobotsTxt(options: RobotsOptions): string;
93
+ /**
94
+ * Generate a default robots.txt that allows all crawling.
95
+ *
96
+ * @param sitemapUrl - Optional sitemap URL
97
+ * @returns robots.txt content string
98
+ */
99
+ export declare function generateDefaultRobotsTxt(sitemapUrl?: string): string;
22
100
  /**
23
101
  * SEO meta directive for basic meta tag generation
24
102
  */
@@ -30,4 +108,39 @@ export declare const structuredDataDirective: CustomDirective;
30
108
  declare interface StructuredData {
31
109
  '@context': string
32
110
  '@type': string
111
+ }
112
+ /**
113
+ * URL entry for sitemap
114
+ */
115
+ export declare interface SitemapEntry {
116
+ loc: string
117
+ lastmod?: string
118
+ changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never'
119
+ priority?: number
120
+ }
121
+ /**
122
+ * Sitemap generation options
123
+ */
124
+ export declare interface SitemapOptions {
125
+ baseUrl: string
126
+ defaultChangefreq?: SitemapEntry['changefreq']
127
+ defaultPriority?: number
128
+ includeLastmod?: boolean
129
+ }
130
+ /**
131
+ * Robots.txt rule
132
+ */
133
+ export declare interface RobotsRule {
134
+ userAgent: string
135
+ allow?: string[]
136
+ disallow?: string[]
137
+ crawlDelay?: number
138
+ }
139
+ /**
140
+ * Robots.txt generation options
141
+ */
142
+ export declare interface RobotsOptions {
143
+ rules: RobotsRule[]
144
+ sitemap?: string | string[]
145
+ host?: string
33
146
  }
@@ -0,0 +1,134 @@
1
+ import type { CustomDirective } from './types';
2
+ /**
3
+ * Register a server component.
4
+ */
5
+ export declare function registerServerComponent(component: ServerComponent): void;
6
+ /**
7
+ * Register a client component.
8
+ */
9
+ export declare function registerClientComponent(component: ClientComponent): void;
10
+ /**
11
+ * Get a registered component.
12
+ */
13
+ export declare function getComponent(name: string): ComponentEntry | undefined;
14
+ /**
15
+ * Check if a component is registered.
16
+ */
17
+ export declare function hasComponent(name: string): boolean;
18
+ /**
19
+ * Get all registered component names.
20
+ */
21
+ export declare function getComponentNames(): string[];
22
+ /**
23
+ * Clear all registered components.
24
+ */
25
+ export declare function clearComponents(): void;
26
+ /**
27
+ * Clear component cache.
28
+ */
29
+ export declare function clearComponentCache(name?: string): void;
30
+ /**
31
+ * Render a server component.
32
+ */
33
+ export declare function renderServerComponent(name: string, options?: RenderOptions): Promise<RenderResult>;
34
+ /**
35
+ * Render a client component (server-side with hydration markers).
36
+ */
37
+ export declare function renderClientComponent(name: string, options?: RenderOptions): Promise<RenderResult>;
38
+ /**
39
+ * Render any registered component.
40
+ */
41
+ export declare function renderComponent(name: string, options?: RenderOptions): Promise<RenderResult>;
42
+ /**
43
+ * Create a suspense boundary.
44
+ */
45
+ export declare function createSuspenseBoundary(id: string, fallback: string): { wrap: (promise: Promise<string>) => Promise<string>, getFallback: () => string };
46
+ /**
47
+ * Get suspense state by ID.
48
+ */
49
+ export declare function getSuspenseState(id: string): SuspenseState | undefined;
50
+ /**
51
+ * Clear suspense state.
52
+ */
53
+ export declare function clearSuspenseState(id?: string): void;
54
+ /**
55
+ * Create a streaming renderer for server components.
56
+ */
57
+ export declare function createStreamingRenderer(components: string[], options?: RenderOptions): {
58
+ renderToStream: () => ReadableStream<string>
59
+ renderToString: () => Promise<string>
60
+ };
61
+ /**
62
+ * Register all server component directives.
63
+ */
64
+ export declare function registerServerComponentDirectives(): CustomDirective[];
65
+ /**
66
+ * Generate client-side runtime for server components hydration.
67
+ */
68
+ export declare function generateServerComponentsRuntime(): string;
69
+ /**
70
+ * @serverComponent directive for defining server components inline.
71
+ */
72
+ export declare const serverComponentDirective: CustomDirective;
73
+ /**
74
+ * @clientComponent directive for defining client components inline.
75
+ */
76
+ export declare const clientComponentDirective: CustomDirective;
77
+ /**
78
+ * @suspense directive for async boundaries.
79
+ */
80
+ export declare const suspenseDirective: CustomDirective;
81
+ /** Server component definition */
82
+ export declare interface ServerComponent {
83
+ name: string
84
+ template: string
85
+ loader?: (props: Record<string, unknown>) => Promise<Record<string, unknown>>
86
+ dependencies?: string[]
87
+ cache?: CacheConfig
88
+ errorBoundary?: string
89
+ suspenseFallback?: string
90
+ }
91
+ /** Client component definition */
92
+ export declare interface ClientComponent {
93
+ name: string
94
+ template: string
95
+ clientScript?: string
96
+ clientProps?: string[]
97
+ priority?: 'eager' | 'lazy' | 'idle'
98
+ }
99
+ /** Cache configuration */
100
+ export declare interface CacheConfig {
101
+ enabled: boolean
102
+ ttl?: number
103
+ keyGenerator?: (props: Record<string, unknown>) => string
104
+ staleWhileRevalidate?: boolean
105
+ }
106
+ /** Server component rendering options */
107
+ export declare interface RenderOptions {
108
+ props?: Record<string, unknown>
109
+ streaming?: boolean
110
+ request?: { url: string, headers: Record<string, string> }
111
+ signal?: AbortSignal
112
+ }
113
+ /** Server component render result */
114
+ export declare interface RenderResult {
115
+ html: string
116
+ renderTime: number
117
+ data?: Record<string, unknown>
118
+ dependencies: string[]
119
+ cached: boolean
120
+ hydrationScript?: string
121
+ }
122
+ /** Component registry entry */
123
+ declare interface ComponentEntry {
124
+ component: ServerComponent | ClientComponent
125
+ type: 'server' | 'client'
126
+ }
127
+ /** Suspense boundary state */
128
+ declare interface SuspenseState {
129
+ id: string
130
+ status: 'pending' | 'resolved' | 'error'
131
+ promise?: Promise<unknown>
132
+ result?: string
133
+ error?: Error
134
+ }