@stacksjs/stx 0.2.9 → 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.
- package/README.md +16 -11
- package/dist/a11y.d.ts +2 -1
- package/dist/analyzer.d.ts +4 -0
- package/dist/app-shell.d.ts +72 -0
- package/dist/app.d.ts +1 -0
- package/dist/broadcasting.d.ts +77 -0
- package/dist/build-assets.d.ts +32 -0
- package/dist/build-mode-detector.d.ts +26 -0
- package/dist/build.d.ts +31 -0
- package/dist/builtins/icon.d.ts +7 -0
- package/dist/builtins/index.d.ts +21 -0
- package/dist/builtins/stx-image.d.ts +2 -0
- package/dist/builtins/stx-link.d.ts +2 -0
- package/dist/builtins/stx-loading-indicator.d.ts +2 -0
- package/dist/bundle-analyzer/index.d.ts +2 -0
- package/dist/bundle-analyzer.js +20 -20
- package/dist/caching.d.ts +27 -0
- package/dist/cli.js +3941 -2609
- package/dist/client-helpers.d.ts +7 -3
- package/dist/client-script-bundler.d.ts +27 -0
- package/dist/client-script.d.ts +5 -1
- package/dist/client.d.ts +1 -0
- package/dist/component-hmr.d.ts +1 -0
- package/dist/component-processing.d.ts +107 -0
- package/dist/component-registry.d.ts +54 -0
- package/dist/component-renderer.d.ts +18 -0
- package/dist/components/StxImage.stx +12 -0
- package/dist/components/StxLink.stx +18 -8
- package/dist/composables/index.d.ts +7 -0
- package/dist/composables/use-broadcast-channel.d.ts +1 -0
- package/dist/composables/use-channel.d.ts +67 -0
- package/dist/composables/use-intersection-observer.d.ts +2 -0
- package/dist/composables/use-keyboard.d.ts +1 -0
- package/dist/composables/use-mouse.d.ts +1 -0
- package/dist/composables/use-router.d.ts +4 -0
- package/dist/composables/use-websocket.d.ts +1 -0
- package/dist/composables.d.ts +2 -0
- package/dist/composition-api.d.ts +1 -0
- package/dist/computed.d.ts +1 -0
- package/dist/config.d.ts +12 -1
- package/dist/craft-bridge.d.ts +6 -3
- package/dist/craft-components.d.ts +1 -0
- package/dist/craft.js +39 -33
- package/dist/deploy/index.d.ts +1 -0
- package/dist/dev-server/crosswind.d.ts +2 -5
- package/dist/dev-server/native-window.d.ts +19 -1
- package/dist/dev-server/serve-app.d.ts +15 -0
- package/dist/dev-server/serve-file.d.ts +3 -0
- package/dist/dev-server/serve-markdown.d.ts +3 -0
- package/dist/dev-server/serve-multi.d.ts +5 -0
- package/dist/dev-server/types.d.ts +2 -0
- package/dist/dev-server.d.ts +6 -40
- package/dist/devtools.d.ts +1 -0
- package/dist/directive-api.d.ts +1 -1
- package/dist/document-shell.d.ts +33 -0
- package/dist/error-boundaries.d.ts +1 -0
- package/dist/events.d.ts +1 -0
- package/dist/expressions.d.ts +38 -0
- package/dist/forms-validation.d.ts +2 -0
- package/dist/head.d.ts +1 -0
- package/dist/hot-reload.d.ts +1 -0
- package/dist/hydration-runtime.d.ts +1 -0
- package/dist/hydration.d.ts +1 -0
- package/dist/i18n.d.ts +3 -1
- package/dist/image-optimization/build-plugin.d.ts +1 -0
- package/dist/index.d.ts +22 -1
- package/dist/index.js +5569 -4182
- package/dist/inline-assets.d.ts +28 -0
- package/dist/internal-markdown.d.ts +0 -4
- package/dist/jsx-runtime.d.ts +1 -0
- package/dist/keep-alive.d.ts +1 -0
- package/dist/manifest.d.ts +41 -0
- package/dist/markdown.d.ts +1 -0
- package/dist/media/client/blur-up.d.ts +1 -0
- package/dist/media/client/lazy-load.d.ts +1 -0
- package/dist/media/client/upload-handler.d.ts +1 -0
- package/dist/media/shared/cache.d.ts +2 -0
- package/dist/media/video/index.d.ts +1 -0
- package/dist/media/video/processor/thumbnail.d.ts +1 -0
- package/dist/misc-directives.d.ts +49 -0
- package/dist/parser/directive-parser.d.ts +13 -0
- package/dist/performance-utils.d.ts +2 -0
- package/dist/placeholder.d.ts +45 -0
- package/dist/plugin-system.d.ts +32 -2
- package/dist/process.d.ts +11 -1
- package/dist/production-builder.d.ts +42 -0
- package/dist/production-server.d.ts +19 -0
- package/dist/props.d.ts +1 -0
- package/dist/pwa.js +3883 -2679
- package/dist/reactive.d.ts +2 -16
- package/dist/reactivity.d.ts +1 -0
- package/dist/router.d.ts +1 -1
- package/dist/runtime-injection.d.ts +20 -0
- package/dist/runtime.d.ts +2 -2
- package/dist/script-classifier.d.ts +35 -0
- package/dist/script-validation.d.ts +16 -0
- package/dist/server-bindings.d.ts +7 -0
- package/dist/server-components.d.ts +4 -0
- package/dist/signal-processing.d.ts +109 -0
- package/dist/signals-api.d.ts +309 -0
- package/dist/signals.d.ts +2 -309
- package/dist/spa-shell.d.ts +1 -0
- package/dist/ssg.js +3862 -2655
- package/dist/ssr.d.ts +1 -0
- package/dist/state-management.d.ts +27 -0
- package/dist/store-imports.d.ts +24 -0
- package/dist/store-loader.d.ts +16 -0
- package/dist/story/bun-test.d.ts +1 -0
- package/dist/story/compiled-output.d.ts +1 -0
- package/dist/story/interactions.d.ts +1 -0
- package/dist/story/renderer.d.ts +2 -0
- package/dist/story/setup.d.ts +1 -0
- package/dist/story/ui/code-panel.d.ts +1 -0
- package/dist/stx.d.ts +437 -0
- package/dist/style-scoping.d.ts +23 -0
- package/dist/template-compiler.d.ts +31 -0
- package/dist/template-hydrator.d.ts +18 -0
- package/dist/transitions.d.ts +1 -0
- package/dist/types/config-types.d.ts +62 -0
- package/dist/validator.d.ts +1 -0
- package/dist/variable-extractor.d.ts +1 -1
- package/dist/view-composers.d.ts +1 -0
- package/dist/virtual-scrolling.d.ts +1 -0
- package/dist/visual-testing.js +2 -2
- package/dist/web-components.d.ts +1 -0
- package/dist/x-element.d.ts +1 -0
- package/package.json +72 -7
- package/stx.d.ts +437 -0
package/dist/signals.d.ts
CHANGED
|
@@ -1,264 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Creates a reactive state signal.
|
|
3
|
-
*
|
|
4
|
-
* State signals are the foundation of STX reactivity. They hold a value that,
|
|
5
|
-
* when changed, automatically updates any derived signals or effects that
|
|
6
|
-
* depend on it.
|
|
7
|
-
*
|
|
8
|
-
* @param initialValue - The initial value for the signal
|
|
9
|
-
* @returns A signal that can be read, set, and subscribed to
|
|
10
|
-
*
|
|
11
|
-
* @example Basic usage
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const count = state(0)
|
|
14
|
-
*
|
|
15
|
-
* // Read the value
|
|
16
|
-
* console.log(count()) // 0
|
|
17
|
-
*
|
|
18
|
-
* // Set a new value
|
|
19
|
-
* count.set(5)
|
|
20
|
-
* console.log(count()) // 5
|
|
21
|
-
*
|
|
22
|
-
* // Update based on current value
|
|
23
|
-
* count.update(n => n + 1)
|
|
24
|
-
* console.log(count()) // 6
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @example With objects
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const user = state({ name: 'Alice', age: 30 })
|
|
30
|
-
*
|
|
31
|
-
* // Update the whole object
|
|
32
|
-
* user.set({ name: 'Bob', age: 25 })
|
|
33
|
-
*
|
|
34
|
-
* // Or update a property (creates new object for immutability)
|
|
35
|
-
* user.update(u => ({ ...u, age: u.age + 1 }))
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @example With arrays
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const items = state<string[]>([])
|
|
41
|
-
*
|
|
42
|
-
* // Add an item
|
|
43
|
-
* items.update(arr => [...arr, 'new item'])
|
|
44
|
-
*
|
|
45
|
-
* // Remove an item
|
|
46
|
-
* items.update(arr => arr.filter(i => i !== 'remove me'))
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare function state<T>(initialValue: T): Signal<T>;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a derived signal that automatically computes its value from other signals.
|
|
52
|
-
*
|
|
53
|
-
* Derived signals are lazy - they only recompute when read after a dependency
|
|
54
|
-
* has changed. They're perfect for computed values that depend on other state.
|
|
55
|
-
*
|
|
56
|
-
* @param compute - A function that computes the derived value
|
|
57
|
-
* @returns A read-only signal with the computed value
|
|
58
|
-
*
|
|
59
|
-
* @example Basic derived value
|
|
60
|
-
* ```typescript
|
|
61
|
-
* const count = state(5)
|
|
62
|
-
* const doubled = derived(() => count() * 2)
|
|
63
|
-
*
|
|
64
|
-
* console.log(doubled()) // 10
|
|
65
|
-
* count.set(10)
|
|
66
|
-
* console.log(doubled()) // 20
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* @example Combining multiple signals
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const firstName = state('John')
|
|
72
|
-
* const lastName = state('Doe')
|
|
73
|
-
*
|
|
74
|
-
* const fullName = derived(() => `${firstName()} ${lastName()}`)
|
|
75
|
-
* console.log(fullName()) // "John Doe"
|
|
76
|
-
* ```
|
|
77
|
-
*
|
|
78
|
-
* @example Filtering and transforming
|
|
79
|
-
* ```typescript
|
|
80
|
-
* const items = state([1, 2, 3, 4, 5])
|
|
81
|
-
* const filter = state('even')
|
|
82
|
-
*
|
|
83
|
-
* const filteredItems = derived(() => {
|
|
84
|
-
* const list = items()
|
|
85
|
-
* return filter() === 'even'
|
|
86
|
-
* ? list.filter(n => n % 2 === 0)
|
|
87
|
-
* : list.filter(n => n % 2 !== 0)
|
|
88
|
-
* })
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
export declare function derived<T>(compute: () => T): DerivedSignal<T>;
|
|
92
|
-
/**
|
|
93
|
-
* Creates a side effect that runs when its dependencies change.
|
|
94
|
-
*
|
|
95
|
-
* Effects automatically track which signals they read and re-run whenever
|
|
96
|
-
* those signals change. They're perfect for syncing state with external
|
|
97
|
-
* systems, logging, or triggering side effects.
|
|
98
|
-
*
|
|
99
|
-
* @param fn - The effect function to run
|
|
100
|
-
* @param options - Optional configuration
|
|
101
|
-
* @returns A cleanup function to stop the effect
|
|
102
|
-
*
|
|
103
|
-
* @example Basic effect
|
|
104
|
-
* ```typescript
|
|
105
|
-
* const count = state(0)
|
|
106
|
-
*
|
|
107
|
-
* effect(() => {
|
|
108
|
-
* console.log(`Count changed to: ${count()}`)
|
|
109
|
-
* })
|
|
110
|
-
*
|
|
111
|
-
* count.set(1) // Logs: "Count changed to: 1"
|
|
112
|
-
* count.set(2) // Logs: "Count changed to: 2"
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* @example Effect with cleanup
|
|
116
|
-
* ```typescript
|
|
117
|
-
* const isActive = state(true)
|
|
118
|
-
*
|
|
119
|
-
* effect(() => {
|
|
120
|
-
* if (isActive()) {
|
|
121
|
-
* const interval = setInterval(() => console.log('tick'), 1000)
|
|
122
|
-
* // Return cleanup function
|
|
123
|
-
* return () => clearInterval(interval)
|
|
124
|
-
* }
|
|
125
|
-
* })
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
128
|
-
* @example Fetching data
|
|
129
|
-
* ```typescript
|
|
130
|
-
* const userId = state(1)
|
|
131
|
-
* const user = state(null)
|
|
132
|
-
*
|
|
133
|
-
* effect(async () => {
|
|
134
|
-
* const id = userId()
|
|
135
|
-
* const response = await fetch(`/api/users/${id}`)
|
|
136
|
-
* user.set(await response.json())
|
|
137
|
-
* })
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
export declare function effect(fn: () => void | CleanupFn, options?: EffectOptions): CleanupFn;
|
|
141
|
-
/**
|
|
142
|
-
* Batches multiple signal updates into a single effect run.
|
|
143
|
-
*
|
|
144
|
-
* Use this when updating multiple signals at once to avoid redundant
|
|
145
|
-
* effect executions.
|
|
146
|
-
*
|
|
147
|
-
* @param fn - Function containing multiple signal updates
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```typescript
|
|
151
|
-
* const firstName = state('John')
|
|
152
|
-
* const lastName = state('Doe')
|
|
153
|
-
*
|
|
154
|
-
* // Without batch: effect runs twice
|
|
155
|
-
* // With batch: effect runs once
|
|
156
|
-
* batch(() => {
|
|
157
|
-
* firstName.set('Jane')
|
|
158
|
-
* lastName.set('Smith')
|
|
159
|
-
* })
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
export declare function batch(fn: () => void): void;
|
|
163
|
-
/**
|
|
164
|
-
* Registers a callback to run when the component mounts (is inserted into the DOM).
|
|
165
|
-
*
|
|
166
|
-
* @param callback - Function to run on mount. Can return a cleanup function.
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* ```typescript
|
|
170
|
-
* onMount(() => {
|
|
171
|
-
* console.log('Component is now in the DOM')
|
|
172
|
-
*
|
|
173
|
-
* // Optional: return cleanup function
|
|
174
|
-
* return () => console.log('Cleanup on unmount')
|
|
175
|
-
* })
|
|
176
|
-
* ```
|
|
177
|
-
*
|
|
178
|
-
* @example Fetching initial data
|
|
179
|
-
* ```typescript
|
|
180
|
-
* const data = state(null)
|
|
181
|
-
*
|
|
182
|
-
* onMount(async () => {
|
|
183
|
-
* data.set(await fetchInitialData())
|
|
184
|
-
* })
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
export declare function onMount(callback: LifecycleCallback): void;
|
|
188
|
-
/**
|
|
189
|
-
* Registers a callback to run when the component is destroyed (removed from the DOM).
|
|
190
|
-
*
|
|
191
|
-
* @param callback - Function to run on destroy
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```typescript
|
|
195
|
-
* onDestroy(() => {
|
|
196
|
-
* console.log('Component is being removed')
|
|
197
|
-
* // Clean up subscriptions, timers, etc.
|
|
198
|
-
* })
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
export declare function onDestroy(callback: LifecycleCallback): void;
|
|
202
|
-
/**
|
|
203
|
-
* Checks if a value is a signal.
|
|
204
|
-
*
|
|
205
|
-
* @param value - Value to check
|
|
206
|
-
* @returns True if the value is a signal
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```typescript
|
|
210
|
-
* const count = state(0)
|
|
211
|
-
* isSignal(count) // true
|
|
212
|
-
* isSignal(5) // false
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
export declare function isSignal(value: unknown): value is Signal<unknown>;
|
|
216
|
-
/**
|
|
217
|
-
* Checks if a value is a derived signal.
|
|
218
|
-
*
|
|
219
|
-
* @param value - Value to check
|
|
220
|
-
* @returns True if the value is a derived signal
|
|
221
|
-
*/
|
|
222
|
-
export declare function isDerived(value: unknown): value is DerivedSignal<unknown>;
|
|
223
|
-
/**
|
|
224
|
-
* Unwraps a signal to get its raw value.
|
|
225
|
-
* If the value is not a signal, returns it as-is.
|
|
226
|
-
*
|
|
227
|
-
* @param value - A signal or plain value
|
|
228
|
-
* @returns The unwrapped value
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* ```typescript
|
|
232
|
-
* const count = state(5)
|
|
233
|
-
* untrack(count) // 5
|
|
234
|
-
* untrack(10) // 10
|
|
235
|
-
* ```
|
|
236
|
-
*/
|
|
237
|
-
export declare function untrack<T>(value: T | Signal<T> | DerivedSignal<T>): T;
|
|
238
|
-
/**
|
|
239
|
-
* Reads a signal's value without tracking it as a dependency.
|
|
240
|
-
*
|
|
241
|
-
* Use this when you need to read a signal inside an effect but don't want
|
|
242
|
-
* the effect to re-run when that signal changes.
|
|
243
|
-
*
|
|
244
|
-
* @param fn - Function to run without tracking
|
|
245
|
-
* @returns The function's return value
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```typescript
|
|
249
|
-
* const count = state(0)
|
|
250
|
-
* const other = state(0)
|
|
251
|
-
*
|
|
252
|
-
* effect(() => {
|
|
253
|
-
* // This effect only re-runs when `count` changes
|
|
254
|
-
* console.log(count())
|
|
255
|
-
*
|
|
256
|
-
* // Reading `other` without tracking
|
|
257
|
-
* const otherValue = peek(() => other())
|
|
258
|
-
* })
|
|
259
|
-
* ```
|
|
260
|
-
*/
|
|
261
|
-
export declare function peek<T>(fn: () => T): T;
|
|
1
|
+
import { state, derived, effect, batch, onMount, onDestroy, isSignal, isDerived, untrack, peek } from './signals-api';
|
|
262
2
|
/**
|
|
263
3
|
* Generates the browser runtime for STX signals.
|
|
264
4
|
*
|
|
@@ -274,54 +14,7 @@ export declare function generateSignalsRuntime(): string;
|
|
|
274
14
|
* @returns Human-readable JavaScript runtime code
|
|
275
15
|
*/
|
|
276
16
|
export declare function generateSignalsRuntimeDev(): string;
|
|
277
|
-
|
|
278
|
-
* A reactive state signal.
|
|
279
|
-
*
|
|
280
|
-
* Call it to read the value, use `.set()` to write, or `.update()` to transform.
|
|
281
|
-
*
|
|
282
|
-
* @example
|
|
283
|
-
* ```typescript
|
|
284
|
-
* const count = state(0)
|
|
285
|
-
* count() // Read: 0
|
|
286
|
-
* count.set(5) // Write: 5
|
|
287
|
-
* count.update(n => n + 1) // Update: 6
|
|
288
|
-
* ```
|
|
289
|
-
*/
|
|
290
|
-
export declare interface Signal<T> {
|
|
291
|
-
(): T
|
|
292
|
-
set(value: T): void
|
|
293
|
-
update(fn: (current: T) => T): void
|
|
294
|
-
subscribe(callback: (value: T, prev: T) => void): () => void
|
|
295
|
-
readonly _isSignal: true
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* A derived (computed) signal that automatically updates when dependencies change.
|
|
299
|
-
*
|
|
300
|
-
* @example
|
|
301
|
-
* ```typescript
|
|
302
|
-
* const doubled = derived(() => count() * 2)
|
|
303
|
-
* doubled() // Read the computed value
|
|
304
|
-
* ```
|
|
305
|
-
*/
|
|
306
|
-
export declare interface DerivedSignal<T> {
|
|
307
|
-
(): T
|
|
308
|
-
readonly _isDerived: true
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Options for creating effects.
|
|
312
|
-
*/
|
|
313
|
-
export declare interface EffectOptions {
|
|
314
|
-
immediate?: boolean
|
|
315
|
-
name?: string
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Cleanup function returned by effects.
|
|
319
|
-
*/
|
|
320
|
-
export type CleanupFn = () => void;
|
|
321
|
-
/**
|
|
322
|
-
* Lifecycle hook callback.
|
|
323
|
-
*/
|
|
324
|
-
export type LifecycleCallback = () => void | CleanupFn | Promise<void>;
|
|
17
|
+
export * from './signals-api';
|
|
325
18
|
// =============================================================================
|
|
326
19
|
// Default Export
|
|
327
20
|
// =============================================================================
|
package/dist/spa-shell.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* for client-side rendering.
|
|
4
4
|
*/
|
|
5
5
|
export declare function generateSpaShell(options: SpaShellOptions): string;
|
|
6
|
+
/* eslint-disable prefer-const, style/max-statements-per-line, no-super-linear-backtracking, regexp/no-unused-capturing-group */
|
|
6
7
|
/**
|
|
7
8
|
* SPA Shell Generator
|
|
8
9
|
*
|