@analogjs/router 2.0.0-alpha.9 → 2.0.0-beta.2

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 (38) hide show
  1. package/fesm2022/{analogjs-router-debug.page-e5DJlNv3.mjs → analogjs-router-debug.page-C7mEWSZu.mjs} +4 -4
  2. package/fesm2022/{analogjs-router-debug.page-e5DJlNv3.mjs.map → analogjs-router-debug.page-C7mEWSZu.mjs.map} +1 -1
  3. package/fesm2022/analogjs-router-server-actions.mjs.map +1 -1
  4. package/fesm2022/analogjs-router-server.mjs +4 -12
  5. package/fesm2022/analogjs-router-server.mjs.map +1 -1
  6. package/fesm2022/analogjs-router.mjs +12 -12
  7. package/fesm2022/analogjs-router.mjs.map +1 -1
  8. package/index.d.ts +265 -16
  9. package/package.json +8 -4
  10. package/server/actions/index.d.ts +16 -1
  11. package/server/index.d.ts +28 -4
  12. package/tokens/index.d.ts +16 -12
  13. package/lib/cache-key.d.ts +0 -3
  14. package/lib/constants.d.ts +0 -2
  15. package/lib/cookie-interceptor.d.ts +0 -2
  16. package/lib/debug/debug.page.d.ts +0 -17
  17. package/lib/debug/index.d.ts +0 -16
  18. package/lib/debug/routes.d.ts +0 -10
  19. package/lib/define-route.d.ts +0 -46
  20. package/lib/endpoints.d.ts +0 -5
  21. package/lib/form-action.directive.d.ts +0 -19
  22. package/lib/get-load-resolver.d.ts +0 -8
  23. package/lib/inject-load.d.ts +0 -6
  24. package/lib/inject-route-endpoint-url.d.ts +0 -2
  25. package/lib/markdown-helpers.d.ts +0 -2
  26. package/lib/meta-tags.d.ts +0 -28
  27. package/lib/models.d.ts +0 -29
  28. package/lib/provide-file-router.d.ts +0 -18
  29. package/lib/request-context.d.ts +0 -12
  30. package/lib/route-config.d.ts +0 -2
  31. package/lib/route-types.d.ts +0 -10
  32. package/lib/routes.d.ts +0 -19
  33. package/lib/server.component.d.ts +0 -32
  34. package/server/actions/actions.d.ts +0 -12
  35. package/server/provide-server-context.d.ts +0 -10
  36. package/server/render.d.ts +0 -12
  37. package/server/server-component-render.d.ts +0 -4
  38. package/server/tokens.d.ts +0 -7
