@analogjs/router 2.8.0-beta.8 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/fesm2022/analogjs-router-debug.page-MFY2u07E.mjs +119 -0
  2. package/fesm2022/analogjs-router-debug.page-MFY2u07E.mjs.map +1 -0
  3. package/fesm2022/analogjs-router-i18n.mjs +82 -219
  4. package/fesm2022/analogjs-router-i18n.mjs.map +1 -1
  5. package/fesm2022/analogjs-router-routes-L2tt-0ms.mjs +263 -0
  6. package/fesm2022/analogjs-router-routes-L2tt-0ms.mjs.map +1 -0
  7. package/fesm2022/analogjs-router-server-actions.mjs +228 -463
  8. package/fesm2022/analogjs-router-server-actions.mjs.map +1 -1
  9. package/fesm2022/analogjs-router-server.mjs +608 -838
  10. package/fesm2022/analogjs-router-server.mjs.map +1 -1
  11. package/fesm2022/analogjs-router-tanstack-query-server.mjs +35 -85
  12. package/fesm2022/analogjs-router-tanstack-query-server.mjs.map +1 -1
  13. package/fesm2022/analogjs-router-tanstack-query.mjs +79 -127
  14. package/fesm2022/analogjs-router-tanstack-query.mjs.map +1 -1
  15. package/fesm2022/analogjs-router-tokens.mjs +14 -19
  16. package/fesm2022/analogjs-router-tokens.mjs.map +1 -1
  17. package/fesm2022/analogjs-router.mjs +882 -1324
  18. package/fesm2022/analogjs-router.mjs.map +1 -1
  19. package/package.json +2 -2
  20. package/types/analogjs-router-i18n.d.ts +55 -24
  21. package/types/analogjs-router-server-actions.d.ts +98 -107
  22. package/types/analogjs-router-server.d.ts +76 -116
  23. package/types/analogjs-router-tanstack-query-server.d.ts +33 -37
  24. package/types/analogjs-router-tanstack-query.d.ts +19 -24
  25. package/types/analogjs-router-tokens.d.ts +26 -22
  26. package/types/analogjs-router.d.ts +528 -348
  27. package/fesm2022/analogjs-router-debug.page-COcFkgRu.mjs +0 -91
  28. package/fesm2022/analogjs-router-debug.page-COcFkgRu.mjs.map +0 -1
@@ -1,65 +1,62 @@
1
- import { H3EventContext, H3Event } from 'h3';
2
- import { $Fetch } from 'nitropack';
3
-
1
+ import { H3Event, H3EventContext } from "h3";
2
+ import { $Fetch } from "nitropack";
4
3
  type PageServerAction = {
5
- params: H3EventContext['params'];
6
- req: H3Event['node']['req'];
7
- res: H3Event['node']['res'];
8
- fetch: $Fetch;
9
- event: H3Event;
4
+ params: H3EventContext['params'];
5
+ req: H3Event['node']['req'];
6
+ res: H3Event['node']['res'];
7
+ fetch: $Fetch;
8
+ event: H3Event;
10
9
  };
11
- declare function fail<T = object>(status: number, errors: T): Response;
12
- declare function json<T = object>(data: T, config?: ResponseInit): Response;
13
- declare function redirect(url: string, config?: number | ResponseInit): Response;
14
-
10
+ export declare function fail<T = object>(status: number, errors: T): Response;
11
+ export declare function json<T = object>(data: T, config?: ResponseInit): Response;
12
+ export declare function redirect(url: string, config?: number | ResponseInit): Response;
15
13
  /**
16
14
  * The Standard Schema interface, inlined from the spec at
17
15
  * https://standardschema.dev so no runtime dependency is required.
18
16
  */
19
17
  interface StandardSchemaV1<Input = unknown, Output = Input> {
20
- readonly '~standard': StandardSchemaV1.Props<Input, Output>;
18
+ readonly '~standard': StandardSchemaV1.Props<Input, Output>;
21
19
  }
