@rangular-framework/compiler 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler/src/catalog.d.ts +63 -0
- package/dist/compiler/src/catalog.js +198 -0
- package/dist/compiler/src/class/formInit.d.ts +119 -0
- package/dist/compiler/src/class/formInit.js +370 -0
- package/dist/compiler/src/class/parseComponent.d.ts +232 -0
- package/dist/compiler/src/class/parseComponent.js +430 -0
- package/dist/compiler/src/class/parseDirective.d.ts +42 -0
- package/dist/compiler/src/class/parseDirective.js +227 -0
- package/dist/compiler/src/class/parseRoutes.d.ts +59 -0
- package/dist/compiler/src/class/parseRoutes.js +163 -0
- package/dist/compiler/src/codegen/generate.d.ts +166 -0
- package/dist/compiler/src/codegen/generate.js +3466 -0
- package/dist/compiler/src/codegen/methods.d.ts +148 -0
- package/dist/compiler/src/codegen/methods.js +975 -0
- package/dist/compiler/src/codegen/sourceMap.d.ts +42 -0
- package/dist/compiler/src/codegen/sourceMap.js +77 -0
- package/dist/compiler/src/compile.d.ts +101 -0
- package/dist/compiler/src/compile.js +775 -0
- package/dist/compiler/src/diagnostics.d.ts +37 -0
- package/dist/compiler/src/diagnostics.js +113 -0
- package/dist/compiler/src/doctor.d.ts +35 -0
- package/dist/compiler/src/doctor.js +144 -0
- package/dist/compiler/src/fix.d.ts +21 -0
- package/dist/compiler/src/fix.js +44 -0
- package/dist/compiler/src/index.d.ts +22 -0
- package/dist/compiler/src/index.js +38 -0
- package/dist/compiler/src/preview/renderPreview.d.ts +101 -0
- package/dist/compiler/src/preview/renderPreview.js +7158 -0
- package/dist/compiler/src/preview/styleSnapshot.d.ts +36 -0
- package/dist/compiler/src/preview/styleSnapshot.js +268 -0
- package/dist/compiler/src/propTable.d.ts +22 -0
- package/dist/compiler/src/propTable.js +107 -0
- package/dist/compiler/src/style/css.d.ts +23 -0
- package/dist/compiler/src/style/css.js +161 -0
- package/dist/compiler/src/template/ast.d.ts +66 -0
- package/dist/compiler/src/template/ast.js +19 -0
- package/dist/compiler/src/template/evaluate.d.ts +45 -0
- package/dist/compiler/src/template/evaluate.js +151 -0
- package/dist/compiler/src/template/expr.d.ts +94 -0
- package/dist/compiler/src/template/expr.js +360 -0
- package/dist/compiler/src/template/forms.d.ts +42 -0
- package/dist/compiler/src/template/forms.js +80 -0
- package/dist/compiler/src/template/literal.d.ts +38 -0
- package/dist/compiler/src/template/literal.js +248 -0
- package/dist/compiler/src/template/parser.d.ts +14 -0
- package/dist/compiler/src/template/parser.js +230 -0
- package/dist/compiler/src/template/pipes.d.ts +48 -0
- package/dist/compiler/src/template/pipes.js +225 -0
- package/dist/compiler/src/template/printAst.d.ts +3 -0
- package/dist/compiler/src/template/printAst.js +38 -0
- package/dist/compiler/src/template/structural.d.ts +27 -0
- package/dist/compiler/src/template/structural.js +51 -0
- package/dist/runtime/src/index.d.ts +486 -0
- package/dist/runtime/src/index.js +1197 -0
- package/dist/ui/src/chart.d.ts +81 -0
- package/dist/ui/src/chart.js +196 -0
- package/dist/ui/src/datetime.d.ts +92 -0
- package/dist/ui/src/datetime.js +240 -0
- package/dist/ui/src/icons.d.ts +63 -0
- package/dist/ui/src/icons.js +310 -0
- package/dist/ui/src/mask.d.ts +38 -0
- package/dist/ui/src/mask.js +103 -0
- package/dist/ui/src/palette.d.ts +66 -0
- package/dist/ui/src/palette.js +141 -0
- package/dist/ui/src/tokens.d.ts +129 -0
- package/dist/ui/src/tokens.js +173 -0
- package/package.json +24 -4
- package/README.md +0 -3
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @rangular-framework/runtime, small pure-TypeScript helpers for generated apps.
|
|
3
|
+
* EventEmitter (for @Output), the signals core (signal, computed,
|
|
4
|
+
* effect, untracked and the SignalRenderTracker React bridge), a DI Container,
|
|
5
|
+
* the ReactiveService base class generated services extend (Stage 3),
|
|
6
|
+
* HttpClient over fetch, returning real RxJS Observables (Stage 3;
|
|
7
|
+
* the RxJS adoption replaced the old Observable-lite shape, so every
|
|
8
|
+
* stream this package hands out takes the full operator library),
|
|
9
|
+
* and the forms core (Stage 8): Validators, FormControl and FormGroup, mirroring
|
|
10
|
+
* @angular/forms semantics (Stage 8), and the routing core (Stage 9):
|
|
11
|
+
* matchRoute, RgNavigator, Router and ActivatedRoute, mirroring
|
|
12
|
+
* @angular/router, and the snackbar service (Stage 10): SnackBar and
|
|
13
|
+
* SnackBarRef, mirroring @angular/material's MatSnackBar. No react or
|
|
14
|
+
* react-native imports live in this file: generated components bridge
|
|
15
|
+
* services to React themselves (useSyncExternalStore over
|
|
16
|
+
* __subscribe / __getVersion), so this package stays environment-free
|
|
17
|
+
* and unit-testable.
|
|
18
|
+
*/
|
|
19
|
+
import { Observable, Subject } from 'rxjs';
|
|
20
|
+
export type { Subscription } from 'rxjs';
|
|
21
|
+
export type Listener<T> = (value: T) => void;
|
|
22
|
+
/**
|
|
23
|
+
* An output emitter, as in Angular: an EventEmitter IS a Subject, so
|
|
24
|
+
* it can be subscribed, piped and composed like any other stream
|
|
25
|
+
* (the RxJS adoption made this literally true; before it, the class
|
|
26
|
+
* was a small listener set shaped like one). `emit` is the Angular
|
|
27
|
+
* spelling of `next`. `on` and `off` stay as the framework's older
|
|
28
|
+
* convenience pair: `on` subscribes and returns an unsubscribe
|
|
29
|
+
* function, `off` removes a listener registered through `on`.
|
|
30
|
+
*/
|
|
31
|
+
export declare class EventEmitter<T = void> extends Subject<T> {
|
|
32
|
+
private readonly tracked;
|
|
33
|
+
/** Subscribe; returns an unsubscribe function. */
|
|
34
|
+
on(listener: Listener<T>): () => void;
|
|
35
|
+
off(listener: Listener<T>): void;
|
|
36
|
+
emit(value: T): void;
|
|
37
|
+
get listenerCount(): number;
|
|
38
|
+
}
|
|
39
|
+
export interface Signal<T> {
|
|
40
|
+
(): T;
|
|
41
|
+
}
|
|
42
|
+
/** A signal whose value can be written, as in Angular. */
|
|
43
|
+
export interface WritableSignal<T> extends Signal<T> {
|
|
44
|
+
set(value: T): void;
|
|
45
|
+
update(fn: (value: T) => T): void;
|
|
46
|
+
asReadonly(): Signal<T>;
|
|
47
|
+
}
|
|
48
|
+
export interface EffectRef {
|
|
49
|
+
destroy(): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The reactive core (signals adoption): callable signals, computed
|
|
53
|
+
* values and effects with automatic dependency tracking, mirroring
|
|
54
|
+
* @angular/core semantics. A signal is a producer; computed values and
|
|
55
|
+
* effects are consumers that record exactly which producers they read,
|
|
56
|
+
* with the version each producer had at the read. A write bumps the
|
|
57
|
+
* producer's version and notifies its consumers: computed consumers
|
|
58
|
+
* mark themselves stale and recompute lazily on the next read (pull),
|
|
59
|
+
* so a chain never observes a half-updated mix, and a computed whose
|
|
60
|
+
* inputs settle to the same value keeps its version, so its own
|
|
61
|
+
* consumers do not recompute either. Effects re-run through a queue
|
|
62
|
+
* flushed on a microtask (flushEffects runs it synchronously), never
|
|
63
|
+
* inside the write itself. Until this adoption the runtime carried a
|
|
64
|
+
* manual get/set/subscribe helper under the signal name; it had no
|
|
65
|
+
* call sites and is superseded by this core.
|
|
66
|
+
*/
|
|
67
|
+
interface ProducerNode {
|
|
68
|
+
version: number;
|
|
69
|
+
consumers: Set<ConsumerNode>;
|
|
70
|
+
}
|
|
71
|
+
interface ConsumerNode {
|
|
72
|
+
producers: Map<ProducerNode, number>;
|
|
73
|
+
onProducerChanged(): void;
|
|
74
|
+
}
|
|
75
|
+
/** Create a writable signal holding `initial`, as in Angular. */
|
|
76
|
+
export declare function signal<T>(initial: T, options?: {
|
|
77
|
+
equal?: (a: T, b: T) => boolean;
|
|
78
|
+
}): WritableSignal<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Create a computed value, as in Angular: lazy (nothing runs until the
|
|
81
|
+
* first read), cached (a read with unchanged inputs returns the cached
|
|
82
|
+
* value), and tracked (the inputs are whatever the function read last).
|
|
83
|
+
*/
|
|
84
|
+
export declare function computed<T>(fn: () => T, options?: {
|
|
85
|
+
equal?: (a: T, b: T) => boolean;
|
|
86
|
+
}): Signal<T>;
|
|
87
|
+
/** Run every queued effect now, including any those runs queue. */
|
|
88
|
+
export declare function flushEffects(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Generated components open an effect scope around their mount effect:
|
|
91
|
+
* every effect created while a scope is open joins it, and the cleanup
|
|
92
|
+
* the matching end call returns destroys them all (the component
|
|
93
|
+
* unmount path).
|
|
94
|
+
*/
|
|
95
|
+
export declare function beginEffectScope(): void;
|
|
96
|
+
export declare function endEffectScope(): () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Create an effect, as in Angular: the function runs once at creation
|
|
99
|
+
* and re-runs whenever a signal or computed it read changes. The
|
|
100
|
+
* function receives onCleanup to register teardown that runs before
|
|
101
|
+
* each re-run and at destroy. Effects created inside a component's
|
|
102
|
+
* mount scope are destroyed with the component.
|
|
103
|
+
*/
|
|
104
|
+
export declare function effect(fn: (onCleanup: (cleanup: () => void) => void) => void): EffectRef;
|
|
105
|
+
/** Run `fn` with dependency tracking suspended, as in Angular. */
|
|
106
|
+
export declare function untracked<T>(fn: () => T): T;
|
|
107
|
+
/**
|
|
108
|
+
* The React bridge for generated components: a tracker is the consumer
|
|
109
|
+
* for one component's render. Codegen opens it (begin) just before the
|
|
110
|
+
* returned view is evaluated and closes it (end) right after, so every
|
|
111
|
+
* signal read by the view, including reads inside methods the view
|
|
112
|
+
* calls, subscribes exactly this component. A later write to any of
|
|
113
|
+
* those signals calls onChange once, and the next render re-tracks
|
|
114
|
+
* from scratch, so a component follows the signals its current view
|
|
115
|
+
* actually reads.
|
|
116
|
+
*/
|
|
117
|
+
export declare class SignalRenderTracker implements ConsumerNode {
|
|
118
|
+
producers: Map<ProducerNode, number>;
|
|
119
|
+
private rendering;
|
|
120
|
+
private disposed;
|
|
121
|
+
private prevConsumer;
|
|
122
|
+
private readonly onChange;
|
|
123
|
+
constructor(onChange: () => void);
|
|
124
|
+
begin(): void;
|
|
125
|
+
end(): void;
|
|
126
|
+
onProducerChanged(): void;
|
|
127
|
+
dispose(): void;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Pipe helper referenced by generated code for `expr | pipeName` template
|
|
131
|
+
* expressions: the full Stage 12 built-in set (uppercase, lowercase,
|
|
132
|
+
* titlecase, json, date, number, percent, currency, slice, keyvalue,
|
|
133
|
+
* async). The semantics are the compiler's canonical ones
|
|
134
|
+
* (packages/compiler/src/template/pipes.ts); a parity test runs one
|
|
135
|
+
* case table through both. Unknown pipes return the value unchanged:
|
|
136
|
+
* generated code only reaches this helper for pipes the compiler has
|
|
137
|
+
* already validated, so an unknown name here means a hand-edited file.
|
|
138
|
+
*
|
|
139
|
+
* The `async` case is only a fallback: codegen replaces every
|
|
140
|
+
* template `| async` with a live subscription hook, so this helper
|
|
141
|
+
* sees an observable only from hand-written calls. Its behaviour is
|
|
142
|
+
* the pure snapshot: subscribe, keep what arrives synchronously,
|
|
143
|
+
* unsubscribe, return the latest value (null before any emission).
|
|
144
|
+
*/
|
|
145
|
+
export declare function pipe<T>(name: string, value: T, ...args: unknown[]): unknown;
|
|
146
|
+
/**
|
|
147
|
+
* Base class for generated services (Stage 3, M6).
|
|
148
|
+
*
|
|
149
|
+
* A service's state is plain class fields. Whenever a translated service
|
|
150
|
+
* method assigns a field, the codegen appends `this.__notify()`; subscribed
|
|
151
|
+
* components re-render. Generated components subscribe with React's
|
|
152
|
+
* useSyncExternalStore over __subscribe/__getVersion, the version counter
|
|
153
|
+
* is the snapshot, so every notification produces a new snapshot value.
|
|
154
|
+
*/
|
|
155
|
+
export declare class ReactiveService {
|
|
156
|
+
private __listeners;
|
|
157
|
+
private __version;
|
|
158
|
+
/** Bump the version and notify every subscribed component. */
|
|
159
|
+
protected __notify(): void;
|
|
160
|
+
/** Subscribe to changes; returns an unsubscribe function. */
|
|
161
|
+
__subscribe(listener: () => void): () => void;
|
|
162
|
+
/** Monotonic snapshot for useSyncExternalStore. */
|
|
163
|
+
__getVersion(): number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The stream type this package hands out: a real RxJS Observable.
|
|
167
|
+
* Before the RxJS adoption this name was a small home-grown interface
|
|
168
|
+
* with subscribe only; it stays exported as an alias so older code
|
|
169
|
+
* that names the type keeps compiling, but the value behind it is
|
|
170
|
+
* the genuine Observable, with pipe and the whole operator library.
|
|
171
|
+
*/
|
|
172
|
+
export type ObservableLite<T> = Observable<T>;
|
|
173
|
+
/** The slice of fetch HttpClient needs, injectable so tests never touch the network. */
|
|
174
|
+
export type FetchLike = (url: string, init?: {
|
|
175
|
+
method?: string;
|
|
176
|
+
headers?: Record<string, string>;
|
|
177
|
+
body?: string;
|
|
178
|
+
}) => Promise<{
|
|
179
|
+
json(): Promise<unknown>;
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Angular-shaped HttpClient over fetch (Stage 3, M6). Registered in the
|
|
183
|
+
* generated app's container under its own class token, so components inject
|
|
184
|
+
* it exactly like a service: `constructor(private http: HttpClient)`.
|
|
185
|
+
* Responses are parsed as JSON (Angular's default responseType). The four
|
|
186
|
+
* verbs share one request path: get and delete send no body, post and put
|
|
187
|
+
* send theirs as JSON (the verbs joined in 0.6.5, for lesson 63's examples).
|
|
188
|
+
*/
|
|
189
|
+
export declare class HttpClient {
|
|
190
|
+
private fetchImpl;
|
|
191
|
+
constructor(fetchImpl?: FetchLike);
|
|
192
|
+
get<T = unknown>(url: string): Observable<T>;
|
|
193
|
+
post<T = unknown>(url: string, body: unknown): Observable<T>;
|
|
194
|
+
put<T = unknown>(url: string, body: unknown): Observable<T>;
|
|
195
|
+
delete<T = unknown>(url: string): Observable<T>;
|
|
196
|
+
private request;
|
|
197
|
+
}
|
|
198
|
+
export type Token = string | symbol | Function;
|
|
199
|
+
/**
|
|
200
|
+
* A tiny dependency-injection registry. Generated apps register providers
|
|
201
|
+
* under a token and components resolve them with get(). A later stage bridges
|
|
202
|
+
* this to React Context; the registry semantics stay the same.
|
|
203
|
+
*/
|
|
204
|
+
export declare class Container {
|
|
205
|
+
private providers;
|
|
206
|
+
register<T>(token: Token, instance: T): this;
|
|
207
|
+
has(token: Token): boolean;
|
|
208
|
+
get<T>(token: Token): T;
|
|
209
|
+
}
|
|
210
|
+
export type ValidationErrors = {
|
|
211
|
+
[key: string]: unknown;
|
|
212
|
+
};
|
|
213
|
+
export type ValidatorFn = (value: unknown) => ValidationErrors | null;
|
|
214
|
+
export declare const Validators: {
|
|
215
|
+
required(value: unknown): ValidationErrors | null;
|
|
216
|
+
minLength(requiredLength: number): ValidatorFn;
|
|
217
|
+
maxLength(requiredLength: number): ValidatorFn;
|
|
218
|
+
email(value: unknown): ValidationErrors | null;
|
|
219
|
+
pattern(p: string | RegExp): ValidatorFn;
|
|
220
|
+
};
|
|
221
|
+
/** Run validators in order and merge their error objects; null when all pass. */
|
|
222
|
+
export declare function validateValue(value: unknown, validators: ValidatorFn[]): ValidationErrors | null;
|
|
223
|
+
/**
|
|
224
|
+
* Any node of a reactive form tree: a single control, a named group or
|
|
225
|
+
* an ordered array. The three classes share this one shape, so a group
|
|
226
|
+
* or an array can hold any of them and every aggregate simply recurses
|
|
227
|
+
* into its children. setValue and patchValue take any value at this
|
|
228
|
+
* level, exactly as Angular's AbstractControl declares them; each
|
|
229
|
+
* class narrows the shape it expects.
|
|
230
|
+
*/
|
|
231
|
+
export interface FormNode {
|
|
232
|
+
readonly value: unknown;
|
|
233
|
+
readonly valid: boolean;
|
|
234
|
+
readonly invalid: boolean;
|
|
235
|
+
readonly errors: ValidationErrors | null;
|
|
236
|
+
readonly touched: boolean;
|
|
237
|
+
readonly dirty: boolean;
|
|
238
|
+
readonly valueChanges: Observable<any>;
|
|
239
|
+
setValue(value: any): void;
|
|
240
|
+
patchValue(value: any): void;
|
|
241
|
+
markAllAsTouched(): void;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* One reactive form control (Stage 8). Holds a value, validates it on
|
|
245
|
+
* construction and on every setValue, tracks touched/dirty the way
|
|
246
|
+
* Angular does, and exposes valueChanges as a real RxJS Observable
|
|
247
|
+
* fed by a Subject the control owns.
|
|
248
|
+
*/
|
|
249
|
+
export declare class FormControl implements FormNode {
|
|
250
|
+
value: unknown;
|
|
251
|
+
errors: ValidationErrors | null;
|
|
252
|
+
touched: boolean;
|
|
253
|
+
dirty: boolean;
|
|
254
|
+
readonly valueChanges: Observable<unknown>;
|
|
255
|
+
private readonly validators;
|
|
256
|
+
private readonly changes;
|
|
257
|
+
constructor(initialValue?: unknown, validators?: ValidatorFn | ValidatorFn[] | null);
|
|
258
|
+
get valid(): boolean;
|
|
259
|
+
get invalid(): boolean;
|
|
260
|
+
get pristine(): boolean;
|
|
261
|
+
get untouched(): boolean;
|
|
262
|
+
setValue(value: unknown): void;
|
|
263
|
+
patchValue(value: unknown): void;
|
|
264
|
+
markAsTouched(): void;
|
|
265
|
+
markAllAsTouched(): void;
|
|
266
|
+
markAsDirty(): void;
|
|
267
|
+
private revalidate;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* A named set of form nodes (Stage 8; tree nodes since the forms
|
|
271
|
+
* completion pass). The group's value is the plain object of child
|
|
272
|
+
* values (a FormArray child contributes an array, a nested FormGroup
|
|
273
|
+
* an object); the group is valid exactly when every child is valid.
|
|
274
|
+
* There are no group-level validators in this version, so the group's
|
|
275
|
+
* own errors are always null, as in Angular when no group validator
|
|
276
|
+
* is registered. The group's valueChanges emits its value whenever
|
|
277
|
+
* any descendant control changes.
|
|
278
|
+
*/
|
|
279
|
+
export declare class FormGroup implements FormNode {
|
|
280
|
+
readonly controls: Record<string, FormNode>;
|
|
281
|
+
readonly valueChanges: Observable<Record<string, unknown>>;
|
|
282
|
+
constructor(controls: Record<string, FormNode>);
|
|
283
|
+
get(name: string): FormNode;
|
|
284
|
+
get value(): Record<string, unknown>;
|
|
285
|
+
get valid(): boolean;
|
|
286
|
+
get invalid(): boolean;
|
|
287
|
+
get errors(): ValidationErrors | null;
|
|
288
|
+
get touched(): boolean;
|
|
289
|
+
get dirty(): boolean;
|
|
290
|
+
markAllAsTouched(): void;
|
|
291
|
+
/** Set every child from a complete value object, as in Angular. */
|
|
292
|
+
setValue(value: Record<string, unknown>): void;
|
|
293
|
+
/** Set the children named in a partial value object, as in Angular. */
|
|
294
|
+
patchValue(value: Record<string, unknown>): void;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* An ordered list of form nodes (forms completion pass): the dynamic
|
|
298
|
+
* side of reactive forms, for rows the user can add and remove. The
|
|
299
|
+
* array's value is the array of child values; it is valid exactly
|
|
300
|
+
* when every child is valid. Its valueChanges emits whenever a child
|
|
301
|
+
* changes and whenever the structure changes (push, insert, removeAt,
|
|
302
|
+
* clear), so a component subscribed once stays live across edits.
|
|
303
|
+
* There are no array-level validators in this version, so the array's
|
|
304
|
+
* own errors are always null.
|
|
305
|
+
*/
|
|
306
|
+
export declare class FormArray implements FormNode {
|
|
307
|
+
readonly controls: FormNode[];
|
|
308
|
+
readonly valueChanges: Observable<unknown[]>;
|
|
309
|
+
private readonly changes;
|
|
310
|
+
private readonly childSubs;
|
|
311
|
+
constructor(controls?: FormNode[]);
|
|
312
|
+
private watch;
|
|
313
|
+
private unwatch;
|
|
314
|
+
private emit;
|
|
315
|
+
get length(): number;
|
|
316
|
+
at(index: number): FormNode;
|
|
317
|
+
push(control: FormNode): void;
|
|
318
|
+
insert(index: number, control: FormNode): void;
|
|
319
|
+
removeAt(index: number): void;
|
|
320
|
+
clear(): void;
|
|
321
|
+
get value(): unknown[];
|
|
322
|
+
get valid(): boolean;
|
|
323
|
+
get invalid(): boolean;
|
|
324
|
+
get errors(): ValidationErrors | null;
|
|
325
|
+
get touched(): boolean;
|
|
326
|
+
get dirty(): boolean;
|
|
327
|
+
markAllAsTouched(): void;
|
|
328
|
+
/** Set every child from a complete array of values, as in Angular. */
|
|
329
|
+
setValue(values: unknown[]): void;
|
|
330
|
+
/** Set the first children from a partial array of values. */
|
|
331
|
+
patchValue(values: unknown[]): void;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* The config-object factory for form trees (forms completion pass),
|
|
335
|
+
* Angular's convenience over the classes above. An injected built-in,
|
|
336
|
+
* like HttpClient: constructor(private fb: FormBuilder). Each config
|
|
337
|
+
* entry becomes a node: a FormControl, FormGroup or FormArray instance
|
|
338
|
+
* is used as-is; a tuple [initialValue, validators] becomes a
|
|
339
|
+
* FormControl with those validators; any other value becomes a
|
|
340
|
+
* FormControl holding it. A tuple's third element (Angular's async
|
|
341
|
+
* validators) is ignored: there are no async validators in this
|
|
342
|
+
* version.
|
|
343
|
+
*/
|
|
344
|
+
export declare class FormBuilder {
|
|
345
|
+
group(config: Record<string, unknown>): FormGroup;
|
|
346
|
+
control(initialValue?: unknown, validators?: ValidatorFn | ValidatorFn[] | null): FormControl;
|
|
347
|
+
array(entries?: unknown[]): FormArray;
|
|
348
|
+
private coerce;
|
|
349
|
+
}
|
|
350
|
+
/** One route pattern, the shape the generated navigator is built from. */
|
|
351
|
+
export interface RgRouteDef {
|
|
352
|
+
path: string;
|
|
353
|
+
redirectTo?: string;
|
|
354
|
+
}
|
|
355
|
+
/** A resolved navigation: the concrete path, its params, and the pattern that matched. */
|
|
356
|
+
export interface RouteMatch {
|
|
357
|
+
/** The concrete path navigated to, normalised (no leading or trailing slash). */
|
|
358
|
+
path: string;
|
|
359
|
+
/** Captured ':param' segments, values are always strings. */
|
|
360
|
+
params: Record<string, string>;
|
|
361
|
+
/** The route pattern that matched, e.g. 'mail/:id'. */
|
|
362
|
+
routePath: string;
|
|
363
|
+
}
|
|
364
|
+
/** Normalise a path: split on '/', drop empty segments, rejoin. */
|
|
365
|
+
export declare function normalizeRoutePath(raw: string): string;
|
|
366
|
+
/**
|
|
367
|
+
* Match a path against a route table, following redirects. Returns the
|
|
368
|
+
* final match, or null when nothing matches (no entry and no wildcard).
|
|
369
|
+
*/
|
|
370
|
+
export declare function matchRoute(routes: RgRouteDef[], rawPath: string): RouteMatch | null;
|
|
371
|
+
/**
|
|
372
|
+
* The navigation stack of a generated app (Stage 9). One instance lives
|
|
373
|
+
* at module level in the generated file; the root component subscribes
|
|
374
|
+
* and re-renders the outlet whenever the top entry changes. The stack
|
|
375
|
+
* always holds at least the initial entry (the match for the empty
|
|
376
|
+
* path, redirects followed), so `current` is always defined and
|
|
377
|
+
* `back()` at depth 1 is a no-op that returns false.
|
|
378
|
+
*/
|
|
379
|
+
export declare class RgNavigator {
|
|
380
|
+
private readonly routes;
|
|
381
|
+
private entries;
|
|
382
|
+
private listeners;
|
|
383
|
+
constructor(routes: RgRouteDef[]);
|
|
384
|
+
/** The entry on top of the stack: what the outlet renders. */
|
|
385
|
+
get current(): RouteMatch;
|
|
386
|
+
/** Stack depth; the app can go back exactly when this is above 1. */
|
|
387
|
+
get depth(): number;
|
|
388
|
+
/** Push a new entry; false (and no change) when no route matches. */
|
|
389
|
+
navigate(rawPath: string): boolean;
|
|
390
|
+
/** Pop back to the previous entry; false at the root of the stack. */
|
|
391
|
+
back(): boolean;
|
|
392
|
+
/** Subscribe to navigation changes; returns an unsubscribe function. */
|
|
393
|
+
subscribe(listener: () => void): () => void;
|
|
394
|
+
private emit;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* The injectable Angular authors navigate with (Stage 9). Generated
|
|
398
|
+
* components receive the one instance bound to the app's navigator.
|
|
399
|
+
*
|
|
400
|
+
* `navigate(commands)` joins the command segments with '/': numbers
|
|
401
|
+
* are stringified, and slashes at segment edges mean nothing, so
|
|
402
|
+
* `navigate(['/mail', 3])` and `navigate(['mail', '3'])` both land on
|
|
403
|
+
* 'mail/3'. In v1 commands always resolve from the app root; Angular's
|
|
404
|
+
* relative-to-current-route navigation is not in this version.
|
|
405
|
+
*/
|
|
406
|
+
export declare class Router {
|
|
407
|
+
private readonly navigator;
|
|
408
|
+
constructor(navigator: RgNavigator);
|
|
409
|
+
navigate(commands: unknown[]): boolean;
|
|
410
|
+
navigateByUrl(url: string): boolean;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* The injectable that carries the current route's parameters into a
|
|
414
|
+
* route component (Stage 9). The outlet creates one instance per mount
|
|
415
|
+
* from the current navigation entry and passes it to the component.
|
|
416
|
+
*
|
|
417
|
+
* `snapshot.params` is the plain params object. `paramMap` is a real
|
|
418
|
+
* RxJS Observable fed by a BehaviorSubject: it emits the current
|
|
419
|
+
* params on subscribe and, while subscribed, again whenever the
|
|
420
|
+
* navigator's current entry changes.
|
|
421
|
+
* In v1 the generated outlet remounts a route component when the path
|
|
422
|
+
* changes (it keys the component by the concrete path), so a component
|
|
423
|
+
* normally sees exactly one emission per mount; the snapshot is the
|
|
424
|
+
* primary surface, exactly the pattern Angular's own docs teach first.
|
|
425
|
+
*/
|
|
426
|
+
export declare class ActivatedRoute {
|
|
427
|
+
private readonly initialParams;
|
|
428
|
+
private readonly navigatorRef?;
|
|
429
|
+
readonly paramMap: Observable<Record<string, string>>;
|
|
430
|
+
private readonly paramsChanges;
|
|
431
|
+
constructor(initialParams: Record<string, string>, navigatorRef?: RgNavigator | undefined);
|
|
432
|
+
/**
|
|
433
|
+
* The current parameters, read live: with a navigator attached the
|
|
434
|
+
* snapshot reflects the latest navigation (Angular refreshes the
|
|
435
|
+
* snapshot on each activation the same way); without one it is the
|
|
436
|
+
* fixed set the instance was constructed with.
|
|
437
|
+
*/
|
|
438
|
+
get snapshot(): {
|
|
439
|
+
params: Record<string, string>;
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
/** What the generated host renders for the currently open bar. */
|
|
443
|
+
export interface SnackBarState {
|
|
444
|
+
message: string;
|
|
445
|
+
actionLabel?: string;
|
|
446
|
+
durationMs: number;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The handle `SnackBar.open` returns, mirroring MatSnackBarRef.
|
|
450
|
+
* `onAction(callback)` registers what runs when the bar's action is
|
|
451
|
+
* pressed (the Undo pattern); `dismiss()` closes the bar early.
|
|
452
|
+
*/
|
|
453
|
+
export declare class SnackBarRef {
|
|
454
|
+
private readonly bar;
|
|
455
|
+
private actionCallbacks;
|
|
456
|
+
constructor(bar: SnackBar);
|
|
457
|
+
onAction(callback: () => void): void;
|
|
458
|
+
dismiss(): void;
|
|
459
|
+
/** Fired by the owning SnackBar when the action is pressed. Hosts never call this. */
|
|
460
|
+
__fireAction(): void;
|
|
461
|
+
}
|
|
462
|
+
export declare class SnackBar {
|
|
463
|
+
private state;
|
|
464
|
+
private currentRef;
|
|
465
|
+
private listeners;
|
|
466
|
+
private timer;
|
|
467
|
+
/** The bar currently showing, or null. The generated host renders this. */
|
|
468
|
+
get current(): SnackBarState | null;
|
|
469
|
+
/** Subscribe to open/dismiss changes; returns an unsubscribe function. */
|
|
470
|
+
subscribe(listener: () => void): () => void;
|
|
471
|
+
/**
|
|
472
|
+
* Open a bar, replacing any bar currently showing (its action
|
|
473
|
+
* callbacks do not fire). Returns the bar's ref.
|
|
474
|
+
*/
|
|
475
|
+
open(message: string, actionLabel?: string, durationMs?: number): SnackBarRef;
|
|
476
|
+
/** Close the current bar without firing its action callbacks. */
|
|
477
|
+
dismiss(): void;
|
|
478
|
+
/**
|
|
479
|
+
* The action was pressed: the bar dismisses and the current ref's
|
|
480
|
+
* onAction callbacks fire, in that order. Called by the generated
|
|
481
|
+
* snackbar host; authors use SnackBarRef.onAction instead.
|
|
482
|
+
*/
|
|
483
|
+
pressAction(): void;
|
|
484
|
+
private clearTimer;
|
|
485
|
+
private emit;
|
|
486
|
+
}
|