animations.mjs 8.4 KB

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