22
20
  declare namespace StandardSchemaV1 {
23
- interface Props<Input = unknown, Output = Input> {
24
- readonly version: 1;
25
- readonly vendor: string;
26
- readonly validate: (value: unknown, options?: Options | undefined) => Result<Output> | Promise<Result<Output>>;
27
- readonly types?: Types<Input, Output> | undefined;
28
- }
29
- type Result<Output> = SuccessResult<Output> | FailureResult;
30
- interface SuccessResult<Output> {
31
- readonly value: Output;
32
- readonly issues?: undefined;
33
- }
34
- interface FailureResult {
35
- readonly issues: ReadonlyArray<Issue>;
36
- }
37
- interface Issue {
38
- readonly message: string;
39
- readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
40
- }
41
- interface PathSegment {
42
- readonly key: PropertyKey;
43
- }
44
- interface Options {
45
- readonly libraryOptions?: Record<string, unknown> | undefined;
46
- }
47
- interface Types<Input = unknown, Output = Input> {
48
- readonly input: Input;
49
- readonly output: Output;
50
- }
51
- type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
52
- type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
21
+ interface Props<Input = unknown, Output = Input> {
22
+ readonly version: 1;
23
+ readonly vendor: string;
24
+ readonly validate: (value: unknown, options?: Options | undefined) => Result<Output> | Promise<Result<Output>>;
25
+ readonly types?: Types<Input, Output> | undefined;
26
+ }
27
+ type Result<Output> = SuccessResult<Output> | FailureResult;
28
+ interface SuccessResult<Output> {
29
+ readonly value: Output;
30
+ readonly issues?: undefined;
31
+ }
32
+ interface FailureResult {
33
+ readonly issues: ReadonlyArray<Issue>;
34
+ }
35
+ interface Issue {
36
+ readonly message: string;
37
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
38
+ }
39
+ interface PathSegment {
40
+ readonly key: PropertyKey;
41
+ }
42
+ interface Options {
43
+ readonly libraryOptions?: Record<string, unknown> | undefined;
44
+ }
45
+ interface Types<Input = unknown, Output = Input> {
46
+ readonly input: Input;
47
+ readonly output: Output;
48
+ }
49
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
50
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
53
51
  }
54
-
55
52
  type DefineServerRouteResult = Response | unknown;
56
53
  interface ServerRouteHandler<TQuery = unknown, TBody = unknown, TResult = unknown> {
57
- (event: H3Event): Promise<Response>;
58
- readonly _types: {
59
- readonly query: TQuery;
60
- readonly body: TBody;
61
- readonly result: TResult;
62
- };
54
+ (event: H3Event): Promise<Response>;
55
+ readonly _types: {
56
+ readonly query: TQuery;
57
+ readonly body: TBody;
58
+ readonly result: TResult;
59
+ };
63
60
  }
64
61
  type InferRouteQuery<T> = T extends ServerRouteHandler<infer Q, any, any> ? Q : never;
65
62
  type InferRouteBody<T> = T extends ServerRouteHandler<any, infer B, any> ? B : never;
@@ -68,19 +65,19 @@ type OptionalSchema$3 = StandardSchemaV1 | undefined;
68
65
  type InferSchema$3<TSchema extends OptionalSchema$3, TFallback = unknown> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
69
66
  type ResolveDataSchema$1<TInput extends OptionalSchema$3, TQuery extends OptionalSchema$3, TBody extends OptionalSchema$3> = TInput extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TInput> : TQuery extends StandardSchemaV1 ? TBody extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TQuery> | StandardSchemaV1.InferOutput<TBody> : StandardSchemaV1.InferOutput<TQuery> : TBody extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TBody> : unknown;
70
67
  interface DefineServerRouteContext<TInput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined> {
71
- data: ResolveDataSchema$1<TInput, TQuery, TBody>;
72
- query: InferSchema$3<TQuery, undefined>;
73
- body: InferSchema$3<TBody, undefined>;
74
- params: InferSchema$3<TParams, H3Event['context']['params']>;
75
- event: H3Event;
68
+ data: ResolveDataSchema$1<TInput, TQuery, TBody>;
69
+ query: InferSchema$3<TQuery, undefined>;
70
+ body: InferSchema$3<TBody, undefined>;
71
+ params: InferSchema$3<TParams, H3Event['context']['params']>;
72
+ event: H3Event;
76
73
  }
77
74
  interface DefineServerRouteOptions<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineServerRouteResult = DefineServerRouteResult> {
78
- input?: TInput;
79
- query?: TQuery;
80
- body?: TBody;
81
- params?: TParams;
82
- output?: TOutput;
83
- handler: (context: DefineServerRouteContext<TInput, TQuery, TBody, TParams>) => Promise<TResult> | TResult;
75
+ input?: TInput;
76
+ query?: TQuery;
77
+ body?: TBody;
78
+ params?: TParams;
79
+ output?: TOutput;
80
+ handler: (context: DefineServerRouteContext<TInput, TQuery, TBody, TParams>) => Promise<TResult> | TResult;
84
81
  }
85
82
  /**
86
83
  * Creates an h3-compatible event handler with Standard Schema validation.
@@ -116,22 +113,21 @@ interface DefineServerRouteOptions<TInput extends StandardSchemaV1 | undefined =
116
113
  * });
117
114
  * ```
118
115
  */
119
- declare function defineServerRoute<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineServerRouteResult = DefineServerRouteResult>(options: DefineServerRouteOptions<TInput, TOutput, TQuery, TBody, TParams, TResult>): ServerRouteHandler<InferSchema$3<TQuery, undefined>, InferSchema$3<TBody, undefined>, TResult>;
120
-
116
+ export declare function defineServerRoute<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineServerRouteResult = DefineServerRouteResult>(options: DefineServerRouteOptions<TInput, TOutput, TQuery, TBody, TParams, TResult>): ServerRouteHandler<InferSchema$3<TQuery, undefined>, InferSchema$3<TBody, undefined>, TResult>;
121
117
  type OptionalSchema$2 = StandardSchemaV1 | undefined;
