@loozo/angular-router 0.0.3 → 0.0.4
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/README.md +243 -121
- package/fesm2022/loozo-angular-router-_core.mjs +19 -41
- package/fesm2022/loozo-angular-router-_core.mjs.map +1 -1
- package/fesm2022/loozo-angular-router-_generated.mjs +148 -315
- package/fesm2022/loozo-angular-router-_generated.mjs.map +1 -1
- package/fesm2022/loozo-angular-router.mjs +2 -2
- package/node/src/builders/application.js +12 -3
- package/node/src/builders/options.js +9 -3
- package/node/src/builders/serve.js +21 -14
- package/node/src/generation/emit.js +26 -8
- package/node/src/generation/filesystem.js +261 -69
- package/node/src/generation/generate.d.ts +1 -1
- package/node/src/generation/generate.js +6 -1
- package/node/src/generation/sources.js +7 -2
- package/node/src/generation/validate.js +15 -24
- package/package.json +1 -1
- package/schemas/application.json +29 -20
- package/schemas/serve.json +142 -7
- package/snippets/angular.json +29 -0
- package/snippets/generated/destinations.generated.ts +126 -0
- package/snippets/generated/routes.generated.ts +35 -0
- package/snippets/src/catalog.ts +20 -0
- package/snippets/src/docs-url.ts +8 -0
- package/snippets/src/index.html +11 -0
- package/snippets/src/main.ts +6 -0
- package/snippets/src/product-url.ts +8 -0
- package/snippets/src/routes/products/$productId/page.ts +20 -0
- package/snippets/src/routes/products/$productId/route.generated.ts +24 -0
- package/snippets/src/routes/products/$productId/route.ts +7 -0
- package/snippets/src/routes/reports/$reportId/page.ts +9 -0
- package/snippets/src/routes/reports/$reportId/route.generated.ts +24 -0
- package/snippets/src/routes/reports/$reportId/route.ts +6 -0
- package/snippets/src/routes/teams/$teamId/items/$id/inputs.ts +15 -0
- package/snippets/src/routes/teams/$teamId/items/$id/links.ts +13 -0
- package/snippets/src/routes/teams/$teamId/items/$id/page.ts +9 -0
- package/snippets/src/routes/teams/$teamId/items/$id/route.generated.ts +24 -0
- package/snippets/src/routes/teams/$teamId/items/$id/route.ts +18 -0
- package/snippets/src/routes/teams/$teamId/members/$memberId/page.ts +9 -0
- package/snippets/src/routes/teams/$teamId/members/$memberId/route.generated.ts +24 -0
- package/snippets/src/routes/teams/$teamId/members/$memberId/route.ts +7 -0
- package/snippets/src/routes/teams/$teamId/old-items/$id/route.ts +13 -0
- package/snippets/src/routes/teams/$teamId/route.generated.ts +24 -0
- package/snippets/src/routes/teams/$teamId/route.ts +6 -0
- package/snippets/src/shell.ts +9 -0
- package/snippets/src/slug.ts +14 -0
- package/snippets/tsconfig.app.json +14 -0
- package/snippets/tsconfig.routes.json +5 -0
- package/types/loozo-angular-router-_core.d.ts +141 -99
- package/types/loozo-angular-router-_generated.d.ts +48 -31
- package/types/loozo-angular-router.d.ts +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActivatedRouteSnapshot, PartialMatchRouteSnapshot, RedirectFunction, Route, UrlTree } from "@angular/router";
|
|
2
2
|
import { AnyRoute, ParamsOf, SearchOf, UrlValues } from "@loozo/angular-router/_core";
|
|
3
|
-
import {
|
|
3
|
+
import { Signal } from "@angular/core";
|
|
4
4
|
interface RecordBinding {
|
|
5
5
|
readonly definition: () => AnyRoute;
|
|
6
6
|
readonly owners: readonly string[];
|
|
@@ -16,7 +16,6 @@ interface Parsed {
|
|
|
16
16
|
readonly search: Readonly<Record<string, unknown>>;
|
|
17
17
|
}
|
|
18
18
|
interface Job {
|
|
19
|
-
readonly source: "path" | "search";
|
|
20
19
|
readonly key: string;
|
|
21
20
|
readonly raws: readonly string[];
|
|
22
21
|
readonly array: boolean;
|
|
@@ -24,27 +23,39 @@ interface Job {
|
|
|
24
23
|
parse(raw: string): unknown;
|
|
25
24
|
};
|
|
26
25
|
}
|
|
27
|
-
interface Operation {
|
|
28
|
-
readonly promise: Promise<Parsed>;
|
|
29
|
-
outcome: {
|
|
30
|
-
value: Parsed;
|
|
31
|
-
} | {
|
|
32
|
-
error: Error;
|
|
33
|
-
} | undefined;
|
|
34
|
-
}
|
|
35
26
|
declare function hasIdentity(snapshot: Pick<ActivatedRouteSnapshot, "routeConfig">, id: string): boolean;
|
|
36
27
|
export declare function assertIdentity(snapshot: Pick<ActivatedRouteSnapshot, "routeConfig">, id: string): void;
|
|
37
|
-
declare function
|
|
38
|
-
declare function validateRaw(source: "path" | "search", key: string, raws: readonly unknown[], array: boolean): asserts raws is readonly string[];
|
|
28
|
+
declare function validateRaw(key: string, raws: readonly unknown[], array: boolean): asserts raws is readonly string[];
|
|
39
29
|
declare function pathJobs(definition: AnyRoute, url: readonly {
|
|
40
30
|
path: string;
|
|
41
31
|
}[]): Job[];
|
|
42
|
-
|
|
43
|
-
declare function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
/** Parses prechecked path jobs; the first codec failure is an input error. */
|
|
33
|
+
declare function runPathJobs(jobs: readonly Job[]): Readonly<Record<string, unknown>>;
|
|
34
|
+
/**
|
|
35
|
+
* Parses a declaration's effective search. It never fails on input: a missing,
|
|
36
|
+
* repeated or invalid value reads as the key's fallback, or leaves it absent.
|
|
37
|
+
*/
|
|
38
|
+
declare function parseSearch(definition: AnyRoute, snapshot: Pick<ActivatedRouteSnapshot, "queryParamMap">): Readonly<Record<string, unknown>>;
|
|
39
|
+
/** The effective inputs of a complete snapshot, shared by guards, resolvers and handles. */
|
|
40
|
+
export declare function parseInputs(set: RouteSet, id: string, snapshot: ActivatedRouteSnapshot): Parsed;
|
|
41
|
+
/**
|
|
42
|
+
* Parses a matching candidate's own path params only. Angular passes one partial
|
|
43
|
+
* snapshot to all of a candidate's canMatch guards, so they share this result.
|
|
44
|
+
*
|
|
45
|
+
* @returns An input error when a param is invalid; throws only programming errors.
|
|
46
|
+
*/
|
|
47
|
+
declare function pathInputs(set: RouteSet, id: string, snapshot: PartialMatchRouteSnapshot): {
|
|
48
|
+
params: Readonly<Record<string, unknown>>;
|
|
49
|
+
} | {
|
|
50
|
+
error: Error;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Local path params plus effective search for a candidate's canMatch guards, the
|
|
54
|
+
* generated one included, or undefined when the path params fail: the generated
|
|
55
|
+
* guard owns that outcome.
|
|
56
|
+
*/
|
|
57
|
+
declare function matchingInputs(set: RouteSet, id: string, snapshot: PartialMatchRouteSnapshot): Parsed | undefined;
|
|
58
|
+
export declare function callbacks(set: RouteSet, id: string): Pick<Route, "canActivate" | "canActivateChild" | "canMatch" | "resolve" | "title">;
|
|
48
59
|
export declare function redirect(definition: () => AnyRoute): RedirectFunction;
|
|
49
60
|
declare const destinationBrand: unique symbol;
|
|
50
61
|
/**
|
|
@@ -63,9 +74,13 @@ declare const destinationBrand: unique symbol;
|
|
|
63
74
|
*/
|
|
64
75
|
export declare class Destination<Target extends AnyRoute, Set = unknown, Id extends string = string> {
|
|
65
76
|
#private;
|
|
77
|
+
/** Type-only nominal brand carrying the reference's identity; not populated at runtime. */
|
|
66
78
|
readonly [destinationBrand]: {
|
|
79
|
+
/** Type-only: the referenced route's input and fragment schema. */
|
|
67
80
|
readonly target: Target;
|
|
81
|
+
/** Type-only: the generator's nominal route-set identity. */
|
|
68
82
|
readonly set: Set;
|
|
83
|
+
/** Type-only: the exact generated declaration identity. */
|
|
69
84
|
readonly id: Id;
|
|
70
85
|
};
|
|
71
86
|
}
|
|
@@ -79,14 +94,16 @@ type IsUnion<Value, Whole = Value> = Value extends unknown ? [Whole] extends [Va
|
|
|
79
94
|
*
|
|
80
95
|
* @remarks
|
|
81
96
|
* Obtain it in an Angular injection context for the exact generated activated
|
|
82
|
-
* record. Params
|
|
83
|
-
*
|
|
84
|
-
*
|
|
97
|
+
* record. Params, search and data are readonly Angular Signals of the route's
|
|
98
|
+
* committed snapshot, with values from the first read. Data contains only local
|
|
99
|
+
* resolver results, not static/ancestor data or title.
|
|
85
100
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
101
|
+
* While a navigation is pending, the signals keep the current snapshot's values;
|
|
102
|
+
* when a navigation commits a new snapshot for this route, all three change
|
|
103
|
+
* together. Cancellation, failure or a same-URL skip leaves them unchanged. For
|
|
104
|
+
* pending-navigation UI, read Angular's `Router.currentNavigation()`. There is no
|
|
105
|
+
* resolved-data cache. Reading params or search throws only when a path codec
|
|
106
|
+
* rejects a value it accepted while matching, a programming error.
|
|
90
107
|
*
|
|
91
108
|
* Selectors are single known authored literals, not concrete URLs or string
|
|
92
109
|
* unions. `.` is exact-current; other absolute/relative selections use generated
|
|
@@ -111,12 +128,12 @@ type IsUnion<Value, Whole = Value> = Value extends unknown ? [Whole] extends [Va
|
|
|
111
128
|
* ```
|
|
112
129
|
*/
|
|
113
130
|
export interface Handle<Target extends AnyRoute, Selected extends Record<string, AnyRoute> = {}, Set = unknown, References extends Record<string, AnyRoute> = {}> {
|
|
114
|
-
/** Effective positional params;
|
|
115
|
-
readonly params:
|
|
116
|
-
/** Effective declared search
|
|
117
|
-
readonly search:
|
|
118
|
-
/** Own native resolver results only
|
|
119
|
-
readonly data:
|
|
131
|
+
/** Effective positional params of the committed snapshot; kept while a navigation is pending. */
|
|
132
|
+
readonly params: Signal<Readonly<ParamsOf<Target>>>;
|
|
133
|
+
/** Effective declared search, from the same snapshot as params; absent keys have no value or fallback. */
|
|
134
|
+
readonly search: Signal<Readonly<SearchOf<Target>>>;
|
|
135
|
+
/** Own native resolver results only, from the same snapshot as params. */
|
|
136
|
+
readonly data: Signal<DataOf<Target>>;
|
|
120
137
|
/**
|
|
121
138
|
* Creates a native UrlTree for this exact declaration without navigating.
|
|
122
139
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ParamCodec, Route, booleanParam, createUrl, defineRoute, enumParam,
|
|
2
|
-
export { type ParamCodec, type Route, booleanParam, createUrl, defineRoute, enumParam,
|
|
1
|
+
import { ParamCodec, Route, booleanParam, createUrl, defineRoute, enumParam, numberParam, stringParam, withFallback } from "@loozo/angular-router/_core";
|
|
2
|
+
export { type ParamCodec, type Route, booleanParam, createUrl, defineRoute, enumParam, numberParam, stringParam, withFallback };
|