Skip to content

Commit 34d8769

Browse files
committed
Refactor animate runner to ESM
1 parent 64289d8 commit 34d8769

17 files changed

+191
-105
lines changed

@types/animations/animate-css-driver.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export class AnimateCssDriverProvider {
88
| string
99
| ((
1010
$animateCss: any,
11-
$$AnimateRunner: typeof import("./runner/animate-runner.js").AnimateRunner,
1211
$rootElement: Element,
1312
) => (animationDetails: any) => any)
1413
)[];

@types/animations/animate-css.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export class AnimateCssProvider {
33
$get: (
44
| string
55
| ((
6-
$$AnimateRunner: typeof import("./runner/animate-runner.js").AnimateRunner,
76
$$animateCache: any,
87
$$rAFScheduler: any,
98
) => (

@types/animations/animate-js-driver.d.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
export function AnimateJsDriverProvider($$animationProvider: any): void;
22
export class AnimateJsDriverProvider {
33
constructor($$animationProvider: any);
4-
$get: (
5-
| string
6-
| ((
7-
$$animateJs: any,
8-
$$AnimateRunner: typeof import("./runner/animate-runner.js").AnimateRunner,
9-
) => (animationDetails: any) => any)
10-
)[];
4+
$get: (string | (($$animateJs: any) => (animationDetails: any) => any))[];
115
}
126
export namespace AnimateJsDriverProvider {
137
let $inject: string[];

@types/animations/animate-js.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ export class AnimateJsProvider {
33
constructor($animateProvider: any);
44
$get: (
55
| string
6-
| ((
7-
$injector: ng.InjectorService,
8-
$$AnimateRunner: typeof import("./runner/animate-runner.js").AnimateRunner,
9-
) => (
6+
| (($injector: ng.InjectorService) => (
107
element: any,
118
event: any,
129
classes: any,

@types/animations/animate-queue.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export class AnimateQueueProvider {
1212
$rootScope: import("../core/scope/scope.js").Scope,
1313
$injector: import("../core/di/internal-injector.js").InjectorService,
1414
$$animation: any,
15-
$$AnimateRunner: typeof import("./runner/animate-runner.js").AnimateRunner,
1615
$templateRequest: any,
1716
) => {
1817
on(event: any, container: any, callback: any): void;

@types/animations/animation.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ export class AnimationProvider {
66
| ((
77
$rootScope: ng.RootScopeService,
88
$injector: any,
9-
$$AnimateRunner: typeof import("./runner/animate-runner.js").AnimateRunner,
109
$$rAFScheduler: any,
1110
$$animateCache: any,
12-
) => (
13-
element: any,
14-
event: any,
15-
options: any,
16-
) => import("./runner/animate-runner.js").AnimateRunner)
11+
) => (element: any, event: any, options: any) => AnimateRunner)
1712
)[];
1813
}
14+
import { AnimateRunner } from "./runner/animate-runner.js";

@types/animations/runner/animate-runner.d.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
* @param {VoidFunction} fn - The callback to execute.
66
*/
77
export function schedule(fn: VoidFunction): void;
8-
/**
9-
* Provider for the `$$AnimateRunner` service.
10-
* Used to inject the runner into the animation subsystem.
11-
*/
12-
export class AnimateRunnerFactoryProvider {
13-
/** @type {() => typeof AnimateRunner} */
14-
$get: () => typeof AnimateRunner;
15-
}
168
/**
179
* Represents an asynchronous animation operation.
1810
* Provides both callback-based and promise-based completion APIs.
@@ -41,8 +33,8 @@ export class AnimateRunner {
4133
host: import("../interface.ts").AnimationHost;
4234
/** @type {Array<(ok: boolean) => void>} */
4335
_doneCallbacks: Array<(ok: boolean) => void>;
44-
/** @type {0|1|2} */
45-
_state: 0 | 1 | 2;
36+
/** @type {RunnerState} */
37+
_state: RunnerState;
4638
/** @type {Promise<void>|null} */
4739
_promise: Promise<void> | null;
4840
/** @type {(fn: VoidFunction) => void} */
@@ -95,3 +87,13 @@ export class AnimateRunner {
9587
*/
9688
private _finish;
9789
}
90+
/**
91+
* Internal runner states.
92+
*/
93+
type RunnerState = number;
94+
declare namespace RunnerState {
95+
let INITIAL: number;
96+
let PENDING: number;
97+
let DONE: number;
98+
}
99+
export {};

src/animations/animate-css-driver.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { isString } from "../shared/utils.js";
2+
import { AnimateRunner } from "./runner/animate-runner.js";
23
import { concatWithSpace } from "./shared.js";
34

45
const NG_ANIMATE_SHIM_CLASS_NAME = "ng-animate-shim";
@@ -20,16 +21,14 @@ export function AnimateCssDriverProvider($$animationProvider) {
2021
*/
2122
this.$get = [
2223
"$animateCss",
23-
"$$AnimateRunner",
2424
"$rootElement",
2525
/**
2626
*
2727
* @param {*} $animateCss
28-
* @param {typeof import('./runner/animate-runner.js').AnimateRunner} $$AnimateRunner
2928
* @param {Element} $rootElement
3029
* @returns
3130
*/
32-
function ($animateCss, $$AnimateRunner, $rootElement) {
31+
function ($animateCss, $rootElement) {
3332
const bodyNode = document.body;
3433
const rootNode = $rootElement;
3534

@@ -102,7 +101,7 @@ export function AnimateCssDriverProvider($$animationProvider) {
102101
runner.complete();
103102
});
104103

105-
runner = new $$AnimateRunner({
104+
runner = new AnimateRunner({
106105
end: endFn,
107106
cancel: endFn,
108107
});
@@ -213,12 +212,12 @@ export function AnimateCssDriverProvider($$animationProvider) {
213212
animationRunners.push(animation.start());
214213
});
215214

216-
const runner = new $$AnimateRunner({
215+
const runner = new AnimateRunner({
217216
end: endFn,
218217
cancel: endFn, // CSS-driven animations cannot be cancelled, only ended
219218
});
220219

221-
$$AnimateRunner.all(animationRunners, (status) => {
220+
AnimateRunner.all(animationRunners, (status) => {
222221
runner.complete(status);
223222
});
224223

src/animations/animate-css.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
setCacheData,
55
} from "../shared/dom.js";
66
import { isDefined } from "../shared/utils.js";
7+
import { AnimateRunner } from "./runner/animate-runner.js";
78
import {
89
ACTIVE_CLASS_SUFFIX,
910
ADD_CLASS_SUFFIX,
@@ -143,18 +144,16 @@ function registerRestorableStyles(backup, node, properties) {
143144
export function AnimateCssProvider() {
144145
let activeClasses;
145146
this.$get = [
146-
"$$AnimateRunner",
147147
"$$animateCache",
148148
"$$rAFScheduler",
149149

150150
/**
151151
*
152-
* @param {typeof import("./runner/animate-runner.js").AnimateRunner} $$AnimateRunner
153152
* @param {*} $$animateCache
154153
* @param {import("./raf-scheduler").RafScheduler} $$rAFScheduler
155154
* @returns
156155
*/
157-
function ($$AnimateRunner, $$animateCache, $$rAFScheduler) {
156+
function ($$animateCache, $$rAFScheduler) {
158157
const applyAnimationClasses = applyAnimationClassesFactory();
159158

160159
function computeCachedCssStyles(
@@ -552,7 +551,7 @@ export function AnimateCssProvider() {
552551
pause: null,
553552
};
554553

555-
runner = new $$AnimateRunner(runnerHost);
554+
runner = new AnimateRunner(runnerHost);
556555

557556
waitUntilQuiet(start);
558557

@@ -651,7 +650,7 @@ export function AnimateCssProvider() {
651650
}
652651

653652
function closeAndReturnNoopAnimator() {
654-
runner = new $$AnimateRunner({
653+
runner = new AnimateRunner({
655654
end: endFn,
656655
cancel: cancelFn,
657656
});

src/animations/animate-js-driver.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
import { AnimateRunner } from "./runner/animate-runner.js";
2+
13
AnimateJsDriverProvider.$inject = ["$$animationProvider"];
24
export function AnimateJsDriverProvider($$animationProvider) {
35
$$animationProvider.drivers.push("$$animateJsDriver");
46
this.$get = [
57
"$$animateJs",
6-
"$$AnimateRunner",
78
/**
89
*
910
* @param {*} $$animateJs
10-
* @param {typeof import("./runner/animate-runner.js").AnimateRunner} $$AnimateRunner
11-
* @returns
1211
*/
13-
function ($$animateJs, $$AnimateRunner) {
12+
function ($$animateJs) {
1413
return function initDriverFn(animationDetails) {
1514
if (animationDetails.from && animationDetails.to) {
1615
const fromAnimation = prepareAnimation(animationDetails.from);
@@ -29,9 +28,9 @@ export function AnimateJsDriverProvider($$animationProvider) {
2928
animationRunners.push(toAnimation.start());
3029
}
3130

32-
$$AnimateRunner.all(animationRunners, done);
31+
AnimateRunner.all(animationRunners, done);
3332

34-
const runner = new $$AnimateRunner({
33+
const runner = new AnimateRunner({
3534
end: endFnFactory(),
3635
cancel: endFnFactory(),
3736
});

0 commit comments

Comments
 (0)