UNPKG

8.7 kBJavaScriptView Raw
1/**
2 * @license Angular v17.3.7
3 * (c) 2010-2024 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import * as i0 from '@angular/core';
8import { inject, ɵChangeDetectionScheduler, Injectable, Inject, RendererFactory2, NgZone, ANIMATION_MODULE_TYPE, NgModule, ɵperformanceMarkFeature } from '@angular/core';
9export { ANIMATION_MODULE_TYPE } from '@angular/core';
10import { ɵDomRendererFactory2, BrowserModule } from '@angular/platform-browser';
11import * as i1 from '@angular/animations/browser';
12import { ɵAnimationEngine, ɵWebAnimationsStyleNormalizer, ɵAnimationRendererFactory, ɵAnimationStyleNormalizer, AnimationDriver, ɵWebAnimationsDriver, NoopAnimationDriver } from '@angular/animations/browser';
13import { DOCUMENT } from '@angular/common';
14
15class InjectableAnimationEngine extends ɵAnimationEngine {
16 // The `ApplicationRef` is injected here explicitly to force the dependency ordering.
17 // Since the `ApplicationRef` should be created earlier before the `AnimationEngine`, they
18 // both have `ngOnDestroy` hooks and `flush()` must be called after all views are destroyed.
19 constructor(doc, driver, normalizer) {
20 super(doc, driver, normalizer, inject(ɵChangeDetectionScheduler, { optional: true }));
21 }
22 ngOnDestroy() {
23 this.flush();
24 }
25 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: InjectableAnimationEngine, deps: [{ token: DOCUMENT }, { token: i1.AnimationDriver }, { token: i1.ɵAnimationStyleNormalizer }], target: i0.ɵɵFactoryTarget.Injectable }); }
26 static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: InjectableAnimationEngine }); }
27}
28i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: InjectableAnimationEngine, decorators: [{
29 type: Injectable
30 }], ctorParameters: () => [{ type: Document, decorators: [{
31 type: Inject,
32 args: [DOCUMENT]
33 }] }, { type: i1.AnimationDriver }, { type: i1.ɵAnimationStyleNormalizer }] });
34function instantiateDefaultStyleNormalizer() {
35 return new ɵWebAnimationsStyleNormalizer();
36}
37function instantiateRendererFactory(renderer, engine, zone) {
38 return new ɵAnimationRendererFactory(renderer, engine, zone);
39}
40const SHARED_ANIMATION_PROVIDERS = [
41 { provide: ɵAnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer },
42 { provide: ɵAnimationEngine, useClass: InjectableAnimationEngine }, {
43 provide: RendererFactory2,
44 useFactory: instantiateRendererFactory,
45 deps: [ɵDomRendererFactory2, ɵAnimationEngine, NgZone]
46 }
47];
48/**
49 * Separate providers from the actual module so that we can do a local modification in Google3 to
50 * include them in the BrowserModule.
51 */
52const BROWSER_ANIMATIONS_PROVIDERS = [
53 { provide: AnimationDriver, useFactory: () => new ɵWebAnimationsDriver() },
54 { provide: ANIMATION_MODULE_TYPE, useValue: 'BrowserAnimations' }, ...SHARED_ANIMATION_PROVIDERS
55];
56/**
57 * Separate providers from the actual module so that we can do a local modification in Google3 to
58 * include them in the BrowserTestingModule.
59 */
60const BROWSER_NOOP_ANIMATIONS_PROVIDERS = [
61 { provide: AnimationDriver, useClass: NoopAnimationDriver },
62 { provide: ANIMATION_MODULE_TYPE, useValue: 'NoopAnimations' }, ...SHARED_ANIMATION_PROVIDERS
63];
64
65/**
66 * Exports `BrowserModule` with additional [dependency-injection providers](guide/glossary#provider)
67 * for use with animations. See [Animations](guide/animations).
68 * @publicApi
69 */
70class BrowserAnimationsModule {
71 /**
72 * Configures the module based on the specified object.
73 *
74 * @param config Object used to configure the behavior of the `BrowserAnimationsModule`.
75 * @see {@link BrowserAnimationsModuleConfig}
76 *
77 * @usageNotes
78 * When registering the `BrowserAnimationsModule`, you can use the `withConfig`
79 * function as follows:
80 * ```
81 * @NgModule({
82 * imports: [BrowserAnimationsModule.withConfig(config)]
83 * })
84 * class MyNgModule {}
85 * ```
86 */
87 static withConfig(config) {
88 return {
89 ngModule: BrowserAnimationsModule,
90 providers: config.disableAnimations ? BROWSER_NOOP_ANIMATIONS_PROVIDERS :
91 BROWSER_ANIMATIONS_PROVIDERS
92 };
93 }
94 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: BrowserAnimationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
95 static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: BrowserAnimationsModule, exports: [BrowserModule] }); }
96 static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: BrowserAnimationsModule, providers: BROWSER_ANIMATIONS_PROVIDERS, imports: [BrowserModule] }); }
97}
98i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: BrowserAnimationsModule, decorators: [{
99 type: NgModule,
100 args: [{
101 exports: [BrowserModule],
102 providers: BROWSER_ANIMATIONS_PROVIDERS,
103 }]
104 }] });
105/**
106 * Returns the set of [dependency-injection providers](guide/glossary#provider)
107 * to enable animations in an application. See [animations guide](guide/animations)
108 * to learn more about animations in Angular.
109 *
110 * @usageNotes
111 *
112 * The function is useful when you want to enable animations in an application
113 * bootstrapped using the `bootstrapApplication` function. In this scenario there
114 * is no need to import the `BrowserAnimationsModule` NgModule at all, just add
115 * providers returned by this function to the `providers` list as show below.
116 *
117 * ```typescript
118 * bootstrapApplication(RootComponent, {
119 * providers: [
120 * provideAnimations()
121 * ]
122 * });
123 * ```
124 *
125 * @publicApi
126 */
127function provideAnimations() {
128 ɵperformanceMarkFeature('NgEagerAnimations');
129 // Return a copy to prevent changes to the original array in case any in-place
130 // alterations are performed to the `provideAnimations` call results in app code.
131 return [...BROWSER_ANIMATIONS_PROVIDERS];
132}
133/**
134 * A null player that must be imported to allow disabling of animations.
135 * @publicApi
136 */
137class NoopAnimationsModule {
138 static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: NoopAnimationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
139 static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: NoopAnimationsModule, exports: [BrowserModule] }); }
140 static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: NoopAnimationsModule, providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS, imports: [BrowserModule] }); }
141}
142i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: NoopAnimationsModule, decorators: [{
143 type: NgModule,
144 args: [{
145 exports: [BrowserModule],
146 providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS,
147 }]
148 }] });
149/**
150 * Returns the set of [dependency-injection providers](guide/glossary#provider)
151 * to disable animations in an application. See [animations guide](guide/animations)
152 * to learn more about animations in Angular.
153 *
154 * @usageNotes
155 *
156 * The function is useful when you want to bootstrap an application using
157 * the `bootstrapApplication` function, but you need to disable animations
158 * (for example, when running tests).
159 *
160 * ```typescript
161 * bootstrapApplication(RootComponent, {
162 * providers: [
163 * provideNoopAnimations()
164 * ]
165 * });
166 * ```
167 *
168 * @publicApi
169 */
170function provideNoopAnimations() {
171 // Return a copy to prevent changes to the original array in case any in-place
172 // alterations are performed to the `provideNoopAnimations` call results in app code.
173 return [...BROWSER_NOOP_ANIMATIONS_PROVIDERS];
174}
175
176/**
177 * @module
178 * @description
179 * Entry point for all animation APIs of the animation browser package.
180 */
181
182/**
183 * @module
184 * @description
185 * Entry point for all public APIs of this package.
186 */
187
188// This file is not used to build this module. It is only used during editing
189
190/**
191 * Generated bundle index. Do not edit.
192 */
193
194export { BrowserAnimationsModule, NoopAnimationsModule, provideAnimations, provideNoopAnimations, InjectableAnimationEngine as ɵInjectableAnimationEngine };
195//# sourceMappingURL=animations.mjs.map