@stacksjs/stx 0.2.10 → 0.2.11

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 (128) hide show
  1. package/README.md +16 -11
  2. package/dist/a11y.d.ts +2 -1
  3. package/dist/analyzer.d.ts +4 -0
  4. package/dist/app-shell.d.ts +72 -0
  5. package/dist/app.d.ts +1 -0
  6. package/dist/broadcasting.d.ts +77 -0
  7. package/dist/build-assets.d.ts +32 -0
  8. package/dist/build-mode-detector.d.ts +26 -0
  9. package/dist/build.d.ts +31 -0
  10. package/dist/builtins/icon.d.ts +7 -0
  11. package/dist/builtins/index.d.ts +21 -0
  12. package/dist/builtins/stx-image.d.ts +2 -0
  13. package/dist/builtins/stx-link.d.ts +2 -0
  14. package/dist/builtins/stx-loading-indicator.d.ts +2 -0
  15. package/dist/bundle-analyzer/index.d.ts +2 -0
  16. package/dist/bundle-analyzer.js +20 -20
  17. package/dist/caching.d.ts +27 -0
  18. package/dist/cli.js +3941 -2609
  19. package/dist/client-helpers.d.ts +7 -3
  20. package/dist/client-script-bundler.d.ts +27 -0
  21. package/dist/client-script.d.ts +5 -1
  22. package/dist/client.d.ts +1 -0
  23. package/dist/component-hmr.d.ts +1 -0
  24. package/dist/component-processing.d.ts +107 -0
  25. package/dist/component-registry.d.ts +54 -0
  26. package/dist/component-renderer.d.ts +18 -0
  27. package/dist/components/StxImage.stx +12 -0
  28. package/dist/components/StxLink.stx +18 -8
  29. package/dist/composables/index.d.ts +7 -0
  30. package/dist/composables/use-broadcast-channel.d.ts +1 -0
  31. package/dist/composables/use-channel.d.ts +67 -0
  32. package/dist/composables/use-intersection-observer.d.ts +2 -0
  33. package/dist/composables/use-keyboard.d.ts +1 -0
  34. package/dist/composables/use-mouse.d.ts +1 -0
  35. package/dist/composables/use-router.d.ts +4 -0
  36. package/dist/composables/use-websocket.d.ts +1 -0
  37. package/dist/composables.d.ts +2 -0
  38. package/dist/composition-api.d.ts +1 -0
  39. package/dist/computed.d.ts +1 -0
  40. package/dist/config.d.ts +12 -1
  41. package/dist/craft-bridge.d.ts +6 -3
  42. package/dist/craft-components.d.ts +1 -0
  43. package/dist/craft.js +39 -33
  44. package/dist/deploy/index.d.ts +1 -0
  45. package/dist/dev-server/crosswind.d.ts +2 -5
  46. package/dist/dev-server/native-window.d.ts +19 -1
  47. package/dist/dev-server/serve-app.d.ts +15 -0
  48. package/dist/dev-server/serve-file.d.ts +3 -0
  49. package/dist/dev-server/serve-markdown.d.ts +3 -0
  50. package/dist/dev-server/serve-multi.d.ts +5 -0
  51. package/dist/dev-server/types.d.ts +2 -0
  52. package/dist/dev-server.d.ts +6 -40
  53. package/dist/devtools.d.ts +1 -0
  54. package/dist/directive-api.d.ts +1 -1
  55. package/dist/document-shell.d.ts +33 -0
  56. package/dist/error-boundaries.d.ts +1 -0
  57. package/dist/events.d.ts +1 -0
  58. package/dist/expressions.d.ts +38 -0
  59. package/dist/forms-validation.d.ts +2 -0
  60. package/dist/head.d.ts +1 -0
  61. package/dist/hot-reload.d.ts +1 -0
  62. package/dist/hydration-runtime.d.ts +1 -0
  63. package/dist/hydration.d.ts +1 -0
  64. package/dist/i18n.d.ts +3 -1
  65. package/dist/image-optimization/build-plugin.d.ts +1 -0
  66. package/dist/index.d.ts +22 -1
  67. package/dist/index.js +5569 -4182
  68. package/dist/inline-assets.d.ts +28 -0
  69. package/dist/internal-markdown.d.ts +0 -4
  70. package/dist/jsx-runtime.d.ts +1 -0
  71. package/dist/keep-alive.d.ts +1 -0
  72. package/dist/manifest.d.ts +41 -0
  73. package/dist/markdown.d.ts +1 -0
  74. package/dist/media/client/blur-up.d.ts +1 -0
  75. package/dist/media/client/lazy-load.d.ts +1 -0
  76. package/dist/media/client/upload-handler.d.ts +1 -0
  77. package/dist/media/shared/cache.d.ts +2 -0
  78. package/dist/media/video/index.d.ts +1 -0
  79. package/dist/media/video/processor/thumbnail.d.ts +1 -0
  80. package/dist/misc-directives.d.ts +49 -0
  81. package/dist/parser/directive-parser.d.ts +13 -0
  82. package/dist/performance-utils.d.ts +2 -0
  83. package/dist/placeholder.d.ts +45 -0
  84. package/dist/plugin-system.d.ts +32 -2
  85. package/dist/process.d.ts +11 -1
  86. package/dist/production-builder.d.ts +42 -0
  87. package/dist/production-server.d.ts +19 -0
  88. package/dist/props.d.ts +1 -0
  89. package/dist/pwa.js +3883 -2679
  90. package/dist/reactive.d.ts +2 -16
  91. package/dist/reactivity.d.ts +1 -0
  92. package/dist/router.d.ts +1 -1
  93. package/dist/runtime-injection.d.ts +20 -0
  94. package/dist/runtime.d.ts +2 -2
  95. package/dist/script-classifier.d.ts +35 -0
  96. package/dist/script-validation.d.ts +16 -0
  97. package/dist/server-bindings.d.ts +7 -0
  98. package/dist/server-components.d.ts +4 -0
  99. package/dist/signal-processing.d.ts +109 -0
  100. package/dist/signals-api.d.ts +309 -0
  101. package/dist/signals.d.ts +2 -309
  102. package/dist/spa-shell.d.ts +1 -0
  103. package/dist/ssg.js +3862 -2655
  104. package/dist/ssr.d.ts +1 -0
  105. package/dist/state-management.d.ts +27 -0
  106. package/dist/store-imports.d.ts +24 -0
  107. package/dist/store-loader.d.ts +16 -0
  108. package/dist/story/bun-test.d.ts +1 -0
  109. package/dist/story/compiled-output.d.ts +1 -0
  110. package/dist/story/interactions.d.ts +1 -0
  111. package/dist/story/renderer.d.ts +2 -0
  112. package/dist/story/setup.d.ts +1 -0
  113. package/dist/story/ui/code-panel.d.ts +1 -0
  114. package/dist/stx.d.ts +437 -0
  115. package/dist/style-scoping.d.ts +23 -0
  116. package/dist/template-compiler.d.ts +31 -0
  117. package/dist/template-hydrator.d.ts +18 -0
  118. package/dist/transitions.d.ts +1 -0
  119. package/dist/types/config-types.d.ts +62 -0
  120. package/dist/validator.d.ts +1 -0
  121. package/dist/variable-extractor.d.ts +1 -1
  122. package/dist/view-composers.d.ts +1 -0
  123. package/dist/virtual-scrolling.d.ts +1 -0
  124. package/dist/visual-testing.js +2 -2
  125. package/dist/web-components.d.ts +1 -0
  126. package/dist/x-element.d.ts +1 -0
  127. package/package.json +72 -7
  128. package/stx.d.ts +437 -0
