@stacksjs/stx 0.2.155 → 0.2.157
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/dist/a11y.d.ts +87 -46
- package/dist/animation.d.ts +96 -42
- package/dist/appearance-bootstrap.d.ts +49 -15
- package/dist/asset-roots.d.ts +32 -0
- package/dist/asset-roots.js +7 -0
- package/dist/assets.d.ts +9 -7
- package/dist/async-components.d.ts +78 -56
- package/dist/auth.d.ts +3 -0
- package/dist/build-externalize.d.ts +40 -0
- package/dist/build-externalize.js +63 -0
- package/dist/build-id.d.ts +22 -22
- package/dist/build-message.d.ts +73 -2
- package/dist/build-message.js +47 -8
- package/dist/builtins/attrs.d.ts +14 -0
- package/dist/builtins/drawer.d.ts +22 -0
- package/dist/builtins/icon.d.ts +16 -2
- package/dist/builtins/index.d.ts +5 -15
- package/dist/builtins/modal.d.ts +24 -0
- package/dist/builtins/safe-image.d.ts +42 -0
- package/dist/builtins/stx-image.d.ts +27 -0
- package/dist/builtins/stx-link.d.ts +9 -0
- package/dist/builtins/stx-loading-indicator.d.ts +11 -0
- package/dist/builtins/suspense.d.ts +28 -0
- package/dist/builtins/toast.d.ts +17 -0
- package/dist/builtins/transition-group.d.ts +25 -0
- package/dist/caching.d.ts +12 -15
- package/dist/cli.js +1798 -908
- package/dist/client/directive.d.ts +7 -0
- package/dist/client/index.d.ts +0 -1
- package/dist/client-script-bundler.d.ts +63 -5
- package/dist/client-script-bundler.js +30 -2
- package/dist/client-script.d.ts +102 -47
- package/dist/client-script.js +15 -3
- package/dist/codemod.d.ts +56 -0
- package/dist/codemod.js +192 -0
- package/dist/color-mode-boot.d.ts +83 -65
- package/dist/component-client-factories.d.ts +1 -6
- package/dist/component-processing.d.ts +58 -49
- package/dist/component-processing.js +1 -1
- package/dist/component-registry.d.ts +94 -31
- package/dist/component-renderer.d.ts +18 -0
- package/dist/composable-loader.d.ts +24 -0
- package/dist/composable-loader.js +12 -9
- package/dist/composables/index.d.ts +7 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-fetch.js +30 -2
- package/dist/composables/use-form.d.ts +91 -0
- package/dist/composables/use-form.js +112 -0
- package/dist/composables.d.ts +64 -60
- package/dist/computed.d.ts +86 -92
- package/dist/conditionals.d.ts +24 -8
- package/dist/conditionals.js +16 -0
- package/dist/config.d.ts +34 -21
- package/dist/config.js +35 -14
- package/dist/craft.js +1476 -768
- package/dist/crosswind-config.d.ts +58 -0
- package/dist/crosswind-config.js +40 -0
- package/dist/csp.d.ts +107 -41
- package/dist/defer.d.ts +24 -0
- package/dist/dev-server/crosswind.d.ts +35 -26
- package/dist/dev-server/crosswind.js +2 -18
- package/dist/dev-server/serve-app.js +4 -3
- package/dist/dev-server/terminal-colors.d.ts +32 -32
- package/dist/directive-api.d.ts +86 -43
- package/dist/document-shell.d.ts +54 -41
- package/dist/dynamic-components.d.ts +9 -0
- package/dist/error-boundaries.d.ts +47 -41
- package/dist/error-handling.d.ts +1 -1
- package/dist/errors/codes.d.ts +51 -43
- package/dist/errors/formatter.d.ts +58 -38
- package/dist/errors/index.d.ts +5 -61
- package/dist/errors/logger.d.ts +114 -40
- package/dist/errors/sanitizer.d.ts +53 -23
- package/dist/errors/types.d.ts +44 -31
- package/dist/events.d.ts +86 -25
- package/dist/expressions.d.ts +50 -42
- package/dist/forms-validation.d.ts +138 -123
- package/dist/forms-validation.js +1 -90
- package/dist/forms.d.ts +120 -66
- package/dist/forms.js +31 -11
- package/dist/fragment-container.d.ts +57 -0
- package/dist/fragment-container.js +109 -0
- package/dist/framework-composables.d.ts +32 -0
- package/dist/head.d.ts +156 -114
- package/dist/heatmap.d.ts +152 -72
- package/dist/html-masking.d.ts +40 -34
- package/dist/hydration-runtime.d.ts +20 -24
- package/dist/i18n.d.ts +93 -32
- package/dist/image-optimization/auto-sibling.d.ts +32 -4
- package/dist/includes.d.ts +69 -7
- package/dist/index.d.ts +66 -0
- package/dist/index.js +23 -0
- package/dist/internal-markdown.d.ts +12 -8
- package/dist/island-chunking.d.ts +30 -13
- package/dist/keep-alive.d.ts +72 -52
- package/dist/layout-types.d.ts +45 -0
- package/dist/layout-types.js +56 -0
- package/dist/lazy-module.d.ts +10 -0
- package/dist/loops.d.ts +66 -0
- package/dist/loops.js +47 -6
- package/dist/markdown.d.ts +0 -1
- package/dist/media/image/component.d.ts +25 -9
- package/dist/media/image/directive.d.ts +15 -1
- package/dist/media/image/placeholder.d.ts +20 -9
- package/dist/media/image/processor/cache.d.ts +40 -18
- package/dist/media/image/processor/index.d.ts +1 -10
- package/dist/media/image/processor/optimizer.d.ts +12 -1
- package/dist/media/image/processor/responsive.d.ts +16 -6
- package/dist/media/image/srcset.d.ts +47 -50
- package/dist/media/shared/cache.d.ts +51 -31
- package/dist/media/shared/hash.d.ts +7 -0
- package/dist/media/types.d.ts +1235 -754
- package/dist/media/video/directive.d.ts +15 -1
- package/dist/media/video/index.d.ts +39 -17
- package/dist/media/video/processor/cache.d.ts +42 -19
- package/dist/media/video/processor/index.d.ts +1 -18
- package/dist/media/video/processor/streaming.d.ts +17 -10
- package/dist/media/video/processor/thumbnail.d.ts +21 -15
- package/dist/media/video/processor/transcoder.d.ts +11 -1
- package/dist/method-spoofing.d.ts +7 -0
- package/dist/middleware.d.ts +60 -0
- package/dist/owned-routes.d.ts +42 -0
- package/dist/owned-routes.js +26 -0
- package/dist/page-meta.d.ts +38 -0
- package/dist/page-meta.js +16 -0
- package/dist/parser/directive-parser.d.ts +57 -45
- package/dist/parser/expression-parser.d.ts +33 -35
- package/dist/parser/index.d.ts +4 -39
- package/dist/parser/tokenizer.d.ts +61 -49
- package/dist/partial-hydration.d.ts +82 -50
- package/dist/performance-utils.d.ts +217 -124
- package/dist/placeholder.d.ts +18 -9
- package/dist/plugin-system.d.ts +264 -115
- package/dist/process.d.ts +11 -6
- package/dist/process.js +21 -4
- package/dist/production-builder.js +7 -0
- package/dist/prop-sentinels.d.ts +11 -11
- package/dist/public-env.d.ts +14 -0
- package/dist/pwa/directives.d.ts +12 -3
- package/dist/pwa/inject.d.ts +10 -0
- package/dist/pwa/precache.d.ts +22 -16
- package/dist/pwa/service-worker.d.ts +12 -0
- package/dist/pwa.js +1318 -610
- package/dist/reactive-bindings.d.ts +34 -11
- package/dist/reactive.d.ts +58 -30
- package/dist/reactive.js +56 -31
- package/dist/render.d.ts +0 -14
- package/dist/render.js +17 -0
- package/dist/route-middleware.d.ts +2 -35
- package/dist/route-types.d.ts +134 -0
- package/dist/route-types.js +24 -0
- package/dist/router.d.ts +5 -7
- package/dist/routes.d.ts +1 -3
- package/dist/runtime-globals.d.ts +147 -24
- package/dist/runtime-globals.js +16 -1
- package/dist/runtime-injection.d.ts +8 -0
- package/dist/runtime-injection.js +33 -24
- package/dist/script-emit.d.ts +30 -0
- package/dist/script-json.d.ts +36 -0
- package/dist/script-json.js +6 -0
- package/dist/script-validation.d.ts +21 -4
- package/dist/seo.d.ts +118 -47
- package/dist/server-bindings.d.ts +21 -0
- package/dist/sfc-template.d.ts +8 -8
- package/dist/signal-processing.d.ts +35 -15
- package/dist/signals-api.d.ts +117 -58
- package/dist/signals-api.js +7 -4
- package/dist/signals.d.ts +24 -17
- package/dist/signals.js +765 -60
- package/dist/site-builder/build.js +8 -0
- package/dist/site-url.d.ts +46 -0
- package/dist/site-url.js +70 -0
- package/dist/slots.d.ts +86 -20
- package/dist/source-signature.d.ts +45 -0
- package/dist/source-signature.js +20 -0
- package/dist/ssg.d.ts +285 -142
- package/dist/ssg.js +1268 -556
- package/dist/state-dir.d.ts +4 -4
- package/dist/state-management.d.ts +0 -12
- package/dist/state-management.js +8 -25
- package/dist/store-imports.d.ts +23 -0
- package/dist/store-imports.js +3 -0
- package/dist/store-loader.d.ts +10 -0
- package/dist/store-loader.js +10 -9
- package/dist/story/analytics.d.ts +138 -60
- package/dist/story/bookmarks.d.ts +87 -34
- package/dist/story/cli.d.ts +123 -69
- package/dist/story/collect/scanner.d.ts +4 -0
- package/dist/story/collect/tree.d.ts +8 -1
- package/dist/story/commands/build.d.ts +11 -6
- package/dist/story/commands/dev.d.ts +15 -8
- package/dist/story/commands/preview.d.ts +13 -7
- package/dist/story/config-watcher.d.ts +20 -13
- package/dist/story/config.d.ts +11 -8
- package/dist/story/context.d.ts +14 -8
- package/dist/story/hmr.d.ts +24 -26
- package/dist/story/hot-swap.d.ts +34 -23
- package/dist/story/keyboard-shortcuts.d.ts +23 -18
- package/dist/story/output.d.ts +46 -44
- package/dist/story/performance.d.ts +107 -45
- package/dist/story/presets.d.ts +107 -41
- package/dist/story/renderer.d.ts +41 -27
- package/dist/story/search.d.ts +23 -12
- package/dist/story/server.d.ts +21 -11
- package/dist/story/setup.d.ts +23 -15
- package/dist/story/testing.d.ts +65 -40
- package/dist/story/types.d.ts +262 -160
- package/dist/streaming.d.ts +119 -57
- package/dist/stx-virtual-ts.d.ts +165 -0
- package/dist/stx-virtual-ts.js +372 -0
- package/dist/stx.d.ts +78 -1
- package/dist/style-scoping.d.ts +17 -4
- package/dist/suspense.d.ts +67 -52
- package/dist/teleport.d.ts +22 -0
- package/dist/template-tag-balance.d.ts +22 -6
- package/dist/transitions.d.ts +66 -55
- package/dist/typecheck.d.ts +77 -0
- package/dist/typecheck.js +156 -0
- package/dist/types/component-types.d.ts +187 -122
- package/dist/types/config-types.d.ts +758 -297
- package/dist/types/context-types.d.ts +46 -24
- package/dist/types/csp-types.d.ts +70 -66
- package/dist/types/directive-types.d.ts +211 -155
- package/dist/types/index.d.ts +6 -109
- package/dist/types/pwa-types.d.ts +273 -148
- package/dist/types.d.ts +0 -1
- package/dist/typescript-templates.d.ts +11 -0
- package/dist/unresolved-identifiers.d.ts +24 -22
- package/dist/unresolved-identifiers.js +2 -0
- package/dist/utils.d.ts +24 -21
- package/dist/validator.d.ts +28 -26
- package/dist/variable-extractor.d.ts +48 -13
- package/dist/variable-extractor.js +27 -4
- package/dist/view-composers.d.ts +80 -81
- package/dist/virtual-scrolling.d.ts +101 -81
- package/dist/vue-template.d.ts +23 -0
- package/dist/web-components/css-scoping.d.ts +21 -11
- package/dist/web-components.d.ts +81 -58
- package/dist/x-element.d.ts +0 -1
- package/package.json +5 -5
- package/stx.d.ts +78 -1
package/dist/web-components.d.ts
CHANGED
|
@@ -3,6 +3,72 @@ import type { StxOptions } from './types';
|
|
|
3
3
|
* Builds web components from stx components
|
|
4
4
|
*/
|
|
5
5
|
export declare function buildWebComponents(options: StxOptions, dependencies: Set<string>): Promise<string[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Property definition for reactive web components
|
|
8
|
+
*/
|
|
9
|
+
export interface ReactivePropertyDefinition {
|
|
10
|
+
/** Property type for serialization/deserialization */
|
|
11
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
12
|
+
/** Default value */
|
|
13
|
+
default?: unknown;
|
|
14
|
+
/** Whether property reflects to attribute */
|
|
15
|
+
reflect?: boolean;
|
|
16
|
+
/** Custom attribute name (defaults to kebab-case of property name) */
|
|
17
|
+
attribute?: string | false;
|
|
18
|
+
/** Observer function name to call when property changes */
|
|
19
|
+
observer?: string;
|
|
20
|
+
/** Whether property changes should trigger re-render */
|
|
21
|
+
render?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reactive web component configuration
|
|
25
|
+
*/
|
|
26
|
+
export interface ReactiveWebComponentConfig {
|
|
27
|
+
/** Component class name */
|
|
28
|
+
name: string;
|
|
29
|
+
/** Custom element tag name */
|
|
30
|
+
tag: string;
|
|
31
|
+
/** Base element to extend */
|
|
32
|
+
baseElement?: string;
|
|
33
|
+
/** Component template HTML */
|
|
34
|
+
template: string;
|
|
35
|
+
/** Component styles (CSS) */
|
|
36
|
+
styles?: string;
|
|
37
|
+
/** Whether to use Shadow DOM */
|
|
38
|
+
shadowDOM?: boolean;
|
|
39
|
+
/** Reactive property definitions */
|
|
40
|
+
properties?: Record<string, ReactivePropertyDefinition>;
|
|
41
|
+
/** Lifecycle hooks to include */
|
|
42
|
+
lifecycle?: {
|
|
43
|
+
connected?: string;
|
|
44
|
+
disconnected?: string;
|
|
45
|
+
adopted?: string;
|
|
46
|
+
attributeChanged?: string;
|
|
47
|
+
};
|
|
48
|
+
/** Event handlers */
|
|
49
|
+
events?: Record<string, string>;
|
|
50
|
+
/** Methods to include in the component */
|
|
51
|
+
methods?: Record<string, string>;
|
|
52
|
+
/** Initial state */
|
|
53
|
+
state?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* CSS scoping strategy
|
|
57
|
+
*/
|
|
58
|
+
export type CssScopingStrategy = 'shadow' | 'prefix' | 'attribute' | 'bem';
|
|
59
|
+
/**
|
|
60
|
+
* CSS scoping configuration
|
|
61
|
+
*/
|
|
62
|
+
export interface CssScopingConfig {
|
|
63
|
+
/** Scoping strategy to use */
|
|
64
|
+
strategy: CssScopingStrategy;
|
|
65
|
+
/** Prefix for class-based scoping (strategy: 'prefix') */
|
|
66
|
+
prefix?: string;
|
|
67
|
+
/** Attribute name for attribute-based scoping (strategy: 'attribute') */
|
|
68
|
+
attributeName?: string;
|
|
69
|
+
/** Whether to preserve original class names */
|
|
70
|
+
preserveOriginal?: boolean;
|
|
71
|
+
}
|
|
6
72
|
/**
|
|
7
73
|
* Generate a unique scope ID for a component
|
|
8
74
|
*/
|
|
@@ -50,7 +116,10 @@ export declare function getScopeAttribute(componentTag: string, config?: Partial
|
|
|
50
116
|
* @param config - Scoping configuration
|
|
51
117
|
* @returns Object with scoped HTML and extracted scoped CSS
|
|
52
118
|
*/
|
|
53
|
-
export declare function extractAndScopeStyles(html: string, componentTag: string, config?: Partial<CssScopingConfig>): {
|
|
119
|
+
export declare function extractAndScopeStyles(html: string, componentTag: string, config?: Partial<CssScopingConfig>): {
|
|
120
|
+
html: string;
|
|
121
|
+
css: string;
|
|
122
|
+
};
|
|
54
123
|
/**
|
|
55
124
|
* Generate a reactive web component with full lifecycle management.
|
|
56
125
|
*
|
|
@@ -117,6 +186,17 @@ export declare function generateReactiveMixin(): string;
|
|
|
117
186
|
* @returns JavaScript runtime code
|
|
118
187
|
*/
|
|
119
188
|
export declare function generateReactiveRuntime(): string;
|
|
189
|
+
/**
|
|
190
|
+
* Parsed SFC web component structure
|
|
191
|
+
*/
|
|
192
|
+
export interface ParsedSFCComponent {
|
|
193
|
+
tag: string;
|
|
194
|
+
props: string[];
|
|
195
|
+
template: string;
|
|
196
|
+
styles: string;
|
|
197
|
+
script: string;
|
|
198
|
+
shadowDOM: boolean;
|
|
199
|
+
}
|
|
120
200
|
/**
|
|
121
201
|
* Parse an SFC-style web component file
|
|
122
202
|
*
|
|
@@ -170,61 +250,4 @@ export declare function generateSFCWebComponent(parsed: ParsedSFCComponent): str
|
|
|
170
250
|
* </style>
|
|
171
251
|
* ```
|
|
172
252
|
*/
|
|
173
|
-
// eslint-disable-next-line pickier/no-unused-vars
|
|
174
253
|
export declare function webComponentDirectiveHandler(content: string, params: string[], context: Record<string, any>, filePath: string): Promise<string>;
|
|
175
|
-
/**
|
|
176
|
-
* Property definition for reactive web components
|
|
177
|
-
*/
|
|
178
|
-
export declare interface ReactivePropertyDefinition {
|
|
179
|
-
type: 'string' | 'number' | 'boolean' | 'object' | 'array'
|
|
180
|
-
default?: unknown
|
|
181
|
-
reflect?: boolean
|
|
182
|
-
attribute?: string | false
|
|
183
|
-
observer?: string
|
|
184
|
-
render?: boolean
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Reactive web component configuration
|
|
188
|
-
*/
|
|
189
|
-
export declare interface ReactiveWebComponentConfig {
|
|
190
|
-
name: string
|
|
191
|
-
tag: string
|
|
192
|
-
baseElement?: string
|
|
193
|
-
template: string
|
|
194
|
-
styles?: string
|
|
195
|
-
shadowDOM?: boolean
|
|
196
|
-
properties?: Record<string, ReactivePropertyDefinition>
|
|
197
|
-
lifecycle?: {
|
|
198
|
-
connected?: string
|
|
199
|
-
disconnected?: string
|
|
200
|
-
adopted?: string
|
|
201
|
-
attributeChanged?: string
|
|
202
|
-
}
|
|
203
|
-
events?: Record<string, string>
|
|
204
|
-
methods?: Record<string, string>
|
|
205
|
-
state?: Record<string, unknown>
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* CSS scoping configuration
|
|
209
|
-
*/
|
|
210
|
-
export declare interface CssScopingConfig {
|
|
211
|
-
strategy: CssScopingStrategy
|
|
212
|
-
prefix?: string
|
|
213
|
-
attributeName?: string
|
|
214
|
-
preserveOriginal?: boolean
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Parsed SFC web component structure
|
|
218
|
-
*/
|
|
219
|
-
export declare interface ParsedSFCComponent {
|
|
220
|
-
tag: string
|
|
221
|
-
props: string[]
|
|
222
|
-
template: string
|
|
223
|
-
styles: string
|
|
224
|
-
script: string
|
|
225
|
-
shadowDOM: boolean
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* CSS scoping strategy
|
|
229
|
-
*/
|
|
230
|
-
export type CssScopingStrategy = 'shadow' | 'prefix' | 'attribute' | 'bem';
|
package/dist/x-element.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.157",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,12 +117,12 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@cwcss/crosswind": "^0.2.14",
|
|
119
119
|
"@stacksjs/clapp": "^0.2.0",
|
|
120
|
-
"@stacksjs/desktop": "0.2.
|
|
121
|
-
"@stacksjs/sanitizer": "0.2.
|
|
120
|
+
"@stacksjs/desktop": "0.2.157",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.157",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.157",
|
|
124
124
|
"bunfig": "^0.15.17",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.157",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.1.9",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|
package/stx.d.ts
CHANGED
|
@@ -124,9 +124,24 @@ interface StxNavigateOptions {
|
|
|
124
124
|
* shape that actually shipped — but keeping it out of the type means nothing
|
|
125
125
|
* that type-checks today changes meaning (#1807).
|
|
126
126
|
*/
|
|
127
|
-
declare function navigate
|
|
127
|
+
declare function navigate<T extends string>(
|
|
128
|
+
_url: T & import('@stacksjs/stx').CheckHref<T>,
|
|
129
|
+
_options?: StxNavigateOptions,
|
|
130
|
+
): void
|
|
128
131
|
declare function goBack(): void
|
|
129
132
|
declare function goForward(): void
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Re-run the current route against the server and swap the result, without a
|
|
136
|
+
* document load. Use after a mutation that changed server-rendered content.
|
|
137
|
+
*/
|
|
138
|
+
declare function refresh(): Promise<boolean>
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Expire one cached route so the next visit re-fetches it. Defaults to the
|
|
142
|
+
* current path.
|
|
143
|
+
*/
|
|
144
|
+
declare function invalidateRoute(_url?: string): void
|
|
130
145
|
declare function useRoute(): {
|
|
131
146
|
path: string
|
|
132
147
|
params: Record<string, string>
|
|
@@ -134,6 +149,17 @@ declare function useRoute(): {
|
|
|
134
149
|
hash: string
|
|
135
150
|
}
|
|
136
151
|
declare function setRouteParams(_params: Record<string, string>): void
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Reactive access to the current route's dynamic segments.
|
|
155
|
+
*
|
|
156
|
+
* Published on `window.stx` by 5daaba1f9b but never added to the auto-imported
|
|
157
|
+
* list, so it was reachable only as `window.stx.useRouteParams()` — exactly the
|
|
158
|
+
* authoring-surface gap in #1846.
|
|
159
|
+
*/
|
|
160
|
+
declare function useRouteParams(): StxSignal<Record<string, string>>
|
|
161
|
+
/** One dynamic segment, as a signal. */
|
|
162
|
+
declare function useRouteParam(_name: string, _defaultValue?: string): StxSignal<string>
|
|
137
163
|
/** How a search-param mutation is written to session history (#1825). */
|
|
138
164
|
interface StxSearchParamsCommitOptions {
|
|
139
165
|
/** Replace the current history entry instead of pushing a new one. */
|
|
@@ -190,6 +216,52 @@ interface StxMutationResult<T> {
|
|
|
190
216
|
declare function useFetch<T = any>(_url: string, _options?: any): StxQueryResult<T>
|
|
191
217
|
declare function useQuery<T = any>(_url: string, _options?: any): StxQueryResult<T>
|
|
192
218
|
declare function useMutation<T = any>(_url: string, _options?: any): StxMutationResult<T>
|
|
219
|
+
|
|
220
|
+
/** Context handed to a request interceptor. Mutate it; the return is ignored. */
|
|
221
|
+
interface StxFetchRequestContext {
|
|
222
|
+
/** Which primitive made the call: 'useFetch' | 'useQuery' | 'useMutation'. */
|
|
223
|
+
source: string
|
|
224
|
+
/** Reassignable, so a hook can prefix a baseURL. */
|
|
225
|
+
url: string
|
|
226
|
+
/** `headers` is normalised to an object before the hook runs. */
|
|
227
|
+
options: RequestInit & { headers: Record<string, string> }
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Context handed to a response interceptor. */
|
|
231
|
+
interface StxFetchResponseContext extends StxFetchRequestContext {
|
|
232
|
+
response: Response
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Context handed to an error interceptor. `response` is the non-ok Response, or
|
|
237
|
+
* null when the fetch itself threw (a network failure); `error` is set only in
|
|
238
|
+
* the latter case.
|
|
239
|
+
*/
|
|
240
|
+
interface StxFetchErrorContext extends StxFetchRequestContext {
|
|
241
|
+
response: Response | null
|
|
242
|
+
error: Error | null
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Install request/response interceptors for every stx data primitive.
|
|
247
|
+
*
|
|
248
|
+
* All three funnel through one internal fetch, so a single pair of hooks
|
|
249
|
+
* carries an auth header or observes a 401 across `useFetch`, `useQuery` and
|
|
250
|
+
* `useMutation`. Calling this again REPLACES the hooks rather than adding to
|
|
251
|
+
* them, so a re-evaluated module cannot install the same interceptor twice.
|
|
252
|
+
*
|
|
253
|
+
* `onResponseError` fires for a non-ok response and for a thrown fetch. Return
|
|
254
|
+
* a Response to replace the failed one — the shape a 401 -> refresh -> retry
|
|
255
|
+
* takes: refresh the token, re-issue the request with a plain `fetch()` (not
|
|
256
|
+
* this data layer, so it does not re-enter the hook), and return that Response.
|
|
257
|
+
* Return nothing to let the original error stand.
|
|
258
|
+
*/
|
|
259
|
+
declare function configureFetch(_config: {
|
|
260
|
+
onRequest?: (_ctx: StxFetchRequestContext) => void | Promise<void>
|
|
261
|
+
onResponse?: (_ctx: StxFetchResponseContext) => void | Promise<void>
|
|
262
|
+
onResponseError?: (_ctx: StxFetchErrorContext) => void | Response | Promise<void | Response>
|
|
263
|
+
}): void
|
|
264
|
+
|
|
193
265
|
declare function useOptimistic<T = any, A = any>(
|
|
194
266
|
_base: StxSignal<T> | (() => T) | T,
|
|
195
267
|
_reducer: (_current: T, _action: A) => T,
|
|
@@ -591,14 +663,19 @@ interface StxRuntimeRegistry {
|
|
|
591
663
|
useRef: typeof useRef
|
|
592
664
|
useQuery: typeof useQuery
|
|
593
665
|
useMutation: typeof useMutation
|
|
666
|
+
configureFetch: typeof configureFetch
|
|
594
667
|
useOptimistic: typeof useOptimistic
|
|
595
668
|
|
|
596
669
|
// Routing
|
|
597
670
|
navigate: typeof navigate
|
|
598
671
|
goBack: typeof goBack
|
|
599
672
|
goForward: typeof goForward
|
|
673
|
+
refresh: typeof refresh
|
|
674
|
+
invalidateRoute: typeof invalidateRoute
|
|
600
675
|
useRoute: typeof useRoute
|
|
601
676
|
setRouteParams: typeof setRouteParams
|
|
677
|
+
useRouteParams: typeof useRouteParams
|
|
678
|
+
useRouteParam: typeof useRouteParam
|
|
602
679
|
useSearchParams: typeof useSearchParams
|
|
603
680
|
|
|
604
681
|
// Composition
|