122
118
  type InferSchema$2<TSchema extends OptionalSchema$2, TFallback> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
123
119
  interface PageLoadContext<TParamsSchema extends OptionalSchema$2 = undefined, TQuerySchema extends OptionalSchema$2 = undefined> {
124
- params: InferSchema$2<TParamsSchema, H3EventContext['params']>;
125
- query: InferSchema$2<TQuerySchema, Record<string, string | string[] | undefined>>;
126
- req: H3Event['node']['req'];
127
- res: H3Event['node']['res'];
128
- fetch: $Fetch;
129
- event: H3Event;
120
+ params: InferSchema$2<TParamsSchema, H3EventContext['params']>;
121
+ query: InferSchema$2<TQuerySchema, Record<string, string | string[] | undefined>>;
122
+ req: H3Event['node']['req'];
123
+ res: H3Event['node']['res'];
124
+ fetch: $Fetch;
125
+ event: H3Event;
130
126
  }
131
127
  interface DefinePageLoadOptions<TParamsSchema extends OptionalSchema$2 = undefined, TQuerySchema extends OptionalSchema$2 = undefined, TResult = unknown> {
132
- params?: TParamsSchema;
133
- query?: TQuerySchema;
134
- handler: (context: PageLoadContext<TParamsSchema, TQuerySchema>) => Promise<TResult> | TResult;
128
+ params?: TParamsSchema;
129
+ query?: TQuerySchema;
130
+ handler: (context: PageLoadContext<TParamsSchema, TQuerySchema>) => Promise<TResult> | TResult;
135
131
  }
136
132
  /**
137
133
  * Creates a typed page server load function with optional
@@ -161,36 +157,34 @@ interface DefinePageLoadOptions<TParamsSchema extends OptionalSchema$2 = undefin
161
157
  * });
162
158
  * ```
163
159
  */
