@analogjs/router 2.8.0-beta.9 → 2.8.1-beta.1
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/fesm2022/analogjs-router-debug.page-MFY2u07E.mjs +119 -0
- package/fesm2022/analogjs-router-debug.page-MFY2u07E.mjs.map +1 -0
- package/fesm2022/analogjs-router-i18n.mjs +82 -219
- package/fesm2022/analogjs-router-i18n.mjs.map +1 -1
- package/fesm2022/analogjs-router-routes-L2tt-0ms.mjs +263 -0
- package/fesm2022/analogjs-router-routes-L2tt-0ms.mjs.map +1 -0
- package/fesm2022/analogjs-router-server-actions.mjs +228 -463
- package/fesm2022/analogjs-router-server-actions.mjs.map +1 -1
- package/fesm2022/analogjs-router-server.mjs +608 -838
- package/fesm2022/analogjs-router-server.mjs.map +1 -1
- package/fesm2022/analogjs-router-tanstack-query-server.mjs +35 -85
- package/fesm2022/analogjs-router-tanstack-query-server.mjs.map +1 -1
- package/fesm2022/analogjs-router-tanstack-query.mjs +79 -127
- package/fesm2022/analogjs-router-tanstack-query.mjs.map +1 -1
- package/fesm2022/analogjs-router-tokens.mjs +14 -19
- package/fesm2022/analogjs-router-tokens.mjs.map +1 -1
- package/fesm2022/analogjs-router.mjs +882 -1324
- package/fesm2022/analogjs-router.mjs.map +1 -1
- package/package.json +2 -2
- package/types/analogjs-router-i18n.d.ts +55 -24
- package/types/analogjs-router-server-actions.d.ts +98 -107
- package/types/analogjs-router-server.d.ts +76 -116
- package/types/analogjs-router-tanstack-query-server.d.ts +33 -37
- package/types/analogjs-router-tanstack-query.d.ts +19 -24
- package/types/analogjs-router-tokens.d.ts +26 -22
- package/types/analogjs-router.d.ts +528 -348
- package/fesm2022/analogjs-router-debug.page-COcFkgRu.mjs +0 -91
- package/fesm2022/analogjs-router-debug.page-COcFkgRu.mjs.map +0 -1
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { $Fetch } from
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import { HttpRequest, HttpHandlerFn } from '@angular/common/http';
|
|
11
|
-
import { StandardSchemaV1 as StandardSchemaV1$1 } from '@analogjs/router/server/actions';
|
|
12
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { EnvironmentProviders, InjectionToken, Injector, InputSignal, OnChanges, OnDestroy, ResourceRef, Signal, Type } from "@angular/core";
|
|
3
|
+
import * as i1 from "@angular/router";
|
|
4
|
+
import { ActivatedRoute, ActivatedRouteSnapshot, CanActivateChildFn, CanActivateFn, CanDeactivateFn, CanMatchFn, DeprecatedGuard, NavigationBehaviorOptions, ResolveFn, Route, Router, RouterFeatures, Routes, UrlCreationOptions } from "@angular/router";
|
|
5
|
+
import { H3Event, H3EventContext } from "h3";
|
|
6
|
+
import { $Fetch } from "nitropack";
|
|
7
|
+
import { Observable } from "rxjs";
|
|
8
|
+
import { HttpHandlerFn, HttpRequest } from "@angular/common/http";
|
|
9
|
+
import { StandardSchemaV1 as StandardSchemaV1$1 } from "@analogjs/router/server/actions";
|
|
13
10
|
type RouteOmitted = 'component' | 'loadComponent' | 'loadChildren' | 'path' | 'pathMatch';
|
|
14
11
|
type RestrictedRoute = Omit<Route, RouteOmitted>;
|
|
15
12
|
/**
|
|
@@ -40,75 +37,81 @@ type RestrictedRoute = Omit<Route, RouteOmitted>;
|
|
|
40
37
|
* @param route
|
|
41
38
|
* @returns
|
|
42
39
|
*/
|
|
43
|
-
declare const defineRouteMeta: (route: RestrictedRoute) => RestrictedRoute;
|
|
40
|
+
export declare const defineRouteMeta: (route: RestrictedRoute) => RestrictedRoute;
|
|
44
41
|
/**
|
|
45
42
|
* Returns the instance of Angular Router
|
|
46
43
|
*
|
|
47
44
|
* @returns The router
|
|
48
45
|
*/
|
|
49
|
-
declare const injectRouter: () => Router;
|
|
46
|
+
export declare const injectRouter: () => Router;
|
|
50
47
|
/**
|
|
51
48
|
* Returns the instance of the Activate Route for the component
|
|
52
49
|
*
|
|
53
50
|
* @returns The activated route
|
|
54
51
|
*/
|
|
55
|
-
declare const injectActivatedRoute: () => ActivatedRoute;
|
|
56
|
-
|
|
52
|
+
export declare const injectActivatedRoute: () => ActivatedRoute;
|
|
53
|
+
declare const ROUTE_META_TAGS_KEY: unique symbol;
|
|
57
54
|
declare const CHARSET_KEY = "charset";
|
|
58
55
|
declare const HTTP_EQUIV_KEY = "httpEquiv";
|
|
59
56
|
declare const NAME_KEY = "name";
|
|
60
57
|
declare const PROPERTY_KEY = "property";
|
|
61
58
|
declare const CONTENT_KEY = "content";
|
|
62
59
|
declare const ITEMPROP_KEY = "itemprop";
|
|
63
|
-
type MetaTag = (CharsetMetaTag & ExcludeRestMetaTagKeys<typeof CHARSET_KEY>) | (HttpEquivMetaTag & ExcludeRestMetaTagKeys<typeof HTTP_EQUIV_KEY>) | (NameMetaTag & ExcludeRestMetaTagKeys<typeof NAME_KEY>) | (PropertyMetaTag & ExcludeRestMetaTagKeys<typeof PROPERTY_KEY>) | (ItempropMetaTag & ExcludeRestMetaTagKeys<typeof ITEMPROP_KEY>);
|
|
60
|
+
export type MetaTag = (CharsetMetaTag & ExcludeRestMetaTagKeys<typeof CHARSET_KEY>) | (HttpEquivMetaTag & ExcludeRestMetaTagKeys<typeof HTTP_EQUIV_KEY>) | (NameMetaTag & ExcludeRestMetaTagKeys<typeof NAME_KEY>) | (PropertyMetaTag & ExcludeRestMetaTagKeys<typeof PROPERTY_KEY>) | (ItempropMetaTag & ExcludeRestMetaTagKeys<typeof ITEMPROP_KEY>);
|
|
64
61
|
type CharsetMetaTag = {
|
|
65
|
-
|
|
62
|
+
[CHARSET_KEY]: string;
|
|
66
63
|
};
|
|
67
64
|
type HttpEquivMetaTag = {
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
[HTTP_EQUIV_KEY]: string;
|
|
66
|
+
[CONTENT_KEY]: string;
|
|
70
67
|
};
|
|
71
68
|
type NameMetaTag = {
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
[NAME_KEY]: string;
|
|
70
|
+
[CONTENT_KEY]: string;
|
|
74
71
|
};
|
|
75
72
|
type PropertyMetaTag = {
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
[PROPERTY_KEY]: string;
|
|
74
|
+
[CONTENT_KEY]: string;
|
|
78
75
|
};
|
|
79
76
|
type ItempropMetaTag = {
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
[ITEMPROP_KEY]: string;
|
|
78
|
+
[CONTENT_KEY]: string;
|
|
82
79
|
};
|
|
83
80
|
type MetaTagKey = typeof CHARSET_KEY | typeof HTTP_EQUIV_KEY | typeof NAME_KEY | typeof PROPERTY_KEY | typeof ITEMPROP_KEY;
|
|
84
|
-
type ExcludeRestMetaTagKeys<Key extends MetaTagKey> = {
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
|
|
81
|
+
type ExcludeRestMetaTagKeys<Key extends MetaTagKey> = { [K in Exclude<MetaTagKey, Key>]?: never; };
|
|
82
|
+
declare function updateMetaTagsOnRouteChange(): void;
|
|
88
83
|
type OmittedRouteProps = 'path' | 'matcher' | 'component' | 'loadComponent' | 'children' | 'loadChildren' | 'canLoad' | 'outlet';
|
|
84
|
+
type RouteConfig = Omit<Route, OmittedRouteProps>;
|
|
89
85
|
interface DefaultRouteMeta extends Omit<Route, OmittedRouteProps | keyof RedirectRouteMeta> {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
86
|
+
canActivate?: CanActivateFn[] | DeprecatedGuard[];
|
|
87
|
+
canActivateChild?: CanActivateChildFn[];
|
|
88
|
+
canDeactivate?: CanDeactivateFn<unknown>[];
|
|
89
|
+
canMatch?: CanMatchFn[];
|
|
90
|
+
resolve?: {
|
|
91
|
+
[key: string | symbol]: ResolveFn<unknown>;
|
|
92
|
+
};
|
|
93
|
+
title?: string | ResolveFn<string>;
|
|
94
|
+
meta?: MetaTag[] | ResolveFn<MetaTag[]>;
|
|
99
95
|
}
|
|
100
96
|
interface RedirectRouteMeta {
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
redirectTo: string;
|
|
98
|
+
pathMatch?: Route['pathMatch'];
|
|
103
99
|
}
|
|
104
|
-
type RouteMeta = (DefaultRouteMeta & {
|
|
105
|
-
|
|
100
|
+
export type RouteMeta = (DefaultRouteMeta & {
|
|
101
|
+
redirectTo?: never;
|
|
106
102
|
}) | RedirectRouteMeta;
|
|
107
103
|
type RouteExport = {
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
default: Type<unknown>;
|
|
105
|
+
routeMeta?: RouteMeta | ReturnType<typeof defineRouteMeta>;
|
|
110
106
|
};
|
|
111
|
-
|
|
107
|
+
/**
|
|
108
|
+
* This variable reference is replaced with a glob of all page routes.
|
|
109
|
+
*/
|
|
110
|
+
declare let ANALOG_ROUTE_FILES: {};
|
|
111
|
+
/**
|
|
112
|
+
* This variable reference is replaced with a glob of all content routes.
|
|
113
|
+
*/
|
|
114
|
+
declare let ANALOG_CONTENT_ROUTE_FILES: {};
|
|
112
115
|
type Files = Record<string, () => Promise<RouteExport | string>>;
|
|
113
116
|
/**
|
|
114
117
|
* A function used to parse list of files and create configuration of routes.
|
|
@@ -116,9 +119,8 @@ type Files = Record<string, () => Promise<RouteExport | string>>;
|
|
|
116
119
|
* @param files
|
|
117
120
|
* @returns Array of routes
|
|
118
121
|
*/
|
|
119
|
-
declare function createRoutes(files: Files, debug?: boolean): Route[];
|
|
120
|
-
declare const routes: Route[];
|
|
121
|
-
|
|
122
|
+
export declare function createRoutes(files: Files, debug?: boolean): Route[];
|
|
123
|
+
export declare const routes: Route[];
|
|
122
124
|
/**
|
|
123
125
|
* Sets up providers for the Angular router, and registers
|
|
124
126
|
* file-based routes. Additional features can be provided
|
|
@@ -127,36 +129,252 @@ declare const routes: Route[];
|
|
|
127
129
|
* @param features
|
|
128
130
|
* @returns Providers and features to configure the router with routes
|
|
129
131
|
*/
|
|
130
|
-
declare function provideFileRouter(...features: RouterFeatures[]): EnvironmentProviders;
|
|
132
|
+
export declare function provideFileRouter(...features: RouterFeatures[]): EnvironmentProviders;
|
|
131
133
|
/**
|
|
132
134
|
* Provides extra custom routes in addition to the routes
|
|
133
135
|
* discovered from the filesystem-based routing. These routes are
|
|
134
136
|
* inserted before the filesystem-based routes, and take priority in
|
|
135
137
|
* route matching.
|
|
136
138
|
*/
|
|
137
|
-
declare function withExtraRoutes(routes: Routes): RouterFeatures;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
event: H3Event;
|
|
139
|
+
export declare function withExtraRoutes(routes: Routes): RouterFeatures;
|
|
140
|
+
export type PageServerLoad = {
|
|
141
|
+
params: H3EventContext['params'];
|
|
142
|
+
req: H3Event['node']['req'];
|
|
143
|
+
res: H3Event['node']['res'];
|
|
144
|
+
fetch: $Fetch;
|
|
145
|
+
event: H3Event;
|
|
145
146
|
};
|
|
146
|
-
type LoadResult<A extends (pageServerLoad: PageServerLoad) => Promise<any>> = Awaited<ReturnType<A>>;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
export type LoadResult<A extends (pageServerLoad: PageServerLoad) => Promise<any>> = Awaited<ReturnType<A>>;
|
|
148
|
+
/**
|
|
149
|
+
* Typed route path utilities for Analog.
|
|
150
|
+
*
|
|
151
|
+
* This module provides:
|
|
152
|
+
* - The `AnalogRouteTable` base interface (augmented by generated code)
|
|
153
|
+
* - The `AnalogRoutePath` union type
|
|
154
|
+
* - The `toRoute()` URL builder function
|
|
155
|
+
*
|
|
156
|
+
* Link construction does not require an injection context.
|
|
157
|
+
*/
|
|
158
|
+
/**
|
|
159
|
+
* Base interface for the typed route table.
|
|
160
|
+
*
|
|
161
|
+
* This interface is augmented by generated code in `src/routeTree.gen.d.ts`.
|
|
162
|
+
* Without the generated declaration, typed helpers reject route paths.
|
|
163
|
+
*/
|
|
164
|
+
interface AnalogRouteTable {}
|
|
165
|
+
/**
|
|
166
|
+
* Union of all valid route paths.
|
|
167
|
+
*
|
|
168
|
+
* When routes are generated, this is a string literal union.
|
|
169
|
+
* Without the generated declaration, this is `never`.
|
|
170
|
+
*/
|
|
171
|
+
type AnalogRoutePath = Extract<keyof AnalogRouteTable, string>;
|
|
172
|
+
type QueryValue = string | number | boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Query values accepted when building URLs. Angular converts them to strings
|
|
175
|
+
* and drops `null` and `undefined`, or removes those keys when merging.
|
|
176
|
+
*/
|
|
177
|
+
type RouteQueryInput = Record<string, QueryValue | QueryValue[] | null | undefined>;
|
|
178
|
+
/**
|
|
179
|
+
* Options for building a route URL.
|
|
180
|
+
*/
|
|
181
|
+
interface RoutePathOptionsBase {
|
|
182
|
+
params?: Record<string, string | number | (string | number)[] | undefined>;
|
|
183
|
+
query?: RouteQueryInput;
|
|
184
|
+
hash?: string;
|
|
185
|
+
}
|
|
186
|
+
/** Raw parameter types from the generated route table. */
|
|
187
|
+
type RouteParamsOutput<P extends string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
188
|
+
params: infer Params;
|
|
189
|
+
} ? Params : Record<string, unknown> : Record<string, unknown>;
|
|
190
|
+
/**
|
|
191
|
+
* Extracts the raw output type for route query params.
|
|
192
|
+
*/
|
|
193
|
+
type RouteQueryOutput<P extends string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
194
|
+
query: infer O;
|
|
195
|
+
} ? O : Record<string, string | string[] | undefined> : Record<string, string | string[] | undefined>;
|
|
196
|
+
type RequiredRouteParamKeys<Params> = Params extends Record<string, never> ? never : { [K in keyof Params]-?: Record<string, never> extends Pick<Params, K> ? never : K; }[keyof Params];
|
|
197
|
+
type HasRequiredRouteParams<Params> = [RequiredRouteParamKeys<Params>] extends [never] ? false : true;
|
|
198
|
+
type RouteParamsInput<Params> = { [K in keyof Params]: Exclude<Params[K], undefined> extends string[] ? undefined extends Params[K] ? (string | number)[] : [string | number, ...(string | number)[]] : Exclude<Params[K], undefined> extends string ? string | number : Params[K]; };
|
|
199
|
+
/**
|
|
200
|
+
* Typed options that infer params from the route table when available.
|
|
201
|
+
*/
|
|
202
|
+
type RoutePathOptions<P extends string = string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
203
|
+
params: infer Params;
|
|
204
|
+
} ? Params extends Record<string, never> ? {
|
|
205
|
+
params?: never;
|
|
206
|
+
query?: RouteQueryInput;
|
|
207
|
+
hash?: string;
|
|
208
|
+
} : HasRequiredRouteParams<Params> extends true ? {
|
|
209
|
+
params: RouteParamsInput<Params>;
|
|
210
|
+
query?: RouteQueryInput;
|
|
211
|
+
hash?: string;
|
|
212
|
+
} : {
|
|
213
|
+
params?: RouteParamsInput<Params>;
|
|
214
|
+
query?: RouteQueryInput;
|
|
215
|
+
hash?: string;
|
|
216
|
+
} : RoutePathOptionsBase : RoutePathOptionsBase;
|
|
217
|
+
/**
|
|
218
|
+
* Conditional args: require options when the route has params.
|
|
219
|
+
*/
|
|
220
|
+
type RoutePathArgs<P extends string = string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
221
|
+
params: infer Params;
|
|
222
|
+
} ? Params extends Record<string, never> ? [options?: RoutePathOptions<P>] : HasRequiredRouteParams<Params> extends true ? [options: RoutePathOptions<P>] : [options?: RoutePathOptions<P>] : [options?: RoutePathOptionsBase] : [options?: RoutePathOptionsBase];
|
|
223
|
+
type EmptyObject = Record<never, never>;
|
|
224
|
+
type Simplify<T> = { [K in keyof T]: T[K]; };
|
|
225
|
+
type Merge<A, B> = Omit<A, keyof B> & B;
|
|
226
|
+
type MetaObject<T> = unknown extends T ? EmptyObject : string extends keyof NonNullable<T> ? Record<string, unknown> : NonNullable<T>;
|
|
227
|
+
type StaticRouteData<Meta> = Meta extends {
|
|
228
|
+
data?: infer Data;
|
|
229
|
+
} ? MetaObject<Data> : EmptyObject;
|
|
230
|
+
type RouteResolvers<Meta> = Meta extends {
|
|
231
|
+
resolve?: infer Resolvers;
|
|
232
|
+
} ? MetaObject<Resolvers> : EmptyObject;
|
|
233
|
+
type ResolvedRouteData<Meta> = { [K in keyof RouteResolvers<Meta>]: RouteResolvers<Meta>[K] extends ResolveFn<infer T> ? T : unknown; };
|
|
234
|
+
type RouteMetaData<Meta> = Merge<StaticRouteData<Meta>, ResolvedRouteData<Meta>>;
|
|
235
|
+
type InheritedRouteData<Metas, Data = EmptyObject> = Metas extends [infer Meta, ...infer Rest] ? InheritedRouteData<Rest, Merge<Data, RouteMetaData<Exclude<Meta, {
|
|
236
|
+
redirectTo: string;
|
|
237
|
+
}>>>> : Data;
|
|
238
|
+
type RouteResourceMap<Meta> = Meta extends {
|
|
239
|
+
resources?: (ctx: never) => infer R;
|
|
240
|
+
} ? Awaited<R> extends Record<PropertyKey, unknown> ? Awaited<R> : EmptyObject : EmptyObject;
|
|
241
|
+
type PageRouteMetas<P extends keyof AnalogRouteTable> = [...(AnalogRouteTable[P] extends {
|
|
242
|
+
layoutRouteMeta: infer Metas extends unknown[];
|
|
243
|
+
} ? Metas : []), ...(AnalogRouteTable[P] extends {
|
|
244
|
+
routeMeta: infer Meta;
|
|
245
|
+
} ? [Meta] : [])];
|
|
246
|
+
type PageLoadData<P extends keyof AnalogRouteTable> = AnalogRouteTable[P] extends {
|
|
247
|
+
load: unknown;
|
|
248
|
+
} ? {
|
|
249
|
+
load: RouteLoadOutput<P>;
|
|
250
|
+
} : EmptyObject;
|
|
251
|
+
/** Route paths whose page has a server `load` function. */
|
|
252
|
+
type AnalogRouteWithLoad = { [P in AnalogRoutePath]: AnalogRouteTable[P] extends {
|
|
253
|
+
load: unknown;
|
|
254
|
+
} ? P : never; }[AnalogRoutePath];
|
|
255
|
+
/** Resolved result of a page's server `load` function. */
|
|
256
|
+
type RouteLoadOutput<P extends string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
257
|
+
load: (...args: never[]) => infer R;
|
|
258
|
+
} ? Awaited<R> : never : never;
|
|
259
|
+
/**
|
|
260
|
+
* Data for a page route: static `routeMeta.data` and `routeMeta.resolve`
|
|
261
|
+
* results from its layouts and the page, and the page's server `load` result.
|
|
262
|
+
*/
|
|
263
|
+
type RouteDataOutput<P extends string> = P extends keyof AnalogRouteTable ? Simplify<Omit<InheritedRouteData<PageRouteMetas<P>>, 'load'> & PageLoadData<P>> : Record<string, unknown>;
|
|
264
|
+
/**
|
|
265
|
+
* Resources for a page route: `routeMeta.resources` results defined on the page.
|
|
266
|
+
*/
|
|
267
|
+
type RouteResourcesOutput<P extends string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
268
|
+
routeMeta: infer Meta;
|
|
269
|
+
} ? Simplify<RouteResourceMap<Exclude<Meta, {
|
|
270
|
+
redirectTo: string;
|
|
271
|
+
}>>> : EmptyObject : ActivatedRoute extends {
|
|
272
|
+
resources: infer Resources;
|
|
273
|
+
} ? Resources : EmptyObject;
|
|
274
|
+
type SplitPath<S extends string> = S extends '' ? [] : S extends `${infer Head}/${infer Tail}` ? [Head, ...SplitPath<Tail>] : [S];
|
|
275
|
+
type Segments<P extends string> = P extends `/${infer Rest}` ? SplitPath<Rest> : SplitPath<P>;
|
|
276
|
+
type JoinPath<S extends string[]> = S extends [infer Head extends string, ...infer Tail extends string[]] ? Tail extends [] ? Head : `${Head}/${JoinPath<Tail>}` : '';
|
|
277
|
+
type Pop<S extends string[]> = S extends [...infer Init extends string[], string] ? Init : [];
|
|
278
|
+
type ParentPath<P extends string> = `/${JoinPath<Pop<Segments<P>>>}`;
|
|
279
|
+
type LastSegment<P extends string> = Segments<P> extends [...string[], infer Last extends string] ? Last : never;
|
|
280
|
+
type ResolveSegments<Base extends string[], Parts extends string[]> = Parts extends [infer Head extends string, ...infer Tail extends string[]] ? ResolveSegments<Head extends '.' ? Base : Head extends '..' ? Pop<Base> : [...Base, Head], Tail> : Base;
|
|
281
|
+
/** Resolves a relative target against the `From` route path. */
|
|
282
|
+
type ResolveRoutePath<From extends string, To extends string> = To extends `/${string}` ? To : `/${JoinPath<ResolveSegments<Segments<From>, SplitPath<To>>>}`;
|
|
283
|
+
type PathPrefix<Base extends string> = Base extends '/' ? '/' : `${Base}/`;
|
|
284
|
+
/** Route paths nested below `Base`, relative to it. */
|
|
285
|
+
type ChildPaths<Base extends string, P extends string = AnalogRoutePath> = P extends `${PathPrefix<Base>}${infer Rest}` ? Rest extends '' ? never : Rest : never;
|
|
286
|
+
type AncestorTargets<From extends string, Up extends string> = From extends '/' ? never : (ParentPath<From> extends AnalogRoutePath ? Up : never) | `${Up}/${Exclude<ChildPaths<ParentPath<From>>, LastSegment<From> | `${LastSegment<From>}/${string}`>}` | AncestorTargets<ParentPath<From>, `${Up}/..`>;
|
|
287
|
+
/** Relative targets from `From`: `.`, `./child`, `..`, and `../sibling`. */
|
|
288
|
+
type RelativeRouteTarget<From extends string> = '.' | `./${ChildPaths<From>}` | AncestorTargets<From, '..'>;
|
|
289
|
+
/** Absolute route paths plus targets relative to `From`. */
|
|
290
|
+
type ScopedRouteTarget<From extends string> = AnalogRoutePath | RelativeRouteTarget<From>;
|
|
291
|
+
type SegmentParam<S extends string> = S extends `[[...${infer Name}]]` ? Name : S extends `[...${infer Name}]` ? Name : S extends `[${infer Name}]` ? Name : never;
|
|
292
|
+
type SharedParams<A extends string[], B extends string[]> = A extends [infer Head extends string, ...infer ATail extends string[]] ? B extends [Head, ...infer BTail extends string[]] ? SegmentParam<Head> | SharedParams<ATail, BTail> : never : never;
|
|
293
|
+
type WithOptional<T, K extends PropertyKey> = Simplify<Omit<T, K> & Partial<Pick<T, Extract<keyof T, K>>>>;
|
|
294
|
+
type ScopedParamsInput<From extends string, To extends string> = WithOptional<RouteParamsInput<RouteParamsOutput<To>>, SharedParams<Segments<From>, Segments<To>>>;
|
|
295
|
+
/** Options for a route path; params shared with `From` default to current values. */
|
|
296
|
+
type ScopedRoutePathOptions<From extends string, To extends string> = RouteParamsOutput<To> extends Record<string, never> ? {
|
|
297
|
+
params?: never;
|
|
298
|
+
query?: RouteQueryInput;
|
|
299
|
+
hash?: string;
|
|
300
|
+
} : HasRequiredRouteParams<ScopedParamsInput<From, To>> extends true ? {
|
|
301
|
+
params: ScopedParamsInput<From, To>;
|
|
302
|
+
query?: RouteQueryInput;
|
|
303
|
+
hash?: string;
|
|
304
|
+
} : {
|
|
305
|
+
params?: ScopedParamsInput<From, To>;
|
|
306
|
+
query?: RouteQueryInput;
|
|
307
|
+
hash?: string;
|
|
308
|
+
};
|
|
309
|
+
/** Conditional args for a target resolved against `From`. */
|
|
310
|
+
type ScopedRoutePathArgs<From extends string, Target extends string> = ScopedRoutePathOptions<From, ResolveRoutePath<From, Target>> extends (infer O) ? EmptyObject extends O ? [options?: O] : [options: O] : never;
|
|
311
|
+
/**
|
|
312
|
+
* Result of `toRoute()` — contains properties that map directly
|
|
313
|
+
* to Angular's `[routerLink]`, `[queryParams]`, and `[fragment]` inputs.
|
|
314
|
+
*/
|
|
315
|
+
interface RouteLinkResult {
|
|
316
|
+
path: string[];
|
|
317
|
+
queryParams: RouteQueryInput | null;
|
|
318
|
+
fragment: string | undefined;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Builds a typed route link object from a route path pattern and options.
|
|
322
|
+
*
|
|
323
|
+
* The returned object separates path, query params, and fragment for
|
|
324
|
+
* direct use with Angular's routerLink directive inputs.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* toRoute('/about')
|
|
328
|
+
* // → { path: ['/', 'about'], queryParams: null, fragment: undefined }
|
|
329
|
+
*
|
|
330
|
+
* toRoute('/users/[id]', { params: { id: '42' } })
|
|
331
|
+
* // → { path: ['/', 'users', '42'], queryParams: null, fragment: undefined }
|
|
332
|
+
*
|
|
333
|
+
* toRoute('/users/[id]', { params: { id: '42' }, query: { tab: 'settings' }, hash: 'bio' })
|
|
334
|
+
* // → { path: ['/', 'users', '42'], queryParams: { tab: 'settings' }, fragment: 'bio' }
|
|
335
|
+
*
|
|
336
|
+
* @example Template usage
|
|
337
|
+
* Compute the link in the component:
|
|
338
|
+
* ```ts
|
|
339
|
+
* readonly link = toRoute('/users/[id]', { params: { id: '42' } });
|
|
340
|
+
* ```
|
|
341
|
+
*
|
|
342
|
+
* ```html
|
|
343
|
+
* <a [routerLink]="link.path" [queryParams]="link.queryParams" [fragment]="link.fragment">
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
export declare function toRoute<P extends AnalogRoutePath>(path: P, ...args: RoutePathArgs<P>): RouteLinkResult;
|
|
347
|
+
/**
|
|
348
|
+
* Internal: builds a `RouteLinkResult` from path and options.
|
|
349
|
+
* Exported for direct use in tests (avoids generic constraints).
|
|
350
|
+
*/
|
|
351
|
+
declare function buildRouteLink(path: string, options?: RoutePathOptionsBase): RouteLinkResult;
|
|
352
|
+
/** Internal URL serialization for programmatic navigation. */
|
|
353
|
+
declare function buildUrl(path: string, options?: RoutePathOptionsBase): string;
|
|
354
|
+
/** Internal: resolves `.` and `..` segments in `to` against the `from` route path. */
|
|
355
|
+
declare function resolveRoutePath(from: string, to: string): string;
|
|
356
|
+
/**
|
|
357
|
+
* Internal: resolves `target` against the `from` route path. Params in the
|
|
358
|
+
* leading segments shared with `from` default to the `current` values.
|
|
359
|
+
*/
|
|
360
|
+
declare function resolveScopedRoute(from: string, target: string, current: Record<string, unknown>, options?: RoutePathOptionsBase): {
|
|
361
|
+
path: string;
|
|
362
|
+
options: RoutePathOptionsBase;
|
|
363
|
+
};
|
|
364
|
+
/** Reads the result of the page's server `load` function, typed by route path. */
|
|
365
|
+
export declare function injectLoad<P extends AnalogRouteWithLoad>(path: P, options?: {
|
|
366
|
+
injector?: Injector;
|
|
367
|
+
}): Observable<RouteLoadOutput<P>>;
|
|
368
|
+
export declare function injectLoad<T extends (pageServerLoad: PageServerLoad) => Promise<any>>(options?: {
|
|
369
|
+
injector?: Injector;
|
|
150
370
|
}): Observable<Awaited<ReturnType<T>>>;
|
|
151
|
-
|
|
152
371
|
/**
|
|
153
372
|
* Get server load resolver data for the route
|
|
154
373
|
*
|
|
155
374
|
* @param route Provides the route to get server load resolver
|
|
156
375
|
* @returns Returns server load resolver data for the route
|
|
157
376
|
*/
|
|
158
|
-
declare function getLoadResolver<T>(route: ActivatedRouteSnapshot): Promise<T>;
|
|
159
|
-
|
|
377
|
+
export declare function getLoadResolver<T>(route: ActivatedRouteSnapshot): Promise<T>;
|
|
160
378
|
/**
|
|
161
379
|
* Interceptor that is server-aware when making HttpClient requests.
|
|
162
380
|
* Server-side requests use the full URL
|
|
@@ -167,145 +385,149 @@ declare function getLoadResolver<T>(route: ActivatedRouteSnapshot): Promise<T>;
|
|
|
167
385
|
* @param next HttpHandlerFn
|
|
168
386
|
* @returns
|
|
169
387
|
*/
|
|
170
|
-
declare function requestContextInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): rxjs.Observable<
|
|
171
|
-
|
|
172
|
-
declare function injectRouteEndpointURL(route: ActivatedRouteSnapshot): URL;
|
|
173
|
-
|
|
388
|
+
export declare function requestContextInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): import("rxjs").Observable<import("@angular/common/http").HttpEvent<unknown>>;
|
|
389
|
+
export declare function injectRouteEndpointURL(route: ActivatedRouteSnapshot): URL;
|
|
174
390
|
type FormActionState = 'submitting' | 'error' | 'redirect' | 'success' | 'navigate';
|
|
175
|
-
declare class FormAction {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
391
|
+
export declare class FormAction {
|
|
392
|
+
action: import("@angular/core").InputSignal<string>;
|
|
393
|
+
enhanceForm: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
394
|
+
onSuccess: import("@angular/core").OutputEmitterRef<unknown>;
|
|
395
|
+
onError: import("@angular/core").OutputEmitterRef<unknown>;
|
|
396
|
+
state: import("@angular/core").OutputEmitterRef<FormActionState>;
|
|
397
|
+
private currentState;
|
|
398
|
+
private injector;
|
|
399
|
+
private router;
|
|
400
|
+
private route;
|
|
401
|
+
private path;
|
|
402
|
+
constructor();
|
|
403
|
+
submitted($event: any): void;
|
|
404
|
+
private _handleGet;
|
|
405
|
+
private _handlePost;
|
|
406
|
+
private _getPath;
|
|
407
|
+
private _handleEnhancedGet;
|
|
408
|
+
private _handleEnhancedPost;
|
|
409
|
+
private _emitState;
|
|
410
|
+
private _navigateTo;
|
|
411
|
+
private _isJSON;
|
|
412
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FormAction, never>;
|
|
413
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<FormAction, "form[action],form[method],form[enhanceForm]", never, {
|
|
414
|
+
"action": {
|
|
415
|
+
"alias": "action";
|
|
416
|
+
"required": false;
|
|
417
|
+
"isSignal": true;
|
|
418
|
+
};
|
|
419
|
+
"enhanceForm": {
|
|
420
|
+
"alias": "enhanceForm";
|
|
421
|
+
"required": false;
|
|
422
|
+
"isSignal": true;
|
|
423
|
+
};
|
|
424
|
+
}, {
|
|
425
|
+
"onSuccess": "onSuccess";
|
|
426
|
+
"onError": "onError";
|
|
427
|
+
"state": "state";
|
|
428
|
+
}, never, never, true, never>;
|
|
198
429
|
}
|
|
199
|
-
|
|
200
430
|
type ValidationFieldErrors = Record<string, string[]>;
|
|
201
|
-
declare function issuePathToFieldName(path: ReadonlyArray<string | number | symbol | {
|
|
202
|
-
|
|
431
|
+
export declare function issuePathToFieldName(path: ReadonlyArray<string | number | symbol | {
|
|
432
|
+
key: string | number | symbol;
|
|
203
433
|
}>): string;
|
|
204
|
-
declare function issuesToFieldErrors(issues: ReadonlyArray<StandardSchemaV1$1.Issue>): ValidationFieldErrors;
|
|
205
|
-
declare function issuesToFormErrors(issues: ReadonlyArray<StandardSchemaV1$1.Issue>): string[];
|
|
206
|
-
|
|
434
|
+
export declare function issuesToFieldErrors(issues: ReadonlyArray<StandardSchemaV1$1.Issue>): ValidationFieldErrors;
|
|
435
|
+
export declare function issuesToFormErrors(issues: ReadonlyArray<StandardSchemaV1$1.Issue>): string[];
|
|
436
|
+
declare const DEBUG_ROUTES: InjectionToken<(Route & DebugRoute)[]>;
|
|
207
437
|
type DebugRoute = {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
438
|
+
path: string;
|
|
439
|
+
filename: string;
|
|
440
|
+
isLayout: boolean;
|
|
441
|
+
children?: DebugRoute[];
|
|
212
442
|
};
|
|
213
|
-
declare function injectDebugRoutes(): (Route & DebugRoute)[];
|
|
214
|
-
|
|
443
|
+
export declare function injectDebugRoutes(): (Route & DebugRoute)[];
|
|
444
|
+
declare namespace debug_page_d_exports {
|
|
445
|
+
export { DebugRoutesComponent as default };
|
|
446
|
+
}
|
|
215
447
|
type CollectedRoute = {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
448
|
+
path: string;
|
|
449
|
+
filename: string;
|
|
450
|
+
file: string;
|
|
451
|
+
isLayout: boolean;
|
|
220
452
|
};
|
|
221
453
|
declare class DebugRoutesComponent {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
454
|
+
collectedRoutes: CollectedRoute[];
|
|
455
|
+
debugRoutes: (import("@angular/router").Route & DebugRoute)[];
|
|
456
|
+
ngOnInit(): void;
|
|
457
|
+
traverseRoutes(routes: DebugRoute[], parent?: string): void;
|
|
458
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DebugRoutesComponent, never>;
|
|
459
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DebugRoutesComponent, "analogjs-debug-routes-page", never, {}, {}, never, never, true, never>;
|
|
228
460
|
}
|
|
229
|
-
|
|
230
|
-
declare namespace __debug_page {
|
|
231
|
-
export {
|
|
232
|
-
DebugRoutesComponent as default,
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
461
|
/**
|
|
237
462
|
* Provides routes that provide additional
|
|
238
463
|
* pages for displaying and debugging
|
|
239
464
|
* routes.
|
|
240
465
|
*/
|
|
241
|
-
declare function withDebugRoutes(): {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}[];
|
|
249
|
-
multi: boolean;
|
|
466
|
+
export declare function withDebugRoutes(): {
|
|
467
|
+
ɵkind: number;
|
|
468
|
+
ɵproviders: {
|
|
469
|
+
provide: import("@angular/core").InjectionToken<import("@angular/router").Route[][]>;
|
|
470
|
+
useValue: {
|
|
471
|
+
path: string;
|
|
472
|
+
loadComponent: () => Promise<typeof debug_page_d_exports>;
|
|
250
473
|
}[];
|
|
474
|
+
multi: boolean;
|
|
475
|
+
}[];
|
|
251
476
|
};
|
|
252
|
-
|
|
253
477
|
/** Minimal Standard Schema shape (valibot/zod/arktype conform). */
|
|
254
478
|
interface StandardSchemaV1<In = unknown> {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
479
|
+
readonly '~standard': {
|
|
480
|
+
readonly version: 1;
|
|
481
|
+
readonly vendor: string;
|
|
482
|
+
validate: (value: unknown) => {
|
|
483
|
+
value: In;
|
|
484
|
+
issues?: undefined;
|
|
485
|
+
} | {
|
|
486
|
+
issues: ReadonlyArray<{
|
|
487
|
+
message: string;
|
|
488
|
+
}>;
|
|
489
|
+
} | Promise<{
|
|
490
|
+
value: In;
|
|
491
|
+
issues?: undefined;
|
|
492
|
+
} | {
|
|
493
|
+
issues: ReadonlyArray<{
|
|
494
|
+
message: string;
|
|
495
|
+
}>;
|
|
496
|
+
}>;
|
|
497
|
+
};
|
|
274
498
|
}
|
|
275
499
|
type ServerFnMethod = 'GET' | 'POST';
|
|
276
500
|
interface ServerFnConfig<In> {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
501
|
+
/**
|
|
502
|
+
* Opaque route id `/_analog/fn/<id>`. **Build-injected, not author-supplied:**
|
|
503
|
+
* the Analog transform derives `hash(fileId + exportName)` and stamps it into
|
|
504
|
+
* both the server registration and the client proxy, so authors never choose a
|
|
505
|
+
* route. Absent at runtime means the transform did not run — `serverFn` throws.
|
|
506
|
+
*/
|
|
507
|
+
id?: string;
|
|
508
|
+
/** Defaults to 'POST' when `input` is present, otherwise 'GET'. */
|
|
509
|
+
method?: ServerFnMethod;
|
|
510
|
+
input?: StandardSchemaV1<In>;
|
|
287
511
|
}
|
|
288
512
|
/**
|
|
289
513
|
* Interceptor-accumulated context, delivered to the handler as its second
|
|
290
514
|
* argument. Apps extend this by declaration merging.
|
|
291
515
|
*/
|
|
292
|
-
interface ServerFnContext {
|
|
293
|
-
}
|
|
516
|
+
interface ServerFnContext {}
|
|
294
517
|
/** A server function reference: callable type on both sides; real impl only on the server. */
|
|
295
518
|
type ServerFn<In, Out> = ((input: In) => Promise<Out>) & {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
519
|
+
readonly __serverFn: true;
|
|
520
|
+
readonly id: string;
|
|
521
|
+
readonly url: string;
|
|
522
|
+
readonly method: ServerFnMethod;
|
|
300
523
|
};
|
|
301
524
|
type ServerFnHandler<In, Out> = (input: In, context: ServerFnContext) => Promise<Out> | Out;
|
|
302
525
|
interface ServerFnDef {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
526
|
+
id: string;
|
|
527
|
+
method: ServerFnMethod;
|
|
528
|
+
config: ServerFnConfig<unknown>;
|
|
529
|
+
handler: ServerFnHandler<unknown, unknown>;
|
|
307
530
|
}
|
|
308
|
-
|
|
309
531
|
/**
|
|
310
532
|
* Client transport for server functions. In the browser it goes through Angular
|
|
311
533
|
* `HttpClient`, so client `HttpInterceptorFn`s apply. During SSR the dispatcher
|
|
@@ -313,23 +535,23 @@ interface ServerFnDef {
|
|
|
313
535
|
* handler runs in-process in the current request injector. Lives in the client
|
|
314
536
|
* entry (client-safe).
|
|
315
537
|
*/
|
|
316
|
-
declare class ServerFnClient {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
538
|
+
export declare class ServerFnClient {
|
|
539
|
+
private readonly http;
|
|
540
|
+
private readonly transferState;
|
|
541
|
+
private readonly injector;
|
|
542
|
+
private readonly dispatcher;
|
|
543
|
+
/** True while rendering on the server (the in-process dispatcher is provided). */
|
|
544
|
+
get isServer(): boolean;
|
|
545
|
+
call<In, Out>(fn: ServerFn<In, Out>, input: In): Promise<Out>;
|
|
546
|
+
/** Key a read's value for TransferState hydration (fn id + input). */
|
|
547
|
+
stateKey<Out>(fn: ServerFn<unknown, Out>, input: unknown): import("@angular/core").StateKey<Out>;
|
|
548
|
+
readSeed<Out>(fn: ServerFn<unknown, Out>, input: unknown): Out | undefined;
|
|
549
|
+
writeSeed<Out>(fn: ServerFn<unknown, Out>, input: unknown, value: Out): void;
|
|
550
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ServerFnClient, never>;
|
|
551
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
330
552
|
}
|
|
331
553
|
/** No-op provider hook; ServerFnClient is `providedIn: 'root'`. */
|
|
332
|
-
declare function provideServerFnClient(): readonly [];
|
|
554
|
+
export declare function provideServerFnClient(): readonly [];
|
|
333
555
|
/**
|
|
334
556
|
* Reactive read of a server function as an Angular `resource()`.
|
|
335
557
|
*
|
|
@@ -338,25 +560,24 @@ declare function provideServerFnClient(): readonly [];
|
|
|
338
560
|
* the resource idle until inputs are ready, the standard resource pattern). For
|
|
339
561
|
* imperative calls (mutations, event handlers) use `injectServerFnMutation`.
|
|
340
562
|
*/
|
|
341
|
-
declare function injectServerFn<Out>(fn: ServerFn<void, Out>): ResourceRef<Out | undefined>;
|
|
342
|
-
declare function injectServerFn<In, Out>(fn: ServerFn<In, Out>, args: () => In | undefined): ResourceRef<Out | undefined>;
|
|
563
|
+
export declare function injectServerFn<Out>(fn: ServerFn<void, Out>): ResourceRef<Out | undefined>;
|
|
564
|
+
export declare function injectServerFn<In, Out>(fn: ServerFn<In, Out>, args: () => In | undefined): ResourceRef<Out | undefined>;
|
|
343
565
|
/**
|
|
344
566
|
* Imperative binding of a server function: returns a callable that dispatches
|
|
345
567
|
* the call through `HttpClient` (so client interceptors apply) and resolves the
|
|
346
568
|
* result. Use for mutations and event-driven calls; use `injectServerFn` for
|
|
347
569
|
* reactive reads.
|
|
348
570
|
*/
|
|
349
|
-
declare function injectServerFnMutation<In, Out>(fn: ServerFn<In, Out>): (input: In) => Promise<Out>;
|
|
350
|
-
|
|
571
|
+
export declare function injectServerFnMutation<In, Out>(fn: ServerFn<In, Out>): (input: In) => Promise<Out>;
|
|
351
572
|
interface ServerFnRefConfig {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
573
|
+
id?: string;
|
|
574
|
+
method?: ServerFnMethod;
|
|
575
|
+
/**
|
|
576
|
+
* Only its presence matters here: when `method` is omitted, a config with an
|
|
577
|
+
* `input` schema defaults to `POST`, otherwise `GET`. The schema itself is
|
|
578
|
+
* never used to build the ref — validation happens server-side.
|
|
579
|
+
*/
|
|
580
|
+
input?: unknown;
|
|
360
581
|
}
|
|
361
582
|
/**
|
|
362
583
|
* Builds a server-function reference: the client-safe `{ __serverFn, id, url,
|
|
@@ -370,8 +591,7 @@ interface ServerFnRefConfig {
|
|
|
370
591
|
* The returned value is callable-typed but throws if invoked directly — it is
|
|
371
592
|
* always dispatched via `injectServerFn`/`ServerFnClient`, never called.
|
|
372
593
|
*/
|
|
373
|
-
declare function createServerFnRef<In, Out>(config: ServerFnRefConfig): ServerFn<In, Out>;
|
|
374
|
-
|
|
594
|
+
export declare function createServerFnRef<In, Out>(config: ServerFnRefConfig): ServerFn<In, Out>;
|
|
375
595
|
/**
|
|
376
596
|
* In-process transport for a server function call.
|
|
377
597
|
*
|
|
@@ -392,145 +612,66 @@ declare function createServerFnRef<In, Out>(config: ServerFnRefConfig): ServerFn
|
|
|
392
612
|
* be surprising and unportable.
|
|
393
613
|
*/
|
|
394
614
|
type ServerFnDispatcher = <In, Out>(fn: ServerFn<In, Out>, input: In, injector: Injector) => Promise<Out>;
|
|
395
|
-
declare const SERVER_FN_DISPATCHER: InjectionToken<ServerFnDispatcher>;
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}[keyof Params];
|
|
443
|
-
type HasRequiredRouteParams<Params> = [RequiredRouteParamKeys<Params>] extends [
|
|
444
|
-
never
|
|
445
|
-
] ? false : true;
|
|
446
|
-
type RouteParamsInput<Params> = {
|
|
447
|
-
[K in keyof Params]: Exclude<Params[K], undefined> extends string[] ? undefined extends Params[K] ? (string | number)[] : [string | number, ...(string | number)[]] : Exclude<Params[K], undefined> extends string ? string | number : Params[K];
|
|
448
|
-
};
|
|
449
|
-
/**
|
|
450
|
-
* Typed options that infer params from the route table when available.
|
|
451
|
-
*/
|
|
452
|
-
type RoutePathOptions<P extends string = string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
453
|
-
params: infer Params;
|
|
454
|
-
} ? Params extends Record<string, never> ? {
|
|
455
|
-
params?: never;
|
|
456
|
-
query?: RouteQueryOutput<P>;
|
|
457
|
-
hash?: string;
|
|
458
|
-
} : HasRequiredRouteParams<Params> extends true ? {
|
|
459
|
-
params: RouteParamsInput<Params>;
|
|
460
|
-
query?: RouteQueryOutput<P>;
|
|
461
|
-
hash?: string;
|
|
462
|
-
} : {
|
|
463
|
-
params?: RouteParamsInput<Params>;
|
|
464
|
-
query?: RouteQueryOutput<P>;
|
|
465
|
-
hash?: string;
|
|
466
|
-
} : RoutePathOptionsBase : RoutePathOptionsBase;
|
|
467
|
-
/**
|
|
468
|
-
* Conditional args: require options when the route has params.
|
|
469
|
-
*/
|
|
470
|
-
type RoutePathArgs<P extends string = string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
|
|
471
|
-
params: infer Params;
|
|
472
|
-
} ? Params extends Record<string, never> ? [options?: RoutePathOptions<P>] : HasRequiredRouteParams<Params> extends true ? [options: RoutePathOptions<P>] : [options?: RoutePathOptions<P>] : [options?: RoutePathOptionsBase] : [options?: RoutePathOptionsBase];
|
|
473
|
-
/**
|
|
474
|
-
* Result of `toRoute()` — contains properties that map directly
|
|
475
|
-
* to Angular's `[routerLink]`, `[queryParams]`, and `[fragment]` inputs.
|
|
476
|
-
*/
|
|
477
|
-
interface RouteLinkResult {
|
|
478
|
-
path: string[];
|
|
479
|
-
queryParams: Record<string, string | string[]> | null;
|
|
480
|
-
fragment: string | undefined;
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Builds a typed route link object from a route path pattern and options.
|
|
484
|
-
*
|
|
485
|
-
* The returned object separates path, query params, and fragment for
|
|
486
|
-
* direct use with Angular's routerLink directive inputs.
|
|
487
|
-
*
|
|
488
|
-
* @example
|
|
489
|
-
* toRoute('/about')
|
|
490
|
-
* // → { path: ['/', 'about'], queryParams: null, fragment: undefined }
|
|
491
|
-
*
|
|
492
|
-
* toRoute('/users/[id]', { params: { id: '42' } })
|
|
493
|
-
* // → { path: ['/', 'users', '42'], queryParams: null, fragment: undefined }
|
|
494
|
-
*
|
|
495
|
-
* toRoute('/users/[id]', { params: { id: '42' }, query: { tab: 'settings' }, hash: 'bio' })
|
|
496
|
-
* // → { path: ['/', 'users', '42'], queryParams: { tab: 'settings' }, fragment: 'bio' }
|
|
497
|
-
*
|
|
498
|
-
* @example Template usage
|
|
499
|
-
* Compute the link in the component:
|
|
500
|
-
* ```ts
|
|
501
|
-
* readonly link = toRoute('/users/[id]', { params: { id: '42' } });
|
|
502
|
-
* ```
|
|
503
|
-
*
|
|
504
|
-
* ```html
|
|
505
|
-
* <a [routerLink]="link.path" [queryParams]="link.queryParams" [fragment]="link.fragment">
|
|
506
|
-
* ```
|
|
507
|
-
*/
|
|
508
|
-
declare function toRoute<P extends AnalogRoutePath>(path: P, ...args: RoutePathArgs<P>): RouteLinkResult;
|
|
509
|
-
|
|
510
|
-
type LinkToDestination = {
|
|
511
|
-
[P in AnalogRoutePath]: {
|
|
512
|
-
path: P;
|
|
513
|
-
} & RoutePathOptions<P>;
|
|
514
|
-
}[AnalogRoutePath];
|
|
515
|
-
type StaticRoutePath = {
|
|
516
|
-
[P in AnalogRoutePath]: RouteParamsOutput<P> extends Record<string, never> ? P : never;
|
|
517
|
-
}[AnalogRoutePath];
|
|
518
|
-
declare class LinkTo implements OnChanges {
|
|
519
|
-
readonly linkTo: InputSignal<StaticRoutePath | LinkToDestination | null | undefined>;
|
|
520
|
-
private readonly routerLink;
|
|
521
|
-
ngOnChanges(): void;
|
|
522
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<LinkTo, never>;
|
|
523
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<LinkTo, "[linkTo]", never, { "linkTo": { "alias": "linkTo"; "required": true; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof _angular_router.RouterLink; inputs: { "target": "target"; "queryParamsHandling": "queryParamsHandling"; "preserveFragment": "preserveFragment"; "skipLocationChange": "skipLocationChange"; "replaceUrl": "replaceUrl"; "state": "state"; }; outputs: {}; }]>;
|
|
615
|
+
export declare const SERVER_FN_DISPATCHER: InjectionToken<ServerFnDispatcher>;
|
|
616
|
+
type LinkToDestination = { [P in AnalogRoutePath]: {
|
|
617
|
+
path: P;
|
|
618
|
+
} & RoutePathOptions<P>; }[AnalogRoutePath];
|
|
619
|
+
type StaticRoutePath = { [P in AnalogRoutePath]: RouteParamsOutput<P> extends Record<string, never> ? P : never; }[AnalogRoutePath];
|
|
620
|
+
type ScopedDestination<From extends AnalogRoutePath> = { [T in ScopedRouteTarget<From>]: {
|
|
621
|
+
path: T;
|
|
622
|
+
} & ScopedRoutePathOptions<From, ResolveRoutePath<From, T>>; }[ScopedRouteTarget<From>];
|
|
623
|
+
type ScopedStaticTarget<From extends AnalogRoutePath> = { [T in ScopedRouteTarget<From>]: [] extends ScopedRoutePathArgs<From, T> ? T : never; }[ScopedRouteTarget<From>];
|
|
624
|
+
/** Destinations accepted by `[linkTo]`, relative to `From` when provided. */
|
|
625
|
+
type LinkToInput<From = undefined> = (unknown extends From ? StaticRoutePath | LinkToDestination : From extends AnalogRoutePath ? ScopedStaticTarget<From> | ScopedDestination<From> : StaticRoutePath | LinkToDestination) | null | undefined;
|
|
626
|
+
export declare class LinkTo<From = undefined> implements OnChanges, OnDestroy {
|
|
627
|
+
readonly linkTo: InputSignal<LinkToInput<From>>;
|
|
628
|
+
/** The current route's path. Enables relative destinations and param inheritance. */
|
|
629
|
+
readonly from: InputSignal<(From & AnalogRoutePath) | undefined>;
|
|
630
|
+
private readonly routerLink;
|
|
631
|
+
private readonly route;
|
|
632
|
+
private currentParams;
|
|
633
|
+
private paramsFrom?;
|
|
634
|
+
private paramsSubscription?;
|
|
635
|
+
ngOnChanges(): void;
|
|
636
|
+
ngOnDestroy(): void;
|
|
637
|
+
private update;
|
|
638
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LinkTo<any>, never>;
|
|
639
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<LinkTo<any>, "[linkTo]", never, {
|
|
640
|
+
"linkTo": {
|
|
641
|
+
"alias": "linkTo";
|
|
642
|
+
"required": true;
|
|
643
|
+
"isSignal": true;
|
|
644
|
+
};
|
|
645
|
+
"from": {
|
|
646
|
+
"alias": "from";
|
|
647
|
+
"required": false;
|
|
648
|
+
"isSignal": true;
|
|
649
|
+
};
|
|
650
|
+
}, {}, never, never, true, [{
|
|
651
|
+
directive: typeof i1.RouterLink;
|
|
652
|
+
inputs: {
|
|
653
|
+
"target": "target";
|
|
654
|
+
"queryParamsHandling": "queryParamsHandling";
|
|
655
|
+
"preserveFragment": "preserveFragment";
|
|
656
|
+
"skipLocationChange": "skipLocationChange";
|
|
657
|
+
"replaceUrl": "replaceUrl";
|
|
658
|
+
"state": "state";
|
|
659
|
+
};
|
|
660
|
+
outputs: {};
|
|
661
|
+
}]>;
|
|
524
662
|
}
|
|
525
|
-
|
|
526
|
-
type
|
|
527
|
-
|
|
528
|
-
options: RoutePathArgs<P>[0] | undefined,
|
|
529
|
-
extras: NavigationBehaviorOptions
|
|
530
|
-
] : [options: RoutePathArgs<P>[0], extras: NavigationBehaviorOptions];
|
|
663
|
+
/** Angular navigation extras; `query` and `hash` replace `queryParams` and `fragment`. */
|
|
664
|
+
type NavigateExtras = NavigationBehaviorOptions & Pick<UrlCreationOptions, 'queryParamsHandling' | 'preserveFragment'>;
|
|
665
|
+
type WithExtrasArgs<Args extends [options?: unknown]> = [] extends Args ? [extras: NavigateExtras] | [options: Args[0] | undefined, extras: NavigateExtras] : [options: Args[0], extras: NavigateExtras];
|
|
531
666
|
type TypedNavigate = {
|
|
532
|
-
|
|
533
|
-
|
|
667
|
+
<P extends AnalogRoutePath>(path: P, ...args: RoutePathArgs<P>): Promise<boolean>;
|
|
668
|
+
<P extends AnalogRoutePath>(path: P, ...args: WithExtrasArgs<RoutePathArgs<P>>): Promise<boolean>;
|
|
669
|
+
};
|
|
670
|
+
type WithUpdaters<From extends string, O> = { [K in keyof O]: K extends 'params' ? O[K] | ((prev: RouteParamsOutput<From>) => Exclude<O[K], undefined>) : K extends 'query' ? O[K] | ((prev: RouteQueryOutput<From>) => Exclude<O[K], undefined>) : O[K]; };
|
|
671
|
+
type ScopedNavigateArgs<From extends string, T extends string> = WithUpdaters<From, ScopedRoutePathOptions<From, ResolveRoutePath<From, T>>> extends (infer O) ? Record<never, never> extends O ? [options?: O] : [options: O] : never;
|
|
672
|
+
type ScopedNavigate<From extends AnalogRoutePath> = {
|
|
673
|
+
<T extends ScopedRouteTarget<From>>(target: T, ...args: ScopedNavigateArgs<From, T>): Promise<boolean>;
|
|
674
|
+
<T extends ScopedRouteTarget<From>>(target: T, ...args: WithExtrasArgs<ScopedNavigateArgs<From, T>>): Promise<boolean>;
|
|
534
675
|
};
|
|
535
676
|
/**
|
|
536
677
|
* Injects a typed navigate function.
|
|
@@ -544,18 +685,57 @@ type TypedNavigate = {
|
|
|
544
685
|
*
|
|
545
686
|
* // With navigation extras
|
|
546
687
|
* navigate('/users/[id]', { params: { id: '42' } }, { replaceUrl: true });
|
|
688
|
+
* navigate('/search', { query: { page: 2 } }, { queryParamsHandling: 'merge' });
|
|
547
689
|
* ```
|
|
548
690
|
*/
|
|
549
|
-
declare function injectNavigate(): TypedNavigate;
|
|
550
|
-
|
|
691
|
+
export declare function injectNavigate(): TypedNavigate;
|
|
692
|
+
/**
|
|
693
|
+
* Injects a navigate function scoped to the current route, `from`.
|
|
694
|
+
*
|
|
695
|
+
* Targets may be relative (`.`, `./child`, `..`, `../sibling`). Params in the
|
|
696
|
+
* leading segments the target shares with `from` default to current values.
|
|
697
|
+
* `params` and `query` may be functions of the current values.
|
|
698
|
+
*
|
|
699
|
+
* @example
|
|
700
|
+
* ```ts
|
|
701
|
+
* // In the component for /users/[id]
|
|
702
|
+
* const navigate = injectNavigate('/users/[id]');
|
|
703
|
+
*
|
|
704
|
+
* navigate('./posts'); // /users/42/posts
|
|
705
|
+
* navigate('.', { params: { id: 43 } }); // /users/43
|
|
706
|
+
* navigate('..'); // /users
|
|
707
|
+
* navigate('.', { params: (prev) => ({ id: Number(prev.id) + 1 }) });
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
710
|
+
export declare function injectNavigate<From extends AnalogRoutePath>(from: From, options?: {
|
|
711
|
+
injector?: Injector;
|
|
712
|
+
}): ScopedNavigate<From>;
|
|
713
|
+
/** Internal: params for `route` and its ancestors, with catch-alls as arrays. */
|
|
714
|
+
declare function observeRouteParams(route: ActivatedRoute, routePath: string): Observable<Record<string, unknown>>;
|
|
715
|
+
type InjectOptions = {
|
|
716
|
+
injector?: Injector;
|
|
717
|
+
};
|
|
551
718
|
/** Read raw route params; catch-all segments are returned as arrays. */
|
|
552
|
-
declare function injectParams<P extends AnalogRoutePath>(
|
|
553
|
-
|
|
554
|
-
|
|
719
|
+
export declare function injectParams<P extends AnalogRoutePath>(from: P, options?: InjectOptions): Signal<RouteParamsOutput<P>>;
|
|
720
|
+
/** Read untyped route params. Catch-all segments require a route path. */
|
|
721
|
+
export declare function injectParams(options?: InjectOptions): Signal<Record<string, string | undefined>>;
|
|
555
722
|
/** Read raw query params as a signal. No schema coercion is performed. */
|
|
556
|
-
declare function injectQuery<P extends AnalogRoutePath>(
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
723
|
+
export declare function injectQuery<P extends AnalogRoutePath>(from: P, options?: InjectOptions): Signal<RouteQueryOutput<P>>;
|
|
724
|
+
/** Read raw query params as a signal. */
|
|
725
|
+
export declare function injectQuery(options?: InjectOptions): Signal<Record<string, string | string[] | undefined>>;
|
|
726
|
+
/**
|
|
727
|
+
* Read route data as a signal: static `routeMeta.data` and `routeMeta.resolve`
|
|
728
|
+
* results from the page and its layouts, and the page's server `load` result
|
|
729
|
+
* under `load`.
|
|
730
|
+
*/
|
|
731
|
+
export declare function injectRouteData<P extends AnalogRoutePath>(from: P, options?: InjectOptions): Signal<RouteDataOutput<P>>;
|
|
732
|
+
/** Read untyped route data as a signal. */
|
|
733
|
+
export declare function injectRouteData(options?: InjectOptions): Signal<Record<string, unknown>>;
|
|
734
|
+
/**
|
|
735
|
+
* Access route resources: returns resources defined on the route and its
|
|
736
|
+
* ancestor layouts via `routeMeta.resources`. Requires `withRouterResources()`.
|
|
737
|
+
*/
|
|
738
|
+
export declare function injectResources<P extends AnalogRoutePath>(from: P, options?: InjectOptions): RouteResourcesOutput<P>;
|
|
739
|
+
/** Access untyped route resources. */
|
|
740
|
+
export declare function injectResources(options?: InjectOptions): RouteResourcesOutput<string>;
|
|
741
|
+
export { type AnalogRoutePath, type AnalogRouteTable, type Files, type FormActionState, type LinkToInput, type RouteDataOutput, type RouteExport, type RouteLoadOutput, type RoutePathOptions, type RouteResourcesOutput, type ServerFn, type ServerFnConfig, type ServerFnContext, type ServerFnDef, type ServerFnDispatcher, type ServerFnHandler, type ServerFnMethod, type ServerFnRefConfig, type StandardSchemaV1, type ValidationFieldErrors, injectResources as injectRouteResources };
|