@@ -1,3 +1,4 @@
1
+ /* eslint-disable prefer-const, style/max-statements-per-line, no-super-linear-backtracking, regexp/no-unused-capturing-group */
1
2
  /**
2
3
  * Client-side helper utilities for stx applications.
3
4
  * Injected as a <script> tag to provide common UI patterns.
@@ -130,7 +131,8 @@ export declare const stxClientHelpers: `
130
131
  if (rows) {
131
132
  if (!Array.isArray(rows) && typeof rows === 'object') {
132
133
  Object.keys(rows).forEach(function(k) { inner += stx.detail.row(k, rows[k]) })
133
- } else {
134
+ }
135
+ else {
134
136
  rows.forEach(function(r) {
135
137
  if (Array.isArray(r)) inner += stx.detail.row(r[0], r[1])
136
138
  else inner += stx.detail.row(r.label, r.value)
@@ -273,9 +275,11 @@ export declare const stxClientHelpers: `
273
275
  pages.forEach(function(p) {
274
276
  if (p === '...') {
275
277
  h += '<span class="px-2 text-sm" style="color:var(--text-muted)">\\u2026</span>'
276
- } else if (p === page) {
278
+ }
279
+ else if (p === page) {
277
280
  h += \`<button class="w-9 h-9 rounded-lg text-sm font-medium" style="background:var(--btn-primary-bg, var(--text-accent));color:#fff">\${p}</button>\`
278
- } else {
281
+ }
282
+ else {
279
283
  h += btn(p, p, false)
280
284
  }
281
285
  })
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Check if a script has user imports that need Bun.build bundling.
3
+ *
4
+ * Returns false for:
5
+ * - `import type { ... }` (type-only — stripped by TS transpiler)
6
+ * - `import { ... } from 'stx'` (auto-imported from window.stx)
7
+ * - `import { ... } from '@stacksjs/browser'` (auto-imported)
8
+ * - `import { ... } from '@stores'` (handled by transformStoreImports)
9
+ * - `import { ... } from '@composables'` (handled by transformStoreImports)
10
+ */
11
+ export declare function hasUserImports(code: string): boolean;
12
+ /**
13
+ * Bundle a client script using Bun.build.
14
+ *
15
+ * Resolves local imports (@/, ./), npm packages, and tree-shakes unused exports.
16
+ * stx runtime, @stores, and @composables are marked as external.
17
+ *
18
+ * @param code - The script content (may contain import statements)
19
+ * @param filePath - The .stx template file path (for relative import resolution)
20
+ * @param options - Bundling options
21
+ * @returns Bundled code with all imports resolved and inlined
22
+ */
23
+ export declare function bundleClientScript(code: string, filePath: string, options?: {
24
+ projectRoot?: string
25
+ minify?: boolean
26
+ cacheDir?: string
27
+ }): Promise<string>;
@@ -11,7 +11,7 @@ import type { ParsedEvent } from './events';
11
11
  * @param options - Event bindings and other processing options
