1 | /**
|
2 | * @license Angular v10.0.10
|
3 | * (c) 2010-2020 Google LLC. https://angular.io/
|
4 | * License: MIT
|
5 | */
|
6 |
|
7 |
|
8 | /**
|
9 | * @description
|
10 | *
|
11 | * Represents an abstract class `T`, if applied to a concrete class it would stop being
|
12 | * instantiatable.
|
13 | *
|
14 | * @publicApi
|
15 | */
|
16 | declare interface AbstractType<T> extends Function {
|
17 | prototype: T;
|
18 | }
|
19 |
|
20 | /**
|
21 | * Base class that provides change detection functionality.
|
22 | * A change-detection tree collects all views that are to be checked for changes.
|
23 | * Use the methods to add and remove views from the tree, initiate change-detection,
|
24 | * and explicitly mark views as _dirty_, meaning that they have changed and need to be re-rendered.
|
25 | *
|
26 | * @see [Using change detection hooks](guide/lifecycle-hooks#using-change-detection-hooks)
|
27 | * @see [Defining custom change detection](guide/lifecycle-hooks#defining-custom-change-detection)
|
28 | *
|
29 | * @usageNotes
|
30 | *
|
31 | * The following examples demonstrate how to modify default change-detection behavior
|
32 | * to perform explicit detection when needed.
|
33 | *
|
34 | * ### Use `markForCheck()` with `CheckOnce` strategy
|
35 | *
|
36 | * The following example sets the `OnPush` change-detection strategy for a component
|
37 | * (`CheckOnce`, rather than the default `CheckAlways`), then forces a second check
|
38 | * after an interval. See [live demo](http://plnkr.co/edit/GC512b?p=preview).
|
39 | *
|
40 | * <code-example path="core/ts/change_detect/change-detection.ts"
|
41 | * region="mark-for-check"></code-example>
|
42 | *
|
43 | * ### Detach change detector to limit how often check occurs
|
44 | *
|
45 | * The following example defines a component with a large list of read-only data
|
46 | * that is expected to change constantly, many times per second.
|
47 | * To improve performance, we want to check and update the list
|
48 | * less often than the changes actually occur. To do that, we detach
|
49 | * the component's change detector and perform an explicit local check every five seconds.
|
50 | *
|
51 | * <code-example path="core/ts/change_detect/change-detection.ts" region="detach"></code-example>
|
52 | *
|
53 | *
|
54 | * ### Reattaching a detached component
|
55 | *
|
56 | * The following example creates a component displaying live data.
|
57 | * The component detaches its change detector from the main change detector tree
|
58 | * when the `live` property is set to false, and reattaches it when the property
|
59 | * becomes true.
|
60 | *
|
61 | * <code-example path="core/ts/change_detect/change-detection.ts" region="reattach"></code-example>
|
62 | *
|
63 | * @publicApi
|
64 | */
|
65 | declare abstract class ChangeDetectorRef {
|
66 | /**
|
67 | * When a view uses the {@link ChangeDetectionStrategy#OnPush OnPush} (checkOnce)
|
68 | * change detection strategy, explicitly marks the view as changed so that
|
69 | * it can be checked again.
|
70 | *
|
71 | * Components are normally marked as dirty (in need of rerendering) when inputs
|
72 | * have changed or events have fired in the view. Call this method to ensure that
|
73 | * a component is checked even if these triggers have not occured.
|
74 | *
|
75 | * <!-- TODO: Add a link to a chapter on OnPush components -->
|
76 | *
|
77 | */
|
78 | abstract markForCheck(): void;
|
79 | /**
|
80 | * Detaches this view from the change-detection tree.
|
81 | * A detached view is not checked until it is reattached.
|
82 | * Use in combination with `detectChanges()` to implement local change detection checks.
|
83 | *
|
84 | * Detached views are not checked during change detection runs until they are
|
85 | * re-attached, even if they are marked as dirty.
|
86 | *
|
87 | * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
|
88 | * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
|
89 | *
|
90 | */
|
91 | abstract detach(): void;
|
92 | /**
|
93 | * Checks this view and its children. Use in combination with {@link ChangeDetectorRef#detach
|
94 | * detach}
|
95 | * to implement local change detection checks.
|
96 | *
|
97 | * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
|
98 | * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
|
99 | *
|
100 | */
|
101 | abstract detectChanges(): void;
|
102 | /**
|
103 | * Checks the change detector and its children, and throws if any changes are detected.
|
104 | *
|
105 | * Use in development mode to verify that running change detection doesn't introduce
|
106 | * other changes.
|
107 | */
|
108 | abstract checkNoChanges(): void;
|
109 | /**
|
110 | * Re-attaches the previously detached view to the change detection tree.
|
111 | * Views are attached to the tree by default.
|
112 | *
|
113 | * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
|
114 | *
|
115 | */
|
116 | abstract reattach(): void;
|
117 | }
|
118 |
|
119 | /**
|
120 | * Configures the `Injector` to return an instance of `useClass` for a token.
|
121 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
122 | *
|
123 | * @usageNotes
|
124 | *
|
125 | * {@example core/di/ts/provider_spec.ts region='ClassProvider'}
|
126 | *
|
127 | * Note that following two providers are not equal:
|
128 | *
|
129 | * {@example core/di/ts/provider_spec.ts region='ClassProviderDifference'}
|
130 | *
|
131 | * ### Multi-value example
|
132 | *
|
133 | * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
134 | *
|
135 | * @publicApi
|
136 | */
|
137 | declare interface ClassProvider extends ClassSansProvider {
|
138 | /**
|
139 | * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).
|
140 | */
|
141 | provide: any;
|
142 | /**
|
143 | * When true, injector returns an array of instances. This is useful to allow multiple
|
144 | * providers spread across many files to provide configuration information to a common token.
|
145 | */
|
146 | multi?: boolean;
|
147 | }
|
148 |
|
149 | /**
|
150 | * Configures the `Injector` to return a value by invoking a `useClass` function.
|
151 | * Base for `ClassProvider` decorator.
|
152 | *
|
153 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
154 | *
|
155 | * @publicApi
|
156 | */
|
157 | declare interface ClassSansProvider {
|
158 | /**
|
159 | * Class to instantiate for the `token`.
|
160 | */
|
161 | useClass: Type<any>;
|
162 | }
|
163 |
|
164 | /**
|
165 | * Base class for a factory that can create a component dynamically.
|
166 | * Instantiate a factory for a given type of component with `resolveComponentFactory()`.
|
167 | * Use the resulting `ComponentFactory.create()` method to create a component of that type.
|
168 | *
|
169 | * @see [Dynamic Components](guide/dynamic-component-loader)
|
170 | *
|
171 | * @publicApi
|
172 | */
|
173 | declare abstract class ComponentFactory<C> {
|
174 | /**
|
175 | * The component's HTML selector.
|
176 | */
|
177 | abstract get selector(): string;
|
178 | /**
|
179 | * The type of component the factory will create.
|
180 | */
|
181 | abstract get componentType(): Type<any>;
|
182 | /**
|
183 | * Selector for all <ng-content> elements in the component.
|
184 | */
|
185 | abstract get ngContentSelectors(): string[];
|
186 | /**
|
187 | * The inputs of the component.
|
188 | */
|
189 | abstract get inputs(): {
|
190 | propName: string;
|
191 | templateName: string;
|
192 | }[];
|
193 | /**
|
194 | * The outputs of the component.
|
195 | */
|
196 | abstract get outputs(): {
|
197 | propName: string;
|
198 | templateName: string;
|
199 | }[];
|
200 | /**
|
201 | * Creates a new component.
|
202 | */
|
203 | abstract create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string | any, ngModule?: NgModuleRef<any>): ComponentRef<C>;
|
204 | }
|
205 |
|
206 | /**
|
207 | * A simple registry that maps `Components` to generated `ComponentFactory` classes
|
208 | * that can be used to create instances of components.
|
209 | * Use to obtain the factory for a given component type,
|
210 | * then use the factory's `create()` method to create a component of that type.
|
211 | *
|
212 | * @see [Dynamic Components](guide/dynamic-component-loader)
|
213 | * @publicApi
|
214 | */
|
215 | declare abstract class ComponentFactoryResolver {
|
216 | static NULL: ComponentFactoryResolver;
|
217 | /**
|
218 | * Retrieves the factory object that creates a component of the given type.
|
219 | * @param component The component type.
|
220 | */
|
221 | abstract resolveComponentFactory<T>(component: Type<T>): ComponentFactory<T>;
|
222 | }
|
223 |
|
224 | /**
|
225 | * Represents a component created by a `ComponentFactory`.
|
226 | * Provides access to the component instance and related objects,
|
227 | * and provides the means of destroying the instance.
|
228 | *
|
229 | * @publicApi
|
230 | */
|
231 | declare abstract class ComponentRef<C> {
|
232 | /**
|
233 | * The host or anchor [element](guide/glossary#element) for this component instance.
|
234 | */
|
235 | abstract get location(): ElementRef;
|
236 | /**
|
237 | * The [dependency injector](guide/glossary#injector) for this component instance.
|
238 | */
|
239 | abstract get injector(): Injector;
|
240 | /**
|
241 | * This component instance.
|
242 | */
|
243 | abstract get instance(): C;
|
244 | /**
|
245 | * The [host view](guide/glossary#view-tree) defined by the template
|
246 | * for this component instance.
|
247 | */
|
248 | abstract get hostView(): ViewRef;
|
249 | /**
|
250 | * The change detector for this component instance.
|
251 | */
|
252 | abstract get changeDetectorRef(): ChangeDetectorRef;
|
253 | /**
|
254 | * The type of this component (as created by a `ComponentFactory` class).
|
255 | */
|
256 | abstract get componentType(): Type<any>;
|
257 | /**
|
258 | * Destroys the component instance and all of the data structures associated with it.
|
259 | */
|
260 | abstract destroy(): void;
|
261 | /**
|
262 | * A lifecycle hook that provides additional developer-defined cleanup
|
263 | * functionality for the component.
|
264 | * @param callback A handler function that cleans up developer-defined data
|
265 | * associated with this component. Called when the `destroy()` method is invoked.
|
266 | */
|
267 | abstract onDestroy(callback: Function): void;
|
268 | }
|
269 |
|
270 | /**
|
271 | * Configures the `Injector` to return an instance of a token.
|
272 | *
|
273 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
274 | *
|
275 | * @usageNotes
|
276 | *
|
277 | * {@example core/di/ts/provider_spec.ts region='ConstructorProvider'}
|
278 | *
|
279 | * ### Multi-value example
|
280 | *
|
281 | * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
282 | *
|
283 | * @publicApi
|
284 | */
|
285 | declare interface ConstructorProvider extends ConstructorSansProvider {
|
286 | /**
|
287 | * An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
|
288 | */
|
289 | provide: Type<any>;
|
290 | /**
|
291 | * When true, injector returns an array of instances. This is useful to allow multiple
|
292 | * providers spread across many files to provide configuration information to a common token.
|
293 | */
|
294 | multi?: boolean;
|
295 | }
|
296 |
|
297 | /**
|
298 | * Configures the `Injector` to return an instance of a token.
|
299 | *
|
300 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
301 | *
|
302 | * @usageNotes
|
303 | *
|
304 | * ```ts
|
305 | * @Injectable(SomeModule, {deps: []})
|
306 | * class MyService {}
|
307 | * ```
|
308 | *
|
309 | * @publicApi
|
310 | */
|
311 | declare interface ConstructorSansProvider {
|
312 | /**
|
313 | * A list of `token`s to be resolved by the injector.
|
314 | */
|
315 | deps?: any[];
|
316 | }
|
317 |
|
318 | /**
|
319 | * An object literal of this type is used to represent the metadata of a constructor dependency.
|
320 | * The type itself is never referred to from generated code.
|
321 | */
|
322 | declare type CtorDependency = {
|
323 | /**
|
324 | * If an `@Attribute` decorator is used, this represents the injected attribute's name. If the
|
325 | * attribute name is a dynamic expression instead of a string literal, this will be the unknown
|
326 | * type.
|
327 | */
|
328 | attribute?: string | unknown;
|
329 | /**
|
330 | * If `@Optional()` is used, this key is set to true.
|
331 | */
|
332 | optional?: true;
|
333 | /**
|
334 | * If `@Host` is used, this key is set to true.
|
335 | */
|
336 | host?: true;
|
337 | /**
|
338 | * If `@Self` is used, this key is set to true.
|
339 | */
|
340 | self?: true;
|
341 | /**
|
342 | * If `@SkipSelf` is used, this key is set to true.
|
343 | */
|
344 | skipSelf?: true;
|
345 | } | null;
|
346 |
|
347 | /**
|
348 | * A wrapper around a native element inside of a View.
|
349 | *
|
350 | * An `ElementRef` is backed by a render-specific element. In the browser, this is usually a DOM
|
351 | * element.
|
352 | *
|
353 | * @security Permitting direct access to the DOM can make your application more vulnerable to
|
354 | * XSS attacks. Carefully review any use of `ElementRef` in your code. For more detail, see the
|
355 | * [Security Guide](http://g.co/ng/security).
|
356 | *
|
357 | * @publicApi
|
358 | */
|
359 | declare class ElementRef<T = any> {
|
360 | /**
|
361 | * The underlying native element or `null` if direct access to native elements is not supported
|
362 | * (e.g. when the application runs in a web worker).
|
363 | *
|
364 | * <div class="callout is-critical">
|
365 | * <header>Use with caution</header>
|
366 | * <p>
|
367 | * Use this API as the last resort when direct access to DOM is needed. Use templating and
|
368 | * data-binding provided by Angular instead. Alternatively you can take a look at {@link
|
369 | * Renderer2}
|
370 | * which provides API that can safely be used even when direct access to native elements is not
|
371 | * supported.
|
372 | * </p>
|
373 | * <p>
|
374 | * Relying on direct DOM access creates tight coupling between your application and rendering
|
375 | * layers which will make it impossible to separate the two and deploy your application into a
|
376 | * web worker.
|
377 | * </p>
|
378 | * </div>
|
379 | *
|
380 | */
|
381 | nativeElement: T;
|
382 | constructor(nativeElement: T);
|
383 | }
|
384 |
|
385 | /**
|
386 | * Configures the `Injector` to return a value of another `useExisting` token.
|
387 | *
|
388 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
389 | *
|
390 | * @usageNotes
|
391 | *
|
392 | * {'ExistingProvider'}
core/di/ts/provider_spec.ts region= |
393 | *
|
394 | * ### Multi-value example
|
395 | *
|
396 | * {'MultiProviderAspect'}
core/di/ts/provider_spec.ts region= |
397 | *
|
398 | *
|
399 | */
|
400 | declare interface ExistingProvider extends ExistingSansProvider {
|
401 | /**
|
402 | * An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
|
403 | */
|
404 | provide: any;
|
405 | /**
|
406 | * When true, injector returns an array of instances. This is useful to allow multiple
|
407 | * providers spread across many files to provide configuration information to a common token.
|
408 | */
|
409 | multi?: boolean;
|
410 | }
|
411 |
|
412 | /**
|
413 | * Configures the `Injector` to return a value of another `useExisting` token.
|
414 | *
|
415 | * @see `ExistingProvider`
|
416 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
417 | *
|
418 | * @publicApi
|
419 | */
|
420 | declare interface ExistingSansProvider {
|
421 | /**
|
422 | * Existing `token` to return. (Equivalent to `injector.get(useExisting)`)
|
423 | */
|
424 | useExisting: any;
|
425 | }
|
426 |
|
427 | /**
|
428 | * Configures the `Injector` to return a value by invoking a `useFactory` function.
|
429 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
430 | *
|
431 | * @usageNotes
|
432 | *
|
433 | * {@example core/di/ts/provider_spec.ts region='FactoryProvider'}
|
434 | *
|
435 | * Dependencies can also be marked as optional:
|
436 | *
|
437 | * {@example core/di/ts/provider_spec.ts region='FactoryProviderOptionalDeps'}
|
438 | *
|
439 | * ### Multi-value example
|
440 | *
|
441 | * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
442 | *
|
443 | * @publicApi
|
444 | */
|
445 | declare interface FactoryProvider extends FactorySansProvider {
|
446 | /**
|
447 | * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).
|
448 | */
|
449 | provide: any;
|
450 | /**
|
451 | * When true, injector returns an array of instances. This is useful to allow multiple
|
452 | * providers spread across many files to provide configuration information to a common token.
|
453 | */
|
454 | multi?: boolean;
|
455 | }
|
456 |
|
457 | /**
|
458 | * Configures the `Injector` to return a value by invoking a `useFactory` function.
|
459 | *
|
460 | * @see `FactoryProvider`
|
461 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
462 | *
|
463 | * @publicApi
|
464 | */
|
465 | declare interface FactorySansProvider {
|
466 | /**
|
467 | * A function to invoke to create a value for this `token`. The function is invoked with
|
468 | * resolved values of `token`s in the `deps` field.
|
469 | */
|
470 | useFactory: Function;
|
471 | /**
|
472 | * A list of `token`s to be resolved by the injector. The list of values is then
|
473 | * used as arguments to the `useFactory` function.
|
474 | */
|
475 | deps?: any[];
|
476 | }
|
477 |
|
478 |
|
479 | /**
|
480 | * Injection flags for DI.
|
481 | *
|
482 | * @publicApi
|
483 | */
|
484 | declare enum InjectFlags {
|
485 | /** Check self and check parent injector if needed */
|
486 | Default = 0,
|
487 | /**
|
488 | * Specifies that an injector should retrieve a dependency from any injector until reaching the
|
489 | * host element of the current component. (Only used with Element Injector)
|
490 | */
|
491 | Host = 1,
|
492 | /** Don't ascend to ancestors of the node requesting injection. */
|
493 | Self = 2,
|
494 | /** Skip the node that is requesting injection. */
|
495 | SkipSelf = 4,
|
496 | /** Inject `defaultValue` instead if token not found. */
|
497 | Optional = 8
|
498 | }
|
499 |
|
500 | /**
|
501 | * Creates a token that can be used in a DI Provider.
|
502 | *
|
503 | * Use an `InjectionToken` whenever the type you are injecting is not reified (does not have a
|
504 | * runtime representation) such as when injecting an interface, callable type, array or
|
505 | * parameterized type.
|
506 | *
|
507 | * `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
|
508 | * the `Injector`. This provides additional level of type safety.
|
509 | *
|
510 | * ```
|
511 | * interface MyInterface {...}
|
512 | * var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
|
513 | * // myInterface is inferred to be MyInterface.
|
514 | * ```
|
515 | *
|
516 | * When creating an `InjectionToken`, you can optionally specify a factory function which returns
|
517 | * (possibly by creating) a default value of the parameterized type `T`. This sets up the
|
518 | * `InjectionToken` using this factory as a provider as if it was defined explicitly in the
|
519 | * application's root injector. If the factory function, which takes zero arguments, needs to inject
|
520 | * dependencies, it can do so using the `inject` function. See below for an example.
|
521 | *
|
522 | * Additionally, if a `factory` is specified you can also specify the `providedIn` option, which
|
523 | * overrides the above behavior and marks the token as belonging to a particular `@NgModule`. As
|
524 | * mentioned above, `'root'` is the default value for `providedIn`.
|
525 | *
|
526 | * @usageNotes
|
527 | * ### Basic Example
|
528 | *
|
529 | * ### Plain InjectionToken
|
530 | *
|
531 | * {@example core/di/ts/injector_spec.ts region='InjectionToken'}
|
532 | *
|
533 | * ### Tree-shakable InjectionToken
|
534 | *
|
535 | * {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'}
|
536 | *
|
537 | *
|
538 | * @publicApi
|
539 | */
|
540 | declare class InjectionToken<T> {
|
541 | protected _desc: string;
|
542 | readonly ɵprov: never | undefined;
|
543 | constructor(_desc: string, options?: {
|
544 | providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
|
545 | factory: () => T;
|
546 | });
|
547 | toString(): string;
|
548 | }
|
549 |
|
550 | /**
|
551 | * Concrete injectors implement this interface. Injectors are configured
|
552 | * with [providers](guide/glossary#provider) that associate
|
553 | * dependencies of various types with [injection tokens](guide/glossary#di-token).
|
554 | *
|
555 | * @see ["DI Providers"](guide/dependency-injection-providers).
|
556 | * @see `StaticProvider`
|
557 | *
|
558 | * @usageNotes
|
559 | *
|
560 | * The following example creates a service injector instance.
|
561 | *
|
562 | * {'ConstructorProvider'}
core/di/ts/provider_spec.ts region= |
563 | *
|
564 | * ### Usage example
|
565 | *
|
566 | * {'Injector'}
core/di/ts/injector_spec.ts region= |
567 | *
|
568 | * `Injector` returns itself when given `Injector` as a token:
|
569 | *
|
570 | * {'injectInjector'}
core/di/ts/injector_spec.ts region= |
571 | *
|
572 | *
|
573 | */
|
574 | declare abstract class Injector {
|
575 | static THROW_IF_NOT_FOUND: {};
|
576 | static NULL: Injector;
|
577 | /**
|
578 | * Retrieves an instance from the injector based on the provided token.
|
579 | * @returns The instance from the injector if defined, otherwise the `notFoundValue`.
|
580 | * @throws When the `notFoundValue` is `undefined` or `Injector.THROW_IF_NOT_FOUND`.
|
581 | */
|
582 | abstract get<T>(token: Type<T> | InjectionToken<T> | AbstractType<T>, notFoundValue?: T, flags?: InjectFlags): T;
|
583 | /**
|
584 | * @deprecated from v4.0.0 use Type<T> or InjectionToken<T>
|
585 | * @suppress {duplicate}
|
586 | */
|
587 | abstract get(token: any, notFoundValue?: any): any;
|
588 | /**
|
589 | * @deprecated from v5 use the new signature Injector.create(options)
|
590 | */
|
591 | static create(providers: StaticProvider[], parent?: Injector): Injector;
|
592 | /**
|
593 | * Creates a new injector instance that provides one or more dependencies,
|
594 | * according to a given type or types of `StaticProvider`.
|
595 | *
|
596 | * @param options An object with the following properties:
|
597 | * * `providers`: An array of providers of the [StaticProvider type](api/core/StaticProvider).
|
598 | * * `parent`: (optional) A parent injector.
|
599 | * * `name`: (optional) A developer-defined identifying name for the new injector.
|
600 | *
|
601 | * @returns The new injector instance.
|
602 | *
|
603 | */
|
604 | static create(options: {
|
605 | providers: StaticProvider[];
|
606 | parent?: Injector;
|
607 | name?: string;
|
608 | }): Injector;
|
609 | /** @nocollapse */
|
610 | static ɵprov: never;
|
611 | }
|
612 |
|
613 | /**
|
614 | * A type which has an `InjectorDef` static field.
|
615 | *
|
616 | * `InjectorDefTypes` can be used to configure a `StaticInjector`.
|
617 | *
|
618 | * @publicApi
|
619 | */
|
620 | declare interface InjectorType<T> extends Type<T> {
|
621 | /**
|
622 | * Opaque type whose structure is highly version dependent. Do not rely on any properties.
|
623 | */
|
624 | ɵinj: never;
|
625 | }
|
626 |
|
627 | /**
|
628 | * Describes the `InjectorDef` equivalent of a `ModuleWithProviders`, an `InjectorDefType` with an
|
629 | * associated array of providers.
|
630 | *
|
631 | * Objects of this type can be listed in the imports section of an `InjectorDef`.
|
632 | *
|
633 | * NOTE: This is a private type and should not be exported
|
634 | */
|
635 | declare interface InjectorTypeWithProviders<T> {
|
636 | ngModule: InjectorType<T>;
|
637 | providers?: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
|
638 | }
|
639 |
|
640 | /**
|
641 | * The existence of this constant (in this particular file) informs the Angular compiler that the
|
642 | * current program is actually @angular/core, which needs to be compiled specially.
|
643 | */
|
644 | export declare const ITS_JUST_ANGULAR = true;
|
645 |
|
646 | /**
|
647 | * Runtime link information for NgModules.
|
648 | *
|
649 | * This is the internal data structure used by the runtime to assemble components, directives,
|
650 | * pipes, and injectors.
|
651 | *
|
652 | * NOTE: Always use `ɵɵdefineNgModule` function to create this object,
|
653 | * never create the object directly since the shape of this object
|
654 | * can change between versions.
|
655 | */
|
656 | export declare interface NgModuleDef<T> {
|
657 | /** Token representing the module. Used by DI. */
|
658 | type: T;
|
659 | /** List of components to bootstrap. */
|
660 | bootstrap: Type<any>[] | (() => Type<any>[]);
|
661 | /** List of components, directives, and pipes declared by this module. */
|
662 | declarations: Type<any>[] | (() => Type<any>[]);
|
663 | /** List of modules or `ModuleWithProviders` imported by this module. */
|
664 | imports: Type<any>[] | (() => Type<any>[]);
|
665 | /**
|
666 | * List of modules, `ModuleWithProviders`, components, directives, or pipes exported by this
|
667 | * module.
|
668 | */
|
669 | exports: Type<any>[] | (() => Type<any>[]);
|
670 | /**
|
671 | * Cached value of computed `transitiveCompileScopes` for this module.
|
672 | *
|
673 | * This should never be read directly, but accessed via `transitiveScopesFor`.
|
674 | */
|
675 | transitiveCompileScopes: NgModuleTransitiveScopes | null;
|
676 | /** The set of schemas that declare elements to be allowed in the NgModule. */
|
677 | schemas: SchemaMetadata[] | null;
|
678 | /** Unique ID for the module with which it should be registered. */
|
679 | id: string | null;
|
680 | }
|
681 |
|
682 | export declare class NgModuleFactory<T> extends NgModuleFactory_2<T> {
|
683 | moduleType: Type<T>;
|
684 | constructor(moduleType: Type<T>);
|
685 | create(parentInjector: Injector | null): NgModuleRef<T>;
|
686 | }
|
687 |
|
688 | /**
|
689 | * @publicApi
|
690 | */
|
691 | declare abstract class NgModuleFactory_2<T> {
|
692 | abstract get moduleType(): Type<T>;
|
693 | abstract create(parentInjector: Injector | null): NgModuleRef<T>;
|
694 | }
|
695 |
|
696 | /**
|
697 | * Represents an instance of an `NgModule` created by an `NgModuleFactory`.
|
698 | * Provides access to the `NgModule` instance and related objects.
|
699 | *
|
700 | * @publicApi
|
701 | */
|
702 | declare abstract class NgModuleRef<T> {
|
703 | /**
|
704 | * The injector that contains all of the providers of the `NgModule`.
|
705 | */
|
706 | abstract get injector(): Injector;
|
707 | /**
|
708 | * The resolver that can retrieve the component factories
|
709 | * declared in the `entryComponents` property of the module.
|
710 | */
|
711 | abstract get componentFactoryResolver(): ComponentFactoryResolver;
|
712 | /**
|
713 | * The `NgModule` instance.
|
714 | */
|
715 | abstract get instance(): T;
|
716 | /**
|
717 | * Destroys the module instance and all of the data structures associated with it.
|
718 | */
|
719 | abstract destroy(): void;
|
720 | /**
|
721 | * Registers a callback to be executed when the module is destroyed.
|
722 | */
|
723 | abstract onDestroy(callback: () => void): void;
|
724 | }
|
725 |
|
726 | /**
|
727 | * Represents the expansion of an `NgModule` into its scopes.
|
728 | *
|
729 | * A scope is a set of directives and pipes that are visible in a particular context. Each
|
730 | * `NgModule` has two scopes. The `compilation` scope is the set of directives and pipes that will
|
731 | * be recognized in the templates of components declared by the module. The `exported` scope is the
|
732 | * set of directives and pipes exported by a module (that is, module B's exported scope gets added
|
733 | * to module A's compilation scope when module A imports B).
|
734 | */
|
735 | declare interface NgModuleTransitiveScopes {
|
736 | compilation: {
|
737 | directives: Set<any>;
|
738 | pipes: Set<any>;
|
739 | };
|
740 | exported: {
|
741 | directives: Set<any>;
|
742 | pipes: Set<any>;
|
743 | };
|
744 | schemas: SchemaMetadata[] | null;
|
745 | }
|
746 |
|
747 |
|
748 | /**
|
749 | * A schema definition associated with an NgModule.
|
750 | *
|
751 | * @see `@NgModule`, `CUSTOM_ELEMENTS_SCHEMA`, `NO_ERRORS_SCHEMA`
|
752 | *
|
753 | * @param name The name of a defined schema.
|
754 | *
|
755 | * @publicApi
|
756 | */
|
757 | declare interface SchemaMetadata {
|
758 | name: string;
|
759 | }
|
760 |
|
761 | /**
|
762 | * Adds decorator, constructor, and property metadata to a given type via static metadata fields
|
763 | * on the type.
|
764 | *
|
765 | * These metadata fields can later be read with Angular's `ReflectionCapabilities` API.
|
766 | *
|
767 | * Calls to `setClassMetadata` can be marked as pure, resulting in the metadata assignments being
|
768 | * tree-shaken away during production builds.
|
769 | */
|
770 | export declare function setClassMetadata(type: Type<any>, decorators: any[] | null, ctorParameters: (() => any[]) | null, propDecorators: {
|
771 | [field: string]: any;
|
772 | } | null): void;
|
773 |
|
774 | /**
|
775 | * Configures the `Injector` to return an instance of `useClass` for a token.
|
776 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
777 | *
|
778 | * @usageNotes
|
779 | *
|
780 | * {@example core/di/ts/provider_spec.ts region='StaticClassProvider'}
|
781 | *
|
782 | * Note that following two providers are not equal:
|
783 | *
|
784 | * {@example core/di/ts/provider_spec.ts region='StaticClassProviderDifference'}
|
785 | *
|
786 | * ### Multi-value example
|
787 | *
|
788 | * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
789 | *
|
790 | * @publicApi
|
791 | */
|
792 | declare interface StaticClassProvider extends StaticClassSansProvider {
|
793 | /**
|
794 | * An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
|
795 | */
|
796 | provide: any;
|
797 | /**
|
798 | * When true, injector returns an array of instances. This is useful to allow multiple
|
799 | * providers spread across many files to provide configuration information to a common token.
|
800 | */
|
801 | multi?: boolean;
|
802 | }
|
803 |
|
804 | /**
|
805 | * Configures the `Injector` to return an instance of `useClass` for a token.
|
806 | * Base for `StaticClassProvider` decorator.
|
807 | *
|
808 | * @publicApi
|
809 | */
|
810 | declare interface StaticClassSansProvider {
|
811 | /**
|
812 | * An optional class to instantiate for the `token`. By default, the `provide`
|
813 | * class is instantiated.
|
814 | */
|
815 | useClass: Type<any>;
|
816 | /**
|
817 | * A list of `token`s to be resolved by the injector. The list of values is then
|
818 | * used as arguments to the `useClass` constructor.
|
819 | */
|
820 | deps: any[];
|
821 | }
|
822 |
|
823 | /**
|
824 | * Describes how an `Injector` should be configured as static (that is, without reflection).
|
825 | * A static provider provides tokens to an injector for various types of dependencies.
|
826 | *
|
827 | * @see [Injector.create()](/api/core/Injector#create).
|
828 | * @see ["Dependency Injection Guide"](guide/dependency-injection-providers).
|
829 | *
|
830 | * @publicApi
|
831 | */
|
832 | declare type StaticProvider = ValueProvider | ExistingProvider | StaticClassProvider | ConstructorProvider | FactoryProvider | any[];
|
833 |
|
834 | /**
|
835 | * @description
|
836 | *
|
837 | * Represents a type that a Component or other object is instances of.
|
838 | *
|
839 | * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is represented by
|
840 | * the `MyCustomComponent` constructor function.
|
841 | *
|
842 | * @publicApi
|
843 | */
|
844 | declare const Type: FunctionConstructor;
|
845 |
|
846 | declare interface Type<T> extends Function {
|
847 | new (...args: any[]): T;
|
848 | }
|
849 |
|
850 | /**
|
851 | * Configures the `Injector` to return a value for a token.
|
852 | * @see ["Dependency Injection Guide"](guide/dependency-injection).
|
853 | *
|
854 | * @usageNotes
|
855 | *
|
856 | * ### Example
|
857 | *
|
858 | * {@example core/di/ts/provider_spec.ts region='ValueProvider'}
|
859 | *
|
860 | * ### Multi-value example
|
861 | *
|
862 | * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}
|
863 | *
|
864 | * @publicApi
|
865 | */
|
866 | declare interface ValueProvider extends ValueSansProvider {
|
867 | /**
|
868 | * An injection token. Typically an instance of `Type` or `InjectionToken`, but can be `any`.
|
869 | */
|
870 | provide: any;
|
871 | /**
|
872 | * When true, injector returns an array of instances. This is useful to allow multiple
|
873 | * providers spread across many files to provide configuration information to a common token.
|
874 | */
|
875 | multi?: boolean;
|
876 | }
|
877 |
|
878 | /**
|
879 | * Configures the `Injector` to return a value for a token.
|
880 | * Base for `ValueProvider` decorator.
|
881 | *
|
882 | * @publicApi
|
883 | */
|
884 | declare interface ValueSansProvider {
|
885 | /**
|
886 | * The value to inject.
|
887 | */
|
888 | useValue: any;
|
889 | }
|
890 |
|
891 | /**
|
892 | * Represents an Angular [view](guide/glossary#view "Definition").
|
893 | *
|
894 | * @see {@link ChangeDetectorRef#usage-notes Change detection usage}
|
895 | *
|
896 | * @publicApi
|
897 | */
|
898 | declare abstract class ViewRef extends ChangeDetectorRef {
|
899 | /**
|
900 | * Destroys this view and all of the data structures associated with it.
|
901 | */
|
902 | abstract destroy(): void;
|
903 | /**
|
904 | * Reports whether this view has been destroyed.
|
905 | * @returns True after the `destroy()` method has been called, false otherwise.
|
906 | */
|
907 | abstract get destroyed(): boolean;
|
908 | /**
|
909 | * A lifecycle hook that provides additional developer-defined cleanup
|
910 | * functionality for views.
|
911 | * @param callback A handler function that cleans up developer-defined data
|
912 | * associated with a view. Called when the `destroy()` method is invoked.
|
913 | */
|
914 | abstract onDestroy(callback: Function): any /** TODO #9100 */;
|
915 | }
|
916 |
|
917 |
|
918 | /**
|
919 | * Convince closure compiler that the wrapped function has no side-effects.
|
920 | *
|
921 | * Closure compiler always assumes that `toString` has no side-effects. We use this quirk to
|
922 | * allow us to execute a function but have closure compiler mark the call as no-side-effects.
|
923 | * It is important that the return value for the `noSideEffects` function be assigned
|
924 | * to something which is retained otherwise the call to `noSideEffects` will be removed by closure
|
925 | * compiler.
|
926 | */
|
927 | export declare function ɵnoSideEffects<T>(fn: () => T): T;
|
928 |
|
929 | /**
|
930 | * Construct an `InjectableDef` which defines how a token will be constructed by the DI system, and
|
931 | * in which injectors (if any) it will be available.
|
932 | *
|
933 | * This should be assigned to a static `ɵprov` field on a type, which will then be an
|
934 | * `InjectableType`.
|
935 | *
|
936 | * Options:
|
937 | * * `providedIn` determines which injectors will include the injectable, by either associating it
|
938 | * with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be
|
939 | * provided in the `'root'` injector, which will be the application-level injector in most apps.
|
940 | * * `factory` gives the zero argument function which will create an instance of the injectable.
|
941 | * The factory can call `inject` to access the `Injector` and request injection of dependencies.
|
942 | *
|
943 | * @codeGenApi
|
944 | * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
|
945 | */
|
946 | export declare function ɵɵdefineInjectable<T>(opts: {
|
947 | token: unknown;
|
948 | providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
|
949 | factory: () => T;
|
950 | }): never;
|
951 |
|
952 | /**
|
953 | * Construct an `InjectorDef` which configures an injector.
|
954 | *
|
955 | * This should be assigned to a static injector def (`ɵinj`) field on a type, which will then be an
|
956 | * `InjectorType`.
|
957 | *
|
958 | * Options:
|
959 | *
|
960 | * * `factory`: an `InjectorType` is an instantiable type, so a zero argument `factory` function to
|
961 | * create the type must be provided. If that factory function needs to inject arguments, it can
|
962 | * use the `inject` function.
|
963 | * * `providers`: an optional array of providers to add to the injector. Each provider must
|
964 | * either have a factory or point to a type which has a `ɵprov` static property (the
|
965 | * type must be an `InjectableType`).
|
966 | * * `imports`: an optional array of imports of other `InjectorType`s or `InjectorTypeWithModule`s
|
967 | * whose providers will also be added to the injector. Locally provided types will override
|
968 | * providers from imports.
|
969 | *
|
970 | * @codeGenApi
|
971 | */
|
972 | export declare function ɵɵdefineInjector(options: {
|
973 | factory: () => any;
|
974 | providers?: any[];
|
975 | imports?: any[];
|
976 | }): never;
|
977 |
|
978 | /**
|
979 | * @codeGenApi
|
980 | */
|
981 | export declare function ɵɵdefineNgModule<T>(def: {
|
982 | /** Token representing the module. Used by DI. */
|
983 | type: T;
|
984 | /** List of components to bootstrap. */
|
985 | bootstrap?: Type<any>[] | (() => Type<any>[]);
|
986 | /** List of components, directives, and pipes declared by this module. */
|
987 | declarations?: Type<any>[] | (() => Type<any>[]);
|
988 | /** List of modules or `ModuleWithProviders` imported by this module. */
|
989 | imports?: Type<any>[] | (() => Type<any>[]);
|
990 | /**
|
991 | * List of modules, `ModuleWithProviders`, components, directives, or pipes exported by this
|
992 | * module.
|
993 | */
|
994 | exports?: Type<any>[] | (() => Type<any>[]);
|
995 | /** The set of schemas that declare elements to be allowed in the NgModule. */
|
996 | schemas?: SchemaMetadata[] | null;
|
997 | /** Unique ID for the module that is used with `getModuleFactory`. */
|
998 | id?: string | null;
|
999 | }): never;
|
1000 |
|
1001 | /**
|
1002 | * @codeGenApi
|
1003 | */
|
1004 | export declare type ɵɵFactoryDef<T, CtorDependencies extends CtorDependency[]> = () => T;
|
1005 |
|
1006 | /**
|
1007 | * Generated instruction: Injects a token from the currently active injector.
|
1008 | *
|
1009 | * Must be used in the context of a factory function such as one defined for an
|
1010 | * `InjectionToken`. Throws an error if not called from such a context.
|
1011 | *
|
1012 | * (Additional documentation moved to `inject`, as it is the public API, and an alias for this
|
1013 | * instruction)
|
1014 | *
|
1015 | * @see inject
|
1016 | * @codeGenApi
|
1017 | * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
|
1018 | */
|
1019 | export declare function ɵɵinject<T>(token: Type<T> | InjectionToken<T>): T;
|
1020 |
|
1021 | export declare function ɵɵinject<T>(token: Type<T> | InjectionToken<T>, flags?: InjectFlags): T | null;
|
1022 |
|
1023 | /**
|
1024 | * Information about how a type or `InjectionToken` interfaces with the DI system.
|
1025 | *
|
1026 | * At a minimum, this includes a `factory` which defines how to create the given type `T`, possibly
|
1027 | * requesting injection of other types if necessary.
|
1028 | *
|
1029 | * Optionally, a `providedIn` parameter specifies that the given type belongs to a particular
|
1030 | * `InjectorDef`, `NgModule`, or a special scope (e.g. `'root'`). A value of `null` indicates
|
1031 | * that the injectable does not belong to any scope.
|
1032 | *
|
1033 | * @codeGenApi
|
1034 | * @publicApi The ViewEngine compiler emits code with this type for injectables. This code is
|
1035 | * deployed to npm, and should be treated as public api.
|
1036 |
|
1037 | */
|
1038 | export declare interface ɵɵInjectableDef<T> {
|
1039 | /**
|
1040 | * Specifies that the given type belongs to a particular injector:
|
1041 | * - `InjectorType` such as `NgModule`,
|
1042 | * - `'root'` the root injector
|
1043 | * - `'any'` all injectors.
|
1044 | * - `null`, does not belong to any injector. Must be explicitly listed in the injector
|
1045 | * `providers`.
|
1046 | */
|
1047 | providedIn: InjectorType<any> | 'root' | 'platform' | 'any' | null;
|
1048 | /**
|
1049 | * The token to which this definition belongs.
|
1050 | *
|
1051 | * Note that this may not be the same as the type that the `factory` will create.
|
1052 | */
|
1053 | token: unknown;
|
1054 | /**
|
1055 | * Factory method to execute to create an instance of the injectable.
|
1056 | */
|
1057 | factory: (t?: Type<any>) => T;
|
1058 | /**
|
1059 | * In a case of no explicit injector, a location where the instance of the injectable is stored.
|
1060 | */
|
1061 | value: T | undefined;
|
1062 | }
|
1063 |
|
1064 | /**
|
1065 | * Information about the providers to be included in an `Injector` as well as how the given type
|
1066 | * which carries the information should be created by the DI system.
|
1067 | *
|
1068 | * An `InjectorDef` can import other types which have `InjectorDefs`, forming a deep nested
|
1069 | * structure of providers with a defined priority (identically to how `NgModule`s also have
|
1070 | * an import/dependency structure).
|
1071 | *
|
1072 | * NOTE: This is a private type and should not be exported
|
1073 | *
|
1074 | * @codeGenApi
|
1075 | */
|
1076 | export declare interface ɵɵInjectorDef<T> {
|
1077 | factory: () => T;
|
1078 | providers: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
|
1079 | imports: (InjectorType<any> | InjectorTypeWithProviders<any>)[];
|
1080 | }
|
1081 |
|
1082 | /**
|
1083 | * @publicApi
|
1084 | */
|
1085 | export declare type ɵɵNgModuleDefWithMeta<T, Declarations, Imports, Exports> = NgModuleDef<T>;
|
1086 |
|
1087 | export { }
|