@loozo/angular-router 0.0.2 → 0.0.3
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 +442 -79
- package/builders.json +2 -2
- package/fesm2022/loozo-angular-router-_core.mjs +348 -589
- package/fesm2022/loozo-angular-router-_core.mjs.map +1 -1
- package/fesm2022/loozo-angular-router-_generated.mjs +492 -617
- package/fesm2022/loozo-angular-router-_generated.mjs.map +1 -1
- package/fesm2022/loozo-angular-router.mjs +2 -19
- package/node/_core/src/path.d.ts +17 -0
- package/node/src/builders/application.js +9 -6
- package/node/src/builders/options.js +38 -58
- package/node/src/builders/serve.js +51 -8
- package/node/src/generation/anchor.d.ts +13 -0
- package/node/src/generation/anchor.js +92 -0
- package/node/src/generation/compiler.d.ts +6 -0
- package/node/src/generation/compiler.js +68 -0
- package/node/src/generation/emit.d.ts +3 -0
- package/node/src/generation/files.d.ts +26 -0
- package/node/src/generation/files.js +14 -3
- package/node/src/generation/filesystem.d.ts +7 -0
- package/node/src/generation/generate.d.ts +16 -0
- package/node/src/generation/generate.js +5 -4
- package/node/src/generation/index.d.ts +16 -0
- package/node/src/generation/index.js +15 -0
- package/node/src/generation/overlay.d.ts +3 -0
- package/node/src/generation/selectors.d.ts +2 -0
- package/node/src/generation/sources.d.ts +50 -0
- package/node/src/generation/sources.js +50 -10
- package/node/src/generation/validate.d.ts +12 -0
- package/node/src/generation/validate.js +38 -33
- package/package.json +7 -2
- package/schemas/application.json +743 -8
- package/schemas/serve.json +11 -32
- package/types/loozo-angular-router-_core.d.ts +159 -181
- package/types/loozo-angular-router-_generated.d.ts +131 -109
- package/types/loozo-angular-router.d.ts +2 -1
- package/.npmignore +0 -3
- package/fesm2022/loozo-angular-router.mjs.map +0 -1
package/schemas/serve.json
CHANGED
|
@@ -1,39 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$comment": "Every option except poll is an @angular/build:dev-server option, passed through and validated by that builder. Router options come from buildTarget.",
|
|
3
4
|
"type": "object",
|
|
4
|
-
"additionalProperties":
|
|
5
|
-
"required": ["
|
|
5
|
+
"additionalProperties": true,
|
|
6
|
+
"required": ["buildTarget"],
|
|
6
7
|
"properties": {
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"maxItems": 1,
|
|
12
|
-
"items": { "type": "string", "minLength": 1 }
|
|
8
|
+
"buildTarget": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"minLength": 1,
|
|
11
|
+
"description": "A target using @loozo/angular-router:application, as project:target[:configuration]."
|
|
13
12
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"type": "object",
|
|
19
|
-
"additionalProperties": false,
|
|
20
|
-
"properties": {
|
|
21
|
-
"filename": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"pattern": "^[A-Za-z0-9_$][A-Za-z0-9_$.-]*\\.ts$",
|
|
24
|
-
"not": {
|
|
25
|
-
"anyOf": [
|
|
26
|
-
{ "pattern": "\\.d\\.ts$" },
|
|
27
|
-
{
|
|
28
|
-
"enum": ["route.generated.ts", "routes.generated.ts", "destinations.generated.ts"]
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"outDirectory": { "type": "string", "minLength": 1 },
|
|
37
|
-
"delegateTarget": { "type": "string", "minLength": 1 }
|
|
13
|
+
"poll": {
|
|
14
|
+
"description": "Watch by polling every this many milliseconds. Defaults to 1000 when omitted. false adds no default, so Angular's own configuration applies, including a poll on the build target.",
|
|
15
|
+
"oneOf": [{ "type": "number", "exclusiveMinimum": 0 }, { "const": false }]
|
|
16
|
+
}
|
|
38
17
|
}
|
|
39
18
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Observable } from
|
|
3
|
-
|
|
1
|
+
import { ActivatedRouteSnapshot, GuardResult, MaybeAsync, PartialMatchRouteSnapshot, RedirectCommand, Route as Route$1, RouterStateSnapshot, RunGuardsAndResolvers, UrlSegment } from "@angular/router";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
4
3
|
/**
|
|
5
4
|
* Converts one decoded path or search value to and from an application value.
|
|
6
5
|
*
|
|
@@ -21,41 +20,42 @@ import { Observable } from 'rxjs';
|
|
|
21
20
|
* ```
|
|
22
21
|
*/
|
|
23
22
|
interface ParamCodec<Value> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Parses one already percent-decoded value; do not decode it again.
|
|
25
|
+
*
|
|
26
|
+
* @param raw - A single logical string from Angular's URL inputs.
|
|
27
|
+
* @returns The logical value or a promise for it.
|
|
28
|
+
* @throws An application error for invalid input; generated input parsing
|
|
29
|
+
* reports throws and rejections as invalid path/search values with a cause.
|
|
30
|
+
*/
|
|
31
|
+
parse(raw: string): Value | Promise<Value>;
|
|
32
|
+
/**
|
|
33
|
+
* Serializes one logical value without percent-encoding it.
|
|
34
|
+
*
|
|
35
|
+
* @param value - The application value to serialize.
|
|
36
|
+
* @returns An unencoded string. Path output must not be empty, `.` or `..`.
|
|
37
|
+
* @throws An application error when the value cannot be serialized.
|
|
38
|
+
*/
|
|
39
|
+
stringify(value: Value): string;
|
|
41
40
|
}
|
|
42
41
|
declare const searchPresence: unique symbol;
|
|
43
42
|
/** A search-only codec whose key may be omitted or supplied as `undefined`. */
|
|
44
43
|
type OptionalCodec<Value> = ParamCodec<Value | undefined> & {
|
|
45
|
-
|
|
44
|
+
readonly [searchPresence]: "optional";
|
|
46
45
|
};
|
|
47
46
|
/** A search-only codec that represents explicit `null` as the text `"null"`. */
|
|
48
47
|
type NullableCodec<Value> = ParamCodec<Value | null> & {
|
|
49
|
-
|
|
48
|
+
readonly [searchPresence]: "nullable";
|
|
50
49
|
};
|
|
51
50
|
type PathCodec = ParamCodec<any> & {
|
|
52
|
-
|
|
51
|
+
readonly [searchPresence]?: never;
|
|
53
52
|
};
|
|
54
53
|
type CodecValue<Codec> = Codec extends ParamCodec<infer Value> ? Value : never;
|
|
55
54
|
type IsOptional<Codec> = Codec extends {
|
|
56
|
-
|
|
55
|
+
readonly [searchPresence]: "optional";
|
|
57
56
|
} ? true : false;
|
|
58
|
-
declare function codecPresence(codec: object): "optional" | "nullable" | undefined;
|
|
57
|
+
export declare function codecPresence(codec: object): "optional" | "nullable" | undefined;
|
|
58
|
+
declare function validateCodec(codec: unknown): asserts codec is ParamCodec<any>;
|
|
59
59
|
/**
|
|
60
60
|
* Preserves strings verbatim, including empty strings and literal percent text.
|
|
61
61
|
*
|
|
@@ -63,7 +63,7 @@ declare function codecPresence(codec: object): "optional" | "nullable" | undefin
|
|
|
63
63
|
* Empty, dot and dotdot values are valid codec values but cannot be serialized
|
|
64
64
|
* into path segments by URL creation. Search values may contain them.
|
|
65
65
|
*/
|
|
66
|
-
declare const stringParam: ParamCodec<string>;
|
|
66
|
+
export declare const stringParam: ParamCodec<string>;
|
|
67
67
|
/**
|
|
68
68
|
* Parses nonblank text with JavaScript `Number` and requires a finite result.
|
|
69
69
|
*
|
|
@@ -72,12 +72,12 @@ declare const stringParam: ParamCodec<string>;
|
|
|
72
72
|
* Blank text, NaN and infinities throw. Stringification requires a finite number
|
|
73
73
|
* and uses its JavaScript string representation (including `-0` becoming `"0"`).
|
|
74
74
|
*/
|
|
75
|
-
declare const numberParam: ParamCodec<number>;
|
|
75
|
+
export declare const numberParam: ParamCodec<number>;
|
|
76
76
|
/**
|
|
77
77
|
* Parses only lowercase `"true"` and `"false"`, and emits those same strings.
|
|
78
78
|
* Other representations and nonboolean values throw.
|
|
79
79
|
*/
|
|
80
|
-
declare const booleanParam: ParamCodec<boolean>;
|
|
80
|
+
export declare const booleanParam: ParamCodec<boolean>;
|
|
81
81
|
/**
|
|
82
82
|
* Creates a case-sensitive string codec from a snapshotted list of members.
|
|
83
83
|
*
|
|
@@ -92,7 +92,7 @@ declare const booleanParam: ParamCodec<boolean>;
|
|
|
92
92
|
* tab.parse("reviews"); // "reviews"
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
|
-
declare function enumParam<const Values extends readonly string[]>(values: Values): ParamCodec<Values[number]>;
|
|
95
|
+
export declare function enumParam<const Values extends readonly string[]>(values: Values): ParamCodec<Values[number]>;
|
|
96
96
|
/**
|
|
97
97
|
* Makes a search key optional without changing the handling of present values.
|
|
98
98
|
*
|
|
@@ -108,7 +108,7 @@ declare function enumParam<const Values extends readonly string[]>(values: Value
|
|
|
108
108
|
* @returns A search-only codec allowing omission.
|
|
109
109
|
* @throws TypeError if the codec lacks callable parse/stringify methods.
|
|
110
110
|
*/
|
|
111
|
-
declare function optionalSearchParam<Value>(codec: ParamCodec<Value>): OptionalCodec<Value>;
|
|
111
|
+
export declare function optionalSearchParam<Value>(codec: ParamCodec<Value>): OptionalCodec<Value>;
|
|
112
112
|
/**
|
|
113
113
|
* Adds explicit null to a search codec, represented by the decoded text `"null"`.
|
|
114
114
|
*
|
|
@@ -129,10 +129,9 @@ declare function optionalSearchParam<Value>(codec: ParamCodec<Value>): OptionalC
|
|
|
129
129
|
* // Omission, null, and a present number remain distinct.
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
132
|
-
declare function nullableSearchParam<Value>(codec: ParamCodec<Value> & {
|
|
133
|
-
|
|
132
|
+
export declare function nullableSearchParam<Value>(codec: ParamCodec<Value> & {
|
|
133
|
+
readonly [searchPresence]?: "nullable";
|
|
134
134
|
}): NullableCodec<Value>;
|
|
135
|
-
|
|
136
135
|
type ValidName<Name extends string> = Name extends "" | "__proto__" | `...${string}` | `${string}?${string}` | `${string}*${string}` | `${string}[]${string}` ? false : true;
|
|
137
136
|
type SegmentValid<Segment extends string> = Segment extends `$${infer Name}` ? ValidName<Name> : Segment extends "" | "." | ".." | "*" | "**" | `:${string}` ? false : true;
|
|
138
137
|
type ValidateSegments<Path extends string, Scalars extends string = never> = Path extends `${infer Head}/${infer Tail}` ? Head extends `$${string}[]` ? false : SegmentValid<Head> extends true ? ValidateSegments<Tail, Scalars | ScalarName<Head>> : false : Path extends `$${infer Name}[]` ? ValidName<Name> extends true ? Name extends Scalars ? false : true : false : SegmentValid<Path>;
|
|
@@ -142,13 +141,13 @@ type SegmentName<Segment extends string> = Segment extends `$${infer Name}[]` ?
|
|
|
142
141
|
type PathNames<Path extends string> = Path extends `${infer Head}/${infer Tail}` ? SegmentName<Head> | PathNames<Tail> : SegmentName<Path>;
|
|
143
142
|
type CatchallName<Path extends string> = Path extends `${string}/${infer Tail}` ? CatchallName<Tail> : Path extends `$${infer Name}[]` ? Name : never;
|
|
144
143
|
type Segment = {
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
readonly kind: "static";
|
|
145
|
+
readonly text: string;
|
|
147
146
|
} | {
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
readonly kind: "scalar" | "catchall";
|
|
148
|
+
readonly name: string;
|
|
150
149
|
};
|
|
151
|
-
|
|
150
|
+
declare function parsePath(path: unknown): readonly Segment[];
|
|
152
151
|
declare const routeBrand: unique symbol;
|
|
153
152
|
/**
|
|
154
153
|
* A nominal route declaration created by `defineRoute`, not a native Angular Route.
|
|
@@ -168,27 +167,25 @@ declare const routeBrand: unique symbol;
|
|
|
168
167
|
* @typeParam Catchall - Whether the declaration is a terminal catchall leaf.
|
|
169
168
|
*/
|
|
170
169
|
interface Route<Path extends string, Params, Search, Resolvers = {}, Fragments extends string = string, Catchall extends boolean = CatchallName<Path> extends never ? false : true> {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
/** The original native rerun policy; omission preserves Angular's default. */
|
|
188
|
-
readonly runGuardsAndResolvers?: RunGuardsAndResolvers;
|
|
170
|
+
readonly [routeBrand]: {
|
|
171
|
+
readonly fragments: Fragments;
|
|
172
|
+
readonly catchall: Catchall;
|
|
173
|
+
};
|
|
174
|
+
/** The exact local authored path supplied to `defineRoute`. */
|
|
175
|
+
readonly path: Path;
|
|
176
|
+
/** Type-only witness for effective path values; not populated at runtime. */
|
|
177
|
+
readonly __params?: Params;
|
|
178
|
+
/** Type-only witness for effective search values; not populated at runtime. */
|
|
179
|
+
readonly __search?: Search;
|
|
180
|
+
/** Type-only witness for unwrapped local resolver data, excluding redirects. */
|
|
181
|
+
readonly __data?: { readonly [Key in keyof Resolvers]: Resolved<Resolvers[Key]>; };
|
|
182
|
+
/** The snapshotted local resolver map, retaining original callback identities. */
|
|
183
|
+
readonly resolve?: Readonly<Resolvers>;
|
|
184
|
+
/** The original native rerun policy; omission preserves Angular's default. */
|
|
185
|
+
readonly runGuardsAndResolvers?: RunGuardsAndResolvers;
|
|
189
186
|
}
|
|
190
187
|
type Unwrap<Value> = Value extends Promise<infer Inner> | Observable<infer Inner> ? Unwrap<Inner> : Value;
|
|
191
|
-
type Resolved<Callback> = Callback extends (...args: any[]) => infer Value ? Exclude<Unwrap<Value>, RedirectCommand> : never;
|
|
188
|
+
type Resolved<Callback> = Callback extends ((...args: any[]) => infer Value) ? Exclude<Unwrap<Value>, RedirectCommand> : never;
|
|
192
189
|
type AnyRoute = Route<string, any, any, any, any, boolean>;
|
|
193
190
|
/** Extracts a declaration's effective inherited and local path-value types. */
|
|
194
191
|
type ParamsOf<Target> = Target extends Route<string, infer Params, any, any, any, boolean> ? Params : {};
|
|
@@ -197,14 +194,8 @@ type SearchOf<Target> = Target extends Route<string, any, infer Search, any, any
|
|
|
197
194
|
/** Extracts only the selected declaration's own allowed fragment-name union. */
|
|
198
195
|
type FragmentsOf<Target> = Target extends Route<string, any, any, any, infer Fragments, boolean> ? Fragments : never;
|
|
199
196
|
type CodecMap = Record<string, ParamCodec<any>>;
|
|
200
|
-
type LocalParams<Path extends string, Codecs> = {
|
|
201
|
-
|
|
202
|
-
};
|
|
203
|
-
type SearchValues<Codecs> = {
|
|
204
|
-
readonly [Key in keyof Codecs as IsOptional<Codecs[Key]> extends true ? never : Key]: CodecValue<Codecs[Key]>;
|
|
205
|
-
} & {
|
|
206
|
-
readonly [Key in keyof Codecs as IsOptional<Codecs[Key]> extends true ? Key : never]?: CodecValue<Codecs[Key]>;
|
|
207
|
-
};
|
|
197
|
+
type LocalParams<Path extends string, Codecs> = { readonly [Key in keyof Codecs]: Key extends CatchallName<Path> ? readonly CodecValue<Codecs[Key]>[] : CodecValue<Codecs[Key]>; };
|
|
198
|
+
type SearchValues<Codecs> = { readonly [Key in keyof Codecs as IsOptional<Codecs[Key]> extends true ? never : Key]: CodecValue<Codecs[Key]>; } & { readonly [Key in keyof Codecs as IsOptional<Codecs[Key]> extends true ? Key : never]?: CodecValue<Codecs[Key]>; };
|
|
208
199
|
type EffectiveParams<Path extends string, Codecs, Parent> = ParamsOf<Parent> & LocalParams<Path, Codecs>;
|
|
209
200
|
type EffectiveSearch<Codecs, Parent> = SearchOf<Parent> & SearchValues<Codecs>;
|
|
210
201
|
/**
|
|
@@ -212,10 +203,10 @@ type EffectiveSearch<Codecs, Parent> = SearchOf<Parent> & SearchValues<Codecs>;
|
|
|
212
203
|
* The container and maps are shallow-frozen; nested codec values remain opaque.
|
|
213
204
|
*/
|
|
214
205
|
type Inputs<Params, Search> = {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
206
|
+
/** Logical positional path values, not Angular's matrix-merged params. */
|
|
207
|
+
readonly params: Readonly<Params>;
|
|
208
|
+
/** Logical declared search values; absent optional keys are omitted. */
|
|
209
|
+
readonly search: Readonly<Search>;
|
|
219
210
|
};
|
|
220
211
|
/**
|
|
221
212
|
* A local resolver invoked after successful effective input parsing.
|
|
@@ -250,9 +241,7 @@ type ActivationGuard<Params, Search> = (inputs: Inputs<Params, Search>, snapshot
|
|
|
250
241
|
* @returns A native guard result; false permits Angular's next candidate.
|
|
251
242
|
*/
|
|
252
243
|
type MatchingGuard<Params, Search> = (inputs: Inputs<Params, Search>, routeConfig: Route$1, segments: UrlSegment[], partialSnapshot: PartialMatchRouteSnapshot) => MaybeAsync<GuardResult>;
|
|
253
|
-
type RequiredKeys<Value> = {
|
|
254
|
-
[Key in keyof Value]-?: Pick<Value, Key> extends Required<Pick<Value, Key>> ? Key : never;
|
|
255
|
-
}[keyof Value];
|
|
244
|
+
type RequiredKeys<Value> = { [Key in keyof Value]-?: Pick<Value, Key> extends Required<Pick<Value, Key>> ? Key : never; }[keyof Value];
|
|
256
245
|
type SearchInput<Schema, Keys extends keyof Schema> = keyof Schema extends never ? Record<string, never> : Pick<Schema, RequiredKeys<Schema> | Keys>;
|
|
257
246
|
/**
|
|
258
247
|
* Explicit values for URL creation and generated link/navigation calls.
|
|
@@ -265,39 +254,31 @@ type SearchInput<Schema, Keys extends keyof Schema> = keyof Schema extends never
|
|
|
265
254
|
* optional-key typing, including keys that coincide with Object members.
|
|
266
255
|
*/
|
|
267
256
|
type UrlValues<Target extends AnyRoute, SearchKeys extends keyof SearchOf<Target> = keyof SearchOf<Target>> = (keyof ParamsOf<Target> extends never ? {
|
|
268
|
-
|
|
269
|
-
|
|
257
|
+
/** Forbidden when the destination has no effective path params. */
|
|
258
|
+
params?: never;
|
|
270
259
|
} : {
|
|
271
|
-
|
|
272
|
-
|
|
260
|
+
/** All effective path values; catchalls are readonly element-value arrays. */
|
|
261
|
+
params: ParamsOf<Target>;
|
|
273
262
|
}) & (keyof SearchOf<Target> extends never ? {
|
|
274
|
-
|
|
275
|
-
|
|
263
|
+
/** Forbidden when the destination has no search declarations. */
|
|
264
|
+
search?: never;
|
|
276
265
|
} : RequiredKeys<SearchOf<Target>> extends never ? {
|
|
277
|
-
|
|
278
|
-
|
|
266
|
+
/** Optional-only search; absent or undefined optional values are omitted. */
|
|
267
|
+
search?: SearchInput<SearchOf<Target>, SearchKeys>;
|
|
279
268
|
} : {
|
|
280
|
-
|
|
281
|
-
|
|
269
|
+
/** All required search values plus any supplied optional values. */
|
|
270
|
+
search: SearchInput<SearchOf<Target>, SearchKeys>;
|
|
282
271
|
}) & (FragmentsOf<Target> extends never ? {
|
|
283
|
-
|
|
284
|
-
|
|
272
|
+
/** Forbidden when this declaration has no fragment names. */
|
|
273
|
+
fragment?: never;
|
|
285
274
|
} : {
|
|
286
|
-
|
|
287
|
-
|
|
275
|
+
/** An optional logical name declared by this exact destination, without `#`. */
|
|
276
|
+
fragment?: FragmentsOf<Target>;
|
|
288
277
|
});
|
|
289
|
-
type CompatibleKeys<Source, Value> = {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
type
|
|
293
|
-
[Key in keyof Destination]: CompatibleKeys<Source, Destination[Key]>;
|
|
294
|
-
};
|
|
295
|
-
type Forwardable<Source, Destination> = {
|
|
296
|
-
[Key in keyof Destination]: Key extends keyof Source ? Source[Key] extends Destination[Key] ? never : Key : Key;
|
|
297
|
-
}[keyof Destination] extends never ? true : false;
|
|
298
|
-
type Preservable<Source, Destination> = {
|
|
299
|
-
[Key in RequiredKeys<Destination>]: Key extends RequiredKeys<Source> ? Source[Key & keyof Source] extends Destination[Key] ? never : Key : Key;
|
|
300
|
-
}[RequiredKeys<Destination>] extends never ? true : false;
|
|
278
|
+
type CompatibleKeys<Source, Value> = { [Key in keyof Source]: Source[Key] extends Value ? Key : never; }[keyof Source];
|
|
279
|
+
type Mapping<Source, Destination> = { [Key in keyof Destination]: CompatibleKeys<Source, Destination[Key]>; };
|
|
280
|
+
type Forwardable<Source, Destination> = { [Key in keyof Destination]: Key extends keyof Source ? Source[Key] extends Destination[Key] ? never : Key : Key; }[keyof Destination] extends never ? true : false;
|
|
281
|
+
type Preservable<Source, Destination> = { [Key in RequiredKeys<Destination>]: Key extends RequiredKeys<Source> ? Source[Key & keyof Source] extends Destination[Key] ? never : Key : Key; }[RequiredKeys<Destination>] extends never ? true : false;
|
|
301
282
|
/**
|
|
302
283
|
* A typed redirect to a genuine authored declaration, not a concrete URL.
|
|
303
284
|
*
|
|
@@ -311,98 +292,98 @@ type Preservable<Source, Destination> = {
|
|
|
311
292
|
* whereas replace requires a target-declared name. Angular executes the redirect.
|
|
312
293
|
*/
|
|
313
294
|
type Redirect<SourceParams, SourceSearch, Target extends AnyRoute, SearchKeys extends keyof SearchOf<Target>> = {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
295
|
+
/** The already constructed target; generation requires a direct default import. */
|
|
296
|
+
to: Target;
|
|
297
|
+
/** Explicit query policy: preserve incoming text, drop it, or replace with values. */
|
|
298
|
+
search: {
|
|
299
|
+
/** Discard incoming queries and serialize explicit target-typed values. */
|
|
300
|
+
mode: "replace";
|
|
301
|
+
/** Required target search keys plus selected optional keys; unknown keys fail. */
|
|
302
|
+
values: SearchInput<SearchOf<NoInfer<Target>>, SearchKeys>;
|
|
303
|
+
} | (RequiredKeys<SearchOf<Target>> extends never ? {
|
|
304
|
+
/** Remove all incoming query values; target required keys are forbidden. */
|
|
305
|
+
mode: "drop";
|
|
306
|
+
} : never) | (Preservable<SourceSearch, SearchOf<Target>> extends true ? {
|
|
307
|
+
/** Keep original query text, validating destination-declared cardinality/values. */
|
|
308
|
+
mode: "preserve";
|
|
309
|
+
} : never);
|
|
310
|
+
/** Explicit hash policy; preserved incoming names need not be declared. */
|
|
311
|
+
fragment: {
|
|
312
|
+
/** Keep the raw incoming hash, or remove it entirely. */
|
|
313
|
+
mode: "preserve" | "drop";
|
|
314
|
+
} | (FragmentsOf<Target> extends never ? never : {
|
|
315
|
+
/** Replace the incoming hash with an explicitly declared target name. */
|
|
316
|
+
mode: "replace";
|
|
317
|
+
/** A logical target fragment name without the `#` delimiter. */
|
|
318
|
+
value: FragmentsOf<Target>;
|
|
319
|
+
});
|
|
339
320
|
} & (Forwardable<SourceParams, ParamsOf<Target>> extends true ? {
|
|
340
|
-
|
|
341
|
-
|
|
321
|
+
/** Optional destination-key to source-key mapping; otherwise forward by name. */
|
|
322
|
+
params?: Mapping<SourceParams, ParamsOf<Target>>;
|
|
342
323
|
} : {
|
|
343
|
-
|
|
344
|
-
|
|
324
|
+
/** Required mapping of every destination path key to a compatible source key. */
|
|
325
|
+
params: Mapping<SourceParams, ParamsOf<Target>>;
|
|
345
326
|
});
|
|
346
327
|
/**
|
|
347
328
|
* Options inferred by `defineRoute`; Angular's structural route fields are excluded.
|
|
348
329
|
* Local params/search cannot redeclare keys inherited from the parent.
|
|
349
330
|
*/
|
|
350
331
|
type RouteConfig<Path extends string, Parent extends AnyRoute | undefined, Params extends Record<string, PathCodec>, Search extends CodecMap, Resolvers, Fragments extends readonly string[], Target extends AnyRoute | undefined, ReplacementKeys extends keyof SearchOf<Target>> = {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
332
|
+
/** Genuine authored parent; pathless nodes retain inherited input ownership. */
|
|
333
|
+
parent?: Parent & (Parent extends Route<string, any, any, any, any, true> ? never : unknown);
|
|
334
|
+
/** Local search codecs; keys are required unless wrapped with optionalSearchParam. */
|
|
335
|
+
search?: Search & Record<Extract<keyof Search, keyof SearchOf<Parent>>, never>;
|
|
336
|
+
/** Local parsed-input resolvers; not snapshot-first native ResolveFn callbacks. */
|
|
337
|
+
resolve?: Resolvers & Record<PropertyKey, Resolver<EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>>> & {
|
|
338
|
+
__loozoAngularRouterRouteId?: never;
|
|
339
|
+
};
|
|
340
|
+
/** Local logical anchor names, never inherited; this does not enable scrolling. */
|
|
341
|
+
fragments?: Fragments;
|
|
342
|
+
/** Native rerun policy. Use paramsOrQueryParamsChange for query-dependent data. */
|
|
343
|
+
runGuardsAndResolvers?: RunGuardsAndResolvers;
|
|
344
|
+
/** Guards with declaring-parent inputs and Angular's native child snapshot. */
|
|
345
|
+
canActivateChild?: readonly ActivationGuard<EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>>[];
|
|
346
|
+
/** Native component-first guard functions/tokens, without automatic input parsing. */
|
|
347
|
+
canDeactivate?: Route$1["canDeactivate"];
|
|
348
|
+
/** Native route-scoped providers; provider factories are not run at declaration. */
|
|
349
|
+
providers?: Route$1["providers"];
|
|
350
|
+
/** Native static title or title resolver, not a parsed-input callback. */
|
|
351
|
+
title?: Route$1["title"];
|
|
352
|
+
/** Native static data; cannot set the reserved __loozoAngularRouterRouteId key. */
|
|
353
|
+
data?: Route$1["data"] & {
|
|
354
|
+
__loozoAngularRouterRouteId?: never;
|
|
355
|
+
};
|
|
375
356
|
} & (PathNames<Path> extends never ? {
|
|
376
|
-
|
|
377
|
-
|
|
357
|
+
/** Paths without local placeholders cannot declare a params map. */
|
|
358
|
+
params?: never;
|
|
378
359
|
} : {
|
|
379
|
-
|
|
380
|
-
|
|
360
|
+
/** Exactly the local placeholder names; catchall codecs apply per element. */
|
|
361
|
+
params: Params & Record<PathNames<Path>, PathCodec> & Record<Exclude<keyof Params, PathNames<Path>> | Extract<keyof Params, keyof ParamsOf<Parent>>, never>;
|
|
381
362
|
}) & (Target extends AnyRoute ? {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
363
|
+
/** Typed native redirect, incompatible with own canActivate/canMatch fields. */
|
|
364
|
+
redirect: Redirect<EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>, Target, ReplacementKeys>;
|
|
365
|
+
canActivate?: never;
|
|
366
|
+
canMatch?: never;
|
|
386
367
|
} : {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
368
|
+
redirect?: never;
|
|
369
|
+
/** Activation guards with effective inherited and local parsed inputs. */
|
|
370
|
+
canActivate?: readonly ActivationGuard<EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>>[];
|
|
371
|
+
/** Matching guards with local path params and effective search only. */
|
|
372
|
+
canMatch?: readonly MatchingGuard<LocalParams<Path, Params>, EffectiveSearch<Search, Parent>>[];
|
|
392
373
|
});
|
|
393
|
-
|
|
394
374
|
interface RouteMetadata {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
375
|
+
readonly parent?: AnyRoute;
|
|
376
|
+
readonly localSegments: readonly Segment[];
|
|
377
|
+
readonly segments: readonly Segment[];
|
|
378
|
+
readonly localParams: Readonly<Record<string, ParamCodec<any>>>;
|
|
379
|
+
readonly localSearch: Readonly<Record<string, ParamCodec<any>>>;
|
|
380
|
+
readonly params: Readonly<Record<string, ParamCodec<any>>>;
|
|
381
|
+
readonly search: Readonly<Record<string, ParamCodec<any>>>;
|
|
382
|
+
readonly fragments: readonly string[];
|
|
383
|
+
readonly config: Readonly<Record<string, unknown>>;
|
|
404
384
|
}
|
|
405
|
-
declare function routeMetadata(route: unknown): RouteMetadata;
|
|
385
|
+
export declare function routeMetadata(route: unknown): RouteMetadata;
|
|
386
|
+
declare function validateSearchValues(codecs: Readonly<Record<string, ParamCodec<any>>>, values: Record<string, unknown>): void;
|
|
406
387
|
/**
|
|
407
388
|
* Declares a nominal typed route without executing codecs or native callbacks.
|
|
408
389
|
*
|
|
@@ -440,8 +421,7 @@ declare function routeMetadata(route: unknown): RouteMetadata;
|
|
|
440
421
|
* });
|
|
441
422
|
* ```
|
|
442
423
|
*/
|
|
443
|
-
declare function defineRoute<const Path extends string, Parent extends AnyRoute | undefined = undefined, Params extends Record<string, PathCodec> = {}, Search extends CodecMap = {}, Resolvers extends Record<string, (...args: any[]) => unknown> = {}, const Fragments extends readonly string[] = [], Target extends AnyRoute | undefined = undefined, ReplacementKeys extends keyof SearchOf<NoInfer<Target>> = never>(path: Path & ValidPath<Path>, config: RouteConfig<Path, Parent, Params, Search, Resolvers, Fragments, Target, ReplacementKeys>): Route<Path, EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>, Resolvers, Fragments[number], CatchallName<Path> extends never ? false : true>;
|
|
444
|
-
|
|
424
|
+
export declare function defineRoute<const Path extends string, Parent extends AnyRoute | undefined = undefined, Params extends Record<string, PathCodec> = {}, Search extends CodecMap = {}, Resolvers extends Record<string, (...args: any[]) => unknown> = {}, const Fragments extends readonly string[] = [], Target extends AnyRoute | undefined = undefined, ReplacementKeys extends keyof SearchOf<NoInfer<Target>> = never>(path: Path & ValidPath<Path>, config: RouteConfig<Path, Parent, Params, Search, Resolvers, Fragments, Target, ReplacementKeys>): Route<Path, EffectiveParams<Path, Params, Parent>, EffectiveSearch<Search, Parent>, Resolvers, Fragments[number], CatchallName<Path> extends never ? false : true>;
|
|
445
425
|
/**
|
|
446
426
|
* Synchronously serializes a route's explicit values into a root-relative URL.
|
|
447
427
|
*
|
|
@@ -478,7 +458,5 @@ declare function defineRoute<const Path extends string, Parent extends AnyRoute
|
|
|
478
458
|
* // /products/42#summary
|
|
479
459
|
* ```
|
|
480
460
|
*/
|
|
481
|
-
declare function createUrl<Target extends AnyRoute, SearchKeys extends keyof SearchOf<NoInfer<Target>> = never>(route: Target, values: UrlValues<NoInfer<Target>, SearchKeys>): string;
|
|
482
|
-
|
|
483
|
-
export { booleanParam, codecPresence, createUrl, defineRoute, enumParam, nullableSearchParam, numberParam, optionalSearchParam, routeMetadata, stringParam };
|
|
484
|
-
export type { AnyRoute, FragmentsOf, Inputs, ParamCodec, ParamsOf, Route, RouteMetadata, SearchOf, UrlValues };
|
|
461
|
+
export declare function createUrl<Target extends AnyRoute, SearchKeys extends keyof SearchOf<NoInfer<Target>> = never>(route: Target, values: UrlValues<NoInfer<Target>, SearchKeys>): string;
|
|
462
|
+
export type { AnyRoute, FragmentsOf, Inputs, ParamCodec, ParamsOf, Route, RouteMetadata, SearchOf, UrlValues };
|