@angular/animations 13.2.2 → 13.2.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.
Files changed (39) hide show
  1. package/animations.d.ts +10 -2
  2. package/browser/browser.d.ts +19 -7
  3. package/browser/testing/testing.d.ts +2 -1
  4. package/esm2020/browser/src/dsl/animation.mjs +10 -6
  5. package/esm2020/browser/src/dsl/animation_ast_builder.mjs +24 -18
  6. package/esm2020/browser/src/dsl/animation_timeline_builder.mjs +3 -2
  7. package/esm2020/browser/src/dsl/animation_transition_expr.mjs +4 -3
  8. package/esm2020/browser/src/dsl/animation_transition_factory.mjs +1 -1
  9. package/esm2020/browser/src/dsl/animation_transition_instruction.mjs +1 -1
  10. package/esm2020/browser/src/dsl/animation_trigger.mjs +1 -1
  11. package/esm2020/browser/src/dsl/style_normalization/animation_style_normalizer.mjs +1 -1
  12. package/esm2020/browser/src/dsl/style_normalization/web_animations_style_normalizer.mjs +3 -2
  13. package/esm2020/browser/src/error_helpers.mjs +135 -0
  14. package/esm2020/browser/src/errors.mjs +9 -0
  15. package/esm2020/browser/src/private_export.mjs +2 -2
  16. package/esm2020/browser/src/render/animation_driver.mjs +8 -5
  17. package/esm2020/browser/src/render/animation_engine_next.mjs +9 -3
  18. package/esm2020/browser/src/render/shared.mjs +16 -5
  19. package/esm2020/browser/src/render/timeline_animation_engine.mjs +12 -6
  20. package/esm2020/browser/src/render/transition_animation_engine.mjs +45 -18
  21. package/esm2020/browser/src/render/web_animations/web_animations_driver.mjs +5 -2
  22. package/esm2020/browser/src/util.mjs +9 -8
  23. package/esm2020/browser/src/warning_helpers.mjs +33 -0
  24. package/esm2020/browser/testing/src/mock_animation_driver.mjs +5 -2
  25. package/esm2020/src/animation_metadata.mjs +10 -2
  26. package/esm2020/src/version.mjs +1 -1
  27. package/fesm2015/animations.mjs +10 -2
  28. package/fesm2015/animations.mjs.map +1 -1
  29. package/fesm2015/browser/testing.mjs +5 -2
  30. package/fesm2015/browser/testing.mjs.map +1 -1
  31. package/fesm2015/browser.mjs +290 -67
  32. package/fesm2015/browser.mjs.map +1 -1
  33. package/fesm2020/animations.mjs +10 -2
  34. package/fesm2020/animations.mjs.map +1 -1
  35. package/fesm2020/browser/testing.mjs +5 -2
  36. package/fesm2020/browser/testing.mjs.map +1 -1
  37. package/fesm2020/browser.mjs +290 -67
  38. package/fesm2020/browser.mjs.map +1 -1
  39. package/package.json +2 -2