164
- declare function definePageLoad<TParamsSchema extends OptionalSchema$2 = undefined, TQuerySchema extends OptionalSchema$2 = undefined, TResult = unknown>(options: DefinePageLoadOptions<TParamsSchema, TQuerySchema, TResult>): (ctx: {
165
- params: H3EventContext['params'];
166
- req: H3Event['node']['req'];
167
- res: H3Event['node']['res'];
168
- fetch: $Fetch;
169
- event: H3Event;
160
+ export declare function definePageLoad<TParamsSchema extends OptionalSchema$2 = undefined, TQuerySchema extends OptionalSchema$2 = undefined, TResult = unknown>(options: DefinePageLoadOptions<TParamsSchema, TQuerySchema, TResult>): (ctx: {
161
+ params: H3EventContext['params'];
162
+ req: H3Event['node']['req'];
163
+ res: H3Event['node']['res'];
164
+ fetch: $Fetch;
165
+ event: H3Event;
170
166
  }) => Promise<TResult | Response>;
171
-
172
167
  /**
173
168
  * Validates unknown input against a Standard Schema.
174
169
  *
175
170
  * Handles both sync and async `validate` implementations — the Standard
176
171
  * Schema spec allows either return shape.
177
172
  */
178
- declare function validateWithSchema<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<T>>>;
179
-
173
+ export declare function validateWithSchema<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<T>>>;
180
174
  type OptionalSchema$1 = StandardSchemaV1 | undefined;
181
175
  type InferSchema$1<TSchema extends OptionalSchema$1, TFallback> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
182
176
  interface DefineActionContext<TSchema extends OptionalSchema$1 = undefined, TParamsSchema extends OptionalSchema$1 = undefined> {
183
- data: InferSchema$1<TSchema, Record<string, unknown>>;
184
- params: InferSchema$1<TParamsSchema, H3EventContext['params']>;
185
- req: PageServerAction['req'];
186
- res: PageServerAction['res'];
187
- fetch: PageServerAction['fetch'];
188
- event: PageServerAction['event'];
177
+ data: InferSchema$1<TSchema, Record<string, unknown>>;
178
+ params: InferSchema$1<TParamsSchema, H3EventContext['params']>;
179
+ req: PageServerAction['req'];
180
+ res: PageServerAction['res'];
181
+ fetch: PageServerAction['fetch'];
182
+ event: PageServerAction['event'];
189
183
  }
190
184
  interface DefineActionOptions<TSchema extends OptionalSchema$1 = undefined, TParamsSchema extends OptionalSchema$1 = undefined> {
191
- schema?: TSchema;
192
- params?: TParamsSchema;
193
- handler: (context: DefineActionContext<TSchema, TParamsSchema>) => Promise<Response> | Response;
185
+ schema?: TSchema;
186
+ params?: TParamsSchema;
187
+ handler: (context: DefineActionContext<TSchema, TParamsSchema>) => Promise<Response> | Response;
194
188
  }
195
189
  /**
196
190
  * Creates a server action handler with Standard Schema input validation.
@@ -219,26 +213,25 @@ interface DefineActionOptions<TSchema extends OptionalSchema$1 = undefined, TPar
219
213
  * });
220
214
  * ```
221
215
  */
222
- declare function defineAction<TSchema extends OptionalSchema$1 = undefined, TParamsSchema extends OptionalSchema$1 = undefined>(options: DefineActionOptions<TSchema, TParamsSchema>): (ctx: PageServerAction) => Promise<Response>;
223
-
216
+ export declare function defineAction<TSchema extends OptionalSchema$1 = undefined, TParamsSchema extends OptionalSchema$1 = undefined>(options: DefineActionOptions<TSchema, TParamsSchema>): (ctx: PageServerAction) => Promise<Response>;
224
217
  type DefineApiRouteResult = Response | unknown;
225
218
  type OptionalSchema = StandardSchemaV1 | undefined;
226
219
  type InferSchema<TSchema extends OptionalSchema, TFallback = unknown> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
227
220
  type ResolveDataSchema<TInput extends OptionalSchema, TQuery extends OptionalSchema, TBody extends OptionalSchema> = TInput extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TInput> : TQuery extends StandardSchemaV1 ? TBody extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TQuery> | StandardSchemaV1.InferOutput<TBody> : StandardSchemaV1.InferOutput<TQuery> : TBody extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TBody> : unknown;
228
221
  interface DefineApiRouteContext<TInput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined> {
229
- data: ResolveDataSchema<TInput, TQuery, TBody>;
230
- query: InferSchema<TQuery, undefined>;
231
- body: InferSchema<TBody, undefined>;
232
- params: InferSchema<TParams, H3Event['context']['params']>;
233
- event: H3Event;
222
+ data: ResolveDataSchema<TInput, TQuery, TBody>;
223
+ query: InferSchema<TQuery, undefined>;
224
+ body: InferSchema<TBody, undefined>;
225
+ params: InferSchema<TParams, H3Event['context']['params']>;
226
+ event: H3Event;
234
227
  }
235
228
  interface DefineApiRouteOptions<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineApiRouteResult = DefineApiRouteResult> {
236
- input?: TInput;
237
- query?: TQuery;
238
- body?: TBody;
239
- params?: TParams;
240
- output?: TOutput;
241
- handler: (context: DefineApiRouteContext<TInput, TQuery, TBody, TParams>) => Promise<TResult> | TResult;
229
+ input?: TInput;
230
+ query?: TQuery;
231
+ body?: TBody;
232
+ params?: TParams;
233
+ output?: TOutput;
234
+ handler: (context: DefineApiRouteContext<TInput, TQuery, TBody, TParams>) => Promise<TResult> | TResult;
242
235
  }
243
236
  /**
244
237
  * Creates an h3-compatible event handler with Standard Schema validation.
@@ -273,7 +266,5 @@ interface DefineApiRouteOptions<TInput extends StandardSchemaV1 | undefined = un
273
266
  * });
274
267
  * ```
275
268
  */
276
- declare function defineApiRoute<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineApiRouteResult = DefineApiRouteResult>(options: DefineApiRouteOptions<TInput, TOutput, TQuery, TBody, TParams, TResult>): (event: H3Event) => Promise<Response>;
277
-
278
- export { StandardSchemaV1, defineAction, defineApiRoute, definePageLoad, defineServerRoute, fail, json, redirect, validateWithSchema };
279
- export type { DefineActionContext, DefineActionOptions, DefineApiRouteContext, DefineApiRouteOptions, DefineApiRouteResult, DefinePageLoadOptions, DefineServerRouteContext, DefineServerRouteOptions, DefineServerRouteResult, InferRouteBody, InferRouteQuery, InferRouteResult, PageLoadContext, PageServerAction, ServerRouteHandler };
269
+ export declare function defineApiRoute<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineApiRouteResult = DefineApiRouteResult>(options: DefineApiRouteOptions<TInput, TOutput, TQuery, TBody, TParams, TResult>): (event: H3Event) => Promise<Response>;
270
+ export type { DefineActionContext, DefineActionOptions, DefineApiRouteContext, DefineApiRouteOptions, DefineApiRouteResult, DefinePageLoadOptions, DefineServerRouteContext, DefineServerRouteOptions, DefineServerRouteResult, InferRouteBody, InferRouteQuery, InferRouteResult, PageLoadContext, PageServerAction, ServerRouteHandler, StandardSchemaV1 };
@@ -1,15 +1,29 @@
1
- import { StaticProvider, Type, ApplicationConfig, Provider, Injector, InjectionToken } from '@angular/core';
2
- import { ServerRequest, ServerResponse, ServerContext } from '@analogjs/router/tokens';
3
- import { ServerFnHandler, ServerFn, StandardSchemaV1, ServerFnConfig, ServerFnContext, ServerFnDef } from '@analogjs/router';
4
- export { ServerFn, ServerFnConfig, ServerFnContext, ServerFnHandler, ServerFnMethod, StandardSchemaV1 } from '@analogjs/router';
5
- import * as h3 from 'h3';
6
- import { H3Event } from 'h3';
7
-
8
- declare function provideServerContext({ req, res, }: {
9
- req: ServerRequest;
10
- res: ServerResponse;
1
+ import { ApplicationConfig, InjectionToken, Injector, Provider, StaticProvider, Type } from "@angular/core";
2
+ import { ServerContext, ServerRequest, ServerResponse } from "@analogjs/router/tokens";
3
+ import { ServerFn, ServerFn as ServerFn$1, ServerFnConfig, ServerFnConfig as ServerFnConfig$1, ServerFnContext, ServerFnContext as ServerFnContext$1, ServerFnDef, ServerFnHandler, ServerFnHandler as ServerFnHandler$1, ServerFnMethod, StandardSchemaV1, StandardSchemaV1 as StandardSchemaV1$1 } from "@analogjs/router";
4
+ import { H3Event } from "h3";
5
+ export declare function provideServerContext({ req, res }: {
6
+ req: ServerRequest;
7
+ res: ServerResponse;
11
8
  }): StaticProvider[];
12
-
9
+ /**
10
+ * Detects the locale from the request URL path prefix or Accept-Language header.
11
+ * URL prefix takes priority (e.g. /fr/about -> 'fr').
12
+ */
13
+ declare function detectLocale(req: ServerRequest): string | undefined;
14
+ /**
15
+ * Extracts a locale from the first URL path segment if it matches
16
+ * a BCP 47-like pattern (e.g. 'en', 'en-US', 'zh-Hans-CN').
17
+ */
18
+ declare function extractLocaleFromUrl(url: string): string | undefined;
19
+ /**
20
+ * Parses the Accept-Language header and returns the most preferred language.
21
+ */
22
+ declare function parseAcceptLanguage(header: string | undefined): string | undefined;
23
+ declare function getBaseUrl(req: ServerRequest): string;
24
+ declare function getRequestProtocol(req: ServerRequest, opts?: {
25
+ xForwardedProto?: boolean;
26
+ }): "https" | "http";
13
27
  /**
14
28
  * Returns a function that accepts the navigation URL,
15
29
  * the root HTML, and server context.
@@ -19,37 +33,7 @@ declare function provideServerContext({ req, res, }: {
19
33
  * @param platformProviders
20
34
  * @returns Promise<string | Reponse>
21
35
  */
22
- declare function render(rootComponent: Type<unknown>, config: ApplicationConfig, platformProviders?: Provider[]): (url: string, document: string, serverContext: ServerContext) => Promise<string>;
23
-
24
- /**
25
- * Progressive streaming SSR renderer — EXPERIMENTAL.
26
- *
27
- * Returns a `ReadableStream<Uint8Array>` that flushes bytes DURING the render,
28
- * not after it:
29
- * 1. the document head + a client reconcile runtime are flushed immediately,
30
- * before the app has finished rendering, so the browser starts fetching
31
- * assets right away;
32
- * 2. each `@defer (hydrate …)` block's content is flushed the moment it
33
- * resolves on the server — out of document order — while later blocks are
34
- * still pending (proven: a slow block does not hold back an early one);
35
- * 3. once the app is stable, the authoritative, fully hydration-annotated
36
- * document is flushed as the tail. This is byte-identical to a buffered
37
- * `renderApplication`, and is what Angular's incremental hydration runs
38
- * against on the client.
39
- *
40
- * Unlike a buffered renderer, this drives the platform directly
41
- * (`platformServer` + `bootstrapApplication` + `ɵrenderInternal`) so it can
42
- * interleave flushes with rendering. Angular's hydration annotation is
43
- * whole-document (the root's `ngh` index references every `@defer` container),
44
- * so the authoritative hydration payload is necessarily the tail: RENDERING
45
- * streams progressively, and hydration begins once the tail arrives.
46
- *
47
- * Depends on an upstream Angular per-block resolution hook exposed on two
48
- * globals (see {@link SsrStreamingGlobals}). When the primitive is absent,
49
- * `renderStream` degrades to a single buffered chunk so behaviour matches the
50
- * classic `render()` path, which is unchanged and remains the default.
51
- */
52
-
36
+ export declare function render(rootComponent: Type<unknown>, config: ApplicationConfig, platformProviders?: Provider[]): (url: string, document: string, serverContext: ServerContext) => Promise<string>;
53
37
  /**
54
38
  * Returns a function that renders a URL to a `ReadableStream<Uint8Array>`.
55
39
  *
@@ -59,8 +43,7 @@ declare function render(rootComponent: Type<unknown>, config: ApplicationConfig,
59
43
  * export default renderStream(App, config);
60
44
  * ```
61
45
  */
62
- declare function renderStream(rootComponent: Type<unknown>, config: ApplicationConfig, platformProviders?: Provider[]): (url: string, document: string, serverContext: ServerContext) => Promise<ReadableStream<Uint8Array>>;
63
-
46
+ export declare function renderStream(rootComponent: Type<unknown>, config: ApplicationConfig, platformProviders?: Provider[]): (url: string, document: string, serverContext: ServerContext) => Promise<ReadableStream<Uint8Array>>;
64
47
  /**
65
48
  * Define a server function. Authored in a `*.server.ts` module.
66
49
  *
@@ -78,10 +61,9 @@ declare function renderStream(rootComponent: Type<unknown>, config: ApplicationC
78
61
  * proxy that calls `/_analog/fn/<id>`; the reference still carries
79
62
  * `id`/`url`/`method` so `injectServerFn`/`ServerFnClient` can dispatch.
80
63
  */
81
- declare function serverFn<Out>(handler: ServerFnHandler<void, Out>): ServerFn<void, Out>;
82
- declare function serverFn<In, Out>(input: StandardSchemaV1<In>, handler: ServerFnHandler<In, Out>): ServerFn<In, Out>;
83
- declare function serverFn<In, Out>(config: ServerFnConfig<In>, handler: ServerFnHandler<In, Out>): ServerFn<In, Out>;
84
-
64
+ export declare function serverFn<Out>(handler: ServerFnHandler$1<void, Out>): ServerFn$1<void, Out>;
65
+ export declare function serverFn<In, Out>(input: StandardSchemaV1$1<In>, handler: ServerFnHandler$1<In, Out>): ServerFn$1<In, Out>;
66
+ export declare function serverFn<In, Out>(config: ServerFnConfig$1<In>, handler: ServerFnHandler$1<In, Out>): ServerFn$1<In, Out>;
85
67
  /**
86
68
  * Builds the parent injector the server-function dispatch endpoint runs handlers
87
69
  * against, over HTTP.
@@ -110,8 +92,7 @@ declare function serverFn<In, Out>(config: ServerFnConfig<In>, handler: ServerFn
110
92
  * app config); it is wrapped with `provideServerRendering` so the server tokens
111
93
  * resolve the same way.
112
94
  */
113
- declare function createServerFnAppInjector(configOrProviders?: ApplicationConfig | StaticProvider[]): Promise<Injector>;
114
-
95
+ export declare function createServerFnAppInjector(configOrProviders?: ApplicationConfig | StaticProvider[]): Promise<Injector>;
115
96
  /**
116
97
  * The h3 request/response layer for the server-function dispatch route.
117
98
  *
@@ -125,45 +106,44 @@ declare function createServerFnAppInjector(configOrProviders?: ApplicationConfig
125
106
  * import time and passes the pending injector, which is awaited on first request
126
107
  * and resolved instantly thereafter.
127
108
  */
128
- declare function createServerFnEventHandler(appInjector: Injector | Promise<Injector>): h3.EventHandler<h3.EventHandlerRequest, Promise<unknown>>;
109
+ export declare function createServerFnEventHandler(appInjector: Injector | Promise<Injector>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
129
110
  /**
130
111
  * Decode a server-function request, dispatch it, and write the result to the
131
112
  * h3 response. Same-origin, method, content-type, validation, and interceptors
132
113
  * are enforced inside `dispatchServerFn`; this owns only the h3 I/O around it.
133
114
  */
134
- declare function handleServerFnRequest(event: H3Event, appInjector: Injector | Promise<Injector>): Promise<unknown>;
135
-
115
+ export declare function handleServerFnRequest(event: H3Event, appInjector: Injector | Promise<Injector>): Promise<unknown>;
136
116
  interface DispatchResult {
137
- status: number;
138
- body: unknown;
139
- /**
140
- * Headers from a returned `Response` (`fail`/`redirect`): Location, … The
141
- * value is an array when the header legitimately repeats, which is why
142
- * `Set-Cookie` is read separately below — collapsing several cookies into one
143
- * comma-joined value corrupts them.
144
- */
145
- headers?: Record<string, string | string[]>;
117
+ status: number;
118
+ body: unknown;
119
+ /**
120
+ * Headers from a returned `Response` (`fail`/`redirect`): Location, … The
121
+ * value is an array when the header legitimately repeats, which is why
122
+ * `Set-Cookie` is read separately below — collapsing several cookies into one
123
+ * comma-joined value corrupts them.
124
+ */
125
+ headers?: Record<string, string | string[]>;
146
126
  }
147
127
  interface DispatchServerFnOptions {
148
- /**
149
- * The app's environment injector. The per-request injector is created as its
150
- * child, so handlers resolve app services (and `providedIn: 'root'` services,
151
- * when this is the app's bootstrapped injector) and registered interceptors
152
- * without re-listing them per request.
153
- */
154
- parent?: Injector;
155
- /** Extra per-request providers, for direct callers without an app injector. */
156
- providers?: StaticProvider[];
157
- /** Request HTTP method; enforced against the function's configured method. */
158
- method?: string;
159
- /**
160
- * Origins permitted beyond same-origin, merged with any registered through DI
161
- * (`provideServerFns(withAllowedOrigins([...]))`). The transport is
162
- * same-origin by default (cross-origin browser calls are rejected with 403);
163
- * `'*'` disables the check entirely. Only consulted for HTTP-transport calls
164
- * (those that pass `method`).
165
- */
166
- allowedOrigins?: string[];
128
+ /**
129
+ * The app's environment injector. The per-request injector is created as its
130
+ * child, so handlers resolve app services (and `providedIn: 'root'` services,
131
+ * when this is the app's bootstrapped injector) and registered interceptors
132
+ * without re-listing them per request.
133
+ */
134
+ parent?: Injector;
135
+ /** Extra per-request providers, for direct callers without an app injector. */
136
+ providers?: StaticProvider[];
137
+ /** Request HTTP method; enforced against the function's configured method. */
138
+ method?: string;
139
+ /**
140
+ * Origins permitted beyond same-origin, merged with any registered through DI
141
+ * (`provideServerFns(withAllowedOrigins([...]))`). The transport is
142
+ * same-origin by default (cross-origin browser calls are rejected with 403);
143
+ * `'*'` disables the check entirely. Only consulted for HTTP-transport calls
144
+ * (those that pass `method`).
145
+ */
146
+ allowedOrigins?: string[];
167
147
  }
168
148
  /**
169
149
  * Server-side dispatch for a server function call.
@@ -186,26 +166,25 @@ interface DispatchServerFnOptions {
186
166
  * guard. Transports (the generated Nitro handler) always pass it; trusted
187
167
  * in-process callers may omit it, which also exempts them from the origin guard.
188
168
  */
189
- declare function dispatchServerFn(id: string, rawInput: unknown, event: Pick<H3Event, 'node'>, options?: DispatchServerFnOptions): Promise<DispatchResult>;
190
-
169
+ export declare function dispatchServerFn(id: string, rawInput: unknown, event: Pick<H3Event, 'node'>, options?: DispatchServerFnOptions): Promise<DispatchResult>;
191
170
  /** Context threaded through the interceptor chain and handed to the handler. */
192
171
  interface ServerFnInterceptorContext {
193
- readonly input: unknown;
194
- readonly context: ServerFnContext;
195
- /** Return a new context with additional typed fields merged in. */
196
- with(patch: Partial<ServerFnContext> & Record<string, unknown>): ServerFnInterceptorContext;
172
+ readonly input: unknown;
173
+ readonly context: ServerFnContext$1;
174
+ /** Return a new context with additional typed fields merged in. */
175
+ with(patch: Partial<ServerFnContext$1> & Record<string, unknown>): ServerFnInterceptorContext;
197
176
  }
198
177
  type ServerFnNext = (ctx: ServerFnInterceptorContext) => Promise<unknown>;
199
178
  /** Functional interceptor, modeled on `HttpInterceptorFn`. */
200
179
  type ServerFnInterceptorFn = (ctx: ServerFnInterceptorContext, next: ServerFnNext) => Promise<unknown> | unknown;
201
- declare const SERVER_FN_INTERCEPTORS: InjectionToken<ServerFnInterceptorFn[]>;
180
+ export declare const SERVER_FN_INTERCEPTORS: InjectionToken<ServerFnInterceptorFn[]>;
202
181
  interface ServerFnsFeature {
203
- providers: Provider[];
182
+ providers: Provider[];
204
183
  }
205
184
  /** `withServerFnInterceptors([...])` — registers the chain (DI, ordered). */
206
- declare function withServerFnInterceptors(interceptors: ServerFnInterceptorFn[]): ServerFnsFeature;
185
+ export declare function withServerFnInterceptors(interceptors: ServerFnInterceptorFn[]): ServerFnsFeature;
207
186
  /** `provideServerFns(withServerFnInterceptors(...))` — mirrors provideHttpClient. */
208
- declare function provideServerFns(...features: ServerFnsFeature[]): Provider[];
187
+ export declare function provideServerFns(...features: ServerFnsFeature[]): Provider[];
209
188
  /**
210
189
  * Run the interceptor chain, then the handler, threading the context.
211
190
  *
@@ -215,23 +194,7 @@ declare function provideServerFns(...features: ServerFnsFeature[]): Provider[];
215
194
  * (which would otherwise resume outside Angular's synchronous injection
216
195
  * context). It defaults to a pass-through for non-DI callers/tests.
217
196
  */
218
- declare function runInterceptors(interceptors: ServerFnInterceptorFn[], input: unknown, handler: (input: unknown, context: ServerFnContext) => Promise<unknown> | unknown, runInCtx?: <T>(fn: () => T) => T): Promise<unknown>;
219
-
220
- /**
221
- * Same-origin enforcement for the server-function HTTP transport.
222
- *
223
- * Server functions are same-origin RPC: a client proxy only ever calls the
224
- * relative `/_analog/fn/:id` URL of its own app. A cross-origin page must not be
225
- * able to invoke them against a logged-in user (a CSRF-shaped attack), so the
226
- * transport rejects browser requests whose origin is not the app's own — out of
227
- * the box, with no per-app configuration.
228
- *
229
- * The signals used (`Sec-Fetch-Site`, `Origin`) are added by the browser and
230
- * cannot be forged by a cross-origin page's `fetch`. Non-browser callers (curl,
231
- * server-to-server, SSR in-process) send neither, so they are unaffected: the
232
- * guard blocks the cross-origin browser attack it is meant to, and nothing else.
233
- */
234
-
197
+ export declare function runInterceptors(interceptors: ServerFnInterceptorFn[], input: unknown, handler: (input: unknown, context: ServerFnContext$1) => Promise<unknown> | unknown, runInCtx?: <T>(fn: () => T) => T): Promise<unknown>;
235
198
  /** Node/h3 header bag shape (`IncomingHttpHeaders`). */
236
199
  type HeaderBag = Record<string, string | string[] | undefined>;
237
200
  /**
@@ -239,14 +202,14 @@ type HeaderBag = Record<string, string | string[] | undefined>;
239
202
  * `provideServerFns(withAllowedOrigins([...]))`. Empty by default — the
240
203
  * transport is same-origin unless an app opts out explicitly.
241
204
  */
242
- declare const SERVER_FN_ALLOWED_ORIGINS: InjectionToken<string[]>;
205
+ export declare const SERVER_FN_ALLOWED_ORIGINS: InjectionToken<string[]>;
243
206
  /**
244
207
  * `withAllowedOrigins([...])` — permit cross-origin browser calls from the
245
208
  * listed origins, or pass `'*'` to disable the same-origin guard entirely.
246
209
  * Server functions are frequently cookie-authenticated, so this is an explicit
247
210
  * opt-out of CSRF protection: allow-list the exact origins you control.
248
211
  */
249
- declare function withAllowedOrigins(origins: string[]): ServerFnsFeature;
212
+ export declare function withAllowedOrigins(origins: string[]): ServerFnsFeature;
250
213
  /**
251
214
  * Whether an HTTP request to a server function may proceed.
252
215
  *
@@ -261,14 +224,11 @@ declare function withAllowedOrigins(origins: string[]): ServerFnsFeature;
261
224
  * absent (older browsers, some proxies) the `Origin` host is compared to the
262
225
  * request host as a fallback.
263
226
  */
264
- declare function isServerFnOriginAllowed(headers: HeaderBag, allowedOrigins?: readonly string[]): boolean;
265
-
227
+ export declare function isServerFnOriginAllowed(headers: HeaderBag, allowedOrigins?: readonly string[]): boolean;
266
228
  /**
267
229
  * Server-side registry of server functions, keyed by id. A `.server.ts` module
268
230
  * populates it as a side effect of `serverFn(...)` running at import time; the
269
231
  * Nitro dispatch route imports those modules to fill it, then looks up by id.
270
232
  */
271
- declare const serverFnRegistry: Map<string, ServerFnDef>;
272
-
273
- export { SERVER_FN_ALLOWED_ORIGINS, SERVER_FN_INTERCEPTORS, createServerFnAppInjector, createServerFnEventHandler, dispatchServerFn, handleServerFnRequest, isServerFnOriginAllowed, provideServerContext, provideServerFns, render, renderStream, runInterceptors, serverFn, serverFnRegistry, withAllowedOrigins, withServerFnInterceptors };
274
- export type { DispatchResult, DispatchServerFnOptions, HeaderBag, ServerFnInterceptorContext, ServerFnInterceptorFn, ServerFnNext, ServerFnsFeature };
233
+ export declare const serverFnRegistry: Map<string, ServerFnDef>;
234
+ export type { DispatchResult, DispatchServerFnOptions, HeaderBag, ServerFn, ServerFnConfig, ServerFnContext, ServerFnHandler, ServerFnInterceptorContext, ServerFnInterceptorFn, ServerFnMethod, ServerFnNext, ServerFnsFeature, StandardSchemaV1 };