12
12
  * @returns A complete `<script>...</script>` tag ready for browser injection
13
13
  */
14
- export declare function processClientScript(scriptContent: string, options?: ClientScriptOptions): string;
14
+ export declare function processClientScript(scriptContent: string, options?: ClientScriptOptions): Promise<string>;
15
15
  // =============================================================================
16
16
  // Types
17
17
  // =============================================================================
@@ -20,4 +20,8 @@ export declare interface ClientScriptOptions {
20
20
  autoImports?: boolean
21
21
  attrs?: string
22
22
  hasColonDirectives?: boolean
23
+ templateContent?: string
24
+ filePath?: string
25
+ projectRoot?: string
26
+ production?: boolean
23
27
  }
package/dist/client.d.ts CHANGED
@@ -17,4 +17,5 @@ declare type IslandHandlers = Record<string, () => Promise<any>>;
17
17
  /**
18
18
  * Island hydration function
19
19
  */
20
+ // eslint-disable-next-line pickier/no-unused-vars
20
21
  declare type IslandHydrationFn = (element: any, props: any) => void | Promise<void>;
@@ -14,6 +14,7 @@ export declare function getHMRHandler(config?: ComponentHMRConfig): ComponentHMR
14
14
  * Reset global HMR handler
15
15
  */
16
16
  export declare function resetHMRHandler(): void;