@@ -1,12 +1,146 @@
1
1
  /**
2
- * @license Angular v13.2.2
2
+ * @license Angular v13.2.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(driver, normalizer, element, keyframes, preStyles =
72
206
  previousOffset = offset;
73
207
  });
74
208
  if (errors.length) {
75
- const LINE_START = '\n - ';
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
  }
@@ -129,6 +262,14 @@ let _contains = (elm1, elm2) => false;
129
262
  let _query = (element, selector, multi) => {
130
263
  return [];
131
264
  };
265
+ let _documentElement = null;
266
+ function getParentElement(element) {
267
+ const parent = element.parentNode || element.host; // consider host to support shadow DOM
268
+ if (parent === _documentElement) {
269
+ return null;
270
+ }
271
+ return parent;
272
+ }
132
273
  // Define utility methods for browsers and platform-server(domino) where Element
133
274
  // and utility methods exist.
134
275
  const _isNode = isNode();
@@ -137,12 +278,15 @@ if (_isNode || typeof Element !== 'undefined') {
137
278
  _contains = (elm1, elm2) => elm1.contains(elm2);
138
279
  }
139
280
  else {
281
+ // Read the document element in an IIFE that's been marked pure to avoid a top-level property
282
+ // read that may prevent tree-shaking.
283
+ _documentElement = /* @__PURE__ */ (() => document.documentElement)();
140
284
  _contains = (elm1, elm2) => {
141
- while (elm2 && elm2 !== document.documentElement) {
285
+ while (elm2) {
142
286
  if (elm2 === elm1) {
143
287
  return true;
144
288
  }
145
- elm2 = elm2.parentNode || elm2.host; // consider host to support shadow DOM
289
+ elm2 = getParentElement(elm2);
146
290
  }
147
291
  return false;
148
292
  };
@@ -215,6 +359,9 @@ class NoopAnimationDriver {
215
359
  containsElement(elm1, elm2) {
216
360
  return containsElement(elm1, elm2);
217
361
  }
362
+ getParentElement(element) {
363
+ return getParentElement(element);
364
+ }
218
365
  query(element, selector, multi) {
219
366
  return invokeQuery(element, selector, multi);
220
367
  }
@@ -225,9 +372,9 @@ class NoopAnimationDriver {
225
372
  return new NoopAnimationPlayer(duration, delay);
226
373
  }
227
374
  }
228
- NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
229
- NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: NoopAnimationDriver });
230
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: NoopAnimationDriver, decorators: [{
375
+ NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
376
+ NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NoopAnimationDriver });
377
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: NoopAnimationDriver, decorators: [{
231
378
  type: Injectable
232
379
  }] });
233
380
  /**
@@ -282,7 +429,7 @@ function parseTimeExpression(exp, errors, allowNegativeValues) {
282
429
  if (typeof exp === 'string') {
283
430
  const matches = exp.match(regex);
284
431
  if (matches === null) {
285
- errors.push(`The provided timing value "${exp}" is invalid.`);
432
+ errors.push(invalidTimingValue(exp));
286
433
  return { duration: 0, delay: 0, easing: '' };
287
434
  }
288
435
  duration = _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);
@@ -302,15 +449,15 @@ function parseTimeExpression(exp, errors, allowNegativeValues) {
302
449
  let containsErrors = false;
303
450
  let startIndex = errors.length;
304
451
  if (duration < 0) {
305
- errors.push(`Duration values below 0 are not allowed for this animation step.`);
452
+ errors.push(negativeStepValue());
306
453
  containsErrors = true;
307
454
  }
308
455
  if (delay < 0) {
309
- errors.push(`Delay values below 0 are not allowed for this animation step.`);
456
+ errors.push(negativeDelayValue());
310
457
  containsErrors = true;
311
458
  }
312
459
  if (containsErrors) {
313
- errors.splice(startIndex, 0, `The provided timing value "${exp}" is invalid.`);
460
+ errors.splice(startIndex, 0, invalidTimingValue(exp));
314
461
  }
315
462
  }
316
463
  return { duration, delay, easing };
@@ -416,7 +563,7 @@ function validateStyleParams(value, options, errors) {
416
563
  if (matches.length) {
417
564
  matches.forEach(varName => {
418
565
  if (!params.hasOwnProperty(varName)) {
419
- errors.push(`Unable to resolve the local animation param ${varName} in the given list of values`);
566
+ errors.push(invalidStyleParams(varName));
420
567
  }
421
568
  });
422
569
  }
@@ -439,7 +586,7 @@ function interpolateParams(value, params, errors) {
439
586
  let localVal = params[varName];
440
587
  // this means that the value was never overridden by the data passed in by the user
441
588
  if (!params.hasOwnProperty(varName)) {
442
- errors.push(`Please provide a value for the animation param ${varName}`);
589
+ errors.push(invalidParamValue(varName));
443
590
  localVal = '';
444
591
  }
445
592
  return localVal.toString();
@@ -518,13 +665,46 @@ function visitDslNode(visitor, node, context) {
518
665
  case 12 /* Stagger */:
519
666
  return visitor.visitStagger(node, context);
520
667
  default:
521
- throw new Error(`Unable to resolve animation metadata node #${node.type}`);
668
+ throw invalidNodeType(node.type);
522
669
  }
523
670
  }
524
671
  function computeStyle(element, prop) {
525
672
  return window.getComputedStyle(element)[prop];
526
673
  }
