@angular/animations 14.0.0-next.2 → 14.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/animations.d.ts +10 -2
- package/browser/browser.d.ts +15 -7
- package/browser/testing/testing.d.ts +2 -1
- package/esm2020/browser/src/dsl/animation.mjs +10 -6
- package/esm2020/browser/src/dsl/animation_ast_builder.mjs +24 -18
- package/esm2020/browser/src/dsl/animation_timeline_builder.mjs +3 -2
- package/esm2020/browser/src/dsl/animation_transition_expr.mjs +4 -3
- package/esm2020/browser/src/dsl/animation_transition_factory.mjs +1 -1
- package/esm2020/browser/src/dsl/animation_transition_instruction.mjs +1 -1
- package/esm2020/browser/src/dsl/animation_trigger.mjs +1 -1
- package/esm2020/browser/src/dsl/style_normalization/animation_style_normalizer.mjs +1 -1
- package/esm2020/browser/src/dsl/style_normalization/web_animations_style_normalizer.mjs +3 -2
- package/esm2020/browser/src/error_helpers.mjs +135 -0
- package/esm2020/browser/src/errors.mjs +9 -0
- package/esm2020/browser/src/private_export.mjs +2 -2
- package/esm2020/browser/src/render/animation_driver.mjs +8 -5
- package/esm2020/browser/src/render/animation_engine_next.mjs +9 -3
- package/esm2020/browser/src/render/shared.mjs +16 -5
- package/esm2020/browser/src/render/timeline_animation_engine.mjs +12 -6
- package/esm2020/browser/src/render/transition_animation_engine.mjs +28 -16
- package/esm2020/browser/src/render/web_animations/web_animations_driver.mjs +5 -2
- package/esm2020/browser/src/util.mjs +9 -8
- package/esm2020/browser/src/warning_helpers.mjs +33 -0
- package/esm2020/browser/testing/src/mock_animation_driver.mjs +5 -2
- package/esm2020/src/animation_metadata.mjs +10 -2
- package/esm2020/src/version.mjs +1 -1
- package/fesm2015/animations.mjs +10 -2
- package/fesm2015/animations.mjs.map +1 -1
- package/fesm2015/browser/testing.mjs +5 -2
- package/fesm2015/browser/testing.mjs.map +1 -1
- package/fesm2015/browser.mjs +273 -65
- package/fesm2015/browser.mjs.map +1 -1
- package/fesm2020/animations.mjs +10 -2
- package/fesm2020/animations.mjs.map +1 -1
- package/fesm2020/browser/testing.mjs +5 -2
- package/fesm2020/browser/testing.mjs.map +1 -1
- package/fesm2020/browser.mjs +273 -65
- package/fesm2020/browser.mjs.map +1 -1
- package/package.json +2 -2
package/fesm2015/browser.mjs
CHANGED
|
@@ -1,12 +1,146 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v14.0.0-next.
|
|
2
|
+
* @license Angular v14.0.0-next.5
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { ɵAnimationGroupPlayer, NoopAnimationPlayer, AUTO_STYLE, ɵPRE_STYLE, sequence, style } from '@angular/animations';
|
|
8
8
|
import * as i0 from '@angular/core';
|
|
9
|
-
import { Injectable } from '@angular/core';
|
|
9
|
+
import { ɵRuntimeError, Injectable } from '@angular/core';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @license
|
|
13
|
+
* Copyright Google LLC All Rights Reserved.
|
|
14
|
+
*
|
|
15
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
16
|
+
* found in the LICENSE file at https://angular.io/license
|
|
17
|
+
*/
|
|
18
|
+
const NG_DEV_MODE$1 = typeof ngDevMode === 'undefined' || !!ngDevMode;
|
|
19
|
+
const LINE_START = '\n - ';
|
|
20
|
+
function invalidTimingValue(exp) {
|
|
21
|
+
return new ɵRuntimeError(3000 /* INVALID_TIMING_VALUE */, NG_DEV_MODE$1 && `The provided timing value "${exp}" is invalid.`);
|
|
22
|
+
}
|
|
23
|
+
function negativeStepValue() {
|
|
24
|
+
return new ɵRuntimeError(3100 /* NEGATIVE_STEP_VALUE */, NG_DEV_MODE$1 && 'Duration values below 0 are not allowed for this animation step.');
|
|
25
|
+
}
|
|
26
|
+
function negativeDelayValue() {
|
|
27
|
+
return new ɵRuntimeError(3101 /* NEGATIVE_DELAY_VALUE */, NG_DEV_MODE$1 && 'Delay values below 0 are not allowed for this animation step.');
|
|
28
|
+
}
|
|
29
|
+
function invalidStyleParams(varName) {
|
|
30
|
+
return new ɵRuntimeError(3001 /* INVALID_STYLE_PARAMS */, NG_DEV_MODE$1 &&
|
|
31
|
+
`Unable to resolve the local animation param ${varName} in the given list of values`);
|
|
32
|
+
}
|
|
33
|
+
function invalidParamValue(varName) {
|
|
34
|
+
return new ɵRuntimeError(3003 /* INVALID_PARAM_VALUE */, NG_DEV_MODE$1 && `Please provide a value for the animation param ${varName}`);
|
|
35
|
+
}
|
|
36
|
+
function invalidNodeType(nodeType) {
|
|
37
|
+
return new ɵRuntimeError(3004 /* INVALID_NODE_TYPE */, NG_DEV_MODE$1 && `Unable to resolve animation metadata node #${nodeType}`);
|
|
38
|
+
}
|
|
39
|
+
function invalidCssUnitValue(userProvidedProperty, value) {
|
|
40
|
+
return new ɵRuntimeError(3005 /* INVALID_CSS_UNIT_VALUE */, NG_DEV_MODE$1 && `Please provide a CSS unit value for ${userProvidedProperty}:${value}`);
|
|
41
|
+
}
|
|
42
|
+
function invalidTrigger() {
|
|
43
|
+
return new ɵRuntimeError(3006 /* INVALID_TRIGGER */, NG_DEV_MODE$1 &&
|
|
44
|
+
'animation triggers cannot be prefixed with an `@` sign (e.g. trigger(\'@foo\', [...]))');
|
|
45
|
+
}
|
|
46
|
+
function invalidDefinition() {
|
|
47
|
+
return new ɵRuntimeError(3007 /* INVALID_DEFINITION */, NG_DEV_MODE$1 && 'only state() and transition() definitions can sit inside of a trigger()');
|
|
48
|
+
}
|
|
49
|
+
function invalidState(metadataName, missingSubs) {
|
|
50
|
+
return new ɵRuntimeError(3008 /* INVALID_STATE */, NG_DEV_MODE$1 &&
|
|
51
|
+
`state("${metadataName}", ...) must define default values for all the following style substitutions: ${missingSubs.join(', ')}`);
|
|
52
|
+
}
|
|
53
|
+
function invalidStyleValue(value) {
|
|
54
|
+
return new ɵRuntimeError(3002 /* INVALID_STYLE_VALUE */, NG_DEV_MODE$1 && `The provided style string value ${value} is not allowed.`);
|
|
55
|
+
}
|
|
56
|
+
function invalidProperty(prop) {
|
|
57
|
+
return new ɵRuntimeError(3009 /* INVALID_PROPERTY */, NG_DEV_MODE$1 &&
|
|
58
|
+
`The provided animation property "${prop}" is not a supported CSS property for animations`);
|
|
59
|
+
}
|
|
60
|
+
function invalidParallelAnimation(prop, firstStart, firstEnd, secondStart, secondEnd) {
|
|
61
|
+
return new ɵRuntimeError(3010 /* INVALID_PARALLEL_ANIMATION */, NG_DEV_MODE$1 &&
|
|
62
|
+
`The CSS property "${prop}" that exists between the times of "${firstStart}ms" and "${firstEnd}ms" is also being animated in a parallel animation between the times of "${secondStart}ms" and "${secondEnd}ms"`);
|
|
63
|
+
}
|
|
64
|
+
function invalidKeyframes() {
|
|
65
|
+
return new ɵRuntimeError(3011 /* INVALID_KEYFRAMES */, NG_DEV_MODE$1 && `keyframes() must be placed inside of a call to animate()`);
|
|
66
|
+
}
|
|
67
|
+
function invalidOffset() {
|
|
68
|
+
return new ɵRuntimeError(3012 /* INVALID_OFFSET */, NG_DEV_MODE$1 && `Please ensure that all keyframe offsets are between 0 and 1`);
|
|
69
|
+
}
|
|
70
|
+
function keyframeOffsetsOutOfOrder() {
|
|
71
|
+
return new ɵRuntimeError(3200 /* KEYFRAME_OFFSETS_OUT_OF_ORDER */, NG_DEV_MODE$1 && `Please ensure that all keyframe offsets are in order`);
|
|
72
|
+
}
|
|
73
|
+
function keyframesMissingOffsets() {
|
|
74
|
+
return new ɵRuntimeError(3202 /* KEYFRAMES_MISSING_OFFSETS */, NG_DEV_MODE$1 && `Not all style() steps within the declared keyframes() contain offsets`);
|
|
75
|
+
}
|
|
76
|
+
function invalidStagger() {
|
|
77
|
+
return new ɵRuntimeError(3013 /* INVALID_STAGGER */, NG_DEV_MODE$1 && `stagger() can only be used inside of query()`);
|
|
78
|
+
}
|
|
79
|
+
function invalidQuery(selector) {
|
|
80
|
+
return new ɵRuntimeError(3014 /* INVALID_QUERY */, NG_DEV_MODE$1 &&
|
|
81
|
+
`\`query("${selector}")\` returned zero elements. (Use \`query("${selector}", { optional: true })\` if you wish to allow this.)`);
|
|
82
|
+
}
|
|
83
|
+
function invalidExpression(expr) {
|
|
84
|
+
return new ɵRuntimeError(3015 /* INVALID_EXPRESSION */, NG_DEV_MODE$1 && `The provided transition expression "${expr}" is not supported`);
|
|
85
|
+
}
|
|
86
|
+
function invalidTransitionAlias(alias) {
|
|
87
|
+
return new ɵRuntimeError(3016 /* INVALID_TRANSITION_ALIAS */, NG_DEV_MODE$1 && `The transition alias value "${alias}" is not supported`);
|
|
88
|
+
}
|
|
89
|
+
function validationFailed(errors) {
|
|
90
|
+
return new ɵRuntimeError(3500 /* VALIDATION_FAILED */, NG_DEV_MODE$1 && `animation validation failed:\n${errors.map(err => err.message).join('\n')}`);
|
|
91
|
+
}
|
|
92
|
+
function buildingFailed(errors) {
|
|
93
|
+
return new ɵRuntimeError(3501 /* BUILDING_FAILED */, NG_DEV_MODE$1 && `animation building failed:\n${errors.map(err => err.message).join('\n')}`);
|
|
94
|
+
}
|
|
95
|
+
function triggerBuildFailed(name, errors) {
|
|
96
|
+
return new ɵRuntimeError(3404 /* TRIGGER_BUILD_FAILED */, NG_DEV_MODE$1 &&
|
|
97
|
+
`The animation trigger "${name}" has failed to build due to the following errors:\n - ${errors.map(err => err.message).join('\n - ')}`);
|
|
98
|
+
}
|
|
99
|
+
function animationFailed(errors) {
|
|
100
|
+
return new ɵRuntimeError(3502 /* ANIMATION_FAILED */, NG_DEV_MODE$1 &&
|
|
101
|
+
`Unable to animate due to the following errors:${LINE_START}${errors.map(err => err.message).join(LINE_START)}`);
|
|
102
|
+
}
|
|
103
|
+
function registerFailed(errors) {
|
|
104
|
+
return new ɵRuntimeError(3503 /* REGISTRATION_FAILED */, NG_DEV_MODE$1 &&
|
|
105
|
+
`Unable to build the animation due to the following errors: ${errors.map(err => err.message).join('\n')}`);
|
|
106
|
+
}
|
|
107
|
+
function missingOrDestroyedAnimation() {
|
|
108
|
+
return new ɵRuntimeError(3300 /* MISSING_OR_DESTROYED_ANIMATION */, NG_DEV_MODE$1 && 'The requested animation doesn\'t exist or has already been destroyed');
|
|
109
|
+
}
|
|
110
|
+
function createAnimationFailed(errors) {
|
|
111
|
+
return new ɵRuntimeError(3504 /* CREATE_ANIMATION_FAILED */, NG_DEV_MODE$1 &&
|
|
112
|
+
`Unable to create the animation due to the following errors:${errors.map(err => err.message).join('\n')}`);
|
|
113
|
+
}
|
|
114
|
+
function missingPlayer(id) {
|
|
115
|
+
return new ɵRuntimeError(3301 /* MISSING_PLAYER */, NG_DEV_MODE$1 && `Unable to find the timeline player referenced by ${id}`);
|
|
116
|
+
}
|
|
117
|
+
function missingTrigger(phase, name) {
|
|
118
|
+
return new ɵRuntimeError(3302 /* MISSING_TRIGGER */, NG_DEV_MODE$1 &&
|
|
119
|
+
`Unable to listen on the animation trigger event "${phase}" because the animation trigger "${name}" doesn\'t exist!`);
|
|
120
|
+
}
|
|
121
|
+
function missingEvent(name) {
|
|
122
|
+
return new ɵRuntimeError(3303 /* MISSING_EVENT */, NG_DEV_MODE$1 &&
|
|
123
|
+
`Unable to listen on the animation trigger "${name}" because the provided event is undefined!`);
|
|
124
|
+
}
|
|
125
|
+
function unsupportedTriggerEvent(phase, name) {
|
|
126
|
+
return new ɵRuntimeError(3400 /* UNSUPPORTED_TRIGGER_EVENT */, NG_DEV_MODE$1 &&
|
|
127
|
+
`The provided animation trigger event "${phase}" for the animation trigger "${name}" is not supported!`);
|
|
128
|
+
}
|
|
129
|
+
function unregisteredTrigger(name) {
|
|
130
|
+
return new ɵRuntimeError(3401 /* UNREGISTERED_TRIGGER */, NG_DEV_MODE$1 && `The provided animation trigger "${name}" has not been registered!`);
|
|
131
|
+
}
|
|
132
|
+
function triggerTransitionsFailed(errors) {
|
|
133
|
+
return new ɵRuntimeError(3402 /* TRIGGER_TRANSITIONS_FAILED */, NG_DEV_MODE$1 &&
|
|
134
|
+
`Unable to process animations due to the following failed trigger transitions\n ${errors.map(err => err.message).join('\n')}`);
|
|
135
|
+
}
|
|
136
|
+
function triggerParsingFailed(name, errors) {
|
|
137
|
+
return new ɵRuntimeError(3403 /* TRIGGER_PARSING_FAILED */, NG_DEV_MODE$1 &&
|
|
138
|
+
`Animation parsing for the ${name} trigger have failed:${LINE_START}${errors.map(err => err.message).join(LINE_START)}`);
|
|
139
|
+
}
|
|
140
|
+
function transitionFailed(name, errors) {
|
|
141
|
+
return new ɵRuntimeError(3505 /* TRANSITION_FAILED */, NG_DEV_MODE$1 &&
|
|
142
|
+
`@${name} has failed due to:\n ${errors.map(err => err.message).join('\n- ')}`);
|
|
143
|
+
}
|
|
10
144
|
|
|
11
145
|
/**
|
|
12
146
|
* @license
|
|
@@ -72,8 +206,7 @@ function normalizeKeyframes$1(driver, normalizer, element, keyframes, preStyles
|
|
|
72
206
|
previousOffset = offset;
|
|
73
207
|
});
|
|
74
208
|
if (errors.length) {
|
|
75
|
-
|
|
76
|
-
throw new Error(`Unable to animate due to the following errors:${LINE_START}${errors.join(LINE_START)}`);
|
|
209
|
+
throw animationFailed(errors);
|
|
77
210
|
}
|
|
78
211
|
return normalizedKeyframes;
|
|
79
212
|
}
|
|
@@ -120,6 +253,14 @@ let _contains = (elm1, elm2) => false;
|
|
|
120
253
|
let _query = (element, selector, multi) => {
|
|
121
254
|
return [];
|
|
122
255
|
};
|
|
256
|
+
let _documentElement = null;
|
|
257
|
+
function getParentElement(element) {
|
|
258
|
+
const parent = element.parentNode || element.host; // consider host to support shadow DOM
|
|
259
|
+
if (parent === _documentElement) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
return parent;
|
|
263
|
+
}
|
|
123
264
|
// Define utility methods for browsers and platform-server(domino) where Element
|
|
124
265
|
// and utility methods exist.
|
|
125
266
|
const _isNode = isNode();
|
|
@@ -128,12 +269,15 @@ if (_isNode || typeof Element !== 'undefined') {
|
|
|
128
269
|
_contains = (elm1, elm2) => elm1.contains(elm2);
|
|
129
270
|
}
|
|
130
271
|
else {
|
|
272
|
+
// Read the document element in an IIFE that's been marked pure to avoid a top-level property
|
|
273
|
+
// read that may prevent tree-shaking.
|
|
274
|
+
_documentElement = /* @__PURE__ */ (() => document.documentElement)();
|
|
131
275
|
_contains = (elm1, elm2) => {
|
|
132
|
-
while (elm2
|
|
276
|
+
while (elm2) {
|
|
133
277
|
if (elm2 === elm1) {
|
|
134
278
|
return true;
|
|
135
279
|
}
|
|
136
|
-
elm2 = elm2
|
|
280
|
+
elm2 = getParentElement(elm2);
|
|
137
281
|
}
|
|
138
282
|
return false;
|
|
139
283
|
};
|
|
@@ -206,6 +350,9 @@ class NoopAnimationDriver {
|
|
|
206
350
|
containsElement(elm1, elm2) {
|
|
207
351
|
return containsElement(elm1, elm2);
|
|
208
352
|
}
|
|
353
|
+
getParentElement(element) {
|
|
354
|
+
return getParentElement(element);
|
|
355
|
+
}
|
|
209
356
|
query(element, selector, multi) {
|
|
210
357
|
return invokeQuery(element, selector, multi);
|
|
211
358
|
}
|
|
@@ -216,9 +363,9 @@ class NoopAnimationDriver {
|
|
|
216
363
|
return new NoopAnimationPlayer(duration, delay);
|
|
217
364
|
}
|
|
218
365
|
}
|
|
219
|
-
NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
220
|
-
NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
221
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.
|
|
366
|
+
NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.5", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
367
|
+
NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.5", ngImport: i0, type: NoopAnimationDriver });
|
|
368
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.5", ngImport: i0, type: NoopAnimationDriver, decorators: [{
|
|
222
369
|
type: Injectable
|
|
223
370
|
}] });
|
|
224
371
|
/**
|
|
@@ -273,7 +420,7 @@ function parseTimeExpression(exp, errors, allowNegativeValues) {
|
|
|
273
420
|
if (typeof exp === 'string') {
|
|
274
421
|
const matches = exp.match(regex);
|
|
275
422
|
if (matches === null) {
|
|
276
|
-
errors.push(
|
|
423
|
+
errors.push(invalidTimingValue(exp));
|
|
277
424
|
return { duration: 0, delay: 0, easing: '' };
|
|
278
425
|
}
|
|
279
426
|
duration = _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);
|
|
@@ -293,15 +440,15 @@ function parseTimeExpression(exp, errors, allowNegativeValues) {
|
|
|
293
440
|
let containsErrors = false;
|
|
294
441
|
let startIndex = errors.length;
|
|
295
442
|
if (duration < 0) {
|
|
296
|
-
errors.push(
|
|
443
|
+
errors.push(negativeStepValue());
|
|
297
444
|
containsErrors = true;
|
|
298
445
|
}
|
|
299
446
|
if (delay < 0) {
|
|
300
|
-
errors.push(
|
|
447
|
+
errors.push(negativeDelayValue());
|
|
301
448
|
containsErrors = true;
|
|
302
449
|
}
|
|
303
450
|
if (containsErrors) {
|
|
304
|
-
errors.splice(startIndex, 0,
|
|
451
|
+
errors.splice(startIndex, 0, invalidTimingValue(exp));
|
|
305
452
|
}
|
|
306
453
|
}
|
|
307
454
|
return { duration, delay, easing };
|
|
@@ -421,7 +568,7 @@ function validateStyleParams(value, options, errors) {
|
|
|
421
568
|
if (matches.length) {
|
|
422
569
|
matches.forEach(varName => {
|
|
423
570
|
if (!params.hasOwnProperty(varName)) {
|
|
424
|
-
errors.push(
|
|
571
|
+
errors.push(invalidStyleParams(varName));
|
|
425
572
|
}
|
|
426
573
|
});
|
|
427
574
|
}
|
|
@@ -444,7 +591,7 @@ function interpolateParams(value, params, errors) {
|
|
|
444
591
|
let localVal = params[varName];
|
|
445
592
|
// this means that the value was never overridden by the data passed in by the user
|
|
446
593
|
if (!params.hasOwnProperty(varName)) {
|
|
447
|
-
errors.push(
|
|
594
|
+
errors.push(invalidParamValue(varName));
|
|
448
595
|
localVal = '';
|
|
449
596
|
}
|
|
450
597
|
return localVal.toString();
|
|
@@ -519,13 +666,46 @@ function visitDslNode(visitor, node, context) {
|
|
|
519
666
|
case 12 /* Stagger */:
|
|
520
667
|
return visitor.visitStagger(node, context);
|
|
521
668
|
default:
|
|
522
|
-
throw
|
|
669
|
+
throw invalidNodeType(node.type);
|
|
523
670
|
}
|
|
524
671
|
}
|
|
525
672
|
function computeStyle(element, prop) {
|
|
526
673
|
return window.getComputedStyle(element)[prop];
|
|
527
674
|
}
|
|
528
675
|
|
|
676
|
+
/**
|
|
677
|
+
* @license
|
|
678
|
+
* Copyright Google LLC All Rights Reserved.
|
|
679
|
+
*
|
|
680
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
681
|
+
* found in the LICENSE file at https://angular.io/license
|
|
682
|
+
*/
|
|
683
|
+
const NG_DEV_MODE = typeof ngDevMode === 'undefined' || !!ngDevMode;
|
|
684
|
+
function createListOfWarnings(warnings) {
|
|
685
|
+
const LINE_START = '\n - ';
|
|
686
|
+
return `${LINE_START}${warnings.filter(Boolean).map(warning => warning).join(LINE_START)}`;
|
|
687
|
+
}
|
|
688
|
+
function warnValidation(warnings) {
|
|
689
|
+
NG_DEV_MODE && console.warn(`animation validation warnings:${createListOfWarnings(warnings)}`);
|
|
690
|
+
}
|
|
691
|
+
function warnTriggerBuild(name, warnings) {
|
|
692
|
+
NG_DEV_MODE &&
|
|
693
|
+
console.warn(`The animation trigger "${name}" has built with the following warnings:${createListOfWarnings(warnings)}`);
|
|
694
|
+
}
|
|
695
|
+
function warnRegister(warnings) {
|
|
696
|
+
NG_DEV_MODE &&
|
|
697
|
+
console.warn(`Animation built with the following warnings:${createListOfWarnings(warnings)}`);
|
|
698
|
+
}
|
|
699
|
+
function triggerParsingWarnings(name, warnings) {
|
|
700
|
+
NG_DEV_MODE &&
|
|
701
|
+
console.warn(`Animation parsing for the ${name} trigger presents the following warnings:${createListOfWarnings(warnings)}`);
|
|
702
|
+
}
|
|
703
|
+
function pushUnrecognizedPropertiesWarning(warnings, props) {
|
|
704
|
+
if (ngDevMode && props.length) {
|
|
705
|
+
warnings.push(`The provided CSS properties are not recognized properties supported for animations: ${props.join(', ')}`);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
529
709
|
/**
|
|
530
710
|
* @license
|
|
531
711
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -555,7 +735,7 @@ function parseInnerTransitionStr(eventStr, expressions, errors) {
|
|
|
555
735
|
}
|
|
556
736
|
const match = eventStr.match(/^(\*|[-\w]+)\s*(<?[=-]>)\s*(\*|[-\w]+)$/);
|
|
557
737
|
if (match == null || match.length < 4) {
|
|
558
|
-
errors.push(
|
|
738
|
+
errors.push(invalidExpression(eventStr));
|
|
559
739
|
return expressions;
|
|
560
740
|
}
|
|
561
741
|
const fromState = match[1];
|
|
@@ -578,7 +758,7 @@ function parseAnimationAlias(alias, errors) {
|
|
|
578
758
|
case ':decrement':
|
|
579
759
|
return (fromState, toState) => parseFloat(toState) < parseFloat(fromState);
|
|
580
760
|
default:
|
|
581
|
-
errors.push(
|
|
761
|
+
errors.push(invalidTransitionAlias(alias));
|
|
582
762
|
return '* => *';
|
|
583
763
|
}
|
|
584
764
|
}
|
|
@@ -649,18 +829,22 @@ const SELF_TOKEN_REGEX = new RegExp(`\s*${SELF_TOKEN}\s*,?`, 'g');
|
|
|
649
829
|
*
|
|
650
830
|
* Otherwise an error will be thrown.
|
|
651
831
|
*/
|
|
652
|
-
function buildAnimationAst(driver, metadata, errors) {
|
|
653
|
-
return new AnimationAstBuilderVisitor(driver).build(metadata, errors);
|
|
832
|
+
function buildAnimationAst(driver, metadata, errors, warnings) {
|
|
833
|
+
return new AnimationAstBuilderVisitor(driver).build(metadata, errors, warnings);
|
|
654
834
|
}
|
|
655
835
|
const ROOT_SELECTOR = '';
|
|
656
836
|
class AnimationAstBuilderVisitor {
|
|
657
837
|
constructor(_driver) {
|
|
658
838
|
this._driver = _driver;
|
|
659
839
|
}
|
|
660
|
-
build(metadata, errors) {
|
|
840
|
+
build(metadata, errors, warnings) {
|
|
661
841
|
const context = new AnimationAstBuilderContext(errors);
|
|
662
842
|
this._resetContextStyleTimingState(context);
|
|
663
|
-
|
|
843
|
+
const ast = visitDslNode(this, normalizeAnimationEntry(metadata), context);
|
|
844
|
+
if (context.unsupportedCSSPropertiesFound.size) {
|
|
845
|
+
pushUnrecognizedPropertiesWarning(warnings, [...context.unsupportedCSSPropertiesFound.keys()]);
|
|
846
|
+
}
|
|
847
|
+
return ast;
|
|
664
848
|
}
|
|
665
849
|
_resetContextStyleTimingState(context) {
|
|
666
850
|
context.currentQuerySelector = ROOT_SELECTOR;
|
|
@@ -674,7 +858,7 @@ class AnimationAstBuilderVisitor {
|
|
|
674
858
|
const states = [];
|
|
675
859
|
const transitions = [];
|
|
676
860
|
if (metadata.name.charAt(0) == '@') {
|
|
677
|
-
context.errors.push(
|
|
861
|
+
context.errors.push(invalidTrigger());
|
|
678
862
|
}
|
|
679
863
|
metadata.definitions.forEach(def => {
|
|
680
864
|
this._resetContextStyleTimingState(context);
|
|
@@ -694,7 +878,7 @@ class AnimationAstBuilderVisitor {
|
|
|
694
878
|
transitions.push(transition);
|
|
695
879
|
}
|
|
696
880
|
else {
|
|
697
|
-
context.errors.push(
|
|
881
|
+
context.errors.push(invalidDefinition());
|
|
698
882
|
}
|
|
699
883
|
});
|
|
700
884
|
return {
|
|
@@ -726,8 +910,7 @@ class AnimationAstBuilderVisitor {
|
|
|
726
910
|
});
|
|
727
911
|
if (missingSubs.size) {
|
|
728
912
|
const missingSubsArr = iteratorToArray(missingSubs.values());
|
|
729
|
-
context.errors.push(
|
|
730
|
-
.name}", ...) must define default values for all the following style substitutions: ${missingSubsArr.join(', ')}`);
|
|
913
|
+
context.errors.push(invalidState(metadata.name, missingSubsArr));
|
|
731
914
|
}
|
|
732
915
|
}
|
|
733
916
|
return {
|
|
@@ -820,7 +1003,7 @@ class AnimationAstBuilderVisitor {
|
|
|
820
1003
|
styles.push(styleTuple);
|
|
821
1004
|
}
|
|
822
1005
|
else {
|
|
823
|
-
context.errors.push(
|
|
1006
|
+
context.errors.push(invalidStyleValue(styleTuple));
|
|
824
1007
|
}
|
|
825
1008
|
}
|
|
826
1009
|
else {
|
|
@@ -866,7 +1049,8 @@ class AnimationAstBuilderVisitor {
|
|
|
866
1049
|
return;
|
|
867
1050
|
tuple.forEach((value, prop) => {
|
|
868
1051
|
if (!this._driver.validateStyleProperty(prop)) {
|
|
869
|
-
|
|
1052
|
+
tuple.delete(prop);
|
|
1053
|
+
context.unsupportedCSSPropertiesFound.add(prop);
|
|
870
1054
|
return;
|
|
871
1055
|
}
|
|
872
1056
|
// This is guaranteed to have a defined Map at this querySelector location making it
|
|
@@ -877,8 +1061,7 @@ class AnimationAstBuilderVisitor {
|
|
|
877
1061
|
if (collectedEntry) {
|
|
878
1062
|
if (startTime != endTime && startTime >= collectedEntry.startTime &&
|
|
879
1063
|
endTime <= collectedEntry.endTime) {
|
|
880
|
-
context.errors.push(
|
|
881
|
-
.endTime}ms" is also being animated in a parallel animation between the times of "${startTime}ms" and "${endTime}ms"`);
|
|
1064
|
+
context.errors.push(invalidParallelAnimation(prop, collectedEntry.startTime, collectedEntry.endTime, startTime, endTime));
|
|
882
1065
|
updateCollectedStyle = false;
|
|
883
1066
|
}
|
|
884
1067
|
// we always choose the smaller start time value since we
|
|
@@ -898,7 +1081,7 @@ class AnimationAstBuilderVisitor {
|
|
|
898
1081
|
visitKeyframes(metadata, context) {
|
|
899
1082
|
const ast = { type: 5 /* Keyframes */, styles: [], options: null };
|
|
900
1083
|
if (!context.currentAnimateTimings) {
|
|
901
|
-
context.errors.push(
|
|
1084
|
+
context.errors.push(invalidKeyframes());
|
|
902
1085
|
return ast;
|
|
903
1086
|
}
|
|
904
1087
|
const MAX_KEYFRAME_OFFSET = 1;
|
|
@@ -922,15 +1105,15 @@ class AnimationAstBuilderVisitor {
|
|
|
922
1105
|
return style;
|
|
923
1106
|
});
|
|
924
1107
|
if (keyframesOutOfRange) {
|
|
925
|
-
context.errors.push(
|
|
1108
|
+
context.errors.push(invalidOffset());
|
|
926
1109
|
}
|
|
927
1110
|
if (offsetsOutOfOrder) {
|
|
928
|
-
context.errors.push(
|
|
1111
|
+
context.errors.push(keyframeOffsetsOutOfOrder());
|
|
929
1112
|
}
|
|
930
1113
|
const length = metadata.steps.length;
|
|
931
1114
|
let generatedOffset = 0;
|
|
932
1115
|
if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) {
|
|
933
|
-
context.errors.push(
|
|
1116
|
+
context.errors.push(keyframesMissingOffsets());
|
|
934
1117
|
}
|
|
935
1118
|
else if (totalKeyframesWithOffsets == 0) {
|
|
936
1119
|
generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1);
|
|
@@ -996,7 +1179,7 @@ class AnimationAstBuilderVisitor {
|
|
|
996
1179
|
}
|
|
997
1180
|
visitStagger(metadata, context) {
|
|
998
1181
|
if (!context.currentQuery) {
|
|
999
|
-
context.errors.push(
|
|
1182
|
+
context.errors.push(invalidStagger());
|
|
1000
1183
|
}
|
|
1001
1184
|
const timings = metadata.timings === 'full' ?
|
|
1002
1185
|
{ duration: 0, delay: 0, easing: 'full' } :
|
|
@@ -1036,6 +1219,7 @@ class AnimationAstBuilderContext {
|
|
|
1036
1219
|
this.currentTime = 0;
|
|
1037
1220
|
this.collectedStyles = new Map();
|
|
1038
1221
|
this.options = null;
|
|
1222
|
+
this.unsupportedCSSPropertiesFound = new Set();
|
|
1039
1223
|
}
|
|
1040
1224
|
}
|
|
1041
1225
|
function consumeOffset(styles) {
|
|
@@ -1614,7 +1798,7 @@ class AnimationTimelineContext {
|
|
|
1614
1798
|
results.push(...elements);
|
|
1615
1799
|
}
|
|
1616
1800
|
if (!optional && results.length == 0) {
|
|
1617
|
-
errors.push(
|
|
1801
|
+
errors.push(invalidQuery(originalSelector));
|
|
1618
1802
|
}
|
|
1619
1803
|
return results;
|
|
1620
1804
|
}
|
|
@@ -1892,10 +2076,13 @@ class Animation {
|
|
|
1892
2076
|
constructor(_driver, input) {
|
|
1893
2077
|
this._driver = _driver;
|
|
1894
2078
|
const errors = [];
|
|
1895
|
-
const
|
|
2079
|
+
const warnings = [];
|
|
2080
|
+
const ast = buildAnimationAst(_driver, input, errors, warnings);
|
|
1896
2081
|
if (errors.length) {
|
|
1897
|
-
|
|
1898
|
-
|
|
2082
|
+
throw validationFailed(errors);
|
|
2083
|
+
}
|
|
2084
|
+
if (warnings.length) {
|
|
2085
|
+
warnValidation(warnings);
|
|
1899
2086
|
}
|
|
1900
2087
|
this._animationAst = ast;
|
|
1901
2088
|
}
|
|
@@ -1908,8 +2095,7 @@ class Animation {
|
|
|
1908
2095
|
subInstructions = subInstructions || new ElementInstructionMap();
|
|
1909
2096
|
const result = buildAnimationTimelines(this._driver, element, this._animationAst, ENTER_CLASSNAME, LEAVE_CLASSNAME, start, dest, options, subInstructions, errors);
|
|
1910
2097
|
if (errors.length) {
|
|
1911
|
-
|
|
1912
|
-
throw new Error(errorMessage);
|
|
2098
|
+
throw buildingFailed(errors);
|
|
1913
2099
|
}
|
|
1914
2100
|
return result;
|
|
1915
2101
|
}
|
|
@@ -1991,7 +2177,7 @@ class WebAnimationsStyleNormalizer extends AnimationStyleNormalizer {
|
|
|
1991
2177
|
else {
|
|
1992
2178
|
const valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/);
|
|
1993
2179
|
if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
|
|
1994
|
-
errors.push(
|
|
2180
|
+
errors.push(invalidCssUnitValue(userProvidedProperty, value));
|
|
1995
2181
|
}
|
|
1996
2182
|
}
|
|
1997
2183
|
}
|
|
@@ -2191,11 +2377,15 @@ class TimelineAnimationEngine {
|
|
|
2191
2377
|
}
|
|
2192
2378
|
register(id, metadata) {
|
|
2193
2379
|
const errors = [];
|
|
2194
|
-
const
|
|
2380
|
+
const warnings = [];
|
|
2381
|
+
const ast = buildAnimationAst(this._driver, metadata, errors, warnings);
|
|
2195
2382
|
if (errors.length) {
|
|
2196
|
-
throw
|
|
2383
|
+
throw registerFailed(errors);
|
|
2197
2384
|
}
|
|
2198
2385
|
else {
|
|
2386
|
+
if (warnings.length) {
|
|
2387
|
+
warnRegister(warnings);
|
|
2388
|
+
}
|
|
2199
2389
|
this._animations.set(id, ast);
|
|
2200
2390
|
}
|
|
2201
2391
|
}
|
|
@@ -2217,11 +2407,11 @@ class TimelineAnimationEngine {
|
|
|
2217
2407
|
});
|
|
2218
2408
|
}
|
|
2219
2409
|
else {
|
|
2220
|
-
errors.push(
|
|
2410
|
+
errors.push(missingOrDestroyedAnimation());
|
|
2221
2411
|
instructions = [];
|
|
2222
2412
|
}
|
|
2223
2413
|
if (errors.length) {
|
|
2224
|
-
throw
|
|
2414
|
+
throw createAnimationFailed(errors);
|
|
2225
2415
|
}
|
|
2226
2416
|
autoStylesMap.forEach((styles, element) => {
|
|
2227
2417
|
styles.forEach((_, prop) => {
|
|
@@ -2250,7 +2440,7 @@ class TimelineAnimationEngine {
|
|
|
2250
2440
|
_getPlayer(id) {
|
|
2251
2441
|
const player = this._playersById.get(id);
|
|
2252
2442
|
if (!player) {
|
|
2253
|
-
throw
|
|
2443
|
+
throw missingPlayer(id);
|
|
2254
2444
|
}
|
|
2255
2445
|
return player;
|
|
2256
2446
|
}
|
|
@@ -2378,13 +2568,13 @@ class AnimationTransitionNamespace {
|
|
|
2378
2568
|
}
|
|
2379
2569
|
listen(element, name, phase, callback) {
|
|
2380
2570
|
if (!this._triggers.has(name)) {
|
|
2381
|
-
throw
|
|
2571
|
+
throw missingTrigger(phase, name);
|
|
2382
2572
|
}
|
|
2383
2573
|
if (phase == null || phase.length == 0) {
|
|
2384
|
-
throw
|
|
2574
|
+
throw missingEvent(name);
|
|
2385
2575
|
}
|
|
2386
2576
|
if (!isTriggerEventValid(phase)) {
|
|
2387
|
-
throw
|
|
2577
|
+
throw unsupportedTriggerEvent(phase, name);
|
|
2388
2578
|
}
|
|
2389
2579
|
const listeners = getOrSetDefaultValue(this._elementListeners, element, []);
|
|
2390
2580
|
const data = { name, phase, callback };
|
|
@@ -2423,7 +2613,7 @@ class AnimationTransitionNamespace {
|
|
|
2423
2613
|
_getTrigger(name) {
|
|
2424
2614
|
const trigger = this._triggers.get(name);
|
|
2425
2615
|
if (!trigger) {
|
|
2426
|
-
throw
|
|
2616
|
+
throw unregisteredTrigger(name);
|
|
2427
2617
|
}
|
|
2428
2618
|
return trigger;
|
|
2429
2619
|
}
|
|
@@ -2777,25 +2967,37 @@ class TransitionAnimationEngine {
|
|
|
2777
2967
|
return this._namespaceLookup[namespaceId] = ns;
|
|
2778
2968
|
}
|
|
2779
2969
|
_balanceNamespaceList(ns, hostElement) {
|
|
2780
|
-
const
|
|
2970
|
+
const namespaceList = this._namespaceList;
|
|
2971
|
+
const namespacesByHostElement = this.namespacesByHostElement;
|
|
2972
|
+
const limit = namespaceList.length - 1;
|
|
2781
2973
|
if (limit >= 0) {
|
|
2782
2974
|
let found = false;
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2975
|
+
// Find the closest ancestor with an existing namespace so we can then insert `ns` after it,
|
|
2976
|
+
// establishing a top-down ordering of namespaces in `this._namespaceList`.
|
|
2977
|
+
let ancestor = this.driver.getParentElement(hostElement);
|
|
2978
|
+
while (ancestor) {
|
|
2979
|
+
const ancestorNs = namespacesByHostElement.get(ancestor);
|
|
2980
|
+
if (ancestorNs) {
|
|
2981
|
+
// An animation namespace has been registered for this ancestor, so we insert `ns`
|
|
2982
|
+
// right after it to establish top-down ordering of animation namespaces.
|
|
2983
|
+
const index = namespaceList.indexOf(ancestorNs);
|
|
2984
|
+
namespaceList.splice(index + 1, 0, ns);
|
|
2787
2985
|
found = true;
|
|
2788
2986
|
break;
|
|
2789
2987
|
}
|
|
2988
|
+
ancestor = this.driver.getParentElement(ancestor);
|
|
2790
2989
|
}
|
|
2791
2990
|
if (!found) {
|
|
2792
|
-
|
|
2991
|
+
// No namespace exists that is an ancestor of `ns`, so `ns` is inserted at the front to
|
|
2992
|
+
// ensure that any existing descendants are ordered after `ns`, retaining the desired
|
|
2993
|
+
// top-down ordering.
|
|
2994
|
+
namespaceList.unshift(ns);
|
|
2793
2995
|
}
|
|
2794
2996
|
}
|
|
2795
2997
|
else {
|
|
2796
|
-
|
|
2998
|
+
namespaceList.push(ns);
|
|
2797
2999
|
}
|
|
2798
|
-
|
|
3000
|
+
namespacesByHostElement.set(hostElement, ns);
|
|
2799
3001
|
return ns;
|
|
2800
3002
|
}
|
|
2801
3003
|
register(namespaceId, hostElement) {
|
|
@@ -3060,7 +3262,7 @@ class TransitionAnimationEngine {
|
|
|
3060
3262
|
}
|
|
3061
3263
|
}
|
|
3062
3264
|
reportError(errors) {
|
|
3063
|
-
throw
|
|
3265
|
+
throw triggerTransitionsFailed(errors);
|
|
3064
3266
|
}
|
|
3065
3267
|
_flushAnimations(cleanupFns, microtaskId) {
|
|
3066
3268
|
const subTimelines = new ElementInstructionMap();
|
|
@@ -3222,8 +3424,7 @@ class TransitionAnimationEngine {
|
|
|
3222
3424
|
if (erroneousTransitions.length) {
|
|
3223
3425
|
const errors = [];
|
|
3224
3426
|
erroneousTransitions.forEach(instruction => {
|
|
3225
|
-
errors.push(
|
|
3226
|
-
instruction.errors.forEach(error => errors.push(`- ${error}\n`));
|
|
3427
|
+
errors.push(transitionFailed(instruction.triggerName, instruction.errors));
|
|
3227
3428
|
});
|
|
3228
3429
|
allPlayers.forEach(player => player.destroy());
|
|
3229
3430
|
this.reportError(errors);
|
|
@@ -3825,9 +4026,13 @@ class AnimationEngine {
|
|
|
3825
4026
|
let trigger = this._triggerCache[cacheKey];
|
|
3826
4027
|
if (!trigger) {
|
|
3827
4028
|
const errors = [];
|
|
3828
|
-
const
|
|
4029
|
+
const warnings = [];
|
|
4030
|
+
const ast = buildAnimationAst(this._driver, metadata, errors, warnings);
|
|
3829
4031
|
if (errors.length) {
|
|
3830
|
-
throw
|
|
4032
|
+
throw triggerBuildFailed(name, errors);
|
|
4033
|
+
}
|
|
4034
|
+
if (warnings.length) {
|
|
4035
|
+
warnTriggerBuild(name, warnings);
|
|
3831
4036
|
}
|
|
3832
4037
|
trigger = buildTrigger(name, ast, this._normalizer);
|
|
3833
4038
|
this._triggerCache[cacheKey] = trigger;
|
|
@@ -4148,6 +4353,9 @@ class WebAnimationsDriver {
|
|
|
4148
4353
|
containsElement(elm1, elm2) {
|
|
4149
4354
|
return containsElement(elm1, elm2);
|
|
4150
4355
|
}
|
|
4356
|
+
getParentElement(element) {
|
|
4357
|
+
return getParentElement(element);
|
|
4358
|
+
}
|
|
4151
4359
|
query(element, selector, multi) {
|
|
4152
4360
|
return invokeQuery(element, selector, multi);
|
|
4153
4361
|
}
|
|
@@ -4212,5 +4420,5 @@ class WebAnimationsDriver {
|
|
|
4212
4420
|
* Generated bundle index. Do not edit.
|
|
4213
4421
|
*/
|
|
4214
4422
|
|
|
4215
|
-
export { AnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, NoopAnimationDriver as ɵNoopAnimationDriver, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsDriver as ɵWebAnimationsDriver, WebAnimationsPlayer as ɵWebAnimationsPlayer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge, containsElement as ɵcontainsElement, invokeQuery as ɵinvokeQuery, normalizeKeyframes as ɵnormalizeKeyframes, validateStyleProperty as ɵvalidateStyleProperty };
|
|
4423
|
+
export { AnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, NoopAnimationDriver as ɵNoopAnimationDriver, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsDriver as ɵWebAnimationsDriver, WebAnimationsPlayer as ɵWebAnimationsPlayer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge, containsElement as ɵcontainsElement, getParentElement as ɵgetParentElement, invokeQuery as ɵinvokeQuery, normalizeKeyframes as ɵnormalizeKeyframes, validateStyleProperty as ɵvalidateStyleProperty };
|
|
4216
4424
|
//# sourceMappingURL=browser.mjs.map
|