@analogjs/router 2.4.0-beta.9 → 3.0.0-alpha.10
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-server-actions.mjs +327 -31
- package/fesm2022/analogjs-router-server.mjs +155 -176
- package/fesm2022/analogjs-router-tanstack-query.mjs +58 -0
- package/fesm2022/analogjs-router-tokens.mjs +17 -16
- package/fesm2022/analogjs-router.mjs +521 -812
- package/fesm2022/debug.page.mjs +121 -0
- package/fesm2022/routes.mjs +301 -0
- package/package.json +44 -26
- package/server/actions/package.json +4 -0
- package/server/package.json +4 -0
- package/tokens/package.json +4 -0
- package/types/server/actions/src/actions.d.ts +13 -0
- package/types/server/actions/src/define-action.d.ts +54 -0
- package/types/server/actions/src/define-page-load.d.ts +55 -0
- package/types/server/actions/src/define-server-route.d.ts +68 -0
- package/types/server/actions/src/index.d.ts +9 -0
- package/types/server/actions/src/parse-request-data.d.ts +9 -0
- package/types/server/actions/src/validate.d.ts +8 -0
- package/types/server/src/index.d.ts +4 -0
- package/types/server/src/provide-server-context.d.ts +11 -0
- package/types/server/src/render.d.ts +12 -0
- package/types/server/src/server-component-render.d.ts +4 -0
- package/types/server/src/tokens.d.ts +7 -0
- package/types/src/index.d.ts +16 -0
- package/types/src/lib/cache-key.d.ts +3 -0
- package/types/src/lib/constants.d.ts +2 -0
- package/types/src/lib/cookie-interceptor.d.ts +4 -0
- package/types/src/lib/debug/debug.page.d.ts +18 -0
- package/types/src/lib/debug/index.d.ts +10 -0
- package/types/src/lib/debug/routes.d.ts +10 -0
- package/types/src/lib/define-route.d.ts +46 -0
- package/types/src/lib/endpoints.d.ts +5 -0
- package/types/src/lib/form-action.directive.d.ts +25 -0
- package/types/src/lib/get-load-resolver.d.ts +8 -0
- package/types/src/lib/inject-load.d.ts +9 -0
- package/types/src/lib/inject-route-endpoint-url.d.ts +2 -0
- package/types/src/lib/markdown-helpers.d.ts +2 -0
- package/types/src/lib/meta-tags.d.ts +33 -0
- package/types/src/lib/models.d.ts +29 -0
- package/types/src/lib/provide-file-router.d.ts +18 -0
- package/types/src/lib/request-context.d.ts +13 -0
- package/types/src/lib/route-config.d.ts +2 -0
- package/types/src/lib/route-types.d.ts +12 -0
- package/types/src/lib/routes.d.ts +19 -0
- package/types/src/lib/server.component.d.ts +33 -0
- package/types/tanstack-query/src/index.d.ts +2 -0
- package/types/tanstack-query/src/provide-analog-query.d.ts +4 -0
- package/types/tanstack-query/src/provide-server-analog-query.d.ts +2 -0
- package/types/tanstack-query/src/server-query.d.ts +16 -0
- package/types/tokens/src/index.d.ts +23 -0
- package/fesm2022/analogjs-router-debug.page-jzggTA45.mjs +0 -91
- package/fesm2022/analogjs-router-debug.page-jzggTA45.mjs.map +0 -1
- package/fesm2022/analogjs-router-server-actions.mjs.map +0 -1
- package/fesm2022/analogjs-router-server.mjs.map +0 -1
- package/fesm2022/analogjs-router-tokens.mjs.map +0 -1
- package/fesm2022/analogjs-router.mjs.map +0 -1
- package/types/analogjs-router-server-actions.d.ts +0 -16
- package/types/analogjs-router-server.d.ts +0 -28
- package/types/analogjs-router-tokens.d.ts +0 -22
- package/types/analogjs-router.d.ts +0 -268
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import type { H3Event } from 'nitro/h3';
|
|
3
|
+
export type DefineServerRouteResult = Response | unknown;
|
|
4
|
+
export interface ServerRouteHandler<TQuery = unknown, TBody = unknown, TResult = unknown> {
|
|
5
|
+
(event: H3Event): Promise<Response>;
|
|
6
|
+
readonly _types: {
|
|
7
|
+
readonly query: TQuery;
|
|
8
|
+
readonly body: TBody;
|
|
9
|
+
readonly result: TResult;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export type InferRouteQuery<T> = T extends ServerRouteHandler<infer Q, any, any> ? Q : never;
|
|
13
|
+
export type InferRouteBody<T> = T extends ServerRouteHandler<any, infer B, any> ? B : never;
|
|
14
|
+
export type InferRouteResult<T> = T extends ServerRouteHandler<any, any, infer R> ? Exclude<R, Response> : never;
|
|
15
|
+
type OptionalSchema = StandardSchemaV1 | undefined;
|
|
16
|
+
type InferSchema<TSchema extends OptionalSchema, TFallback = unknown> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
|
|
17
|
+
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;
|
|
18
|
+
export interface DefineServerRouteContext<TInput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined> {
|
|
19
|
+
data: ResolveDataSchema<TInput, TQuery, TBody>;
|
|
20
|
+
query: InferSchema<TQuery, undefined>;
|
|
21
|
+
body: InferSchema<TBody, undefined>;
|
|
22
|
+
params: InferSchema<TParams, H3Event['context']['params']>;
|
|
23
|
+
event: H3Event;
|
|
24
|
+
}
|
|
25
|
+
export 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> {
|
|
26
|
+
input?: TInput;
|
|
27
|
+
query?: TQuery;
|
|
28
|
+
body?: TBody;
|
|
29
|
+
params?: TParams;
|
|
30
|
+
output?: TOutput;
|
|
31
|
+
handler: (context: DefineServerRouteContext<TInput, TQuery, TBody, TParams>) => Promise<TResult> | TResult;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates an h3-compatible event handler with Standard Schema validation.
|
|
35
|
+
*
|
|
36
|
+
* - `input` schema validates the request body (POST/PUT/PATCH) or query
|
|
37
|
+
* params (GET). Returns 422 with `StandardSchemaV1.Issue[]` on failure.
|
|
38
|
+
* - `output` schema validates the response in development only (stripped
|
|
39
|
+
* in production for zero overhead). Logs a warning on mismatch.
|
|
40
|
+
* - Plain return values are serialized with `json(...)`; raw `Response`
|
|
41
|
+
* objects are returned unchanged.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { defineServerRoute } from '@analogjs/router/server/actions';
|
|
46
|
+
* import * as v from 'valibot';
|
|
47
|
+
*
|
|
48
|
+
* const Input = v.object({
|
|
49
|
+
* name: v.pipe(v.string(), v.minLength(1)),
|
|
50
|
+
* email: v.pipe(v.string(), v.email()),
|
|
51
|
+
* });
|
|
52
|
+
* const Output = v.object({
|
|
53
|
+
* id: v.string(),
|
|
54
|
+
* name: v.string(),
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* export default defineServerRoute({
|
|
58
|
+
* input: Input,
|
|
59
|
+
* output: Output,
|
|
60
|
+
* handler: async ({ data }) => {
|
|
61
|
+
* const user = await db.users.create(data);
|
|
62
|
+
* return user;
|
|
63
|
+
* },
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
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<TQuery, undefined>, InferSchema<TBody, undefined>, TResult>;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { PageServerAction } from './actions';
|
|
2
|
+
export { json, redirect, fail } from './actions';
|
|
3
|
+
export { defineAction } from './define-action';
|
|
4
|
+
export type { DefineActionContext, DefineActionOptions } from './define-action';
|
|
5
|
+
export { defineServerRoute } from './define-server-route';
|
|
6
|
+
export type { DefineServerRouteContext, DefineServerRouteOptions, DefineServerRouteResult, ServerRouteHandler, InferRouteQuery, InferRouteBody, InferRouteResult, } from './define-server-route';
|
|
7
|
+
export { definePageLoad } from './define-page-load';
|
|
8
|
+
export type { PageLoadContext, DefinePageLoadOptions, } from './define-page-load';
|
|
9
|
+
export { validateWithSchema } from './validate';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type RequestEntryValue = string | File;
|
|
2
|
+
type ParsedRequestValue = RequestEntryValue | RequestEntryValue[];
|
|
3
|
+
export declare function parseSearchParams(searchParams: URLSearchParams): Record<string, ParsedRequestValue>;
|
|
4
|
+
export declare function parseFormData(formData: FormData): Record<string, ParsedRequestValue>;
|
|
5
|
+
export declare function parseRequestData(event: {
|
|
6
|
+
method: string;
|
|
7
|
+
headers: Headers;
|
|
8
|
+
}): Promise<unknown>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
/**
|
|
3
|
+
* Validates unknown input against a Standard Schema.
|
|
4
|
+
*
|
|
5
|
+
* Handles both sync and async `validate` implementations — the Standard
|
|
6
|
+
* Schema spec allows either return shape.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateWithSchema<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<T>>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StaticProvider } from '@angular/core';
|
|
2
|
+
import { ServerInternalFetch, ServerRequest, ServerResponse } from '@analogjs/router/tokens';
|
|
3
|
+
export declare function provideServerContext({ req, res, fetch, }: {
|
|
4
|
+
req: ServerRequest;
|
|
5
|
+
res: ServerResponse;
|
|
6
|
+
fetch?: ServerInternalFetch;
|
|
7
|
+
}): StaticProvider[];
|
|
8
|
+
export declare function getBaseUrl(req: ServerRequest): string;
|
|
9
|
+
export declare function getRequestProtocol(req: ServerRequest, opts?: {
|
|
10
|
+
xForwardedProto?: boolean;
|
|
11
|
+
}): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ApplicationConfig, Provider, Type } from '@angular/core';
|
|
2
|
+
import type { ServerContext } from '@analogjs/router/tokens';
|
|
3
|
+
/**
|
|
4
|
+
* Returns a function that accepts the navigation URL,
|
|
5
|
+
* the root HTML, and server context.
|
|
6
|
+
*
|
|
7
|
+
* @param rootComponent
|
|
8
|
+
* @param config
|
|
9
|
+
* @param platformProviders
|
|
10
|
+
* @returns Promise<string | Reponse>
|
|
11
|
+
*/
|
|
12
|
+
export declare function render(rootComponent: Type<unknown>, config: ApplicationConfig, platformProviders?: Provider[]): (url: string, document: string, serverContext: ServerContext) => Promise<string | Response>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ApplicationConfig } from '@angular/core';
|
|
2
|
+
import { ServerContext } from '@analogjs/router/tokens';
|
|
3
|
+
export declare function serverComponentRequest(serverContext: ServerContext): string | undefined;
|
|
4
|
+
export declare function renderServerComponent(url: string, serverContext: ServerContext, config?: ApplicationConfig): Promise<Response>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InjectionToken, Provider } from '@angular/core';
|
|
2
|
+
export declare const STATIC_PROPS: InjectionToken<Record<string, any>>;
|
|
3
|
+
export declare function provideStaticProps<T = Record<string, any>>(props: T): Provider;
|
|
4
|
+
export declare function injectStaticProps(): Record<string, any>;
|
|
5
|
+
export declare function injectStaticOutputs<T>(): {
|
|
6
|
+
set(data: T): void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type { RouteExport } from './lib/models';
|
|
2
|
+
export type { Files } from './lib/routes';
|
|
3
|
+
export { routes, createRoutes } from './lib/routes';
|
|
4
|
+
export { defineRouteMeta, injectActivatedRoute, injectRouter, } from './lib/define-route';
|
|
5
|
+
export { RouteMeta } from './lib/models';
|
|
6
|
+
export { provideFileRouter, withExtraRoutes } from './lib/provide-file-router';
|
|
7
|
+
export { MetaTag } from './lib/meta-tags';
|
|
8
|
+
export { PageServerLoad, LoadResult, LoadDataResult } from './lib/route-types';
|
|
9
|
+
export { injectLoad, injectLoadData } from './lib/inject-load';
|
|
10
|
+
export { getLoadResolver } from './lib/get-load-resolver';
|
|
11
|
+
export { requestContextInterceptor } from './lib/request-context';
|
|
12
|
+
export { injectRouteEndpointURL } from './lib/inject-route-endpoint-url';
|
|
13
|
+
export { FormAction } from './lib/form-action.directive';
|
|
14
|
+
export { injectDebugRoutes } from './lib/debug/routes';
|
|
15
|
+
export { withDebugRoutes } from './lib/debug';
|
|
16
|
+
export { ServerOnly } from './lib/server.component';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HttpHandlerFn, HttpRequest, HttpEvent } from '@angular/common/http';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ServerRequest } from '@analogjs/router/tokens';
|
|
4
|
+
export declare function cookieInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn, location?: object, serverRequest?: ServerRequest | null): Observable<HttpEvent<unknown>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OnInit } from '@angular/core';
|
|
2
|
+
import { DebugRoute } from './routes';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
type CollectedRoute = {
|
|
5
|
+
path: string;
|
|
6
|
+
filename: string;
|
|
7
|
+
file: string;
|
|
8
|
+
isLayout: boolean;
|
|
9
|
+
};
|
|
10
|
+
export default class DebugRoutesComponent implements OnInit {
|
|
11
|
+
collectedRoutes: CollectedRoute[];
|
|
12
|
+
debugRoutes: (import('@angular/router').Route & DebugRoute)[];
|
|
13
|
+
ngOnInit(): void;
|
|
14
|
+
traverseRoutes(routes: DebugRoute[], parent?: string): void;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DebugRoutesComponent, never>;
|
|
16
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DebugRoutesComponent, "analogjs-debug-routes-page", never, {}, {}, never, never, true, never>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EnvironmentProviders, Provider } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* Provides routes that provide additional
|
|
4
|
+
* pages for displaying and debugging
|
|
5
|
+
* routes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withDebugRoutes(): {
|
|
8
|
+
ɵkind: number;
|
|
9
|
+
ɵproviders: (Provider | EnvironmentProviders)[];
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Route } from '@angular/router';
|
|
3
|
+
export declare const DEBUG_ROUTES: InjectionToken<(Route & DebugRoute)[]>;
|
|
4
|
+
export type DebugRoute = {
|
|
5
|
+
path: string;
|
|
6
|
+
filename: string;
|
|
7
|
+
isLayout: boolean;
|
|
8
|
+
children?: DebugRoute[];
|
|
9
|
+
};
|
|
10
|
+
export declare function injectDebugRoutes(): (Route & DebugRoute)[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Route as NgRoute, Router } from '@angular/router';
|
|
2
|
+
import { ActivatedRoute } from '@angular/router';
|
|
3
|
+
type RouteOmitted = 'component' | 'loadComponent' | 'loadChildren' | 'path' | 'pathMatch';
|
|
4
|
+
type RestrictedRoute = Omit<NgRoute, RouteOmitted>;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `RouteMeta` type instead.
|
|
7
|
+
* For more info see: https://github.com/analogjs/analog/issues/223
|
|
8
|
+
*
|
|
9
|
+
* Defines additional route config metadata. This
|
|
10
|
+
* object is merged into the route config with
|
|
11
|
+
* the predefined file-based route.
|
|
12
|
+
*
|
|
13
|
+
* @usageNotes
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
16
|
+
* import { Component } from '@angular/core';
|
|
17
|
+
* import { defineRouteMeta } from '@analogjs/router';
|
|
18
|
+
*
|
|
19
|
+
* export const routeMeta = defineRouteMeta({
|
|
20
|
+
* title: 'Welcome'
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* @Component({
|
|
24
|
+
* template: `Home`,
|
|
25
|
+
* standalone: true,
|
|
26
|
+
* })
|
|
27
|
+
* export default class HomeComponent {}
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param route
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare const defineRouteMeta: (route: RestrictedRoute) => RestrictedRoute;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the instance of Angular Router
|
|
36
|
+
*
|
|
37
|
+
* @returns The router
|
|
38
|
+
*/
|
|
39
|
+
export declare const injectRouter: () => Router;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the instance of the Activate Route for the component
|
|
42
|
+
*
|
|
43
|
+
* @returns The activated route
|
|
44
|
+
*/
|
|
45
|
+
export declare const injectActivatedRoute: () => ActivatedRoute;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type InputSignal, type OutputEmitterRef, type WritableSignal } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export type FormActionState = 'submitting' | 'error' | 'redirect' | 'success' | 'navigate';
|
|
4
|
+
export declare class FormAction {
|
|
5
|
+
action: InputSignal<string>;
|
|
6
|
+
onSuccess: OutputEmitterRef<unknown>;
|
|
7
|
+
onError: OutputEmitterRef<unknown>;
|
|
8
|
+
state: OutputEmitterRef<FormActionState>;
|
|
9
|
+
private router;
|
|
10
|
+
private route;
|
|
11
|
+
protected currentState: WritableSignal<FormActionState | 'idle'>;
|
|
12
|
+
/** Cached during construction (injection context) so inject() works. */
|
|
13
|
+
private _endpointUrl;
|
|
14
|
+
submitted($event: any): void;
|
|
15
|
+
private _handleGet;
|
|
16
|
+
private _handlePost;
|
|
17
|
+
private _getExplicitAction;
|
|
18
|
+
private _getGetPath;
|
|
19
|
+
private _getPostPath;
|
|
20
|
+
private _emitState;
|
|
21
|
+
private _navigateTo;
|
|
22
|
+
private _isJSON;
|
|
23
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FormAction, never>;
|
|
24
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<FormAction, "form[action],form[method]", never, { "action": { "alias": "action"; "required": false; "isSignal": true; }; }, { "onSuccess": "onSuccess"; "onError": "onError"; "state": "state"; }, never, never, true, never>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActivatedRouteSnapshot } from '@angular/router';
|
|
2
|
+
/**
|
|
3
|
+
* Get server load resolver data for the route
|
|
4
|
+
*
|
|
5
|
+
* @param route Provides the route to get server load resolver
|
|
6
|
+
* @returns Returns server load resolver data for the route
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLoadResolver<T>(route: ActivatedRouteSnapshot): Promise<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Injector } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { LoadDataResult, PageServerLoad } from './route-types';
|
|
4
|
+
export declare function injectLoad<T extends (pageServerLoad: PageServerLoad) => Promise<any>>(options?: {
|
|
5
|
+
injector?: Injector;
|
|
6
|
+
}): Observable<Awaited<ReturnType<T>>>;
|
|
7
|
+
export declare function injectLoadData<T extends (pageServerLoad: PageServerLoad) => Promise<any>>(options?: {
|
|
8
|
+
injector?: Injector;
|
|
9
|
+
}): Observable<LoadDataResult<T>>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const ROUTE_META_TAGS_KEY: unique symbol;
|
|
2
|
+
declare const CHARSET_KEY = "charset";
|
|
3
|
+
declare const HTTP_EQUIV_KEY = "httpEquiv";
|
|
4
|
+
declare const NAME_KEY = "name";
|
|
5
|
+
declare const PROPERTY_KEY = "property";
|
|
6
|
+
declare const CONTENT_KEY = "content";
|
|
7
|
+
declare const ITEMPROP_KEY = "itemprop";
|
|
8
|
+
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>);
|
|
9
|
+
type CharsetMetaTag = {
|
|
10
|
+
[CHARSET_KEY]: string;
|
|
11
|
+
};
|
|
12
|
+
type HttpEquivMetaTag = {
|
|
13
|
+
[HTTP_EQUIV_KEY]: string;
|
|
14
|
+
[CONTENT_KEY]: string;
|
|
15
|
+
};
|
|
16
|
+
type NameMetaTag = {
|
|
17
|
+
[NAME_KEY]: string;
|
|
18
|
+
[CONTENT_KEY]: string;
|
|
19
|
+
};
|
|
20
|
+
type PropertyMetaTag = {
|
|
21
|
+
[PROPERTY_KEY]: string;
|
|
22
|
+
[CONTENT_KEY]: string;
|
|
23
|
+
};
|
|
24
|
+
type ItempropMetaTag = {
|
|
25
|
+
[ITEMPROP_KEY]: string;
|
|
26
|
+
[CONTENT_KEY]: string;
|
|
27
|
+
};
|
|
28
|
+
type MetaTagKey = typeof CHARSET_KEY | typeof HTTP_EQUIV_KEY | typeof NAME_KEY | typeof PROPERTY_KEY | typeof ITEMPROP_KEY;
|
|
29
|
+
type ExcludeRestMetaTagKeys<Key extends MetaTagKey> = {
|
|
30
|
+
[K in Exclude<MetaTagKey, Key>]?: never;
|
|
31
|
+
};
|
|
32
|
+
export declare function updateMetaTagsOnRouteChange(): void;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Type } from '@angular/core';
|
|
2
|
+
import { CanActivateChildFn, CanActivateFn, CanDeactivateFn, CanMatchFn, DeprecatedGuard, ResolveFn, Route } from '@angular/router';
|
|
3
|
+
import { defineRouteMeta } from './define-route';
|
|
4
|
+
import { MetaTag } from './meta-tags';
|
|
5
|
+
type OmittedRouteProps = 'path' | 'matcher' | 'component' | 'loadComponent' | 'children' | 'loadChildren' | 'canLoad' | 'outlet';
|
|
6
|
+
export type RouteConfig = Omit<Route, OmittedRouteProps>;
|
|
7
|
+
export interface DefaultRouteMeta extends Omit<Route, OmittedRouteProps | keyof RedirectRouteMeta> {
|
|
8
|
+
canActivate?: CanActivateFn[] | DeprecatedGuard[];
|
|
9
|
+
canActivateChild?: CanActivateChildFn[];
|
|
10
|
+
canDeactivate?: CanDeactivateFn<unknown>[];
|
|
11
|
+
canMatch?: CanMatchFn[];
|
|
12
|
+
resolve?: {
|
|
13
|
+
[key: string | symbol]: ResolveFn<unknown>;
|
|
14
|
+
};
|
|
15
|
+
title?: string | ResolveFn<string>;
|
|
16
|
+
meta?: MetaTag[] | ResolveFn<MetaTag[]>;
|
|
17
|
+
}
|
|
18
|
+
export interface RedirectRouteMeta {
|
|
19
|
+
redirectTo: string;
|
|
20
|
+
pathMatch?: Route['pathMatch'];
|
|
21
|
+
}
|
|
22
|
+
export type RouteMeta = (DefaultRouteMeta & {
|
|
23
|
+
redirectTo?: never;
|
|
24
|
+
}) | RedirectRouteMeta;
|
|
25
|
+
export type RouteExport = {
|
|
26
|
+
default: Type<unknown>;
|
|
27
|
+
routeMeta?: RouteMeta | ReturnType<typeof defineRouteMeta>;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { RouterFeatures, Routes } from '@angular/router';
|
|
3
|
+
/**
|
|
4
|
+
* Sets up providers for the Angular router, and registers
|
|
5
|
+
* file-based routes. Additional features can be provided
|
|
6
|
+
* to further configure the behavior of the router.
|
|
7
|
+
*
|
|
8
|
+
* @param features
|
|
9
|
+
* @returns Providers and features to configure the router with routes
|
|
10
|
+
*/
|
|
11
|
+
export declare function provideFileRouter(...features: RouterFeatures[]): EnvironmentProviders;
|
|
12
|
+
/**
|
|
13
|
+
* Provides extra custom routes in addition to the routes
|
|
14
|
+
* discovered from the filesystem-based routing. These routes are
|
|
15
|
+
* inserted before the filesystem-based routes, and take priority in
|
|
16
|
+
* route matching.
|
|
17
|
+
*/
|
|
18
|
+
export declare function withExtraRoutes(routes: Routes): RouterFeatures;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
/**
|
|
4
|
+
* Interceptor that is server-aware when making HttpClient requests.
|
|
5
|
+
* Server-side requests use the full URL
|
|
6
|
+
* Prerendering uses the internal Nitro $fetch function, along with state transfer
|
|
7
|
+
* Client-side requests use the window.location.origin
|
|
8
|
+
*
|
|
9
|
+
* @param req HttpRequest<unknown>
|
|
10
|
+
* @param next HttpHandlerFn
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function requestContextInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { H3Event, H3EventContext } from 'nitro/h3';
|
|
2
|
+
import type { $Fetch } from 'nitro/types';
|
|
3
|
+
export type NodeContext = NonNullable<H3Event['node']>;
|
|
4
|
+
export type PageServerLoad = {
|
|
5
|
+
params: H3EventContext['params'];
|
|
6
|
+
req: NodeContext['req'];
|
|
7
|
+
res: NonNullable<NodeContext['res']>;
|
|
8
|
+
fetch: $Fetch;
|
|
9
|
+
event: H3Event;
|
|
10
|
+
};
|
|
11
|
+
export type LoadResult<A extends (pageServerLoad: PageServerLoad) => Promise<any>> = Awaited<ReturnType<A>>;
|
|
12
|
+
export type LoadDataResult<A extends (pageServerLoad: PageServerLoad) => Promise<any>> = Exclude<LoadResult<A>, Response>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Route } from '@angular/router';
|
|
2
|
+
import type { RouteExport } from './models';
|
|
3
|
+
/**
|
|
4
|
+
* This variable reference is replaced with a glob of all page routes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ANALOG_ROUTE_FILES: {};
|
|
7
|
+
/**
|
|
8
|
+
* This variable reference is replaced with a glob of all content routes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ANALOG_CONTENT_ROUTE_FILES: {};
|
|
11
|
+
export type Files = Record<string, () => Promise<RouteExport | string>>;
|
|
12
|
+
/**
|
|
13
|
+
* A function used to parse list of files and create configuration of routes.
|
|
14
|
+
*
|
|
15
|
+
* @param files
|
|
16
|
+
* @returns Array of routes
|
|
17
|
+
*/
|
|
18
|
+
export declare function createRoutes(files: Files, debug?: boolean): Route[];
|
|
19
|
+
export declare const routes: Route[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { InputSignal, OutputEmitterRef, WritableSignal } from '@angular/core';
|
|
2
|
+
import { SafeHtml } from '@angular/platform-browser';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
type ServerProps = Record<string, any>;
|
|
5
|
+
type ServerOutputs = Record<string, any>;
|
|
6
|
+
/**
|
|
7
|
+
* @description
|
|
8
|
+
* Component that defines the bridge between the client and server-only
|
|
9
|
+
* components. The component passes the component ID and props to the server
|
|
10
|
+
* and retrieves the rendered HTML and outputs from the server-only component.
|
|
11
|
+
*
|
|
12
|
+
* Status: experimental
|
|
13
|
+
*/
|
|
14
|
+
export declare class ServerOnly {
|
|
15
|
+
component: InputSignal<string>;
|
|
16
|
+
props: InputSignal<ServerProps | undefined>;
|
|
17
|
+
outputs: OutputEmitterRef<ServerOutputs>;
|
|
18
|
+
private http;
|
|
19
|
+
private sanitizer;
|
|
20
|
+
protected content: WritableSignal<SafeHtml>;
|
|
21
|
+
private route;
|
|
22
|
+
private baseURL;
|
|
23
|
+
private transferState;
|
|
24
|
+
constructor();
|
|
25
|
+
updateContent(content: {
|
|
26
|
+
html: string;
|
|
27
|
+
outputs: ServerOutputs;
|
|
28
|
+
}): void;
|
|
29
|
+
getComponentUrl(componentId: string): string;
|
|
30
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ServerOnly, never>;
|
|
31
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ServerOnly, "server-only,ServerOnly,Server", never, { "component": { "alias": "component"; "required": true; "isSignal": true; }; "props": { "alias": "props"; "required": false; "isSignal": true; }; }, { "outputs": "outputs"; }, never, never, true, never>;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EnvironmentProviders, StateKey } from '@angular/core';
|
|
2
|
+
import type { DehydratedState } from '@tanstack/angular-query-experimental';
|
|
3
|
+
export declare const ANALOG_QUERY_STATE_KEY: StateKey<DehydratedState>;
|
|
4
|
+
export declare function provideAnalogQuery(): EnvironmentProviders;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HttpClient } from '@angular/common/http';
|
|
2
|
+
import type { CreateQueryOptions, CreateMutationOptions, CreateInfiniteQueryOptions, DefaultError, InfiniteData, QueryKey } from '@tanstack/angular-query-experimental';
|
|
3
|
+
import type { ServerRouteHandler, InferRouteQuery, InferRouteBody, InferRouteResult } from '@analogjs/router/server/actions';
|
|
4
|
+
export declare function serverQueryOptions<TRoute extends ServerRouteHandler<any, any, any>, TError = DefaultError, TData = InferRouteResult<TRoute>, TQueryKey extends QueryKey = QueryKey>(http: HttpClient, url: string, options: {
|
|
5
|
+
queryKey: TQueryKey;
|
|
6
|
+
query?: InferRouteQuery<TRoute>;
|
|
7
|
+
} & Omit<CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey>, 'queryKey' | 'queryFn'>): CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey>;
|
|
8
|
+
export declare function serverMutationOptions<TRoute extends ServerRouteHandler<any, any, any>, TError = DefaultError, TOnMutateResult = unknown>(http: HttpClient, url: string, options?: Omit<CreateMutationOptions<InferRouteResult<TRoute>, TError, InferRouteBody<TRoute>, TOnMutateResult>, 'mutationFn'>): CreateMutationOptions<InferRouteResult<TRoute>, TError, InferRouteBody<TRoute>, TOnMutateResult>;
|
|
9
|
+
export declare function serverInfiniteQueryOptions<TRoute extends ServerRouteHandler<any, any, any>, TError = DefaultError, TData = InfiniteData<InferRouteResult<TRoute>>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(http: HttpClient, url: string, options: {
|
|
10
|
+
queryKey: TQueryKey;
|
|
11
|
+
query: (context: {
|
|
12
|
+
pageParam: TPageParam;
|
|
13
|
+
}) => InferRouteQuery<TRoute>;
|
|
14
|
+
initialPageParam: TPageParam;
|
|
15
|
+
getNextPageParam: (lastPage: InferRouteResult<TRoute>, allPages: InferRouteResult<TRoute>[]) => TPageParam | undefined | null;
|
|
16
|
+
} & Omit<CreateInfiniteQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey, TPageParam>, 'queryKey' | 'queryFn' | 'initialPageParam' | 'getNextPageParam'>): CreateInfiniteQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey, TPageParam>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import type { $Fetch } from 'nitro/types';
|
|
3
|
+
import type { IncomingMessage, ServerResponse as NodeServerResponse } from 'node:http';
|
|
4
|
+
export type ServerRequest = IncomingMessage & {
|
|
5
|
+
originalUrl: string;
|
|
6
|
+
};
|
|
7
|
+
export type ServerResponse = NodeServerResponse;
|
|
8
|
+
export type ServerInternalFetch = $Fetch;
|
|
9
|
+
export type ServerContext = {
|
|
10
|
+
req: ServerRequest;
|
|
11
|
+
res: ServerResponse;
|
|
12
|
+
fetch?: ServerInternalFetch;
|
|
13
|
+
};
|
|
14
|
+
export declare const REQUEST: InjectionToken<ServerRequest>;
|
|
15
|
+
export declare const RESPONSE: InjectionToken<ServerResponse>;
|
|
16
|
+
export declare const BASE_URL: InjectionToken<string>;
|
|
17
|
+
export declare const INTERNAL_FETCH: InjectionToken<ServerInternalFetch>;
|
|
18
|
+
export declare const API_PREFIX: InjectionToken<string>;
|
|
19
|
+
export declare function injectRequest(): ServerRequest | null;
|
|
20
|
+
export declare function injectResponse(): ServerResponse | null;
|
|
21
|
+
export declare function injectBaseURL(): string | null;
|
|
22
|
+
export declare function injectInternalServerFetch(): ServerInternalFetch | null;
|
|
23
|
+
export declare function injectAPIPrefix(): string;
|