527
674
 
675
+ /**
676
+ * @license
677
+ * Copyright Google LLC All Rights Reserved.
678
+ *
679
+ * Use of this source code is governed by an MIT-style license that can be
680
+ * found in the LICENSE file at https://angular.io/license
681
+ */
682
+ const NG_DEV_MODE = typeof ngDevMode === 'undefined' || !!ngDevMode;
683
+ function createListOfWarnings(warnings) {
684
+ const LINE_START = '\n - ';
685
+ return `${LINE_START}${warnings.filter(Boolean).map(warning => warning).join(LINE_START)}`;
686
+ }
687
+ function warnValidation(warnings) {
688
+ NG_DEV_MODE && console.warn(`animation validation warnings:${createListOfWarnings(warnings)}`);
689
+ }
690
+ function warnTriggerBuild(name, warnings) {
691
+ NG_DEV_MODE &&
692
+ console.warn(`The animation trigger "${name}" has built with the following warnings:${createListOfWarnings(warnings)}`);
693
+ }
694
+ function warnRegister(warnings) {
695
+ NG_DEV_MODE &&
696
+ console.warn(`Animation built with the following warnings:${createListOfWarnings(warnings)}`);
697
+ }
698
+ function triggerParsingWarnings(name, warnings) {
699
+ NG_DEV_MODE &&
700
+ console.warn(`Animation parsing for the ${name} trigger presents the following warnings:${createListOfWarnings(warnings)}`);
701
+ }
702
+ function pushUnrecognizedPropertiesWarning(warnings, props) {
703
+ if (ngDevMode && props.length) {
704
+ warnings.push(`The provided CSS properties are not recognized properties supported for animations: ${props.join(', ')}`);
705
+ }
706
+ }
707
+
528
708
  /**
529
709
  * @license
530
710
  * Copyright Google LLC All Rights Reserved.
@@ -554,7 +734,7 @@ function parseInnerTransitionStr(eventStr, expressions, errors) {
554
734
  }
555
735
  const match = eventStr.match(/^(\*|[-\w]+)\s*(<?[=-]>)\s*(\*|[-\w]+)$/);
556
736
  if (match == null || match.length < 4) {
557
- errors.push(`The provided transition expression "${eventStr}" is not supported`);
737
+ errors.push(invalidExpression(eventStr));
558
738
  return expressions;
559
739
  }
560
740
  const fromState = match[1];
@@ -577,7 +757,7 @@ function parseAnimationAlias(alias, errors) {
577
757
  case ':decrement':
578
758
  return (fromState, toState) => parseFloat(toState) < parseFloat(fromState);
579
759
  default:
580
- errors.push(`The transition alias value "${alias}" is not supported`);
760
+ errors.push(invalidTransitionAlias(alias));
581
761
  return '* => *';
582
762
  }
583
763
  }
@@ -648,18 +828,22 @@ const SELF_TOKEN_REGEX = new RegExp(`\s*${SELF_TOKEN}\s*,?`, 'g');
648
828
  *
649
829
  * Otherwise an error will be thrown.
650
830
  */