package/index.d.ts CHANGED
@@ -1,16 +1,265 @@
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 } from './lib/route-types';
9
- export { injectLoad } 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';
1
+ import * as _angular_core from '@angular/core';
2
+ import { Type, EnvironmentProviders, Injector } from '@angular/core';
3
+ import * as _angular_router from '@angular/router';
4
+ import { Route, ActivatedRoute, Router, CanActivateFn, DeprecatedGuard, CanActivateChildFn, CanDeactivateFn, CanMatchFn, ResolveFn, RouterFeatures, Routes, ActivatedRouteSnapshot } from '@angular/router';
5
+ import { H3EventContext, H3Event } from 'h3';
6
+ import { $Fetch } from 'nitropack';
7
+ import * as rxjs from 'rxjs';
8
+ import { Observable } from 'rxjs';
9
+ import * as _angular_common_module_d from '@angular/common/module.d';
10
+ import { HttpRequest, HttpHandlerFn } from '@angular/common/http';
11
+ import { SafeHtml } from '@angular/platform-browser';
12
+
13
+ type RouteOmitted = 'component' | 'loadComponent' | 'loadChildren' | 'path' | 'pathMatch';
14
+ type RestrictedRoute = Omit<Route, RouteOmitted>;
15
+ /**
16
+ * @deprecated Use `RouteMeta` type instead.
17
+ * For more info see: https://github.com/analogjs/analog/issues/223
18
+ *
19
+ * Defines additional route config metadata. This
20
+ * object is merged into the route config with
21
+ * the predefined file-based route.
22
+ *
23
+ * @usageNotes
24
+ *
25
+ * ```
26
+ * import { Component } from '@angular/core';
27
+ * import { defineRouteMeta } from '@analogjs/router';
28
+ *
29
+ * export const routeMeta = defineRouteMeta({
30
+ * title: 'Welcome'
31
+ * });
32
+ *
33
+ * @Component({
34
+ * template: `Home`,
35
+ * standalone: true,
36
+ * })
37
+ * export default class HomeComponent {}
38
+ * ```
39
+ *
40
+ * @param route
41
+ * @returns
42
+ */
43
+ declare const defineRouteMeta: (route: RestrictedRoute) => RestrictedRoute;
44
+ /**
45
+ * Returns the instance of Angular Router
46
+ *
47
+ * @returns The router
48
+ */
49
+ declare const injectRouter: () => Router;
50
+ /**
51
+ * Returns the instance of the Activate Route for the component
52
+ *
53
+ * @returns The activated route
54
+ */
55
+ declare const injectActivatedRoute: () => ActivatedRoute;
56
+
57
+ declare const CHARSET_KEY = "charset";
58
+ declare const HTTP_EQUIV_KEY = "httpEquiv";
59
+ declare const NAME_KEY = "name";
60
+ declare const PROPERTY_KEY = "property";
61
+ declare const CONTENT_KEY = "content";
62
+ type MetaTag = (CharsetMetaTag & ExcludeRestMetaTagKeys<typeof CHARSET_KEY>) | (HttpEquivMetaTag & ExcludeRestMetaTagKeys<typeof HTTP_EQUIV_KEY>) | (NameMetaTag & ExcludeRestMetaTagKeys<typeof NAME_KEY>) | (PropertyMetaTag & ExcludeRestMetaTagKeys<typeof PROPERTY_KEY>);
63
+ type CharsetMetaTag = {
64
+ [CHARSET_KEY]: string;
65
+ };
66
+ type HttpEquivMetaTag = {
67
+ [HTTP_EQUIV_KEY]: string;
68
+ [CONTENT_KEY]: string;
69
+ };
70
+ type NameMetaTag = {
71
+ [NAME_KEY]: string;
72
+ [CONTENT_KEY]: string;
73
+ };
74
+ type PropertyMetaTag = {
75
+ [PROPERTY_KEY]: string;
76
+ [CONTENT_KEY]: string;
77
+ };
78
+ type MetaTagKey = typeof CHARSET_KEY | typeof HTTP_EQUIV_KEY | typeof NAME_KEY | typeof PROPERTY_KEY;
79
+ type ExcludeRestMetaTagKeys<Key extends MetaTagKey> = {
80
+ [K in Exclude<MetaTagKey, Key>]?: never;
81
+ };
82
+
83
+ type OmittedRouteProps = 'path' | 'matcher' | 'component' | 'loadComponent' | 'children' | 'loadChildren' | 'canLoad' | 'outlet';
84
+ interface DefaultRouteMeta extends Omit<Route, OmittedRouteProps | keyof RedirectRouteMeta> {
85
+ canActivate?: CanActivateFn[] | DeprecatedGuard[];
86
+ canActivateChild?: CanActivateChildFn[];
87
+ canDeactivate?: CanDeactivateFn<unknown>[];
88
+ canMatch?: CanMatchFn[];
89
+ resolve?: {
90
+ [key: string | symbol]: ResolveFn<unknown>;
91
+ };
92
+ title?: string | ResolveFn<string>;
93
+ meta?: MetaTag[] | ResolveFn<MetaTag[]>;
94
+ }
95
+ interface RedirectRouteMeta {
96
+ redirectTo: string;
97
+ pathMatch?: Route['pathMatch'];
98
+ }
99
+ type RouteMeta = (DefaultRouteMeta & {
100
+ redirectTo?: never;
101
+ }) | RedirectRouteMeta;
102
+ type RouteExport = {
103
+ default: Type<unknown>;
104
+ routeMeta?: RouteMeta | ReturnType<typeof defineRouteMeta>;
105
+ };
106
+
107
+ type Files = Record<string, () => Promise<RouteExport | string>>;
108
+ /**
109
+ * A function used to parse list of files and create configuration of routes.
110
+ *
111
+ * @param files
112
+ * @returns Array of routes
113
+ */
114
+ declare function createRoutes(files: Files, debug?: boolean): Route[];
115
+ declare const routes: Route[];
116
+
117
+ /**
118
+ * Sets up providers for the Angular router, and registers
119
+ * file-based routes. Additional features can be provided
120
+ * to further configure the behavior of the router.
121
+ *
122
+ * @param features
123
+ * @returns Providers and features to configure the router with routes
124
+ */
125
+ declare function provideFileRouter(...features: RouterFeatures[]): EnvironmentProviders;
126
+ /**
127
+ * Provides extra custom routes in addition to the routes
128
+ * discovered from the filesystem-based routing. These routes are
129
+ * inserted before the filesystem-based routes, and take priority in
130
+ * route matching.
131
+ */
132
+ declare function withExtraRoutes(routes: Routes): RouterFeatures;
133
+
134
+ type PageServerLoad = {
135
+ params: H3EventContext['params'];
136
+ req: H3Event['node']['req'];
137
+ res: H3Event['node']['res'];
138
+ fetch: $Fetch;
139
+ event: H3Event;
140
+ };
141
+ type LoadResult<A extends (pageServerLoad: PageServerLoad) => Promise<any>> = Awaited<ReturnType<A>>;
142
+
143
+ declare function injectLoad<T extends (pageServerLoad: PageServerLoad) => Promise<any>>(options?: {
144
+ injector?: Injector;
145
+ }): Observable<Awaited<ReturnType<T>>>;
146
+
147
+ /**
148
+ * Get server load resolver data for the route
149
+ *
150
+ * @param route Provides the route to get server load resolver
151
+ * @returns Returns server load resolver data for the route
152
+ */
153
+ declare function getLoadResolver<T>(route: ActivatedRouteSnapshot): Promise<T>;
154
+
155
+ /**
156
+ * Interceptor that is server-aware when making HttpClient requests.
157
+ * Server-side requests use the full URL
158
+ * Prerendering uses the internal Nitro $fetch function, along with state transfer
159
+ * Client-side requests use the window.location.origin
160
+ *
161
+ * @param req HttpRequest<unknown>
162
+ * @param next HttpHandlerFn
163
+ * @returns
164
+ */
165
+ declare function requestContextInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): rxjs.Observable<_angular_common_module_d.HttpEvent<unknown>>;
166
+
167
+ declare function injectRouteEndpointURL(route: ActivatedRouteSnapshot): URL;
168
+
169
+ declare class FormAction {
170
+ action: _angular_core.InputSignal<string>;
171
+ onSuccess: _angular_core.OutputEmitterRef<unknown>;
172
+ onError: _angular_core.OutputEmitterRef<unknown>;
173
+ state: _angular_core.OutputEmitterRef<"error" | "navigate" | "redirect" | "submitting" | "success">;
174
+ private router;
175
+ private route;
176
+ private path;
177
+ submitted($event: {
178
+ target: HTMLFormElement;
179
+ } & Event): void;
180
+ private _handleGet;
181
+ private _handlePost;
182
+ private _getPath;
183
+ private _isJSON;
184
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormAction, never>;
185
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<FormAction, "form[action],form[method]", never, { "action": { "alias": "action"; "required": false; "isSignal": true; }; }, { "onSuccess": "onSuccess"; "onError": "onError"; "state": "state"; }, never, never, true, never>;
186
+ }
187
+
188
+ type DebugRoute = {
189
+ path: string;
190
+ filename: string;
191
+ isLayout: boolean;
192
+ children?: DebugRoute[];
193
+ };
194
+ declare function injectDebugRoutes(): (Route & DebugRoute)[];
195
+
196
+ type CollectedRoute = {
197
+ path: string;
198
+ filename: string;
199
+ file: string;
200
+ isLayout: boolean;
201
+ };
202
+ declare class DebugRoutesComponent {
203
+ collectedRoutes: CollectedRoute[];
204
+ debugRoutes: (_angular_router.Route & DebugRoute)[];
205
+ ngOnInit(): void;
206
+ traverseRoutes(routes: DebugRoute[], parent?: string): void;
207
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DebugRoutesComponent, never>;
208
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<DebugRoutesComponent, "analogjs-debug-routes-page", never, {}, {}, never, never, true, never>;
209
+ }
210
+
211
+ declare namespace __debug_page {
212
+ export {
213
+ DebugRoutesComponent as default,
214
+ };
215
+ }
216
+
217
+ /**
218
+ * Provides routes that provide additional
219
+ * pages for displaying and debugging
220
+ * routes.
221
+ */
222
+ declare function withDebugRoutes(): {
223
+ ɵkind: number;
224
+ ɵproviders: {
225
+ provide: _angular_core.InjectionToken<_angular_router.Route[][]>;
226
+ useValue: {
227
+ path: string;
228
+ loadComponent: () => Promise<typeof __debug_page>;
229
+ }[];
230
+ multi: boolean;
231
+ }[];
232
+ };
233
+
234
+ type ServerProps = Record<string, any>;
235
+ type ServerOutputs = Record<string, any>;
236
+ /**
237
+ * @description
238
+ * Component that defines the bridge between the client and server-only
239
+ * components. The component passes the component ID and props to the server
240
+ * and retrieves the rendered HTML and outputs from the server-only component.
241
+ *
242
+ * Status: experimental
243
+ */
244
+ declare class ServerOnly {
245
+ component: _angular_core.InputSignal<string>;
246
+ props: _angular_core.InputSignal<ServerProps | undefined>;
247
+ outputs: _angular_core.OutputEmitterRef<ServerOutputs>;
248
+ private http;
249
+ private sanitizer;
250
+ protected content: _angular_core.WritableSignal<SafeHtml>;
251
+ private route;
252
+ private baseURL;
253
+ private transferState;
254
+ constructor();
255
+ updateContent(content: {
256
+ html: string;
257
+ outputs: ServerOutputs;
258
+ }): void;
259
+ getComponentUrl(componentId: string): string;
260
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ServerOnly, never>;
261
+ static ɵcmp: _angular_core.ɵɵ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>;
262
+ }
263
+
264
+ export { FormAction, ServerOnly, createRoutes, defineRouteMeta, getLoadResolver, injectActivatedRoute, injectDebugRoutes, injectLoad, injectRouteEndpointURL, injectRouter, provideFileRouter, requestContextInterceptor, routes, withDebugRoutes, withExtraRoutes };
265
+ export type { Files, LoadResult, MetaTag, PageServerLoad, RouteExport, RouteMeta };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/router",
3
- "version": "2.0.0-alpha.9",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Filesystem-based routing for Angular",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
@@ -24,9 +24,9 @@
24
24
  "url": "https://github.com/sponsors/brandonroberts"
