UNPKG

16.4 kBJavaScriptView Raw
1/**
2 * @license Angular v9.0.1
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7(function (global, factory) {
8 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/animations'), require('@angular/animations/browser')) :
9 typeof define === 'function' && define.amd ? define('@angular/animations/browser/testing', ['exports', '@angular/animations', '@angular/animations/browser'], factory) :
10 (global = global || self, factory((global.ng = global.ng || {}, global.ng.animations = global.ng.animations || {}, global.ng.animations.browser = global.ng.animations.browser || {}, global.ng.animations.browser.testing = {}), global.ng.animations, global.ng.animations.browser));
11}(this, (function (exports, animations, browser) { 'use strict';
12
13 /*! *****************************************************************************
14 Copyright (c) Microsoft Corporation. All rights reserved.
15 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
16 this file except in compliance with the License. You may obtain a copy of the
17 License at http://www.apache.org/licenses/LICENSE-2.0
18
19 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
21 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
22 MERCHANTABLITY OR NON-INFRINGEMENT.
23
24 See the Apache Version 2.0 License for specific language governing permissions
25 and limitations under the License.
26 ***************************************************************************** */
27 /* global Reflect, Promise */
28
29 var extendStatics = function(d, b) {
30 extendStatics = Object.setPrototypeOf ||
31 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33 return extendStatics(d, b);
34 };
35
36 function __extends(d, b) {
37 extendStatics(d, b);
38 function __() { this.constructor = d; }
39 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40 }
41
42 var __assign = function() {
43 __assign = Object.assign || function __assign(t) {
44 for (var s, i = 1, n = arguments.length; i < n; i++) {
45 s = arguments[i];
46 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
47 }
48 return t;
49 };
50 return __assign.apply(this, arguments);
51 };
52
53 function __rest(s, e) {
54 var t = {};
55 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
56 t[p] = s[p];
57 if (s != null && typeof Object.getOwnPropertySymbols === "function")
58 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
59 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60 t[p[i]] = s[p[i]];
61 }
62 return t;
63 }
64
65 function __decorate(decorators, target, key, desc) {
66 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
67 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
68 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
69 return c > 3 && r && Object.defineProperty(target, key, r), r;
70 }
71
72 function __param(paramIndex, decorator) {
73 return function (target, key) { decorator(target, key, paramIndex); }
74 }
75
76 function __metadata(metadataKey, metadataValue) {
77 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
78 }
79
80 function __awaiter(thisArg, _arguments, P, generator) {
81 return new (P || (P = Promise))(function (resolve, reject) {
82 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
83 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
84 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
85 step((generator = generator.apply(thisArg, _arguments || [])).next());
86 });
87 }
88
89 function __generator(thisArg, body) {
90 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
91 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
92 function verb(n) { return function (v) { return step([n, v]); }; }
93 function step(op) {
94 if (f) throw new TypeError("Generator is already executing.");
95 while (_) try {
96 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
97 if (y = 0, t) op = [op[0] & 2, t.value];
98 switch (op[0]) {
99 case 0: case 1: t = op; break;
100 case 4: _.label++; return { value: op[1], done: false };
101 case 5: _.label++; y = op[1]; op = [0]; continue;
102 case 7: op = _.ops.pop(); _.trys.pop(); continue;
103 default:
104 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
105 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
106 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
107 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
108 if (t[2]) _.ops.pop();
109 _.trys.pop(); continue;
110 }
111 op = body.call(thisArg, _);
112 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
113 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
114 }
115 }
116
117 function __exportStar(m, exports) {
118 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
119 }
120
121 function __values(o) {
122 var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
123 if (m) return m.call(o);
124 return {
125 next: function () {
126 if (o && i >= o.length) o = void 0;
127 return { value: o && o[i++], done: !o };
128 }
129 };
130 }
131
132 function __read(o, n) {
133 var m = typeof Symbol === "function" && o[Symbol.iterator];
134 if (!m) return o;
135 var i = m.call(o), r, ar = [], e;
136 try {
137 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
138 }
139 catch (error) { e = { error: error }; }
140 finally {
141 try {
142 if (r && !r.done && (m = i["return"])) m.call(i);
143 }
144 finally { if (e) throw e.error; }
145 }
146 return ar;
147 }
148
149 function __spread() {
150 for (var ar = [], i = 0; i < arguments.length; i++)
151 ar = ar.concat(__read(arguments[i]));
152 return ar;
153 }
154
155 function __spreadArrays() {
156 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
157 for (var r = Array(s), k = 0, i = 0; i < il; i++)
158 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
159 r[k] = a[j];
160 return r;
161 };
162
163 function __await(v) {
164 return this instanceof __await ? (this.v = v, this) : new __await(v);
165 }
166
167 function __asyncGenerator(thisArg, _arguments, generator) {
168 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
169 var g = generator.apply(thisArg, _arguments || []), i, q = [];
170 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
171 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
172 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
173 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
174 function fulfill(value) { resume("next", value); }
175 function reject(value) { resume("throw", value); }
176 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
177 }
178
179 function __asyncDelegator(o) {
180 var i, p;
181 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
182 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
183 }
184
185 function __asyncValues(o) {
186 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
187 var m = o[Symbol.asyncIterator], i;
188 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
189 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
190 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
191 }
192
193 function __makeTemplateObject(cooked, raw) {
194 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
195 return cooked;
196 };
197
198 function __importStar(mod) {
199 if (mod && mod.__esModule) return mod;
200 var result = {};
201 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
202 result.default = mod;
203 return result;
204 }
205
206 function __importDefault(mod) {
207 return (mod && mod.__esModule) ? mod : { default: mod };
208 }
209
210 /**
211 * @publicApi
212 */
213 var MockAnimationDriver = /** @class */ (function () {
214 function MockAnimationDriver() {
215 }
216 MockAnimationDriver.prototype.validateStyleProperty = function (prop) { return browser.ɵvalidateStyleProperty(prop); };
217 MockAnimationDriver.prototype.matchesElement = function (element, selector) {
218 return browser.ɵmatchesElement(element, selector);
219 };
220 MockAnimationDriver.prototype.containsElement = function (elm1, elm2) { return browser.ɵcontainsElement(elm1, elm2); };
221 MockAnimationDriver.prototype.query = function (element, selector, multi) {
222 return browser.ɵinvokeQuery(element, selector, multi);
223 };
224 MockAnimationDriver.prototype.computeStyle = function (element, prop, defaultValue) {
225 return defaultValue || '';
226 };
227 MockAnimationDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers) {
228 if (previousPlayers === void 0) { previousPlayers = []; }
229 var player = new MockAnimationPlayer(element, keyframes, duration, delay, easing, previousPlayers);
230 MockAnimationDriver.log.push(player);
231 return player;
232 };
233 MockAnimationDriver.log = [];
234 return MockAnimationDriver;
235 }());
236 /**
237 * @publicApi
238 */
239 var MockAnimationPlayer = /** @class */ (function (_super) {
240 __extends(MockAnimationPlayer, _super);
241 function MockAnimationPlayer(element, keyframes, duration, delay, easing, previousPlayers) {
242 var _this = _super.call(this, duration, delay) || this;
243 _this.element = element;
244 _this.keyframes = keyframes;
245 _this.duration = duration;
246 _this.delay = delay;
247 _this.easing = easing;
248 _this.previousPlayers = previousPlayers;
249 _this.__finished = false;
250 _this.__started = false;
251 _this.previousStyles = {};
252 _this._onInitFns = [];
253 _this.currentSnapshot = {};
254 if (browser.ɵallowPreviousPlayerStylesMerge(duration, delay)) {
255 previousPlayers.forEach(function (player) {
256 if (player instanceof MockAnimationPlayer) {
257 var styles_1 = player.currentSnapshot;
258 Object.keys(styles_1).forEach(function (prop) { return _this.previousStyles[prop] = styles_1[prop]; });
259 }
260 });
261 }
262 return _this;
263 }
264 /* @internal */
265 MockAnimationPlayer.prototype.onInit = function (fn) { this._onInitFns.push(fn); };
266 /* @internal */
267 MockAnimationPlayer.prototype.init = function () {
268 _super.prototype.init.call(this);
269 this._onInitFns.forEach(function (fn) { return fn(); });
270 this._onInitFns = [];
271 };
272 MockAnimationPlayer.prototype.finish = function () {
273 _super.prototype.finish.call(this);
274 this.__finished = true;
275 };
276 MockAnimationPlayer.prototype.destroy = function () {
277 _super.prototype.destroy.call(this);
278 this.__finished = true;
279 };
280 /* @internal */
281 MockAnimationPlayer.prototype.triggerMicrotask = function () { };
282 MockAnimationPlayer.prototype.play = function () {
283 _super.prototype.play.call(this);
284 this.__started = true;
285 };
286 MockAnimationPlayer.prototype.hasStarted = function () { return this.__started; };
287 MockAnimationPlayer.prototype.beforeDestroy = function () {
288 var _this = this;
289 var captures = {};
290 Object.keys(this.previousStyles).forEach(function (prop) {
291 captures[prop] = _this.previousStyles[prop];
292 });
293 if (this.hasStarted()) {
294 // when assembling the captured styles, it's important that
295 // we build the keyframe styles in the following order:
296 // {other styles within keyframes, ... previousStyles }
297 this.keyframes.forEach(function (kf) {
298 Object.keys(kf).forEach(function (prop) {
299 if (prop != 'offset') {
300 captures[prop] = _this.__finished ? kf[prop] : animations.AUTO_STYLE;
301 }
302 });
303 });
304 }
305 this.currentSnapshot = captures;
306 };
307 return MockAnimationPlayer;
308 }(animations.NoopAnimationPlayer));
309
310 /**
311 * @license
312 * Copyright Google Inc. All Rights Reserved.
313 *
314 * Use of this source code is governed by an MIT-style license that can be
315 * found in the LICENSE file at https://angular.io/license
316 */
317
318 /**
319 * @license
320 * Copyright Google Inc. All Rights Reserved.
321 *
322 * Use of this source code is governed by an MIT-style license that can be
323 * found in the LICENSE file at https://angular.io/license
324 */
325
326 /**
327 * @license
328 * Copyright Google Inc. All Rights Reserved.
329 *
330 * Use of this source code is governed by an MIT-style license that can be
331 * found in the LICENSE file at https://angular.io/license
332 */
333
334 /**
335 * Generated bundle index. Do not edit.
336 */
337
338 exports.MockAnimationDriver = MockAnimationDriver;
339 exports.MockAnimationPlayer = MockAnimationPlayer;
340
341 Object.defineProperty(exports, '__esModule', { value: true });
342
343})));
344//# sourceMappingURL=animations-browser-testing.umd.js.map