651
- function buildAnimationAst(driver, metadata, errors) {
652
- return new AnimationAstBuilderVisitor(driver).build(metadata, errors);
831
+ function buildAnimationAst(driver, metadata, errors, warnings) {
832
+ return new AnimationAstBuilderVisitor(driver).build(metadata, errors, warnings);
653
833
  }
654
834
  const ROOT_SELECTOR = '';
655
835
  class AnimationAstBuilderVisitor {
656
836
  constructor(_driver) {
657
837
  this._driver = _driver;
658
838
  }
659
- build(metadata, errors) {
839
+ build(metadata, errors, warnings) {
660
840
  const context = new AnimationAstBuilderContext(errors);
661
841
  this._resetContextStyleTimingState(context);
662
- return visitDslNode(this, normalizeAnimationEntry(metadata), context);
842
+ const ast = visitDslNode(this, normalizeAnimationEntry(metadata), context);
843
+ if (context.unsupportedCSSPropertiesFound.size) {
844
+ pushUnrecognizedPropertiesWarning(warnings, [...context.unsupportedCSSPropertiesFound.keys()]);
845
+ }
846
+ return ast;
663
847
  }
664
848
  _resetContextStyleTimingState(context) {
665
849
  context.currentQuerySelector = ROOT_SELECTOR;
@@ -673,7 +857,7 @@ class AnimationAstBuilderVisitor {
673
857
  const states = [];
674
858
  const transitions = [];
675
859
  if (metadata.name.charAt(0) == '@') {
676
- context.errors.push('animation triggers cannot be prefixed with an `@` sign (e.g. trigger(\'@foo\', [...]))');
860
+ context.errors.push(invalidTrigger());
677
861
  }
678
862
  metadata.definitions.forEach(def => {
679
863
  this._resetContextStyleTimingState(context);
@@ -693,7 +877,7 @@ class AnimationAstBuilderVisitor {
693
877
  transitions.push(transition);
694
878
  }
695
879
  else {
696
- context.errors.push('only state() and transition() definitions can sit inside of a trigger()');
880
+ context.errors.push(invalidDefinition());
697
881
  }
698
882
  });
699
883
  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(`state("${metadata
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(`The provided style string value ${styleTuple} is not allowed.`);
1006
+ context.errors.push(invalidStyleValue(styleTuple));
824
1007
  }
825
1008
  }
826
1009
  else {
@@ -873,7 +1056,8 @@ class AnimationAstBuilderVisitor {
873
1056
  return;
874
1057
  Object.keys(tuple).forEach(prop => {
875
1058
  if (!this._driver.validateStyleProperty(prop)) {
876
- context.errors.push(`The provided animation property "${prop}" is not a supported CSS property for animations`);
1059
+ delete tuple[prop];
1060
+ context.unsupportedCSSPropertiesFound.add(prop);
877
1061
  return;
878
1062
  }
879
1063
  const collectedStyles = context.collectedStyles[context.currentQuerySelector];
@@ -882,8 +1066,7 @@ class AnimationAstBuilderVisitor {
882
1066
  if (collectedEntry) {
883
1067
  if (startTime != endTime && startTime >= collectedEntry.startTime &&
884
1068
  endTime <= collectedEntry.endTime) {
885
- context.errors.push(`The CSS property "${prop}" that exists between the times of "${collectedEntry.startTime}ms" and "${collectedEntry
886
- .endTime}ms" is also being animated in a parallel animation between the times of "${startTime}ms" and "${endTime}ms"`);
1069
+ context.errors.push(invalidParallelAnimation(prop, collectedEntry.startTime, collectedEntry.endTime, startTime, endTime));
887
1070
  updateCollectedStyle = false;
888
1071
  }
889
1072
  // we always choose the smaller start time value since we
@@ -903,7 +1086,7 @@ class AnimationAstBuilderVisitor {
903
1086
  visitKeyframes(metadata, context) {
904
1087
  const ast = { type: 5 /* Keyframes */, styles: [], options: null };
905
1088
  if (!context.currentAnimateTimings) {
906
- context.errors.push(`keyframes() must be placed inside of a call to animate()`);
1089
+ context.errors.push(invalidKeyframes());
907
1090
  return ast;
908
1091
  }
909
1092
  const MAX_KEYFRAME_OFFSET = 1;
@@ -927,15 +1110,15 @@ class AnimationAstBuilderVisitor {
927
1110
  return style;
928
1111
  });
929
1112
  if (keyframesOutOfRange) {
930
- context.errors.push(`Please ensure that all keyframe offsets are between 0 and 1`);
1113
+ context.errors.push(invalidOffset());
931
1114
  }
932
1115
  if (offsetsOutOfOrder) {
933
- context.errors.push(`Please ensure that all keyframe offsets are in order`);
1116
+ context.errors.push(keyframeOffsetsOutOfOrder());
934
1117
  }
935
1118
  const length = metadata.steps.length;
936
1119
  let generatedOffset = 0;
937
1120
  if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) {
938
- context.errors.push(`Not all style() steps within the declared keyframes() contain offsets`);
1121
+ context.errors.push(keyframesMissingOffsets());
939
1122
  }
940
1123
  else if (totalKeyframesWithOffsets == 0) {
941
1124
  generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1);
@@ -1001,7 +1184,7 @@ class AnimationAstBuilderVisitor {
1001
1184
  }
1002
1185
  visitStagger(metadata, context) {
1003
1186
  if (!context.currentQuery) {
1004
- context.errors.push(`stagger() can only be used inside of query()`);
1187
+ context.errors.push(invalidStagger());
1005
1188
  }
1006
1189
  const timings = metadata.timings === 'full' ?
1007
1190
  { duration: 0, delay: 0, easing: 'full' } :
@@ -1041,6 +1224,7 @@ class AnimationAstBuilderContext {
1041
1224
  this.currentTime = 0;
1042
1225
  this.collectedStyles = {};
1043
1226
  this.options = null;
1227
+ this.unsupportedCSSPropertiesFound = new Set();
1044
1228
  }
1045
1229
  }
1046
1230
  function consumeOffset(styles) {
@@ -1624,7 +1808,7 @@ class AnimationTimelineContext {
1624
1808
  results.push(...elements);
1625
1809
  }
1626
1810
  if (!optional && results.length == 0) {
1627
- errors.push(`\`query("${originalSelector}")\` returned zero elements. (Use \`query("${originalSelector}", { optional: true })\` if you wish to allow this.)`);
1811
+ errors.push(invalidQuery(originalSelector));
1628
1812
  }
1629
1813
  return results;
1630
1814
  }
@@ -1910,10 +2094,13 @@ class Animation {
1910
2094
  constructor(_driver, input) {
1911
2095
  this._driver = _driver;
1912
2096
  const errors = [];
1913
- const ast = buildAnimationAst(_driver, input, errors);
2097
+ const warnings = [];
2098
+ const ast = buildAnimationAst(_driver, input, errors, warnings);
1914
2099
  if (errors.length) {
1915
- const errorMessage = `animation validation failed:\n${errors.join('\n')}`;
1916
- throw new Error(errorMessage);
2100
+ throw validationFailed(errors);
2101
+ }
2102
+ if (warnings.length) {
2103
+ warnValidation(warnings);
1917
2104
  }
1918
2105
  this._animationAst = ast;
1919
2106
  }
@@ -1926,8 +2113,7 @@ class Animation {
1926
2113
  subInstructions = subInstructions || new ElementInstructionMap();
1927
2114
  const result = buildAnimationTimelines(this._driver, element, this._animationAst, ENTER_CLASSNAME, LEAVE_CLASSNAME, start, dest, options, subInstructions, errors);
1928
2115
  if (errors.length) {
1929
- const errorMessage = `animation building failed:\n${errors.join('\n')}`;
1930
- throw new Error(errorMessage);
2116
+ throw buildingFailed(errors);
1931
2117
  }
1932
2118
  return result;
1933
2119
  }
@@ -1978,7 +2164,7 @@ class WebAnimationsStyleNormalizer extends AnimationStyleNormalizer {
1978
2164
  else {
1979
2165
  const valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/);
1980
2166
  if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
1981
- errors.push(`Please provide a CSS unit value for ${userProvidedProperty}:${value}`);
2167
+ errors.push(invalidCssUnitValue(userProvidedProperty, value));
1982
2168
  }
1983
2169
  }
1984
2170
  }
@@ -2175,11 +2361,15 @@ class TimelineAnimationEngine {
2175
2361
  }
2176
2362
  register(id, metadata) {
2177
2363
  const errors = [];
2178
- const ast = buildAnimationAst(this._driver, metadata, errors);
2364
+ const warnings = [];
2365
+ const ast = buildAnimationAst(this._driver, metadata, errors, warnings);
2179
2366
  if (errors.length) {
2180
- throw new Error(`Unable to build the animation due to the following errors: ${errors.join('\n')}`);
2367
+ throw registerFailed(errors);
2181
2368
  }
2182
2369
  else {
2370
+ if (warnings.length) {
2371
+ warnRegister(warnings);
2372
+ }
2183
2373
  this._animations[id] = ast;
2184
2374
  }
2185
2375
  }
@@ -2201,11 +2391,11 @@ class TimelineAnimationEngine {
2201
2391
  });
2202
2392
  }
2203
2393
  else {
2204
- errors.push('The requested animation doesn\'t exist or has already been destroyed');
2394
+ errors.push(missingOrDestroyedAnimation());
2205
2395
  instructions = [];
2206
2396
  }
2207
2397
  if (errors.length) {
2208
- throw new Error(`Unable to create the animation due to the following errors: ${errors.join('\n')}`);
2398
+ throw createAnimationFailed(errors);
2209
2399
  }
2210
2400
  autoStylesMap.forEach((styles, element) => {
2211
2401
  Object.keys(styles).forEach(prop => {
@@ -2234,7 +2424,7 @@ class TimelineAnimationEngine {
2234
2424
  _getPlayer(id) {
2235
2425
  const player = this._playersById[id];
2236
2426
  if (!player) {
2237
- throw new Error(`Unable to find the timeline player referenced by ${id}`);
2427
+ throw missingPlayer(id);
2238
2428
  }
2239
2429
  return player;
2240
2430
  }
@@ -2362,13 +2552,13 @@ class AnimationTransitionNamespace {
2362
2552
  }
2363
2553
  listen(element, name, phase, callback) {
2364
2554
  if (!this._triggers.hasOwnProperty(name)) {
2365
- throw new Error(`Unable to listen on the animation trigger event "${phase}" because the animation trigger "${name}" doesn\'t exist!`);
2555
+ throw missingTrigger(phase, name);
2366
2556
  }
2367
2557
  if (phase == null || phase.length == 0) {
2368
- throw new Error(`Unable to listen on the animation trigger "${name}" because the provided event is undefined!`);
2558
+ throw missingEvent(name);
2369
2559
  }
2370
2560
  if (!isTriggerEventValid(phase)) {
2371
- throw new Error(`The provided animation trigger event "${phase}" for the animation trigger "${name}" is not supported!`);
2561
+ throw unsupportedTriggerEvent(phase, name);
2372
2562
  }
2373
2563
  const listeners = getOrSetAsInMap(this._elementListeners, element, []);
2374
2564
  const data = { name, phase, callback };
@@ -2407,7 +2597,7 @@ class AnimationTransitionNamespace {
2407
2597
  _getTrigger(name) {
2408
2598
  const trigger = this._triggers[name];
2409
2599
  if (!trigger) {
2410
- throw new Error(`The provided animation trigger "${name}" has not been registered!`);
2600
+ throw unregisteredTrigger(name);
2411
2601
  }
2412
2602
  return trigger;
2413
2603
  }
@@ -2763,25 +2953,52 @@ class TransitionAnimationEngine {
2763
2953
  return this._namespaceLookup[namespaceId] = ns;
2764
2954
  }
2765
2955
  _balanceNamespaceList(ns, hostElement) {
2766
- const limit = this._namespaceList.length - 1;
2956
+ const namespaceList = this._namespaceList;
2957
+ const namespacesByHostElement = this.namespacesByHostElement;
2958
+ const limit = namespaceList.length - 1;
2767
2959
  if (limit >= 0) {
2768
2960
  let found = false;
2769
- for (let i = limit; i >= 0; i--) {
2770
- const nextNamespace = this._namespaceList[i];
2771
- if (this.driver.containsElement(nextNamespace.hostElement, hostElement)) {
2772
- this._namespaceList.splice(i + 1, 0, ns);
2773
- found = true;
2774
- break;
2961
+ if (this.driver.getParentElement !== undefined) {
2962
+ // Fast path for when the driver implements `getParentElement`, which allows us to find the
2963
+ // closest ancestor with an existing namespace that we can then insert `ns` after, without
2964
+ // having to inspect all existing namespaces.
2965
+ let ancestor = this.driver.getParentElement(hostElement);
2966
+ while (ancestor) {
2967
+ const ancestorNs = namespacesByHostElement.get(ancestor);
2968
+ if (ancestorNs) {
2969
+ // An animation namespace has been registered for this ancestor, so we insert `ns`
2970
+ // right after it to establish top-down ordering of animation namespaces.
2971
+ const index = namespaceList.indexOf(ancestorNs);
2972
+ namespaceList.splice(index + 1, 0, ns);
2973
+ found = true;
2974
+ break;
2975
+ }
2976
+ ancestor = this.driver.getParentElement(ancestor);
2977
+ }
2978
+ }
2979
+ else {
2980
+ // Slow path for backwards compatibility if the driver does not implement
2981
+ // `getParentElement`, to be removed once `getParentElement` is a required method.
2982
+ for (let i = limit; i >= 0; i--) {
2983
+ const nextNamespace = namespaceList[i];
2984
+ if (this.driver.containsElement(nextNamespace.hostElement, hostElement)) {
2985
+ namespaceList.splice(i + 1, 0, ns);
2986
+ found = true;
2987
+ break;
2988
+ }
2775
2989
  }
2776
2990
  }
2777
2991
  if (!found) {
2778
- this._namespaceList.splice(0, 0, ns);
2992
+ // No namespace exists that is an ancestor of `ns`, so `ns` is inserted at the front to
2993
+ // ensure that any existing descendants are ordered after `ns`, retaining the desired
2994
+ // top-down ordering.
2995
+ namespaceList.unshift(ns);
2779
2996
  }
2780
2997
  }
2781
2998
  else {
2782
- this._namespaceList.push(ns);
2999
+ namespaceList.push(ns);
2783
3000
  }
2784
- this.namespacesByHostElement.set(hostElement, ns);
3001
+ namespacesByHostElement.set(hostElement, ns);
2785
3002
  return ns;
2786
3003
  }
2787
3004
  register(namespaceId, hostElement) {
@@ -3048,7 +3265,7 @@ class TransitionAnimationEngine {
3048
3265
  }
3049
3266
  }
3050
3267
  reportError(errors) {
3051
- throw new Error(`Unable to process animations due to the following failed trigger transitions\n ${errors.join('\n')}`);
3268
+ throw triggerTransitionsFailed(errors);
3052
3269
  }
3053
3270
  _flushAnimations(cleanupFns, microtaskId) {
3054
3271
  const subTimelines = new ElementInstructionMap();
@@ -3210,8 +3427,7 @@ class TransitionAnimationEngine {
3210
3427
  if (erroneousTransitions.length) {
3211
3428
  const errors = [];
3212
3429
  erroneousTransitions.forEach(instruction => {
3213
- errors.push(`@${instruction.triggerName} has failed due to:\n`);
3214
- instruction.errors.forEach(error => errors.push(`- ${error}\n`));
3430
+ errors.push(transitionFailed(instruction.triggerName, instruction.errors));
3215
3431
  });
3216
3432
  allPlayers.forEach(player => player.destroy());
3217
3433
  this.reportError(errors);
@@ -3826,9 +4042,13 @@ class AnimationEngine {
3826
4042
  let trigger = this._triggerCache[cacheKey];
3827
4043
  if (!trigger) {
3828
4044
  const errors = [];
3829
- const ast = buildAnimationAst(this._driver, metadata, errors);
4045
+ const warnings = [];
4046
+ const ast = buildAnimationAst(this._driver, metadata, errors, warnings);
3830
4047
  if (errors.length) {
3831
- throw new Error(`The animation trigger "${name}" has failed to build due to the following errors:\n - ${errors.join('\n - ')}`);
4048
+ throw triggerBuildFailed(name, errors);
4049
+ }
4050
+ if (warnings.length) {
4051
+ warnTriggerBuild(name, warnings);
3832
4052
  }
3833
4053
  trigger = buildTrigger(name, ast, this._normalizer);
3834
4054
  this._triggerCache[cacheKey] = trigger;
@@ -4151,6 +4371,9 @@ class WebAnimationsDriver {
4151
4371
  containsElement(elm1, elm2) {
4152
4372
  return containsElement(elm1, elm2);
4153
4373
  }
4374
+ getParentElement(element) {
4375
+ return getParentElement(element);
4376
+ }
4154
4377
  query(element, selector, multi) {
4155
4378
  return invokeQuery(element, selector, multi);
4156
4379
  }
@@ -4216,5 +4439,5 @@ class WebAnimationsDriver {
4216
4439
  * Generated bundle index. Do not edit.
4217
4440
  */
4218
4441
 
4219
- 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, validateStyleProperty as ɵvalidateStyleProperty };
4442
+ 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, validateStyleProperty as ɵvalidateStyleProperty };
4220
4443
  //# sourceMappingURL=browser.mjs.map