25
25
  },
26
26
  "peerDependencies": {
27
- "@analogjs/content": "^2.0.0-alpha.9",
28
- "@angular/core": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
29
- "@angular/router": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
27
+ "@analogjs/content": "^2.0.0-beta.2",
28
+ "@angular/core": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
29
+ "@angular/router": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0"
30
30
  },
31
31
  "dependencies": {
32
32
  "tslib": "^2.0.0"
@@ -43,6 +43,10 @@
43
43
  ],
44
44
  "migrations": "./migrations/migration.json"
45
45
  },
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "provenance": true
49
+ },
46
50
  "module": "fesm2022/analogjs-router.mjs",
47
51
  "typings": "index.d.ts",
48
52
  "exports": {
@@ -1 +1,16 @@
1
- export { PageServerAction, json, redirect, fail } from './actions';
1
+ import { H3EventContext, H3Event } from 'h3';
2
+ import { $Fetch } from 'nitropack';
3
+
4
+ type PageServerAction = {
5
+ params: H3EventContext['params'];
6
+ req: H3Event['node']['req'];
7
+ res: H3Event['node']['res'];
8
+ fetch: $Fetch;
9
+ event: H3Event;
10
+ };
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
+
15
+ export { fail, json, redirect };
16
+ export type { PageServerAction };
package/server/index.d.ts CHANGED
@@ -1,4 +1,28 @@
1
- export { provideServerContext } from './provide-server-context';
2
- export { injectStaticProps, injectStaticOutputs } from './tokens';
3
- export { serverComponentRequest, renderServerComponent, } from './server-component-render';
4
- export { render } from './render';
1
+ import { StaticProvider, ApplicationConfig, Type, Provider } from '@angular/core';
2
+ import { ServerRequest, ServerResponse, ServerContext } from '@analogjs/router/tokens';
3
+
4
+ declare function provideServerContext({ req, res, }: {
5
+ req: ServerRequest;
6
+ res: ServerResponse;
7
+ }): StaticProvider[];
8
+
9
+ declare function injectStaticProps(): Record<string, any>;
10
+ declare function injectStaticOutputs<T>(): {
11
+ set(data: T): void;
12
+ };
13
+
14
+ declare function serverComponentRequest(serverContext: ServerContext): string | undefined;
15
+ declare function renderServerComponent(url: string, serverContext: ServerContext, config?: ApplicationConfig): Promise<Response>;
16
+
17
+ /**
18
+ * Returns a function that accepts the navigation URL,
19
+ * the root HTML, and server context.
20
+ *
21
+ * @param rootComponent
22
+ * @param config
23
+ * @param platformProviders
24
+ * @returns Promise<string | Reponse>
25
+ */
26
+ declare function render(rootComponent: Type<unknown>, config: ApplicationConfig, platformProviders?: Provider[]): (url: string, document: string, serverContext: ServerContext) => Promise<string | Response>;
27
+
28
+ export { injectStaticOutputs, injectStaticProps, provideServerContext, render, renderServerComponent, serverComponentRequest };
package/tokens/index.d.ts CHANGED
@@ -1,18 +1,22 @@
1
1
  import { InjectionToken } from '@angular/core';
2
- import type { IncomingMessage, ServerResponse as NodeServerResponse } from 'node:http';
3
- export type ServerRequest = IncomingMessage & {
2
+ import { IncomingMessage, ServerResponse as ServerResponse$1 } from 'node:http';
3
+
4
+ type ServerRequest = IncomingMessage & {
4
5
  originalUrl: string;
5
6
  };
6
- export type ServerResponse = NodeServerResponse;
7
- export type ServerContext = {
7
+ type ServerResponse = ServerResponse$1;
8
+ type ServerContext = {
8
9
  req: ServerRequest;
9
10
  res: ServerResponse;
10
11
  };
11
- export declare const REQUEST: InjectionToken<ServerRequest>;
12
- export declare const RESPONSE: InjectionToken<ServerResponse>;
13
- export declare const BASE_URL: InjectionToken<string>;
14
- export declare const API_PREFIX: InjectionToken<string>;
15
- export declare function injectRequest(): ServerRequest | null;
16
- export declare function injectResponse(): ServerResponse | null;
17
- export declare function injectBaseURL(): string | null;
18
- export declare function injectAPIPrefix(): string;
12
+ declare const REQUEST: InjectionToken<ServerRequest>;
13
+ declare const RESPONSE: InjectionToken<ServerResponse>;
14
+ declare const BASE_URL: InjectionToken<string>;
15
+ declare const API_PREFIX: InjectionToken<string>;
16
+ declare function injectRequest(): ServerRequest | null;
17
+ declare function injectResponse(): ServerResponse | null;
18
+ declare function injectBaseURL(): string | null;
19
+ declare function injectAPIPrefix(): string;
20
+
21
+ export { API_PREFIX, BASE_URL, REQUEST, RESPONSE, injectAPIPrefix, injectBaseURL, injectRequest, injectResponse };
22
+ export type { ServerContext, ServerRequest, ServerResponse };
@@ -1,3 +0,0 @@
1
- import { HttpRequest } from '@angular/common/http';
2
- import { StateKey } from '@angular/core';
3
- export declare function makeCacheKey(request: HttpRequest<any>, mappedRequestUrl: string): StateKey<unknown>;
@@ -1,2 +0,0 @@
1
- export declare const ENDPOINT_EXTENSION = ".server.ts";
2
- export declare const APP_DIR = "src/app";
@@ -1,2 +0,0 @@
1
- import { HttpHandlerFn, HttpRequest } from '@angular/common/http';
2
- export declare function cookieInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn, location?: Object, serverRequest?: import("@analogjs/router/tokens").ServerRequest | null): import("rxjs").Observable<import("@angular/common/http").HttpEvent<unknown>>;
@@ -1,17 +0,0 @@
1
- import { DebugRoute } from './routes';
2
- import * as i0 from "@angular/core";
3
- type CollectedRoute = {
4
- path: string;
5
- filename: string;
6
- file: string;
7
- isLayout: boolean;
8
- };
9
- export default class DebugRoutesComponent {
10
- collectedRoutes: CollectedRoute[];
11
- debugRoutes: (import("@angular/router").Route & DebugRoute)[];
12
- ngOnInit(): void;
13
- traverseRoutes(routes: DebugRoute[], parent?: string): void;
14
- static ɵfac: i0.ɵɵFactoryDeclaration<DebugRoutesComponent, never>;
15
- static ɵcmp: i0.ɵɵComponentDeclaration<DebugRoutesComponent, "analogjs-debug-routes-page", never, {}, {}, never, never, true, never>;
16
- }
17
- export {};
@@ -1,16 +0,0 @@
1
- /**
2
- * Provides routes that provide additional
3
- * pages for displaying and debugging
4
- * routes.
5
- */
6
- export declare function withDebugRoutes(): {
7
- ɵkind: number;
8
- ɵproviders: {
9
- provide: import("@angular/core").InjectionToken<import("@angular/router").Route[][]>;
10
- useValue: {
11
- path: string;
12
- loadComponent: () => Promise<typeof import("./debug.page")>;
13
- }[];
14
- multi: boolean;
15
- }[];
16
- };
@@ -1,10 +0,0 @@
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)[];
@@ -1,46 +0,0 @@
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 {};
@@ -1,5 +0,0 @@
1
- export declare const ANALOG_META_KEY: unique symbol;
2
- /**
3
- * This variable reference is replaced with a glob of all route endpoints.
4
- */
5
- export declare let ANALOG_PAGE_ENDPOINTS: any;
@@ -1,19 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- export declare class FormAction {
3
- action: import("@angular/core").InputSignal<string>;
4
- onSuccess: import("@angular/core").OutputEmitterRef<unknown>;
5
- onError: import("@angular/core").OutputEmitterRef<unknown>;
6
- state: import("@angular/core").OutputEmitterRef<"error" | "redirect" | "submitting" | "success" | "navigate">;
7
- private router;
8
- private route;
9
- private path;
10
- submitted($event: {
11
- target: HTMLFormElement;
12
- } & Event): void;
13
- private _handleGet;
14
- private _handlePost;
15
- private _getPath;
16
- private _isJSON;
17
- static ɵfac: i0.ɵɵFactoryDeclaration<FormAction, never>;
18
- 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>;
19
- }
@@ -1,8 +0,0 @@
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>;
@@ -1,6 +0,0 @@
1
- import { Injector } from '@angular/core';
2
- import { Observable } from 'rxjs';
3
- import { PageServerLoad } from './route-types';
4
- export declare function injectLoad<T extends (pageServerLoad: PageServerLoad) => Promise<any>>(options?: {
5
- injector?: Injector;
6
- }): Observable<Awaited<ReturnType<T>>>;
@@ -1,2 +0,0 @@
1
- import type { ActivatedRouteSnapshot } from '@angular/router';
2
- export declare function injectRouteEndpointURL(route: ActivatedRouteSnapshot): URL;
@@ -1,2 +0,0 @@
1
- import { RouteExport } from './models';
2
- export declare function toMarkdownModule(markdownFileFactory: () => Promise<string>): () => Promise<RouteExport>;
@@ -1,28 +0,0 @@
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
- export type MetaTag = (CharsetMetaTag & ExcludeRestMetaTagKeys<typeof CHARSET_KEY>) | (HttpEquivMetaTag & ExcludeRestMetaTagKeys<typeof HTTP_EQUIV_KEY>) | (NameMetaTag & ExcludeRestMetaTagKeys<typeof NAME_KEY>) | (PropertyMetaTag & ExcludeRestMetaTagKeys<typeof PROPERTY_KEY>);
8
- type CharsetMetaTag = {
9
- [CHARSET_KEY]: string;
10
- };
11
- type HttpEquivMetaTag = {
12
- [HTTP_EQUIV_KEY]: string;
13
- [CONTENT_KEY]: string;
14
- };
15
- type NameMetaTag = {
16
- [NAME_KEY]: string;
17
- [CONTENT_KEY]: string;
18
- };
19
- type PropertyMetaTag = {
20
- [PROPERTY_KEY]: string;
21
- [CONTENT_KEY]: string;
22
- };
23
- type MetaTagKey = typeof CHARSET_KEY | typeof HTTP_EQUIV_KEY | typeof NAME_KEY | typeof PROPERTY_KEY;
24
- type ExcludeRestMetaTagKeys<Key extends MetaTagKey> = {
25
- [K in Exclude<MetaTagKey, Key>]?: never;
26
- };
27
- export declare function updateMetaTagsOnRouteChange(): void;
28
- export {};
package/lib/models.d.ts DELETED
@@ -1,29 +0,0 @@
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 {};
@@ -1,18 +0,0 @@
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;
@@ -1,12 +0,0 @@
1
- import { HttpHandlerFn, HttpRequest } from '@angular/common/http';
2
- /**
3
- * Interceptor that is server-aware when making HttpClient requests.
4
- * Server-side requests use the full URL
5
- * Prerendering uses the internal Nitro $fetch function, along with state transfer
6
- * Client-side requests use the window.location.origin
7
- *
8
- * @param req HttpRequest<unknown>
9
- * @param next HttpHandlerFn
10
- * @returns
11
- */
12
- export declare function requestContextInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn): import("rxjs").Observable<import("@angular/common/http").HttpEvent<unknown>>;
@@ -1,2 +0,0 @@
1
- import { RouteConfig, RouteMeta } from './models';
2
- export declare function toRouteConfig(routeMeta: RouteMeta | undefined): RouteConfig;