animations.mjs 8.5 KB

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