17
+ /* eslint-disable prefer-const, style/max-statements-per-line, no-super-linear-backtracking, regexp/no-unused-capturing-group */
17
18
  /**
18
19
  * Component HMR (Hot Module Replacement)
19
20
  *
@@ -0,0 +1,107 @@
1
+ import type { StxOptions } from './types';
2
+ /**
3
+ * Convert PascalCase to kebab-case with proper handling of consecutive uppercase letters.
4
+ *
5
+ * Examples:
6
+ * - `UserCard` → `user-card`
7
+ * - `XMLParser` → `xml-parser` (not `x-m-l-parser`)
8
+ * - `HTMLElement` → `html-element`
9
+ * - `MyURLParser` → `my-url-parser`
10
+ * - `IOStream` → `io-stream`
11
+ *
12
+ * The algorithm:
13
+ * 1. Insert hyphen before uppercase letters that follow lowercase letters
14
+ * 2. Insert hyphen before the last uppercase in a sequence of uppercase letters (before lowercase)
15
+ * 3. Convert to lowercase
16
+ */
17
+ export declare function pascalToKebab(str: string): string;
18
+ /**
19
+ * Find component tags in HTML, properly handling quoted strings
20
+ * This solves the issue where `>` inside attribute values would incorrectly end the tag
21
+ *
22
+ * @param html - The HTML string to search
23
+ * @param tagPattern - Regex pattern for tag name (for PascalCase components)
24
+ * @param skipTags - Optional set of tag names to skip (for HTML tags)
25
+ * @returns Array of found component tags
26
+ */
27
+ export declare function findComponentTags(html: string, tagPattern: RegExp, skipTags?: Set<string>): ComponentTagMatch[];
28
+ /**
29
+ * Parse multiline attributes from a component tag
30
+ * Handles HTML content inside attribute values correctly
31
+ *
32
+ * @param attributesStr - The attributes string (may be multiline)
33
+ * @returns Object mapping attribute names to values
34
+ */
35
+ export declare function parseMultilineAttributes(attributesStr: string): Record<string, string>;
36
+ export declare function parseAttributes(attributesStr: string): ParsedAttribute[];
37
+ /**
38
+ * Process built-in STX components like <stx-loading-indicator>
39
+ */
40
+ export declare function processBuiltInComponents(template: string, _context: Record<string, any>, _filePath: string, _options: StxOptions): Promise<string>;
41
+ /**
42
+ * Process @import directives for explicit component imports.
43
+ *
44
+ * Syntax:
45
+ * @import('components/Card')
46
+ * @import('ui/Button', 'ui/Modal')
47
+ * @import('Card', 'Button', 'Modal')
48
+ *
49
+ * This allows explicit importing of components from any path,
50
+ * overriding the auto-import from the components directory.
51
+ */
52
+ export declare function processImportDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
53
+ /**
54
+ * Process @component directives
55
+ */
56
+ export declare function processComponentDirectives(template: string, context: Record<string, any>, filePath: string, componentsDir: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
57
+ /**
58
+ * Process custom element components (both kebab-case and PascalCase)
59
+ * Uses a proper parser that handles HTML content inside attribute values
60
+ */
61
+ export declare function processCustomElements(template: string, context: Record<string, any>, filePath: string, componentsDir: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
62
+ /**
63
+ * Parse HTML/JSX-like attributes from a string.
64
+ *
65
+ * Properly handles:
66
+ * - Simple attributes: `name="value"`
67
+ * - Boolean attributes: `disabled`
68
+ * - Dynamic values: `prop="{{ expr }}"` (evaluated at SSR)
69
+ * - Attributes with `=` in values: `url="https://example.com?a=1&b=2"`
70
+ * - Single and double quoted values
71
+ * - Escaped quotes within values
72
+ *
73
+ * ## Dynamic Data Syntax
74
+ *
75
+ * Use `{{ }}` for all dynamic data interpolation:
76
+ * ```html
77
+ * <Component title="{{ pageTitle }}" count="{{ items.length }}" />
78
+ * <div class="{{ isActive ? 'active' : '' }}">{{ content }}</div>
79
+ * ```
80
+ *
81
+ * ## Event Syntax (Alpine-style)
82
+ *
83
+ * ```html
84
+ * <button @click="handleClick()">Click me</button>
85
+ * <form @submit.prevent="handleSubmit()">...</form>
86
+ * <input @keydown.enter="send()" @keydown.escape="cancel()">
87
+ * ```
88
+ *
89
+ * @param attributesStr - The attributes portion of a tag (between tag name and closing)
90
+ * @returns Array of parsed attributes with name and value
91
+ */
92
+ export declare interface ParsedAttribute {
93
+ name: string
94
+ value: string | true
95
+ }
96
+ /**
97
+ * Component tag match result
98
+ */
99
+ export declare interface ComponentTagMatch {
100
+ fullMatch: string
101
+ tagName: string
102
+ attributes: string
103
+ content: string
104
+ startIndex: number
105
+ endIndex: number
106
+ isSelfClosing: boolean
107
+ }
@@ -0,0 +1,54 @@
1
+ import type { StxOptions } from './types';
2
+ /**
3
+ * Convert a kebab-case string to PascalCase.
4
+ *
5
+ * @example kebabToPascal("stx-link") // "StxLink"
6
+ */
7
+ export declare function kebabToPascal(str: string): string;
8
+ /**
9
+ * Convert a PascalCase string to kebab-case.
10
+ *
11
+ * @example pascalToKebab("StxLink") // "stx-link"
12
+ */
13
+ export declare function pascalToKebab(str: string): string;
14
+ /** Singleton registry instance shared across the framework */
15
+ export declare const registry: ComponentRegistry;
16
+ /**
17
+ * Context passed to builtin component render functions.
18
+ */
19
+ export declare interface RenderContext {
20
+ context: Record<string, any>
21
+ filePath: string
22
+ options: StxOptions
23
+ dependencies: Set<string>
24
+ }
25
+ /**
26
+ * Props resolved from component attributes, categorized by binding type.
27
+ */
28
+ export declare interface ResolvedProps {
29
+ static: Record<string, string | boolean>
30
+ serverDynamic: Record<string, unknown>
31
+ clientReactive: Record<string, string>
32
+ events: Record<string, string>
33
+ }
34
+ /**
35
+ * Definition for a builtin component that renders without a .stx file.
36
+ */
37
+ export declare interface BuiltinComponentDef {
38
+ name: string
39
+ aliases: string[]
40
+ render(props: ResolvedProps, slotContent: string, ctx: RenderContext): string
41
+ }
42
+ /**
43
+ * Central registry for STX components.
44
+ *
45
+ * Manages builtin components (registered in-memory) and provides
46
+ * file-based component resolution with multi-directory search.
47
+ */
48
+ export declare class ComponentRegistry {
49
+ builtins: Map<string, BuiltinComponentDef>;
50
+ registerBuiltin(def: BuiltinComponentDef): void;
51
+ isBuiltin(name: string): boolean;
52
+ getBuiltin(name: string): BuiltinComponentDef | null;
53
+ resolveFile(name: string, fromFile: string, options: StxOptions, parentContext?: Record<string, any>): Promise<string | null>;
54
+ }
@@ -0,0 +1,18 @@
1
+ import type { StxOptions } from './types';
2
+ /**
3
+ * Unified component processing entry point.
4
+ *
5
+ * Processes all component-related syntax in the template in the correct order:
6
+ * 1. Register builtin components (once)
7
+ * 2. Process `@import` directives
8
+ * 3. Process `@component` directives
9
+ * 4. Process custom element tags (builtins and file-based)
10
+ *
11
+ * @param template - The template string to process
12
+ * @param context - Template variable context
13
+ * @param filePath - Absolute path of the template being processed
14
+ * @param options - Compiler options
15
+ * @param dependencies - Set to track file dependencies for cache invalidation
16
+ * @returns The processed template with all components rendered
17
+ */
18
+ export declare function processComponents(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
@@ -0,0 +1,12 @@
1
+ <img
2
+ src='{{ src }}'
3
+ alt='{{ alt || "" }}'
4
+ @if(typeof width !== 'undefined' && width) width='{{ width }}' @endif
5
+ @if(typeof height !== 'undefined' && height) height='{{ height }}' @endif
6
+ loading='{{ typeof lazy !== "undefined" && lazy === false ? "eager" : "lazy" }}'
7
+ decoding='async'
8
+ @if(typeof sizes !== 'undefined' && sizes) sizes='{{ sizes }}' @endif
9
+ @if(typeof srcset !== 'undefined' && srcset) srcset='{{ srcset }}' @endif
10
+ @if(typeof placeholder !== 'undefined' && placeholder) style='background-image: url({{ placeholder }}); background-size: cover;' @endif
11
+ class='{{ className || "" }}'
12
+ />
@@ -1,8 +1,18 @@
1
- <a
2
- href="{{ to }}"
3
- class="{{ className || '' }}"
4
- data-stx-link
5
- data-stx-active-class="{{ activeClass || 'active' }}"
6
- data-stx-exact-active-class="{{ exactActiveClass || 'exact-active' }}"
7
- @if(typeof prefetch !== 'undefined' && prefetch) data-stx-prefetch @endif
8
- >{!! slot !!}</a>
1
+ @if(typeof __bindTo !== 'undefined' && __bindTo)
2
+ <stx-link
3
+ :to="{{ __bindTo }}"
4
+ class='{{ className || "" }}'
5
+ active-class='{{ activeClass || "active" }}'
6
+ exact-active-class='{{ exactActiveClass || "exact-active" }}'
7
+ @if(typeof prefetch !== 'undefined' && prefetch) prefetch @endif
8
+ >{!! slot !!}</stx-link>
9
+ @endif
10
+ @if(typeof __bindTo === 'undefined' || !__bindTo)
11
+ <stx-link
12
+ to='{{ to }}'
13
+ class='{{ className || "" }}'
14
+ active-class='{{ activeClass || "active" }}'
15
+ exact-active-class='{{ exactActiveClass || "exact-active" }}'
16
+ @if(typeof prefetch !== 'undefined' && prefetch) prefetch @endif
17
+ >{!! slot !!}</stx-link>
18
+ @endif
@@ -243,6 +243,13 @@ export {
243
243
  type WebSocketOptions,
244
244
  type WebSocketRef,
245
245
  } from './use-websocket';
246
+ // Broadcasting Channels (ts-broadcasting)
247
+ export {
248
+ useChannel,
249
+ type ChannelState,
250
+ type ChannelOptions,
251
+ type ChannelRef,
252
+ } from './use-channel';
246
253
  // Device Orientation & Motion
247
254
  export {
248
255
  useDeviceOrientation,
@@ -55,4 +55,5 @@ export declare interface BroadcastChannelRef<T = unknown> {
55
55
  isSupported: () => boolean
56
56
  }
57
57
  declare type BroadcastEventType = 'message' | 'error';
58
+ // eslint-disable-next-line pickier/no-unused-vars
58
59
  declare type BroadcastEventCallback = (data: MessageEvent) => void;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Subscribe to a broadcasting channel.
3
+ *
4
+ * Connects to the stx broadcasting server via WebSocket, subscribes
5
+ * to the named channel, and pushes every incoming event through the
6
+ * reactive subscriber set.
7
+ *
8
+ * @param channelName - Channel to subscribe to (e.g. `'notifications'`, `'private-orders.123'`)
9
+ * @param options - Connection options (host, port, reconnect behaviour)
10
+ */
11
+ export declare function useChannel<T = unknown>(channelName: string, options?: ChannelOptions): ChannelRef<T>;
12
+ /**
13
+ * Broadcasting Channel Composables
14
+ *
15
+ * Reactive client-side subscriptions to ts-broadcasting channels.
16
+ * Auto-connects to the stx broadcasting server, handles the WebSocket
17
+ * protocol, and provides a subscriber-based reactive API.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const channel = useChannel<{ count: number }>('metrics')
22
+ *
23
+ * channel.subscribe((state) => {
24
+ * console.log(state.data) // latest event payload
25
+ * console.log(state.isSubscribed) // channel subscription status
26
+ * console.log(state.isConnected) // WebSocket connection status
27
+ * })
28
+ *
29
+ * // Listen for a specific event
30
+ * channel.on('metrics.updated', (data) => {
31
+ * document.getElementById('cpu').textContent = data.cpu
32
+ * })
33
+ *
34
+ * // Clean up
35
+ * channel.close()
36
+ * ```
37
+ */
38
+ // ── Types ──────────────────────────────────────────────────────
39
+ export declare interface ChannelState<T = unknown> {
40
+ data: T | null
41
+ event: string | null
42
+ isSubscribed: boolean
43
+ isConnected: boolean
44
+ socketId: string | null
45
+ }
46
+ export declare interface ChannelOptions {
47
+ host?: string
48
+ port?: number
49
+ scheme?: 'ws' | 'wss'
50
+ autoConnect?: boolean
51
+ autoReconnect?: boolean
52
+ maxReconnectAttempts?: number
53
+ reconnectDelay?: number
54
+ }
55
+ export declare interface ChannelRef<T = unknown> {
56
+ get: () => ChannelState<T>
57
+ subscribe: (fn: (state: ChannelState<T>) => void) => () => void
58
+ on: (event: string, callback: (data: any) => void) => () => void
59
+ close: () => void
60
+ open: () => void
61
+ }
62
+ // ── Helpers ────────────────────────────────────────────────────
63
+ declare global {
64
+ interface Window {
65
+ __stx_broadcasting?: { port?: number, host?: string, scheme?: string }
66
+ }
67
+ }
@@ -5,6 +5,7 @@ export declare function useIntersectionObserver(target: Element | (() => Element
5
5
  /**
6
6
  * Simple visibility check - returns true when element is in viewport
7
7
  */
8
+ // eslint-disable-next-line pickier/no-unused-vars
8
9
  export declare function useElementVisibility(target: Element | (() => Element | null) | null, options?: Omit<IntersectionObserverOptions, 'once'>): {
9
10
  get: () => boolean
10
11
  subscribe: (fn: (visible: boolean) => void) => () => void
@@ -78,4 +79,5 @@ export declare interface IntersectionObserverRef {
78
79
  stop: () => void
79
80
  start: () => void
80
81
  }
82
+ // eslint-disable-next-line pickier/no-unused-vars
81
83
  declare type IntersectionCallback = (entry: IntersectionObserverEntry, observer: IntersectionObserver) => void;
@@ -96,4 +96,5 @@ export declare interface HotkeyOptions {
96
96
  keyup?: boolean
97
97
  ignoreInputs?: boolean
98
98
  }
99
+ // eslint-disable-next-line pickier/no-unused-vars
99
100
  declare type HotkeyCallback = (event: KeyboardEvent) => void;
@@ -5,6 +5,7 @@ export declare function useMouse(options?: MouseOptions): MouseRef;
5
5
  /**
6
6
  * Track mouse position relative to an element
7
7
  */
8
+ // eslint-disable-next-line pickier/no-unused-vars
8
9
  export declare function useMouseInElement(element: HTMLElement | (() => HTMLElement | null) | null, options?: Omit<MouseOptions, 'target'>): ElementMouseRef;
9
10
  /**
10
11
  * Track pointer (unified mouse + touch + pen)
@@ -27,6 +27,10 @@ export declare function goForward(): void;
27
27
  * ```
28
28
  */
29
29
  export declare function useRoute(): RouteInfo;
30
+ /**
31
+ * Set route params (called by server injection or page scripts).
32
+ */
33
+ export declare function setRouteParams(params: Record<string, string>): void;
30
34
  /**
31
35
  * Reactive URL search parameters with get/set/setAll methods.
32
36
  *
@@ -66,4 +66,5 @@ export declare interface WebSocketRef<T = unknown> {
66
66
  */
67
67
  export type WebSocketStatus = 'connecting' | 'open' | 'closing' | 'closed';
68
68
  declare type WebSocketEventType = 'open' | 'message' | 'close' | 'error';
69
+ // eslint-disable-next-line pickier/no-unused-vars
69
70
  declare type WebSocketEventCallback = (event: Event | MessageEvent | CloseEvent) => void;
@@ -245,6 +245,7 @@ export declare interface ComponentInstance {
245
245
  watchers: Array<{ stop: () => void }>
246
246
  isMounted: boolean
247
247
  }
248
+ /* eslint-disable prefer-const, style/max-statements-per-line, no-super-linear-backtracking, regexp/no-unused-capturing-group */
248
249
  /**
249
250
  * STX Composables
250
251
  *
@@ -260,6 +261,7 @@ export declare interface ComponentInstance {
260
261
  // =============================================================================
261
262
  export type LifecycleHook = () => void | (() => void);
262
263
  export type CleanupFn = () => void;
264
+ // eslint-disable-next-line pickier/no-unused-vars
263
265
  export type WatchCallback<T> = (newValue: T, oldValue: T | undefined) => void | CleanupFn;
264
266
  export type WatchSource<T> = () => T;
265
267
  /** Symbol for injection keys */
@@ -174,4 +174,5 @@ export declare interface StxComponentInstance {
174
174
  isMounted: boolean
175
175
  }
176
176
  /** Type-safe emit function */
177
+ // eslint-disable-next-line pickier/no-unused-vars
177
178
  export type EmitFn<T extends string = string> = (event: T, ...args: any[]) => void;
@@ -22,6 +22,7 @@ export declare function shallowRef<T>(initialValue: T): Ref<T>;
22
22
  * Create a computed property with automatic dependency tracking
23
23
  */
24
24
  export declare function computed<T>(getter: () => T): ComputedRef<T>;
25
+ // eslint-disable-next-line pickier/no-unused-vars
25
26
  export declare function computed<T>(options: ComputedOptions<T>): WritableComputedRef<T>;
26
27
  /**
27
28
  * Watch a reactive source and run a callback when it changes
package/dist/config.d.ts CHANGED
@@ -1,5 +1,16 @@
1
+ import path from 'node:path';
1
2
  import type { StxConfig, StxOptions } from './types';
2
- export declare function loadStxConfig(): Promise<StxConfig>;
3
+ /**
4
+ * Load the stx config for a project.
5
+ *
6
+ * `cwd` lets the caller specify which directory to search in — critical for
7
+ * the dev server, which may be invoked as `stx <app-dir>` from outside the
8
+ * app. Without it, `process.cwd()` is used, which can accidentally pick up
9
+ * a stray `stx.config.ts` / `.config/stx.ts` from a parent directory.
10
+ *
11
+ * Results are cached per cwd so repeated calls don't re-read disk.
12
+ */
13
+ export declare function loadStxConfig(cwd?: string): Promise<StxConfig>;
3
14
  /**
4
15
  * Helper function to define stx configuration
5
16
  */
@@ -111,7 +111,8 @@ export declare const CRAFT_BRIDGE_SCRIPT: `
111
111
  let data;
112
112
  try {
113
113
  data = event.detail || (typeof event.data === 'string' ? JSON.parse(event.data) : event.data);
114
- } catch (e) {
114
+ }
115
+ catch (e) {
115
116
  return;
116
117
  }
117
118
 
@@ -128,11 +129,13 @@ export declare const CRAFT_BRIDGE_SCRIPT: `
128
129
  pending.delete(data.id);
129
130
  if (data.error) {
130
131
  req.reject(new Error(data.error.message));
131
- } else {
132
+ }
133
+ else {
132
134
  req.resolve(data.result);
133
135
  }
134
136
  }
135
- } else if (data.type === 'event' && data.method) {
137
+ }
138
+ else if (data.type === 'event' && data.method) {
136
139
  const listeners = eventListeners.get(data.method) || [];
137
140
  listeners.forEach(fn => fn(data.params));
138
141
  }
@@ -370,6 +370,7 @@ export declare const CRAFT_COMPONENT_STYLES: `
370
370
  }
371
371
  </style>
372
372
  `;
373
+ /* eslint-disable prefer-const, style/max-statements-per-line, no-super-linear-backtracking, regexp/no-unused-capturing-group */
373
374
  /**
374
375
  * Craft Native Components for stx
375
376
  *