1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import { Observable } from 'rxjs/Observable';
|
7 | import { merge } from 'rxjs/observable/merge';
|
8 | import { share } from 'rxjs/operator/share';
|
9 | import { Subject } from 'rxjs/Subject';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | class OpaqueToken {
|
35 | |
36 |
|
37 |
|
38 | constructor(_desc) {
|
39 | this._desc = _desc;
|
40 | }
|
41 | |
42 |
|
43 |
|
44 | toString() { return `Token ${this._desc}`; }
|
45 | }
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | class InjectionToken extends OpaqueToken {
|
69 | |
70 |
|
71 |
|
72 | constructor(desc) { super(desc); }
|
73 | |
74 |
|
75 |
|
76 | toString() { return `InjectionToken ${this._desc}`; }
|
77 | }
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | const __window = typeof window !== 'undefined' && window;
|
87 | const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
|
88 | self instanceof WorkerGlobalScope && self;
|
89 | const __global = typeof global !== 'undefined' && global;
|
90 | const _global = __window || __global || __self;
|
91 | let _symbolIterator = null;
|
92 |
|
93 |
|
94 |
|
95 | function getSymbolIterator() {
|
96 | if (!_symbolIterator) {
|
97 | const Symbol = _global['Symbol'];
|
98 | if (Symbol && Symbol.iterator) {
|
99 | _symbolIterator = Symbol.iterator;
|
100 | }
|
101 | else {
|
102 |
|
103 | const keys = Object.getOwnPropertyNames(Map.prototype);
|
104 | for (let i = 0; i < keys.length; ++i) {
|
105 | const key = keys[i];
|
106 | if (key !== 'entries' && key !== 'size' &&
|
107 | ((Map)).prototype[key] === Map.prototype['entries']) {
|
108 | _symbolIterator = key;
|
109 | }
|
110 | }
|
111 | }
|
112 | }
|
113 | return _symbolIterator;
|
114 | }
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | function scheduleMicroTask(fn) {
|
120 | Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
|
121 | }
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 | function looseIdentical(a, b) {
|
128 | return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
|
129 | }
|
130 |
|
131 |
|
132 |
|
133 |
|
134 | function stringify(token) {
|
135 | if (typeof token === 'string') {
|
136 | return token;
|
137 | }
|
138 | if (token == null) {
|
139 | return '' + token;
|
140 | }
|
141 | if (token.overriddenName) {
|
142 | return `${token.overriddenName}`;
|
143 | }
|
144 | if (token.name) {
|
145 | return `${token.name}`;
|
146 | }
|
147 | const res = token.toString();
|
148 | if (res == null) {
|
149 | return '' + res;
|
150 | }
|
151 | const newLineIndex = res.indexOf('\n');
|
152 | return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
153 | }
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | let _nextClassId = 0;
|
163 | const Reflect = _global['Reflect'];
|
164 |
|
165 |
|
166 |
|
167 |
|
168 | function extractAnnotation(annotation) {
|
169 | if (typeof annotation === 'function' && annotation.hasOwnProperty('annotation')) {
|
170 |
|
171 | annotation = annotation.annotation;
|
172 | }
|
173 | return annotation;
|
174 | }
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 | function applyParams(fnOrArray, key) {
|
181 | if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
|
182 | fnOrArray === Number || fnOrArray === Array) {
|
183 | throw new Error(`Can not use native ${stringify(fnOrArray)} as constructor`);
|
184 | }
|
185 | if (typeof fnOrArray === 'function') {
|
186 | return fnOrArray;
|
187 | }
|
188 | if (Array.isArray(fnOrArray)) {
|
189 | const annotations = (fnOrArray);
|
190 | const annoLength = annotations.length - 1;
|
191 | const fn = fnOrArray[annoLength];
|
192 | if (typeof fn !== 'function') {
|
193 | throw new Error(`Last position of Class method array must be Function in key ${key} was '${stringify(fn)}'`);
|
194 | }
|
195 | if (annoLength != fn.length) {
|
196 | throw new Error(`Number of annotations (${annoLength}) does not match number of arguments (${fn.length}) in the function: ${stringify(fn)}`);
|
197 | }
|
198 | const paramsAnnotations = [];
|
199 | for (let i = 0, ii = annotations.length - 1; i < ii; i++) {
|
200 | const paramAnnotations = [];
|
201 | paramsAnnotations.push(paramAnnotations);
|
202 | const annotation = annotations[i];
|
203 | if (Array.isArray(annotation)) {
|
204 | for (let j = 0; j < annotation.length; j++) {
|
205 | paramAnnotations.push(extractAnnotation(annotation[j]));
|
206 | }
|
207 | }
|
208 | else if (typeof annotation === 'function') {
|
209 | paramAnnotations.push(extractAnnotation(annotation));
|
210 | }
|
211 | else {
|
212 | paramAnnotations.push(annotation);
|
213 | }
|
214 | }
|
215 | Reflect.defineMetadata('parameters', paramsAnnotations, fn);
|
216 | return fn;
|
217 | }
|
218 | throw new Error(`Only Function or Array is supported in Class definition for key '${key}' is '${stringify(fnOrArray)}'`);
|
219 | }
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 | function Class(clsDef) {
|
306 | const constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
|
307 | let /** @type {?} */ proto = constructor.prototype;
|
308 | if (clsDef.hasOwnProperty('extends')) {
|
309 | if (typeof clsDef.extends === 'function') {
|
310 | ((constructor)).prototype = proto =
|
311 | Object.create(((clsDef.extends)).prototype);
|
312 | }
|
313 | else {
|
314 | throw new Error(`Class definition 'extends' property must be a constructor function was: ${stringify(clsDef.extends)}`);
|
315 | }
|
316 | }
|
317 | for (const key in clsDef) {
|
318 | if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
|
319 | proto[key] = applyParams(clsDef[key], key);
|
320 | }
|
321 | }
|
322 | if (this && this.annotations instanceof Array) {
|
323 | Reflect.defineMetadata('annotations', this.annotations, constructor);
|
324 | }
|
325 | const /** @type {?} */ constructorName = constructor['name'];
|
326 | if (!constructorName || constructorName === 'constructor') {
|
327 | ((constructor))['overriddenName'] = `class${_nextClassId++}`;
|
328 | }
|
329 | return (constructor);
|
330 | }
|
331 | /**
|
332 | * @suppress {globalThis}
|
333 | * @param {?} name
|
334 | * @param {?} props
|
335 | * @param {?=} parentClass
|
336 | * @param {?=} chainFn
|
337 | * @return {?}
|
338 | */
|
339 | function makeDecorator(name, props, parentClass, chainFn) {
|
340 | const /** @type {?} */ metaCtor = makeMetadataCtor([props]);
|
341 | /**
|
342 | * @param {?} objOrType
|
343 | * @return {?}
|
344 | */
|
345 | function DecoratorFactory(objOrType) {
|
346 | if (!(Reflect && Reflect.getOwnMetadata)) {
|
347 | throw 'reflect-metadata shim is required when using class decorators';
|
348 | }
|
349 | if (this instanceof DecoratorFactory) {
|
350 | metaCtor.call(this, objOrType);
|
351 | return this;
|
352 | }
|
353 | const /** @type {?} */ annotationInstance = new ((DecoratorFactory))(objOrType);
|
354 | const /** @type {?} */ chainAnnotation = typeof this === 'function' && Array.isArray(this.annotations) ? this.annotations : [];
|
355 | chainAnnotation.push(annotationInstance);
|
356 | const /** @type {?} */ TypeDecorator = (function TypeDecorator(cls) {
|
357 | const /** @type {?} */ annotations = Reflect.getOwnMetadata('annotations', cls) || [];
|
358 | annotations.push(annotationInstance);
|
359 | Reflect.defineMetadata('annotations', annotations, cls);
|
360 | return cls;
|
361 | });
|
362 | TypeDecorator.annotations = chainAnnotation;
|
363 | TypeDecorator.Class = Class;
|
364 | if (chainFn)
|
365 | chainFn(TypeDecorator);
|
366 | return TypeDecorator;
|
367 | }
|
368 | if (parentClass) {
|
369 | DecoratorFactory.prototype = Object.create(parentClass.prototype);
|
370 | }
|
371 | DecoratorFactory.prototype.toString = () => `@${name}`;
|
372 | ((DecoratorFactory)).annotationCls = DecoratorFactory;
|
373 | return DecoratorFactory;
|
374 | }
|
375 | /**
|
376 | * @param {?} props
|
377 | * @return {?}
|
378 | */
|
379 | function makeMetadataCtor(props) {
|
380 | return function ctor(...args) {
|
381 | props.forEach((prop, i) => {
|
382 | const /** @type {?} */ argVal = args[i];
|
383 | if (Array.isArray(prop)) {
|
384 | // plain parameter
|
385 | this[prop[0]] = argVal === undefined ? prop[1] : argVal;
|
386 | }
|
387 | else {
|
388 | for (const /** @type {?} */ propName in prop) {
|
389 | this[propName] =
|
390 | argVal && argVal.hasOwnProperty(propName) ? argVal[propName] : prop[propName];
|
391 | }
|
392 | }
|
393 | });
|
394 | };
|
395 | }
|
396 | /**
|
397 | * @param {?} name
|
398 | * @param {?} props
|
399 | * @param {?=} parentClass
|
400 | * @return {?}
|
401 | */
|
402 | function makeParamDecorator(name, props, parentClass) {
|
403 | const /** @type {?} */ metaCtor = makeMetadataCtor(props);
|
404 | /**
|
405 | * @param {...?} args
|
406 | * @return {?}
|
407 | */
|
408 | function ParamDecoratorFactory(...args) {
|
409 | if (this instanceof ParamDecoratorFactory) {
|
410 | metaCtor.apply(this, args);
|
411 | return this;
|
412 | }
|
413 | const /** @type {?} */ annotationInstance = new ((ParamDecoratorFactory))(...args);
|
414 | ((ParamDecorator)).annotation = annotationInstance;
|
415 | return ParamDecorator;
|
416 | /**
|
417 | * @param {?} cls
|
418 | * @param {?} unusedKey
|
419 | * @param {?} index
|
420 | * @return {?}
|
421 | */
|
422 | function ParamDecorator(cls, unusedKey, index) {
|
423 | const /** @type {?} */ parameters = Reflect.getOwnMetadata('parameters', cls) || [];
|
424 | // there might be gaps if some in between parameters do not have annotations.
|
425 | // we pad with nulls.
|
426 | while (parameters.length <= index) {
|
427 | parameters.push(null);
|
428 | }
|
429 | parameters[index] = parameters[index] || []; /** @type {?} */
|
430 | ((parameters[index])).push(annotationInstance);
|
431 | Reflect.defineMetadata('parameters', parameters, cls);
|
432 | return cls;
|
433 | }
|
434 | }
|
435 | if (parentClass) {
|
436 | ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
|
437 | }
|
438 | ParamDecoratorFactory.prototype.toString = () => `@${name}`;
|
439 | ((ParamDecoratorFactory)).annotationCls = ParamDecoratorFactory;
|
440 | return ParamDecoratorFactory;
|
441 | }
|
442 | /**
|
443 | * @param {?} name
|
444 | * @param {?} props
|
445 | * @param {?=} parentClass
|
446 | * @return {?}
|
447 | */
|
448 | function makePropDecorator(name, props, parentClass) {
|
449 | const /** @type {?} */ metaCtor = makeMetadataCtor(props);
|
450 | /**
|
451 | * @param {...?} args
|
452 | * @return {?}
|
453 | */
|
454 | function PropDecoratorFactory(...args) {
|
455 | if (this instanceof PropDecoratorFactory) {
|
456 | metaCtor.apply(this, args);
|
457 | return this;
|
458 | }
|
459 | const /** @type {?} */ decoratorInstance = new ((PropDecoratorFactory))(...args);
|
460 | return function PropDecorator(target, name) {
|
461 | const /** @type {?} */ meta = Reflect.getOwnMetadata('propMetadata', target.constructor) || {};
|
462 | meta[name] = meta.hasOwnProperty(name) && meta[name] || [];
|
463 | meta[name].unshift(decoratorInstance);
|
464 | Reflect.defineMetadata('propMetadata', meta, target.constructor);
|
465 | };
|
466 | }
|
467 | if (parentClass) {
|
468 | PropDecoratorFactory.prototype = Object.create(parentClass.prototype);
|
469 | }
|
470 | PropDecoratorFactory.prototype.toString = () => `@${name}`;
|
471 | ((PropDecoratorFactory)).annotationCls = PropDecoratorFactory;
|
472 | return PropDecoratorFactory;
|
473 | }
|
474 |
|
475 | /**
|
476 | * @license
|
477 | * Copyright Google Inc. All Rights Reserved.
|
478 | *
|
479 | * Use of this source code is governed by an MIT-style license that can be
|
480 | * found in the LICENSE file at https://angular.io/license
|
481 | */
|
482 | /**
|
483 | * This token can be used to create a virtual provider that will populate the
|
484 | * `entryComponents` fields of components and ng modules based on its `useValue`.
|
485 | * All components that are referenced in the `useValue` value (either directly
|
486 | * or in a nested array or map) will be added to the `entryComponents` property.
|
487 | *
|
488 | * ### Example
|
489 | * The following example shows how the router can populate the `entryComponents`
|
490 | * field of an NgModule based on the router configuration which refers
|
491 | * to components.
|
492 | *
|
493 | * ```typescript
|
494 | *
|
495 | * function provideRoutes(routes) {
|
496 | * return [
|
497 | * {provide: ROUTES, useValue: routes},
|
498 | * {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
|
499 | * ];
|
500 | * }
|
501 | *
|
502 | *
|
503 | * let routes = [
|
504 | * {path: '/root', component: RootComp},
|
505 | * {path: '/teams', component: TeamsComp}
|
506 | * ];
|
507 | *
|
508 | * \@NgModule({
|
509 | * providers: [provideRoutes(routes)]
|
510 | * })
|
511 | * class ModuleWithRoutes {}
|
512 | * ```
|
513 | *
|
514 | * \@experimental
|
515 | */
|
516 | const ANALYZE_FOR_ENTRY_COMPONENTS = new InjectionToken('AnalyzeForEntryComponents');
|
517 | /**
|
518 | * Attribute decorator and metadata.
|
519 | *
|
520 | * \@stable
|
521 | * \@Annotation
|
522 | */
|
523 | const Attribute = makeParamDecorator('Attribute', [['attributeName', undefined]]);
|
524 | /**
|
525 | * Base class for query metadata.
|
526 | *
|
527 | * See {\@link ContentChildren}, {\@link ContentChild}, {\@link ViewChildren}, {\@link ViewChild} for
|
528 | * more information.
|
529 | *
|
530 | * \@stable
|
531 | * @abstract
|
532 | */
|
533 | class Query {
|
534 | }
|
535 | /**
|
536 | * ContentChildren decorator and metadata.
|
537 | *
|
538 | * \@stable
|
539 | * \@Annotation
|
540 | */
|
541 | const ContentChildren = makePropDecorator('ContentChildren', [
|
542 | ['selector', undefined], {
|
543 | first: false,
|
544 | isViewQuery: false,
|
545 | descendants: false,
|
546 | read: undefined,
|
547 | }
|
548 | ], Query);
|
549 | /**
|
550 | * ContentChild decorator and metadata.
|
551 | *
|
552 | * \@stable
|
553 | * \@Annotation
|
554 | */
|
555 | const ContentChild = makePropDecorator('ContentChild', [
|
556 | ['selector', undefined], {
|
557 | first: true,
|
558 | isViewQuery: false,
|
559 | descendants: true,
|
560 | read: undefined,
|
561 | }
|
562 | ], Query);
|
563 | /**
|
564 | * ViewChildren decorator and metadata.
|
565 | *
|
566 | * \@stable
|
567 | * \@Annotation
|
568 | */
|
569 | const ViewChildren = makePropDecorator('ViewChildren', [
|
570 | ['selector', undefined], {
|
571 | first: false,
|
572 | isViewQuery: true,
|
573 | descendants: true,
|
574 | read: undefined,
|
575 | }
|
576 | ], Query);
|
577 | /**
|
578 | * ViewChild decorator and metadata.
|
579 | *
|
580 | * \@stable
|
581 | * \@Annotation
|
582 | */
|
583 | const ViewChild = makePropDecorator('ViewChild', [
|
584 | ['selector', undefined], {
|
585 | first: true,
|
586 | isViewQuery: true,
|
587 | descendants: true,
|
588 | read: undefined,
|
589 | }
|
590 | ], Query);
|
591 |
|
592 | let ChangeDetectionStrategy = {};
|
593 | ChangeDetectionStrategy.OnPush = 0;
|
594 | ChangeDetectionStrategy.Default = 1;
|
595 | ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
|
596 | ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
|
597 | let ChangeDetectorStatus = {};
|
598 | ChangeDetectorStatus.CheckOnce = 0;
|
599 | ChangeDetectorStatus.Checked = 1;
|
600 | ChangeDetectorStatus.CheckAlways = 2;
|
601 | ChangeDetectorStatus.Detached = 3;
|
602 | ChangeDetectorStatus.Errored = 4;
|
603 | ChangeDetectorStatus.Destroyed = 5;
|
604 | ChangeDetectorStatus[ChangeDetectorStatus.CheckOnce] = "CheckOnce";
|
605 | ChangeDetectorStatus[ChangeDetectorStatus.Checked] = "Checked";
|
606 | ChangeDetectorStatus[ChangeDetectorStatus.CheckAlways] = "CheckAlways";
|
607 | ChangeDetectorStatus[ChangeDetectorStatus.Detached] = "Detached";
|
608 | ChangeDetectorStatus[ChangeDetectorStatus.Errored] = "Errored";
|
609 | ChangeDetectorStatus[ChangeDetectorStatus.Destroyed] = "Destroyed";
|
610 | /**
|
611 | * @param {?} changeDetectionStrategy
|
612 | * @return {?}
|
613 | */
|
614 | function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
|
615 | return changeDetectionStrategy == null ||
|
616 | changeDetectionStrategy === ChangeDetectionStrategy.Default;
|
617 | }
|
618 |
|
619 | /**
|
620 | * @license
|
621 | * Copyright Google Inc. All Rights Reserved.
|
622 | *
|
623 | * Use of this source code is governed by an MIT-style license that can be
|
624 | * found in the LICENSE file at https://angular.io/license
|
625 | */
|
626 | /**
|
627 | * Directive decorator and metadata.
|
628 | *
|
629 | * \@stable
|
630 | * \@Annotation
|
631 | */
|
632 | const Directive = makeDecorator('Directive', {
|
633 | selector: undefined,
|
634 | inputs: undefined,
|
635 | outputs: undefined,
|
636 | host: undefined,
|
637 | providers: undefined,
|
638 | exportAs: undefined,
|
639 | queries: undefined
|
640 | });
|
641 | /**
|
642 | * Component decorator and metadata.
|
643 | *
|
644 | * \@stable
|
645 | * \@Annotation
|
646 | */
|
647 | const Component = makeDecorator('Component', {
|
648 | selector: undefined,
|
649 | inputs: undefined,
|
650 | outputs: undefined,
|
651 | host: undefined,
|
652 | exportAs: undefined,
|
653 | moduleId: undefined,
|
654 | providers: undefined,
|
655 | viewProviders: undefined,
|
656 | changeDetection: ChangeDetectionStrategy.Default,
|
657 | queries: undefined,
|
658 | templateUrl: undefined,
|
659 | template: undefined,
|
660 | styleUrls: undefined,
|
661 | styles: undefined,
|
662 | animations: undefined,
|
663 | encapsulation: undefined,
|
664 | interpolation: undefined,
|
665 | entryComponents: undefined
|
666 | }, Directive);
|
667 | /**
|
668 | * Pipe decorator and metadata.
|
669 | *
|
670 | * \@stable
|
671 | * \@Annotation
|
672 | */
|
673 | const Pipe = makeDecorator('Pipe', {
|
674 | name: undefined,
|
675 | pure: true,
|
676 | });
|
677 | /**
|
678 | * Input decorator and metadata.
|
679 | *
|
680 | * \@stable
|
681 | * \@Annotation
|
682 | */
|
683 | const Input = makePropDecorator('Input', [['bindingPropertyName', undefined]]);
|
684 | /**
|
685 | * Output decorator and metadata.
|
686 | *
|
687 | * \@stable
|
688 | * \@Annotation
|
689 | */
|
690 | const Output = makePropDecorator('Output', [['bindingPropertyName', undefined]]);
|
691 | /**
|
692 | * HostBinding decorator and metadata.
|
693 | *
|
694 | * \@stable
|
695 | * \@Annotation
|
696 | */
|
697 | const HostBinding = makePropDecorator('HostBinding', [['hostPropertyName', undefined]]);
|
698 | /**
|
699 | * HostListener decorator and metadata.
|
700 | *
|
701 | * \@stable
|
702 | * \@Annotation
|
703 | */
|
704 | const HostListener = makePropDecorator('HostListener', [['eventName', undefined], ['args', []]]);
|
705 |
|
706 | /**
|
707 | * @license
|
708 | * Copyright Google Inc. All Rights Reserved.
|
709 | *
|
710 | * Use of this source code is governed by an MIT-style license that can be
|
711 | * found in the LICENSE file at https://angular.io/license
|
712 | */
|
713 | /**
|
714 | * Defines a schema that will allow:
|
715 | * - any non-Angular elements with a `-` in their name,
|
716 | * - any properties on elements with a `-` in their name which is the common rule for custom
|
717 | * elements.
|
718 | *
|
719 | * \@stable
|
720 | */
|
721 | const CUSTOM_ELEMENTS_SCHEMA = {
|
722 | name: 'custom-elements'
|
723 | };
|
724 | /**
|
725 | * Defines a schema that will allow any property on any element.
|
726 | *
|
727 | * \@experimental
|
728 | */
|
729 | const NO_ERRORS_SCHEMA = {
|
730 | name: 'no-errors-schema'
|
731 | };
|
732 | /**
|
733 | * NgModule decorator and metadata.
|
734 | *
|
735 | * \@stable
|
736 | * \@Annotation
|
737 | */
|
738 | const NgModule = makeDecorator('NgModule', {
|
739 | providers: undefined,
|
740 | declarations: undefined,
|
741 | imports: undefined,
|
742 | exports: undefined,
|
743 | entryComponents: undefined,
|
744 | bootstrap: undefined,
|
745 | schemas: undefined,
|
746 | id: undefined,
|
747 | });
|
748 |
|
749 | let ViewEncapsulation = {};
|
750 | ViewEncapsulation.Emulated = 0;
|
751 | ViewEncapsulation.Native = 1;
|
752 | ViewEncapsulation.None = 2;
|
753 | ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
|
754 | ViewEncapsulation[ViewEncapsulation.Native] = "Native";
|
755 | ViewEncapsulation[ViewEncapsulation.None] = "None";
|
756 | /**
|
757 | * Metadata properties available for configuring Views.
|
758 | *
|
759 | * For details on the `\@Component` annotation, see {\@link Component}.
|
760 | *
|
761 | * ### Example
|
762 | *
|
763 | * ```
|
764 | * \@Component({
|
765 | * selector: 'greet',
|
766 | * template: 'Hello {{name}}!',
|
767 | * })
|
768 | * class Greet {
|
769 | * name: string;
|
770 | *
|
771 | * constructor() {
|
772 | * this.name = 'World';
|
773 | * }
|
774 | * }
|
775 | * ```
|
776 | *
|
777 | * @deprecated Use Component instead.
|
778 | *
|
779 | * {\@link Component}
|
780 | */
|
781 | class ViewMetadata {
|
782 | /**
|
783 | * @param {?=} __0
|
784 | */
|
785 | constructor({ templateUrl, template, encapsulation, styles, styleUrls, animations, interpolation } = {}) {
|
786 | this.templateUrl = templateUrl;
|
787 | this.template = template;
|
788 | this.styleUrls = styleUrls;
|
789 | this.styles = styles;
|
790 | this.encapsulation = encapsulation;
|
791 | this.animations = animations;
|
792 | this.interpolation = interpolation;
|
793 | }
|
794 | }
|
795 |
|
796 | /**
|
797 | * @license
|
798 | * Copyright Google Inc. All Rights Reserved.
|
799 | *
|
800 | * Use of this source code is governed by an MIT-style license that can be
|
801 | * found in the LICENSE file at https://angular.io/license
|
802 | */
|
803 |
|
804 | /**
|
805 | * \@whatItDoes Represents the version of Angular
|
806 | *
|
807 | * \@stable
|
808 | */
|
809 | class Version {
|
810 | /**
|
811 | * @param {?} full
|
812 | */
|
813 | constructor(full) {
|
814 | this.full = full;
|
815 | }
|
816 | /**
|
817 | * @return {?}
|
818 | */
|
819 | get major() { return this.full.split('.')[0]; }
|
820 | /**
|
821 | * @return {?}
|
822 | */
|
823 | get minor() { return this.full.split('.')[1]; }
|
824 | /**
|
825 | * @return {?}
|
826 | */
|
827 | get patch() { return this.full.split('.').slice(2).join('.'); }
|
828 | }
|
829 | /**
|
830 | * \@stable
|
831 | */
|
832 | const VERSION = new Version('4.1.1');
|
833 |
|
834 | /**
|
835 | * @license
|
836 | * Copyright Google Inc. All Rights Reserved.
|
837 | *
|
838 | * Use of this source code is governed by an MIT-style license that can be
|
839 | * found in the LICENSE file at https://angular.io/license
|
840 | */
|
841 | /**
|
842 | * Inject decorator and metadata.
|
843 | *
|
844 | * \@stable
|
845 | * \@Annotation
|
846 | */
|
847 | const Inject = makeParamDecorator('Inject', [['token', undefined]]);
|
848 | /**
|
849 | * Optional decorator and metadata.
|
850 | *
|
851 | * \@stable
|
852 | * \@Annotation
|
853 | */
|
854 | const Optional = makeParamDecorator('Optional', []);
|
855 | /**
|
856 | * Injectable decorator and metadata.
|
857 | *
|
858 | * \@stable
|
859 | * \@Annotation
|
860 | */
|
861 | const Injectable = makeDecorator('Injectable', []);
|
862 | /**
|
863 | * Self decorator and metadata.
|
864 | *
|
865 | * \@stable
|
866 | * \@Annotation
|
867 | */
|
868 | const Self = makeParamDecorator('Self', []);
|
869 | /**
|
870 | * SkipSelf decorator and metadata.
|
871 | *
|
872 | * \@stable
|
873 | * \@Annotation
|
874 | */
|
875 | const SkipSelf = makeParamDecorator('SkipSelf', []);
|
876 | /**
|
877 | * Host decorator and metadata.
|
878 | *
|
879 | * \@stable
|
880 | * \@Annotation
|
881 | */
|
882 | const Host = makeParamDecorator('Host', []);
|
883 |
|
884 | /**
|
885 | * @license
|
886 | * Copyright Google Inc. All Rights Reserved.
|
887 | *
|
888 | * Use of this source code is governed by an MIT-style license that can be
|
889 | * found in the LICENSE file at https://angular.io/license
|
890 | */
|
891 | /**
|
892 | * Allows to refer to references which are not yet defined.
|
893 | *
|
894 | * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
|
895 | * DI is declared,
|
896 | * but not yet defined. It is also used when the `token` which we use when creating a query is not
|
897 | * yet defined.
|
898 | *
|
899 | * ### Example
|
900 | * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
|
901 | * \@experimental
|
902 | * @param {?} forwardRefFn
|
903 | * @return {?}
|
904 | */
|
905 | function forwardRef(forwardRefFn) {
|
906 | ((forwardRefFn)).__forward_ref__ = forwardRef;
|
907 | ((forwardRefFn)).toString = function () { return stringify(this()); };
|
908 | return (((forwardRefFn)));
|
909 | }
|
910 | /**
|
911 | * Lazily retrieves the reference value from a forwardRef.
|
912 | *
|
913 | * Acts as the identity function when given a non-forward-ref value.
|
914 | *
|
915 | * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
|
916 | *
|
917 | * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
|
918 | *
|
919 | * See: {\@link forwardRef}
|
920 | * \@experimental
|
921 | * @param {?} type
|
922 | * @return {?}
|
923 | */
|
924 | function resolveForwardRef(type) {
|
925 | if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') &&
|
926 | type.__forward_ref__ === forwardRef) {
|
927 | return ((type))();
|
928 | }
|
929 | else {
|
930 | return type;
|
931 | }
|
932 | }
|
933 |
|
934 | /**
|
935 | * @license
|
936 | * Copyright Google Inc. All Rights Reserved.
|
937 | *
|
938 | * Use of this source code is governed by an MIT-style license that can be
|
939 | * found in the LICENSE file at https://angular.io/license
|
940 | */
|
941 | const _THROW_IF_NOT_FOUND = new Object();
|
942 | const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
943 | class _NullInjector {
|
944 | /**
|
945 | * @param {?} token
|
946 | * @param {?=} notFoundValue
|
947 | * @return {?}
|
948 | */
|
949 | get(token, notFoundValue = _THROW_IF_NOT_FOUND) {
|
950 | if (notFoundValue === _THROW_IF_NOT_FOUND) {
|
951 | throw new Error(`No provider for ${stringify(token)}!`);
|
952 | }
|
953 | return notFoundValue;
|
954 | }
|
955 | }
|
956 | /**
|
957 | * \@whatItDoes Injector interface
|
958 | * \@howToUse
|
959 | * ```
|
960 | * const injector: Injector = ...;
|
961 | * injector.get(...);
|
962 | * ```
|
963 | *
|
964 | * \@description
|
965 | * For more details, see the {\@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
|
966 | *
|
967 | * ### Example
|
968 | *
|
969 | * {\@example core/di/ts/injector_spec.ts region='Injector'}
|
970 | *
|
971 | * `Injector` returns itself when given `Injector` as a token:
|
972 | * {\@example core/di/ts/injector_spec.ts region='injectInjector'}
|
973 | *
|
974 | * \@stable
|
975 | * @abstract
|
976 | */
|
977 | class Injector {
|
978 | /**
|
979 | * Retrieves an instance from the injector based on the provided token.
|
980 | * If not found:
|
981 | * - Throws an error if no `notFoundValue` that is not equal to
|
982 | * Injector.THROW_IF_NOT_FOUND is given
|
983 | * - Returns the `notFoundValue` otherwise
|
984 | * @abstract
|
985 | * @template T
|
986 | * @param {?} token
|
987 | * @param {?=} notFoundValue
|
988 | * @return {?}
|
989 | */
|
990 | get(token, notFoundValue) { }
|
991 | /**
|
992 | * @deprecated from v4.0.0 use Type<T> or InjectionToken<T>
|
993 | * @suppress {duplicate}
|
994 | * @abstract
|
995 | * @param {?} token
|
996 | * @param {?=} notFoundValue
|
997 | * @return {?}
|
998 | */
|
999 | get(token, notFoundValue) { }
|
1000 | }
|
1001 | Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
1002 | Injector.NULL = new _NullInjector();
|
1003 |
|
1004 | /**
|
1005 | * @license
|
1006 | * Copyright Google Inc. All Rights Reserved.
|
1007 | *
|
1008 | * Use of this source code is governed by an MIT-style license that can be
|
1009 | * found in the LICENSE file at https://angular.io/license
|
1010 | */
|
1011 |
|
1012 | const ERROR_COMPONENT_TYPE = 'ngComponentType';
|
1013 | const ERROR_DEBUG_CONTEXT = 'ngDebugContext';
|
1014 | const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
|
1015 | const ERROR_LOGGER = 'ngErrorLogger';
|
1016 | /**
|
1017 | * @param {?} error
|
1018 | * @return {?}
|
1019 | */
|
1020 |
|
1021 | /**
|
1022 | * @param {?} error
|
1023 | * @return {?}
|
1024 | */
|
1025 | function getDebugContext(error) {
|
1026 | return ((error))[ERROR_DEBUG_CONTEXT];
|
1027 | }
|
1028 | /**
|
1029 | * @param {?} error
|
1030 | * @return {?}
|
1031 | */
|
1032 | function getOriginalError(error) {
|
1033 | return ((error))[ERROR_ORIGINAL_ERROR];
|
1034 | }
|
1035 | /**
|
1036 | * @param {?} error
|
1037 | * @return {?}
|
1038 | */
|
1039 | function getErrorLogger(error) {
|
1040 | return ((error))[ERROR_LOGGER] || defaultErrorLogger;
|
1041 | }
|
1042 | /**
|
1043 | * @param {?} console
|
1044 | * @param {...?} values
|
1045 | * @return {?}
|
1046 | */
|
1047 | function defaultErrorLogger(console, ...values) {
|
1048 | ((console.error))(...values);
|
1049 | }
|
1050 |
|
1051 | /**
|
1052 | * @license
|
1053 | * Copyright Google Inc. All Rights Reserved.
|
1054 | *
|
1055 | * Use of this source code is governed by an MIT-style license that can be
|
1056 | * found in the LICENSE file at https://angular.io/license
|
1057 | */
|
1058 | /**
|
1059 | * \@whatItDoes Provides a hook for centralized exception handling.
|
1060 | *
|
1061 | * \@description
|
1062 | *
|
1063 | * The default implementation of `ErrorHandler` prints error messages to the `console`. To
|
1064 | * intercept error handling, write a custom exception handler that replaces this default as
|
1065 | * appropriate for your app.
|
1066 | *
|
1067 | * ### Example
|
1068 | *
|
1069 | * ```
|
1070 | * class MyErrorHandler implements ErrorHandler {
|
1071 | * handleError(error) {
|
1072 | *
|
1073 | * }
|
1074 | * }
|
1075 | *
|
1076 | * \@NgModule({
|
1077 | * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
|
1078 | * })
|
1079 | * class MyModule {}
|
1080 | * ```
|
1081 | *
|
1082 | * \@stable
|
1083 | */
|
1084 | class ErrorHandler {
|
1085 | /**
|
1086 | * @param {?=} deprecatedParameter
|
1087 | */
|
1088 | constructor(
|
1089 | /**
|
1090 | * @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never
|
1091 | * rethrow.
|
1092 | */
|
1093 | deprecatedParameter) {
|
1094 | /**
|
1095 | * \@internal
|
1096 | */
|
1097 | this._console = console;
|
1098 | }
|
1099 | /**
|
1100 | * @param {?} error
|
1101 | * @return {?}
|
1102 | */
|
1103 | handleError(error) {
|
1104 | const /** @type {?} */ originalError = this._findOriginalError(error);
|
1105 | const /** @type {?} */ context = this._findContext(error);
|
1106 | // Note: Browser consoles show the place from where console.error was called.
|
1107 | // We can use this to give users additional information about the error.
|
1108 | const /** @type {?} */ errorLogger = getErrorLogger(error);
|
1109 | errorLogger(this._console, `ERROR`, error);
|
1110 | if (originalError) {
|
1111 | errorLogger(this._console, `ORIGINAL ERROR`, originalError);
|
1112 | }
|
1113 | if (context) {
|
1114 | errorLogger(this._console, 'ERROR CONTEXT', context);
|
1115 | }
|
1116 | }
|
1117 | /**
|
1118 | * \@internal
|
1119 | * @param {?} error
|
1120 | * @return {?}
|
1121 | */
|
1122 | _findContext(error) {
|
1123 | if (error) {
|
1124 | return getDebugContext(error) ? getDebugContext(error) :
|
1125 | this._findContext(getOriginalError(error));
|
1126 | }
|
1127 | return null;
|
1128 | }
|
1129 | /**
|
1130 | * \@internal
|
1131 | * @param {?} error
|
1132 | * @return {?}
|
1133 | */
|
1134 | _findOriginalError(error) {
|
1135 | let /** @type {?} */ e = getOriginalError(error);
|
1136 | while (e && getOriginalError(e)) {
|
1137 | e = getOriginalError(e);
|
1138 | }
|
1139 | return e;
|
1140 | }
|
1141 | }
|
1142 | /**
|
1143 | * @param {?} message
|
1144 | * @param {?} originalError
|
1145 | * @return {?}
|
1146 | */
|
1147 | function wrappedError(message, originalError) {
|
1148 | const /** @type {?} */ msg = `${message} caused by: ${originalError instanceof Error ? originalError.message : originalError}`;
|
1149 | const /** @type {?} */ error = Error(msg);
|
1150 | ((error))[ERROR_ORIGINAL_ERROR] = originalError;
|
1151 | return error;
|
1152 | }
|
1153 |
|
1154 | /**
|
1155 | * @license
|
1156 | * Copyright Google Inc. All Rights Reserved.
|
1157 | *
|
1158 | * Use of this source code is governed by an MIT-style license that can be
|
1159 | * found in the LICENSE file at https://angular.io/license
|
1160 | */
|
1161 | /**
|
1162 | * @param {?} keys
|
1163 | * @return {?}
|
1164 | */
|
1165 | function findFirstClosedCycle(keys) {
|
1166 | const /** @type {?} */ res = [];
|
1167 | for (let /** @type {?} */ i = 0; i < keys.length; ++i) {
|
1168 | if (res.indexOf(keys[i]) > -1) {
|
1169 | res.push(keys[i]);
|
1170 | return res;
|
1171 | }
|
1172 | res.push(keys[i]);
|
1173 | }
|
1174 | return res;
|
1175 | }
|
1176 | /**
|
1177 | * @param {?} keys
|
1178 | * @return {?}
|
1179 | */
|
1180 | function constructResolvingPath(keys) {
|
1181 | if (keys.length > 1) {
|
1182 | const /** @type {?} */ reversed = findFirstClosedCycle(keys.slice().reverse());
|
1183 | const /** @type {?} */ tokenStrs = reversed.map(k => stringify(k.token));
|
1184 | return ' (' + tokenStrs.join(' -> ') + ')';
|
1185 | }
|
1186 | return '';
|
1187 | }
|
1188 | /**
|
1189 | * @param {?} injector
|
1190 | * @param {?} key
|
1191 | * @param {?} constructResolvingMessage
|
1192 | * @param {?=} originalError
|
1193 | * @return {?}
|
1194 | */
|
1195 | function injectionError(injector, key, constructResolvingMessage, originalError) {
|
1196 | const /** @type {?} */ error = ((originalError ? wrappedError('', originalError) : Error()));
|
1197 | error.addKey = addKey;
|
1198 | error.keys = [key];
|
1199 | error.injectors = [injector];
|
1200 | error.constructResolvingMessage = constructResolvingMessage;
|
1201 | error.message = error.constructResolvingMessage();
|
1202 | ((error))[ERROR_ORIGINAL_ERROR] = originalError;
|
1203 | return error;
|
1204 | }
|
1205 | /**
|
1206 | * @this {?}
|
1207 | * @param {?} injector
|
1208 | * @param {?} key
|
1209 | * @return {?}
|
1210 | */
|
1211 | function addKey(injector, key) {
|
1212 | this.injectors.push(injector);
|
1213 | this.keys.push(key);
|
1214 | this.message = this.constructResolvingMessage();
|
1215 | }
|
1216 | /**
|
1217 | * Thrown when trying to retrieve a dependency by key from {\@link Injector}, but the
|
1218 | * {\@link Injector} does not have a {\@link Provider} for the given key.
|
1219 | *
|
1220 | * ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
|
1221 | *
|
1222 | * ```typescript
|
1223 | * class A {
|
1224 | * constructor(b:B) {}
|
1225 | * }
|
1226 | *
|
1227 | * expect(() => Injector.resolveAndCreate([A])).toThrowError();
|
1228 | * ```
|
1229 | * @param {?} injector
|
1230 | * @param {?} key
|
1231 | * @return {?}
|
1232 | */
|
1233 | function noProviderError(injector, key) {
|
1234 | return injectionError(injector, key, function () {
|
1235 | const /** @type {?} */ first = stringify(this.keys[0].token);
|
1236 | return `No provider for ${first}!${constructResolvingPath(this.keys)}`;
|
1237 | });
|
1238 | }
|
1239 | /**
|
1240 | * Thrown when dependencies form a cycle.
|
1241 | *
|
1242 | * ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
|
1243 | *
|
1244 | * ```typescript
|
1245 | * var injector = Injector.resolveAndCreate([
|
1246 | * {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
|
1247 | * {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
|
1248 | * ]);
|
1249 | *
|
1250 | * expect(() => injector.get("one")).toThrowError();
|
1251 | * ```
|
1252 | *
|
1253 | * Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
|
1254 | * @param {?} injector
|
1255 | * @param {?} key
|
1256 | * @return {?}
|
1257 | */
|
1258 | function cyclicDependencyError(injector, key) {
|
1259 | return injectionError(injector, key, function () {
|
1260 | return `Cannot instantiate cyclic dependency!${constructResolvingPath(this.keys)}`;
|
1261 | });
|
1262 | }
|
1263 | /**
|
1264 | * Thrown when a constructing type returns with an Error.
|
1265 | *
|
1266 | * The `InstantiationError` class contains the original error plus the dependency graph which caused
|
1267 | * this object to be instantiated.
|
1268 | *
|
1269 | * ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
|
1270 | *
|
1271 | * ```typescript
|
1272 | * class A {
|
1273 | * constructor() {
|
1274 | * throw new Error('message');
|
1275 | * }
|
1276 | * }
|
1277 | *
|
1278 | * var injector = Injector.resolveAndCreate([A]);
|
1279 | * try {
|
1280 | * injector.get(A);
|
1281 | * } catch (e) {
|
1282 | * expect(e instanceof InstantiationError).toBe(true);
|
1283 | * expect(e.originalException.message).toEqual("message");
|
1284 | * expect(e.originalStack).toBeDefined();
|
1285 | * }
|
1286 | * ```
|
1287 | * @param {?} injector
|
1288 | * @param {?} originalException
|
1289 | * @param {?} originalStack
|
1290 | * @param {?} key
|
1291 | * @return {?}
|
1292 | */
|
1293 | function instantiationError(injector, originalException, originalStack, key) {
|
1294 | return injectionError(injector, key, function () {
|
1295 | const /** @type {?} */ first = stringify(this.keys[0].token);
|
1296 | return `${getOriginalError(this).message}: Error during instantiation of ${first}!${constructResolvingPath(this.keys)}.`;
|
1297 | }, originalException);
|
1298 | }
|
1299 | /**
|
1300 | * Thrown when an object other then {\@link Provider} (or `Type`) is passed to {\@link Injector}
|
1301 | * creation.
|
1302 | *
|
1303 | * ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
|
1304 | *
|
1305 | * ```typescript
|
1306 | * expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
|
1307 | * ```
|
1308 | * @param {?} provider
|
1309 | * @return {?}
|
1310 | */
|
1311 | function invalidProviderError(provider) {
|
1312 | return Error(`Invalid provider - only instances of Provider and Type are allowed, got: ${provider}`);
|
1313 | }
|
1314 | /**
|
1315 | * Thrown when the class has no annotation information.
|
1316 | *
|
1317 | * Lack of annotation information prevents the {\@link Injector} from determining which dependencies
|
1318 | * need to be injected into the constructor.
|
1319 | *
|
1320 | * ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
|
1321 | *
|
1322 | * ```typescript
|
1323 | * class A {
|
1324 | * constructor(b) {}
|
1325 | * }
|
1326 | *
|
1327 | * expect(() => Injector.resolveAndCreate([A])).toThrowError();
|
1328 | * ```
|
1329 | *
|
1330 | * This error is also thrown when the class not marked with {\@link Injectable} has parameter types.
|
1331 | *
|
1332 | * ```typescript
|
1333 | * class B {}
|
1334 | *
|
1335 | * class A {
|
1336 | * constructor(b:B) {}
|
1337 | * }
|
1338 | *
|
1339 | * expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
|
1340 | * ```
|
1341 | * \@stable
|
1342 | * @param {?} typeOrFunc
|
1343 | * @param {?} params
|
1344 | * @return {?}
|
1345 | */
|
1346 | function noAnnotationError(typeOrFunc, params) {
|
1347 | const /** @type {?} */ signature = [];
|
1348 | for (let /** @type {?} */ i = 0, /** @type {?} */ ii = params.length; i < ii; i++) {
|
1349 | const /** @type {?} */ parameter = params[i];
|
1350 | if (!parameter || parameter.length == 0) {
|
1351 | signature.push('?');
|
1352 | }
|
1353 | else {
|
1354 | signature.push(parameter.map(stringify).join(' '));
|
1355 | }
|
1356 | }
|
1357 | return Error('Cannot resolve all parameters for \'' + stringify(typeOrFunc) + '\'(' +
|
1358 | signature.join(', ') + '). ' +
|
1359 | 'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' +
|
1360 | stringify(typeOrFunc) + '\' is decorated with Injectable.');
|
1361 | }
|
1362 | /**
|
1363 | * Thrown when getting an object by index.
|
1364 | *
|
1365 | * ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
|
1366 | *
|
1367 | * ```typescript
|
1368 | * class A {}
|
1369 | *
|
1370 | * var injector = Injector.resolveAndCreate([A]);
|
1371 | *
|
1372 | * expect(() => injector.getAt(100)).toThrowError();
|
1373 | * ```
|
1374 | * \@stable
|
1375 | * @param {?} index
|
1376 | * @return {?}
|
1377 | */
|
1378 | function outOfBoundsError(index) {
|
1379 | return Error(`Index ${index} is out-of-bounds.`);
|
1380 | }
|
1381 | /**
|
1382 | * Thrown when a multi provider and a regular provider are bound to the same token.
|
1383 | *
|
1384 | * ### Example
|
1385 | *
|
1386 | * ```typescript
|
1387 | * expect(() => Injector.resolveAndCreate([
|
1388 | * { provide: "Strings", useValue: "string1", multi: true},
|
1389 | * { provide: "Strings", useValue: "string2", multi: false}
|
1390 | * ])).toThrowError();
|
1391 | * ```
|
1392 | * @param {?} provider1
|
1393 | * @param {?} provider2
|
1394 | * @return {?}
|
1395 | */
|
1396 | function mixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
|
1397 | return Error(`Cannot mix multi providers and regular providers, got: ${provider1} ${provider2}`);
|
1398 | }
|
1399 |
|
1400 | /**
|
1401 | * @license
|
1402 | * Copyright Google Inc. All Rights Reserved.
|
1403 | *
|
1404 | * Use of this source code is governed by an MIT-style license that can be
|
1405 | * found in the LICENSE file at https://angular.io/license
|
1406 | */
|
1407 | /**
|
1408 | * A unique object used for retrieving items from the {\@link ReflectiveInjector}.
|
1409 | *
|
1410 | * Keys have:
|
1411 | * - a system-wide unique `id`.
|
1412 | * - a `token`.
|
1413 | *
|
1414 | * `Key` is used internally by {\@link ReflectiveInjector} because its system-wide unique `id` allows
|
1415 | * the
|
1416 | * injector to store created objects in a more efficient way.
|
1417 | *
|
1418 | * `Key` should not be created directly. {\@link ReflectiveInjector} creates keys automatically when
|
1419 | * resolving
|
1420 | * providers.
|
1421 | * \@experimental
|
1422 | */
|
1423 | class ReflectiveKey {
|
1424 | /**
|
1425 | * Private
|
1426 | * @param {?} token
|
1427 | * @param {?} id
|
1428 | */
|
1429 | constructor(token, id) {
|
1430 | this.token = token;
|
1431 | this.id = id;
|
1432 | if (!token) {
|
1433 | throw new Error('Token must be defined!');
|
1434 | }
|
1435 | }
|
1436 | /**
|
1437 | * Returns a stringified token.
|
1438 | * @return {?}
|
1439 | */
|
1440 | get displayName() { return stringify(this.token); }
|
1441 | /**
|
1442 | * Retrieves a `Key` for a token.
|
1443 | * @param {?} token
|
1444 | * @return {?}
|
1445 | */
|
1446 | static get(token) {
|
1447 | return _globalKeyRegistry.get(resolveForwardRef(token));
|
1448 | }
|
1449 | /**
|
1450 | * @return {?} the number of keys registered in the system.
|
1451 | */
|
1452 | static get numberOfKeys() { return _globalKeyRegistry.numberOfKeys; }
|
1453 | }
|
1454 | /**
|
1455 | * \@internal
|
1456 | */
|
1457 | class KeyRegistry {
|
1458 | constructor() {
|
1459 | this._allKeys = new Map();
|
1460 | }
|
1461 | /**
|
1462 | * @param {?} token
|
1463 | * @return {?}
|
1464 | */
|
1465 | get(token) {
|
1466 | if (token instanceof ReflectiveKey)
|
1467 | return token;
|
1468 | if (this._allKeys.has(token)) {
|
1469 | return ((this._allKeys.get(token)));
|
1470 | }
|
1471 | const /** @type {?} */ newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
|
1472 | this._allKeys.set(token, newKey);
|
1473 | return newKey;
|
1474 | }
|
1475 | /**
|
1476 | * @return {?}
|
1477 | */
|
1478 | get numberOfKeys() { return this._allKeys.size; }
|
1479 | }
|
1480 | const _globalKeyRegistry = new KeyRegistry();
|
1481 |
|
1482 | /**
|
1483 | * \@whatItDoes Represents a type that a Component or other object is instances of.
|
1484 | *
|
1485 | * \@description
|
1486 | *
|
1487 | * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
|
1488 | * the `MyCustomComponent` constructor function.
|
1489 | *
|
1490 | * \@stable
|
1491 | */
|
1492 | const Type = Function;
|
1493 | /**
|
1494 | * @param {?} v
|
1495 | * @return {?}
|
1496 | */
|
1497 | function isType(v) {
|
1498 | return typeof v === 'function';
|
1499 | }
|
1500 |
|
1501 | /**
|
1502 | * @license
|
1503 | * Copyright Google Inc. All Rights Reserved.
|
1504 | *
|
1505 | * Use of this source code is governed by an MIT-style license that can be
|
1506 | * found in the LICENSE file at https://angular.io/license
|
1507 | */
|
1508 | /**
|
1509 | * Attention: This regex has to hold even if the code is minified!
|
1510 | */
|
1511 | const DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/;
|
1512 | class ReflectionCapabilities {
|
1513 | /**
|
1514 | * @param {?=} reflect
|
1515 | */
|
1516 | constructor(reflect) { this._reflect = reflect || _global['Reflect']; }
|
1517 | /**
|
1518 | * @return {?}
|
1519 | */
|
1520 | isReflectionEnabled() { return true; }
|
1521 | /**
|
1522 | * @template T
|
1523 | * @param {?} t
|
1524 | * @return {?}
|
1525 | */
|
1526 | factory(t) { return (...args) => new t(...args); }
|
1527 | /**
|
1528 | * \@internal
|
1529 | * @param {?} paramTypes
|
1530 | * @param {?} paramAnnotations
|
1531 | * @return {?}
|
1532 | */
|
1533 | _zipTypesAndAnnotations(paramTypes, paramAnnotations) {
|
1534 | let /** @type {?} */ result;
|
1535 | if (typeof paramTypes === 'undefined') {
|
1536 | result = new Array(paramAnnotations.length);
|
1537 | }
|
1538 | else {
|
1539 | result = new Array(paramTypes.length);
|
1540 | }
|
1541 | for (let /** @type {?} */ i = 0; i < result.length; i++) {
|
1542 | // TS outputs Object for parameters without types, while Traceur omits
|
1543 | // the annotations. For now we preserve the Traceur behavior to aid
|
1544 | // migration, but this can be revisited.
|
1545 | if (typeof paramTypes === 'undefined') {
|
1546 | result[i] = [];
|
1547 | }
|
1548 | else if (paramTypes[i] != Object) {
|
1549 | result[i] = [paramTypes[i]];
|
1550 | }
|
1551 | else {
|
1552 | result[i] = [];
|
1553 | }
|
1554 | if (paramAnnotations && paramAnnotations[i] != null) {
|
1555 | result[i] = result[i].concat(paramAnnotations[i]);
|
1556 | }
|
1557 | }
|
1558 | return result;
|
1559 | }
|
1560 | /**
|
1561 | * @param {?} type
|
1562 | * @param {?} parentCtor
|
1563 | * @return {?}
|
1564 | */
|
1565 | _ownParameters(type, parentCtor) {
|
1566 | // If we have no decorators, we only have function.length as metadata.
|
1567 | // In that case, to detect whether a child class declared an own constructor or not,
|
1568 | // we need to look inside of that constructor to check whether it is
|
1569 | // just calling the parent.
|
1570 | // This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439
|
1571 | // that sets 'design:paramtypes' to []
|
1572 | // if a class inherits from another class but has no ctor declared itself.
|
1573 | if (DELEGATE_CTOR.exec(type.toString())) {
|
1574 | return null;
|
1575 | }
|
1576 | // Prefer the direct API.
|
1577 | if (((type)).parameters && ((type)).parameters !== parentCtor.parameters) {
|
1578 | return ((type)).parameters;
|
1579 | }
|
1580 | // API of tsickle for lowering decorators to properties on the class.
|
1581 | const /** @type {?} */ tsickleCtorParams = ((type)).ctorParameters;
|
1582 | if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) {
|
1583 | // Newer tsickle uses a function closure
|
1584 | // Retain the non-function case for compatibility with older tsickle
|
1585 | const /** @type {?} */ ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;
|
1586 | const /** @type {?} */ paramTypes = ctorParameters.map((ctorParam) => ctorParam && ctorParam.type);
|
1587 | const /** @type {?} */ paramAnnotations = ctorParameters.map((ctorParam) => ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators));
|
1588 | return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
|
1589 | }
|
1590 | // API for metadata created by invoking the decorators.
|
1591 | if (this._reflect != null && this._reflect.getOwnMetadata != null) {
|
1592 | const /** @type {?} */ paramAnnotations = this._reflect.getOwnMetadata('parameters', type);
|
1593 | const /** @type {?} */ paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type);
|
1594 | if (paramTypes || paramAnnotations) {
|
1595 | return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
|
1596 | }
|
1597 | }
|
1598 | // If a class has no decorators, at least create metadata
|
1599 | // based on function.length.
|
1600 | // Note: We know that this is a real constructor as we checked
|
1601 | // the content of the constructor above.
|
1602 | return new Array(((type.length))).fill(undefined);
|
1603 | }
|
1604 | /**
|
1605 | * @param {?} type
|
1606 | * @return {?}
|
1607 | */
|
1608 | parameters(type) {
|
1609 | // Note: only report metadata if we have at least one class decorator
|
1610 | // to stay in sync with the static reflector.
|
1611 | if (!isType(type)) {
|
1612 | return [];
|
1613 | }
|
1614 | const /** @type {?} */ parentCtor = getParentCtor(type);
|
1615 | let /** @type {?} */ parameters = this._ownParameters(type, parentCtor);
|
1616 | if (!parameters && parentCtor !== Object) {
|
1617 | parameters = this.parameters(parentCtor);
|
1618 | }
|
1619 | return parameters || [];
|
1620 | }
|
1621 | /**
|
1622 | * @param {?} typeOrFunc
|
1623 | * @param {?} parentCtor
|
1624 | * @return {?}
|
1625 | */
|
1626 | _ownAnnotations(typeOrFunc, parentCtor) {
|
1627 | // Prefer the direct API.
|
1628 | if (((typeOrFunc)).annotations && ((typeOrFunc)).annotations !== parentCtor.annotations) {
|
1629 | let /** @type {?} */ annotations = ((typeOrFunc)).annotations;
|
1630 | if (typeof annotations === 'function' && annotations.annotations) {
|
1631 | annotations = annotations.annotations;
|
1632 | }
|
1633 | return annotations;
|
1634 | }
|
1635 | // API of tsickle for lowering decorators to properties on the class.
|
1636 | if (((typeOrFunc)).decorators && ((typeOrFunc)).decorators !== parentCtor.decorators) {
|
1637 | return convertTsickleDecoratorIntoMetadata(((typeOrFunc)).decorators);
|
1638 | }
|
1639 | // API for metadata created by invoking the decorators.
|
1640 | if (this._reflect && this._reflect.getOwnMetadata) {
|
1641 | return this._reflect.getOwnMetadata('annotations', typeOrFunc);
|
1642 | }
|
1643 | return null;
|
1644 | }
|
1645 | /**
|
1646 | * @param {?} typeOrFunc
|
1647 | * @return {?}
|
1648 | */
|
1649 | annotations(typeOrFunc) {
|
1650 | if (!isType(typeOrFunc)) {
|
1651 | return [];
|
1652 | }
|
1653 | const /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
|
1654 | const /** @type {?} */ ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];
|
1655 | const /** @type {?} */ parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];
|
1656 | return parentAnnotations.concat(ownAnnotations);
|
1657 | }
|
1658 | /**
|
1659 | * @param {?} typeOrFunc
|
1660 | * @param {?} parentCtor
|
1661 | * @return {?}
|
1662 | */
|
1663 | _ownPropMetadata(typeOrFunc, parentCtor) {
|
1664 | // Prefer the direct API.
|
1665 | if (((typeOrFunc)).propMetadata &&
|
1666 | ((typeOrFunc)).propMetadata !== parentCtor.propMetadata) {
|
1667 | let /** @type {?} */ propMetadata = ((typeOrFunc)).propMetadata;
|
1668 | if (typeof propMetadata === 'function' && propMetadata.propMetadata) {
|
1669 | propMetadata = propMetadata.propMetadata;
|
1670 | }
|
1671 | return propMetadata;
|
1672 | }
|
1673 | // API of tsickle for lowering decorators to properties on the class.
|
1674 | if (((typeOrFunc)).propDecorators &&
|
1675 | ((typeOrFunc)).propDecorators !== parentCtor.propDecorators) {
|
1676 | const /** @type {?} */ propDecorators = ((typeOrFunc)).propDecorators;
|
1677 | const /** @type {?} */ propMetadata = ({});
|
1678 | Object.keys(propDecorators).forEach(prop => {
|
1679 | propMetadata[prop] = convertTsickleDecoratorIntoMetadata(propDecorators[prop]);
|
1680 | });
|
1681 | return propMetadata;
|
1682 | }
|
1683 | // API for metadata created by invoking the decorators.
|
1684 | if (this._reflect && this._reflect.getOwnMetadata) {
|
1685 | return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);
|
1686 | }
|
1687 | return null;
|
1688 | }
|
1689 | /**
|
1690 | * @param {?} typeOrFunc
|
1691 | * @return {?}
|
1692 | */
|
1693 | propMetadata(typeOrFunc) {
|
1694 | if (!isType(typeOrFunc)) {
|
1695 | return {};
|
1696 | }
|
1697 | const /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
|
1698 | const /** @type {?} */ propMetadata = {};
|
1699 | if (parentCtor !== Object) {
|
1700 | const /** @type {?} */ parentPropMetadata = this.propMetadata(parentCtor);
|
1701 | Object.keys(parentPropMetadata).forEach((propName) => {
|
1702 | propMetadata[propName] = parentPropMetadata[propName];
|
1703 | });
|
1704 | }
|
1705 | const /** @type {?} */ ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
|
1706 | if (ownPropMetadata) {
|
1707 | Object.keys(ownPropMetadata).forEach((propName) => {
|
1708 | const /** @type {?} */ decorators = [];
|
1709 | if (propMetadata.hasOwnProperty(propName)) {
|
1710 | decorators.push(...propMetadata[propName]);
|
1711 | }
|
1712 | decorators.push(...ownPropMetadata[propName]);
|
1713 | propMetadata[propName] = decorators;
|
1714 | });
|
1715 | }
|
1716 | return propMetadata;
|
1717 | }
|
1718 | /**
|
1719 | * @param {?} type
|
1720 | * @param {?} lcProperty
|
1721 | * @return {?}
|
1722 | */
|
1723 | hasLifecycleHook(type, lcProperty) {
|
1724 | return type instanceof Type && lcProperty in type.prototype;
|
1725 | }
|
1726 | /**
|
1727 | * @param {?} name
|
1728 | * @return {?}
|
1729 | */
|
1730 | getter(name) { return (new Function('o', 'return o.' + name + ';')); }
|
1731 | /**
|
1732 | * @param {?} name
|
1733 | * @return {?}
|
1734 | */
|
1735 | setter(name) {
|
1736 | return (new Function('o', 'v', 'return o.' + name + ' = v;'));
|
1737 | }
|
1738 | /**
|
1739 | * @param {?} name
|
1740 | * @return {?}
|
1741 | */
|
1742 | method(name) {
|
1743 | const /** @type {?} */ functionBody = `if (!o.${name}) throw new Error('"${name}" is undefined');
|
1744 | return o.${name}.apply(o, args);`;
|
1745 | return (new Function('o', 'args', functionBody));
|
1746 | }
|
1747 | /**
|
1748 | * @param {?} type
|
1749 | * @return {?}
|
1750 | */
|
1751 | importUri(type) {
|
1752 | // StaticSymbol
|
1753 | if (typeof type === 'object' && type['filePath']) {
|
1754 | return type['filePath'];
|
1755 | }
|
1756 | // Runtime type
|
1757 | return `./${stringify(type)}`;
|
1758 | }
|
1759 | /**
|
1760 | * @param {?} type
|
1761 | * @return {?}
|
1762 | */
|
1763 | resourceUri(type) { return `./${stringify(type)}`; }
|
1764 | /**
|
1765 | * @param {?} name
|
1766 | * @param {?} moduleUrl
|
1767 | * @param {?} members
|
1768 | * @param {?} runtime
|
1769 | * @return {?}
|
1770 | */
|
1771 | resolveIdentifier(name, moduleUrl, members, runtime) {
|
1772 | return runtime;
|
1773 | }
|
1774 | /**
|
1775 | * @param {?} enumIdentifier
|
1776 | * @param {?} name
|
1777 | * @return {?}
|
1778 | */
|
1779 | resolveEnum(enumIdentifier, name) { return enumIdentifier[name]; }
|
1780 | }
|
1781 | /**
|
1782 | * @param {?} decoratorInvocations
|
1783 | * @return {?}
|
1784 | */
|
1785 | function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
|
1786 | if (!decoratorInvocations) {
|
1787 | return [];
|
1788 | }
|
1789 | return decoratorInvocations.map(decoratorInvocation => {
|
1790 | const /** @type {?} */ decoratorType = decoratorInvocation.type;
|
1791 | const /** @type {?} */ annotationCls = decoratorType.annotationCls;
|
1792 | const /** @type {?} */ annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
|
1793 | return new annotationCls(...annotationArgs);
|
1794 | });
|
1795 | }
|
1796 | /**
|
1797 | * @param {?} ctor
|
1798 | * @return {?}
|
1799 | */
|
1800 | function getParentCtor(ctor) {
|
1801 | const /** @type {?} */ parentProto = Object.getPrototypeOf(ctor.prototype);
|
1802 | const /** @type {?} */ parentCtor = parentProto ? parentProto.constructor : null;
|
1803 | // Note: We always use `Object` as the null value
|
1804 | // to simplify checking later on.
|
1805 | return parentCtor || Object;
|
1806 | }
|
1807 |
|
1808 | /**
|
1809 | * Provides read-only access to reflection data about symbols. Used internally by Angular
|
1810 | * to power dependency injection and compilation.
|
1811 | * @abstract
|
1812 | */
|
1813 | class ReflectorReader {
|
1814 | /**
|
1815 | * @abstract
|
1816 | * @param {?} typeOrFunc
|
1817 | * @return {?}
|
1818 | */
|
1819 | parameters(typeOrFunc) { }
|
1820 | /**
|
1821 | * @abstract
|
1822 | * @param {?} typeOrFunc
|
1823 | * @return {?}
|
1824 | */
|
1825 | annotations(typeOrFunc) { }
|
1826 | /**
|
1827 | * @abstract
|
1828 | * @param {?} typeOrFunc
|
1829 | * @return {?}
|
1830 | */
|
1831 | propMetadata(typeOrFunc) { }
|
1832 | /**
|
1833 | * @abstract
|
1834 | * @param {?} typeOrFunc
|
1835 | * @return {?}
|
1836 | */
|
1837 | importUri(typeOrFunc) { }
|
1838 | /**
|
1839 | * @abstract
|
1840 | * @param {?} typeOrFunc
|
1841 | * @return {?}
|
1842 | */
|
1843 | resourceUri(typeOrFunc) { }
|
1844 | /**
|
1845 | * @abstract
|
1846 | * @param {?} name
|
1847 | * @param {?} moduleUrl
|
1848 | * @param {?} members
|
1849 | * @param {?} runtime
|
1850 | * @return {?}
|
1851 | */
|
1852 | resolveIdentifier(name, moduleUrl, members, runtime) { }
|
1853 | /**
|
1854 | * @abstract
|
1855 | * @param {?} identifier
|
1856 | * @param {?} name
|
1857 | * @return {?}
|
1858 | */
|
1859 | resolveEnum(identifier, name) { }
|
1860 | }
|
1861 |
|
1862 | /**
|
1863 | * @license
|
1864 | * Copyright Google Inc. All Rights Reserved.
|
1865 | *
|
1866 | * Use of this source code is governed by an MIT-style license that can be
|
1867 | * found in the LICENSE file at https://angular.io/license
|
1868 | */
|
1869 | /**
|
1870 | * Provides access to reflection data about symbols. Used internally by Angular
|
1871 | * to power dependency injection and compilation.
|
1872 | */
|
1873 | class Reflector extends ReflectorReader {
|
1874 | /**
|
1875 | * @param {?} reflectionCapabilities
|
1876 | */
|
1877 | constructor(reflectionCapabilities) {
|
1878 | super();
|
1879 | this.reflectionCapabilities = reflectionCapabilities;
|
1880 | }
|
1881 | /**
|
1882 | * @param {?} caps
|
1883 | * @return {?}
|
1884 | */
|
1885 | updateCapabilities(caps) { this.reflectionCapabilities = caps; }
|
1886 | /**
|
1887 | * @param {?} type
|
1888 | * @return {?}
|
1889 | */
|
1890 | factory(type) { return this.reflectionCapabilities.factory(type); }
|
1891 | /**
|
1892 | * @param {?} typeOrFunc
|
1893 | * @return {?}
|
1894 | */
|
1895 | parameters(typeOrFunc) {
|
1896 | return this.reflectionCapabilities.parameters(typeOrFunc);
|
1897 | }
|
1898 | /**
|
1899 | * @param {?} typeOrFunc
|
1900 | * @return {?}
|
1901 | */
|
1902 | annotations(typeOrFunc) {
|
1903 | return this.reflectionCapabilities.annotations(typeOrFunc);
|
1904 | }
|
1905 | /**
|
1906 | * @param {?} typeOrFunc
|
1907 | * @return {?}
|
1908 | */
|
1909 | propMetadata(typeOrFunc) {
|
1910 | return this.reflectionCapabilities.propMetadata(typeOrFunc);
|
1911 | }
|
1912 | /**
|
1913 | * @param {?} type
|
1914 | * @param {?} lcProperty
|
1915 | * @return {?}
|
1916 | */
|
1917 | hasLifecycleHook(type, lcProperty) {
|
1918 | return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
|
1919 | }
|
1920 | /**
|
1921 | * @param {?} name
|
1922 | * @return {?}
|
1923 | */
|
1924 | getter(name) { return this.reflectionCapabilities.getter(name); }
|
1925 | /**
|
1926 | * @param {?} name
|
1927 | * @return {?}
|
1928 | */
|
1929 | setter(name) { return this.reflectionCapabilities.setter(name); }
|
1930 | /**
|
1931 | * @param {?} name
|
1932 | * @return {?}
|
1933 | */
|
1934 | method(name) { return this.reflectionCapabilities.method(name); }
|
1935 | /**
|
1936 | * @param {?} type
|
1937 | * @return {?}
|
1938 | */
|
1939 | importUri(type) { return this.reflectionCapabilities.importUri(type); }
|
1940 | /**
|
1941 | * @param {?} type
|
1942 | * @return {?}
|
1943 | */
|
1944 | resourceUri(type) { return this.reflectionCapabilities.resourceUri(type); }
|
1945 | /**
|
1946 | * @param {?} name
|
1947 | * @param {?} moduleUrl
|
1948 | * @param {?} members
|
1949 | * @param {?} runtime
|
1950 | * @return {?}
|
1951 | */
|
1952 | resolveIdentifier(name, moduleUrl, members, runtime) {
|
1953 | return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
|
1954 | }
|
1955 | /**
|
1956 | * @param {?} identifier
|
1957 | * @param {?} name
|
1958 | * @return {?}
|
1959 | */
|
1960 | resolveEnum(identifier, name) {
|
1961 | return this.reflectionCapabilities.resolveEnum(identifier, name);
|
1962 | }
|
1963 | }
|
1964 |
|
1965 | /**
|
1966 | * @license
|
1967 | * Copyright Google Inc. All Rights Reserved.
|
1968 | *
|
1969 | * Use of this source code is governed by an MIT-style license that can be
|
1970 | * found in the LICENSE file at https://angular.io/license
|
1971 | */
|
1972 | /**
|
1973 | * The {@link Reflector} used internally in Angular to access metadata
|
1974 | * about symbols.
|
1975 | */
|
1976 | const reflector = new Reflector(new ReflectionCapabilities());
|
1977 |
|
1978 | /**
|
1979 | * @license
|
1980 | * Copyright Google Inc. All Rights Reserved.
|
1981 | *
|
1982 | * Use of this source code is governed by an MIT-style license that can be
|
1983 | * found in the LICENSE file at https://angular.io/license
|
1984 | */
|
1985 | /**
|
1986 | * `Dependency` is used by the framework to extend DI.
|
1987 | * This is internal to Angular and should not be used directly.
|
1988 | */
|
1989 | class ReflectiveDependency {
|
1990 | /**
|
1991 | * @param {?} key
|
1992 | * @param {?} optional
|
1993 | * @param {?} visibility
|
1994 | */
|
1995 | constructor(key, optional, visibility) {
|
1996 | this.key = key;
|
1997 | this.optional = optional;
|
1998 | this.visibility = visibility;
|
1999 | }
|
2000 | /**
|
2001 | * @param {?} key
|
2002 | * @return {?}
|
2003 | */
|
2004 | static fromKey(key) {
|
2005 | return new ReflectiveDependency(key, false, null);
|
2006 | }
|
2007 | }
|
2008 | const _EMPTY_LIST = [];
|
2009 | class ResolvedReflectiveProvider_ {
|
2010 | /**
|
2011 | * @param {?} key
|
2012 | * @param {?} resolvedFactories
|
2013 | * @param {?} multiProvider
|
2014 | */
|
2015 | constructor(key, resolvedFactories, multiProvider) {
|
2016 | this.key = key;
|
2017 | this.resolvedFactories = resolvedFactories;
|
2018 | this.multiProvider = multiProvider;
|
2019 | }
|
2020 | /**
|
2021 | * @return {?}
|
2022 | */
|
2023 | get resolvedFactory() { return this.resolvedFactories[0]; }
|
2024 | }
|
2025 | /**
|
2026 | * An internal resolved representation of a factory function created by resolving {\@link
|
2027 | * Provider}.
|
2028 | * \@experimental
|
2029 | */
|
2030 | class ResolvedReflectiveFactory {
|
2031 | /**
|
2032 | * @param {?} factory
|
2033 | * @param {?} dependencies
|
2034 | */
|
2035 | constructor(factory, dependencies) {
|
2036 | this.factory = factory;
|
2037 | this.dependencies = dependencies;
|
2038 | }
|
2039 | }
|
2040 | /**
|
2041 | * Resolve a single provider.
|
2042 | * @param {?} provider
|
2043 | * @return {?}
|
2044 | */
|
2045 | function resolveReflectiveFactory(provider) {
|
2046 | let /** @type {?} */ factoryFn;
|
2047 | let /** @type {?} */ resolvedDeps;
|
2048 | if (provider.useClass) {
|
2049 | const /** @type {?} */ useClass = resolveForwardRef(provider.useClass);
|
2050 | factoryFn = reflector.factory(useClass);
|
2051 | resolvedDeps = _dependenciesFor(useClass);
|
2052 | }
|
2053 | else if (provider.useExisting) {
|
2054 | factoryFn = (aliasInstance) => aliasInstance;
|
2055 | resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
|
2056 | }
|
2057 | else if (provider.useFactory) {
|
2058 | factoryFn = provider.useFactory;
|
2059 | resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
|
2060 | }
|
2061 | else {
|
2062 | factoryFn = () => provider.useValue;
|
2063 | resolvedDeps = _EMPTY_LIST;
|
2064 | }
|
2065 | return new ResolvedReflectiveFactory(factoryFn, resolvedDeps);
|
2066 | }
|
2067 | /**
|
2068 | * Converts the {\@link Provider} into {\@link ResolvedProvider}.
|
2069 | *
|
2070 | * {\@link Injector} internally only uses {\@link ResolvedProvider}, {\@link Provider} contains
|
2071 | * convenience provider syntax.
|
2072 | * @param {?} provider
|
2073 | * @return {?}
|
2074 | */
|
2075 | function resolveReflectiveProvider(provider) {
|
2076 | return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi || false);
|
2077 | }
|
2078 | /**
|
2079 | * Resolve a list of Providers.
|
2080 | * @param {?} providers
|
2081 | * @return {?}
|
2082 | */
|
2083 | function resolveReflectiveProviders(providers) {
|
2084 | const /** @type {?} */ normalized = _normalizeProviders(providers, []);
|
2085 | const /** @type {?} */ resolved = normalized.map(resolveReflectiveProvider);
|
2086 | const /** @type {?} */ resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
|
2087 | return Array.from(resolvedProviderMap.values());
|
2088 | }
|
2089 | /**
|
2090 | * Merges a list of ResolvedProviders into a list where
|
2091 | * each key is contained exactly once and multi providers
|
2092 | * have been merged.
|
2093 | * @param {?} providers
|
2094 | * @param {?} normalizedProvidersMap
|
2095 | * @return {?}
|
2096 | */
|
2097 | function mergeResolvedReflectiveProviders(providers, normalizedProvidersMap) {
|
2098 | for (let /** @type {?} */ i = 0; i < providers.length; i++) {
|
2099 | const /** @type {?} */ provider = providers[i];
|
2100 | const /** @type {?} */ existing = normalizedProvidersMap.get(provider.key.id);
|
2101 | if (existing) {
|
2102 | if (provider.multiProvider !== existing.multiProvider) {
|
2103 | throw mixingMultiProvidersWithRegularProvidersError(existing, provider);
|
2104 | }
|
2105 | if (provider.multiProvider) {
|
2106 | for (let /** @type {?} */ j = 0; j < provider.resolvedFactories.length; j++) {
|
2107 | existing.resolvedFactories.push(provider.resolvedFactories[j]);
|
2108 | }
|
2109 | }
|
2110 | else {
|
2111 | normalizedProvidersMap.set(provider.key.id, provider);
|
2112 | }
|
2113 | }
|
2114 | else {
|
2115 | let /** @type {?} */ resolvedProvider;
|
2116 | if (provider.multiProvider) {
|
2117 | resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
|
2118 | }
|
2119 | else {
|
2120 | resolvedProvider = provider;
|
2121 | }
|
2122 | normalizedProvidersMap.set(provider.key.id, resolvedProvider);
|
2123 | }
|
2124 | }
|
2125 | return normalizedProvidersMap;
|
2126 | }
|
2127 | /**
|
2128 | * @param {?} providers
|
2129 | * @param {?} res
|
2130 | * @return {?}
|
2131 | */
|
2132 | function _normalizeProviders(providers, res) {
|
2133 | providers.forEach(b => {
|
2134 | if (b instanceof Type) {
|
2135 | res.push({ provide: b, useClass: b });
|
2136 | }
|
2137 | else if (b && typeof b == 'object' && ((b)).provide !== undefined) {
|
2138 | res.push(/** @type {?} */ (b));
|
2139 | }
|
2140 | else if (b instanceof Array) {
|
2141 | _normalizeProviders(b, res);
|
2142 | }
|
2143 | else {
|
2144 | throw invalidProviderError(b);
|
2145 | }
|
2146 | });
|
2147 | return res;
|
2148 | }
|
2149 | /**
|
2150 | * @param {?} typeOrFunc
|
2151 | * @param {?=} dependencies
|
2152 | * @return {?}
|
2153 | */
|
2154 | function constructDependencies(typeOrFunc, dependencies) {
|
2155 | if (!dependencies) {
|
2156 | return _dependenciesFor(typeOrFunc);
|
2157 | }
|
2158 | else {
|
2159 | const /** @type {?} */ params = dependencies.map(t => [t]);
|
2160 | return dependencies.map(t => _extractToken(typeOrFunc, t, params));
|
2161 | }
|
2162 | }
|
2163 | /**
|
2164 | * @param {?} typeOrFunc
|
2165 | * @return {?}
|
2166 | */
|
2167 | function _dependenciesFor(typeOrFunc) {
|
2168 | const /** @type {?} */ params = reflector.parameters(typeOrFunc);
|
2169 | if (!params)
|
2170 | return [];
|
2171 | if (params.some(p => p == null)) {
|
2172 | throw noAnnotationError(typeOrFunc, params);
|
2173 | }
|
2174 | return params.map(p => _extractToken(typeOrFunc, p, params));
|
2175 | }
|
2176 | /**
|
2177 | * @param {?} typeOrFunc
|
2178 | * @param {?} metadata
|
2179 | * @param {?} params
|
2180 | * @return {?}
|
2181 | */
|
2182 | function _extractToken(typeOrFunc, metadata, params) {
|
2183 | let /** @type {?} */ token = null;
|
2184 | let /** @type {?} */ optional = false;
|
2185 | if (!Array.isArray(metadata)) {
|
2186 | if (metadata instanceof Inject) {
|
2187 | return _createDependency(metadata['token'], optional, null);
|
2188 | }
|
2189 | else {
|
2190 | return _createDependency(metadata, optional, null);
|
2191 | }
|
2192 | }
|
2193 | let /** @type {?} */ visibility = null;
|
2194 | for (let /** @type {?} */ i = 0; i < metadata.length; ++i) {
|
2195 | const /** @type {?} */ paramMetadata = metadata[i];
|
2196 | if (paramMetadata instanceof Type) {
|
2197 | token = paramMetadata;
|
2198 | }
|
2199 | else if (paramMetadata instanceof Inject) {
|
2200 | token = paramMetadata['token'];
|
2201 | }
|
2202 | else if (paramMetadata instanceof Optional) {
|
2203 | optional = true;
|
2204 | }
|
2205 | else if (paramMetadata instanceof Self || paramMetadata instanceof SkipSelf) {
|
2206 | visibility = paramMetadata;
|
2207 | }
|
2208 | else if (paramMetadata instanceof InjectionToken) {
|
2209 | token = paramMetadata;
|
2210 | }
|
2211 | }
|
2212 | token = resolveForwardRef(token);
|
2213 | if (token != null) {
|
2214 | return _createDependency(token, optional, visibility);
|
2215 | }
|
2216 | else {
|
2217 | throw noAnnotationError(typeOrFunc, params);
|
2218 | }
|
2219 | }
|
2220 | /**
|
2221 | * @param {?} token
|
2222 | * @param {?} optional
|
2223 | * @param {?} visibility
|
2224 | * @return {?}
|
2225 | */
|
2226 | function _createDependency(token, optional, visibility) {
|
2227 | return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
|
2228 | }
|
2229 |
|
2230 | /**
|
2231 | * @license
|
2232 | * Copyright Google Inc. All Rights Reserved.
|
2233 | *
|
2234 | * Use of this source code is governed by an MIT-style license that can be
|
2235 | * found in the LICENSE file at https://angular.io/license
|
2236 | */
|
2237 | // Threshold for the dynamic version
|
2238 | const UNDEFINED = new Object();
|
2239 | /**
|
2240 | * A ReflectiveDependency injection container used for instantiating objects and resolving
|
2241 | * dependencies.
|
2242 | *
|
2243 | * An `Injector` is a replacement for a `new` operator, which can automatically resolve the
|
2244 | * constructor dependencies.
|
2245 | *
|
2246 | * In typical use, application code asks for the dependencies in the constructor and they are
|
2247 | * resolved by the `Injector`.
|
2248 | *
|
2249 | * ### Example ([live demo](http://plnkr.co/edit/jzjec0?p=preview))
|
2250 | *
|
2251 | * The following example creates an `Injector` configured to create `Engine` and `Car`.
|
2252 | *
|
2253 | * ```typescript
|
2254 | * \@Injectable()
|
2255 | * class Engine {
|
2256 | * }
|
2257 | *
|
2258 | * \@Injectable()
|
2259 | * class Car {
|
2260 | * constructor(public engine:Engine) {}
|
2261 | * }
|
2262 | *
|
2263 | * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
2264 | * var car = injector.get(Car);
|
2265 | * expect(car instanceof Car).toBe(true);
|
2266 | * expect(car.engine instanceof Engine).toBe(true);
|
2267 | * ```
|
2268 | *
|
2269 | * Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
|
2270 | * resolve all of the object's dependencies automatically.
|
2271 | *
|
2272 | * \@stable
|
2273 | * @abstract
|
2274 | */
|
2275 | class ReflectiveInjector {
|
2276 | /**
|
2277 | * Turns an array of provider definitions into an array of resolved providers.
|
2278 | *
|
2279 | * A resolution is a process of flattening multiple nested arrays and converting individual
|
2280 | * providers into an array of {\@link ResolvedReflectiveProvider}s.
|
2281 | *
|
2282 | * ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
|
2283 | *
|
2284 | * ```typescript
|
2285 | * \@Injectable()
|
2286 | * class Engine {
|
2287 | * }
|
2288 | *
|
2289 | * \@Injectable()
|
2290 | * class Car {
|
2291 | * constructor(public engine:Engine) {}
|
2292 | * }
|
2293 | *
|
2294 | * var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
|
2295 | *
|
2296 | * expect(providers.length).toEqual(2);
|
2297 | *
|
2298 | * expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
|
2299 | * expect(providers[0].key.displayName).toBe("Car");
|
2300 | * expect(providers[0].dependencies.length).toEqual(1);
|
2301 | * expect(providers[0].factory).toBeDefined();
|
2302 | *
|
2303 | * expect(providers[1].key.displayName).toBe("Engine");
|
2304 | * });
|
2305 | * ```
|
2306 | *
|
2307 | * See {\@link ReflectiveInjector#fromResolvedProviders} for more info.
|
2308 | * @param {?} providers
|
2309 | * @return {?}
|
2310 | */
|
2311 | static resolve(providers) {
|
2312 | return resolveReflectiveProviders(providers);
|
2313 | }
|
2314 | /**
|
2315 | * Resolves an array of providers and creates an injector from those providers.
|
2316 | *
|
2317 | * The passed-in providers can be an array of `Type`, {\@link Provider},
|
2318 | * or a recursive array of more providers.
|
2319 | *
|
2320 | * ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
|
2321 | *
|
2322 | * ```typescript
|
2323 | * \@Injectable()
|
2324 | * class Engine {
|
2325 | * }
|
2326 | *
|
2327 | * \@Injectable()
|
2328 | * class Car {
|
2329 | * constructor(public engine:Engine) {}
|
2330 | * }
|
2331 | *
|
2332 | * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
2333 | * expect(injector.get(Car) instanceof Car).toBe(true);
|
2334 | * ```
|
2335 | *
|
2336 | * This function is slower than the corresponding `fromResolvedProviders`
|
2337 | * because it needs to resolve the passed-in providers first.
|
2338 | * See {\@link Injector#resolve} and {\@link Injector#fromResolvedProviders}.
|
2339 | * @param {?} providers
|
2340 | * @param {?=} parent
|
2341 | * @return {?}
|
2342 | */
|
2343 | static resolveAndCreate(providers, parent) {
|
2344 | const /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
2345 | return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
|
2346 | }
|
2347 | /**
|
2348 | * Creates an injector from previously resolved providers.
|
2349 | *
|
2350 | * This API is the recommended way to construct injectors in performance-sensitive parts.
|
2351 | *
|
2352 | * ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
|
2353 | *
|
2354 | * ```typescript
|
2355 | * \@Injectable()
|
2356 | * class Engine {
|
2357 | * }
|
2358 | *
|
2359 | * \@Injectable()
|
2360 | * class Car {
|
2361 | * constructor(public engine:Engine) {}
|
2362 | * }
|
2363 | *
|
2364 | * var providers = ReflectiveInjector.resolve([Car, Engine]);
|
2365 | * var injector = ReflectiveInjector.fromResolvedProviders(providers);
|
2366 | * expect(injector.get(Car) instanceof Car).toBe(true);
|
2367 | * ```
|
2368 | * \@experimental
|
2369 | * @param {?} providers
|
2370 | * @param {?=} parent
|
2371 | * @return {?}
|
2372 | */
|
2373 | static fromResolvedProviders(providers, parent) {
|
2374 | return new ReflectiveInjector_(providers, parent);
|
2375 | }
|
2376 | /**
|
2377 | * Parent of this injector.
|
2378 | *
|
2379 | * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
|
2380 | * -->
|
2381 | *
|
2382 | * ### Example ([live demo](http://plnkr.co/edit/eosMGo?p=preview))
|
2383 | *
|
2384 | * ```typescript
|
2385 | * var parent = ReflectiveInjector.resolveAndCreate([]);
|
2386 | * var child = parent.resolveAndCreateChild([]);
|
2387 | * expect(child.parent).toBe(parent);
|
2388 | * ```
|
2389 | * @abstract
|
2390 | * @return {?}
|
2391 | */
|
2392 | parent() { }
|
2393 | /**
|
2394 | * Resolves an array of providers and creates a child injector from those providers.
|
2395 | *
|
2396 | * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
|
2397 | * -->
|
2398 | *
|
2399 | * The passed-in providers can be an array of `Type`, {\@link Provider},
|
2400 | * or a recursive array of more providers.
|
2401 | *
|
2402 | * ### Example ([live demo](http://plnkr.co/edit/opB3T4?p=preview))
|
2403 | *
|
2404 | * ```typescript
|
2405 | * class ParentProvider {}
|
2406 | * class ChildProvider {}
|
2407 | *
|
2408 | * var parent = ReflectiveInjector.resolveAndCreate([ParentProvider]);
|
2409 | * var child = parent.resolveAndCreateChild([ChildProvider]);
|
2410 | *
|
2411 | * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
|
2412 | * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
|
2413 | * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
|
2414 | * ```
|
2415 | *
|
2416 | * This function is slower than the corresponding `createChildFromResolved`
|
2417 | * because it needs to resolve the passed-in providers first.
|
2418 | * See {\@link Injector#resolve} and {\@link Injector#createChildFromResolved}.
|
2419 | * @abstract
|
2420 | * @param {?} providers
|
2421 | * @return {?}
|
2422 | */
|
2423 | resolveAndCreateChild(providers) { }
|
2424 | /**
|
2425 | * Creates a child injector from previously resolved providers.
|
2426 | *
|
2427 | * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
|
2428 | * -->
|
2429 | *
|
2430 | * This API is the recommended way to construct injectors in performance-sensitive parts.
|
2431 | *
|
2432 | * ### Example ([live demo](http://plnkr.co/edit/VhyfjN?p=preview))
|
2433 | *
|
2434 | * ```typescript
|
2435 | * class ParentProvider {}
|
2436 | * class ChildProvider {}
|
2437 | *
|
2438 | * var parentProviders = ReflectiveInjector.resolve([ParentProvider]);
|
2439 | * var childProviders = ReflectiveInjector.resolve([ChildProvider]);
|
2440 | *
|
2441 | * var parent = ReflectiveInjector.fromResolvedProviders(parentProviders);
|
2442 | * var child = parent.createChildFromResolved(childProviders);
|
2443 | *
|
2444 | * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
|
2445 | * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
|
2446 | * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
|
2447 | * ```
|
2448 | * @abstract
|
2449 | * @param {?} providers
|
2450 | * @return {?}
|
2451 | */
|
2452 | createChildFromResolved(providers) { }
|
2453 | /**
|
2454 | * Resolves a provider and instantiates an object in the context of the injector.
|
2455 | *
|
2456 | * The created object does not get cached by the injector.
|
2457 | *
|
2458 | * ### Example ([live demo](http://plnkr.co/edit/yvVXoB?p=preview))
|
2459 | *
|
2460 | * ```typescript
|
2461 | * \@Injectable()
|
2462 | * class Engine {
|
2463 | * }
|
2464 | *
|
2465 | * \@Injectable()
|
2466 | * class Car {
|
2467 | * constructor(public engine:Engine) {}
|
2468 | * }
|
2469 | *
|
2470 | * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
|
2471 | *
|
2472 | * var car = injector.resolveAndInstantiate(Car);
|
2473 | * expect(car.engine).toBe(injector.get(Engine));
|
2474 | * expect(car).not.toBe(injector.resolveAndInstantiate(Car));
|
2475 | * ```
|
2476 | * @abstract
|
2477 | * @param {?} provider
|
2478 | * @return {?}
|
2479 | */
|
2480 | resolveAndInstantiate(provider) { }
|
2481 | /**
|
2482 | * Instantiates an object using a resolved provider in the context of the injector.
|
2483 | *
|
2484 | * The created object does not get cached by the injector.
|
2485 | *
|
2486 | * ### Example ([live demo](http://plnkr.co/edit/ptCImQ?p=preview))
|
2487 | *
|
2488 | * ```typescript
|
2489 | * \@Injectable()
|
2490 | * class Engine {
|
2491 | * }
|
2492 | *
|
2493 | * \@Injectable()
|
2494 | * class Car {
|
2495 | * constructor(public engine:Engine) {}
|
2496 | * }
|
2497 | *
|
2498 | * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
|
2499 | * var carProvider = ReflectiveInjector.resolve([Car])[0];
|
2500 | * var car = injector.instantiateResolved(carProvider);
|
2501 | * expect(car.engine).toBe(injector.get(Engine));
|
2502 | * expect(car).not.toBe(injector.instantiateResolved(carProvider));
|
2503 | * ```
|
2504 | * @abstract
|
2505 | * @param {?} provider
|
2506 | * @return {?}
|
2507 | */
|
2508 | instantiateResolved(provider) { }
|
2509 | /**
|
2510 | * @abstract
|
2511 | * @param {?} token
|
2512 | * @param {?=} notFoundValue
|
2513 | * @return {?}
|
2514 | */
|
2515 | get(token, notFoundValue) { }
|
2516 | }
|
2517 | class ReflectiveInjector_ {
|
2518 | /**
|
2519 | * Private
|
2520 | * @param {?} _providers
|
2521 | * @param {?=} _parent
|
2522 | */
|
2523 | constructor(_providers, _parent) {
|
2524 | /**
|
2525 | * \@internal
|
2526 | */
|
2527 | this._constructionCounter = 0;
|
2528 | this._providers = _providers;
|
2529 | this._parent = _parent || null;
|
2530 | const len = _providers.length;
|
2531 | this.keyIds = new Array(len);
|
2532 | this.objs = new Array(len);
|
2533 | for (let i = 0; i < len; i++) {
|
2534 | this.keyIds[i] = _providers[i].key.id;
|
2535 | this.objs[i] = UNDEFINED;
|
2536 | }
|
2537 | }
|
2538 | /**
|
2539 | * @param {?} token
|
2540 | * @param {?=} notFoundValue
|
2541 | * @return {?}
|
2542 | */
|
2543 | get(token, notFoundValue = THROW_IF_NOT_FOUND) {
|
2544 | return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
|
2545 | }
|
2546 | /**
|
2547 | * @return {?}
|
2548 | */
|
2549 | get parent() { return this._parent; }
|
2550 | /**
|
2551 | * @param {?} providers
|
2552 | * @return {?}
|
2553 | */
|
2554 | resolveAndCreateChild(providers) {
|
2555 | const /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
2556 | return this.createChildFromResolved(ResolvedReflectiveProviders);
|
2557 | }
|
2558 | /**
|
2559 | * @param {?} providers
|
2560 | * @return {?}
|
2561 | */
|
2562 | createChildFromResolved(providers) {
|
2563 | const /** @type {?} */ inj = new ReflectiveInjector_(providers);
|
2564 | inj._parent = this;
|
2565 | return inj;
|
2566 | }
|
2567 | /**
|
2568 | * @param {?} provider
|
2569 | * @return {?}
|
2570 | */
|
2571 | resolveAndInstantiate(provider) {
|
2572 | return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
|
2573 | }
|
2574 | /**
|
2575 | * @param {?} provider
|
2576 | * @return {?}
|
2577 | */
|
2578 | instantiateResolved(provider) {
|
2579 | return this._instantiateProvider(provider);
|
2580 | }
|
2581 | /**
|
2582 | * @param {?} index
|
2583 | * @return {?}
|
2584 | */
|
2585 | getProviderAtIndex(index) {
|
2586 | if (index < 0 || index >= this._providers.length) {
|
2587 | throw outOfBoundsError(index);
|
2588 | }
|
2589 | return this._providers[index];
|
2590 | }
|
2591 | /**
|
2592 | * \@internal
|
2593 | * @param {?} provider
|
2594 | * @return {?}
|
2595 | */
|
2596 | _new(provider) {
|
2597 | if (this._constructionCounter++ > this._getMaxNumberOfObjects()) {
|
2598 | throw cyclicDependencyError(this, provider.key);
|
2599 | }
|
2600 | return this._instantiateProvider(provider);
|
2601 | }
|
2602 | /**
|
2603 | * @return {?}
|
2604 | */
|
2605 | _getMaxNumberOfObjects() { return this.objs.length; }
|
2606 | /**
|
2607 | * @param {?} provider
|
2608 | * @return {?}
|
2609 | */
|
2610 | _instantiateProvider(provider) {
|
2611 | if (provider.multiProvider) {
|
2612 | const /** @type {?} */ res = new Array(provider.resolvedFactories.length);
|
2613 | for (let /** @type {?} */ i = 0; i < provider.resolvedFactories.length; ++i) {
|
2614 | res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
|
2615 | }
|
2616 | return res;
|
2617 | }
|
2618 | else {
|
2619 | return this._instantiate(provider, provider.resolvedFactories[0]);
|
2620 | }
|
2621 | }
|
2622 | /**
|
2623 | * @param {?} provider
|
2624 | * @param {?} ResolvedReflectiveFactory
|
2625 | * @return {?}
|
2626 | */
|
2627 | _instantiate(provider, ResolvedReflectiveFactory$$1) {
|
2628 | const /** @type {?} */ factory = ResolvedReflectiveFactory$$1.factory;
|
2629 | let /** @type {?} */ deps;
|
2630 | try {
|
2631 | deps =
|
2632 | ResolvedReflectiveFactory$$1.dependencies.map(dep => this._getByReflectiveDependency(dep));
|
2633 | }
|
2634 | catch (e) {
|
2635 | if (e.addKey) {
|
2636 | e.addKey(this, provider.key);
|
2637 | }
|
2638 | throw e;
|
2639 | }
|
2640 | let /** @type {?} */ obj;
|
2641 | try {
|
2642 | obj = factory(...deps);
|
2643 | }
|
2644 | catch (e) {
|
2645 | throw instantiationError(this, e, e.stack, provider.key);
|
2646 | }
|
2647 | return obj;
|
2648 | }
|
2649 | /**
|
2650 | * @param {?} dep
|
2651 | * @return {?}
|
2652 | */
|
2653 | _getByReflectiveDependency(dep) {
|
2654 | return this._getByKey(dep.key, dep.visibility, dep.optional ? null : THROW_IF_NOT_FOUND);
|
2655 | }
|
2656 | /**
|
2657 | * @param {?} key
|
2658 | * @param {?} visibility
|
2659 | * @param {?} notFoundValue
|
2660 | * @return {?}
|
2661 | */
|
2662 | _getByKey(key, visibility, notFoundValue) {
|
2663 | if (key === INJECTOR_KEY) {
|
2664 | return this;
|
2665 | }
|
2666 | if (visibility instanceof Self) {
|
2667 | return this._getByKeySelf(key, notFoundValue);
|
2668 | }
|
2669 | else {
|
2670 | return this._getByKeyDefault(key, notFoundValue, visibility);
|
2671 | }
|
2672 | }
|
2673 | /**
|
2674 | * @param {?} keyId
|
2675 | * @return {?}
|
2676 | */
|
2677 | _getObjByKeyId(keyId) {
|
2678 | for (let /** @type {?} */ i = 0; i < this.keyIds.length; i++) {
|
2679 | if (this.keyIds[i] === keyId) {
|
2680 | if (this.objs[i] === UNDEFINED) {
|
2681 | this.objs[i] = this._new(this._providers[i]);
|
2682 | }
|
2683 | return this.objs[i];
|
2684 | }
|
2685 | }
|
2686 | return UNDEFINED;
|
2687 | }
|
2688 | /**
|
2689 | * \@internal
|
2690 | * @param {?} key
|
2691 | * @param {?} notFoundValue
|
2692 | * @return {?}
|
2693 | */
|
2694 | _throwOrNull(key, notFoundValue) {
|
2695 | if (notFoundValue !== THROW_IF_NOT_FOUND) {
|
2696 | return notFoundValue;
|
2697 | }
|
2698 | else {
|
2699 | throw noProviderError(this, key);
|
2700 | }
|
2701 | }
|
2702 | /**
|
2703 | * \@internal
|
2704 | * @param {?} key
|
2705 | * @param {?} notFoundValue
|
2706 | * @return {?}
|
2707 | */
|
2708 | _getByKeySelf(key, notFoundValue) {
|
2709 | const /** @type {?} */ obj = this._getObjByKeyId(key.id);
|
2710 | return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, notFoundValue);
|
2711 | }
|
2712 | /**
|
2713 | * \@internal
|
2714 | * @param {?} key
|
2715 | * @param {?} notFoundValue
|
2716 | * @param {?} visibility
|
2717 | * @return {?}
|
2718 | */
|
2719 | _getByKeyDefault(key, notFoundValue, visibility) {
|
2720 | let /** @type {?} */ inj;
|
2721 | if (visibility instanceof SkipSelf) {
|
2722 | inj = this._parent;
|
2723 | }
|
2724 | else {
|
2725 | inj = this;
|
2726 | }
|
2727 | while (inj instanceof ReflectiveInjector_) {
|
2728 | const /** @type {?} */ inj_ = (inj);
|
2729 | const /** @type {?} */ obj = inj_._getObjByKeyId(key.id);
|
2730 | if (obj !== UNDEFINED)
|
2731 | return obj;
|
2732 | inj = inj_._parent;
|
2733 | }
|
2734 | if (inj !== null) {
|
2735 | return inj.get(key.token, notFoundValue);
|
2736 | }
|
2737 | else {
|
2738 | return this._throwOrNull(key, notFoundValue);
|
2739 | }
|
2740 | }
|
2741 | /**
|
2742 | * @return {?}
|
2743 | */
|
2744 | get displayName() {
|
2745 | const /** @type {?} */ providers = _mapProviders(this, (b) => ' "' + b.key.displayName + '" ')
|
2746 | .join(', ');
|
2747 | return `ReflectiveInjector(providers: [${providers}])`;
|
2748 | }
|
2749 | /**
|
2750 | * @return {?}
|
2751 | */
|
2752 | toString() { return this.displayName; }
|
2753 | }
|
2754 | const INJECTOR_KEY = ReflectiveKey.get(Injector);
|
2755 | /**
|
2756 | * @param {?} injector
|
2757 | * @param {?} fn
|
2758 | * @return {?}
|
2759 | */
|
2760 | function _mapProviders(injector, fn) {
|
2761 | const /** @type {?} */ res = new Array(injector._providers.length);
|
2762 | for (let /** @type {?} */ i = 0; i < injector._providers.length; ++i) {
|
2763 | res[i] = fn(injector.getProviderAtIndex(i));
|
2764 | }
|
2765 | return res;
|
2766 | }
|
2767 |
|
2768 | /**
|
2769 | * @license
|
2770 | * Copyright Google Inc. All Rights Reserved.
|
2771 | *
|
2772 | * Use of this source code is governed by an MIT-style license that can be
|
2773 | * found in the LICENSE file at https://angular.io/license
|
2774 | */
|
2775 | /**
|
2776 | * @module
|
2777 | * @description
|
2778 | * The `di` module provides dependency injection container services.
|
2779 | */
|
2780 |
|
2781 | /**
|
2782 | * @license
|
2783 | * Copyright Google Inc. All Rights Reserved.
|
2784 | *
|
2785 | * Use of this source code is governed by an MIT-style license that can be
|
2786 | * found in the LICENSE file at https://angular.io/license
|
2787 | */
|
2788 | /**
|
2789 | * Determine if the argument is shaped like a Promise
|
2790 | * @param {?} obj
|
2791 | * @return {?}
|
2792 | */
|
2793 | function isPromise(obj) {
|
2794 | // allow any Promise/A+ compliant thenable.
|
2795 | // It's up to the caller to ensure that obj.then conforms to the spec
|
2796 | return !!obj && typeof obj.then === 'function';
|
2797 | }
|
2798 | /**
|
2799 | * Determine if the argument is an Observable
|
2800 | * @param {?} obj
|
2801 | * @return {?}
|
2802 | */
|
2803 | function isObservable(obj) {
|
2804 | // TODO use Symbol.observable when https://github.com/ReactiveX/rxjs/issues/2415 will be resolved
|
2805 | return !!obj && typeof obj.subscribe === 'function';
|
2806 | }
|
2807 |
|
2808 | /**
|
2809 | * @license
|
2810 | * Copyright Google Inc. All Rights Reserved.
|
2811 | *
|
2812 | * Use of this source code is governed by an MIT-style license that can be
|
2813 | * found in the LICENSE file at https://angular.io/license
|
2814 | */
|
2815 | /**
|
2816 | * A function that will be executed when an application is initialized.
|
2817 | * \@experimental
|
2818 | */
|
2819 | const APP_INITIALIZER = new InjectionToken('Application Initializer');
|
2820 | /**
|
2821 | * A class that reflects the state of running {\@link APP_INITIALIZER}s.
|
2822 | *
|
2823 | * \@experimental
|
2824 | */
|
2825 | class ApplicationInitStatus {
|
2826 | /**
|
2827 | * @param {?} appInits
|
2828 | */
|
2829 | constructor(appInits) {
|
2830 | this._done = false;
|
2831 | const asyncInitPromises = [];
|
2832 | if (appInits) {
|
2833 | for (let i = 0; i < appInits.length; i++) {
|
2834 | const initResult = appInits[i]();
|
2835 | if (isPromise(initResult)) {
|
2836 | asyncInitPromises.push(initResult);
|
2837 | }
|
2838 | }
|
2839 | }
|
2840 | this._donePromise = Promise.all(asyncInitPromises).then(() => { this._done = true; });
|
2841 | if (asyncInitPromises.length === 0) {
|
2842 | this._done = true;
|
2843 | }
|
2844 | }
|
2845 | /**
|
2846 | * @return {?}
|
2847 | */
|
2848 | get done() { return this._done; }
|
2849 | /**
|
2850 | * @return {?}
|
2851 | */
|
2852 | get donePromise() { return this._donePromise; }
|
2853 | }
|
2854 | ApplicationInitStatus.decorators = [
|
2855 | { type: Injectable },
|
2856 | ];
|
2857 | /**
|
2858 | * @nocollapse
|
2859 | */
|
2860 | ApplicationInitStatus.ctorParameters = () => [
|
2861 | { type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER,] }, { type: Optional },] },
|
2862 | ];
|
2863 |
|
2864 | /**
|
2865 | * @license
|
2866 | * Copyright Google Inc. All Rights Reserved.
|
2867 | *
|
2868 | * Use of this source code is governed by an MIT-style license that can be
|
2869 | * found in the LICENSE file at https://angular.io/license
|
2870 | */
|
2871 | /**
|
2872 | * A DI Token representing a unique string id assigned to the application by Angular and used
|
2873 | * primarily for prefixing application attributes and CSS styles when
|
2874 | * {\@link ViewEncapsulation#Emulated} is being used.
|
2875 | *
|
2876 | * If you need to avoid randomly generated value to be used as an application id, you can provide
|
2877 | * a custom value via a DI provider <!-- TODO: provider --> configuring the root {\@link Injector}
|
2878 | * using this token.
|
2879 | * \@experimental
|
2880 | */
|
2881 | const APP_ID = new InjectionToken('AppId');
|
2882 | /**
|
2883 | * @return {?}
|
2884 | */
|
2885 | function _appIdRandomProviderFactory() {
|
2886 | return `${_randomChar()}${_randomChar()}${_randomChar()}`;
|
2887 | }
|
2888 | /**
|
2889 | * Providers that will generate a random APP_ID_TOKEN.
|
2890 | * \@experimental
|
2891 | */
|
2892 | const APP_ID_RANDOM_PROVIDER = {
|
2893 | provide: APP_ID,
|
2894 | useFactory: _appIdRandomProviderFactory,
|
2895 | deps: [],
|
2896 | };
|
2897 | /**
|
2898 | * @return {?}
|
2899 | */
|
2900 | function _randomChar() {
|
2901 | return String.fromCharCode(97 + Math.floor(Math.random() * 25));
|
2902 | }
|
2903 | /**
|
2904 | * A function that will be executed when a platform is initialized.
|
2905 | * \@experimental
|
2906 | */
|
2907 | const PLATFORM_INITIALIZER = new InjectionToken('Platform Initializer');
|
2908 | /**
|
2909 | * A token that indicates an opaque platform id.
|
2910 | * \@experimental
|
2911 | */
|
2912 | const PLATFORM_ID = new InjectionToken('Platform ID');
|
2913 | /**
|
2914 | * All callbacks provided via this token will be called for every component that is bootstrapped.
|
2915 | * Signature of the callback:
|
2916 | *
|
2917 | * `(componentRef: ComponentRef) => void`.
|
2918 | *
|
2919 | * \@experimental
|
2920 | */
|
2921 | const APP_BOOTSTRAP_LISTENER = new InjectionToken('appBootstrapListener');
|
2922 | /**
|
2923 | * A token which indicates the root directory of the application
|
2924 | * \@experimental
|
2925 | */
|
2926 | const PACKAGE_ROOT_URL = new InjectionToken('Application Packages Root URL');
|
2927 |
|
2928 | /**
|
2929 | * @license
|
2930 | * Copyright Google Inc. All Rights Reserved.
|
2931 | *
|
2932 | * Use of this source code is governed by an MIT-style license that can be
|
2933 | * found in the LICENSE file at https://angular.io/license
|
2934 | */
|
2935 | class Console {
|
2936 | /**
|
2937 | * @param {?} message
|
2938 | * @return {?}
|
2939 | */
|
2940 | log(message) {
|
2941 | // tslint:disable-next-line:no-console
|
2942 | console.log(message);
|
2943 | }
|
2944 | /**
|
2945 | * @param {?} message
|
2946 | * @return {?}
|
2947 | */
|
2948 | warn(message) {
|
2949 | // tslint:disable-next-line:no-console
|
2950 | console.warn(message);
|
2951 | }
|
2952 | }
|
2953 | Console.decorators = [
|
2954 | { type: Injectable },
|
2955 | ];
|
2956 | /**
|
2957 | * @nocollapse
|
2958 | */
|
2959 | Console.ctorParameters = () => [];
|
2960 |
|
2961 | /**
|
2962 | * @license
|
2963 | * Copyright Google Inc. All Rights Reserved.
|
2964 | *
|
2965 | * Use of this source code is governed by an MIT-style license that can be
|
2966 | * found in the LICENSE file at https://angular.io/license
|
2967 | */
|
2968 | /**
|
2969 | * Combination of NgModuleFactory and ComponentFactorys.
|
2970 | *
|
2971 | * \@experimental
|
2972 | */
|
2973 | class ModuleWithComponentFactories {
|
2974 | /**
|
2975 | * @param {?} ngModuleFactory
|
2976 | * @param {?} componentFactories
|
2977 | */
|
2978 | constructor(ngModuleFactory, componentFactories) {
|
2979 | this.ngModuleFactory = ngModuleFactory;
|
2980 | this.componentFactories = componentFactories;
|
2981 | }
|
2982 | }
|
2983 | /**
|
2984 | * @return {?}
|
2985 | */
|
2986 | function _throwError() {
|
2987 | throw new Error(`Runtime compiler is not loaded`);
|
2988 | }
|
2989 | /**
|
2990 | * Low-level service for running the angular compiler during runtime
|
2991 | * to create {\@link ComponentFactory}s, which
|
2992 | * can later be used to create and render a Component instance.
|
2993 | *
|
2994 | * Each `\@NgModule` provides an own `Compiler` to its injector,
|
2995 | * that will use the directives/pipes of the ng module for compilation
|
2996 | * of components.
|
2997 | * \@stable
|
2998 | */
|
2999 | class Compiler {
|
3000 | /**
|
3001 | * Compiles the given NgModule and all of its components. All templates of the components listed
|
3002 | * in `entryComponents` have to be inlined.
|
3003 | * @template T
|
3004 | * @param {?} moduleType
|
3005 | * @return {?}
|
3006 | */
|
3007 | compileModuleSync(moduleType) { throw _throwError(); }
|
3008 | /**
|
3009 | * Compiles the given NgModule and all of its components
|
3010 | * @template T
|
3011 | * @param {?} moduleType
|
3012 | * @return {?}
|
3013 | */
|
3014 | compileModuleAsync(moduleType) { throw _throwError(); }
|
3015 | /**
|
3016 | * Same as {\@link #compileModuleSync} but also creates ComponentFactories for all components.
|
3017 | * @template T
|
3018 | * @param {?} moduleType
|
3019 | * @return {?}
|
3020 | */
|
3021 | compileModuleAndAllComponentsSync(moduleType) {
|
3022 | throw _throwError();
|
3023 | }
|
3024 | /**
|
3025 | * Same as {\@link #compileModuleAsync} but also creates ComponentFactories for all components.
|
3026 | * @template T
|
3027 | * @param {?} moduleType
|
3028 | * @return {?}
|
3029 | */
|
3030 | compileModuleAndAllComponentsAsync(moduleType) {
|
3031 | throw _throwError();
|
3032 | }
|
3033 | /**
|
3034 | * Exposes the CSS-style selectors that have been used in `ngContent` directives within
|
3035 | * the template of the given component.
|
3036 | * This is used by the `upgrade` library to compile the appropriate transclude content
|
3037 | * in the AngularJS wrapper component.
|
3038 | *
|
3039 | * @deprecated since v4. Use ComponentFactory.ngContentSelectors instead.
|
3040 | * @param {?} component
|
3041 | * @return {?}
|
3042 | */
|
3043 | getNgContentSelectors(component) { throw _throwError(); }
|
3044 | /**
|
3045 | * Clears all caches.
|
3046 | * @return {?}
|
3047 | */
|
3048 | clearCache() { }
|
3049 | /**
|
3050 | * Clears the cache for the given component/ngModule.
|
3051 | * @param {?} type
|
3052 | * @return {?}
|
3053 | */
|
3054 | clearCacheFor(type) { }
|
3055 | }
|
3056 | Compiler.decorators = [
|
3057 | { type: Injectable },
|
3058 | ];
|
3059 | /**
|
3060 | * @nocollapse
|
3061 | */
|
3062 | Compiler.ctorParameters = () => [];
|
3063 | /**
|
3064 | * Token to provide CompilerOptions in the platform injector.
|
3065 | *
|
3066 | * \@experimental
|
3067 | */
|
3068 | const COMPILER_OPTIONS = new InjectionToken('compilerOptions');
|
3069 | /**
|
3070 | * A factory for creating a Compiler
|
3071 | *
|
3072 | * \@experimental
|
3073 | * @abstract
|
3074 | */
|
3075 | class CompilerFactory {
|
3076 | /**
|
3077 | * @abstract
|
3078 | * @param {?=} options
|
3079 | * @return {?}
|
3080 | */
|
3081 | createCompiler(options) { }
|
3082 | }
|
3083 |
|
3084 | /**
|
3085 | * @license
|
3086 | * Copyright Google Inc. All Rights Reserved.
|
3087 | *
|
3088 | * Use of this source code is governed by an MIT-style license that can be
|
3089 | * found in the LICENSE file at https://angular.io/license
|
3090 | */
|
3091 | /**
|
3092 | * Represents an instance of a Component created via a {\@link ComponentFactory}.
|
3093 | *
|
3094 | * `ComponentRef` provides access to the Component Instance as well other objects related to this
|
3095 | * Component Instance and allows you to destroy the Component Instance via the {\@link #destroy}
|
3096 | * method.
|
3097 | * \@stable
|
3098 | * @abstract
|
3099 | */
|
3100 | class ComponentRef {
|
3101 | /**
|
3102 | * Location of the Host Element of this Component Instance.
|
3103 | * @abstract
|
3104 | * @return {?}
|
3105 | */
|
3106 | location() { }
|
3107 | /**
|
3108 | * The injector on which the component instance exists.
|
3109 | * @abstract
|
3110 | * @return {?}
|
3111 | */
|
3112 | injector() { }
|
3113 | /**
|
3114 | * The instance of the Component.
|
3115 | * @abstract
|
3116 | * @return {?}
|
3117 | */
|
3118 | instance() { }
|
3119 | /**
|
3120 | * The {\@link ViewRef} of the Host View of this Component instance.
|
3121 | * @abstract
|
3122 | * @return {?}
|
3123 | */
|
3124 | hostView() { }
|
3125 | /**
|
3126 | * The {\@link ChangeDetectorRef} of the Component instance.
|
3127 | * @abstract
|
3128 | * @return {?}
|
3129 | */
|
3130 | changeDetectorRef() { }
|
3131 | /**
|
3132 | * The component type.
|
3133 | * @abstract
|
3134 | * @return {?}
|
3135 | */
|
3136 | componentType() { }
|
3137 | /**
|
3138 | * Destroys the component instance and all of the data structures associated with it.
|
3139 | * @abstract
|
3140 | * @return {?}
|
3141 | */
|
3142 | destroy() { }
|
3143 | /**
|
3144 | * Allows to register a callback that will be called when the component is destroyed.
|
3145 | * @abstract
|
3146 | * @param {?} callback
|
3147 | * @return {?}
|
3148 | */
|
3149 | onDestroy(callback) { }
|
3150 | }
|
3151 | /**
|
3152 | * \@stable
|
3153 | * @abstract
|
3154 | */
|
3155 | class ComponentFactory {
|
3156 | /**
|
3157 | * @abstract
|
3158 | * @return {?}
|
3159 | */
|
3160 | selector() { }
|
3161 | /**
|
3162 | * @abstract
|
3163 | * @return {?}
|
3164 | */
|
3165 | componentType() { }
|
3166 | /**
|
3167 | * selector for all <ng-content> elements in the component.
|
3168 | * @abstract
|
3169 | * @return {?}
|
3170 | */
|
3171 | ngContentSelectors() { }
|
3172 | /**
|
3173 | * the inputs of the component.
|
3174 | * @abstract
|
3175 | * @return {?}
|
3176 | */
|
3177 | inputs() { }
|
3178 | /**
|
3179 | * the outputs of the component.
|
3180 | * @abstract
|
3181 | * @return {?}
|
3182 | */
|
3183 | outputs() { }
|
3184 | /**
|
3185 | * Creates a new component.
|
3186 | * @abstract
|
3187 | * @param {?} injector
|
3188 | * @param {?=} projectableNodes
|
3189 | * @param {?=} rootSelectorOrNode
|
3190 | * @param {?=} ngModule
|
3191 | * @return {?}
|
3192 | */
|
3193 | create(injector, projectableNodes, rootSelectorOrNode, ngModule) { }
|
3194 | }
|
3195 |
|
3196 | /**
|
3197 | * @license
|
3198 | * Copyright Google Inc. All Rights Reserved.
|
3199 | *
|
3200 | * Use of this source code is governed by an MIT-style license that can be
|
3201 | * found in the LICENSE file at https://angular.io/license
|
3202 | */
|
3203 | /**
|
3204 | * @param {?} component
|
3205 | * @return {?}
|
3206 | */
|
3207 | function noComponentFactoryError(component) {
|
3208 | const /** @type {?} */ error = Error(`No component factory found for ${stringify(component)}. Did you add it to @NgModule.entryComponents?`);
|
3209 | ((error))[ERROR_COMPONENT] = component;
|
3210 | return error;
|
3211 | }
|
3212 | const ERROR_COMPONENT = 'ngComponent';
|
3213 | /**
|
3214 | * @param {?} error
|
3215 | * @return {?}
|
3216 | */
|
3217 |
|
3218 | class _NullComponentFactoryResolver {
|
3219 | /**
|
3220 | * @template T
|
3221 | * @param {?} component
|
3222 | * @return {?}
|
3223 | */
|
3224 | resolveComponentFactory(component) {
|
3225 | throw noComponentFactoryError(component);
|
3226 | }
|
3227 | }
|
3228 | /**
|
3229 | * \@stable
|
3230 | * @abstract
|
3231 | */
|
3232 | class ComponentFactoryResolver {
|
3233 | /**
|
3234 | * @abstract
|
3235 | * @template T
|
3236 | * @param {?} component
|
3237 | * @return {?}
|
3238 | */
|
3239 | resolveComponentFactory(component) { }
|
3240 | }
|
3241 | ComponentFactoryResolver.NULL = new _NullComponentFactoryResolver();
|
3242 | class CodegenComponentFactoryResolver {
|
3243 | /**
|
3244 | * @param {?} factories
|
3245 | * @param {?} _parent
|
3246 | * @param {?} _ngModule
|
3247 | */
|
3248 | constructor(factories, _parent, _ngModule) {
|
3249 | this._parent = _parent;
|
3250 | this._ngModule = _ngModule;
|
3251 | this._factories = new Map();
|
3252 | for (let i = 0; i < factories.length; i++) {
|
3253 | const factory = factories[i];
|
3254 | this._factories.set(factory.componentType, factory);
|
3255 | }
|
3256 | }
|
3257 | /**
|
3258 | * @template T
|
3259 | * @param {?} component
|
3260 | * @return {?}
|
3261 | */
|
3262 | resolveComponentFactory(component) {
|
3263 | let /** @type {?} */ factory = this._factories.get(component) || this._parent.resolveComponentFactory(component);
|
3264 | return new ComponentFactoryBoundToModule(factory, this._ngModule);
|
3265 | }
|
3266 | }
|
3267 | class ComponentFactoryBoundToModule extends ComponentFactory {
|
3268 | /**
|
3269 | * @param {?} factory
|
3270 | * @param {?} ngModule
|
3271 | */
|
3272 | constructor(factory, ngModule) {
|
3273 | super();
|
3274 | this.factory = factory;
|
3275 | this.ngModule = ngModule;
|
3276 | }
|
3277 | /**
|
3278 | * @return {?}
|
3279 | */
|
3280 | get selector() { return this.factory.selector; }
|
3281 | /**
|
3282 | * @return {?}
|
3283 | */
|
3284 | get componentType() { return this.factory.componentType; }
|
3285 | /**
|
3286 | * @return {?}
|
3287 | */
|
3288 | get ngContentSelectors() { return this.factory.ngContentSelectors; }
|
3289 | /**
|
3290 | * @return {?}
|
3291 | */
|
3292 | get inputs() { return this.factory.inputs; }
|
3293 | /**
|
3294 | * @return {?}
|
3295 | */
|
3296 | get outputs() { return this.factory.outputs; }
|
3297 | /**
|
3298 | * @param {?} injector
|
3299 | * @param {?=} projectableNodes
|
3300 | * @param {?=} rootSelectorOrNode
|
3301 | * @param {?=} ngModule
|
3302 | * @return {?}
|
3303 | */
|
3304 | create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
|
3305 | return this.factory.create(injector, projectableNodes, rootSelectorOrNode, ngModule || this.ngModule);
|
3306 | }
|
3307 | }
|
3308 |
|
3309 | /**
|
3310 | * @license
|
3311 | * Copyright Google Inc. All Rights Reserved.
|
3312 | *
|
3313 | * Use of this source code is governed by an MIT-style license that can be
|
3314 | * found in the LICENSE file at https://angular.io/license
|
3315 | */
|
3316 | /**
|
3317 | * Represents an instance of an NgModule created via a {\@link NgModuleFactory}.
|
3318 | *
|
3319 | * `NgModuleRef` provides access to the NgModule Instance as well other objects related to this
|
3320 | * NgModule Instance.
|
3321 | *
|
3322 | * \@stable
|
3323 | * @abstract
|
3324 | */
|
3325 | class NgModuleRef {
|
3326 | /**
|
3327 | * The injector that contains all of the providers of the NgModule.
|
3328 | * @abstract
|
3329 | * @return {?}
|
3330 | */
|
3331 | injector() { }
|
3332 | /**
|
3333 | * The ComponentFactoryResolver to get hold of the ComponentFactories
|
3334 | * declared in the `entryComponents` property of the module.
|
3335 | * @abstract
|
3336 | * @return {?}
|
3337 | */
|
3338 | componentFactoryResolver() { }
|
3339 | /**
|
3340 | * The NgModule instance.
|
3341 | * @abstract
|
3342 | * @return {?}
|
3343 | */
|
3344 | instance() { }
|
3345 | /**
|
3346 | * Destroys the module instance and all of the data structures associated with it.
|
3347 | * @abstract
|
3348 | * @return {?}
|
3349 | */
|
3350 | destroy() { }
|
3351 | /**
|
3352 | * Allows to register a callback that will be called when the module is destroyed.
|
3353 | * @abstract
|
3354 | * @param {?} callback
|
3355 | * @return {?}
|
3356 | */
|
3357 | onDestroy(callback) { }
|
3358 | }
|
3359 | /**
|
3360 | * \@experimental
|
3361 | */
|
3362 | class NgModuleFactory {
|
3363 | /**
|
3364 | * @param {?} _injectorClass
|
3365 | * @param {?} _moduleType
|
3366 | */
|
3367 | constructor(_injectorClass, _moduleType) {
|
3368 | this._injectorClass = _injectorClass;
|
3369 | this._moduleType = _moduleType;
|
3370 | }
|
3371 | /**
|
3372 | * @return {?}
|
3373 | */
|
3374 | get moduleType() { return this._moduleType; }
|
3375 | /**
|
3376 | * @param {?} parentInjector
|
3377 | * @return {?}
|
3378 | */
|
3379 | create(parentInjector) {
|
3380 | const /** @type {?} */ instance = new this._injectorClass(parentInjector || Injector.NULL);
|
3381 | instance.create();
|
3382 | return instance;
|
3383 | }
|
3384 | }
|
3385 | const _UNDEFINED = new Object();
|
3386 | /**
|
3387 | * @abstract
|
3388 | */
|
3389 | class NgModuleInjector {
|
3390 | /**
|
3391 | * @param {?} parent
|
3392 | * @param {?} factories
|
3393 | * @param {?} bootstrapFactories
|
3394 | */
|
3395 | constructor(parent, factories, bootstrapFactories) {
|
3396 | this.parent = parent;
|
3397 | this._destroyListeners = [];
|
3398 | this._destroyed = false;
|
3399 | this.bootstrapFactories =
|
3400 | bootstrapFactories.map(f => new ComponentFactoryBoundToModule(f, this));
|
3401 | this._cmpFactoryResolver = new CodegenComponentFactoryResolver(factories, parent.get(ComponentFactoryResolver, ComponentFactoryResolver.NULL), this);
|
3402 | }
|
3403 | /**
|
3404 | * @return {?}
|
3405 | */
|
3406 | create() { this.instance = this.createInternal(); }
|
3407 | /**
|
3408 | * @abstract
|
3409 | * @return {?}
|
3410 | */
|
3411 | createInternal() { }
|
3412 | /**
|
3413 | * @param {?} token
|
3414 | * @param {?=} notFoundValue
|
3415 | * @return {?}
|
3416 | */
|
3417 | get(token, notFoundValue = THROW_IF_NOT_FOUND) {
|
3418 | if (token === Injector || token === NgModuleRef) {
|
3419 | return this;
|
3420 | }
|
3421 | if (token === ComponentFactoryResolver) {
|
3422 | return this._cmpFactoryResolver;
|
3423 | }
|
3424 | const /** @type {?} */ result = this.getInternal(token, _UNDEFINED);
|
3425 | return result === _UNDEFINED ? this.parent.get(token, notFoundValue) : result;
|
3426 | }
|
3427 | /**
|
3428 | * @abstract
|
3429 | * @param {?} token
|
3430 | * @param {?} notFoundValue
|
3431 | * @return {?}
|
3432 | */
|
3433 | getInternal(token, notFoundValue) { }
|
3434 | /**
|
3435 | * @return {?}
|
3436 | */
|
3437 | get injector() { return this; }
|
3438 | /**
|
3439 | * @return {?}
|
3440 | */
|
3441 | get componentFactoryResolver() { return this._cmpFactoryResolver; }
|
3442 | /**
|
3443 | * @return {?}
|
3444 | */
|
3445 | destroy() {
|
3446 | if (this._destroyed) {
|
3447 | throw new Error(`The ng module ${stringify(this.instance.constructor)} has already been destroyed.`);
|
3448 | }
|
3449 | this._destroyed = true;
|
3450 | this.destroyInternal();
|
3451 | this._destroyListeners.forEach((listener) => listener());
|
3452 | }
|
3453 | /**
|
3454 | * @param {?} callback
|
3455 | * @return {?}
|
3456 | */
|
3457 | onDestroy(callback) { this._destroyListeners.push(callback); }
|
3458 | /**
|
3459 | * @abstract
|
3460 | * @return {?}
|
3461 | */
|
3462 | destroyInternal() { }
|
3463 | }
|
3464 |
|
3465 | /**
|
3466 | * @license
|
3467 | * Copyright Google Inc. All Rights Reserved.
|
3468 | *
|
3469 | * Use of this source code is governed by an MIT-style license that can be
|
3470 | * found in the LICENSE file at https://angular.io/license
|
3471 | */
|
3472 | let trace;
|
3473 | let events;
|
3474 | /**
|
3475 | * @return {?}
|
3476 | */
|
3477 | function detectWTF() {
|
3478 | const /** @type {?} */ wtf = ((_global) /** TODO #9100 */)['wtf'];
|
3479 | if (wtf) {
|
3480 | trace = wtf['trace'];
|
3481 | if (trace) {
|
3482 | events = trace['events'];
|
3483 | return true;
|
3484 | }
|
3485 | }
|
3486 | return false;
|
3487 | }
|
3488 | /**
|
3489 | * @param {?} signature
|
3490 | * @param {?=} flags
|
3491 | * @return {?}
|
3492 | */
|
3493 | function createScope$1(signature, flags = null) {
|
3494 | return events.createScope(signature, flags);
|
3495 | }
|
3496 | /**
|
3497 | * @template T
|
3498 | * @param {?} scope
|
3499 | * @param {?=} returnValue
|
3500 | * @return {?}
|
3501 | */
|
3502 | function leave(scope, returnValue) {
|
3503 | trace.leaveScope(scope, returnValue);
|
3504 | return returnValue;
|
3505 | }
|
3506 | /**
|
3507 | * @param {?} rangeType
|
3508 | * @param {?} action
|
3509 | * @return {?}
|
3510 | */
|
3511 | function startTimeRange(rangeType, action) {
|
3512 | return trace.beginTimeRange(rangeType, action);
|
3513 | }
|
3514 | /**
|
3515 | * @param {?} range
|
3516 | * @return {?}
|
3517 | */
|
3518 | function endTimeRange(range) {
|
3519 | trace.endTimeRange(range);
|
3520 | }
|
3521 |
|
3522 | /**
|
3523 | * @license
|
3524 | * Copyright Google Inc. All Rights Reserved.
|
3525 | *
|
3526 | * Use of this source code is governed by an MIT-style license that can be
|
3527 | * found in the LICENSE file at https://angular.io/license
|
3528 | */
|
3529 | /**
|
3530 | * True if WTF is enabled.
|
3531 | */
|
3532 | const wtfEnabled = detectWTF();
|
3533 | /**
|
3534 | * @param {?=} arg0
|
3535 | * @param {?=} arg1
|
3536 | * @return {?}
|
3537 | */
|
3538 | function noopScope(arg0, arg1) {
|
3539 | return null;
|
3540 | }
|
3541 | /**
|
3542 | * Create trace scope.
|
3543 | *
|
3544 | * Scopes must be strictly nested and are analogous to stack frames, but
|
3545 | * do not have to follow the stack frames. Instead it is recommended that they follow logical
|
3546 | * nesting. You may want to use
|
3547 | * [Event
|
3548 | * Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
|
3549 | * as they are defined in WTF.
|
3550 | *
|
3551 | * Used to mark scope entry. The return value is used to leave the scope.
|
3552 | *
|
3553 | * var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
|
3554 | *
|
3555 | * someMethod() {
|
3556 | * var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
|
3557 | * // DO SOME WORK HERE
|
3558 | * return wtfLeave(s, 123); // Return value 123
|
3559 | * }
|
3560 | *
|
3561 | * Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
|
3562 | * negatively impact the performance of your application. For this reason we recommend that
|
3563 | * you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
|
3564 | * so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
|
3565 | * exception, will produce incorrect trace, but presence of exception signifies logic error which
|
3566 | * needs to be fixed before the app should be profiled. Add try-finally only when you expect that
|
3567 | * an exception is expected during normal execution while profiling.
|
3568 | *
|
3569 | * \@experimental
|
3570 | */
|
3571 | const wtfCreateScope = wtfEnabled ? createScope$1 : (signature, flags) => noopScope;
|
3572 | /**
|
3573 | * Used to mark end of Scope.
|
3574 | *
|
3575 | * - `scope` to end.
|
3576 | * - `returnValue` (optional) to be passed to the WTF.
|
3577 | *
|
3578 | * Returns the `returnValue for easy chaining.
|
3579 | * \@experimental
|
3580 | */
|
3581 | const wtfLeave = wtfEnabled ? leave : (s, r) => r;
|
3582 |
|
3583 |
|
3584 |
|
3585 |
|
3586 |
|
3587 |
|
3588 |
|
3589 |
|
3590 |
|
3591 |
|
3592 |
|
3593 |
|
3594 |
|
3595 | const wtfStartTimeRange = wtfEnabled ? startTimeRange : (rangeType, action) => null;
|
3596 |
|
3597 |
|
3598 |
|
3599 |
|
3600 |
|
3601 |
|
3602 | const wtfEndTimeRange = wtfEnabled ? endTimeRange : (r) => null;
|
3603 |
|
3604 |
|
3605 |
|
3606 |
|
3607 |
|
3608 |
|
3609 |
|
3610 |
|
3611 |
|
3612 |
|
3613 |
|
3614 |
|
3615 |
|
3616 |
|
3617 |
|
3618 |
|
3619 |
|
3620 |
|
3621 |
|
3622 |
|
3623 |
|
3624 |
|
3625 |
|
3626 |
|
3627 |
|
3628 |
|
3629 |
|
3630 |
|
3631 |
|
3632 |
|
3633 |
|
3634 |
|
3635 |
|
3636 |
|
3637 |
|
3638 |
|
3639 |
|
3640 |
|
3641 |
|
3642 |
|
3643 |
|
3644 |
|
3645 |
|
3646 |
|
3647 |
|
3648 |
|
3649 |
|
3650 |
|
3651 |
|
3652 |
|
3653 |
|
3654 |
|
3655 |
|
3656 |
|
3657 |
|
3658 | class EventEmitter extends Subject {
|
3659 | |
3660 |
|
3661 |
|
3662 |
|
3663 |
|
3664 | constructor(isAsync = false) {
|
3665 | super();
|
3666 | this.__isAsync = isAsync;
|
3667 | }
|
3668 | |
3669 |
|
3670 |
|
3671 |
|
3672 | emit(value) { super.next(value); }
|
3673 | |
3674 |
|
3675 |
|
3676 |
|
3677 |
|
3678 |
|
3679 | subscribe(generatorOrNext, error, complete) {
|
3680 | let schedulerFn;
|
3681 | let errorFn = (err) => null;
|
3682 | let completeFn = () => null;
|
3683 | if (generatorOrNext && typeof generatorOrNext === 'object') {
|
3684 | schedulerFn = this.__isAsync ? (value) => {
|
3685 | setTimeout(() => generatorOrNext.next(value));
|
3686 | } : (value) => { generatorOrNext.next(value); };
|
3687 | if (generatorOrNext.error) {
|
3688 | errorFn = this.__isAsync ? (err) => { setTimeout(() => generatorOrNext.error(err)); } :
|
3689 | (err) => { generatorOrNext.error(err); };
|
3690 | }
|
3691 | if (generatorOrNext.complete) {
|
3692 | completeFn = this.__isAsync ? () => { setTimeout(() => generatorOrNext.complete()); } :
|
3693 | () => { generatorOrNext.complete(); };
|
3694 | }
|
3695 | }
|
3696 | else {
|
3697 | schedulerFn = this.__isAsync ? (value) => { setTimeout(() => generatorOrNext(value)); } :
|
3698 | (value) => { generatorOrNext(value); };
|
3699 | if (error) {
|
3700 | errorFn =
|
3701 | this.__isAsync ? (err) => { setTimeout(() => error(err)); } : (err) => { error(err); };
|
3702 | }
|
3703 | if (complete) {
|
3704 | completeFn =
|
3705 | this.__isAsync ? () => { setTimeout(() => complete()); } : () => { complete(); };
|
3706 | }
|
3707 | }
|
3708 | return super.subscribe(schedulerFn, errorFn, completeFn);
|
3709 | }
|
3710 | }
|
3711 |
|
3712 |
|
3713 |
|
3714 |
|
3715 |
|
3716 |
|
3717 |
|
3718 |
|
3719 |
|
3720 |
|
3721 |
|
3722 |
|
3723 |
|
3724 |
|
3725 |
|
3726 |
|
3727 |
|
3728 |
|
3729 |
|
3730 |
|
3731 |
|
3732 |
|
3733 |
|
3734 |
|
3735 |
|
3736 |
|
3737 |
|
3738 |
|
3739 |
|
3740 |
|
3741 |
|
3742 |
|
3743 |
|
3744 |
|
3745 |
|
3746 |
|
3747 |
|
3748 |
|
3749 |
|
3750 |
|
3751 |
|
3752 |
|
3753 |
|
3754 |
|
3755 |
|
3756 |
|
3757 |
|
3758 |
|
3759 |
|
3760 |
|
3761 |
|
3762 |
|
3763 |
|
3764 |
|
3765 |
|
3766 |
|
3767 |
|
3768 |
|
3769 |
|
3770 |
|
3771 |
|
3772 |
|
3773 |
|
3774 |
|
3775 |
|
3776 |
|
3777 |
|
3778 |
|
3779 |
|
3780 |
|
3781 |
|
3782 |
|
3783 |
|
3784 |
|
3785 |
|
3786 |
|
3787 |
|
3788 |
|
3789 |
|
3790 |
|
3791 | class NgZone {
|
3792 | |
3793 |
|
3794 |
|
3795 | constructor({ enableLongStackTrace = false }) {
|
3796 | this._hasPendingMicrotasks = false;
|
3797 | this._hasPendingMacrotasks = false;
|
3798 | this._isStable = true;
|
3799 | this._nesting = 0;
|
3800 | this._onUnstable = new EventEmitter(false);
|
3801 | this._onMicrotaskEmpty = new EventEmitter(false);
|
3802 | this._onStable = new EventEmitter(false);
|
3803 | this._onErrorEvents = new EventEmitter(false);
|
3804 | if (typeof Zone == 'undefined') {
|
3805 | throw new Error('Angular requires Zone.js prolyfill.');
|
3806 | }
|
3807 | Zone.assertZonePatched();
|
3808 | this.outer = this.inner = Zone.current;
|
3809 | if (Zone['wtfZoneSpec']) {
|
3810 | this.inner = this.inner.fork(Zone['wtfZoneSpec']);
|
3811 | }
|
3812 | if (enableLongStackTrace && Zone['longStackTraceZoneSpec']) {
|
3813 | this.inner = this.inner.fork(Zone['longStackTraceZoneSpec']);
|
3814 | }
|
3815 | this.forkInnerZoneWithAngularBehavior();
|
3816 | }
|
3817 | |
3818 |
|
3819 |
|
3820 | static isInAngularZone() { return Zone.current.get('isAngularZone') === true; }
|
3821 | |
3822 |
|
3823 |
|
3824 | static assertInAngularZone() {
|
3825 | if (!NgZone.isInAngularZone()) {
|
3826 | throw new Error('Expected to be in Angular Zone, but it is not!');
|
3827 | }
|
3828 | }
|
3829 | |
3830 |
|
3831 |
|
3832 | static assertNotInAngularZone() {
|
3833 | if (NgZone.isInAngularZone()) {
|
3834 | throw new Error('Expected to not be in Angular Zone, but it is!');
|
3835 | }
|
3836 | }
|
3837 | |
3838 |
|
3839 |
|
3840 |
|
3841 |
|
3842 |
|
3843 |
|
3844 |
|
3845 |
|
3846 |
|
3847 |
|
3848 |
|
3849 |
|
3850 |
|
3851 | run(fn) { return this.inner.run(fn); }
|
3852 | |
3853 |
|
3854 |
|
3855 |
|
3856 |
|
3857 |
|
3858 | runGuarded(fn) { return this.inner.runGuarded(fn); }
|
3859 | |
3860 |
|
3861 |
|
3862 |
|
3863 |
|
3864 |
|
3865 |
|
3866 |
|
3867 |
|
3868 |
|
3869 |
|
3870 |
|
3871 |
|
3872 |
|
3873 |
|
3874 | runOutsideAngular(fn) { return this.outer.run(fn); }
|
3875 | |
3876 |
|
3877 |
|
3878 |
|
3879 | get onUnstable() { return this._onUnstable; }
|
3880 | |
3881 |
|
3882 |
|
3883 |
|
3884 |
|
3885 |
|
3886 | get onMicrotaskEmpty() { return this._onMicrotaskEmpty; }
|
3887 | |
3888 |
|
3889 |
|
3890 |
|
3891 |
|
3892 |
|
3893 | get onStable() { return this._onStable; }
|
3894 | |
3895 |
|
3896 |
|
3897 |
|
3898 | get onError() { return this._onErrorEvents; }
|
3899 | |
3900 |
|
3901 |
|
3902 |
|
3903 | get isStable() { return this._isStable; }
|
3904 | |
3905 |
|
3906 |
|
3907 | get hasPendingMicrotasks() { return this._hasPendingMicrotasks; }
|
3908 | |
3909 |
|
3910 |
|
3911 | get hasPendingMacrotasks() { return this._hasPendingMacrotasks; }
|
3912 | |
3913 |
|
3914 |
|
3915 | checkStable() {
|
3916 | if (this._nesting == 0 && !this._hasPendingMicrotasks && !this._isStable) {
|
3917 | try {
|
3918 | this._nesting++;
|
3919 | this._onMicrotaskEmpty.emit(null);
|
3920 | }
|
3921 | finally {
|
3922 | this._nesting--;
|
3923 | if (!this._hasPendingMicrotasks) {
|
3924 | try {
|
3925 | this.runOutsideAngular(() => this._onStable.emit(null));
|
3926 | }
|
3927 | finally {
|
3928 | this._isStable = true;
|
3929 | }
|
3930 | }
|
3931 | }
|
3932 | }
|
3933 | }
|
3934 | |
3935 |
|
3936 |
|
3937 | forkInnerZoneWithAngularBehavior() {
|
3938 | this.inner = this.inner.fork({
|
3939 | name: 'angular',
|
3940 | properties: ({ 'isAngularZone': true }),
|
3941 | onInvokeTask: (delegate, current, target, task, applyThis, applyArgs) => {
|
3942 | try {
|
3943 | this.onEnter();
|
3944 | return delegate.invokeTask(target, task, applyThis, applyArgs);
|
3945 | }
|
3946 | finally {
|
3947 | this.onLeave();
|
3948 | }
|
3949 | },
|
3950 | onInvoke: (delegate, current, target, callback, applyThis, applyArgs, source) => {
|
3951 | try {
|
3952 | this.onEnter();
|
3953 | return delegate.invoke(target, callback, applyThis, applyArgs, source);
|
3954 | }
|
3955 | finally {
|
3956 | this.onLeave();
|
3957 | }
|
3958 | },
|
3959 | onHasTask: (delegate, current, target, hasTaskState) => {
|
3960 | delegate.hasTask(target, hasTaskState);
|
3961 | if (current === target) {
|
3962 |
|
3963 |
|
3964 | if (hasTaskState.change == 'microTask') {
|
3965 | this.setHasMicrotask(hasTaskState.microTask);
|
3966 | }
|
3967 | else if (hasTaskState.change == 'macroTask') {
|
3968 | this.setHasMacrotask(hasTaskState.macroTask);
|
3969 | }
|
3970 | }
|
3971 | },
|
3972 | onHandleError: (delegate, current, target, error) => {
|
3973 | delegate.handleError(target, error);
|
3974 | this.triggerError(error);
|
3975 | return false;
|
3976 | }
|
3977 | });
|
3978 | }
|
3979 | |
3980 |
|
3981 |
|
3982 | onEnter() {
|
3983 | this._nesting++;
|
3984 | if (this._isStable) {
|
3985 | this._isStable = false;
|
3986 | this._onUnstable.emit(null);
|
3987 | }
|
3988 | }
|
3989 | |
3990 |
|
3991 |
|
3992 | onLeave() {
|
3993 | this._nesting--;
|
3994 | this.checkStable();
|
3995 | }
|
3996 | |
3997 |
|
3998 |
|
3999 |
|
4000 | setHasMicrotask(hasMicrotasks) {
|
4001 | this._hasPendingMicrotasks = hasMicrotasks;
|
4002 | this.checkStable();
|
4003 | }
|
4004 | |
4005 |
|
4006 |
|
4007 |
|
4008 | setHasMacrotask(hasMacrotasks) { this._hasPendingMacrotasks = hasMacrotasks; }
|
4009 | |
4010 |
|
4011 |
|
4012 |
|
4013 | triggerError(error) { this._onErrorEvents.emit(error); }
|
4014 | }
|
4015 |
|
4016 |
|
4017 |
|
4018 |
|
4019 |
|
4020 |
|
4021 |
|
4022 |
|
4023 |
|
4024 |
|
4025 |
|
4026 |
|
4027 |
|
4028 |
|
4029 | class Testability {
|
4030 | |
4031 |
|
4032 |
|
4033 | constructor(_ngZone) {
|
4034 | this._ngZone = _ngZone;
|
4035 | |
4036 |
|
4037 |
|
4038 | this._pendingCount = 0;
|
4039 | |
4040 |
|
4041 |
|
4042 | this._isZoneStable = true;
|
4043 | |
4044 |
|
4045 |
|
4046 |
|
4047 |
|
4048 |
|
4049 | this._didWork = false;
|
4050 | |
4051 |
|
4052 |
|
4053 | this._callbacks = [];
|
4054 | this._watchAngularEvents();
|
4055 | }
|
4056 | |
4057 |
|
4058 |
|
4059 |
|
4060 | _watchAngularEvents() {
|
4061 | this._ngZone.onUnstable.subscribe({
|
4062 | next: () => {
|
4063 | this._didWork = true;
|
4064 | this._isZoneStable = false;
|
4065 | }
|
4066 | });
|
4067 | this._ngZone.runOutsideAngular(() => {
|
4068 | this._ngZone.onStable.subscribe({
|
4069 | next: () => {
|
4070 | NgZone.assertNotInAngularZone();
|
4071 | scheduleMicroTask(() => {
|
4072 | this._isZoneStable = true;
|
4073 | this._runCallbacksIfReady();
|
4074 | });
|
4075 | }
|
4076 | });
|
4077 | });
|
4078 | }
|
4079 | |
4080 |
|
4081 |
|
4082 | increasePendingRequestCount() {
|
4083 | this._pendingCount += 1;
|
4084 | this._didWork = true;
|
4085 | return this._pendingCount;
|
4086 | }
|
4087 | |
4088 |
|
4089 |
|
4090 | decreasePendingRequestCount() {
|
4091 | this._pendingCount -= 1;
|
4092 | if (this._pendingCount < 0) {
|
4093 | throw new Error('pending async requests below zero');
|
4094 | }
|
4095 | this._runCallbacksIfReady();
|
4096 | return this._pendingCount;
|
4097 | }
|
4098 | |
4099 |
|
4100 |
|
4101 | isStable() {
|
4102 | return this._isZoneStable && this._pendingCount == 0 && !this._ngZone.hasPendingMacrotasks;
|
4103 | }
|
4104 | |
4105 |
|
4106 |
|
4107 |
|
4108 | _runCallbacksIfReady() {
|
4109 | if (this.isStable()) {
|
4110 |
|
4111 | scheduleMicroTask(() => {
|
4112 | while (this._callbacks.length !== 0) {
|
4113 | (((this._callbacks.pop())))(this._didWork);
|
4114 | }
|
4115 | this._didWork = false;
|
4116 | });
|
4117 | }
|
4118 | else {
|
4119 |
|
4120 | this._didWork = true;
|
4121 | }
|
4122 | }
|
4123 | |
4124 |
|
4125 |
|
4126 |
|
4127 | whenStable(callback) {
|
4128 | this._callbacks.push(callback);
|
4129 | this._runCallbacksIfReady();
|
4130 | }
|
4131 | |
4132 |
|
4133 |
|
4134 | getPendingRequestCount() { return this._pendingCount; }
|
4135 | |
4136 |
|
4137 |
|
4138 |
|
4139 |
|
4140 |
|
4141 |
|
4142 | findBindings(using, provider, exactMatch) {
|
4143 |
|
4144 | return [];
|
4145 | }
|
4146 | |
4147 |
|
4148 |
|
4149 |
|
4150 |
|
4151 |
|
4152 | findProviders(using, provider, exactMatch) {
|
4153 |
|
4154 | return [];
|
4155 | }
|
4156 | }
|
4157 | Testability.decorators = [
|
4158 | { type: Injectable },
|
4159 | ];
|
4160 |
|
4161 |
|
4162 |
|
4163 | Testability.ctorParameters = () => [
|
4164 | { type: NgZone, },
|
4165 | ];
|
4166 |
|
4167 |
|
4168 |
|
4169 |
|
4170 | class TestabilityRegistry {
|
4171 | constructor() {
|
4172 | |
4173 |
|
4174 |
|
4175 | this._applications = new Map();
|
4176 | _testabilityGetter.addToWindow(this);
|
4177 | }
|
4178 | |
4179 |
|
4180 |
|
4181 |
|
4182 |
|
4183 | registerApplication(token, testability) {
|
4184 | this._applications.set(token, testability);
|
4185 | }
|
4186 | |
4187 |
|
4188 |
|
4189 |
|
4190 | getTestability(elem) { return this._applications.get(elem) || null; }
|
4191 | |
4192 |
|
4193 |
|
4194 | getAllTestabilities() { return Array.from(this._applications.values()); }
|
4195 | |
4196 |
|
4197 |
|
4198 | getAllRootElements() { return Array.from(this._applications.keys()); }
|
4199 | |
4200 |
|
4201 |
|
4202 |
|
4203 |
|
4204 | findTestabilityInTree(elem, findInAncestors = true) {
|
4205 | return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
|
4206 | }
|
4207 | }
|
4208 | TestabilityRegistry.decorators = [
|
4209 | { type: Injectable },
|
4210 | ];
|
4211 |
|
4212 |
|
4213 |
|
4214 | TestabilityRegistry.ctorParameters = () => [];
|
4215 | class _NoopGetTestability {
|
4216 | |
4217 |
|
4218 |
|
4219 |
|
4220 | addToWindow(registry) { }
|
4221 | |
4222 |
|
4223 |
|
4224 |
|
4225 |
|
4226 |
|
4227 | findTestabilityInTree(registry, elem, findInAncestors) {
|
4228 | return null;
|
4229 | }
|
4230 | }
|
4231 |
|
4232 |
|
4233 |
|
4234 |
|
4235 |
|
4236 |
|
4237 | function setTestabilityGetter(getter) {
|
4238 | _testabilityGetter = getter;
|
4239 | }
|
4240 | let _testabilityGetter = new _NoopGetTestability();
|
4241 |
|
4242 |
|
4243 |
|
4244 |
|
4245 |
|
4246 |
|
4247 |
|
4248 |
|
4249 | let _devMode = true;
|
4250 | let _runModeLocked = false;
|
4251 | let _platform;
|
4252 | const ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
|
4253 |
|
4254 |
|
4255 |
|
4256 |
|
4257 |
|
4258 |
|
4259 |
|
4260 |
|
4261 |
|
4262 |
|
4263 |
|
4264 | function enableProdMode() {
|
4265 | if (_runModeLocked) {
|
4266 | throw new Error('Cannot enable prod mode after platform setup.');
|
4267 | }
|
4268 | _devMode = false;
|
4269 | }
|
4270 |
|
4271 |
|
4272 |
|
4273 |
|
4274 |
|
4275 |
|
4276 |
|
4277 |
|
4278 |
|
4279 | function isDevMode() {
|
4280 | _runModeLocked = true;
|
4281 | return _devMode;
|
4282 | }
|
4283 |
|
4284 |
|
4285 |
|
4286 |
|
4287 |
|
4288 | class NgProbeToken {
|
4289 | |
4290 |
|
4291 |
|
4292 |
|
4293 | constructor(name, token) {
|
4294 | this.name = name;
|
4295 | this.token = token;
|
4296 | }
|
4297 | }
|
4298 |
|
4299 |
|
4300 |
|
4301 |
|
4302 |
|
4303 |
|
4304 |
|
4305 |
|
4306 | function createPlatform(injector) {
|
4307 | if (_platform && !_platform.destroyed &&
|
4308 | !_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
|
4309 | throw new Error('There can be only one platform. Destroy the previous one to create a new one.');
|
4310 | }
|
4311 | _platform = injector.get(PlatformRef);
|
4312 | const inits = injector.get(PLATFORM_INITIALIZER, null);
|
4313 | if (inits)
|
4314 | inits.forEach((init) => init());
|
4315 | return _platform;
|
4316 | }
|
4317 |
|
4318 |
|
4319 |
|
4320 |
|
4321 |
|
4322 |
|
4323 |
|
4324 |
|
4325 |
|
4326 | function createPlatformFactory(parentPlatformFactory, name, providers = []) {
|
4327 | const marker = new InjectionToken(`Platform: ${name}`);
|
4328 | return (extraProviders = []) => {
|
4329 | let platform = getPlatform();
|
4330 | if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
|
4331 | if (parentPlatformFactory) {
|
4332 | parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
|
4333 | }
|
4334 | else {
|
4335 | createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
|
4336 | }
|
4337 | }
|
4338 | return assertPlatform(marker);
|
4339 | };
|
4340 | }
|
4341 |
|
4342 |
|
4343 |
|
4344 |
|
4345 |
|
4346 |
|
4347 |
|
4348 | function assertPlatform(requiredToken) {
|
4349 | const platform = getPlatform();
|
4350 | if (!platform) {
|
4351 | throw new Error('No platform exists!');
|
4352 | }
|
4353 | if (!platform.injector.get(requiredToken, null)) {
|
4354 | throw new Error('A platform with a different configuration has been created. Please destroy it first.');
|
4355 | }
|
4356 | return platform;
|
4357 | }
|
4358 |
|
4359 |
|
4360 |
|
4361 |
|
4362 |
|
4363 |
|
4364 | function destroyPlatform() {
|
4365 | if (_platform && !_platform.destroyed) {
|
4366 | _platform.destroy();
|
4367 | }
|
4368 | }
|
4369 |
|
4370 |
|
4371 |
|
4372 |
|
4373 |
|
4374 |
|
4375 | function getPlatform() {
|
4376 | return _platform && !_platform.destroyed ? _platform : null;
|
4377 | }
|
4378 |
|
4379 |
|
4380 |
|
4381 |
|
4382 |
|
4383 |
|
4384 |
|
4385 |
|
4386 |
|
4387 |
|
4388 |
|
4389 | class PlatformRef {
|
4390 | |
4391 |
|
4392 |
|
4393 |
|
4394 |
|
4395 |
|
4396 |
|
4397 |
|
4398 |
|
4399 |
|
4400 |
|
4401 |
|
4402 |
|
4403 |
|
4404 |
|
4405 |
|
4406 |
|
4407 |
|
4408 |
|
4409 |
|
4410 |
|
4411 |
|
4412 |
|
4413 |
|
4414 |
|
4415 |
|
4416 |
|
4417 | bootstrapModuleFactory(moduleFactory) { }
|
4418 | |
4419 |
|
4420 |
|
4421 |
|
4422 |
|
4423 |
|
4424 |
|
4425 |
|
4426 |
|
4427 |
|
4428 |
|
4429 |
|
4430 |
|
4431 |
|
4432 |
|
4433 |
|
4434 |
|
4435 |
|
4436 |
|
4437 |
|
4438 | bootstrapModule(moduleType, compilerOptions) { }
|
4439 | |
4440 |
|
4441 |
|
4442 |
|
4443 |
|
4444 |
|
4445 | onDestroy(callback) { }
|
4446 | |
4447 |
|
4448 |
|
4449 |
|
4450 |
|
4451 |
|
4452 | injector() { }
|
4453 | |
4454 |
|
4455 |
|
4456 |
|
4457 |
|
4458 | destroy() { }
|
4459 | |
4460 |
|
4461 |
|
4462 |
|
4463 | destroyed() { }
|
4464 | }
|
4465 |
|
4466 |
|
4467 |
|
4468 |
|
4469 |
|
4470 | function _callAndReportToErrorHandler(errorHandler, callback) {
|
4471 | try {
|
4472 | const result = callback();
|
4473 | if (isPromise(result)) {
|
4474 | return result.catch((e) => {
|
4475 | errorHandler.handleError(e);
|
4476 |
|
4477 | throw e;
|
4478 | });
|
4479 | }
|
4480 | return result;
|
4481 | }
|
4482 | catch (e) {
|
4483 | errorHandler.handleError(e);
|
4484 |
|
4485 | throw e;
|
4486 | }
|
4487 | }
|
4488 |
|
4489 |
|
4490 |
|
4491 |
|
4492 | class PlatformRef_ extends PlatformRef {
|
4493 | |
4494 |
|
4495 |
|
4496 | constructor(_injector) {
|
4497 | super();
|
4498 | this._injector = _injector;
|
4499 | this._modules = [];
|
4500 | this._destroyListeners = [];
|
4501 | this._destroyed = false;
|
4502 | }
|
4503 | |
4504 |
|
4505 |
|
4506 |
|
4507 | onDestroy(callback) { this._destroyListeners.push(callback); }
|
4508 | |
4509 |
|
4510 |
|
4511 | get injector() { return this._injector; }
|
4512 | |
4513 |
|
4514 |
|
4515 | get destroyed() { return this._destroyed; }
|
4516 | |
4517 |
|
4518 |
|
4519 | destroy() {
|
4520 | if (this._destroyed) {
|
4521 | throw new Error('The platform has already been destroyed!');
|
4522 | }
|
4523 | this._modules.slice().forEach(module => module.destroy());
|
4524 | this._destroyListeners.forEach(listener => listener());
|
4525 | this._destroyed = true;
|
4526 | }
|
4527 | |
4528 |
|
4529 |
|
4530 |
|
4531 |
|
4532 | bootstrapModuleFactory(moduleFactory) {
|
4533 | return this._bootstrapModuleFactoryWithZone(moduleFactory);
|
4534 | }
|
4535 | |
4536 |
|
4537 |
|
4538 |
|
4539 |
|
4540 |
|
4541 | _bootstrapModuleFactoryWithZone(moduleFactory, ngZone) {
|
4542 |
|
4543 |
|
4544 |
|
4545 |
|
4546 | if (!ngZone)
|
4547 | ngZone = new NgZone({ enableLongStackTrace: isDevMode() });
|
4548 |
|
4549 |
|
4550 | return ngZone.run(() => {
|
4551 | const ngZoneInjector = ReflectiveInjector.resolveAndCreate([{ provide: NgZone, useValue: ngZone }], this.injector);
|
4552 | const moduleRef = (moduleFactory.create(ngZoneInjector));
|
4553 | const exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
|
4554 | if (!exceptionHandler) {
|
4555 | throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
|
4556 | }
|
4557 | moduleRef.onDestroy(() => remove(this._modules, moduleRef));
|
4558 | ((ngZone)).onError.subscribe({ next: (error) => { exceptionHandler.handleError(error); } });
|
4559 | return _callAndReportToErrorHandler(exceptionHandler, () => {
|
4560 | const initStatus = moduleRef.injector.get(ApplicationInitStatus);
|
4561 | return initStatus.donePromise.then(() => {
|
4562 | this._moduleDoBootstrap(moduleRef);
|
4563 | return moduleRef;
|
4564 | });
|
4565 | });
|
4566 | });
|
4567 | }
|
4568 | |
4569 |
|
4570 |
|
4571 |
|
4572 |
|
4573 |
|
4574 | bootstrapModule(moduleType, compilerOptions = []) {
|
4575 | return this._bootstrapModuleWithZone(moduleType, compilerOptions);
|
4576 | }
|
4577 | |
4578 |
|
4579 |
|
4580 |
|
4581 |
|
4582 |
|
4583 |
|
4584 | _bootstrapModuleWithZone(moduleType, compilerOptions = [], ngZone) {
|
4585 | const compilerFactory = this.injector.get(CompilerFactory);
|
4586 | const compiler = compilerFactory.createCompiler(Array.isArray(compilerOptions) ? compilerOptions : [compilerOptions]);
|
4587 | return compiler.compileModuleAsync(moduleType)
|
4588 | .then((moduleFactory) => this._bootstrapModuleFactoryWithZone(moduleFactory, ngZone));
|
4589 | }
|
4590 | |
4591 |
|
4592 |
|
4593 |
|
4594 | _moduleDoBootstrap(moduleRef) {
|
4595 | const appRef = moduleRef.injector.get(ApplicationRef);
|
4596 | if (moduleRef.bootstrapFactories.length > 0) {
|
4597 | moduleRef.bootstrapFactories.forEach(f => appRef.bootstrap(f));
|
4598 | }
|
4599 | else if (moduleRef.instance.ngDoBootstrap) {
|
4600 | moduleRef.instance.ngDoBootstrap(appRef);
|
4601 | }
|
4602 | else {
|
4603 | throw new Error(`The module ${stringify(moduleRef.instance.constructor)} was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` +
|
4604 | `Please define one of these.`);
|
4605 | }
|
4606 | this._modules.push(moduleRef);
|
4607 | }
|
4608 | }
|
4609 | PlatformRef_.decorators = [
|
4610 | { type: Injectable },
|
4611 | ];
|
4612 |
|
4613 |
|
4614 |
|
4615 | PlatformRef_.ctorParameters = () => [
|
4616 | { type: Injector, },
|
4617 | ];
|
4618 |
|
4619 |
|
4620 |
|
4621 |
|
4622 |
|
4623 |
|
4624 | class ApplicationRef {
|
4625 | |
4626 |
|
4627 |
|
4628 |
|
4629 |
|
4630 |
|
4631 |
|
4632 |
|
4633 |
|
4634 |
|
4635 |
|
4636 |
|
4637 |
|
4638 |
|
4639 |
|
4640 |
|
4641 | bootstrap(componentFactory) { }
|
4642 | |
4643 |
|
4644 |
|
4645 |
|
4646 |
|
4647 |
|
4648 |
|
4649 |
|
4650 |
|
4651 |
|
4652 |
|
4653 |
|
4654 | tick() { }
|
4655 | |
4656 |
|
4657 |
|
4658 |
|
4659 |
|
4660 |
|
4661 | componentTypes() { }
|
4662 | |
4663 |
|
4664 |
|
4665 |
|
4666 |
|
4667 | components() { }
|
4668 | |
4669 |
|
4670 |
|
4671 |
|
4672 |
|
4673 |
|
4674 |
|
4675 |
|
4676 | attachView(view) { }
|
4677 | |
4678 |
|
4679 |
|
4680 |
|
4681 |
|
4682 |
|
4683 | detachView(view) { }
|
4684 | |
4685 |
|
4686 |
|
4687 |
|
4688 |
|
4689 | viewCount() { }
|
4690 | |
4691 |
|
4692 |
|
4693 |
|
4694 |
|
4695 | isStable() { }
|
4696 | }
|
4697 |
|
4698 |
|
4699 |
|
4700 |
|
4701 | class ApplicationRef_ extends ApplicationRef {
|
4702 | |
4703 |
|
4704 |
|
4705 |
|
4706 |
|
4707 |
|
4708 |
|
4709 |
|
4710 | constructor(_zone, _console, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
|
4711 | super();
|
4712 | this._zone = _zone;
|
4713 | this._console = _console;
|
4714 | this._injector = _injector;
|
4715 | this._exceptionHandler = _exceptionHandler;
|
4716 | this._componentFactoryResolver = _componentFactoryResolver;
|
4717 | this._initStatus = _initStatus;
|
4718 | this._bootstrapListeners = [];
|
4719 | this._rootComponents = [];
|
4720 | this._rootComponentTypes = [];
|
4721 | this._views = [];
|
4722 | this._runningTick = false;
|
4723 | this._enforceNoNewChanges = false;
|
4724 | this._stable = true;
|
4725 | this._enforceNoNewChanges = isDevMode();
|
4726 | this._zone.onMicrotaskEmpty.subscribe({ next: () => { this._zone.run(() => { this.tick(); }); } });
|
4727 | const isCurrentlyStable = new Observable((observer) => {
|
4728 | this._stable = this._zone.isStable && !this._zone.hasPendingMacrotasks &&
|
4729 | !this._zone.hasPendingMicrotasks;
|
4730 | this._zone.runOutsideAngular(() => {
|
4731 | observer.next(this._stable);
|
4732 | observer.complete();
|
4733 | });
|
4734 | });
|
4735 | const isStable = new Observable((observer) => {
|
4736 | const stableSub = this._zone.onStable.subscribe(() => {
|
4737 | NgZone.assertNotInAngularZone();
|
4738 |
|
4739 |
|
4740 | scheduleMicroTask(() => {
|
4741 | if (!this._stable && !this._zone.hasPendingMacrotasks &&
|
4742 | !this._zone.hasPendingMicrotasks) {
|
4743 | this._stable = true;
|
4744 | observer.next(true);
|
4745 | }
|
4746 | });
|
4747 | });
|
4748 | const unstableSub = this._zone.onUnstable.subscribe(() => {
|
4749 | NgZone.assertInAngularZone();
|
4750 | if (this._stable) {
|
4751 | this._stable = false;
|
4752 | this._zone.runOutsideAngular(() => { observer.next(false); });
|
4753 | }
|
4754 | });
|
4755 | return () => {
|
4756 | stableSub.unsubscribe();
|
4757 | unstableSub.unsubscribe();
|
4758 | };
|
4759 | });
|
4760 | this._isStable = merge(isCurrentlyStable, share.call(isStable));
|
4761 | }
|
4762 | |
4763 |
|
4764 |
|
4765 |
|
4766 | attachView(viewRef) {
|
4767 | const view = ((viewRef));
|
4768 | this._views.push(view);
|
4769 | view.attachToAppRef(this);
|
4770 | }
|
4771 | |
4772 |
|
4773 |
|
4774 |
|
4775 | detachView(viewRef) {
|
4776 | const view = ((viewRef));
|
4777 | remove(this._views, view);
|
4778 | view.detachFromAppRef();
|
4779 | }
|
4780 | |
4781 |
|
4782 |
|
4783 |
|
4784 |
|
4785 | bootstrap(componentOrFactory) {
|
4786 | if (!this._initStatus.done) {
|
4787 | throw new Error('Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
|
4788 | }
|
4789 | let componentFactory;
|
4790 | if (componentOrFactory instanceof ComponentFactory) {
|
4791 | componentFactory = componentOrFactory;
|
4792 | }
|
4793 | else {
|
4794 | componentFactory = ((this._componentFactoryResolver.resolveComponentFactory(componentOrFactory)));
|
4795 | }
|
4796 | this._rootComponentTypes.push(componentFactory.componentType);
|
4797 |
|
4798 | const ngModule = componentFactory instanceof ComponentFactoryBoundToModule ?
|
4799 | null :
|
4800 | this._injector.get(NgModuleRef);
|
4801 | const compRef = componentFactory.create(Injector.NULL, [], componentFactory.selector, ngModule);
|
4802 | compRef.onDestroy(() => { this._unloadComponent(compRef); });
|
4803 | const testability = compRef.injector.get(Testability, null);
|
4804 | if (testability) {
|
4805 | compRef.injector.get(TestabilityRegistry)
|
4806 | .registerApplication(compRef.location.nativeElement, testability);
|
4807 | }
|
4808 | this._loadComponent(compRef);
|
4809 | if (isDevMode()) {
|
4810 | this._console.log(`Angular is running in the development mode. Call enableProdMode() to enable the production mode.`);
|
4811 | }
|
4812 | return compRef;
|
4813 | }
|
4814 | |
4815 |
|
4816 |
|
4817 |
|
4818 | _loadComponent(componentRef) {
|
4819 | this.attachView(componentRef.hostView);
|
4820 | this.tick();
|
4821 | this._rootComponents.push(componentRef);
|
4822 |
|
4823 | const listeners = this._injector.get(APP_BOOTSTRAP_LISTENER, []).concat(this._bootstrapListeners);
|
4824 | listeners.forEach((listener) => listener(componentRef));
|
4825 | }
|
4826 | |
4827 |
|
4828 |
|
4829 |
|
4830 | _unloadComponent(componentRef) {
|
4831 | this.detachView(componentRef.hostView);
|
4832 | remove(this._rootComponents, componentRef);
|
4833 | }
|
4834 | |
4835 |
|
4836 |
|
4837 | tick() {
|
4838 | if (this._runningTick) {
|
4839 | throw new Error('ApplicationRef.tick is called recursively');
|
4840 | }
|
4841 | const scope = ApplicationRef_._tickScope();
|
4842 | try {
|
4843 | this._runningTick = true;
|
4844 | this._views.forEach((view) => view.detectChanges());
|
4845 | if (this._enforceNoNewChanges) {
|
4846 | this._views.forEach((view) => view.checkNoChanges());
|
4847 | }
|
4848 | }
|
4849 | catch (e) {
|
4850 |
|
4851 | this._exceptionHandler.handleError(e);
|
4852 | }
|
4853 | finally {
|
4854 | this._runningTick = false;
|
4855 | wtfLeave(scope);
|
4856 | }
|
4857 | }
|
4858 | |
4859 |
|
4860 |
|
4861 | ngOnDestroy() {
|
4862 |
|
4863 | this._views.slice().forEach((view) => view.destroy());
|
4864 | }
|
4865 | |
4866 |
|
4867 |
|
4868 | get viewCount() { return this._views.length; }
|
4869 | |
4870 |
|
4871 |
|
4872 | get componentTypes() { return this._rootComponentTypes; }
|
4873 | |
4874 |
|
4875 |
|
4876 | get components() { return this._rootComponents; }
|
4877 | |
4878 |
|
4879 |
|
4880 | get isStable() { return this._isStable; }
|
4881 | }
|
4882 |
|
4883 |
|
4884 |
|
4885 | ApplicationRef_._tickScope = wtfCreateScope('ApplicationRef#tick()');
|
4886 | ApplicationRef_.decorators = [
|
4887 | { type: Injectable },
|
4888 | ];
|
4889 |
|
4890 |
|
4891 |
|
4892 | ApplicationRef_.ctorParameters = () => [
|
4893 | { type: NgZone, },
|
4894 | { type: Console, },
|
4895 | { type: Injector, },
|
4896 | { type: ErrorHandler, },
|
4897 | { type: ComponentFactoryResolver, },
|
4898 | { type: ApplicationInitStatus, },
|
4899 | ];
|
4900 |
|
4901 |
|
4902 |
|
4903 |
|
4904 |
|
4905 |
|
4906 | function remove(list, el) {
|
4907 | const index = list.indexOf(el);
|
4908 | if (index > -1) {
|
4909 | list.splice(index, 1);
|
4910 | }
|
4911 | }
|
4912 |
|
4913 |
|
4914 |
|
4915 |
|
4916 |
|
4917 |
|
4918 |
|
4919 |
|
4920 |
|
4921 |
|
4922 |
|
4923 |
|
4924 |
|
4925 |
|
4926 |
|
4927 |
|
4928 |
|
4929 |
|
4930 |
|
4931 |
|
4932 | class RenderComponentType {
|
4933 | |
4934 |
|
4935 |
|
4936 |
|
4937 |
|
4938 |
|
4939 |
|
4940 |
|
4941 | constructor(id, templateUrl, slotCount, encapsulation, styles, animations) {
|
4942 | this.id = id;
|
4943 | this.templateUrl = templateUrl;
|
4944 | this.slotCount = slotCount;
|
4945 | this.encapsulation = encapsulation;
|
4946 | this.styles = styles;
|
4947 | this.animations = animations;
|
4948 | }
|
4949 | }
|
4950 |
|
4951 |
|
4952 |
|
4953 |
|
4954 | class RenderDebugInfo {
|
4955 | |
4956 |
|
4957 |
|
4958 |
|
4959 | injector() { }
|
4960 | |
4961 |
|
4962 |
|
4963 |
|
4964 | component() { }
|
4965 | |
4966 |
|
4967 |
|
4968 |
|
4969 | providerTokens() { }
|
4970 | |
4971 |
|
4972 |
|
4973 |
|
4974 | references() { }
|
4975 | |
4976 |
|
4977 |
|
4978 |
|
4979 | context() { }
|
4980 | |
4981 |
|
4982 |
|
4983 |
|
4984 | source() { }
|
4985 | }
|
4986 |
|
4987 |
|
4988 |
|
4989 |
|
4990 | class Renderer {
|
4991 | |
4992 |
|
4993 |
|
4994 |
|
4995 |
|
4996 |
|
4997 | selectRootElement(selectorOrNode, debugInfo) { }
|
4998 | |
4999 |
|
5000 |
|
5001 |
|
5002 |
|
5003 |
|
5004 |
|
5005 | createElement(parentElement, name, debugInfo) { }
|
5006 | |
5007 |
|
5008 |
|
5009 |
|
5010 |
|
5011 | createViewRoot(hostElement) { }
|
5012 | |
5013 |
|
5014 |
|
5015 |
|
5016 |
|
5017 |
|
5018 | createTemplateAnchor(parentElement, debugInfo) { }
|
5019 | |
5020 |
|
5021 |
|
5022 |
|
5023 |
|
5024 |
|
5025 |
|
5026 | createText(parentElement, value, debugInfo) { }
|
5027 | |
5028 |
|
5029 |
|
5030 |
|
5031 |
|
5032 |
|
5033 | projectNodes(parentElement, nodes) { }
|
5034 | |
5035 |
|
5036 |
|
5037 |
|
5038 |
|
5039 |
|
5040 | attachViewAfter(node, viewRootNodes) { }
|
5041 | |
5042 |
|
5043 |
|
5044 |
|
5045 |
|
5046 | detachView(viewRootNodes) { }
|
5047 | |
5048 |
|
5049 |
|
5050 |
|
5051 |
|
5052 |
|
5053 | destroyView(hostElement, viewAllNodes) { }
|
5054 | |
5055 |
|
5056 |
|
5057 |
|
5058 |
|
5059 |
|
5060 |
|
5061 | listen(renderElement, name, callback) { }
|
5062 | |
5063 |
|
5064 |
|
5065 |
|
5066 |
|
5067 |
|
5068 |
|
5069 | listenGlobal(target, name, callback) { }
|
5070 | |
5071 |
|
5072 |
|
5073 |
|
5074 |
|
5075 |
|
5076 |
|
5077 | setElementProperty(renderElement, propertyName, propertyValue) { }
|
5078 | |
5079 |
|
5080 |
|
5081 |
|
5082 |
|
5083 |
|
5084 |
|
5085 | setElementAttribute(renderElement, attributeName, attributeValue) { }
|
5086 | |
5087 |
|
5088 |
|
5089 |
|
5090 |
|
5091 |
|
5092 |
|
5093 |
|
5094 | setBindingDebugInfo(renderElement, propertyName, propertyValue) { }
|
5095 | |
5096 |
|
5097 |
|
5098 |
|
5099 |
|
5100 |
|
5101 |
|
5102 | setElementClass(renderElement, className, isAdd) { }
|
5103 | |
5104 |
|
5105 |
|
5106 |
|
5107 |
|
5108 |
|
5109 |
|
5110 | setElementStyle(renderElement, styleName, styleValue) { }
|
5111 | |
5112 |
|
5113 |
|
5114 |
|
5115 |
|
5116 |
|
5117 |
|
5118 | invokeElementMethod(renderElement, methodName, args) { }
|
5119 | |
5120 |
|
5121 |
|
5122 |
|
5123 |
|
5124 |
|
5125 | setText(renderNode, text) { }
|
5126 | |
5127 |
|
5128 |
|
5129 |
|
5130 |
|
5131 |
|
5132 |
|
5133 |
|
5134 |
|
5135 |
|
5136 |
|
5137 | animate(element, startingStyles, keyframes, duration, delay, easing, previousPlayers) { }
|
5138 | }
|
5139 | const Renderer2Interceptor = new InjectionToken('Renderer2Interceptor');
|
5140 |
|
5141 |
|
5142 |
|
5143 |
|
5144 |
|
5145 |
|
5146 |
|
5147 |
|
5148 |
|
5149 |
|
5150 |
|
5151 |
|
5152 |
|
5153 |
|
5154 |
|
5155 | class RootRenderer {
|
5156 | |
5157 |
|
5158 |
|
5159 |
|
5160 |
|
5161 | renderComponent(componentType) { }
|
5162 | }
|
5163 |
|
5164 |
|
5165 |
|
5166 |
|
5167 | class RendererFactory2 {
|
5168 | |
5169 |
|
5170 |
|
5171 |
|
5172 |
|
5173 |
|
5174 | createRenderer(hostElement, type) { }
|
5175 | }
|
5176 | let RendererStyleFlags2 = {};
|
5177 | RendererStyleFlags2.Important = 1;
|
5178 | RendererStyleFlags2.DashCase = 2;
|
5179 | RendererStyleFlags2[RendererStyleFlags2.Important] = "Important";
|
5180 | RendererStyleFlags2[RendererStyleFlags2.DashCase] = "DashCase";
|
5181 |
|
5182 |
|
5183 |
|
5184 |
|
5185 | class Renderer2 {
|
5186 | |
5187 |
|
5188 |
|
5189 |
|
5190 |
|
5191 |
|
5192 | data() { }
|
5193 | |
5194 |
|
5195 |
|
5196 |
|
5197 | destroy() { }
|
5198 | |
5199 |
|
5200 |
|
5201 |
|
5202 |
|
5203 |
|
5204 | createElement(name, namespace) { }
|
5205 | |
5206 |
|
5207 |
|
5208 |
|
5209 |
|
5210 | createComment(value) { }
|
5211 | |
5212 |
|
5213 |
|
5214 |
|
5215 |
|
5216 | createText(value) { }
|
5217 | |
5218 |
|
5219 |
|
5220 |
|
5221 |
|
5222 |
|
5223 | appendChild(parent, newChild) { }
|
5224 | |
5225 |
|
5226 |
|
5227 |
|
5228 |
|
5229 |
|
5230 |
|
5231 | insertBefore(parent, newChild, refChild) { }
|
5232 | |
5233 |
|
5234 |
|
5235 |
|
5236 |
|
5237 |
|
5238 | removeChild(parent, oldChild) { }
|
5239 | |
5240 |
|
5241 |
|
5242 |
|
5243 |
|
5244 | selectRootElement(selectorOrNode) { }
|
5245 | |
5246 |
|
5247 |
|
5248 |
|
5249 |
|
5250 |
|
5251 |
|
5252 |
|
5253 | parentNode(node) { }
|
5254 | |
5255 |
|
5256 |
|
5257 |
|
5258 |
|
5259 |
|
5260 |
|
5261 |
|
5262 | nextSibling(node) { }
|
5263 | |
5264 |
|
5265 |
|
5266 |
|
5267 |
|
5268 |
|
5269 |
|
5270 |
|
5271 | setAttribute(el, name, value, namespace) { }
|
5272 | |
5273 |
|
5274 |
|
5275 |
|
5276 |
|
5277 |
|
5278 |
|
5279 | removeAttribute(el, name, namespace) { }
|
5280 | |
5281 |
|
5282 |
|
5283 |
|
5284 |
|
5285 |
|
5286 | addClass(el, name) { }
|
5287 | |
5288 |
|
5289 |
|
5290 |
|
5291 |
|
5292 |
|
5293 | removeClass(el, name) { }
|
5294 | |
5295 |
|
5296 |
|
5297 |
|
5298 |
|
5299 |
|
5300 |
|
5301 |
|
5302 | setStyle(el, style, value, flags) { }
|
5303 | |
5304 |
|
5305 |
|
5306 |
|
5307 |
|
5308 |
|
5309 |
|
5310 | removeStyle(el, style, flags) { }
|
5311 | |
5312 |
|
5313 |
|
5314 |
|
5315 |
|
5316 |
|
5317 |
|
5318 | setProperty(el, name, value) { }
|
5319 | |
5320 |
|
5321 |
|
5322 |
|
5323 |
|
5324 |
|
5325 | setValue(node, value) { }
|
5326 | |
5327 |
|
5328 |
|
5329 |
|
5330 |
|
5331 |
|
5332 |
|
5333 | listen(target, eventName, callback) { }
|
5334 | }
|
5335 |
|
5336 |
|
5337 |
|
5338 |
|
5339 |
|
5340 |
|
5341 |
|
5342 |
|
5343 |
|
5344 |
|
5345 | class ElementRef {
|
5346 | |
5347 |
|
5348 |
|
5349 | constructor(nativeElement) { this.nativeElement = nativeElement; }
|
5350 | }
|
5351 |
|
5352 |
|
5353 |
|
5354 |
|
5355 |
|
5356 |
|
5357 |
|
5358 |
|
5359 |
|
5360 |
|
5361 |
|
5362 |
|
5363 |
|
5364 | class NgModuleFactoryLoader {
|
5365 | |
5366 |
|
5367 |
|
5368 |
|
5369 |
|
5370 | load(path) { }
|
5371 | }
|
5372 | let moduleFactories = new Map();
|
5373 |
|
5374 |
|
5375 |
|
5376 |
|
5377 |
|
5378 |
|
5379 |
|
5380 | function registerModuleFactory(id, factory) {
|
5381 | const existing = moduleFactories.get(id);
|
5382 | if (existing) {
|
5383 | throw new Error(`Duplicate module registered for ${id} - ${existing.moduleType.name} vs ${factory.moduleType.name}`);
|
5384 | }
|
5385 | moduleFactories.set(id, factory);
|
5386 | }
|
5387 |
|
5388 |
|
5389 |
|
5390 |
|
5391 |
|
5392 |
|
5393 |
|
5394 |
|
5395 |
|
5396 |
|
5397 |
|
5398 |
|
5399 | function getModuleFactory(id) {
|
5400 | const factory = moduleFactories.get(id);
|
5401 | if (!factory)
|
5402 | throw new Error(`No module with ID ${id} loaded`);
|
5403 | return factory;
|
5404 | }
|
5405 |
|
5406 |
|
5407 |
|
5408 |
|
5409 |
|
5410 |
|
5411 |
|
5412 |
|
5413 |
|
5414 |
|
5415 |
|
5416 |
|
5417 |
|
5418 |
|
5419 |
|
5420 |
|
5421 |
|
5422 |
|
5423 |
|
5424 |
|
5425 |
|
5426 |
|
5427 |
|
5428 |
|
5429 |
|
5430 |
|
5431 |
|
5432 |
|
5433 |
|
5434 |
|
5435 |
|
5436 |
|
5437 | class QueryList {
|
5438 | constructor() {
|
5439 | this._dirty = true;
|
5440 | this._results = [];
|
5441 | this._emitter = new EventEmitter();
|
5442 | }
|
5443 | |
5444 |
|
5445 |
|
5446 | get changes() { return this._emitter; }
|
5447 | |
5448 |
|
5449 |
|
5450 | get length() { return this._results.length; }
|
5451 | |
5452 |
|
5453 |
|
5454 | get first() { return this._results[0]; }
|
5455 | |
5456 |
|
5457 |
|
5458 | get last() { return this._results[this.length - 1]; }
|
5459 | |
5460 |
|
5461 |
|
5462 |
|
5463 |
|
5464 |
|
5465 |
|
5466 | map(fn) { return this._results.map(fn); }
|
5467 | |
5468 |
|
5469 |
|
5470 |
|
5471 |
|
5472 |
|
5473 | filter(fn) {
|
5474 | return this._results.filter(fn);
|
5475 | }
|
5476 | |
5477 |
|
5478 |
|
5479 |
|
5480 |
|
5481 |
|
5482 | find(fn) {
|
5483 | return this._results.find(fn);
|
5484 | }
|
5485 | |
5486 |
|
5487 |
|
5488 |
|
5489 |
|
5490 |
|
5491 |
|
5492 |
|
5493 | reduce(fn, init) {
|
5494 | return this._results.reduce(fn, init);
|
5495 | }
|
5496 | |
5497 |
|
5498 |
|
5499 |
|
5500 |
|
5501 |
|
5502 | forEach(fn) { this._results.forEach(fn); }
|
5503 | |
5504 |
|
5505 |
|
5506 |
|
5507 |
|
5508 |
|
5509 | some(fn) {
|
5510 | return this._results.some(fn);
|
5511 | }
|
5512 | |
5513 |
|
5514 |
|
5515 | toArray() { return this._results.slice(); }
|
5516 | |
5517 |
|
5518 |
|
5519 | [getSymbolIterator()]() { return ((this._results))[getSymbolIterator()](); }
|
5520 | |
5521 |
|
5522 |
|
5523 | toString() { return this._results.toString(); }
|
5524 | |
5525 |
|
5526 |
|
5527 |
|
5528 | reset(res) {
|
5529 | this._results = flatten(res);
|
5530 | this._dirty = false;
|
5531 | }
|
5532 | |
5533 |
|
5534 |
|
5535 | notifyOnChanges() { this._emitter.emit(this); }
|
5536 | |
5537 |
|
5538 |
|
5539 |
|
5540 | setDirty() { this._dirty = true; }
|
5541 | |
5542 |
|
5543 |
|
5544 |
|
5545 | get dirty() { return this._dirty; }
|
5546 | }
|
5547 |
|
5548 |
|
5549 |
|
5550 |
|
5551 |
|
5552 | function flatten(list) {
|
5553 | return list.reduce((flat, item) => {
|
5554 | const flatItem = Array.isArray(item) ? flatten(item) : item;
|
5555 | return ((flat)).concat(flatItem);
|
5556 | }, []);
|
5557 | }
|
5558 |
|
5559 |
|
5560 |
|
5561 |
|
5562 |
|
5563 |
|
5564 |
|
5565 |
|
5566 | const _SEPARATOR = '#';
|
5567 | const FACTORY_CLASS_SUFFIX = 'NgFactory';
|
5568 |
|
5569 |
|
5570 |
|
5571 |
|
5572 |
|
5573 |
|
5574 |
|
5575 | class SystemJsNgModuleLoaderConfig {
|
5576 | }
|
5577 | const DEFAULT_CONFIG = {
|
5578 | factoryPathPrefix: '',
|
5579 | factoryPathSuffix: '.ngfactory',
|
5580 | };
|
5581 |
|
5582 |
|
5583 |
|
5584 |
|
5585 | class SystemJsNgModuleLoader {
|
5586 | |
5587 |
|
5588 |
|
5589 |
|
5590 | constructor(_compiler, config) {
|
5591 | this._compiler = _compiler;
|
5592 | this._config = config || DEFAULT_CONFIG;
|
5593 | }
|
5594 | |
5595 |
|
5596 |
|
5597 |
|
5598 | load(path) {
|
5599 | const offlineMode = this._compiler instanceof Compiler;
|
5600 | return offlineMode ? this.loadFactory(path) : this.loadAndCompile(path);
|
5601 | }
|
5602 | |
5603 |
|
5604 |
|
5605 |
|
5606 | loadAndCompile(path) {
|
5607 | let [module, exportName] = path.split(_SEPARATOR);
|
5608 | if (exportName === undefined) {
|
5609 | exportName = 'default';
|
5610 | }
|
5611 | return System.import(module)
|
5612 | .then((module) => module[exportName])
|
5613 | .then((type) => checkNotEmpty(type, module, exportName))
|
5614 | .then((type) => this._compiler.compileModuleAsync(type));
|
5615 | }
|
5616 | |
5617 |
|
5618 |
|
5619 |
|
5620 | loadFactory(path) {
|
5621 | let [module, exportName] = path.split(_SEPARATOR);
|
5622 | let factoryClassSuffix = FACTORY_CLASS_SUFFIX;
|
5623 | if (exportName === undefined) {
|
5624 | exportName = 'default';
|
5625 | factoryClassSuffix = '';
|
5626 | }
|
5627 | return System.import(this._config.factoryPathPrefix + module + this._config.factoryPathSuffix)
|
5628 | .then((module) => module[exportName + factoryClassSuffix])
|
5629 | .then((factory) => checkNotEmpty(factory, module, exportName));
|
5630 | }
|
5631 | }
|
5632 | SystemJsNgModuleLoader.decorators = [
|
5633 | { type: Injectable },
|
5634 | ];
|
5635 |
|
5636 |
|
5637 |
|
5638 | SystemJsNgModuleLoader.ctorParameters = () => [
|
5639 | { type: Compiler, },
|
5640 | { type: SystemJsNgModuleLoaderConfig, decorators: [{ type: Optional },] },
|
5641 | ];
|
5642 |
|
5643 |
|
5644 |
|
5645 |
|
5646 |
|
5647 |
|
5648 | function checkNotEmpty(value, modulePath, exportName) {
|
5649 | if (!value) {
|
5650 | throw new Error(`Cannot find '${exportName}' in '${modulePath}'`);
|
5651 | }
|
5652 | return value;
|
5653 | }
|
5654 |
|
5655 |
|
5656 |
|
5657 |
|
5658 |
|
5659 |
|
5660 |
|
5661 |
|
5662 |
|
5663 |
|
5664 |
|
5665 |
|
5666 |
|
5667 |
|
5668 |
|
5669 |
|
5670 |
|
5671 |
|
5672 |
|
5673 |
|
5674 |
|
5675 |
|
5676 | class TemplateRef {
|
5677 | |
5678 |
|
5679 |
|
5680 |
|
5681 | elementRef() { }
|
5682 | |
5683 |
|
5684 |
|
5685 |
|
5686 |
|
5687 | createEmbeddedView(context) { }
|
5688 | }
|
5689 |
|
5690 |
|
5691 |
|
5692 |
|
5693 |
|
5694 |
|
5695 |
|
5696 |
|
5697 |
|
5698 |
|
5699 |
|
5700 |
|
5701 |
|
5702 |
|
5703 |
|
5704 |
|
5705 |
|
5706 |
|
5707 |
|
5708 |
|
5709 |
|
5710 |
|
5711 |
|
5712 |
|
5713 |
|
5714 |
|
5715 |
|
5716 | class ViewContainerRef {
|
5717 | |
5718 |
|
5719 |
|
5720 |
|
5721 |
|
5722 |
|
5723 | element() { }
|
5724 | |
5725 |
|
5726 |
|
5727 |
|
5728 | injector() { }
|
5729 | |
5730 |
|
5731 |
|
5732 |
|
5733 | parentInjector() { }
|
5734 | |
5735 |
|
5736 |
|
5737 |
|
5738 |
|
5739 | clear() { }
|
5740 | |
5741 |
|
5742 |
|
5743 |
|
5744 |
|
5745 |
|
5746 | get(index) { }
|
5747 | |
5748 |
|
5749 |
|
5750 |
|
5751 |
|
5752 | length() { }
|
5753 | |
5754 |
|
5755 |
|
5756 |
|
5757 |
|
5758 |
|
5759 |
|
5760 |
|
5761 |
|
5762 |
|
5763 |
|
5764 |
|
5765 |
|
5766 |
|
5767 | createEmbeddedView(templateRef, context, index) { }
|
5768 | |
5769 |
|
5770 |
|
5771 |
|
5772 |
|
5773 |
|
5774 |
|
5775 |
|
5776 |
|
5777 |
|
5778 |
|
5779 |
|
5780 |
|
5781 |
|
5782 |
|
5783 |
|
5784 |
|
5785 |
|
5786 |
|
5787 |
|
5788 |
|
5789 | createComponent(componentFactory, index, injector, projectableNodes, ngModule) { }
|
5790 | |
5791 |
|
5792 |
|
5793 |
|
5794 |
|
5795 |
|
5796 |
|
5797 |
|
5798 |
|
5799 |
|
5800 |
|
5801 | insert(viewRef, index) { }
|
5802 | |
5803 |
|
5804 |
|
5805 |
|
5806 |
|
5807 |
|
5808 |
|
5809 |
|
5810 |
|
5811 | move(viewRef, currentIndex) { }
|
5812 | |
5813 |
|
5814 |
|
5815 |
|
5816 |
|
5817 |
|
5818 |
|
5819 | indexOf(viewRef) { }
|
5820 | |
5821 |
|
5822 |
|
5823 |
|
5824 |
|
5825 |
|
5826 |
|
5827 |
|
5828 | remove(index) { }
|
5829 | |
5830 |
|
5831 |
|
5832 |
|
5833 |
|
5834 |
|
5835 |
|
5836 |
|
5837 | detach(index) { }
|
5838 | }
|
5839 |
|
5840 |
|
5841 |
|
5842 |
|
5843 |
|
5844 | class ChangeDetectorRef {
|
5845 | |
5846 |
|
5847 |
|
5848 |
|
5849 |
|
5850 |
|
5851 |
|
5852 |
|
5853 |
|
5854 |
|
5855 |
|
5856 |
|
5857 |
|
5858 |
|
5859 |
|
5860 |
|
5861 |
|
5862 |
|
5863 |
|
5864 |
|
5865 |
|
5866 |
|
5867 |
|
5868 |
|
5869 |
|
5870 |
|
5871 |
|
5872 |
|
5873 |
|
5874 |
|
5875 |
|
5876 |
|
5877 |
|
5878 |
|
5879 |
|
5880 |
|
5881 |
|
5882 |
|
5883 | markForCheck() { }
|
5884 | |
5885 |
|
5886 |
|
5887 |
|
5888 |
|
5889 |
|
5890 |
|
5891 |
|
5892 |
|
5893 |
|
5894 |
|
5895 |
|
5896 |
|
5897 |
|
5898 |
|
5899 |
|
5900 |
|
5901 |
|
5902 |
|
5903 |
|
5904 |
|
5905 |
|
5906 |
|
5907 |
|
5908 |
|
5909 |
|
5910 |
|
5911 |
|
5912 |
|
5913 |
|
5914 |
|
5915 |
|
5916 |
|
5917 |
|
5918 |
|
5919 |
|
5920 |
|
5921 |
|
5922 |
|
5923 |
|
5924 |
|
5925 |
|
5926 |
|
5927 |
|
5928 |
|
5929 |
|
5930 |
|
5931 |
|
5932 |
|
5933 |
|
5934 |
|
5935 |
|
5936 |
|
5937 |
|
5938 |
|
5939 | detach() { }
|
5940 | |
5941 |
|
5942 |
|
5943 |
|
5944 |
|
5945 |
|
5946 |
|
5947 |
|
5948 |
|
5949 |
|
5950 |
|
5951 |
|
5952 |
|
5953 |
|
5954 |
|
5955 |
|
5956 |
|
5957 |
|
5958 |
|
5959 |
|
5960 |
|
5961 |
|
5962 |
|
5963 |
|
5964 | detectChanges() { }
|
5965 | |
5966 |
|
5967 |
|
5968 |
|
5969 |
|
5970 |
|
5971 |
|
5972 |
|
5973 | checkNoChanges() { }
|
5974 | |
5975 |
|
5976 |
|
5977 |
|
5978 |
|
5979 |
|
5980 |
|
5981 |
|
5982 |
|
5983 |
|
5984 |
|
5985 |
|
5986 |
|
5987 |
|
5988 |
|
5989 |
|
5990 |
|
5991 |
|
5992 |
|
5993 |
|
5994 |
|
5995 |
|
5996 |
|
5997 |
|
5998 |
|
5999 |
|
6000 |
|
6001 |
|
6002 |
|
6003 |
|
6004 |
|
6005 |
|
6006 |
|
6007 |
|
6008 |
|
6009 |
|
6010 |
|
6011 |
|
6012 |
|
6013 |
|
6014 |
|
6015 |
|
6016 |
|
6017 |
|
6018 |
|
6019 |
|
6020 |
|
6021 |
|
6022 |
|
6023 |
|
6024 |
|
6025 |
|
6026 |
|
6027 |
|
6028 |
|
6029 |
|
6030 | reattach() { }
|
6031 | }
|
6032 |
|
6033 |
|
6034 |
|
6035 |
|
6036 |
|
6037 |
|
6038 |
|
6039 |
|
6040 |
|
6041 |
|
6042 |
|
6043 |
|
6044 | class ViewRef extends ChangeDetectorRef {
|
6045 | |
6046 |
|
6047 |
|
6048 |
|
6049 |
|
6050 | destroy() { }
|
6051 | |
6052 |
|
6053 |
|
6054 |
|
6055 | destroyed() { }
|
6056 | |
6057 |
|
6058 |
|
6059 |
|
6060 |
|
6061 | onDestroy(callback) { }
|
6062 | }
|
6063 |
|
6064 |
|
6065 |
|
6066 |
|
6067 |
|
6068 |
|
6069 |
|
6070 |
|
6071 |
|
6072 |
|
6073 |
|
6074 |
|
6075 |
|
6076 |
|
6077 |
|
6078 |
|
6079 |
|
6080 |
|
6081 |
|
6082 |
|
6083 |
|
6084 |
|
6085 |
|
6086 |
|
6087 |
|
6088 |
|
6089 |
|
6090 |
|
6091 |
|
6092 |
|
6093 |
|
6094 |
|
6095 |
|
6096 |
|
6097 |
|
6098 |
|
6099 |
|
6100 |
|
6101 |
|
6102 |
|
6103 |
|
6104 |
|
6105 |
|
6106 |
|
6107 |
|
6108 |
|
6109 |
|
6110 |
|
6111 |
|
6112 |
|
6113 |
|
6114 |
|
6115 |
|
6116 |
|
6117 |
|
6118 | class EmbeddedViewRef extends ViewRef {
|
6119 | |
6120 |
|
6121 |
|
6122 |
|
6123 | context() { }
|
6124 | |
6125 |
|
6126 |
|
6127 |
|
6128 | rootNodes() { }
|
6129 | }
|
6130 |
|
6131 |
|
6132 |
|
6133 |
|
6134 |
|
6135 |
|
6136 |
|
6137 |
|
6138 |
|
6139 |
|
6140 |
|
6141 |
|
6142 |
|
6143 |
|
6144 |
|
6145 |
|
6146 |
|
6147 | class EventListener {
|
6148 | |
6149 |
|
6150 |
|
6151 |
|
6152 | constructor(name, callback) {
|
6153 | this.name = name;
|
6154 | this.callback = callback;
|
6155 | }
|
6156 | ;
|
6157 | }
|
6158 |
|
6159 |
|
6160 |
|
6161 | class DebugNode {
|
6162 | |
6163 |
|
6164 |
|
6165 |
|
6166 |
|
6167 | constructor(nativeNode, parent, _debugContext) {
|
6168 | this._debugContext = _debugContext;
|
6169 | this.nativeNode = nativeNode;
|
6170 | if (parent && parent instanceof DebugElement) {
|
6171 | parent.addChild(this);
|
6172 | }
|
6173 | else {
|
6174 | this.parent = null;
|
6175 | }
|
6176 | this.listeners = [];
|
6177 | }
|
6178 | |
6179 |
|
6180 |
|
6181 | get injector() { return this._debugContext.injector; }
|
6182 | |
6183 |
|
6184 |
|
6185 | get componentInstance() { return this._debugContext.component; }
|
6186 | |
6187 |
|
6188 |
|
6189 | get context() { return this._debugContext.context; }
|
6190 | |
6191 |
|
6192 |
|
6193 | get references() { return this._debugContext.references; }
|
6194 | |
6195 |
|
6196 |
|
6197 | get providerTokens() { return this._debugContext.providerTokens; }
|
6198 | |
6199 |
|
6200 |
|
6201 |
|
6202 | get source() { return 'Deprecated since v4'; }
|
6203 | }
|
6204 |
|
6205 |
|
6206 |
|
6207 | class DebugElement extends DebugNode {
|
6208 | |
6209 |
|
6210 |
|
6211 |
|
6212 |
|
6213 | constructor(nativeNode, parent, _debugContext) {
|
6214 | super(nativeNode, parent, _debugContext);
|
6215 | this.properties = {};
|
6216 | this.attributes = {};
|
6217 | this.classes = {};
|
6218 | this.styles = {};
|
6219 | this.childNodes = [];
|
6220 | this.nativeElement = nativeNode;
|
6221 | }
|
6222 | |
6223 |
|
6224 |
|
6225 |
|
6226 | addChild(child) {
|
6227 | if (child) {
|
6228 | this.childNodes.push(child);
|
6229 | child.parent = this;
|
6230 | }
|
6231 | }
|
6232 | |
6233 |
|
6234 |
|
6235 |
|
6236 | removeChild(child) {
|
6237 | const childIndex = this.childNodes.indexOf(child);
|
6238 | if (childIndex !== -1) {
|
6239 | child.parent = null;
|
6240 | this.childNodes.splice(childIndex, 1);
|
6241 | }
|
6242 | }
|
6243 | |
6244 |
|
6245 |
|
6246 |
|
6247 |
|
6248 | insertChildrenAfter(child, newChildren) {
|
6249 | const siblingIndex = this.childNodes.indexOf(child);
|
6250 | if (siblingIndex !== -1) {
|
6251 | this.childNodes.splice(siblingIndex + 1, 0, ...newChildren);
|
6252 | newChildren.forEach(c => {
|
6253 | if (c.parent) {
|
6254 | c.parent.removeChild(c);
|
6255 | }
|
6256 | c.parent = this;
|
6257 | });
|
6258 | }
|
6259 | }
|
6260 | |
6261 |
|
6262 |
|
6263 |
|
6264 |
|
6265 | insertBefore(refChild, newChild) {
|
6266 | const refIndex = this.childNodes.indexOf(refChild);
|
6267 | if (refIndex === -1) {
|
6268 | this.addChild(newChild);
|
6269 | }
|
6270 | else {
|
6271 | if (newChild.parent) {
|
6272 | newChild.parent.removeChild(newChild);
|
6273 | }
|
6274 | newChild.parent = this;
|
6275 | this.childNodes.splice(refIndex, 0, newChild);
|
6276 | }
|
6277 | }
|
6278 | |
6279 |
|
6280 |
|
6281 |
|
6282 | query(predicate) {
|
6283 | const results = this.queryAll(predicate);
|
6284 | return results[0] || null;
|
6285 | }
|
6286 | |
6287 |
|
6288 |
|
6289 |
|
6290 | queryAll(predicate) {
|
6291 | const matches = [];
|
6292 | _queryElementChildren(this, predicate, matches);
|
6293 | return matches;
|
6294 | }
|
6295 | |
6296 |
|
6297 |
|
6298 |
|
6299 | queryAllNodes(predicate) {
|
6300 | const matches = [];
|
6301 | _queryNodeChildren(this, predicate, matches);
|
6302 | return matches;
|
6303 | }
|
6304 | |
6305 |
|
6306 |
|
6307 | get children() {
|
6308 | return (this.childNodes.filter((node) => node instanceof DebugElement));
|
6309 | }
|
6310 | |
6311 |
|
6312 |
|
6313 |
|
6314 |
|
6315 | triggerEventHandler(eventName, eventObj) {
|
6316 | this.listeners.forEach((listener) => {
|
6317 | if (listener.name == eventName) {
|
6318 | listener.callback(eventObj);
|
6319 | }
|
6320 | });
|
6321 | }
|
6322 | }
|
6323 |
|
6324 |
|
6325 |
|
6326 |
|
6327 |
|
6328 | function asNativeElements(debugEls) {
|
6329 | return debugEls.map((el) => el.nativeElement);
|
6330 | }
|
6331 |
|
6332 |
|
6333 |
|
6334 |
|
6335 |
|
6336 |
|
6337 | function _queryElementChildren(element, predicate, matches) {
|
6338 | element.childNodes.forEach(node => {
|
6339 | if (node instanceof DebugElement) {
|
6340 | if (predicate(node)) {
|
6341 | matches.push(node);
|
6342 | }
|
6343 | _queryElementChildren(node, predicate, matches);
|
6344 | }
|
6345 | });
|
6346 | }
|
6347 |
|
6348 |
|
6349 |
|
6350 |
|
6351 |
|
6352 |
|
6353 | function _queryNodeChildren(parentNode, predicate, matches) {
|
6354 | if (parentNode instanceof DebugElement) {
|
6355 | parentNode.childNodes.forEach(node => {
|
6356 | if (predicate(node)) {
|
6357 | matches.push(node);
|
6358 | }
|
6359 | if (node instanceof DebugElement) {
|
6360 | _queryNodeChildren(node, predicate, matches);
|
6361 | }
|
6362 | });
|
6363 | }
|
6364 | }
|
6365 |
|
6366 | const _nativeNodeToDebugNode = new Map();
|
6367 |
|
6368 |
|
6369 |
|
6370 |
|
6371 |
|
6372 | function getDebugNode(nativeNode) {
|
6373 | return _nativeNodeToDebugNode.get(nativeNode) || null;
|
6374 | }
|
6375 |
|
6376 |
|
6377 |
|
6378 |
|
6379 |
|
6380 |
|
6381 |
|
6382 |
|
6383 | function indexDebugNode(node) {
|
6384 | _nativeNodeToDebugNode.set(node.nativeNode, node);
|
6385 | }
|
6386 |
|
6387 |
|
6388 |
|
6389 |
|
6390 | function removeDebugNodeFromIndex(node) {
|
6391 | _nativeNodeToDebugNode.delete(node.nativeNode);
|
6392 | }
|
6393 |
|
6394 |
|
6395 |
|
6396 |
|
6397 |
|
6398 |
|
6399 |
|
6400 |
|
6401 |
|
6402 |
|
6403 |
|
6404 |
|
6405 |
|
6406 | function devModeEqual(a, b) {
|
6407 | const isListLikeIterableA = isListLikeIterable(a);
|
6408 | const isListLikeIterableB = isListLikeIterable(b);
|
6409 | if (isListLikeIterableA && isListLikeIterableB) {
|
6410 | return areIterablesEqual(a, b, devModeEqual);
|
6411 | }
|
6412 | else {
|
6413 | const isAObject = a && (typeof a === 'object' || typeof a === 'function');
|
6414 | const isBObject = b && (typeof b === 'object' || typeof b === 'function');
|
6415 | if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
|
6416 | return true;
|
6417 | }
|
6418 | else {
|
6419 | return looseIdentical(a, b);
|
6420 | }
|
6421 | }
|
6422 | }
|
6423 |
|
6424 |
|
6425 |
|
6426 |
|
6427 |
|
6428 |
|
6429 |
|
6430 |
|
6431 |
|
6432 |
|
6433 |
|
6434 |
|
6435 |
|
6436 |
|
6437 |
|
6438 |
|
6439 |
|
6440 |
|
6441 |
|
6442 | class WrappedValue {
|
6443 | |
6444 |
|
6445 |
|
6446 | constructor(wrapped) {
|
6447 | this.wrapped = wrapped;
|
6448 | }
|
6449 | |
6450 |
|
6451 |
|
6452 |
|
6453 | static wrap(value) { return new WrappedValue(value); }
|
6454 | }
|
6455 |
|
6456 |
|
6457 |
|
6458 | class ValueUnwrapper {
|
6459 | constructor() {
|
6460 | this.hasWrappedValue = false;
|
6461 | }
|
6462 | |
6463 |
|
6464 |
|
6465 |
|
6466 | unwrap(value) {
|
6467 | if (value instanceof WrappedValue) {
|
6468 | this.hasWrappedValue = true;
|
6469 | return value.wrapped;
|
6470 | }
|
6471 | return value;
|
6472 | }
|
6473 | |
6474 |
|
6475 |
|
6476 | reset() { this.hasWrappedValue = false; }
|
6477 | }
|
6478 |
|
6479 |
|
6480 |
|
6481 |
|
6482 | class SimpleChange {
|
6483 | |
6484 |
|
6485 |
|
6486 |
|
6487 |
|
6488 | constructor(previousValue, currentValue, firstChange) {
|
6489 | this.previousValue = previousValue;
|
6490 | this.currentValue = currentValue;
|
6491 | this.firstChange = firstChange;
|
6492 | }
|
6493 | |
6494 |
|
6495 |
|
6496 |
|
6497 | isFirstChange() { return this.firstChange; }
|
6498 | }
|
6499 |
|
6500 |
|
6501 |
|
6502 |
|
6503 | function isListLikeIterable(obj) {
|
6504 | if (!isJsObject(obj))
|
6505 | return false;
|
6506 | return Array.isArray(obj) ||
|
6507 | (!(obj instanceof Map) &&
|
6508 | getSymbolIterator() in obj);
|
6509 | }
|
6510 |
|
6511 |
|
6512 |
|
6513 |
|
6514 |
|
6515 |
|
6516 | function areIterablesEqual(a, b, comparator) {
|
6517 | const iterator1 = a[getSymbolIterator()]();
|
6518 | const iterator2 = b[getSymbolIterator()]();
|
6519 | while (true) {
|
6520 | const item1 = iterator1.next();
|
6521 | const item2 = iterator2.next();
|
6522 | if (item1.done && item2.done)
|
6523 | return true;
|
6524 | if (item1.done || item2.done)
|
6525 | return false;
|
6526 | if (!comparator(item1.value, item2.value))
|
6527 | return false;
|
6528 | }
|
6529 | }
|
6530 |
|
6531 |
|
6532 |
|
6533 |
|
6534 |
|
6535 | function iterateListLike(obj, fn) {
|
6536 | if (Array.isArray(obj)) {
|
6537 | for (let i = 0; i < obj.length; i++) {
|
6538 | fn(obj[i]);
|
6539 | }
|
6540 | }
|
6541 | else {
|
6542 | const iterator = obj[getSymbolIterator()]();
|
6543 | let item;
|
6544 | while (!((item = iterator.next()).done)) {
|
6545 | fn(item.value);
|
6546 | }
|
6547 | }
|
6548 | }
|
6549 |
|
6550 |
|
6551 |
|
6552 |
|
6553 | function isJsObject(o) {
|
6554 | return o !== null && (typeof o === 'function' || typeof o === 'object');
|
6555 | }
|
6556 |
|
6557 |
|
6558 |
|
6559 |
|
6560 |
|
6561 |
|
6562 |
|
6563 |
|
6564 | class DefaultIterableDifferFactory {
|
6565 | constructor() { }
|
6566 | |
6567 |
|
6568 |
|
6569 |
|
6570 | supports(obj) { return isListLikeIterable(obj); }
|
6571 | |
6572 |
|
6573 |
|
6574 |
|
6575 |
|
6576 |
|
6577 |
|
6578 | create(cdRefOrTrackBy, trackByFn) {
|
6579 | return new DefaultIterableDiffer(trackByFn || (cdRefOrTrackBy));
|
6580 | }
|
6581 | }
|
6582 | const trackByIdentity = (index, item) => item;
|
6583 |
|
6584 |
|
6585 |
|
6586 | class DefaultIterableDiffer {
|
6587 | |
6588 |
|
6589 |
|
6590 | constructor(trackByFn) {
|
6591 | this._length = 0;
|
6592 | this._collection = null;
|
6593 | this._linkedRecords = null;
|
6594 | this._unlinkedRecords = null;
|
6595 | this._previousItHead = null;
|
6596 | this._itHead = null;
|
6597 | this._itTail = null;
|
6598 | this._additionsHead = null;
|
6599 | this._additionsTail = null;
|
6600 | this._movesHead = null;
|
6601 | this._movesTail = null;
|
6602 | this._removalsHead = null;
|
6603 | this._removalsTail = null;
|
6604 | this._identityChangesHead = null;
|
6605 | this._identityChangesTail = null;
|
6606 | this._trackByFn = trackByFn || trackByIdentity;
|
6607 | }
|
6608 | |
6609 |
|
6610 |
|
6611 | get collection() { return this._collection; }
|
6612 | |
6613 |
|
6614 |
|
6615 | get length() { return this._length; }
|
6616 | |
6617 |
|
6618 |
|
6619 |
|
6620 | forEachItem(fn) {
|
6621 | let record;
|
6622 | for (record = this._itHead; record !== null; record = record._next) {
|
6623 | fn(record);
|
6624 | }
|
6625 | }
|
6626 | |
6627 |
|
6628 |
|
6629 |
|
6630 | forEachOperation(fn) {
|
6631 | let nextIt = this._itHead;
|
6632 | let nextRemove = this._removalsHead;
|
6633 | let addRemoveOffset = 0;
|
6634 | let moveOffsets = null;
|
6635 | while (nextIt || nextRemove) {
|
6636 |
|
6637 |
|
6638 | const record = !nextRemove ||
|
6639 | nextIt && ((nextIt.currentIndex)) <
|
6640 | getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ? ((nextIt)) :
|
6641 | nextRemove;
|
6642 | const adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
|
6643 | const currentIndex = record.currentIndex;
|
6644 |
|
6645 | if (record === nextRemove) {
|
6646 | addRemoveOffset--;
|
6647 | nextRemove = nextRemove._nextRemoved;
|
6648 | }
|
6649 | else {
|
6650 | nextIt = ((nextIt))._next;
|
6651 | if (record.previousIndex == null) {
|
6652 | addRemoveOffset++;
|
6653 | }
|
6654 | else {
|
6655 |
|
6656 | if (!moveOffsets)
|
6657 | moveOffsets = [];
|
6658 | const localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
|
6659 | const localCurrentIndex = ((currentIndex)) - addRemoveOffset;
|
6660 | if (localMovePreviousIndex != localCurrentIndex) {
|
6661 | for (let i = 0; i < localMovePreviousIndex; i++) {
|
6662 | const offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
|
6663 | const index = offset + i;
|
6664 | if (localCurrentIndex <= index && index < localMovePreviousIndex) {
|
6665 | moveOffsets[i] = offset + 1;
|
6666 | }
|
6667 | }
|
6668 | const previousIndex = record.previousIndex;
|
6669 | moveOffsets[previousIndex] = localCurrentIndex - localMovePreviousIndex;
|
6670 | }
|
6671 | }
|
6672 | }
|
6673 | if (adjPreviousIndex !== currentIndex) {
|
6674 | fn(record, adjPreviousIndex, currentIndex);
|
6675 | }
|
6676 | }
|
6677 | }
|
6678 | |
6679 |
|
6680 |
|
6681 |
|
6682 | forEachPreviousItem(fn) {
|
6683 | let record;
|
6684 | for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
|
6685 | fn(record);
|
6686 | }
|
6687 | }
|
6688 | |
6689 |
|
6690 |
|
6691 |
|
6692 | forEachAddedItem(fn) {
|
6693 | let record;
|
6694 | for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
6695 | fn(record);
|
6696 | }
|
6697 | }
|
6698 | |
6699 |
|
6700 |
|
6701 |
|
6702 | forEachMovedItem(fn) {
|
6703 | let record;
|
6704 | for (record = this._movesHead; record !== null; record = record._nextMoved) {
|
6705 | fn(record);
|
6706 | }
|
6707 | }
|
6708 | |
6709 |
|
6710 |
|
6711 |
|
6712 | forEachRemovedItem(fn) {
|
6713 | let record;
|
6714 | for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
6715 | fn(record);
|
6716 | }
|
6717 | }
|
6718 | |
6719 |
|
6720 |
|
6721 |
|
6722 | forEachIdentityChange(fn) {
|
6723 | let record;
|
6724 | for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
|
6725 | fn(record);
|
6726 | }
|
6727 | }
|
6728 | |
6729 |
|
6730 |
|
6731 |
|
6732 | diff(collection) {
|
6733 | if (collection == null)
|
6734 | collection = [];
|
6735 | if (!isListLikeIterable(collection)) {
|
6736 | throw new Error(`Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed`);
|
6737 | }
|
6738 | if (this.check(collection)) {
|
6739 | return this;
|
6740 | }
|
6741 | else {
|
6742 | return null;
|
6743 | }
|
6744 | }
|
6745 | |
6746 |
|
6747 |
|
6748 | onDestroy() { }
|
6749 | |
6750 |
|
6751 |
|
6752 |
|
6753 | check(collection) {
|
6754 | this._reset();
|
6755 | let record = this._itHead;
|
6756 | let mayBeDirty = false;
|
6757 | let index;
|
6758 | let item;
|
6759 | let itemTrackBy;
|
6760 | if (Array.isArray(collection)) {
|
6761 | this._length = collection.length;
|
6762 | for (let index = 0; index < this._length; index++) {
|
6763 | item = collection[index];
|
6764 | itemTrackBy = this._trackByFn(index, item);
|
6765 | if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
|
6766 | record = this._mismatch(record, item, itemTrackBy, index);
|
6767 | mayBeDirty = true;
|
6768 | }
|
6769 | else {
|
6770 | if (mayBeDirty) {
|
6771 |
|
6772 | record = this._verifyReinsertion(record, item, itemTrackBy, index);
|
6773 | }
|
6774 | if (!looseIdentical(record.item, item))
|
6775 | this._addIdentityChange(record, item);
|
6776 | }
|
6777 | record = record._next;
|
6778 | }
|
6779 | }
|
6780 | else {
|
6781 | index = 0;
|
6782 | iterateListLike(collection, (item) => {
|
6783 | itemTrackBy = this._trackByFn(index, item);
|
6784 | if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
|
6785 | record = this._mismatch(record, item, itemTrackBy, index);
|
6786 | mayBeDirty = true;
|
6787 | }
|
6788 | else {
|
6789 | if (mayBeDirty) {
|
6790 |
|
6791 | record = this._verifyReinsertion(record, item, itemTrackBy, index);
|
6792 | }
|
6793 | if (!looseIdentical(record.item, item))
|
6794 | this._addIdentityChange(record, item);
|
6795 | }
|
6796 | record = record._next;
|
6797 | index++;
|
6798 | });
|
6799 | this._length = index;
|
6800 | }
|
6801 | this._truncate(record);
|
6802 | this._collection = collection;
|
6803 | return this.isDirty;
|
6804 | }
|
6805 | |
6806 |
|
6807 |
|
6808 | get isDirty() {
|
6809 | return this._additionsHead !== null || this._movesHead !== null ||
|
6810 | this._removalsHead !== null || this._identityChangesHead !== null;
|
6811 | }
|
6812 | |
6813 |
|
6814 |
|
6815 |
|
6816 |
|
6817 |
|
6818 |
|
6819 |
|
6820 |
|
6821 | _reset() {
|
6822 | if (this.isDirty) {
|
6823 | let record;
|
6824 | let nextRecord;
|
6825 | for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
|
6826 | record._nextPrevious = record._next;
|
6827 | }
|
6828 | for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
6829 | record.previousIndex = record.currentIndex;
|
6830 | }
|
6831 | this._additionsHead = this._additionsTail = null;
|
6832 | for (record = this._movesHead; record !== null; record = nextRecord) {
|
6833 | record.previousIndex = record.currentIndex;
|
6834 | nextRecord = record._nextMoved;
|
6835 | }
|
6836 | this._movesHead = this._movesTail = null;
|
6837 | this._removalsHead = this._removalsTail = null;
|
6838 | this._identityChangesHead = this._identityChangesTail = null;
|
6839 | }
|
6840 | }
|
6841 | |
6842 |
|
6843 |
|
6844 |
|
6845 |
|
6846 |
|
6847 |
|
6848 |
|
6849 |
|
6850 |
|
6851 |
|
6852 |
|
6853 |
|
6854 |
|
6855 |
|
6856 | _mismatch(record, item, itemTrackBy, index) {
|
6857 |
|
6858 | let previousRecord;
|
6859 | if (record === null) {
|
6860 | previousRecord = ((this._itTail));
|
6861 | }
|
6862 | else {
|
6863 | previousRecord = ((record._prev));
|
6864 |
|
6865 | this._remove(record);
|
6866 | }
|
6867 |
|
6868 | record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
|
6869 | if (record !== null) {
|
6870 |
|
6871 |
|
6872 | if (!looseIdentical(record.item, item))
|
6873 | this._addIdentityChange(record, item);
|
6874 | this._moveAfter(record, previousRecord, index);
|
6875 | }
|
6876 | else {
|
6877 |
|
6878 | record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
|
6879 | if (record !== null) {
|
6880 |
|
6881 |
|
6882 | if (!looseIdentical(record.item, item))
|
6883 | this._addIdentityChange(record, item);
|
6884 | this._reinsertAfter(record, previousRecord, index);
|
6885 | }
|
6886 | else {
|
6887 |
|
6888 | record =
|
6889 | this._addAfter(new IterableChangeRecord_(item, itemTrackBy), previousRecord, index);
|
6890 | }
|
6891 | }
|
6892 | return record;
|
6893 | }
|
6894 | |
6895 |
|
6896 |
|
6897 |
|
6898 |
|
6899 |
|
6900 |
|
6901 |
|
6902 |
|
6903 |
|
6904 |
|
6905 |
|
6906 |
|
6907 |
|
6908 |
|
6909 |
|
6910 |
|
6911 |
|
6912 |
|
6913 |
|
6914 |
|
6915 |
|
6916 |
|
6917 |
|
6918 |
|
6919 |
|
6920 |
|
6921 |
|
6922 |
|
6923 |
|
6924 |
|
6925 |
|
6926 | _verifyReinsertion(record, item, itemTrackBy, index) {
|
6927 | let reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
|
6928 | if (reinsertRecord !== null) {
|
6929 | record = this._reinsertAfter(reinsertRecord, ((record._prev)), index);
|
6930 | }
|
6931 | else if (record.currentIndex != index) {
|
6932 | record.currentIndex = index;
|
6933 | this._addToMoves(record, index);
|
6934 | }
|
6935 | return record;
|
6936 | }
|
6937 | |
6938 |
|
6939 |
|
6940 |
|
6941 |
|
6942 |
|
6943 |
|
6944 |
|
6945 |
|
6946 | _truncate(record) {
|
6947 |
|
6948 | while (record !== null) {
|
6949 | const nextRecord = record._next;
|
6950 | this._addToRemovals(this._unlink(record));
|
6951 | record = nextRecord;
|
6952 | }
|
6953 | if (this._unlinkedRecords !== null) {
|
6954 | this._unlinkedRecords.clear();
|
6955 | }
|
6956 | if (this._additionsTail !== null) {
|
6957 | this._additionsTail._nextAdded = null;
|
6958 | }
|
6959 | if (this._movesTail !== null) {
|
6960 | this._movesTail._nextMoved = null;
|
6961 | }
|
6962 | if (this._itTail !== null) {
|
6963 | this._itTail._next = null;
|
6964 | }
|
6965 | if (this._removalsTail !== null) {
|
6966 | this._removalsTail._nextRemoved = null;
|
6967 | }
|
6968 | if (this._identityChangesTail !== null) {
|
6969 | this._identityChangesTail._nextIdentityChange = null;
|
6970 | }
|
6971 | }
|
6972 | |
6973 |
|
6974 |
|
6975 |
|
6976 |
|
6977 |
|
6978 |
|
6979 | _reinsertAfter(record, prevRecord, index) {
|
6980 | if (this._unlinkedRecords !== null) {
|
6981 | this._unlinkedRecords.remove(record);
|
6982 | }
|
6983 | const prev = record._prevRemoved;
|
6984 | const next = record._nextRemoved;
|
6985 | if (prev === null) {
|
6986 | this._removalsHead = next;
|
6987 | }
|
6988 | else {
|
6989 | prev._nextRemoved = next;
|
6990 | }
|
6991 | if (next === null) {
|
6992 | this._removalsTail = prev;
|
6993 | }
|
6994 | else {
|
6995 | next._prevRemoved = prev;
|
6996 | }
|
6997 | this._insertAfter(record, prevRecord, index);
|
6998 | this._addToMoves(record, index);
|
6999 | return record;
|
7000 | }
|
7001 | |
7002 |
|
7003 |
|
7004 |
|
7005 |
|
7006 |
|
7007 |
|
7008 | _moveAfter(record, prevRecord, index) {
|
7009 | this._unlink(record);
|
7010 | this._insertAfter(record, prevRecord, index);
|
7011 | this._addToMoves(record, index);
|
7012 | return record;
|
7013 | }
|
7014 | |
7015 |
|
7016 |
|
7017 |
|
7018 |
|
7019 |
|
7020 |
|
7021 | _addAfter(record, prevRecord, index) {
|
7022 | this._insertAfter(record, prevRecord, index);
|
7023 | if (this._additionsTail === null) {
|
7024 |
|
7025 |
|
7026 | this._additionsTail = this._additionsHead = record;
|
7027 | }
|
7028 | else {
|
7029 |
|
7030 |
|
7031 |
|
7032 | this._additionsTail = this._additionsTail._nextAdded = record;
|
7033 | }
|
7034 | return record;
|
7035 | }
|
7036 | |
7037 |
|
7038 |
|
7039 |
|
7040 |
|
7041 |
|
7042 |
|
7043 | _insertAfter(record, prevRecord, index) {
|
7044 |
|
7045 |
|
7046 |
|
7047 |
|
7048 | const next = prevRecord === null ? this._itHead : prevRecord._next;
|
7049 |
|
7050 |
|
7051 |
|
7052 | record._next = next;
|
7053 | record._prev = prevRecord;
|
7054 | if (next === null) {
|
7055 | this._itTail = record;
|
7056 | }
|
7057 | else {
|
7058 | next._prev = record;
|
7059 | }
|
7060 | if (prevRecord === null) {
|
7061 | this._itHead = record;
|
7062 | }
|
7063 | else {
|
7064 | prevRecord._next = record;
|
7065 | }
|
7066 | if (this._linkedRecords === null) {
|
7067 | this._linkedRecords = new _DuplicateMap();
|
7068 | }
|
7069 | this._linkedRecords.put(record);
|
7070 | record.currentIndex = index;
|
7071 | return record;
|
7072 | }
|
7073 | |
7074 |
|
7075 |
|
7076 |
|
7077 |
|
7078 | _remove(record) {
|
7079 | return this._addToRemovals(this._unlink(record));
|
7080 | }
|
7081 | |
7082 |
|
7083 |
|
7084 |
|
7085 |
|
7086 | _unlink(record) {
|
7087 | if (this._linkedRecords !== null) {
|
7088 | this._linkedRecords.remove(record);
|
7089 | }
|
7090 | const prev = record._prev;
|
7091 | const next = record._next;
|
7092 |
|
7093 |
|
7094 |
|
7095 | if (prev === null) {
|
7096 | this._itHead = next;
|
7097 | }
|
7098 | else {
|
7099 | prev._next = next;
|
7100 | }
|
7101 | if (next === null) {
|
7102 | this._itTail = prev;
|
7103 | }
|
7104 | else {
|
7105 | next._prev = prev;
|
7106 | }
|
7107 | return record;
|
7108 | }
|
7109 | |
7110 |
|
7111 |
|
7112 |
|
7113 |
|
7114 |
|
7115 | _addToMoves(record, toIndex) {
|
7116 |
|
7117 |
|
7118 | if (record.previousIndex === toIndex) {
|
7119 | return record;
|
7120 | }
|
7121 | if (this._movesTail === null) {
|
7122 |
|
7123 |
|
7124 | this._movesTail = this._movesHead = record;
|
7125 | }
|
7126 | else {
|
7127 |
|
7128 |
|
7129 | this._movesTail = this._movesTail._nextMoved = record;
|
7130 | }
|
7131 | return record;
|
7132 | }
|
7133 | |
7134 |
|
7135 |
|
7136 |
|
7137 | _addToRemovals(record) {
|
7138 | if (this._unlinkedRecords === null) {
|
7139 | this._unlinkedRecords = new _DuplicateMap();
|
7140 | }
|
7141 | this._unlinkedRecords.put(record);
|
7142 | record.currentIndex = null;
|
7143 | record._nextRemoved = null;
|
7144 | if (this._removalsTail === null) {
|
7145 |
|
7146 |
|
7147 | this._removalsTail = this._removalsHead = record;
|
7148 | record._prevRemoved = null;
|
7149 | }
|
7150 | else {
|
7151 |
|
7152 |
|
7153 |
|
7154 | record._prevRemoved = this._removalsTail;
|
7155 | this._removalsTail = this._removalsTail._nextRemoved = record;
|
7156 | }
|
7157 | return record;
|
7158 | }
|
7159 | |
7160 |
|
7161 |
|
7162 |
|
7163 |
|
7164 |
|
7165 | _addIdentityChange(record, item) {
|
7166 | record.item = item;
|
7167 | if (this._identityChangesTail === null) {
|
7168 | this._identityChangesTail = this._identityChangesHead = record;
|
7169 | }
|
7170 | else {
|
7171 | this._identityChangesTail = this._identityChangesTail._nextIdentityChange = record;
|
7172 | }
|
7173 | return record;
|
7174 | }
|
7175 | |
7176 |
|
7177 |
|
7178 | toString() {
|
7179 | const list = [];
|
7180 | this.forEachItem((record) => list.push(record));
|
7181 | const previous = [];
|
7182 | this.forEachPreviousItem((record) => previous.push(record));
|
7183 | const additions = [];
|
7184 | this.forEachAddedItem((record) => additions.push(record));
|
7185 | const moves = [];
|
7186 | this.forEachMovedItem((record) => moves.push(record));
|
7187 | const removals = [];
|
7188 | this.forEachRemovedItem((record) => removals.push(record));
|
7189 | const identityChanges = [];
|
7190 | this.forEachIdentityChange((record) => identityChanges.push(record));
|
7191 | return 'collection: ' + list.join(', ') + '\n' +
|
7192 | 'previous: ' + previous.join(', ') + '\n' +
|
7193 | 'additions: ' + additions.join(', ') + '\n' +
|
7194 | 'moves: ' + moves.join(', ') + '\n' +
|
7195 | 'removals: ' + removals.join(', ') + '\n' +
|
7196 | 'identityChanges: ' + identityChanges.join(', ') + '\n';
|
7197 | }
|
7198 | }
|
7199 |
|
7200 |
|
7201 |
|
7202 | class IterableChangeRecord_ {
|
7203 | |
7204 |
|
7205 |
|
7206 |
|
7207 | constructor(item, trackById) {
|
7208 | this.item = item;
|
7209 | this.trackById = trackById;
|
7210 | this.currentIndex = null;
|
7211 | this.previousIndex = null;
|
7212 | |
7213 |
|
7214 |
|
7215 | this._nextPrevious = null;
|
7216 | |
7217 |
|
7218 |
|
7219 | this._prev = null;
|
7220 | |
7221 |
|
7222 |
|
7223 | this._next = null;
|
7224 | |
7225 |
|
7226 |
|
7227 | this._prevDup = null;
|
7228 | |
7229 |
|
7230 |
|
7231 | this._nextDup = null;
|
7232 | |
7233 |
|
7234 |
|
7235 | this._prevRemoved = null;
|
7236 | |
7237 |
|
7238 |
|
7239 | this._nextRemoved = null;
|
7240 | |
7241 |
|
7242 |
|
7243 | this._nextAdded = null;
|
7244 | |
7245 |
|
7246 |
|
7247 | this._nextMoved = null;
|
7248 | |
7249 |
|
7250 |
|
7251 | this._nextIdentityChange = null;
|
7252 | }
|
7253 | |
7254 |
|
7255 |
|
7256 | toString() {
|
7257 | return this.previousIndex === this.currentIndex ? stringify(this.item) :
|
7258 | stringify(this.item) + '[' +
|
7259 | stringify(this.previousIndex) + '->' + stringify(this.currentIndex) + ']';
|
7260 | }
|
7261 | }
|
7262 | class _DuplicateItemRecordList {
|
7263 | constructor() {
|
7264 | |
7265 |
|
7266 |
|
7267 | this._head = null;
|
7268 | |
7269 |
|
7270 |
|
7271 | this._tail = null;
|
7272 | }
|
7273 | |
7274 |
|
7275 |
|
7276 |
|
7277 |
|
7278 |
|
7279 |
|
7280 | add(record) {
|
7281 | if (this._head === null) {
|
7282 | this._head = this._tail = record;
|
7283 | record._nextDup = null;
|
7284 | record._prevDup = null;
|
7285 | }
|
7286 | else {
|
7287 | ((
|
7288 |
|
7289 |
|
7290 |
|
7291 | this._tail))._nextDup = record;
|
7292 | record._prevDup = this._tail;
|
7293 | record._nextDup = null;
|
7294 | this._tail = record;
|
7295 | }
|
7296 | }
|
7297 | |
7298 |
|
7299 |
|
7300 |
|
7301 |
|
7302 | get(trackById, afterIndex) {
|
7303 | let record;
|
7304 | for (record = this._head; record !== null; record = record._nextDup) {
|
7305 | if ((afterIndex === null || afterIndex < record.currentIndex) &&
|
7306 | looseIdentical(record.trackById, trackById)) {
|
7307 | return record;
|
7308 | }
|
7309 | }
|
7310 | return null;
|
7311 | }
|
7312 | |
7313 |
|
7314 |
|
7315 |
|
7316 |
|
7317 |
|
7318 |
|
7319 | remove(record) {
|
7320 |
|
7321 |
|
7322 |
|
7323 |
|
7324 |
|
7325 |
|
7326 |
|
7327 |
|
7328 | const prev = record._prevDup;
|
7329 | const next = record._nextDup;
|
7330 | if (prev === null) {
|
7331 | this._head = next;
|
7332 | }
|
7333 | else {
|
7334 | prev._nextDup = next;
|
7335 | }
|
7336 | if (next === null) {
|
7337 | this._tail = prev;
|
7338 | }
|
7339 | else {
|
7340 | next._prevDup = prev;
|
7341 | }
|
7342 | return this._head === null;
|
7343 | }
|
7344 | }
|
7345 | class _DuplicateMap {
|
7346 | constructor() {
|
7347 | this.map = new Map();
|
7348 | }
|
7349 | |
7350 |
|
7351 |
|
7352 |
|
7353 | put(record) {
|
7354 | const key = record.trackById;
|
7355 | let duplicates = this.map.get(key);
|
7356 | if (!duplicates) {
|
7357 | duplicates = new _DuplicateItemRecordList();
|
7358 | this.map.set(key, duplicates);
|
7359 | }
|
7360 | duplicates.add(record);
|
7361 | }
|
7362 | |
7363 |
|
7364 |
|
7365 |
|
7366 |
|
7367 |
|
7368 |
|
7369 |
|
7370 |
|
7371 |
|
7372 | get(trackById, afterIndex) {
|
7373 | const key = trackById;
|
7374 | const recordList = this.map.get(key);
|
7375 | return recordList ? recordList.get(trackById, afterIndex) : null;
|
7376 | }
|
7377 | |
7378 |
|
7379 |
|
7380 |
|
7381 |
|
7382 |
|
7383 |
|
7384 | remove(record) {
|
7385 | const key = record.trackById;
|
7386 | const recordList = ((this.map.get(key)));
|
7387 |
|
7388 | if (recordList.remove(record)) {
|
7389 | this.map.delete(key);
|
7390 | }
|
7391 | return record;
|
7392 | }
|
7393 | |
7394 |
|
7395 |
|
7396 | get isEmpty() { return this.map.size === 0; }
|
7397 | |
7398 |
|
7399 |
|
7400 | clear() { this.map.clear(); }
|
7401 | |
7402 |
|
7403 |
|
7404 | toString() { return '_DuplicateMap(' + stringify(this.map) + ')'; }
|
7405 | }
|
7406 |
|
7407 |
|
7408 |
|
7409 |
|
7410 |
|
7411 |
|
7412 | function getPreviousIndex(item, addRemoveOffset, moveOffsets) {
|
7413 | const previousIndex = item.previousIndex;
|
7414 | if (previousIndex === null)
|
7415 | return previousIndex;
|
7416 | let moveOffset = 0;
|
7417 | if (moveOffsets && previousIndex < moveOffsets.length) {
|
7418 | moveOffset = moveOffsets[previousIndex];
|
7419 | }
|
7420 | return previousIndex + addRemoveOffset + moveOffset;
|
7421 | }
|
7422 |
|
7423 |
|
7424 |
|
7425 |
|
7426 |
|
7427 |
|
7428 |
|
7429 |
|
7430 | class DefaultKeyValueDifferFactory {
|
7431 | constructor() { }
|
7432 | |
7433 |
|
7434 |
|
7435 |
|
7436 | supports(obj) { return obj instanceof Map || isJsObject(obj); }
|
7437 | |
7438 |
|
7439 |
|
7440 |
|
7441 |
|
7442 |
|
7443 | create(cd) {
|
7444 | return new DefaultKeyValueDiffer();
|
7445 | }
|
7446 | }
|
7447 | class DefaultKeyValueDiffer {
|
7448 | constructor() {
|
7449 | this._records = new Map();
|
7450 | this._mapHead = null;
|
7451 | this._appendAfter = null;
|
7452 | this._previousMapHead = null;
|
7453 | this._changesHead = null;
|
7454 | this._changesTail = null;
|
7455 | this._additionsHead = null;
|
7456 | this._additionsTail = null;
|
7457 | this._removalsHead = null;
|
7458 | this._removalsTail = null;
|
7459 | }
|
7460 | |
7461 |
|
7462 |
|
7463 | get isDirty() {
|
7464 | return this._additionsHead !== null || this._changesHead !== null ||
|
7465 | this._removalsHead !== null;
|
7466 | }
|
7467 | |
7468 |
|
7469 |
|
7470 |
|
7471 | forEachItem(fn) {
|
7472 | let record;
|
7473 | for (record = this._mapHead; record !== null; record = record._next) {
|
7474 | fn(record);
|
7475 | }
|
7476 | }
|
7477 | |
7478 |
|
7479 |
|
7480 |
|
7481 | forEachPreviousItem(fn) {
|
7482 | let record;
|
7483 | for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
|
7484 | fn(record);
|
7485 | }
|
7486 | }
|
7487 | |
7488 |
|
7489 |
|
7490 |
|
7491 | forEachChangedItem(fn) {
|
7492 | let record;
|
7493 | for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
7494 | fn(record);
|
7495 | }
|
7496 | }
|
7497 | |
7498 |
|
7499 |
|
7500 |
|
7501 | forEachAddedItem(fn) {
|
7502 | let record;
|
7503 | for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
7504 | fn(record);
|
7505 | }
|
7506 | }
|
7507 | |
7508 |
|
7509 |
|
7510 |
|
7511 | forEachRemovedItem(fn) {
|
7512 | let record;
|
7513 | for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
7514 | fn(record);
|
7515 | }
|
7516 | }
|
7517 | |
7518 |
|
7519 |
|
7520 |
|
7521 | diff(map) {
|
7522 | if (!map) {
|
7523 | map = new Map();
|
7524 | }
|
7525 | else if (!(map instanceof Map || isJsObject(map))) {
|
7526 | throw new Error(`Error trying to diff '${stringify(map)}'. Only maps and objects are allowed`);
|
7527 | }
|
7528 | return this.check(map) ? this : null;
|
7529 | }
|
7530 | |
7531 |
|
7532 |
|
7533 | onDestroy() { }
|
7534 | |
7535 |
|
7536 |
|
7537 |
|
7538 |
|
7539 |
|
7540 | check(map) {
|
7541 | this._reset();
|
7542 | let insertBefore = this._mapHead;
|
7543 | this._appendAfter = null;
|
7544 | this._forEach(map, (value, key) => {
|
7545 | if (insertBefore && insertBefore.key === key) {
|
7546 | this._maybeAddToChanges(insertBefore, value);
|
7547 | this._appendAfter = insertBefore;
|
7548 | insertBefore = insertBefore._next;
|
7549 | }
|
7550 | else {
|
7551 | const record = this._getOrCreateRecordForKey(key, value);
|
7552 | insertBefore = this._insertBeforeOrAppend(insertBefore, record);
|
7553 | }
|
7554 | });
|
7555 |
|
7556 | if (insertBefore) {
|
7557 | if (insertBefore._prev) {
|
7558 | insertBefore._prev._next = null;
|
7559 | }
|
7560 | this._removalsHead = insertBefore;
|
7561 | for (let record = insertBefore; record !== null; record = record._nextRemoved) {
|
7562 | if (record === this._mapHead) {
|
7563 | this._mapHead = null;
|
7564 | }
|
7565 | this._records.delete(record.key);
|
7566 | record._nextRemoved = record._next;
|
7567 | record.previousValue = record.currentValue;
|
7568 | record.currentValue = null;
|
7569 | record._prev = null;
|
7570 | record._next = null;
|
7571 | }
|
7572 | }
|
7573 |
|
7574 | if (this._changesTail)
|
7575 | this._changesTail._nextChanged = null;
|
7576 | if (this._additionsTail)
|
7577 | this._additionsTail._nextAdded = null;
|
7578 | return this.isDirty;
|
7579 | }
|
7580 | |
7581 |
|
7582 |
|
7583 |
|
7584 |
|
7585 |
|
7586 |
|
7587 |
|
7588 |
|
7589 |
|
7590 |
|
7591 | _insertBeforeOrAppend(before, record) {
|
7592 | if (before) {
|
7593 | const prev = before._prev;
|
7594 | record._next = before;
|
7595 | record._prev = prev;
|
7596 | before._prev = record;
|
7597 | if (prev) {
|
7598 | prev._next = record;
|
7599 | }
|
7600 | if (before === this._mapHead) {
|
7601 | this._mapHead = record;
|
7602 | }
|
7603 | this._appendAfter = before;
|
7604 | return before;
|
7605 | }
|
7606 | if (this._appendAfter) {
|
7607 | this._appendAfter._next = record;
|
7608 | record._prev = this._appendAfter;
|
7609 | }
|
7610 | else {
|
7611 | this._mapHead = record;
|
7612 | }
|
7613 | this._appendAfter = record;
|
7614 | return null;
|
7615 | }
|
7616 | |
7617 |
|
7618 |
|
7619 |
|
7620 |
|
7621 | _getOrCreateRecordForKey(key, value) {
|
7622 | if (this._records.has(key)) {
|
7623 | const record = ((this._records.get(key)));
|
7624 | this._maybeAddToChanges(record, value);
|
7625 | const prev = record._prev;
|
7626 | const next = record._next;
|
7627 | if (prev) {
|
7628 | prev._next = next;
|
7629 | }
|
7630 | if (next) {
|
7631 | next._prev = prev;
|
7632 | }
|
7633 | record._next = null;
|
7634 | record._prev = null;
|
7635 | return record;
|
7636 | }
|
7637 | const record = new KeyValueChangeRecord_(key);
|
7638 | this._records.set(key, record);
|
7639 | record.currentValue = value;
|
7640 | this._addToAdditions(record);
|
7641 | return record;
|
7642 | }
|
7643 | |
7644 |
|
7645 |
|
7646 |
|
7647 | _reset() {
|
7648 | if (this.isDirty) {
|
7649 | let record;
|
7650 |
|
7651 | this._previousMapHead = this._mapHead;
|
7652 | for (record = this._previousMapHead; record !== null; record = record._next) {
|
7653 | record._nextPrevious = record._next;
|
7654 | }
|
7655 |
|
7656 |
|
7657 | for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
7658 | record.previousValue = record.currentValue;
|
7659 | }
|
7660 | for (record = this._additionsHead; record != null; record = record._nextAdded) {
|
7661 | record.previousValue = record.currentValue;
|
7662 | }
|
7663 | this._changesHead = this._changesTail = null;
|
7664 | this._additionsHead = this._additionsTail = null;
|
7665 | this._removalsHead = null;
|
7666 | }
|
7667 | }
|
7668 | |
7669 |
|
7670 |
|
7671 |
|
7672 |
|
7673 | _maybeAddToChanges(record, newValue) {
|
7674 | if (!looseIdentical(newValue, record.currentValue)) {
|
7675 | record.previousValue = record.currentValue;
|
7676 | record.currentValue = newValue;
|
7677 | this._addToChanges(record);
|
7678 | }
|
7679 | }
|
7680 | |
7681 |
|
7682 |
|
7683 |
|
7684 | _addToAdditions(record) {
|
7685 | if (this._additionsHead === null) {
|
7686 | this._additionsHead = this._additionsTail = record;
|
7687 | }
|
7688 | else {
|
7689 | ((this._additionsTail))._nextAdded = record;
|
7690 | this._additionsTail = record;
|
7691 | }
|
7692 | }
|
7693 | |
7694 |
|
7695 |
|
7696 |
|
7697 | _addToChanges(record) {
|
7698 | if (this._changesHead === null) {
|
7699 | this._changesHead = this._changesTail = record;
|
7700 | }
|
7701 | else {
|
7702 | ((this._changesTail))._nextChanged = record;
|
7703 | this._changesTail = record;
|
7704 | }
|
7705 | }
|
7706 | |
7707 |
|
7708 |
|
7709 | toString() {
|
7710 | const items = [];
|
7711 | const previous = [];
|
7712 | const changes = [];
|
7713 | const additions = [];
|
7714 | const removals = [];
|
7715 | this.forEachItem(r => items.push(stringify(r)));
|
7716 | this.forEachPreviousItem(r => previous.push(stringify(r)));
|
7717 | this.forEachChangedItem(r => changes.push(stringify(r)));
|
7718 | this.forEachAddedItem(r => additions.push(stringify(r)));
|
7719 | this.forEachRemovedItem(r => removals.push(stringify(r)));
|
7720 | return 'map: ' + items.join(', ') + '\n' +
|
7721 | 'previous: ' + previous.join(', ') + '\n' +
|
7722 | 'additions: ' + additions.join(', ') + '\n' +
|
7723 | 'changes: ' + changes.join(', ') + '\n' +
|
7724 | 'removals: ' + removals.join(', ') + '\n';
|
7725 | }
|
7726 | |
7727 |
|
7728 |
|
7729 |
|
7730 |
|
7731 |
|
7732 |
|
7733 | _forEach(obj, fn) {
|
7734 | if (obj instanceof Map) {
|
7735 | obj.forEach(fn);
|
7736 | }
|
7737 | else {
|
7738 | Object.keys(obj).forEach(k => fn(obj[k], k));
|
7739 | }
|
7740 | }
|
7741 | }
|
7742 |
|
7743 |
|
7744 |
|
7745 | class KeyValueChangeRecord_ {
|
7746 | |
7747 |
|
7748 |
|
7749 | constructor(key) {
|
7750 | this.key = key;
|
7751 | this.previousValue = null;
|
7752 | this.currentValue = null;
|
7753 | |
7754 |
|
7755 |
|
7756 | this._nextPrevious = null;
|
7757 | |
7758 |
|
7759 |
|
7760 | this._next = null;
|
7761 | |
7762 |
|
7763 |
|
7764 | this._prev = null;
|
7765 | |
7766 |
|
7767 |
|
7768 | this._nextAdded = null;
|
7769 | |
7770 |
|
7771 |
|
7772 | this._nextRemoved = null;
|
7773 | |
7774 |
|
7775 |
|
7776 | this._nextChanged = null;
|
7777 | }
|
7778 | |
7779 |
|
7780 |
|
7781 | toString() {
|
7782 | return looseIdentical(this.previousValue, this.currentValue) ?
|
7783 | stringify(this.key) :
|
7784 | (stringify(this.key) + '[' + stringify(this.previousValue) + '->' +
|
7785 | stringify(this.currentValue) + ']');
|
7786 | }
|
7787 | }
|
7788 |
|
7789 |
|
7790 |
|
7791 |
|
7792 |
|
7793 |
|
7794 |
|
7795 |
|
7796 |
|
7797 |
|
7798 |
|
7799 |
|
7800 | class IterableDiffers {
|
7801 | |
7802 |
|
7803 |
|
7804 | constructor(factories) { this.factories = factories; }
|
7805 | |
7806 |
|
7807 |
|
7808 |
|
7809 |
|
7810 | static create(factories, parent) {
|
7811 | if (parent != null) {
|
7812 | const copied = parent.factories.slice();
|
7813 | factories = factories.concat(copied);
|
7814 | return new IterableDiffers(factories);
|
7815 | }
|
7816 | else {
|
7817 | return new IterableDiffers(factories);
|
7818 | }
|
7819 | }
|
7820 | |
7821 |
|
7822 |
|
7823 |
|
7824 |
|
7825 |
|
7826 |
|
7827 |
|
7828 |
|
7829 |
|
7830 |
|
7831 |
|
7832 |
|
7833 |
|
7834 |
|
7835 |
|
7836 |
|
7837 |
|
7838 |
|
7839 |
|
7840 |
|
7841 | static extend(factories) {
|
7842 | return {
|
7843 | provide: IterableDiffers,
|
7844 | useFactory: (parent) => {
|
7845 | if (!parent) {
|
7846 |
|
7847 |
|
7848 |
|
7849 | throw new Error('Cannot extend IterableDiffers without a parent injector');
|
7850 | }
|
7851 | return IterableDiffers.create(factories, parent);
|
7852 | },
|
7853 |
|
7854 | deps: [[IterableDiffers, new SkipSelf(), new Optional()]]
|
7855 | };
|
7856 | }
|
7857 | |
7858 |
|
7859 |
|
7860 |
|
7861 | find(iterable) {
|
7862 | const factory = this.factories.find(f => f.supports(iterable));
|
7863 | if (factory != null) {
|
7864 | return factory;
|
7865 | }
|
7866 | else {
|
7867 | throw new Error(`Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'`);
|
7868 | }
|
7869 | }
|
7870 | }
|
7871 |
|
7872 |
|
7873 |
|
7874 |
|
7875 | function getTypeNameForDebugging(type) {
|
7876 | return type['name'] || typeof type;
|
7877 | }
|
7878 |
|
7879 |
|
7880 |
|
7881 |
|
7882 |
|
7883 |
|
7884 |
|
7885 |
|
7886 |
|
7887 |
|
7888 |
|
7889 |
|
7890 | class KeyValueDiffers {
|
7891 | |
7892 |
|
7893 |
|
7894 | constructor(factories) { this.factories = factories; }
|
7895 | |
7896 |
|
7897 |
|
7898 |
|
7899 |
|
7900 |
|
7901 | static create(factories, parent) {
|
7902 | if (parent) {
|
7903 | const copied = parent.factories.slice();
|
7904 | factories = factories.concat(copied);
|
7905 | }
|
7906 | return new KeyValueDiffers(factories);
|
7907 | }
|
7908 | |
7909 |
|
7910 |
|
7911 |
|
7912 |
|
7913 |
|
7914 |
|
7915 |
|
7916 |
|
7917 |
|
7918 |
|
7919 |
|
7920 |
|
7921 |
|
7922 |
|
7923 |
|
7924 |
|
7925 |
|
7926 |
|
7927 |
|
7928 |
|
7929 |
|
7930 | static extend(factories) {
|
7931 | return {
|
7932 | provide: KeyValueDiffers,
|
7933 | useFactory: (parent) => {
|
7934 | if (!parent) {
|
7935 |
|
7936 |
|
7937 | throw new Error('Cannot extend KeyValueDiffers without a parent injector');
|
7938 | }
|
7939 | return KeyValueDiffers.create(factories, parent);
|
7940 | },
|
7941 |
|
7942 | deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
|
7943 | };
|
7944 | }
|
7945 | |
7946 |
|
7947 |
|
7948 |
|
7949 | find(kv) {
|
7950 | const factory = this.factories.find(f => f.supports(kv));
|
7951 | if (factory) {
|
7952 | return factory;
|
7953 | }
|
7954 | throw new Error(`Cannot find a differ supporting object '${kv}'`);
|
7955 | }
|
7956 | }
|
7957 |
|
7958 |
|
7959 |
|
7960 |
|
7961 |
|
7962 |
|
7963 |
|
7964 |
|
7965 |
|
7966 |
|
7967 |
|
7968 | const keyValDiff = [new DefaultKeyValueDifferFactory()];
|
7969 |
|
7970 |
|
7971 |
|
7972 | const iterableDiff = [new DefaultIterableDifferFactory()];
|
7973 | const defaultIterableDiffers = new IterableDiffers(iterableDiff);
|
7974 | const defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
|
7975 |
|
7976 |
|
7977 |
|
7978 |
|
7979 |
|
7980 |
|
7981 |
|
7982 |
|
7983 |
|
7984 |
|
7985 |
|
7986 |
|
7987 |
|
7988 |
|
7989 |
|
7990 |
|
7991 |
|
7992 |
|
7993 |
|
7994 |
|
7995 |
|
7996 |
|
7997 |
|
7998 |
|
7999 | function _reflector() {
|
8000 | return reflector;
|
8001 | }
|
8002 | const _CORE_PLATFORM_PROVIDERS = [
|
8003 |
|
8004 | { provide: PLATFORM_ID, useValue: 'unknown' },
|
8005 | PlatformRef_,
|
8006 | { provide: PlatformRef, useExisting: PlatformRef_ },
|
8007 | { provide: Reflector, useFactory: _reflector, deps: [] },
|
8008 | { provide: ReflectorReader, useExisting: Reflector },
|
8009 | TestabilityRegistry,
|
8010 | Console,
|
8011 | ];
|
8012 |
|
8013 |
|
8014 |
|
8015 |
|
8016 |
|
8017 | const platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
|
8018 |
|
8019 |
|
8020 |
|
8021 |
|
8022 |
|
8023 |
|
8024 |
|
8025 |
|
8026 |
|
8027 |
|
8028 |
|
8029 | const LOCALE_ID = new InjectionToken('LocaleId');
|
8030 |
|
8031 |
|
8032 |
|
8033 | const TRANSLATIONS = new InjectionToken('Translations');
|
8034 |
|
8035 |
|
8036 |
|
8037 | const TRANSLATIONS_FORMAT = new InjectionToken('TranslationsFormat');
|
8038 | let MissingTranslationStrategy = {};
|
8039 | MissingTranslationStrategy.Error = 0;
|
8040 | MissingTranslationStrategy.Warning = 1;
|
8041 | MissingTranslationStrategy.Ignore = 2;
|
8042 | MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
|
8043 | MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
|
8044 | MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
|
8045 |
|
8046 | let SecurityContext = {};
|
8047 | SecurityContext.NONE = 0;
|
8048 | SecurityContext.HTML = 1;
|
8049 | SecurityContext.STYLE = 2;
|
8050 | SecurityContext.SCRIPT = 3;
|
8051 | SecurityContext.URL = 4;
|
8052 | SecurityContext.RESOURCE_URL = 5;
|
8053 | SecurityContext[SecurityContext.NONE] = "NONE";
|
8054 | SecurityContext[SecurityContext.HTML] = "HTML";
|
8055 | SecurityContext[SecurityContext.STYLE] = "STYLE";
|
8056 | SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
|
8057 | SecurityContext[SecurityContext.URL] = "URL";
|
8058 | SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
|
8059 |
|
8060 |
|
8061 |
|
8062 |
|
8063 |
|
8064 |
|
8065 | class Sanitizer {
|
8066 | |
8067 |
|
8068 |
|
8069 |
|
8070 |
|
8071 |
|
8072 | sanitize(context, value) { }
|
8073 | }
|
8074 |
|
8075 |
|
8076 |
|
8077 |
|
8078 |
|
8079 |
|
8080 |
|
8081 |
|
8082 |
|
8083 |
|
8084 |
|
8085 |
|
8086 |
|
8087 |
|
8088 |
|
8089 |
|
8090 |
|
8091 |
|
8092 |
|
8093 |
|
8094 |
|
8095 |
|
8096 |
|
8097 |
|
8098 |
|
8099 |
|
8100 | function asTextData(view, index) {
|
8101 | return (view.nodes[index]);
|
8102 | }
|
8103 |
|
8104 |
|
8105 |
|
8106 |
|
8107 |
|
8108 |
|
8109 | function asElementData(view, index) {
|
8110 | return (view.nodes[index]);
|
8111 | }
|
8112 |
|
8113 |
|
8114 |
|
8115 |
|
8116 |
|
8117 |
|
8118 | function asProviderData(view, index) {
|
8119 | return (view.nodes[index]);
|
8120 | }
|
8121 |
|
8122 |
|
8123 |
|
8124 |
|
8125 |
|
8126 |
|
8127 | function asPureExpressionData(view, index) {
|
8128 | return (view.nodes[index]);
|
8129 | }
|
8130 |
|
8131 |
|
8132 |
|
8133 |
|
8134 |
|
8135 |
|
8136 | function asQueryList(view, index) {
|
8137 | return (view.nodes[index]);
|
8138 | }
|
8139 |
|
8140 |
|
8141 |
|
8142 | class DebugContext {
|
8143 | |
8144 |
|
8145 |
|
8146 |
|
8147 | view() { }
|
8148 | |
8149 |
|
8150 |
|
8151 |
|
8152 | nodeIndex() { }
|
8153 | |
8154 |
|
8155 |
|
8156 |
|
8157 | injector() { }
|
8158 | |
8159 |
|
8160 |
|
8161 |
|
8162 | component() { }
|
8163 | |
8164 |
|
8165 |
|
8166 |
|
8167 | providerTokens() { }
|
8168 | |
8169 |
|
8170 |
|
8171 |
|
8172 | references() { }
|
8173 | |
8174 |
|
8175 |
|
8176 |
|
8177 | context() { }
|
8178 | |
8179 |
|
8180 |
|
8181 |
|
8182 | componentRenderElement() { }
|
8183 | |
8184 |
|
8185 |
|
8186 |
|
8187 | renderNode() { }
|
8188 | |
8189 |
|
8190 |
|
8191 |
|
8192 |
|
8193 |
|
8194 | logError(console, ...values) { }
|
8195 | }
|
8196 |
|
8197 |
|
8198 |
|
8199 |
|
8200 | const Services = {
|
8201 | setCurrentNode: ((undefined)),
|
8202 | createRootView: ((undefined)),
|
8203 | createEmbeddedView: ((undefined)),
|
8204 | checkAndUpdateView: ((undefined)),
|
8205 | checkNoChangesView: ((undefined)),
|
8206 | destroyView: ((undefined)),
|
8207 | resolveDep: ((undefined)),
|
8208 | createDebugContext: ((undefined)),
|
8209 | handleEvent: ((undefined)),
|
8210 | updateDirectives: ((undefined)),
|
8211 | updateRenderer: ((undefined)),
|
8212 | dirtyParentQueries: ((undefined)),
|
8213 | };
|
8214 |
|
8215 |
|
8216 |
|
8217 |
|
8218 |
|
8219 |
|
8220 |
|
8221 |
|
8222 |
|
8223 |
|
8224 |
|
8225 |
|
8226 |
|
8227 |
|
8228 |
|
8229 | function expressionChangedAfterItHasBeenCheckedError(context, oldValue, currValue, isFirstCheck) {
|
8230 | let msg = `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '${oldValue}'. Current value: '${currValue}'.`;
|
8231 | if (isFirstCheck) {
|
8232 | msg +=
|
8233 | ` It seems like the view has been created after its parent and its children have been dirty checked.` +
|
8234 | ` Has it been created in a change detection hook ?`;
|
8235 | }
|
8236 | return viewDebugError(msg, context);
|
8237 | }
|
8238 |
|
8239 |
|
8240 |
|
8241 |
|
8242 |
|
8243 | function viewWrappedDebugError(err, context) {
|
8244 | if (!(err instanceof Error)) {
|
8245 |
|
8246 |
|
8247 | err = new Error(err.toString());
|
8248 | }
|
8249 | _addDebugContext(err, context);
|
8250 | return err;
|
8251 | }
|
8252 |
|
8253 |
|
8254 |
|
8255 |
|
8256 |
|
8257 | function viewDebugError(msg, context) {
|
8258 | const err = new Error(msg);
|
8259 | _addDebugContext(err, context);
|
8260 | return err;
|
8261 | }
|
8262 |
|
8263 |
|
8264 |
|
8265 |
|
8266 |
|
8267 | function _addDebugContext(err, context) {
|
8268 | ((err))[ERROR_DEBUG_CONTEXT] = context;
|
8269 | ((err))[ERROR_LOGGER] = context.logError.bind(context);
|
8270 | }
|
8271 |
|
8272 |
|
8273 |
|
8274 |
|
8275 | function isViewDebugError(err) {
|
8276 | return !!getDebugContext(err);
|
8277 | }
|
8278 |
|
8279 |
|
8280 |
|
8281 |
|
8282 | function viewDestroyedError(action) {
|
8283 | return new Error(`ViewDestroyedError: Attempt to use a destroyed view: ${action}`);
|
8284 | }
|
8285 |
|
8286 |
|
8287 |
|
8288 |
|
8289 |
|
8290 |
|
8291 |
|
8292 |
|
8293 | const NOOP = () => { };
|
8294 | const _tokenKeyCache = new Map();
|
8295 |
|
8296 |
|
8297 |
|
8298 |
|
8299 | function tokenKey(token) {
|
8300 | let key = _tokenKeyCache.get(token);
|
8301 | if (!key) {
|
8302 | key = stringify(token) + '_' + _tokenKeyCache.size;
|
8303 | _tokenKeyCache.set(token, key);
|
8304 | }
|
8305 | return key;
|
8306 | }
|
8307 |
|
8308 |
|
8309 |
|
8310 |
|
8311 |
|
8312 |
|
8313 |
|
8314 | function unwrapValue(view, nodeIdx, bindingIdx, value) {
|
8315 | if (value instanceof WrappedValue) {
|
8316 | value = value.wrapped;
|
8317 | let globalBindingIdx = view.def.nodes[nodeIdx].bindingIndex + bindingIdx;
|
8318 | let oldValue = view.oldValues[globalBindingIdx];
|
8319 | if (oldValue instanceof WrappedValue) {
|
8320 | oldValue = oldValue.wrapped;
|
8321 | }
|
8322 | view.oldValues[globalBindingIdx] = new WrappedValue(oldValue);
|
8323 | }
|
8324 | return value;
|
8325 | }
|
8326 | const UNDEFINED_RENDERER_TYPE_ID = '$$undefined';
|
8327 | const EMPTY_RENDERER_TYPE_ID = '$$empty';
|
8328 |
|
8329 |
|
8330 |
|
8331 |
|
8332 | function createRendererType2(values) {
|
8333 | return {
|
8334 | id: UNDEFINED_RENDERER_TYPE_ID,
|
8335 | styles: values.styles,
|
8336 | encapsulation: values.encapsulation,
|
8337 | data: values.data
|
8338 | };
|
8339 | }
|
8340 | let _renderCompCount = 0;
|
8341 |
|
8342 |
|
8343 |
|
8344 |
|
8345 | function resolveRendererType2(type) {
|
8346 | if (type && type.id === UNDEFINED_RENDERER_TYPE_ID) {
|
8347 |
|
8348 | const isFilled = ((type.encapsulation != null && type.encapsulation !== ViewEncapsulation.None) ||
|
8349 | type.styles.length || Object.keys(type.data).length);
|
8350 | if (isFilled) {
|
8351 | type.id = `c${_renderCompCount++}`;
|
8352 | }
|
8353 | else {
|
8354 | type.id = EMPTY_RENDERER_TYPE_ID;
|
8355 | }
|
8356 | }
|
8357 | if (type && type.id === EMPTY_RENDERER_TYPE_ID) {
|
8358 | type = null;
|
8359 | }
|
8360 | return type || null;
|
8361 | }
|
8362 |
|
8363 |
|
8364 |
|
8365 |
|
8366 |
|
8367 |
|
8368 |
|
8369 | function checkBinding(view, def, bindingIdx, value) {
|
8370 | const oldValues = view.oldValues;
|
8371 | if ((view.state & 2 ) ||
|
8372 | !looseIdentical(oldValues[def.bindingIndex + bindingIdx], value)) {
|
8373 | return true;
|
8374 | }
|
8375 | return false;
|
8376 | }
|
8377 |
|
8378 |
|
8379 |
|
8380 |
|
8381 |
|
8382 |
|
8383 |
|
8384 | function checkAndUpdateBinding(view, def, bindingIdx, value) {
|
8385 | if (checkBinding(view, def, bindingIdx, value)) {
|
8386 | view.oldValues[def.bindingIndex + bindingIdx] = value;
|
8387 | return true;
|
8388 | }
|
8389 | return false;
|
8390 | }
|
8391 |
|
8392 |
|
8393 |
|
8394 |
|
8395 |
|
8396 |
|
8397 |
|
8398 | function checkBindingNoChanges(view, def, bindingIdx, value) {
|
8399 | const oldValue = view.oldValues[def.bindingIndex + bindingIdx];
|
8400 | if ((view.state & 1 ) || !devModeEqual(oldValue, value)) {
|
8401 | throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, def.index), oldValue, value, (view.state & 1 ) !== 0);
|
8402 | }
|
8403 | }
|
8404 |
|
8405 |
|
8406 |
|
8407 |
|
8408 | function markParentViewsForCheck(view) {
|
8409 | let currView = view;
|
8410 | while (currView) {
|
8411 | if (currView.def.flags & 2 ) {
|
8412 | currView.state |= 8 ;
|
8413 | }
|
8414 | currView = currView.viewContainerParent || currView.parent;
|
8415 | }
|
8416 | }
|
8417 |
|
8418 |
|
8419 |
|
8420 |
|
8421 |
|
8422 |
|
8423 |
|
8424 | function dispatchEvent(view, nodeIndex, eventName, event) {
|
8425 | const nodeDef = view.def.nodes[nodeIndex];
|
8426 | const startView = nodeDef.flags & 16777216 ? asElementData(view, nodeIndex).componentView : view;
|
8427 | markParentViewsForCheck(startView);
|
8428 | return Services.handleEvent(view, nodeIndex, eventName, event);
|
8429 | }
|
8430 |
|
8431 |
|
8432 |
|
8433 |
|
8434 | function declaredViewContainer(view) {
|
8435 | if (view.parent) {
|
8436 | const parentView = view.parent;
|
8437 | return asElementData(parentView, ((view.parentNodeDef)).index);
|
8438 | }
|
8439 | return null;
|
8440 | }
|
8441 |
|
8442 |
|
8443 |
|
8444 |
|
8445 |
|
8446 |
|
8447 |
|
8448 | function viewParentEl(view) {
|
8449 | const parentView = view.parent;
|
8450 | if (parentView) {
|
8451 | return ((view.parentNodeDef)).parent;
|
8452 | }
|
8453 | else {
|
8454 | return null;
|
8455 | }
|
8456 | }
|
8457 |
|
8458 |
|
8459 |
|
8460 |
|
8461 |
|
8462 | function renderNode(view, def) {
|
8463 | switch (def.flags & 100673535 ) {
|
8464 | case 1 :
|
8465 | return asElementData(view, def.index).renderElement;
|
8466 | case 2 :
|
8467 | return asTextData(view, def.index).renderText;
|
8468 | }
|
8469 | }
|
8470 |
|
8471 |
|
8472 |
|
8473 |
|
8474 |
|
8475 | function elementEventFullName(target, name) {
|
8476 | return target ? `${target}:${name}` : name;
|
8477 | }
|
8478 |
|
8479 |
|
8480 |
|
8481 |
|
8482 | function isComponentView(view) {
|
8483 | return !!view.parent && !!(((view.parentNodeDef)).flags & 16384 );
|
8484 | }
|
8485 |
|
8486 |
|
8487 |
|
8488 |
|
8489 | function isEmbeddedView(view) {
|
8490 | return !!view.parent && !(((view.parentNodeDef)).flags & 16384 );
|
8491 | }
|
8492 |
|
8493 |
|
8494 |
|
8495 |
|
8496 | function filterQueryId(queryId) {
|
8497 | return 1 << (queryId % 32);
|
8498 | }
|
8499 |
|
8500 |
|
8501 |
|
8502 |
|
8503 | function splitMatchedQueriesDsl(matchedQueriesDsl) {
|
8504 | const matchedQueries = {};
|
8505 | let matchedQueryIds = 0;
|
8506 | const references = {};
|
8507 | if (matchedQueriesDsl) {
|
8508 | matchedQueriesDsl.forEach(([queryId, valueType]) => {
|
8509 | if (typeof queryId === 'number') {
|
8510 | matchedQueries[queryId] = valueType;
|
8511 | matchedQueryIds |= filterQueryId(queryId);
|
8512 | }
|
8513 | else {
|
8514 | references[queryId] = valueType;
|
8515 | }
|
8516 | });
|
8517 | }
|
8518 | return { matchedQueries, references, matchedQueryIds };
|
8519 | }
|
8520 |
|
8521 |
|
8522 |
|
8523 |
|
8524 |
|
8525 |
|
8526 | function getParentRenderElement(view, renderHost, def) {
|
8527 | let renderParent = def.renderParent;
|
8528 | if (renderParent) {
|
8529 | if ((renderParent.flags & 1 ) === 0 ||
|
8530 | (renderParent.flags & 16777216 ) === 0 ||
|
8531 | (((renderParent.element)).componentRendererType && ((((renderParent.element)).componentRendererType)).encapsulation ===
|
8532 | ViewEncapsulation.Native)) {
|
8533 |
|
8534 |
|
8535 | return asElementData(view, ((def.renderParent)).index).renderElement;
|
8536 | }
|
8537 | }
|
8538 | else {
|
8539 | return renderHost;
|
8540 | }
|
8541 | }
|
8542 | const VIEW_DEFINITION_CACHE = new WeakMap();
|
8543 |
|
8544 |
|
8545 |
|
8546 |
|
8547 | function resolveViewDefinition(factory) {
|
8548 | let value = ((VIEW_DEFINITION_CACHE.get(factory)));
|
8549 | if (!value) {
|
8550 | value = factory(() => NOOP);
|
8551 | value.factory = factory;
|
8552 | VIEW_DEFINITION_CACHE.set(factory, value);
|
8553 | }
|
8554 | return value;
|
8555 | }
|
8556 |
|
8557 |
|
8558 |
|
8559 |
|
8560 | function rootRenderNodes(view) {
|
8561 | const renderNodes = [];
|
8562 | visitRootRenderNodes(view, 0 , undefined, undefined, renderNodes);
|
8563 | return renderNodes;
|
8564 | }
|
8565 |
|
8566 |
|
8567 |
|
8568 |
|
8569 |
|
8570 |
|
8571 |
|
8572 |
|
8573 | function visitRootRenderNodes(view, action, parentNode, nextSibling, target) {
|
8574 |
|
8575 | if (action === 3 ) {
|
8576 | parentNode = view.renderer.parentNode(renderNode(view, ((view.def.lastRenderRootNode))));
|
8577 | }
|
8578 | visitSiblingRenderNodes(view, action, 0, view.def.nodes.length - 1, parentNode, nextSibling, target);
|
8579 | }
|
8580 |
|
8581 |
|
8582 |
|
8583 |
|
8584 |
|
8585 |
|
8586 |
|
8587 |
|
8588 |
|
8589 |
|
8590 | function visitSiblingRenderNodes(view, action, startIndex, endIndex, parentNode, nextSibling, target) {
|
8591 | for (let i = startIndex; i <= endIndex; i++) {
|
8592 | const nodeDef = view.def.nodes[i];
|
8593 | if (nodeDef.flags & (1 | 2 | 4 )) {
|
8594 | visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target);
|
8595 | }
|
8596 |
|
8597 | i += nodeDef.childCount;
|
8598 | }
|
8599 | }
|
8600 |
|
8601 |
|
8602 |
|
8603 |
|
8604 |
|
8605 |
|
8606 |
|
8607 |
|
8608 |
|
8609 | function visitProjectedRenderNodes(view, ngContentIndex, action, parentNode, nextSibling, target) {
|
8610 | let compView = view;
|
8611 | while (compView && !isComponentView(compView)) {
|
8612 | compView = compView.parent;
|
8613 | }
|
8614 | const hostView = ((compView)).parent;
|
8615 | const hostElDef = viewParentEl( ((compView)));
|
8616 | const startIndex = ((hostElDef)).index + 1;
|
8617 | const endIndex = ((hostElDef)).index + ((hostElDef)).childCount;
|
8618 | for (let i = startIndex; i <= endIndex; i++) {
|
8619 | const nodeDef = ((hostView)).def.nodes[i];
|
8620 | if (nodeDef.ngContentIndex === ngContentIndex) {
|
8621 | visitRenderNode( ((hostView)), nodeDef, action, parentNode, nextSibling, target);
|
8622 | }
|
8623 |
|
8624 | i += nodeDef.childCount;
|
8625 | }
|
8626 | if (!((hostView)).parent) {
|
8627 |
|
8628 | const projectedNodes = view.root.projectableNodes[ngContentIndex];
|
8629 | if (projectedNodes) {
|
8630 | for (let i = 0; i < projectedNodes.length; i++) {
|
8631 | execRenderNodeAction(view, projectedNodes[i], action, parentNode, nextSibling, target);
|
8632 | }
|
8633 | }
|
8634 | }
|
8635 | }
|
8636 |
|
8637 |
|
8638 |
|
8639 |
|
8640 |
|
8641 |
|
8642 |
|
8643 |
|
8644 |
|
8645 | function visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target) {
|
8646 | if (nodeDef.flags & 4 ) {
|
8647 | visitProjectedRenderNodes(view, ((nodeDef.ngContent)).index, action, parentNode, nextSibling, target);
|
8648 | }
|
8649 | else {
|
8650 | const rn = renderNode(view, nodeDef);
|
8651 | if (action === 3 && (nodeDef.flags & 16777216 ) &&
|
8652 | (nodeDef.bindingFlags & 48 )) {
|
8653 |
|
8654 | if (nodeDef.bindingFlags & (16 )) {
|
8655 | execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
|
8656 | }
|
8657 | if (nodeDef.bindingFlags & (32 )) {
|
8658 | const compView = asElementData(view, nodeDef.index).componentView;
|
8659 | execRenderNodeAction(compView, rn, action, parentNode, nextSibling, target);
|
8660 | }
|
8661 | }
|
8662 | else {
|
8663 | execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
|
8664 | }
|
8665 | if (nodeDef.flags & 8388608 ) {
|
8666 | const embeddedViews = ((asElementData(view, nodeDef.index).viewContainer))._embeddedViews;
|
8667 | for (let k = 0; k < embeddedViews.length; k++) {
|
8668 | visitRootRenderNodes(embeddedViews[k], action, parentNode, nextSibling, target);
|
8669 | }
|
8670 | }
|
8671 | if (nodeDef.flags & 1 && !((nodeDef.element)).name) {
|
8672 | visitSiblingRenderNodes(view, action, nodeDef.index + 1, nodeDef.index + nodeDef.childCount, parentNode, nextSibling, target);
|
8673 | }
|
8674 | }
|
8675 | }
|
8676 |
|
8677 |
|
8678 |
|
8679 |
|
8680 |
|
8681 |
|
8682 |
|
8683 |
|
8684 |
|
8685 | function execRenderNodeAction(view, renderNode, action, parentNode, nextSibling, target) {
|
8686 | const renderer = view.renderer;
|
8687 | switch (action) {
|
8688 | case 1 :
|
8689 | renderer.appendChild(parentNode, renderNode);
|
8690 | break;
|
8691 | case 2 :
|
8692 | renderer.insertBefore(parentNode, renderNode, nextSibling);
|
8693 | break;
|
8694 | case 3 :
|
8695 | renderer.removeChild(parentNode, renderNode);
|
8696 | break;
|
8697 | case 0 :
|
8698 | ((target)).push(renderNode);
|
8699 | break;
|
8700 | }
|
8701 | }
|
8702 | const NS_PREFIX_RE = /^:([^:]+):(.+)$/;
|
8703 |
|
8704 |
|
8705 |
|
8706 |
|
8707 | function splitNamespace(name) {
|
8708 | if (name[0] === ':') {
|
8709 | const match = ((name.match(NS_PREFIX_RE)));
|
8710 | return [match[1], match[2]];
|
8711 | }
|
8712 | return ['', name];
|
8713 | }
|
8714 |
|
8715 |
|
8716 |
|
8717 |
|
8718 | function calcBindingFlags(bindings) {
|
8719 | let flags = 0;
|
8720 | for (let i = 0; i < bindings.length; i++) {
|
8721 | flags |= bindings[i].flags;
|
8722 | }
|
8723 | return flags;
|
8724 | }
|
8725 |
|
8726 |
|
8727 |
|
8728 |
|
8729 |
|
8730 | function interpolate(valueCount, constAndInterp) {
|
8731 | let result = '';
|
8732 | for (let i = 0; i < valueCount * 2; i = i + 2) {
|
8733 | result = result + constAndInterp[i] + _toStringWithNull(constAndInterp[i + 1]);
|
8734 | }
|
8735 | return result + constAndInterp[valueCount * 2];
|
8736 | }
|
8737 |
|
8738 |
|
8739 |
|
8740 |
|
8741 |
|
8742 |
|
8743 |
|
8744 |
|
8745 |
|
8746 |
|
8747 |
|
8748 |
|
8749 |
|
8750 |
|
8751 |
|
8752 |
|
8753 |
|
8754 |
|
8755 |
|
8756 |
|
8757 |
|
8758 |
|
8759 |
|
8760 | function inlineInterpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) {
|
8761 | switch (valueCount) {
|
8762 | case 1:
|
8763 | return c0 + _toStringWithNull(a1) + c1;
|
8764 | case 2:
|
8765 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2;
|
8766 | case 3:
|
8767 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8768 | c3;
|
8769 | case 4:
|
8770 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8771 | c3 + _toStringWithNull(a4) + c4;
|
8772 | case 5:
|
8773 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8774 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5;
|
8775 | case 6:
|
8776 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8777 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6;
|
8778 | case 7:
|
8779 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8780 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
|
8781 | c6 + _toStringWithNull(a7) + c7;
|
8782 | case 8:
|
8783 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8784 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
|
8785 | c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8;
|
8786 | case 9:
|
8787 | return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8788 | c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
|
8789 | c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8 + _toStringWithNull(a9) + c9;
|
8790 | default:
|
8791 | throw new Error(`Does not support more than 9 expressions`);
|
8792 | }
|
8793 | }
|
8794 |
|
8795 |
|
8796 |
|
8797 |
|
8798 | function _toStringWithNull(v) {
|
8799 | return v != null ? v.toString() : '';
|
8800 | }
|
8801 | const EMPTY_ARRAY = [];
|
8802 | const EMPTY_MAP = {};
|
8803 |
|
8804 |
|
8805 |
|
8806 |
|
8807 |
|
8808 |
|
8809 |
|
8810 |
|
8811 |
|
8812 |
|
8813 |
|
8814 |
|
8815 |
|
8816 |
|
8817 |
|
8818 |
|
8819 |
|
8820 | function anchorDef(flags, matchedQueriesDsl, ngContentIndex, childCount, handleEvent, templateFactory) {
|
8821 | flags |= 1 ;
|
8822 | const { matchedQueries, references, matchedQueryIds } = splitMatchedQueriesDsl(matchedQueriesDsl);
|
8823 | const template = templateFactory ? resolveViewDefinition(templateFactory) : null;
|
8824 | return {
|
8825 |
|
8826 | index: -1,
|
8827 | parent: null,
|
8828 | renderParent: null,
|
8829 | bindingIndex: -1,
|
8830 | outputIndex: -1,
|
8831 |
|
8832 | flags,
|
8833 | childFlags: 0,
|
8834 | directChildFlags: 0,
|
8835 | childMatchedQueries: 0, matchedQueries, matchedQueryIds, references, ngContentIndex, childCount,
|
8836 | bindings: [],
|
8837 | bindingFlags: 0,
|
8838 | outputs: [],
|
8839 | element: {
|
8840 | ns: null,
|
8841 | name: null,
|
8842 | attrs: null, template,
|
8843 | componentProvider: null,
|
8844 | componentView: null,
|
8845 | componentRendererType: null,
|
8846 | publicProviders: null,
|
8847 | allProviders: null,
|
8848 | handleEvent: handleEvent || NOOP
|
8849 | },
|
8850 | provider: null,
|
8851 | text: null,
|
8852 | query: null,
|
8853 | ngContent: null
|
8854 | };
|
8855 | }
|
8856 |
|
8857 |
|
8858 |
|
8859 |
|
8860 |
|
8861 |
|
8862 |
|
8863 |
|
8864 |
|
8865 |
|
8866 |
|
8867 |
|
8868 |
|
8869 |
|
8870 | function elementDef(flags, matchedQueriesDsl, ngContentIndex, childCount, namespaceAndName, fixedAttrs = [], bindings, outputs, handleEvent, componentView, componentRendererType) {
|
8871 | if (!handleEvent) {
|
8872 | handleEvent = NOOP;
|
8873 | }
|
8874 | const { matchedQueries, references, matchedQueryIds } = splitMatchedQueriesDsl(matchedQueriesDsl);
|
8875 | let ns = ((null));
|
8876 | let name = ((null));
|
8877 | if (namespaceAndName) {
|
8878 | [ns, name] = splitNamespace(namespaceAndName);
|
8879 | }
|
8880 | bindings = bindings || [];
|
8881 | const bindingDefs = new Array(bindings.length);
|
8882 | for (let i = 0; i < bindings.length; i++) {
|
8883 | const [bindingFlags, namespaceAndName, suffixOrSecurityContext] = bindings[i];
|
8884 | const [ns, name] = splitNamespace(namespaceAndName);
|
8885 | let securityContext = ((undefined));
|
8886 | let suffix = ((undefined));
|
8887 | switch (bindingFlags & 15 ) {
|
8888 | case 4 :
|
8889 | suffix = (suffixOrSecurityContext);
|
8890 | break;
|
8891 | case 1 :
|
8892 | case 8 :
|
8893 | securityContext = (suffixOrSecurityContext);
|
8894 | break;
|
8895 | }
|
8896 | bindingDefs[i] =
|
8897 | { flags: bindingFlags, ns, name, nonMinifiedName: name, securityContext, suffix };
|
8898 | }
|
8899 | outputs = outputs || [];
|
8900 | const outputDefs = new Array(outputs.length);
|
8901 | for (let i = 0; i < outputs.length; i++) {
|
8902 | const [target, eventName] = outputs[i];
|
8903 | outputDefs[i] = {
|
8904 | type: 0 ,
|
8905 | target: (target), eventName,
|
8906 | propName: null
|
8907 | };
|
8908 | }
|
8909 | fixedAttrs = fixedAttrs || [];
|
8910 | const attrs = (fixedAttrs.map(([namespaceAndName, value]) => {
|
8911 | const [ns, name] = splitNamespace(namespaceAndName);
|
8912 | return [ns, name, value];
|
8913 | }));
|
8914 | componentRendererType = resolveRendererType2(componentRendererType);
|
8915 | if (componentView) {
|
8916 | flags |= 16777216 ;
|
8917 | }
|
8918 | flags |= 1 ;
|
8919 | return {
|
8920 |
|
8921 | index: -1,
|
8922 | parent: null,
|
8923 | renderParent: null,
|
8924 | bindingIndex: -1,
|
8925 | outputIndex: -1,
|
8926 |
|
8927 | flags,
|
8928 | childFlags: 0,
|
8929 | directChildFlags: 0,
|
8930 | childMatchedQueries: 0, matchedQueries, matchedQueryIds, references, ngContentIndex, childCount,
|
8931 | bindings: bindingDefs,
|
8932 | bindingFlags: calcBindingFlags(bindingDefs),
|
8933 | outputs: outputDefs,
|
8934 | element: {
|
8935 | ns,
|
8936 | name,
|
8937 | attrs,
|
8938 | template: null,
|
8939 |
|
8940 | componentProvider: null,
|
8941 | componentView: componentView || null,
|
8942 | componentRendererType: componentRendererType,
|
8943 | publicProviders: null,
|
8944 | allProviders: null,
|
8945 | handleEvent: handleEvent || NOOP,
|
8946 | },
|
8947 | provider: null,
|
8948 | text: null,
|
8949 | query: null,
|
8950 | ngContent: null
|
8951 | };
|
8952 | }
|
8953 |
|
8954 |
|
8955 |
|
8956 |
|
8957 |
|
8958 |
|
8959 | function createElement(view, renderHost, def) {
|
8960 | const elDef = ((def.element));
|
8961 | const rootSelectorOrNode = view.root.selectorOrNode;
|
8962 | const renderer = view.renderer;
|
8963 | let el;
|
8964 | if (view.parent || !rootSelectorOrNode) {
|
8965 | if (elDef.name) {
|
8966 | el = renderer.createElement(elDef.name, elDef.ns);
|
8967 | }
|
8968 | else {
|
8969 | el = renderer.createComment('');
|
8970 | }
|
8971 | const parentEl = getParentRenderElement(view, renderHost, def);
|
8972 | if (parentEl) {
|
8973 | renderer.appendChild(parentEl, el);
|
8974 | }
|
8975 | }
|
8976 | else {
|
8977 | el = renderer.selectRootElement(rootSelectorOrNode);
|
8978 | }
|
8979 | if (elDef.attrs) {
|
8980 | for (let i = 0; i < elDef.attrs.length; i++) {
|
8981 | const [ns, name, value] = elDef.attrs[i];
|
8982 | renderer.setAttribute(el, name, value, ns);
|
8983 | }
|
8984 | }
|
8985 | return el;
|
8986 | }
|
8987 |
|
8988 |
|
8989 |
|
8990 |
|
8991 |
|
8992 |
|
8993 |
|
8994 | function listenToElementOutputs(view, compView, def, el) {
|
8995 | for (let i = 0; i < def.outputs.length; i++) {
|
8996 | const output = def.outputs[i];
|
8997 | const handleEventClosure = renderEventHandlerClosure(view, def.index, elementEventFullName(output.target, output.eventName));
|
8998 | let listenTarget = output.target;
|
8999 | let listenerView = view;
|
9000 | if (output.target === 'component') {
|
9001 | listenTarget = null;
|
9002 | listenerView = compView;
|
9003 | }
|
9004 | const disposable = (listenerView.renderer.listen(listenTarget || el, output.eventName, handleEventClosure));
|
9005 | ((view.disposables))[def.outputIndex + i] = disposable;
|
9006 | }
|
9007 | }
|
9008 |
|
9009 |
|
9010 |
|
9011 |
|
9012 |
|
9013 |
|
9014 | function renderEventHandlerClosure(view, index, eventName) {
|
9015 | return (event) => {
|
9016 | try {
|
9017 | return dispatchEvent(view, index, eventName, event);
|
9018 | }
|
9019 | catch (e) {
|
9020 |
|
9021 | view.root.errorHandler.handleError(e);
|
9022 | }
|
9023 | };
|
9024 | }
|
9025 |
|
9026 |
|
9027 |
|
9028 |
|
9029 |
|
9030 |
|
9031 |
|
9032 |
|
9033 |
|
9034 |
|
9035 |
|
9036 |
|
9037 |
|
9038 |
|
9039 |
|
9040 | function checkAndUpdateElementInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
9041 | const bindLen = def.bindings.length;
|
9042 | let changed = false;
|
9043 | if (bindLen > 0 && checkAndUpdateElementValue(view, def, 0, v0))
|
9044 | changed = true;
|
9045 | if (bindLen > 1 && checkAndUpdateElementValue(view, def, 1, v1))
|
9046 | changed = true;
|
9047 | if (bindLen > 2 && checkAndUpdateElementValue(view, def, 2, v2))
|
9048 | changed = true;
|
9049 | if (bindLen > 3 && checkAndUpdateElementValue(view, def, 3, v3))
|
9050 | changed = true;
|
9051 | if (bindLen > 4 && checkAndUpdateElementValue(view, def, 4, v4))
|
9052 | changed = true;
|
9053 | if (bindLen > 5 && checkAndUpdateElementValue(view, def, 5, v5))
|
9054 | changed = true;
|
9055 | if (bindLen > 6 && checkAndUpdateElementValue(view, def, 6, v6))
|
9056 | changed = true;
|
9057 | if (bindLen > 7 && checkAndUpdateElementValue(view, def, 7, v7))
|
9058 | changed = true;
|
9059 | if (bindLen > 8 && checkAndUpdateElementValue(view, def, 8, v8))
|
9060 | changed = true;
|
9061 | if (bindLen > 9 && checkAndUpdateElementValue(view, def, 9, v9))
|
9062 | changed = true;
|
9063 | return changed;
|
9064 | }
|
9065 |
|
9066 |
|
9067 |
|
9068 |
|
9069 |
|
9070 |
|
9071 | function checkAndUpdateElementDynamic(view, def, values) {
|
9072 | let changed = false;
|
9073 | for (let i = 0; i < values.length; i++) {
|
9074 | if (checkAndUpdateElementValue(view, def, i, values[i]))
|
9075 | changed = true;
|
9076 | }
|
9077 | return changed;
|
9078 | }
|
9079 |
|
9080 |
|
9081 |
|
9082 |
|
9083 |
|
9084 |
|
9085 |
|
9086 | function checkAndUpdateElementValue(view, def, bindingIdx, value) {
|
9087 | if (!checkAndUpdateBinding(view, def, bindingIdx, value)) {
|
9088 | return false;
|
9089 | }
|
9090 | const binding = def.bindings[bindingIdx];
|
9091 | const elData = asElementData(view, def.index);
|
9092 | const renderNode$$1 = elData.renderElement;
|
9093 | const name = ((binding.name));
|
9094 | switch (binding.flags & 15 ) {
|
9095 | case 1 :
|
9096 | setElementAttribute(view, binding, renderNode$$1, binding.ns, name, value);
|
9097 | break;
|
9098 | case 2 :
|
9099 | setElementClass(view, renderNode$$1, name, value);
|
9100 | break;
|
9101 | case 4 :
|
9102 | setElementStyle(view, binding, renderNode$$1, name, value);
|
9103 | break;
|
9104 | case 8 :
|
9105 | const bindView = (def.flags & 16777216 &&
|
9106 | binding.flags & 32 ) ?
|
9107 | elData.componentView :
|
9108 | view;
|
9109 | setElementProperty(bindView, binding, renderNode$$1, name, value);
|
9110 | break;
|
9111 | }
|
9112 | return true;
|
9113 | }
|
9114 |
|
9115 |
|
9116 |
|
9117 |
|
9118 |
|
9119 |
|
9120 |
|
9121 |
|
9122 |
|
9123 | function setElementAttribute(view, binding, renderNode$$1, ns, name, value) {
|
9124 | const securityContext = binding.securityContext;
|
9125 | let renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
|
9126 | renderValue = renderValue != null ? renderValue.toString() : null;
|
9127 | const renderer = view.renderer;
|
9128 | if (value != null) {
|
9129 | renderer.setAttribute(renderNode$$1, name, renderValue, ns);
|
9130 | }
|
9131 | else {
|
9132 | renderer.removeAttribute(renderNode$$1, name, ns);
|
9133 | }
|
9134 | }
|
9135 |
|
9136 |
|
9137 |
|
9138 |
|
9139 |
|
9140 |
|
9141 |
|
9142 | function setElementClass(view, renderNode$$1, name, value) {
|
9143 | const renderer = view.renderer;
|
9144 | if (value) {
|
9145 | renderer.addClass(renderNode$$1, name);
|
9146 | }
|
9147 | else {
|
9148 | renderer.removeClass(renderNode$$1, name);
|
9149 | }
|
9150 | }
|
9151 |
|
9152 |
|
9153 |
|
9154 |
|
9155 |
|
9156 |
|
9157 |
|
9158 |
|
9159 | function setElementStyle(view, binding, renderNode$$1, name, value) {
|
9160 | let renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, (value));
|
9161 | if (renderValue != null) {
|
9162 | renderValue = renderValue.toString();
|
9163 | const unit = binding.suffix;
|
9164 | if (unit != null) {
|
9165 | renderValue = renderValue + unit;
|
9166 | }
|
9167 | }
|
9168 | else {
|
9169 | renderValue = null;
|
9170 | }
|
9171 | const renderer = view.renderer;
|
9172 | if (renderValue != null) {
|
9173 | renderer.setStyle(renderNode$$1, name, renderValue);
|
9174 | }
|
9175 | else {
|
9176 | renderer.removeStyle(renderNode$$1, name);
|
9177 | }
|
9178 | }
|
9179 |
|
9180 |
|
9181 |
|
9182 |
|
9183 |
|
9184 |
|
9185 |
|
9186 |
|
9187 | function setElementProperty(view, binding, renderNode$$1, name, value) {
|
9188 | const securityContext = binding.securityContext;
|
9189 | let renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
|
9190 | view.renderer.setProperty(renderNode$$1, name, renderValue);
|
9191 | }
|
9192 |
|
9193 |
|
9194 |
|
9195 |
|
9196 |
|
9197 |
|
9198 |
|
9199 |
|
9200 |
|
9201 |
|
9202 |
|
9203 |
|
9204 |
|
9205 | function ngContentDef(ngContentIndex, index) {
|
9206 | return {
|
9207 |
|
9208 | index: -1,
|
9209 | parent: null,
|
9210 | renderParent: null,
|
9211 | bindingIndex: -1,
|
9212 | outputIndex: -1,
|
9213 |
|
9214 | flags: 4 ,
|
9215 | childFlags: 0,
|
9216 | directChildFlags: 0,
|
9217 | childMatchedQueries: 0,
|
9218 | matchedQueries: {},
|
9219 | matchedQueryIds: 0,
|
9220 | references: {}, ngContentIndex,
|
9221 | childCount: 0,
|
9222 | bindings: [],
|
9223 | bindingFlags: 0,
|
9224 | outputs: [],
|
9225 | element: null,
|
9226 | provider: null,
|
9227 | text: null,
|
9228 | query: null,
|
9229 | ngContent: { index }
|
9230 | };
|
9231 | }
|
9232 |
|
9233 |
|
9234 |
|
9235 |
|
9236 |
|
9237 |
|
9238 | function appendNgContent(view, renderHost, def) {
|
9239 | const parentEl = getParentRenderElement(view, renderHost, def);
|
9240 | if (!parentEl) {
|
9241 |
|
9242 | return;
|
9243 | }
|
9244 | const ngContentIndex = ((def.ngContent)).index;
|
9245 | visitProjectedRenderNodes(view, ngContentIndex, 1 , parentEl, null, undefined);
|
9246 | }
|
9247 |
|
9248 |
|
9249 |
|
9250 |
|
9251 |
|
9252 |
|
9253 |
|
9254 |
|
9255 |
|
9256 |
|
9257 |
|
9258 |
|
9259 |
|
9260 |
|
9261 |
|
9262 | function attachEmbeddedView(parentView, elementData, viewIndex, view) {
|
9263 | let embeddedViews = ((elementData.viewContainer))._embeddedViews;
|
9264 | if (viewIndex === null || viewIndex === undefined) {
|
9265 | viewIndex = embeddedViews.length;
|
9266 | }
|
9267 | view.viewContainerParent = parentView;
|
9268 | addToArray(embeddedViews, ((viewIndex)), view);
|
9269 | const dvcElementData = declaredViewContainer(view);
|
9270 | if (dvcElementData && dvcElementData !== elementData) {
|
9271 | let projectedViews = dvcElementData.template._projectedViews;
|
9272 | if (!projectedViews) {
|
9273 | projectedViews = dvcElementData.template._projectedViews = [];
|
9274 | }
|
9275 | projectedViews.push(view);
|
9276 | }
|
9277 | Services.dirtyParentQueries(view);
|
9278 | const prevView = ((viewIndex)) > 0 ? embeddedViews[((viewIndex)) - 1] : null;
|
9279 | renderAttachEmbeddedView(elementData, prevView, view);
|
9280 | }
|
9281 |
|
9282 |
|
9283 |
|
9284 |
|
9285 |
|
9286 | function detachEmbeddedView(elementData, viewIndex) {
|
9287 | const embeddedViews = ((elementData.viewContainer))._embeddedViews;
|
9288 | if (viewIndex == null || viewIndex >= embeddedViews.length) {
|
9289 | viewIndex = embeddedViews.length - 1;
|
9290 | }
|
9291 | if (viewIndex < 0) {
|
9292 | return null;
|
9293 | }
|
9294 | const view = embeddedViews[viewIndex];
|
9295 | view.viewContainerParent = null;
|
9296 | removeFromArray(embeddedViews, viewIndex);
|
9297 | const dvcElementData = declaredViewContainer(view);
|
9298 | if (dvcElementData && dvcElementData !== elementData) {
|
9299 | const projectedViews = dvcElementData.template._projectedViews;
|
9300 | removeFromArray(projectedViews, projectedViews.indexOf(view));
|
9301 | }
|
9302 | Services.dirtyParentQueries(view);
|
9303 | renderDetachView(view);
|
9304 | return view;
|
9305 | }
|
9306 |
|
9307 |
|
9308 |
|
9309 |
|
9310 |
|
9311 |
|
9312 | function moveEmbeddedView(elementData, oldViewIndex, newViewIndex) {
|
9313 | const embeddedViews = ((elementData.viewContainer))._embeddedViews;
|
9314 | const view = embeddedViews[oldViewIndex];
|
9315 | removeFromArray(embeddedViews, oldViewIndex);
|
9316 | if (newViewIndex == null) {
|
9317 | newViewIndex = embeddedViews.length;
|
9318 | }
|
9319 | addToArray(embeddedViews, newViewIndex, view);
|
9320 |
|
9321 |
|
9322 | Services.dirtyParentQueries(view);
|
9323 | renderDetachView(view);
|
9324 | const prevView = newViewIndex > 0 ? embeddedViews[newViewIndex - 1] : null;
|
9325 | renderAttachEmbeddedView(elementData, prevView, view);
|
9326 | return view;
|
9327 | }
|
9328 |
|
9329 |
|
9330 |
|
9331 |
|
9332 |
|
9333 |
|
9334 | function renderAttachEmbeddedView(elementData, prevView, view) {
|
9335 | const prevRenderNode = prevView ? renderNode(prevView, ((prevView.def.lastRenderRootNode))) :
|
9336 | elementData.renderElement;
|
9337 | const parentNode = view.renderer.parentNode(prevRenderNode);
|
9338 | const nextSibling = view.renderer.nextSibling(prevRenderNode);
|
9339 |
|
9340 |
|
9341 | visitRootRenderNodes(view, 2 , parentNode, nextSibling, undefined);
|
9342 | }
|
9343 |
|
9344 |
|
9345 |
|
9346 |
|
9347 | function renderDetachView(view) {
|
9348 | visitRootRenderNodes(view, 3 , null, null, undefined);
|
9349 | }
|
9350 |
|
9351 |
|
9352 |
|
9353 |
|
9354 |
|
9355 |
|
9356 | function addToArray(arr, index, value) {
|
9357 |
|
9358 | if (index >= arr.length) {
|
9359 | arr.push(value);
|
9360 | }
|
9361 | else {
|
9362 | arr.splice(index, 0, value);
|
9363 | }
|
9364 | }
|
9365 |
|
9366 |
|
9367 |
|
9368 |
|
9369 |
|
9370 | function removeFromArray(arr, index) {
|
9371 |
|
9372 | if (index >= arr.length - 1) {
|
9373 | arr.pop();
|
9374 | }
|
9375 | else {
|
9376 | arr.splice(index, 1);
|
9377 | }
|
9378 | }
|
9379 |
|
9380 |
|
9381 |
|
9382 |
|
9383 |
|
9384 |
|
9385 |
|
9386 |
|
9387 | const EMPTY_CONTEXT = new Object();
|
9388 |
|
9389 |
|
9390 |
|
9391 |
|
9392 |
|
9393 |
|
9394 |
|
9395 |
|
9396 |
|
9397 | function createComponentFactory(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors) {
|
9398 | return new ComponentFactory_(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors);
|
9399 | }
|
9400 |
|
9401 |
|
9402 |
|
9403 |
|
9404 | function getComponentViewDefinitionFactory(componentFactory) {
|
9405 | return ((componentFactory)).viewDefFactory;
|
9406 | }
|
9407 | class ComponentFactory_ extends ComponentFactory {
|
9408 | |
9409 |
|
9410 |
|
9411 |
|
9412 |
|
9413 |
|
9414 |
|
9415 |
|
9416 | constructor(selector, componentType, viewDefFactory, _inputs, _outputs, ngContentSelectors) {
|
9417 |
|
9418 |
|
9419 | super();
|
9420 | this.selector = selector;
|
9421 | this.componentType = componentType;
|
9422 | this._inputs = _inputs;
|
9423 | this._outputs = _outputs;
|
9424 | this.ngContentSelectors = ngContentSelectors;
|
9425 | this.viewDefFactory = viewDefFactory;
|
9426 | }
|
9427 | |
9428 |
|
9429 |
|
9430 | get inputs() {
|
9431 | const inputsArr = [];
|
9432 | const inputs = ((this._inputs));
|
9433 | for (let propName in inputs) {
|
9434 | const templateName = inputs[propName];
|
9435 | inputsArr.push({ propName, templateName });
|
9436 | }
|
9437 | return inputsArr;
|
9438 | }
|
9439 | |
9440 |
|
9441 |
|
9442 | get outputs() {
|
9443 | const outputsArr = [];
|
9444 | for (let propName in this._outputs) {
|
9445 | const templateName = this._outputs[propName];
|
9446 | outputsArr.push({ propName, templateName });
|
9447 | }
|
9448 | return outputsArr;
|
9449 | }
|
9450 | |
9451 |
|
9452 |
|
9453 |
|
9454 |
|
9455 |
|
9456 |
|
9457 |
|
9458 | create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
|
9459 | if (!ngModule) {
|
9460 | throw new Error('ngModule should be provided');
|
9461 | }
|
9462 | const viewDef = resolveViewDefinition(this.viewDefFactory);
|
9463 | const componentNodeIndex = ((((viewDef.nodes[0].element)).componentProvider)).index;
|
9464 | const view = Services.createRootView(injector, projectableNodes || [], rootSelectorOrNode, viewDef, ngModule, EMPTY_CONTEXT);
|
9465 | const component = asProviderData(view, componentNodeIndex).instance;
|
9466 | if (rootSelectorOrNode) {
|
9467 | view.renderer.setAttribute(asElementData(view, 0).renderElement, 'ng-version', VERSION.full);
|
9468 | }
|
9469 | return new ComponentRef_(view, new ViewRef_(view), component);
|
9470 | }
|
9471 | }
|
9472 | class ComponentRef_ extends ComponentRef {
|
9473 | |
9474 |
|
9475 |
|
9476 |
|
9477 |
|
9478 | constructor(_view, _viewRef, _component) {
|
9479 | super();
|
9480 | this._view = _view;
|
9481 | this._viewRef = _viewRef;
|
9482 | this._component = _component;
|
9483 | this._elDef = this._view.def.nodes[0];
|
9484 | }
|
9485 | |
9486 |
|
9487 |
|
9488 | get location() {
|
9489 | return new ElementRef(asElementData(this._view, this._elDef.index).renderElement);
|
9490 | }
|
9491 | |
9492 |
|
9493 |
|
9494 | get injector() { return new Injector_(this._view, this._elDef); }
|
9495 | |
9496 |
|
9497 |
|
9498 | get instance() { return this._component; }
|
9499 | ;
|
9500 | |
9501 |
|
9502 |
|
9503 | get hostView() { return this._viewRef; }
|
9504 | ;
|
9505 | |
9506 |
|
9507 |
|
9508 | get changeDetectorRef() { return this._viewRef; }
|
9509 | ;
|
9510 | |
9511 |
|
9512 |
|
9513 | get componentType() { return (this._component.constructor); }
|
9514 | |
9515 |
|
9516 |
|
9517 | destroy() { this._viewRef.destroy(); }
|
9518 | |
9519 |
|
9520 |
|
9521 |
|
9522 | onDestroy(callback) { this._viewRef.onDestroy(callback); }
|
9523 | }
|
9524 |
|
9525 |
|
9526 |
|
9527 |
|
9528 |
|
9529 |
|
9530 | function createViewContainerData(view, elDef, elData) {
|
9531 | return new ViewContainerRef_(view, elDef, elData);
|
9532 | }
|
9533 | class ViewContainerRef_ {
|
9534 | |
9535 |
|
9536 |
|
9537 |
|
9538 |
|
9539 | constructor(_view, _elDef, _data) {
|
9540 | this._view = _view;
|
9541 | this._elDef = _elDef;
|
9542 | this._data = _data;
|
9543 | |
9544 |
|
9545 |
|
9546 | this._embeddedViews = [];
|
9547 | }
|
9548 | |
9549 |
|
9550 |
|
9551 | get element() { return new ElementRef(this._data.renderElement); }
|
9552 | |
9553 |
|
9554 |
|
9555 | get injector() { return new Injector_(this._view, this._elDef); }
|
9556 | |
9557 |
|
9558 |
|
9559 | get parentInjector() {
|
9560 | let view = this._view;
|
9561 | let elDef = this._elDef.parent;
|
9562 | while (!elDef && view) {
|
9563 | elDef = viewParentEl(view);
|
9564 | view = ((view.parent));
|
9565 | }
|
9566 | return view ? new Injector_(view, elDef) : new Injector_(this._view, null);
|
9567 | }
|
9568 | |
9569 |
|
9570 |
|
9571 | clear() {
|
9572 | const len = this._embeddedViews.length;
|
9573 | for (let i = len - 1; i >= 0; i--) {
|
9574 | const view = ((detachEmbeddedView(this._data, i)));
|
9575 | Services.destroyView(view);
|
9576 | }
|
9577 | }
|
9578 | |
9579 |
|
9580 |
|
9581 |
|
9582 | get(index) {
|
9583 | const view = this._embeddedViews[index];
|
9584 | if (view) {
|
9585 | const ref = new ViewRef_(view);
|
9586 | ref.attachToViewContainerRef(this);
|
9587 | return ref;
|
9588 | }
|
9589 | return null;
|
9590 | }
|
9591 | |
9592 |
|
9593 |
|
9594 | get length() { return this._embeddedViews.length; }
|
9595 | ;
|
9596 | |
9597 |
|
9598 |
|
9599 |
|
9600 |
|
9601 |
|
9602 |
|
9603 | createEmbeddedView(templateRef, context, index) {
|
9604 | const viewRef = templateRef.createEmbeddedView(context || ({}));
|
9605 | this.insert(viewRef, index);
|
9606 | return viewRef;
|
9607 | }
|
9608 | |
9609 |
|
9610 |
|
9611 |
|
9612 |
|
9613 |
|
9614 |
|
9615 |
|
9616 |
|
9617 | createComponent(componentFactory, index, injector, projectableNodes, ngModuleRef) {
|
9618 | const contextInjector = injector || this.parentInjector;
|
9619 | if (!ngModuleRef && !(componentFactory instanceof ComponentFactoryBoundToModule)) {
|
9620 | ngModuleRef = contextInjector.get(NgModuleRef);
|
9621 | }
|
9622 | const componentRef = componentFactory.create(contextInjector, projectableNodes, undefined, ngModuleRef);
|
9623 | this.insert(componentRef.hostView, index);
|
9624 | return componentRef;
|
9625 | }
|
9626 | |
9627 |
|
9628 |
|
9629 |
|
9630 |
|
9631 | insert(viewRef, index) {
|
9632 | const viewRef_ = (viewRef);
|
9633 | const viewData = viewRef_._view;
|
9634 | attachEmbeddedView(this._view, this._data, index, viewData);
|
9635 | viewRef_.attachToViewContainerRef(this);
|
9636 | return viewRef;
|
9637 | }
|
9638 | |
9639 |
|
9640 |
|
9641 |
|
9642 |
|
9643 | move(viewRef, currentIndex) {
|
9644 | const previousIndex = this._embeddedViews.indexOf(viewRef._view);
|
9645 | moveEmbeddedView(this._data, previousIndex, currentIndex);
|
9646 | return viewRef;
|
9647 | }
|
9648 | |
9649 |
|
9650 |
|
9651 |
|
9652 | indexOf(viewRef) {
|
9653 | return this._embeddedViews.indexOf(((viewRef))._view);
|
9654 | }
|
9655 | |
9656 |
|
9657 |
|
9658 |
|
9659 | remove(index) {
|
9660 | const viewData = detachEmbeddedView(this._data, index);
|
9661 | if (viewData) {
|
9662 | Services.destroyView(viewData);
|
9663 | }
|
9664 | }
|
9665 | |
9666 |
|
9667 |
|
9668 |
|
9669 | detach(index) {
|
9670 | const view = detachEmbeddedView(this._data, index);
|
9671 | return view ? new ViewRef_(view) : null;
|
9672 | }
|
9673 | }
|
9674 |
|
9675 |
|
9676 |
|
9677 |
|
9678 | function createChangeDetectorRef(view) {
|
9679 | return new ViewRef_(view);
|
9680 | }
|
9681 | class ViewRef_ {
|
9682 | |
9683 |
|
9684 |
|
9685 | constructor(_view) {
|
9686 | this._view = _view;
|
9687 | this._viewContainerRef = null;
|
9688 | this._appRef = null;
|
9689 | }
|
9690 | |
9691 |
|
9692 |
|
9693 | get rootNodes() { return rootRenderNodes(this._view); }
|
9694 | |
9695 |
|
9696 |
|
9697 | get context() { return this._view.context; }
|
9698 | |
9699 |
|
9700 |
|
9701 | get destroyed() { return (this._view.state & 16 ) !== 0; }
|
9702 | |
9703 |
|
9704 |
|
9705 | markForCheck() { markParentViewsForCheck(this._view); }
|
9706 | |
9707 |
|
9708 |
|
9709 | detach() { this._view.state &= ~4 ; }
|
9710 | |
9711 |
|
9712 |
|
9713 | detectChanges() { Services.checkAndUpdateView(this._view); }
|
9714 | |
9715 |
|
9716 |
|
9717 | checkNoChanges() { Services.checkNoChangesView(this._view); }
|
9718 | |
9719 |
|
9720 |
|
9721 | reattach() { this._view.state |= 4 ; }
|
9722 | |
9723 |
|
9724 |
|
9725 |
|
9726 | onDestroy(callback) {
|
9727 | if (!this._view.disposables) {
|
9728 | this._view.disposables = [];
|
9729 | }
|
9730 | this._view.disposables.push( (callback));
|
9731 | }
|
9732 | |
9733 |
|
9734 |
|
9735 | destroy() {
|
9736 | if (this._appRef) {
|
9737 | this._appRef.detachView(this);
|
9738 | }
|
9739 | else if (this._viewContainerRef) {
|
9740 | this._viewContainerRef.detach(this._viewContainerRef.indexOf(this));
|
9741 | }
|
9742 | Services.destroyView(this._view);
|
9743 | }
|
9744 | |
9745 |
|
9746 |
|
9747 | detachFromAppRef() {
|
9748 | this._appRef = null;
|
9749 | renderDetachView(this._view);
|
9750 | Services.dirtyParentQueries(this._view);
|
9751 | }
|
9752 | |
9753 |
|
9754 |
|
9755 |
|
9756 | attachToAppRef(appRef) {
|
9757 | if (this._viewContainerRef) {
|
9758 | throw new Error('This view is already attached to a ViewContainer!');
|
9759 | }
|
9760 | this._appRef = appRef;
|
9761 | }
|
9762 | |
9763 |
|
9764 |
|
9765 |
|
9766 | attachToViewContainerRef(vcRef) {
|
9767 | if (this._appRef) {
|
9768 | throw new Error('This view is already attached directly to the ApplicationRef!');
|
9769 | }
|
9770 | this._viewContainerRef = vcRef;
|
9771 | }
|
9772 | }
|
9773 |
|
9774 |
|
9775 |
|
9776 |
|
9777 |
|
9778 | function createTemplateData(view, def) {
|
9779 | return new TemplateRef_(view, def);
|
9780 | }
|
9781 | class TemplateRef_ extends TemplateRef {
|
9782 | |
9783 |
|
9784 |
|
9785 |
|
9786 | constructor(_parentView, _def) {
|
9787 | super();
|
9788 | this._parentView = _parentView;
|
9789 | this._def = _def;
|
9790 | }
|
9791 | |
9792 |
|
9793 |
|
9794 |
|
9795 | createEmbeddedView(context) {
|
9796 | return new ViewRef_(Services.createEmbeddedView(this._parentView, this._def, context));
|
9797 | }
|
9798 | |
9799 |
|
9800 |
|
9801 | get elementRef() {
|
9802 | return new ElementRef(asElementData(this._parentView, this._def.index).renderElement);
|
9803 | }
|
9804 | }
|
9805 |
|
9806 |
|
9807 |
|
9808 |
|
9809 |
|
9810 | function createInjector(view, elDef) {
|
9811 | return new Injector_(view, elDef);
|
9812 | }
|
9813 | class Injector_ {
|
9814 | |
9815 |
|
9816 |
|
9817 |
|
9818 | constructor(view, elDef) {
|
9819 | this.view = view;
|
9820 | this.elDef = elDef;
|
9821 | }
|
9822 | |
9823 |
|
9824 |
|
9825 |
|
9826 |
|
9827 | get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
|
9828 | const allowPrivateServices = this.elDef ? (this.elDef.flags & 16777216 ) !== 0 : false;
|
9829 | return Services.resolveDep(this.view, this.elDef, allowPrivateServices, { flags: 0 , token, tokenKey: tokenKey(token) }, notFoundValue);
|
9830 | }
|
9831 | }
|
9832 |
|
9833 |
|
9834 |
|
9835 |
|
9836 |
|
9837 | function nodeValue(view, index) {
|
9838 | const def = view.def.nodes[index];
|
9839 | if (def.flags & 1 ) {
|
9840 | const elData = asElementData(view, def.index);
|
9841 | return ((def.element)).template ? elData.template : elData.renderElement;
|
9842 | }
|
9843 | else if (def.flags & 2 ) {
|
9844 | return asTextData(view, def.index).renderText;
|
9845 | }
|
9846 | else if (def.flags & (10112 | 8 )) {
|
9847 | return asProviderData(view, def.index).instance;
|
9848 | }
|
9849 | throw new Error(`Illegal state: read nodeValue for node index ${index}`);
|
9850 | }
|
9851 |
|
9852 |
|
9853 |
|
9854 |
|
9855 | function createRendererV1(view) {
|
9856 | return new RendererAdapter(view.renderer);
|
9857 | }
|
9858 | class RendererAdapter {
|
9859 | |
9860 |
|
9861 |
|
9862 | constructor(delegate) {
|
9863 | this.delegate = delegate;
|
9864 | }
|
9865 | |
9866 |
|
9867 |
|
9868 |
|
9869 | selectRootElement(selectorOrNode) {
|
9870 | return this.delegate.selectRootElement(selectorOrNode);
|
9871 | }
|
9872 | |
9873 |
|
9874 |
|
9875 |
|
9876 |
|
9877 | createElement(parent, namespaceAndName) {
|
9878 | const [ns, name] = splitNamespace(namespaceAndName);
|
9879 | const el = this.delegate.createElement(name, ns);
|
9880 | if (parent) {
|
9881 | this.delegate.appendChild(parent, el);
|
9882 | }
|
9883 | return el;
|
9884 | }
|
9885 | |
9886 |
|
9887 |
|
9888 |
|
9889 | createViewRoot(hostElement) { return hostElement; }
|
9890 | |
9891 |
|
9892 |
|
9893 |
|
9894 | createTemplateAnchor(parentElement) {
|
9895 | const comment = this.delegate.createComment('');
|
9896 | if (parentElement) {
|
9897 | this.delegate.appendChild(parentElement, comment);
|
9898 | }
|
9899 | return comment;
|
9900 | }
|
9901 | |
9902 |
|
9903 |
|
9904 |
|
9905 |
|
9906 | createText(parentElement, value) {
|
9907 | const node = this.delegate.createText(value);
|
9908 | if (parentElement) {
|
9909 | this.delegate.appendChild(parentElement, node);
|
9910 | }
|
9911 | return node;
|
9912 | }
|
9913 | |
9914 |
|
9915 |
|
9916 |
|
9917 |
|
9918 | projectNodes(parentElement, nodes) {
|
9919 | for (let i = 0; i < nodes.length; i++) {
|
9920 | this.delegate.appendChild(parentElement, nodes[i]);
|
9921 | }
|
9922 | }
|
9923 | |
9924 |
|
9925 |
|
9926 |
|
9927 |
|
9928 | attachViewAfter(node, viewRootNodes) {
|
9929 | const parentElement = this.delegate.parentNode(node);
|
9930 | const nextSibling = this.delegate.nextSibling(node);
|
9931 | for (let i = 0; i < viewRootNodes.length; i++) {
|
9932 | this.delegate.insertBefore(parentElement, viewRootNodes[i], nextSibling);
|
9933 | }
|
9934 | }
|
9935 | |
9936 |
|
9937 |
|
9938 |
|
9939 | detachView(viewRootNodes) {
|
9940 | for (let i = 0; i < viewRootNodes.length; i++) {
|
9941 | const node = viewRootNodes[i];
|
9942 | const parentElement = this.delegate.parentNode(node);
|
9943 | this.delegate.removeChild(parentElement, node);
|
9944 | }
|
9945 | }
|
9946 | |
9947 |
|
9948 |
|
9949 |
|
9950 |
|
9951 | destroyView(hostElement, viewAllNodes) {
|
9952 | for (let i = 0; i < viewAllNodes.length; i++) {
|
9953 | ((this.delegate.destroyNode))(viewAllNodes[i]);
|
9954 | }
|
9955 | }
|
9956 | |
9957 |
|
9958 |
|
9959 |
|
9960 |
|
9961 |
|
9962 | listen(renderElement, name, callback) {
|
9963 | return this.delegate.listen(renderElement, name, (callback));
|
9964 | }
|
9965 | |
9966 |
|
9967 |
|
9968 |
|
9969 |
|
9970 |
|
9971 | listenGlobal(target, name, callback) {
|
9972 | return this.delegate.listen(target, name, (callback));
|
9973 | }
|
9974 | |
9975 |
|
9976 |
|
9977 |
|
9978 |
|
9979 |
|
9980 | setElementProperty(renderElement, propertyName, propertyValue) {
|
9981 | this.delegate.setProperty(renderElement, propertyName, propertyValue);
|
9982 | }
|
9983 | |
9984 |
|
9985 |
|
9986 |
|
9987 |
|
9988 |
|
9989 | setElementAttribute(renderElement, namespaceAndName, attributeValue) {
|
9990 | const [ns, name] = splitNamespace(namespaceAndName);
|
9991 | if (attributeValue != null) {
|
9992 | this.delegate.setAttribute(renderElement, name, attributeValue, ns);
|
9993 | }
|
9994 | else {
|
9995 | this.delegate.removeAttribute(renderElement, name, ns);
|
9996 | }
|
9997 | }
|
9998 | |
9999 |
|
10000 |
|
10001 |
|
10002 |
|
10003 |
|
10004 | setBindingDebugInfo(renderElement, propertyName, propertyValue) { }
|
10005 | |
10006 |
|
10007 |
|
10008 |
|
10009 |
|
10010 |
|
10011 | setElementClass(renderElement, className, isAdd) {
|
10012 | if (isAdd) {
|
10013 | this.delegate.addClass(renderElement, className);
|
10014 | }
|
10015 | else {
|
10016 | this.delegate.removeClass(renderElement, className);
|
10017 | }
|
10018 | }
|
10019 | |
10020 |
|
10021 |
|
10022 |
|
10023 |
|
10024 |
|
10025 | setElementStyle(renderElement, styleName, styleValue) {
|
10026 | if (styleValue != null) {
|
10027 | this.delegate.setStyle(renderElement, styleName, styleValue);
|
10028 | }
|
10029 | else {
|
10030 | this.delegate.removeStyle(renderElement, styleName);
|
10031 | }
|
10032 | }
|
10033 | |
10034 |
|
10035 |
|
10036 |
|
10037 |
|
10038 |
|
10039 | invokeElementMethod(renderElement, methodName, args) {
|
10040 | ((renderElement))[methodName].apply(renderElement, args);
|
10041 | }
|
10042 | |
10043 |
|
10044 |
|
10045 |
|
10046 |
|
10047 | setText(renderNode$$1, text) { this.delegate.setValue(renderNode$$1, text); }
|
10048 | |
10049 |
|
10050 |
|
10051 | animate() { throw new Error('Renderer.animate is no longer supported!'); }
|
10052 | }
|
10053 |
|
10054 |
|
10055 |
|
10056 |
|
10057 |
|
10058 |
|
10059 |
|
10060 |
|
10061 | const RendererV1TokenKey = tokenKey(Renderer);
|
10062 | const Renderer2TokenKey = tokenKey(Renderer2);
|
10063 | const ElementRefTokenKey = tokenKey(ElementRef);
|
10064 | const ViewContainerRefTokenKey = tokenKey(ViewContainerRef);
|
10065 | const TemplateRefTokenKey = tokenKey(TemplateRef);
|
10066 | const ChangeDetectorRefTokenKey = tokenKey(ChangeDetectorRef);
|
10067 | const InjectorRefTokenKey = tokenKey(Injector);
|
10068 | const NOT_CREATED = new Object();
|
10069 |
|
10070 |
|
10071 |
|
10072 |
|
10073 |
|
10074 |
|
10075 |
|
10076 |
|
10077 |
|
10078 |
|
10079 | function directiveDef(flags, matchedQueries, childCount, ctor, deps, props, outputs) {
|
10080 | const bindings = [];
|
10081 | if (props) {
|
10082 | for (let prop in props) {
|
10083 | const [bindingIndex, nonMinifiedName] = props[prop];
|
10084 | bindings[bindingIndex] = {
|
10085 | flags: 8 ,
|
10086 | name: prop, nonMinifiedName,
|
10087 | ns: null,
|
10088 | securityContext: null,
|
10089 | suffix: null
|
10090 | };
|
10091 | }
|
10092 | }
|
10093 | const outputDefs = [];
|
10094 | if (outputs) {
|
10095 | for (let propName in outputs) {
|
10096 | outputDefs.push({ type: 1 , propName, target: null, eventName: outputs[propName] });
|
10097 | }
|
10098 | }
|
10099 | flags |= 8192 ;
|
10100 | return _def(flags, matchedQueries, childCount, ctor, ctor, deps, bindings, outputDefs);
|
10101 | }
|
10102 |
|
10103 |
|
10104 |
|
10105 |
|
10106 |
|
10107 |
|
10108 | function pipeDef(flags, ctor, deps) {
|
10109 | flags |= 8 ;
|
10110 | return _def(flags, null, 0, ctor, ctor, deps);
|
10111 | }
|
10112 |
|
10113 |
|
10114 |
|
10115 |
|
10116 |
|
10117 |
|
10118 |
|
10119 |
|
10120 | function providerDef(flags, matchedQueries, token, value, deps) {
|
10121 | return _def(flags, matchedQueries, 0, token, value, deps);
|
10122 | }
|
10123 |
|
10124 |
|
10125 |
|
10126 |
|
10127 |
|
10128 |
|
10129 |
|
10130 |
|
10131 |
|
10132 |
|
10133 |
|
10134 | function _def(flags, matchedQueriesDsl, childCount, token, value, deps, bindings, outputs) {
|
10135 | const { matchedQueries, references, matchedQueryIds } = splitMatchedQueriesDsl(matchedQueriesDsl);
|
10136 | if (!outputs) {
|
10137 | outputs = [];
|
10138 | }
|
10139 | if (!bindings) {
|
10140 | bindings = [];
|
10141 | }
|
10142 | const depDefs = deps.map(value => {
|
10143 | let token;
|
10144 | let flags;
|
10145 | if (Array.isArray(value)) {
|
10146 | [flags, token] = value;
|
10147 | }
|
10148 | else {
|
10149 | flags = 0 ;
|
10150 | token = value;
|
10151 | }
|
10152 | return { flags, token, tokenKey: tokenKey(token) };
|
10153 | });
|
10154 | return {
|
10155 |
|
10156 | index: -1,
|
10157 | parent: null,
|
10158 | renderParent: null,
|
10159 | bindingIndex: -1,
|
10160 | outputIndex: -1,
|
10161 |
|
10162 | flags,
|
10163 | childFlags: 0,
|
10164 | directChildFlags: 0,
|
10165 | childMatchedQueries: 0, matchedQueries, matchedQueryIds, references,
|
10166 | ngContentIndex: -1, childCount, bindings,
|
10167 | bindingFlags: calcBindingFlags(bindings), outputs,
|
10168 | element: null,
|
10169 | provider: { token, tokenKey: tokenKey(token), value, deps: depDefs },
|
10170 | text: null,
|
10171 | query: null,
|
10172 | ngContent: null
|
10173 | };
|
10174 | }
|
10175 |
|
10176 |
|
10177 |
|
10178 |
|
10179 |
|
10180 | function createProviderInstance(view, def) {
|
10181 | return def.flags & 2048 ? NOT_CREATED : _createProviderInstance(view, def);
|
10182 | }
|
10183 |
|
10184 |
|
10185 |
|
10186 |
|
10187 |
|
10188 | function createPipeInstance(view, def) {
|
10189 |
|
10190 | let compView = view;
|
10191 | while (compView.parent && !isComponentView(compView)) {
|
10192 | compView = compView.parent;
|
10193 | }
|
10194 |
|
10195 | const allowPrivateServices = true;
|
10196 |
|
10197 | return createClass( ((compView.parent)), ((viewParentEl(compView))), allowPrivateServices, ((def.provider)).value, ((def.provider)).deps);
|
10198 | }
|
10199 |
|
10200 |
|
10201 |
|
10202 |
|
10203 |
|
10204 | function createDirectiveInstance(view, def) {
|
10205 |
|
10206 | const allowPrivateServices = (def.flags & 16384 ) > 0;
|
10207 |
|
10208 | const instance = createClass(view, ((def.parent)), allowPrivateServices, ((def.provider)).value, ((def.provider)).deps);
|
10209 | if (def.outputs.length) {
|
10210 | for (let i = 0; i < def.outputs.length; i++) {
|
10211 | const output = def.outputs[i];
|
10212 | const subscription = instance[((output.propName))].subscribe(eventHandlerClosure(view, ((def.parent)).index, output.eventName));
|
10213 | ((view.disposables))[def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
|
10214 | }
|
10215 | }
|
10216 | return instance;
|
10217 | }
|
10218 |
|
10219 |
|
10220 |
|
10221 |
|
10222 |
|
10223 |
|
10224 | function eventHandlerClosure(view, index, eventName) {
|
10225 | return (event) => {
|
10226 | try {
|
10227 | return dispatchEvent(view, index, eventName, event);
|
10228 | }
|
10229 | catch (e) {
|
10230 |
|
10231 | view.root.errorHandler.handleError(e);
|
10232 | }
|
10233 | };
|
10234 | }
|
10235 |
|
10236 |
|
10237 |
|
10238 |
|
10239 |
|
10240 |
|
10241 |
|
10242 |
|
10243 |
|
10244 |
|
10245 |
|
10246 |
|
10247 |
|
10248 |
|
10249 |
|
10250 | function checkAndUpdateDirectiveInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
10251 | const providerData = asProviderData(view, def.index);
|
10252 | const directive = providerData.instance;
|
10253 | let changed = false;
|
10254 | let changes = ((undefined));
|
10255 | const bindLen = def.bindings.length;
|
10256 | if (bindLen > 0 && checkBinding(view, def, 0, v0)) {
|
10257 | changed = true;
|
10258 | changes = updateProp(view, providerData, def, 0, v0, changes);
|
10259 | }
|
10260 | if (bindLen > 1 && checkBinding(view, def, 1, v1)) {
|
10261 | changed = true;
|
10262 | changes = updateProp(view, providerData, def, 1, v1, changes);
|
10263 | }
|
10264 | if (bindLen > 2 && checkBinding(view, def, 2, v2)) {
|
10265 | changed = true;
|
10266 | changes = updateProp(view, providerData, def, 2, v2, changes);
|
10267 | }
|
10268 | if (bindLen > 3 && checkBinding(view, def, 3, v3)) {
|
10269 | changed = true;
|
10270 | changes = updateProp(view, providerData, def, 3, v3, changes);
|
10271 | }
|
10272 | if (bindLen > 4 && checkBinding(view, def, 4, v4)) {
|
10273 | changed = true;
|
10274 | changes = updateProp(view, providerData, def, 4, v4, changes);
|
10275 | }
|
10276 | if (bindLen > 5 && checkBinding(view, def, 5, v5)) {
|
10277 | changed = true;
|
10278 | changes = updateProp(view, providerData, def, 5, v5, changes);
|
10279 | }
|
10280 | if (bindLen > 6 && checkBinding(view, def, 6, v6)) {
|
10281 | changed = true;
|
10282 | changes = updateProp(view, providerData, def, 6, v6, changes);
|
10283 | }
|
10284 | if (bindLen > 7 && checkBinding(view, def, 7, v7)) {
|
10285 | changed = true;
|
10286 | changes = updateProp(view, providerData, def, 7, v7, changes);
|
10287 | }
|
10288 | if (bindLen > 8 && checkBinding(view, def, 8, v8)) {
|
10289 | changed = true;
|
10290 | changes = updateProp(view, providerData, def, 8, v8, changes);
|
10291 | }
|
10292 | if (bindLen > 9 && checkBinding(view, def, 9, v9)) {
|
10293 | changed = true;
|
10294 | changes = updateProp(view, providerData, def, 9, v9, changes);
|
10295 | }
|
10296 | if (changes) {
|
10297 | directive.ngOnChanges(changes);
|
10298 | }
|
10299 | if ((view.state & 2 ) && (def.flags & 32768 )) {
|
10300 | directive.ngOnInit();
|
10301 | }
|
10302 | if (def.flags & 131072 ) {
|
10303 | directive.ngDoCheck();
|
10304 | }
|
10305 | return changed;
|
10306 | }
|
10307 |
|
10308 |
|
10309 |
|
10310 |
|
10311 |
|
10312 |
|
10313 | function checkAndUpdateDirectiveDynamic(view, def, values) {
|
10314 | const providerData = asProviderData(view, def.index);
|
10315 | const directive = providerData.instance;
|
10316 | let changed = false;
|
10317 | let changes = ((undefined));
|
10318 | for (let i = 0; i < values.length; i++) {
|
10319 | if (checkBinding(view, def, i, values[i])) {
|
10320 | changed = true;
|
10321 | changes = updateProp(view, providerData, def, i, values[i], changes);
|
10322 | }
|
10323 | }
|
10324 | if (changes) {
|
10325 | directive.ngOnChanges(changes);
|
10326 | }
|
10327 | if ((view.state & 2 ) && (def.flags & 32768 )) {
|
10328 | directive.ngOnInit();
|
10329 | }
|
10330 | if (def.flags & 131072 ) {
|
10331 | directive.ngDoCheck();
|
10332 | }
|
10333 | return changed;
|
10334 | }
|
10335 |
|
10336 |
|
10337 |
|
10338 |
|
10339 |
|
10340 | function _createProviderInstance(view, def) {
|
10341 |
|
10342 | const allowPrivateServices = (def.flags & 4096 ) > 0;
|
10343 | const providerDef = def.provider;
|
10344 | let injectable;
|
10345 | switch (def.flags & 100673535 ) {
|
10346 | case 256 :
|
10347 | injectable = createClass(view, ((def.parent)), allowPrivateServices, ((providerDef)).value, ((providerDef)).deps);
|
10348 | break;
|
10349 | case 512 :
|
10350 | injectable = callFactory(view, ((def.parent)), allowPrivateServices, ((providerDef)).value, ((providerDef)).deps);
|
10351 | break;
|
10352 | case 1024 :
|
10353 | injectable = resolveDep(view, ((def.parent)), allowPrivateServices, ((providerDef)).deps[0]);
|
10354 | break;
|
10355 | case 128 :
|
10356 | injectable = ((providerDef)).value;
|
10357 | break;
|
10358 | }
|
10359 | return injectable;
|
10360 | }
|
10361 |
|
10362 |
|
10363 |
|
10364 |
|
10365 |
|
10366 |
|
10367 |
|
10368 |
|
10369 | function createClass(view, elDef, allowPrivateServices, ctor, deps) {
|
10370 | const len = deps.length;
|
10371 | let injectable;
|
10372 | switch (len) {
|
10373 | case 0:
|
10374 | injectable = new ctor();
|
10375 | break;
|
10376 | case 1:
|
10377 | injectable = new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]));
|
10378 | break;
|
10379 | case 2:
|
10380 | injectable = new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
|
10381 | break;
|
10382 | case 3:
|
10383 | injectable = new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
|
10384 | break;
|
10385 | default:
|
10386 | const depValues = new Array(len);
|
10387 | for (let i = 0; i < len; i++) {
|
10388 | depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
|
10389 | }
|
10390 | injectable = new ctor(...depValues);
|
10391 | }
|
10392 | return injectable;
|
10393 | }
|
10394 |
|
10395 |
|
10396 |
|
10397 |
|
10398 |
|
10399 |
|
10400 |
|
10401 |
|
10402 | function callFactory(view, elDef, allowPrivateServices, factory, deps) {
|
10403 | const len = deps.length;
|
10404 | let injectable;
|
10405 | switch (len) {
|
10406 | case 0:
|
10407 | injectable = factory();
|
10408 | break;
|
10409 | case 1:
|
10410 | injectable = factory(resolveDep(view, elDef, allowPrivateServices, deps[0]));
|
10411 | break;
|
10412 | case 2:
|
10413 | injectable = factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
|
10414 | break;
|
10415 | case 3:
|
10416 | injectable = factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
|
10417 | break;
|
10418 | default:
|
10419 | const depValues = Array(len);
|
10420 | for (let i = 0; i < len; i++) {
|
10421 | depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
|
10422 | }
|
10423 | injectable = factory(...depValues);
|
10424 | }
|
10425 | return injectable;
|
10426 | }
|
10427 |
|
10428 |
|
10429 |
|
10430 |
|
10431 |
|
10432 |
|
10433 |
|
10434 |
|
10435 |
|
10436 |
|
10437 |
|
10438 |
|
10439 |
|
10440 |
|
10441 |
|
10442 |
|
10443 |
|
10444 | const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
|
10445 |
|
10446 |
|
10447 |
|
10448 |
|
10449 |
|
10450 |
|
10451 |
|
10452 |
|
10453 | function resolveDep(view, elDef, allowPrivateServices, depDef, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
|
10454 | if (depDef.flags & 8 ) {
|
10455 | return depDef.token;
|
10456 | }
|
10457 | const startView = view;
|
10458 | if (depDef.flags & 2 ) {
|
10459 | notFoundValue = null;
|
10460 | }
|
10461 | const tokenKey$$1 = depDef.tokenKey;
|
10462 | if (tokenKey$$1 === ChangeDetectorRefTokenKey) {
|
10463 |
|
10464 |
|
10465 | allowPrivateServices = !!(elDef && ((elDef.element)).componentView);
|
10466 | }
|
10467 | if (elDef && (depDef.flags & 1 )) {
|
10468 | allowPrivateServices = false;
|
10469 | elDef = ((elDef.parent));
|
10470 | }
|
10471 | while (view) {
|
10472 | if (elDef) {
|
10473 | switch (tokenKey$$1) {
|
10474 | case RendererV1TokenKey: {
|
10475 | const compView = findCompView(view, elDef, allowPrivateServices);
|
10476 | return createRendererV1(compView);
|
10477 | }
|
10478 | case Renderer2TokenKey: {
|
10479 | const compView = findCompView(view, elDef, allowPrivateServices);
|
10480 | return compView.renderer;
|
10481 | }
|
10482 | case ElementRefTokenKey:
|
10483 | return new ElementRef(asElementData(view, elDef.index).renderElement);
|
10484 | case ViewContainerRefTokenKey:
|
10485 | return asElementData(view, elDef.index).viewContainer;
|
10486 | case TemplateRefTokenKey: {
|
10487 | if (((elDef.element)).template) {
|
10488 | return asElementData(view, elDef.index).template;
|
10489 | }
|
10490 | break;
|
10491 | }
|
10492 | case ChangeDetectorRefTokenKey: {
|
10493 | let cdView = findCompView(view, elDef, allowPrivateServices);
|
10494 | return createChangeDetectorRef(cdView);
|
10495 | }
|
10496 | case InjectorRefTokenKey:
|
10497 | return createInjector(view, elDef);
|
10498 | default:
|
10499 | const providerDef = (((allowPrivateServices ? ((elDef.element)).allProviders : ((elDef.element)).publicProviders)))[tokenKey$$1];
|
10500 | if (providerDef) {
|
10501 | const providerData = asProviderData(view, providerDef.index);
|
10502 | if (providerData.instance === NOT_CREATED) {
|
10503 | providerData.instance = _createProviderInstance(view, providerDef);
|
10504 | }
|
10505 | return providerData.instance;
|
10506 | }
|
10507 | }
|
10508 | }
|
10509 | allowPrivateServices = isComponentView(view);
|
10510 | elDef = ((viewParentEl(view)));
|
10511 | view = ((view.parent));
|
10512 | }
|
10513 | const value = startView.root.injector.get(depDef.token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR);
|
10514 | if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
|
10515 | notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
|
10516 |
|
10517 |
|
10518 |
|
10519 |
|
10520 |
|
10521 | return value;
|
10522 | }
|
10523 | return startView.root.ngModule.injector.get(depDef.token, notFoundValue);
|
10524 | }
|
10525 |
|
10526 |
|
10527 |
|
10528 |
|
10529 |
|
10530 |
|
10531 | function findCompView(view, elDef, allowPrivateServices) {
|
10532 | let compView;
|
10533 | if (allowPrivateServices) {
|
10534 | compView = asElementData(view, elDef.index).componentView;
|
10535 | }
|
10536 | else {
|
10537 | compView = view;
|
10538 | while (compView.parent && !isComponentView(compView)) {
|
10539 | compView = compView.parent;
|
10540 | }
|
10541 | }
|
10542 | return compView;
|
10543 | }
|
10544 |
|
10545 |
|
10546 |
|
10547 |
|
10548 |
|
10549 |
|
10550 |
|
10551 |
|
10552 |
|
10553 | function updateProp(view, providerData, def, bindingIdx, value, changes) {
|
10554 | if (def.flags & 16384 ) {
|
10555 | const compView = asElementData(view, ((def.parent)).index).componentView;
|
10556 | if (compView.def.flags & 2 ) {
|
10557 | compView.state |= 8 ;
|
10558 | }
|
10559 | }
|
10560 | const binding = def.bindings[bindingIdx];
|
10561 | const propName = ((binding.name));
|
10562 |
|
10563 |
|
10564 |
|
10565 | providerData.instance[propName] = value;
|
10566 | if (def.flags & 262144 ) {
|
10567 | changes = changes || {};
|
10568 | let oldValue = view.oldValues[def.bindingIndex + bindingIdx];
|
10569 | if (oldValue instanceof WrappedValue) {
|
10570 | oldValue = oldValue.wrapped;
|
10571 | }
|
10572 | const binding = def.bindings[bindingIdx];
|
10573 | changes[((binding.nonMinifiedName))] =
|
10574 | new SimpleChange(oldValue, value, (view.state & 2 ) !== 0);
|
10575 | }
|
10576 | view.oldValues[def.bindingIndex + bindingIdx] = value;
|
10577 | return changes;
|
10578 | }
|
10579 |
|
10580 |
|
10581 |
|
10582 |
|
10583 |
|
10584 | function callLifecycleHooksChildrenFirst(view, lifecycles) {
|
10585 | if (!(view.def.nodeFlags & lifecycles)) {
|
10586 | return;
|
10587 | }
|
10588 | const nodes = view.def.nodes;
|
10589 | for (let i = 0; i < nodes.length; i++) {
|
10590 | const nodeDef = nodes[i];
|
10591 | let parent = nodeDef.parent;
|
10592 | if (!parent && nodeDef.flags & lifecycles) {
|
10593 |
|
10594 | callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
|
10595 | }
|
10596 | if ((nodeDef.childFlags & lifecycles) === 0) {
|
10597 |
|
10598 | i += nodeDef.childCount;
|
10599 | }
|
10600 | while (parent && (parent.flags & 1 ) &&
|
10601 | i === parent.index + parent.childCount) {
|
10602 |
|
10603 | if (parent.directChildFlags & lifecycles) {
|
10604 | callElementProvidersLifecycles(view, parent, lifecycles);
|
10605 | }
|
10606 | parent = parent.parent;
|
10607 | }
|
10608 | }
|
10609 | }
|
10610 |
|
10611 |
|
10612 |
|
10613 |
|
10614 |
|
10615 |
|
10616 | function callElementProvidersLifecycles(view, elDef, lifecycles) {
|
10617 | for (let i = elDef.index + 1; i <= elDef.index + elDef.childCount; i++) {
|
10618 | const nodeDef = view.def.nodes[i];
|
10619 | if (nodeDef.flags & lifecycles) {
|
10620 | callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
|
10621 | }
|
10622 |
|
10623 | i += nodeDef.childCount;
|
10624 | }
|
10625 | }
|
10626 |
|
10627 |
|
10628 |
|
10629 |
|
10630 |
|
10631 |
|
10632 | function callProviderLifecycles(view, index, lifecycles) {
|
10633 | const provider = asProviderData(view, index).instance;
|
10634 | if (provider === NOT_CREATED) {
|
10635 | return;
|
10636 | }
|
10637 | Services.setCurrentNode(view, index);
|
10638 | if (lifecycles & 524288 ) {
|
10639 | provider.ngAfterContentInit();
|
10640 | }
|
10641 | if (lifecycles & 1048576 ) {
|
10642 | provider.ngAfterContentChecked();
|
10643 | }
|
10644 | if (lifecycles & 2097152 ) {
|
10645 | provider.ngAfterViewInit();
|
10646 | }
|
10647 | if (lifecycles & 4194304 ) {
|
10648 | provider.ngAfterViewChecked();
|
10649 | }
|
10650 | if (lifecycles & 65536 ) {
|
10651 | provider.ngOnDestroy();
|
10652 | }
|
10653 | }
|
10654 |
|
10655 |
|
10656 |
|
10657 |
|
10658 |
|
10659 |
|
10660 |
|
10661 |
|
10662 |
|
10663 |
|
10664 |
|
10665 |
|
10666 | function purePipeDef(argCount) {
|
10667 |
|
10668 | return _pureExpressionDef(64 , new Array(argCount + 1));
|
10669 | }
|
10670 |
|
10671 |
|
10672 |
|
10673 |
|
10674 | function pureArrayDef(argCount) {
|
10675 | return _pureExpressionDef(16 , new Array(argCount));
|
10676 | }
|
10677 |
|
10678 |
|
10679 |
|
10680 |
|
10681 | function pureObjectDef(propertyNames) {
|
10682 | return _pureExpressionDef(32 , propertyNames);
|
10683 | }
|
10684 |
|
10685 |
|
10686 |
|
10687 |
|
10688 |
|
10689 | function _pureExpressionDef(flags, propertyNames) {
|
10690 | const bindings = new Array(propertyNames.length);
|
10691 | for (let i = 0; i < propertyNames.length; i++) {
|
10692 | const prop = propertyNames[i];
|
10693 | bindings[i] = {
|
10694 | flags: 8 ,
|
10695 | name: prop,
|
10696 | ns: null,
|
10697 | nonMinifiedName: prop,
|
10698 | securityContext: null,
|
10699 | suffix: null
|
10700 | };
|
10701 | }
|
10702 | return {
|
10703 |
|
10704 | index: -1,
|
10705 | parent: null,
|
10706 | renderParent: null,
|
10707 | bindingIndex: -1,
|
10708 | outputIndex: -1,
|
10709 |
|
10710 | flags,
|
10711 | childFlags: 0,
|
10712 | directChildFlags: 0,
|
10713 | childMatchedQueries: 0,
|
10714 | matchedQueries: {},
|
10715 | matchedQueryIds: 0,
|
10716 | references: {},
|
10717 | ngContentIndex: -1,
|
10718 | childCount: 0, bindings,
|
10719 | bindingFlags: calcBindingFlags(bindings),
|
10720 | outputs: [],
|
10721 | element: null,
|
10722 | provider: null,
|
10723 | text: null,
|
10724 | query: null,
|
10725 | ngContent: null
|
10726 | };
|
10727 | }
|
10728 |
|
10729 |
|
10730 |
|
10731 |
|
10732 |
|
10733 | function createPureExpression(view, def) {
|
10734 | return { value: undefined };
|
10735 | }
|
10736 |
|
10737 |
|
10738 |
|
10739 |
|
10740 |
|
10741 |
|
10742 |
|
10743 |
|
10744 |
|
10745 |
|
10746 |
|
10747 |
|
10748 |
|
10749 |
|
10750 |
|
10751 | function checkAndUpdatePureExpressionInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
10752 | const bindings = def.bindings;
|
10753 | let changed = false;
|
10754 | const bindLen = bindings.length;
|
10755 | if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
|
10756 | changed = true;
|
10757 | if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
|
10758 | changed = true;
|
10759 | if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
|
10760 | changed = true;
|
10761 | if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
|
10762 | changed = true;
|
10763 | if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
|
10764 | changed = true;
|
10765 | if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
|
10766 | changed = true;
|
10767 | if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
|
10768 | changed = true;
|
10769 | if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
|
10770 | changed = true;
|
10771 | if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
|
10772 | changed = true;
|
10773 | if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
|
10774 | changed = true;
|
10775 | if (changed) {
|
10776 | const data = asPureExpressionData(view, def.index);
|
10777 | let value;
|
10778 | switch (def.flags & 100673535 ) {
|
10779 | case 16 :
|
10780 | value = new Array(bindings.length);
|
10781 | if (bindLen > 0)
|
10782 | value[0] = v0;
|
10783 | if (bindLen > 1)
|
10784 | value[1] = v1;
|
10785 | if (bindLen > 2)
|
10786 | value[2] = v2;
|
10787 | if (bindLen > 3)
|
10788 | value[3] = v3;
|
10789 | if (bindLen > 4)
|
10790 | value[4] = v4;
|
10791 | if (bindLen > 5)
|
10792 | value[5] = v5;
|
10793 | if (bindLen > 6)
|
10794 | value[6] = v6;
|
10795 | if (bindLen > 7)
|
10796 | value[7] = v7;
|
10797 | if (bindLen > 8)
|
10798 | value[8] = v8;
|
10799 | if (bindLen > 9)
|
10800 | value[9] = v9;
|
10801 | break;
|
10802 | case 32 :
|
10803 | value = {};
|
10804 | if (bindLen > 0)
|
10805 | value[((bindings[0].name))] = v0;
|
10806 | if (bindLen > 1)
|
10807 | value[((bindings[1].name))] = v1;
|
10808 | if (bindLen > 2)
|
10809 | value[((bindings[2].name))] = v2;
|
10810 | if (bindLen > 3)
|
10811 | value[((bindings[3].name))] = v3;
|
10812 | if (bindLen > 4)
|
10813 | value[((bindings[4].name))] = v4;
|
10814 | if (bindLen > 5)
|
10815 | value[((bindings[5].name))] = v5;
|
10816 | if (bindLen > 6)
|
10817 | value[((bindings[6].name))] = v6;
|
10818 | if (bindLen > 7)
|
10819 | value[((bindings[7].name))] = v7;
|
10820 | if (bindLen > 8)
|
10821 | value[((bindings[8].name))] = v8;
|
10822 | if (bindLen > 9)
|
10823 | value[((bindings[9].name))] = v9;
|
10824 | break;
|
10825 | case 64 :
|
10826 | const pipe = v0;
|
10827 | switch (bindLen) {
|
10828 | case 1:
|
10829 | value = pipe.transform(v0);
|
10830 | break;
|
10831 | case 2:
|
10832 | value = pipe.transform(v1);
|
10833 | break;
|
10834 | case 3:
|
10835 | value = pipe.transform(v1, v2);
|
10836 | break;
|
10837 | case 4:
|
10838 | value = pipe.transform(v1, v2, v3);
|
10839 | break;
|
10840 | case 5:
|
10841 | value = pipe.transform(v1, v2, v3, v4);
|
10842 | break;
|
10843 | case 6:
|
10844 | value = pipe.transform(v1, v2, v3, v4, v5);
|
10845 | break;
|
10846 | case 7:
|
10847 | value = pipe.transform(v1, v2, v3, v4, v5, v6);
|
10848 | break;
|
10849 | case 8:
|
10850 | value = pipe.transform(v1, v2, v3, v4, v5, v6, v7);
|
10851 | break;
|
10852 | case 9:
|
10853 | value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8);
|
10854 | break;
|
10855 | case 10:
|
10856 | value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
10857 | break;
|
10858 | }
|
10859 | break;
|
10860 | }
|
10861 | data.value = value;
|
10862 | }
|
10863 | return changed;
|
10864 | }
|
10865 |
|
10866 |
|
10867 |
|
10868 |
|
10869 |
|
10870 |
|
10871 | function checkAndUpdatePureExpressionDynamic(view, def, values) {
|
10872 | const bindings = def.bindings;
|
10873 | let changed = false;
|
10874 | for (let i = 0; i < values.length; i++) {
|
10875 |
|
10876 |
|
10877 | if (checkAndUpdateBinding(view, def, i, values[i])) {
|
10878 | changed = true;
|
10879 | }
|
10880 | }
|
10881 | if (changed) {
|
10882 | const data = asPureExpressionData(view, def.index);
|
10883 | let value;
|
10884 | switch (def.flags & 100673535 ) {
|
10885 | case 16 :
|
10886 | value = values;
|
10887 | break;
|
10888 | case 32 :
|
10889 | value = {};
|
10890 | for (let i = 0; i < values.length; i++) {
|
10891 | value[((bindings[i].name))] = values[i];
|
10892 | }
|
10893 | break;
|
10894 | case 64 :
|
10895 | const pipe = values[0];
|
10896 | const params = values.slice(1);
|
10897 | value = ((pipe.transform))(...params);
|
10898 | break;
|
10899 | }
|
10900 | data.value = value;
|
10901 | }
|
10902 | return changed;
|
10903 | }
|
10904 |
|
10905 |
|
10906 |
|
10907 |
|
10908 |
|
10909 |
|
10910 |
|
10911 |
|
10912 |
|
10913 |
|
10914 |
|
10915 |
|
10916 |
|
10917 |
|
10918 | function queryDef(flags, id, bindings) {
|
10919 | let bindingDefs = [];
|
10920 | for (let propName in bindings) {
|
10921 | const bindingType = bindings[propName];
|
10922 | bindingDefs.push({ propName, bindingType });
|
10923 | }
|
10924 | return {
|
10925 |
|
10926 | index: -1,
|
10927 | parent: null,
|
10928 | renderParent: null,
|
10929 | bindingIndex: -1,
|
10930 | outputIndex: -1,
|
10931 |
|
10932 | flags,
|
10933 | childFlags: 0,
|
10934 | directChildFlags: 0,
|
10935 | childMatchedQueries: 0,
|
10936 | ngContentIndex: -1,
|
10937 | matchedQueries: {},
|
10938 | matchedQueryIds: 0,
|
10939 | references: {},
|
10940 | childCount: 0,
|
10941 | bindings: [],
|
10942 | bindingFlags: 0,
|
10943 | outputs: [],
|
10944 | element: null,
|
10945 | provider: null,
|
10946 | text: null,
|
10947 | query: { id, filterId: filterQueryId(id), bindings: bindingDefs },
|
10948 | ngContent: null
|
10949 | };
|
10950 | }
|
10951 |
|
10952 |
|
10953 |
|
10954 | function createQuery() {
|
10955 | return new QueryList();
|
10956 | }
|
10957 |
|
10958 |
|
10959 |
|
10960 |
|
10961 | function dirtyParentQueries(view) {
|
10962 | const queryIds = view.def.nodeMatchedQueries;
|
10963 | while (view.parent && isEmbeddedView(view)) {
|
10964 | let tplDef = ((view.parentNodeDef));
|
10965 | view = view.parent;
|
10966 |
|
10967 | const end = tplDef.index + tplDef.childCount;
|
10968 | for (let i = 0; i <= end; i++) {
|
10969 | const nodeDef = view.def.nodes[i];
|
10970 | if ((nodeDef.flags & 33554432 ) &&
|
10971 | (nodeDef.flags & 268435456 ) &&
|
10972 | (((nodeDef.query)).filterId & queryIds) === ((nodeDef.query)).filterId) {
|
10973 | asQueryList(view, i).setDirty();
|
10974 | }
|
10975 | if ((nodeDef.flags & 1 && i + nodeDef.childCount < tplDef.index) ||
|
10976 | !(nodeDef.childFlags & 33554432 ) ||
|
10977 | !(nodeDef.childFlags & 268435456 )) {
|
10978 |
|
10979 | i += nodeDef.childCount;
|
10980 | }
|
10981 | }
|
10982 | }
|
10983 |
|
10984 | if (view.def.nodeFlags & 67108864 ) {
|
10985 | for (let i = 0; i < view.def.nodes.length; i++) {
|
10986 | const nodeDef = view.def.nodes[i];
|
10987 | if ((nodeDef.flags & 67108864 ) && (nodeDef.flags & 268435456 )) {
|
10988 | asQueryList(view, i).setDirty();
|
10989 | }
|
10990 |
|
10991 | i += nodeDef.childCount;
|
10992 | }
|
10993 | }
|
10994 | }
|
10995 |
|
10996 |
|
10997 |
|
10998 |
|
10999 |
|
11000 | function checkAndUpdateQuery(view, nodeDef) {
|
11001 | const queryList = asQueryList(view, nodeDef.index);
|
11002 | if (!queryList.dirty) {
|
11003 | return;
|
11004 | }
|
11005 | let directiveInstance;
|
11006 | let newValues = ((undefined));
|
11007 | if (nodeDef.flags & 33554432 ) {
|
11008 | const elementDef = ((((nodeDef.parent)).parent));
|
11009 | newValues = calcQueryValues(view, elementDef.index, elementDef.index + elementDef.childCount, ((nodeDef.query)), []);
|
11010 | directiveInstance = asProviderData(view, ((nodeDef.parent)).index).instance;
|
11011 | }
|
11012 | else if (nodeDef.flags & 67108864 ) {
|
11013 | newValues = calcQueryValues(view, 0, view.def.nodes.length - 1, ((nodeDef.query)), []);
|
11014 | directiveInstance = view.component;
|
11015 | }
|
11016 | queryList.reset(newValues);
|
11017 | const bindings = ((nodeDef.query)).bindings;
|
11018 | let notify = false;
|
11019 | for (let i = 0; i < bindings.length; i++) {
|
11020 | const binding = bindings[i];
|
11021 | let boundValue;
|
11022 | switch (binding.bindingType) {
|
11023 | case 0 :
|
11024 | boundValue = queryList.first;
|
11025 | break;
|
11026 | case 1 :
|
11027 | boundValue = queryList;
|
11028 | notify = true;
|
11029 | break;
|
11030 | }
|
11031 | directiveInstance[binding.propName] = boundValue;
|
11032 | }
|
11033 | if (notify) {
|
11034 | queryList.notifyOnChanges();
|
11035 | }
|
11036 | }
|
11037 |
|
11038 |
|
11039 |
|
11040 |
|
11041 |
|
11042 |
|
11043 |
|
11044 |
|
11045 | function calcQueryValues(view, startIndex, endIndex, queryDef, values) {
|
11046 | for (let i = startIndex; i <= endIndex; i++) {
|
11047 | const nodeDef = view.def.nodes[i];
|
11048 | const valueType = nodeDef.matchedQueries[queryDef.id];
|
11049 | if (valueType != null) {
|
11050 | values.push(getQueryValue(view, nodeDef, valueType));
|
11051 | }
|
11052 | if (nodeDef.flags & 1 && ((nodeDef.element)).template &&
|
11053 | (((((nodeDef.element)).template)).nodeMatchedQueries & queryDef.filterId) ===
|
11054 | queryDef.filterId) {
|
11055 |
|
11056 | const elementData = asElementData(view, i);
|
11057 | if (nodeDef.flags & 8388608 ) {
|
11058 | const embeddedViews = ((elementData.viewContainer))._embeddedViews;
|
11059 | for (let k = 0; k < embeddedViews.length; k++) {
|
11060 | const embeddedView = embeddedViews[k];
|
11061 | const dvc = declaredViewContainer(embeddedView);
|
11062 | if (dvc && dvc === elementData) {
|
11063 | calcQueryValues(embeddedView, 0, embeddedView.def.nodes.length - 1, queryDef, values);
|
11064 | }
|
11065 | }
|
11066 | }
|
11067 | const projectedViews = elementData.template._projectedViews;
|
11068 | if (projectedViews) {
|
11069 | for (let k = 0; k < projectedViews.length; k++) {
|
11070 | const projectedView = projectedViews[k];
|
11071 | calcQueryValues(projectedView, 0, projectedView.def.nodes.length - 1, queryDef, values);
|
11072 | }
|
11073 | }
|
11074 | }
|
11075 | if ((nodeDef.childMatchedQueries & queryDef.filterId) !== queryDef.filterId) {
|
11076 |
|
11077 | i += nodeDef.childCount;
|
11078 | }
|
11079 | }
|
11080 | return values;
|
11081 | }
|
11082 |
|
11083 |
|
11084 |
|
11085 |
|
11086 |
|
11087 |
|
11088 | function getQueryValue(view, nodeDef, queryValueType) {
|
11089 | if (queryValueType != null) {
|
11090 |
|
11091 | let value;
|
11092 | switch (queryValueType) {
|
11093 | case 1 :
|
11094 | value = asElementData(view, nodeDef.index).renderElement;
|
11095 | break;
|
11096 | case 0 :
|
11097 | value = new ElementRef(asElementData(view, nodeDef.index).renderElement);
|
11098 | break;
|
11099 | case 2 :
|
11100 | value = asElementData(view, nodeDef.index).template;
|
11101 | break;
|
11102 | case 3 :
|
11103 | value = asElementData(view, nodeDef.index).viewContainer;
|
11104 | break;
|
11105 | case 4 :
|
11106 | value = asProviderData(view, nodeDef.index).instance;
|
11107 | break;
|
11108 | }
|
11109 | return value;
|
11110 | }
|
11111 | }
|
11112 |
|
11113 |
|
11114 |
|
11115 |
|
11116 |
|
11117 |
|
11118 |
|
11119 |
|
11120 |
|
11121 |
|
11122 |
|
11123 |
|
11124 |
|
11125 | function textDef(ngContentIndex, constants) {
|
11126 | const bindings = new Array(constants.length - 1);
|
11127 | for (let i = 1; i < constants.length; i++) {
|
11128 | bindings[i - 1] = {
|
11129 | flags: 8 ,
|
11130 | name: null,
|
11131 | ns: null,
|
11132 | nonMinifiedName: null,
|
11133 | securityContext: null,
|
11134 | suffix: constants[i]
|
11135 | };
|
11136 | }
|
11137 | const flags = 2;
|
11138 | return {
|
11139 |
|
11140 | index: -1,
|
11141 | parent: null,
|
11142 | renderParent: null,
|
11143 | bindingIndex: -1,
|
11144 | outputIndex: -1,
|
11145 |
|
11146 | flags,
|
11147 | childFlags: 0,
|
11148 | directChildFlags: 0,
|
11149 | childMatchedQueries: 0,
|
11150 | matchedQueries: {},
|
11151 | matchedQueryIds: 0,
|
11152 | references: {}, ngContentIndex,
|
11153 | childCount: 0, bindings,
|
11154 | bindingFlags: calcBindingFlags(bindings),
|
11155 | outputs: [],
|
11156 | element: null,
|
11157 | provider: null,
|
11158 | text: { prefix: constants[0] },
|
11159 | query: null,
|
11160 | ngContent: null
|
11161 | };
|
11162 | }
|
11163 |
|
11164 |
|
11165 |
|
11166 |
|
11167 |
|
11168 |
|
11169 | function createText(view, renderHost, def) {
|
11170 | let renderNode$$1;
|
11171 | const renderer = view.renderer;
|
11172 | renderNode$$1 = renderer.createText( ((def.text)).prefix);
|
11173 | const parentEl = getParentRenderElement(view, renderHost, def);
|
11174 | if (parentEl) {
|
11175 | renderer.appendChild(parentEl, renderNode$$1);
|
11176 | }
|
11177 | return { renderText: renderNode$$1 };
|
11178 | }
|
11179 |
|
11180 |
|
11181 |
|
11182 |
|
11183 |
|
11184 |
|
11185 |
|
11186 |
|
11187 |
|
11188 |
|
11189 |
|
11190 |
|
11191 |
|
11192 |
|
11193 |
|
11194 | function checkAndUpdateTextInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11195 | let changed = false;
|
11196 | const bindings = def.bindings;
|
11197 | const bindLen = bindings.length;
|
11198 | if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
|
11199 | changed = true;
|
11200 | if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
|
11201 | changed = true;
|
11202 | if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
|
11203 | changed = true;
|
11204 | if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
|
11205 | changed = true;
|
11206 | if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
|
11207 | changed = true;
|
11208 | if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
|
11209 | changed = true;
|
11210 | if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
|
11211 | changed = true;
|
11212 | if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
|
11213 | changed = true;
|
11214 | if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
|
11215 | changed = true;
|
11216 | if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
|
11217 | changed = true;
|
11218 | if (changed) {
|
11219 | let value = ((def.text)).prefix;
|
11220 | if (bindLen > 0)
|
11221 | value += _addInterpolationPart(v0, bindings[0]);
|
11222 | if (bindLen > 1)
|
11223 | value += _addInterpolationPart(v1, bindings[1]);
|
11224 | if (bindLen > 2)
|
11225 | value += _addInterpolationPart(v2, bindings[2]);
|
11226 | if (bindLen > 3)
|
11227 | value += _addInterpolationPart(v3, bindings[3]);
|
11228 | if (bindLen > 4)
|
11229 | value += _addInterpolationPart(v4, bindings[4]);
|
11230 | if (bindLen > 5)
|
11231 | value += _addInterpolationPart(v5, bindings[5]);
|
11232 | if (bindLen > 6)
|
11233 | value += _addInterpolationPart(v6, bindings[6]);
|
11234 | if (bindLen > 7)
|
11235 | value += _addInterpolationPart(v7, bindings[7]);
|
11236 | if (bindLen > 8)
|
11237 | value += _addInterpolationPart(v8, bindings[8]);
|
11238 | if (bindLen > 9)
|
11239 | value += _addInterpolationPart(v9, bindings[9]);
|
11240 | const renderNode$$1 = asTextData(view, def.index).renderText;
|
11241 | view.renderer.setValue(renderNode$$1, value);
|
11242 | }
|
11243 | return changed;
|
11244 | }
|
11245 |
|
11246 |
|
11247 |
|
11248 |
|
11249 |
|
11250 |
|
11251 | function checkAndUpdateTextDynamic(view, def, values) {
|
11252 | const bindings = def.bindings;
|
11253 | let changed = false;
|
11254 | for (let i = 0; i < values.length; i++) {
|
11255 |
|
11256 |
|
11257 | if (checkAndUpdateBinding(view, def, i, values[i])) {
|
11258 | changed = true;
|
11259 | }
|
11260 | }
|
11261 | if (changed) {
|
11262 | let value = '';
|
11263 | for (let i = 0; i < values.length; i++) {
|
11264 | value = value + _addInterpolationPart(values[i], bindings[i]);
|
11265 | }
|
11266 | value = ((def.text)).prefix + value;
|
11267 | const renderNode$$1 = asTextData(view, def.index).renderText;
|
11268 | view.renderer.setValue(renderNode$$1, value);
|
11269 | }
|
11270 | return changed;
|
11271 | }
|
11272 |
|
11273 |
|
11274 |
|
11275 |
|
11276 |
|
11277 | function _addInterpolationPart(value, binding) {
|
11278 | const valueStr = value != null ? value.toString() : '';
|
11279 | return valueStr + binding.suffix;
|
11280 | }
|
11281 |
|
11282 |
|
11283 |
|
11284 |
|
11285 |
|
11286 |
|
11287 |
|
11288 |
|
11289 |
|
11290 |
|
11291 |
|
11292 |
|
11293 |
|
11294 |
|
11295 |
|
11296 | function viewDef(flags, nodes, updateDirectives, updateRenderer) {
|
11297 |
|
11298 | let viewBindingCount = 0;
|
11299 | let viewDisposableCount = 0;
|
11300 | let viewNodeFlags = 0;
|
11301 | let viewRootNodeFlags = 0;
|
11302 | let viewMatchedQueries = 0;
|
11303 | let currentParent = null;
|
11304 | let currentElementHasPublicProviders = false;
|
11305 | let currentElementHasPrivateProviders = false;
|
11306 | let lastRenderRootNode = null;
|
11307 | for (let i = 0; i < nodes.length; i++) {
|
11308 | while (currentParent && i > currentParent.index + currentParent.childCount) {
|
11309 | const newParent = currentParent.parent;
|
11310 | if (newParent) {
|
11311 | newParent.childFlags |= ((currentParent.childFlags));
|
11312 | newParent.childMatchedQueries |= currentParent.childMatchedQueries;
|
11313 | }
|
11314 | currentParent = newParent;
|
11315 | }
|
11316 | const node = nodes[i];
|
11317 | node.index = i;
|
11318 | node.parent = currentParent;
|
11319 | node.bindingIndex = viewBindingCount;
|
11320 | node.outputIndex = viewDisposableCount;
|
11321 |
|
11322 | let currentRenderParent;
|
11323 | if (currentParent && currentParent.flags & 1 &&
|
11324 | !((currentParent.element)).name) {
|
11325 | currentRenderParent = currentParent.renderParent;
|
11326 | }
|
11327 | else {
|
11328 | currentRenderParent = currentParent;
|
11329 | }
|
11330 | node.renderParent = currentRenderParent;
|
11331 | if (node.element) {
|
11332 | const elDef = node.element;
|
11333 | elDef.publicProviders =
|
11334 | currentParent ? ((currentParent.element)).publicProviders : Object.create(null);
|
11335 | elDef.allProviders = elDef.publicProviders;
|
11336 |
|
11337 | currentElementHasPublicProviders = false;
|
11338 | currentElementHasPrivateProviders = false;
|
11339 | }
|
11340 | validateNode(currentParent, node, nodes.length);
|
11341 | viewNodeFlags |= node.flags;
|
11342 | viewMatchedQueries |= node.matchedQueryIds;
|
11343 | if (node.element && node.element.template) {
|
11344 | viewMatchedQueries |= node.element.template.nodeMatchedQueries;
|
11345 | }
|
11346 | if (currentParent) {
|
11347 | currentParent.childFlags |= node.flags;
|
11348 | currentParent.directChildFlags |= node.flags;
|
11349 | currentParent.childMatchedQueries |= node.matchedQueryIds;
|
11350 | if (node.element && node.element.template) {
|
11351 | currentParent.childMatchedQueries |= node.element.template.nodeMatchedQueries;
|
11352 | }
|
11353 | }
|
11354 | else {
|
11355 | viewRootNodeFlags |= node.flags;
|
11356 | }
|
11357 | viewBindingCount += node.bindings.length;
|
11358 | viewDisposableCount += node.outputs.length;
|
11359 | if (!currentRenderParent && (node.flags & 3 )) {
|
11360 | lastRenderRootNode = node;
|
11361 | }
|
11362 | if (node.flags & 10112 ) {
|
11363 | if (!currentElementHasPublicProviders) {
|
11364 | currentElementHasPublicProviders = true;
|
11365 | ((((
|
11366 |
|
11367 | currentParent)).element)).publicProviders =
|
11368 | Object.create( ((((currentParent)).element)).publicProviders);
|
11369 | ((((currentParent)).element)).allProviders = ((((currentParent)).element)).publicProviders;
|
11370 | }
|
11371 | const isPrivateService = (node.flags & 4096 ) !== 0;
|
11372 | const isComponent = (node.flags & 16384 ) !== 0;
|
11373 | if (!isPrivateService || isComponent) {
|
11374 | ((((((currentParent)).element)).publicProviders))[((node.provider)).tokenKey] = node;
|
11375 | }
|
11376 | else {
|
11377 | if (!currentElementHasPrivateProviders) {
|
11378 | currentElementHasPrivateProviders = true;
|
11379 | ((((
|
11380 |
|
11381 | currentParent)).element)).allProviders =
|
11382 | Object.create( ((((currentParent)).element)).publicProviders);
|
11383 | }
|
11384 | ((((((currentParent)).element)).allProviders))[((node.provider)).tokenKey] = node;
|
11385 | }
|
11386 | if (isComponent) {
|
11387 | ((((currentParent)).element)).componentProvider = node;
|
11388 | }
|
11389 | }
|
11390 | if (node.childCount) {
|
11391 | currentParent = node;
|
11392 | }
|
11393 | }
|
11394 | while (currentParent) {
|
11395 | const newParent = currentParent.parent;
|
11396 | if (newParent) {
|
11397 | newParent.childFlags |= currentParent.childFlags;
|
11398 | newParent.childMatchedQueries |= currentParent.childMatchedQueries;
|
11399 | }
|
11400 | currentParent = newParent;
|
11401 | }
|
11402 | const handleEvent = (view, nodeIndex, eventName, event) => ((((nodes[nodeIndex].element)).handleEvent))(view, eventName, event);
|
11403 | return {
|
11404 |
|
11405 | factory: null,
|
11406 | nodeFlags: viewNodeFlags,
|
11407 | rootNodeFlags: viewRootNodeFlags,
|
11408 | nodeMatchedQueries: viewMatchedQueries, flags,
|
11409 | nodes: nodes,
|
11410 | updateDirectives: updateDirectives || NOOP,
|
11411 | updateRenderer: updateRenderer || NOOP,
|
11412 | handleEvent: handleEvent || NOOP,
|
11413 | bindingCount: viewBindingCount,
|
11414 | outputCount: viewDisposableCount, lastRenderRootNode
|
11415 | };
|
11416 | }
|
11417 |
|
11418 |
|
11419 |
|
11420 |
|
11421 |
|
11422 |
|
11423 | function validateNode(parent, node, nodeCount) {
|
11424 | const template = node.element && node.element.template;
|
11425 | if (template) {
|
11426 | if (!template.lastRenderRootNode) {
|
11427 | throw new Error(`Illegal State: Embedded templates without nodes are not allowed!`);
|
11428 | }
|
11429 | if (template.lastRenderRootNode &&
|
11430 | template.lastRenderRootNode.flags & 8388608 ) {
|
11431 | throw new Error(`Illegal State: Last root node of a template can't have embedded views, at index ${node.index}!`);
|
11432 | }
|
11433 | }
|
11434 | if (node.flags & 10112 ) {
|
11435 | const parentFlags = parent ? parent.flags : 0;
|
11436 | if ((parentFlags & 1 ) === 0) {
|
11437 | throw new Error(`Illegal State: Provider/Directive nodes need to be children of elements or anchors, at index ${node.index}!`);
|
11438 | }
|
11439 | }
|
11440 | if (node.query) {
|
11441 | if (node.flags & 33554432 &&
|
11442 | (!parent || (parent.flags & 8192 ) === 0)) {
|
11443 | throw new Error(`Illegal State: Content Query nodes need to be children of directives, at index ${node.index}!`);
|
11444 | }
|
11445 | if (node.flags & 67108864 && parent) {
|
11446 | throw new Error(`Illegal State: View Query nodes have to be top level nodes, at index ${node.index}!`);
|
11447 | }
|
11448 | }
|
11449 | if (node.childCount) {
|
11450 | const parentEnd = parent ? parent.index + parent.childCount : nodeCount - 1;
|
11451 | if (node.index <= parentEnd && node.index + node.childCount > parentEnd) {
|
11452 | throw new Error(`Illegal State: childCount of node leads outside of parent, at index ${node.index}!`);
|
11453 | }
|
11454 | }
|
11455 | }
|
11456 |
|
11457 |
|
11458 |
|
11459 |
|
11460 |
|
11461 |
|
11462 | function createEmbeddedView(parent, anchorDef$$1, context) {
|
11463 |
|
11464 |
|
11465 | const view = createView(parent.root, parent.renderer, parent, anchorDef$$1, ((((anchorDef$$1.element)).template)));
|
11466 | initView(view, parent.component, context);
|
11467 | createViewNodes(view);
|
11468 | return view;
|
11469 | }
|
11470 |
|
11471 |
|
11472 |
|
11473 |
|
11474 |
|
11475 |
|
11476 | function createRootView(root, def, context) {
|
11477 | const view = createView(root, root.renderer, null, null, def);
|
11478 | initView(view, context, context);
|
11479 | createViewNodes(view);
|
11480 | return view;
|
11481 | }
|
11482 |
|
11483 |
|
11484 |
|
11485 |
|
11486 |
|
11487 |
|
11488 |
|
11489 |
|
11490 | function createView(root, renderer, parent, parentNodeDef, def) {
|
11491 | const nodes = new Array(def.nodes.length);
|
11492 | const disposables = def.outputCount ? new Array(def.outputCount) : null;
|
11493 | const view = {
|
11494 | def,
|
11495 | parent,
|
11496 | viewContainerParent: null, parentNodeDef,
|
11497 | context: null,
|
11498 | component: null, nodes,
|
11499 | state: 13 , root, renderer,
|
11500 | oldValues: new Array(def.bindingCount), disposables
|
11501 | };
|
11502 | return view;
|
11503 | }
|
11504 |
|
11505 |
|
11506 |
|
11507 |
|
11508 |
|
11509 |
|
11510 | function initView(view, component, context) {
|
11511 | view.component = component;
|
11512 | view.context = context;
|
11513 | }
|
11514 |
|
11515 |
|
11516 |
|
11517 |
|
11518 | function createViewNodes(view) {
|
11519 | let renderHost;
|
11520 | if (isComponentView(view)) {
|
11521 | const hostDef = view.parentNodeDef;
|
11522 | renderHost = asElementData( ((view.parent)), ((((hostDef)).parent)).index).renderElement;
|
11523 | }
|
11524 | const def = view.def;
|
11525 | const nodes = view.nodes;
|
11526 | for (let i = 0; i < def.nodes.length; i++) {
|
11527 | const nodeDef = def.nodes[i];
|
11528 | Services.setCurrentNode(view, i);
|
11529 | let nodeData;
|
11530 | switch (nodeDef.flags & 100673535 ) {
|
11531 | case 1 :
|
11532 | const el = (createElement(view, renderHost, nodeDef));
|
11533 | let componentView = ((undefined));
|
11534 | if (nodeDef.flags & 16777216 ) {
|
11535 | const compViewDef = resolveViewDefinition( ((((nodeDef.element)).componentView)));
|
11536 | const rendererType = ((nodeDef.element)).componentRendererType;
|
11537 | let compRenderer;
|
11538 | if (!rendererType) {
|
11539 | compRenderer = view.root.renderer;
|
11540 | }
|
11541 | else {
|
11542 | compRenderer = view.root.rendererFactory.createRenderer(el, rendererType);
|
11543 | }
|
11544 | componentView = createView(view.root, compRenderer, view, ((nodeDef.element)).componentProvider, compViewDef);
|
11545 | }
|
11546 | listenToElementOutputs(view, componentView, nodeDef, el);
|
11547 | nodeData = ({
|
11548 | renderElement: el,
|
11549 | componentView,
|
11550 | viewContainer: null,
|
11551 | template: ((nodeDef.element)).template ? createTemplateData(view, nodeDef) : undefined
|
11552 | });
|
11553 | if (nodeDef.flags & 8388608 ) {
|
11554 | nodeData.viewContainer = createViewContainerData(view, nodeDef, nodeData);
|
11555 | }
|
11556 | break;
|
11557 | case 2 :
|
11558 | nodeData = (createText(view, renderHost, nodeDef));
|
11559 | break;
|
11560 | case 256 :
|
11561 | case 512 :
|
11562 | case 1024 :
|
11563 | case 128 : {
|
11564 | const instance = createProviderInstance(view, nodeDef);
|
11565 | nodeData = ({ instance });
|
11566 | break;
|
11567 | }
|
11568 | case 8 : {
|
11569 | const instance = createPipeInstance(view, nodeDef);
|
11570 | nodeData = ({ instance });
|
11571 | break;
|
11572 | }
|
11573 | case 8192 : {
|
11574 | const instance = createDirectiveInstance(view, nodeDef);
|
11575 | nodeData = ({ instance });
|
11576 | if (nodeDef.flags & 16384 ) {
|
11577 | const compView = asElementData(view, ((nodeDef.parent)).index).componentView;
|
11578 | initView(compView, instance, instance);
|
11579 | }
|
11580 | break;
|
11581 | }
|
11582 | case 16 :
|
11583 | case 32 :
|
11584 | case 64 :
|
11585 | nodeData = (createPureExpression(view, nodeDef));
|
11586 | break;
|
11587 | case 33554432 :
|
11588 | case 67108864 :
|
11589 | nodeData = (createQuery());
|
11590 | break;
|
11591 | case 4 :
|
11592 | appendNgContent(view, renderHost, nodeDef);
|
11593 |
|
11594 | nodeData = undefined;
|
11595 | break;
|
11596 | }
|
11597 | nodes[i] = nodeData;
|
11598 | }
|
11599 |
|
11600 |
|
11601 | execComponentViewsAction(view, ViewAction.CreateViewNodes);
|
11602 |
|
11603 | execQueriesAction(view, 33554432 | 67108864 , 134217728 , 0 );
|
11604 | }
|
11605 |
|
11606 |
|
11607 |
|
11608 |
|
11609 | function checkNoChangesView(view) {
|
11610 | Services.updateDirectives(view, 1 );
|
11611 | execEmbeddedViewsAction(view, ViewAction.CheckNoChanges);
|
11612 | Services.updateRenderer(view, 1 );
|
11613 | execComponentViewsAction(view, ViewAction.CheckNoChanges);
|
11614 |
|
11615 |
|
11616 | }
|
11617 |
|
11618 |
|
11619 |
|
11620 |
|
11621 | function checkAndUpdateView(view) {
|
11622 | if (view.state & 1 ) {
|
11623 | view.state &= ~1 ;
|
11624 | view.state |= 2 ;
|
11625 | }
|
11626 | else {
|
11627 | view.state &= ~2 ;
|
11628 | }
|
11629 | Services.updateDirectives(view, 0 );
|
11630 | execEmbeddedViewsAction(view, ViewAction.CheckAndUpdate);
|
11631 | execQueriesAction(view, 33554432 , 268435456 , 0 );
|
11632 | callLifecycleHooksChildrenFirst(view, 1048576 |
|
11633 | (view.state & 2 ? 524288 : 0));
|
11634 | Services.updateRenderer(view, 0 );
|
11635 | execComponentViewsAction(view, ViewAction.CheckAndUpdate);
|
11636 | execQueriesAction(view, 67108864 , 268435456 , 0 );
|
11637 | callLifecycleHooksChildrenFirst(view, 4194304 |
|
11638 | (view.state & 2 ? 2097152 : 0));
|
11639 | if (view.def.flags & 2 ) {
|
11640 | view.state &= ~8 ;
|
11641 | }
|
11642 | }
|
11643 |
|
11644 |
|
11645 |
|
11646 |
|
11647 |
|
11648 |
|
11649 |
|
11650 |
|
11651 |
|
11652 |
|
11653 |
|
11654 |
|
11655 |
|
11656 |
|
11657 |
|
11658 |
|
11659 | function checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11660 | if (argStyle === 0 ) {
|
11661 | return checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11662 | }
|
11663 | else {
|
11664 | return checkAndUpdateNodeDynamic(view, nodeDef, v0);
|
11665 | }
|
11666 | }
|
11667 |
|
11668 |
|
11669 |
|
11670 |
|
11671 |
|
11672 |
|
11673 |
|
11674 |
|
11675 |
|
11676 |
|
11677 |
|
11678 |
|
11679 |
|
11680 |
|
11681 |
|
11682 | function checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11683 | let changed = false;
|
11684 | switch (nodeDef.flags & 100673535 ) {
|
11685 | case 1 :
|
11686 | changed = checkAndUpdateElementInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11687 | break;
|
11688 | case 2 :
|
11689 | changed = checkAndUpdateTextInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11690 | break;
|
11691 | case 8192 :
|
11692 | changed =
|
11693 | checkAndUpdateDirectiveInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11694 | break;
|
11695 | case 16 :
|
11696 | case 32 :
|
11697 | case 64 :
|
11698 | changed =
|
11699 | checkAndUpdatePureExpressionInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11700 | break;
|
11701 | }
|
11702 | return changed;
|
11703 | }
|
11704 |
|
11705 |
|
11706 |
|
11707 |
|
11708 |
|
11709 |
|
11710 | function checkAndUpdateNodeDynamic(view, nodeDef, values) {
|
11711 | let changed = false;
|
11712 | switch (nodeDef.flags & 100673535 ) {
|
11713 | case 1 :
|
11714 | changed = checkAndUpdateElementDynamic(view, nodeDef, values);
|
11715 | break;
|
11716 | case 2 :
|
11717 | changed = checkAndUpdateTextDynamic(view, nodeDef, values);
|
11718 | break;
|
11719 | case 8192 :
|
11720 | changed = checkAndUpdateDirectiveDynamic(view, nodeDef, values);
|
11721 | break;
|
11722 | case 16 :
|
11723 | case 32 :
|
11724 | case 64 :
|
11725 | changed = checkAndUpdatePureExpressionDynamic(view, nodeDef, values);
|
11726 | break;
|
11727 | }
|
11728 | if (changed) {
|
11729 |
|
11730 |
|
11731 | const bindLen = nodeDef.bindings.length;
|
11732 | const bindingStart = nodeDef.bindingIndex;
|
11733 | const oldValues = view.oldValues;
|
11734 | for (let i = 0; i < bindLen; i++) {
|
11735 | oldValues[bindingStart + i] = values[i];
|
11736 | }
|
11737 | }
|
11738 | return changed;
|
11739 | }
|
11740 |
|
11741 |
|
11742 |
|
11743 |
|
11744 |
|
11745 |
|
11746 |
|
11747 |
|
11748 |
|
11749 |
|
11750 |
|
11751 |
|
11752 |
|
11753 |
|
11754 |
|
11755 |
|
11756 | function checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11757 | if (argStyle === 0 ) {
|
11758 | checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11759 | }
|
11760 | else {
|
11761 | checkNoChangesNodeDynamic(view, nodeDef, v0);
|
11762 | }
|
11763 |
|
11764 | return false;
|
11765 | }
|
11766 |
|
11767 |
|
11768 |
|
11769 |
|
11770 |
|
11771 |
|
11772 |
|
11773 |
|
11774 |
|
11775 |
|
11776 |
|
11777 |
|
11778 |
|
11779 |
|
11780 |
|
11781 | function checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11782 | const bindLen = nodeDef.bindings.length;
|
11783 | if (bindLen > 0)
|
11784 | checkBindingNoChanges(view, nodeDef, 0, v0);
|
11785 | if (bindLen > 1)
|
11786 | checkBindingNoChanges(view, nodeDef, 1, v1);
|
11787 | if (bindLen > 2)
|
11788 | checkBindingNoChanges(view, nodeDef, 2, v2);
|
11789 | if (bindLen > 3)
|
11790 | checkBindingNoChanges(view, nodeDef, 3, v3);
|
11791 | if (bindLen > 4)
|
11792 | checkBindingNoChanges(view, nodeDef, 4, v4);
|
11793 | if (bindLen > 5)
|
11794 | checkBindingNoChanges(view, nodeDef, 5, v5);
|
11795 | if (bindLen > 6)
|
11796 | checkBindingNoChanges(view, nodeDef, 6, v6);
|
11797 | if (bindLen > 7)
|
11798 | checkBindingNoChanges(view, nodeDef, 7, v7);
|
11799 | if (bindLen > 8)
|
11800 | checkBindingNoChanges(view, nodeDef, 8, v8);
|
11801 | if (bindLen > 9)
|
11802 | checkBindingNoChanges(view, nodeDef, 9, v9);
|
11803 | }
|
11804 |
|
11805 |
|
11806 |
|
11807 |
|
11808 |
|
11809 |
|
11810 | function checkNoChangesNodeDynamic(view, nodeDef, values) {
|
11811 | for (let i = 0; i < values.length; i++) {
|
11812 | checkBindingNoChanges(view, nodeDef, i, values[i]);
|
11813 | }
|
11814 | }
|
11815 |
|
11816 |
|
11817 |
|
11818 |
|
11819 |
|
11820 | function checkNoChangesQuery(view, nodeDef) {
|
11821 | const queryList = asQueryList(view, nodeDef.index);
|
11822 | if (queryList.dirty) {
|
11823 | throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, nodeDef.index), `Query ${ /** @type {?} */((nodeDef.query)).id} not dirty`, `Query ${ /** @type {?} */((nodeDef.query)).id} dirty`, (view.state & 1 ) !== 0);
|
11824 | }
|
11825 | }
|
11826 |
|
11827 |
|
11828 |
|
11829 |
|
11830 | function destroyView(view) {
|
11831 | if (view.state & 16 ) {
|
11832 | return;
|
11833 | }
|
11834 | execEmbeddedViewsAction(view, ViewAction.Destroy);
|
11835 | execComponentViewsAction(view, ViewAction.Destroy);
|
11836 | callLifecycleHooksChildrenFirst(view, 65536 );
|
11837 | if (view.disposables) {
|
11838 | for (let i = 0; i < view.disposables.length; i++) {
|
11839 | view.disposables[i]();
|
11840 | }
|
11841 | }
|
11842 | if (view.renderer.destroyNode) {
|
11843 | destroyViewNodes(view);
|
11844 | }
|
11845 | if (isComponentView(view)) {
|
11846 | view.renderer.destroy();
|
11847 | }
|
11848 | view.state |= 16 ;
|
11849 | }
|
11850 |
|
11851 |
|
11852 |
|
11853 |
|
11854 | function destroyViewNodes(view) {
|
11855 | const len = view.def.nodes.length;
|
11856 | for (let i = 0; i < len; i++) {
|
11857 | const def = view.def.nodes[i];
|
11858 | if (def.flags & 1 ) {
|
11859 | ((view.renderer.destroyNode))(asElementData(view, i).renderElement);
|
11860 | }
|
11861 | else if (def.flags & 2 ) {
|
11862 | ((view.renderer.destroyNode))(asTextData(view, i).renderText);
|
11863 | }
|
11864 | }
|
11865 | }
|
11866 | let ViewAction = {};
|
11867 | ViewAction.CreateViewNodes = 0;
|
11868 | ViewAction.CheckNoChanges = 1;
|
11869 | ViewAction.CheckAndUpdate = 2;
|
11870 | ViewAction.Destroy = 3;
|
11871 | ViewAction[ViewAction.CreateViewNodes] = "CreateViewNodes";
|
11872 | ViewAction[ViewAction.CheckNoChanges] = "CheckNoChanges";
|
11873 | ViewAction[ViewAction.CheckAndUpdate] = "CheckAndUpdate";
|
11874 | ViewAction[ViewAction.Destroy] = "Destroy";
|
11875 |
|
11876 |
|
11877 |
|
11878 |
|
11879 |
|
11880 | function execComponentViewsAction(view, action) {
|
11881 | const def = view.def;
|
11882 | if (!(def.nodeFlags & 16777216 )) {
|
11883 | return;
|
11884 | }
|
11885 | for (let i = 0; i < def.nodes.length; i++) {
|
11886 | const nodeDef = def.nodes[i];
|
11887 | if (nodeDef.flags & 16777216 ) {
|
11888 |
|
11889 | callViewAction(asElementData(view, i).componentView, action);
|
11890 | }
|
11891 | else if ((nodeDef.childFlags & 16777216 ) === 0) {
|
11892 |
|
11893 |
|
11894 |
|
11895 | i += nodeDef.childCount;
|
11896 | }
|
11897 | }
|
11898 | }
|
11899 |
|
11900 |
|
11901 |
|
11902 |
|
11903 |
|
11904 | function execEmbeddedViewsAction(view, action) {
|
11905 | const def = view.def;
|
11906 | if (!(def.nodeFlags & 8388608 )) {
|
11907 | return;
|
11908 | }
|
11909 | for (let i = 0; i < def.nodes.length; i++) {
|
11910 | const nodeDef = def.nodes[i];
|
11911 | if (nodeDef.flags & 8388608 ) {
|
11912 |
|
11913 | const embeddedViews = ((asElementData(view, i).viewContainer))._embeddedViews;
|
11914 | for (let k = 0; k < embeddedViews.length; k++) {
|
11915 | callViewAction(embeddedViews[k], action);
|
11916 | }
|
11917 | }
|
11918 | else if ((nodeDef.childFlags & 8388608 ) === 0) {
|
11919 |
|
11920 |
|
11921 |
|
11922 | i += nodeDef.childCount;
|
11923 | }
|
11924 | }
|
11925 | }
|
11926 |
|
11927 |
|
11928 |
|
11929 |
|
11930 |
|
11931 | function callViewAction(view, action) {
|
11932 | const viewState = view.state;
|
11933 | switch (action) {
|
11934 | case ViewAction.CheckNoChanges:
|
11935 | if ((viewState & 12 ) === 12 &&
|
11936 | (viewState & 16 ) === 0) {
|
11937 | checkNoChangesView(view);
|
11938 | }
|
11939 | break;
|
11940 | case ViewAction.CheckAndUpdate:
|
11941 | if ((viewState & 12 ) === 12 &&
|
11942 | (viewState & 16 ) === 0) {
|
11943 | checkAndUpdateView(view);
|
11944 | }
|
11945 | break;
|
11946 | case ViewAction.Destroy:
|
11947 | destroyView(view);
|
11948 | break;
|
11949 | case ViewAction.CreateViewNodes:
|
11950 | createViewNodes(view);
|
11951 | break;
|
11952 | }
|
11953 | }
|
11954 |
|
11955 |
|
11956 |
|
11957 |
|
11958 |
|
11959 |
|
11960 |
|
11961 | function execQueriesAction(view, queryFlags, staticDynamicQueryFlag, checkType) {
|
11962 | if (!(view.def.nodeFlags & queryFlags) || !(view.def.nodeFlags & staticDynamicQueryFlag)) {
|
11963 | return;
|
11964 | }
|
11965 | const nodeCount = view.def.nodes.length;
|
11966 | for (let i = 0; i < nodeCount; i++) {
|
11967 | const nodeDef = view.def.nodes[i];
|
11968 | if ((nodeDef.flags & queryFlags) && (nodeDef.flags & staticDynamicQueryFlag)) {
|
11969 | Services.setCurrentNode(view, nodeDef.index);
|
11970 | switch (checkType) {
|
11971 | case 0 :
|
11972 | checkAndUpdateQuery(view, nodeDef);
|
11973 | break;
|
11974 | case 1 :
|
11975 | checkNoChangesQuery(view, nodeDef);
|
11976 | break;
|
11977 | }
|
11978 | }
|
11979 | if (!(nodeDef.childFlags & queryFlags) || !(nodeDef.childFlags & staticDynamicQueryFlag)) {
|
11980 |
|
11981 |
|
11982 | i += nodeDef.childCount;
|
11983 | }
|
11984 | }
|
11985 | }
|
11986 |
|
11987 |
|
11988 |
|
11989 |
|
11990 |
|
11991 |
|
11992 |
|
11993 |
|
11994 | let initialized = false;
|
11995 |
|
11996 |
|
11997 |
|
11998 | function initServicesIfNeeded() {
|
11999 | if (initialized) {
|
12000 | return;
|
12001 | }
|
12002 | initialized = true;
|
12003 | const services = isDevMode() ? createDebugServices() : createProdServices();
|
12004 | Services.setCurrentNode = services.setCurrentNode;
|
12005 | Services.createRootView = services.createRootView;
|
12006 | Services.createEmbeddedView = services.createEmbeddedView;
|
12007 | Services.checkAndUpdateView = services.checkAndUpdateView;
|
12008 | Services.checkNoChangesView = services.checkNoChangesView;
|
12009 | Services.destroyView = services.destroyView;
|
12010 | Services.resolveDep = resolveDep;
|
12011 | Services.createDebugContext = services.createDebugContext;
|
12012 | Services.handleEvent = services.handleEvent;
|
12013 | Services.updateDirectives = services.updateDirectives;
|
12014 | Services.updateRenderer = services.updateRenderer;
|
12015 | Services.dirtyParentQueries = dirtyParentQueries;
|
12016 | }
|
12017 |
|
12018 |
|
12019 |
|
12020 | function createProdServices() {
|
12021 | return {
|
12022 | setCurrentNode: () => { },
|
12023 | createRootView: createProdRootView,
|
12024 | createEmbeddedView: createEmbeddedView,
|
12025 | checkAndUpdateView: checkAndUpdateView,
|
12026 | checkNoChangesView: checkNoChangesView,
|
12027 | destroyView: destroyView,
|
12028 | createDebugContext: (view, nodeIndex) => new DebugContext_(view, nodeIndex),
|
12029 | handleEvent: (view, nodeIndex, eventName, event) => view.def.handleEvent(view, nodeIndex, eventName, event),
|
12030 | updateDirectives: (view, checkType) => view.def.updateDirectives(checkType === 0 ? prodCheckAndUpdateNode :
|
12031 | prodCheckNoChangesNode, view),
|
12032 | updateRenderer: (view, checkType) => view.def.updateRenderer(checkType === 0 ? prodCheckAndUpdateNode :
|
12033 | prodCheckNoChangesNode, view),
|
12034 | };
|
12035 | }
|
12036 |
|
12037 |
|
12038 |
|
12039 | function createDebugServices() {
|
12040 | return {
|
12041 | setCurrentNode: debugSetCurrentNode,
|
12042 | createRootView: debugCreateRootView,
|
12043 | createEmbeddedView: debugCreateEmbeddedView,
|
12044 | checkAndUpdateView: debugCheckAndUpdateView,
|
12045 | checkNoChangesView: debugCheckNoChangesView,
|
12046 | destroyView: debugDestroyView,
|
12047 | createDebugContext: (view, nodeIndex) => new DebugContext_(view, nodeIndex),
|
12048 | handleEvent: debugHandleEvent,
|
12049 | updateDirectives: debugUpdateDirectives,
|
12050 | updateRenderer: debugUpdateRenderer
|
12051 | };
|
12052 | }
|
12053 |
|
12054 |
|
12055 |
|
12056 |
|
12057 |
|
12058 |
|
12059 |
|
12060 |
|
12061 |
|
12062 | function createProdRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
|
12063 | const rendererFactory = ngModule.injector.get(RendererFactory2);
|
12064 | return createRootView(createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode), def, context);
|
12065 | }
|
12066 |
|
12067 |
|
12068 |
|
12069 |
|
12070 |
|
12071 |
|
12072 |
|
12073 |
|
12074 |
|
12075 | function debugCreateRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
|
12076 | const rendererFactory = ngModule.injector.get(RendererFactory2);
|
12077 | const root = createRootData(elInjector, ngModule, new DebugRendererFactory2(rendererFactory), projectableNodes, rootSelectorOrNode);
|
12078 | return callWithDebugContext(DebugAction.create, createRootView, null, [root, def, context]);
|
12079 | }
|
12080 |
|
12081 |
|
12082 |
|
12083 |
|
12084 |
|
12085 |
|
12086 |
|
12087 |
|
12088 | function createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode) {
|
12089 | const sanitizer = ngModule.injector.get(Sanitizer);
|
12090 | const errorHandler = ngModule.injector.get(ErrorHandler);
|
12091 | const renderer = rendererFactory.createRenderer(null, null);
|
12092 | return {
|
12093 | ngModule,
|
12094 | injector: elInjector, projectableNodes,
|
12095 | selectorOrNode: rootSelectorOrNode, sanitizer, rendererFactory, renderer, errorHandler
|
12096 | };
|
12097 | }
|
12098 |
|
12099 |
|
12100 |
|
12101 |
|
12102 |
|
12103 |
|
12104 |
|
12105 |
|
12106 |
|
12107 |
|
12108 |
|
12109 |
|
12110 |
|
12111 |
|
12112 |
|
12113 |
|
12114 | function prodCheckAndUpdateNode(view, nodeIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
12115 | const nodeDef = view.def.nodes[nodeIndex];
|
12116 | checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
12117 | return (nodeDef.flags & 112 ) ?
|
12118 | asPureExpressionData(view, nodeIndex).value :
|
12119 | undefined;
|
12120 | }
|
12121 |
|
12122 |
|
12123 |
|
12124 |
|
12125 |
|
12126 |
|
12127 |
|
12128 |
|
12129 |
|
12130 |
|
12131 |
|
12132 |
|
12133 |
|
12134 |
|
12135 |
|
12136 |
|
12137 | function prodCheckNoChangesNode(view, nodeIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
12138 | const nodeDef = view.def.nodes[nodeIndex];
|
12139 | checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
12140 | return (nodeDef.flags & 112 ) ?
|
12141 | asPureExpressionData(view, nodeIndex).value :
|
12142 | undefined;
|
12143 | }
|
12144 |
|
12145 |
|
12146 |
|
12147 |
|
12148 |
|
12149 |
|
12150 | function debugCreateEmbeddedView(parent, anchorDef, context) {
|
12151 | return callWithDebugContext(DebugAction.create, createEmbeddedView, null, [parent, anchorDef, context]);
|
12152 | }
|
12153 |
|
12154 |
|
12155 |
|
12156 |
|
12157 | function debugCheckAndUpdateView(view) {
|
12158 | return callWithDebugContext(DebugAction.detectChanges, checkAndUpdateView, null, [view]);
|
12159 | }
|
12160 |
|
12161 |
|
12162 |
|
12163 |
|
12164 | function debugCheckNoChangesView(view) {
|
12165 | return callWithDebugContext(DebugAction.checkNoChanges, checkNoChangesView, null, [view]);
|
12166 | }
|
12167 |
|
12168 |
|
12169 |
|
12170 |
|
12171 | function debugDestroyView(view) {
|
12172 | return callWithDebugContext(DebugAction.destroy, destroyView, null, [view]);
|
12173 | }
|
12174 | let DebugAction = {};
|
12175 | DebugAction.create = 0;
|
12176 | DebugAction.detectChanges = 1;
|
12177 | DebugAction.checkNoChanges = 2;
|
12178 | DebugAction.destroy = 3;
|
12179 | DebugAction.handleEvent = 4;
|
12180 | DebugAction[DebugAction.create] = "create";
|
12181 | DebugAction[DebugAction.detectChanges] = "detectChanges";
|
12182 | DebugAction[DebugAction.checkNoChanges] = "checkNoChanges";
|
12183 | DebugAction[DebugAction.destroy] = "destroy";
|
12184 | DebugAction[DebugAction.handleEvent] = "handleEvent";
|
12185 | let _currentAction;
|
12186 | let _currentView;
|
12187 | let _currentNodeIndex;
|
12188 |
|
12189 |
|
12190 |
|
12191 |
|
12192 |
|
12193 | function debugSetCurrentNode(view, nodeIndex) {
|
12194 | _currentView = view;
|
12195 | _currentNodeIndex = nodeIndex;
|
12196 | }
|
12197 |
|
12198 |
|
12199 |
|
12200 |
|
12201 |
|
12202 |
|
12203 |
|
12204 | function debugHandleEvent(view, nodeIndex, eventName, event) {
|
12205 | debugSetCurrentNode(view, nodeIndex);
|
12206 | return callWithDebugContext(DebugAction.handleEvent, view.def.handleEvent, null, [view, nodeIndex, eventName, event]);
|
12207 | }
|
12208 |
|
12209 |
|
12210 |
|
12211 |
|
12212 |
|
12213 | function debugUpdateDirectives(view, checkType) {
|
12214 | if (view.state & 16 ) {
|
12215 | throw viewDestroyedError(DebugAction[_currentAction]);
|
12216 | }
|
12217 | debugSetCurrentNode(view, nextDirectiveWithBinding(view, 0));
|
12218 | return view.def.updateDirectives(debugCheckDirectivesFn, view);
|
12219 | |
12220 |
|
12221 |
|
12222 |
|
12223 |
|
12224 |
|
12225 |
|
12226 | function debugCheckDirectivesFn(view, nodeIndex, argStyle, ...values) {
|
12227 | const nodeDef = view.def.nodes[nodeIndex];
|
12228 | if (checkType === 0 ) {
|
12229 | debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
|
12230 | }
|
12231 | else {
|
12232 | debugCheckNoChangesNode(view, nodeDef, argStyle, values);
|
12233 | }
|
12234 | if (nodeDef.flags & 8192 ) {
|
12235 | debugSetCurrentNode(view, nextDirectiveWithBinding(view, nodeIndex));
|
12236 | }
|
12237 | return (nodeDef.flags & 112 ) ?
|
12238 | asPureExpressionData(view, nodeDef.index).value :
|
12239 | undefined;
|
12240 | }
|
12241 | }
|
12242 |
|
12243 |
|
12244 |
|
12245 |
|
12246 |
|
12247 | function debugUpdateRenderer(view, checkType) {
|
12248 | if (view.state & 16 ) {
|
12249 | throw viewDestroyedError(DebugAction[_currentAction]);
|
12250 | }
|
12251 | debugSetCurrentNode(view, nextRenderNodeWithBinding(view, 0));
|
12252 | return view.def.updateRenderer(debugCheckRenderNodeFn, view);
|
12253 | |
12254 |
|
12255 |
|
12256 |
|
12257 |
|
12258 |
|
12259 |
|
12260 | function debugCheckRenderNodeFn(view, nodeIndex, argStyle, ...values) {
|
12261 | const nodeDef = view.def.nodes[nodeIndex];
|
12262 | if (checkType === 0 ) {
|
12263 | debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
|
12264 | }
|
12265 | else {
|
12266 | debugCheckNoChangesNode(view, nodeDef, argStyle, values);
|
12267 | }
|
12268 | if (nodeDef.flags & 3 ) {
|
12269 | debugSetCurrentNode(view, nextRenderNodeWithBinding(view, nodeIndex));
|
12270 | }
|
12271 | return (nodeDef.flags & 112 ) ?
|
12272 | asPureExpressionData(view, nodeDef.index).value :
|
12273 | undefined;
|
12274 | }
|
12275 | }
|
12276 |
|
12277 |
|
12278 |
|
12279 |
|
12280 |
|
12281 |
|
12282 |
|
12283 | function debugCheckAndUpdateNode(view, nodeDef, argStyle, givenValues) {
|
12284 | const changed = ((checkAndUpdateNode))(view, nodeDef, argStyle, ...givenValues);
|
12285 | if (changed) {
|
12286 | const values = argStyle === 1 ? givenValues[0] : givenValues;
|
12287 | if (nodeDef.flags & 8192 ) {
|
12288 | const bindingValues = {};
|
12289 | for (let i = 0; i < nodeDef.bindings.length; i++) {
|
12290 | const binding = nodeDef.bindings[i];
|
12291 | const value = values[i];
|
12292 | if (binding.flags & 8 ) {
|
12293 | bindingValues[normalizeDebugBindingName( ((binding.nonMinifiedName)))] =
|
12294 | normalizeDebugBindingValue(value);
|
12295 | }
|
12296 | }
|
12297 | const elDef = ((nodeDef.parent));
|
12298 | const el = asElementData(view, elDef.index).renderElement;
|
12299 | if (!((elDef.element)).name) {
|
12300 |
|
12301 | view.renderer.setValue(el, `bindings=${JSON.stringify(bindingValues, null, 2)}`);
|
12302 | }
|
12303 | else {
|
12304 |
|
12305 | for (let attr in bindingValues) {
|
12306 | const value = bindingValues[attr];
|
12307 | if (value != null) {
|
12308 | view.renderer.setAttribute(el, attr, value);
|
12309 | }
|
12310 | else {
|
12311 | view.renderer.removeAttribute(el, attr);
|
12312 | }
|
12313 | }
|
12314 | }
|
12315 | }
|
12316 | }
|
12317 | }
|
12318 |
|
12319 |
|
12320 |
|
12321 |
|
12322 |
|
12323 |
|
12324 |
|
12325 | function debugCheckNoChangesNode(view, nodeDef, argStyle, values) {
|
12326 | ((checkNoChangesNode))(view, nodeDef, argStyle, ...values);
|
12327 | }
|
12328 |
|
12329 |
|
12330 |
|
12331 |
|
12332 | function normalizeDebugBindingName(name) {
|
12333 |
|
12334 | name = camelCaseToDashCase(name.replace(/[$@]/g, '_'));
|
12335 | return `ng-reflect-${name}`;
|
12336 | }
|
12337 | const CAMEL_CASE_REGEXP = /([A-Z])/g;
|
12338 |
|
12339 |
|
12340 |
|
12341 |
|
12342 | function camelCaseToDashCase(input) {
|
12343 | return input.replace(CAMEL_CASE_REGEXP, (...m) => '-' + m[1].toLowerCase());
|
12344 | }
|
12345 |
|
12346 |
|
12347 |
|
12348 |
|
12349 | function normalizeDebugBindingValue(value) {
|
12350 | try {
|
12351 |
|
12352 | return value != null ? value.toString().slice(0, 30) : value;
|
12353 | }
|
12354 | catch (e) {
|
12355 | return '[ERROR] Exception while trying to serialize the value';
|
12356 | }
|
12357 | }
|
12358 |
|
12359 |
|
12360 |
|
12361 |
|
12362 |
|
12363 | function nextDirectiveWithBinding(view, nodeIndex) {
|
12364 | for (let i = nodeIndex; i < view.def.nodes.length; i++) {
|
12365 | const nodeDef = view.def.nodes[i];
|
12366 | if (nodeDef.flags & 8192 && nodeDef.bindings && nodeDef.bindings.length) {
|
12367 | return i;
|
12368 | }
|
12369 | }
|
12370 | return null;
|
12371 | }
|
12372 |
|
12373 |
|
12374 |
|
12375 |
|
12376 |
|
12377 | function nextRenderNodeWithBinding(view, nodeIndex) {
|
12378 | for (let i = nodeIndex; i < view.def.nodes.length; i++) {
|
12379 | const nodeDef = view.def.nodes[i];
|
12380 | if ((nodeDef.flags & 3 ) && nodeDef.bindings && nodeDef.bindings.length) {
|
12381 | return i;
|
12382 | }
|
12383 | }
|
12384 | return null;
|
12385 | }
|
12386 | class DebugContext_ {
|
12387 | |
12388 |
|
12389 |
|
12390 |
|
12391 | constructor(view, nodeIndex) {
|
12392 | this.view = view;
|
12393 | this.nodeIndex = nodeIndex;
|
12394 | if (nodeIndex == null) {
|
12395 | this.nodeIndex = nodeIndex = 0;
|
12396 | }
|
12397 | this.nodeDef = view.def.nodes[nodeIndex];
|
12398 | let elDef = this.nodeDef;
|
12399 | let elView = view;
|
12400 | while (elDef && (elDef.flags & 1 ) === 0) {
|
12401 | elDef = elDef.parent;
|
12402 | }
|
12403 | if (!elDef) {
|
12404 | while (!elDef && elView) {
|
12405 | elDef = viewParentEl(elView);
|
12406 | elView = elView.parent;
|
12407 | }
|
12408 | }
|
12409 | this.elDef = elDef;
|
12410 | this.elView = elView;
|
12411 | }
|
12412 | |
12413 |
|
12414 |
|
12415 | get elOrCompView() {
|
12416 |
|
12417 | return asElementData(this.elView, this.elDef.index).componentView || this.view;
|
12418 | }
|
12419 | |
12420 |
|
12421 |
|
12422 | get injector() { return createInjector(this.elView, this.elDef); }
|
12423 | |
12424 |
|
12425 |
|
12426 | get component() { return this.elOrCompView.component; }
|
12427 | |
12428 |
|
12429 |
|
12430 | get context() { return this.elOrCompView.context; }
|
12431 | |
12432 |
|
12433 |
|
12434 | get providerTokens() {
|
12435 | const tokens = [];
|
12436 | if (this.elDef) {
|
12437 | for (let i = this.elDef.index + 1; i <= this.elDef.index + this.elDef.childCount; i++) {
|
12438 | const childDef = this.elView.def.nodes[i];
|
12439 | if (childDef.flags & 10112 ) {
|
12440 | tokens.push( ((childDef.provider)).token);
|
12441 | }
|
12442 | i += childDef.childCount;
|
12443 | }
|
12444 | }
|
12445 | return tokens;
|
12446 | }
|
12447 | |
12448 |
|
12449 |
|
12450 | get references() {
|
12451 | const references = {};
|
12452 | if (this.elDef) {
|
12453 | collectReferences(this.elView, this.elDef, references);
|
12454 | for (let i = this.elDef.index + 1; i <= this.elDef.index + this.elDef.childCount; i++) {
|
12455 | const childDef = this.elView.def.nodes[i];
|
12456 | if (childDef.flags & 10112 ) {
|
12457 | collectReferences(this.elView, childDef, references);
|
12458 | }
|
12459 | i += childDef.childCount;
|
12460 | }
|
12461 | }
|
12462 | return references;
|
12463 | }
|
12464 | |
12465 |
|
12466 |
|
12467 | get componentRenderElement() {
|
12468 | const elData = findHostElement(this.elOrCompView);
|
12469 | return elData ? elData.renderElement : undefined;
|
12470 | }
|
12471 | |
12472 |
|
12473 |
|
12474 | get renderNode() {
|
12475 | return this.nodeDef.flags & 2 ? renderNode(this.view, this.nodeDef) :
|
12476 | renderNode(this.elView, this.elDef);
|
12477 | }
|
12478 | |
12479 |
|
12480 |
|
12481 |
|
12482 |
|
12483 | logError(console, ...values) {
|
12484 | let logViewDef;
|
12485 | let logNodeIndex;
|
12486 | if (this.nodeDef.flags & 2 ) {
|
12487 | logViewDef = this.view.def;
|
12488 | logNodeIndex = this.nodeDef.index;
|
12489 | }
|
12490 | else {
|
12491 | logViewDef = this.elView.def;
|
12492 | logNodeIndex = this.elDef.index;
|
12493 | }
|
12494 |
|
12495 |
|
12496 | const renderNodeIndex = getRenderNodeIndex(logViewDef, logNodeIndex);
|
12497 | let currRenderNodeIndex = -1;
|
12498 | let nodeLogger = () => {
|
12499 | currRenderNodeIndex++;
|
12500 | if (currRenderNodeIndex === renderNodeIndex) {
|
12501 | return console.error.bind(console, ...values);
|
12502 | }
|
12503 | else {
|
12504 | return NOOP;
|
12505 | }
|
12506 | };
|
12507 | ((logViewDef.factory))(nodeLogger);
|
12508 | if (currRenderNodeIndex < renderNodeIndex) {
|
12509 | console.error('Illegal state: the ViewDefinitionFactory did not call the logger!');
|
12510 | ((console.error))(...values);
|
12511 | }
|
12512 | }
|
12513 | }
|
12514 |
|
12515 |
|
12516 |
|
12517 |
|
12518 |
|
12519 | function getRenderNodeIndex(viewDef$$1, nodeIndex) {
|
12520 | let renderNodeIndex = -1;
|
12521 | for (let i = 0; i <= nodeIndex; i++) {
|
12522 | const nodeDef = viewDef$$1.nodes[i];
|
12523 | if (nodeDef.flags & 3 ) {
|
12524 | renderNodeIndex++;
|
12525 | }
|
12526 | }
|
12527 | return renderNodeIndex;
|
12528 | }
|
12529 |
|
12530 |
|
12531 |
|
12532 |
|
12533 | function findHostElement(view) {
|
12534 | while (view && !isComponentView(view)) {
|
12535 | view = ((view.parent));
|
12536 | }
|
12537 | if (view.parent) {
|
12538 | return asElementData(view.parent, ((viewParentEl(view))).index);
|
12539 | }
|
12540 | return null;
|
12541 | }
|
12542 |
|
12543 |
|
12544 |
|
12545 |
|
12546 |
|
12547 |
|
12548 | function collectReferences(view, nodeDef, references) {
|
12549 | for (let refName in nodeDef.references) {
|
12550 | references[refName] = getQueryValue(view, nodeDef, nodeDef.references[refName]);
|
12551 | }
|
12552 | }
|
12553 |
|
12554 |
|
12555 |
|
12556 |
|
12557 |
|
12558 |
|
12559 |
|
12560 | function callWithDebugContext(action, fn, self, args) {
|
12561 | const oldAction = _currentAction;
|
12562 | const oldView = _currentView;
|
12563 | const oldNodeIndex = _currentNodeIndex;
|
12564 | try {
|
12565 | _currentAction = action;
|
12566 | const result = fn.apply(self, args);
|
12567 | _currentView = oldView;
|
12568 | _currentNodeIndex = oldNodeIndex;
|
12569 | _currentAction = oldAction;
|
12570 | return result;
|
12571 | }
|
12572 | catch (e) {
|
12573 | if (isViewDebugError(e) || !_currentView) {
|
12574 | throw e;
|
12575 | }
|
12576 | throw viewWrappedDebugError(e, ((getCurrentDebugContext())));
|
12577 | }
|
12578 | }
|
12579 |
|
12580 |
|
12581 |
|
12582 | function getCurrentDebugContext() {
|
12583 | return _currentView ? new DebugContext_(_currentView, _currentNodeIndex) : null;
|
12584 | }
|
12585 | class DebugRendererFactory2 {
|
12586 | |
12587 |
|
12588 |
|
12589 | constructor(delegate) {
|
12590 | this.delegate = delegate;
|
12591 | }
|
12592 | |
12593 |
|
12594 |
|
12595 |
|
12596 |
|
12597 | createRenderer(element, renderData) {
|
12598 | return new DebugRenderer2(this.delegate.createRenderer(element, renderData));
|
12599 | }
|
12600 | }
|
12601 | class DebugRenderer2 {
|
12602 | |
12603 |
|
12604 |
|
12605 | constructor(delegate) {
|
12606 | this.delegate = delegate;
|
12607 | }
|
12608 | |
12609 |
|
12610 |
|
12611 | get data() { return this.delegate.data; }
|
12612 | |
12613 |
|
12614 |
|
12615 |
|
12616 | destroyNode(node) {
|
12617 | removeDebugNodeFromIndex( ((getDebugNode(node))));
|
12618 | if (this.delegate.destroyNode) {
|
12619 | this.delegate.destroyNode(node);
|
12620 | }
|
12621 | }
|
12622 | |
12623 |
|
12624 |
|
12625 | destroy() { this.delegate.destroy(); }
|
12626 | |
12627 |
|
12628 |
|
12629 |
|
12630 |
|
12631 | createElement(name, namespace) {
|
12632 | const el = this.delegate.createElement(name, namespace);
|
12633 | const debugCtx = getCurrentDebugContext();
|
12634 | if (debugCtx) {
|
12635 | const debugEl = new DebugElement(el, null, debugCtx);
|
12636 | debugEl.name = name;
|
12637 | indexDebugNode(debugEl);
|
12638 | }
|
12639 | return el;
|
12640 | }
|
12641 | |
12642 |
|
12643 |
|
12644 |
|
12645 | createComment(value) {
|
12646 | const comment = this.delegate.createComment(value);
|
12647 | const debugCtx = getCurrentDebugContext();
|
12648 | if (debugCtx) {
|
12649 | indexDebugNode(new DebugNode(comment, null, debugCtx));
|
12650 | }
|
12651 | return comment;
|
12652 | }
|
12653 | |
12654 |
|
12655 |
|
12656 |
|
12657 | createText(value) {
|
12658 | const text = this.delegate.createText(value);
|
12659 | const debugCtx = getCurrentDebugContext();
|
12660 | if (debugCtx) {
|
12661 | indexDebugNode(new DebugNode(text, null, debugCtx));
|
12662 | }
|
12663 | return text;
|
12664 | }
|
12665 | |
12666 |
|
12667 |
|
12668 |
|
12669 |
|
12670 | appendChild(parent, newChild) {
|
12671 | const debugEl = getDebugNode(parent);
|
12672 | const debugChildEl = getDebugNode(newChild);
|
12673 | if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
|
12674 | debugEl.addChild(debugChildEl);
|
12675 | }
|
12676 | this.delegate.appendChild(parent, newChild);
|
12677 | }
|
12678 | |
12679 |
|
12680 |
|
12681 |
|
12682 |
|
12683 |
|
12684 | insertBefore(parent, newChild, refChild) {
|
12685 | const debugEl = getDebugNode(parent);
|
12686 | const debugChildEl = getDebugNode(newChild);
|
12687 | const debugRefEl = ((getDebugNode(refChild)));
|
12688 | if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
|
12689 | debugEl.insertBefore(debugRefEl, debugChildEl);
|
12690 | }
|
12691 | this.delegate.insertBefore(parent, newChild, refChild);
|
12692 | }
|
12693 | |
12694 |
|
12695 |
|
12696 |
|
12697 |
|
12698 | removeChild(parent, oldChild) {
|
12699 | const debugEl = getDebugNode(parent);
|
12700 | const debugChildEl = getDebugNode(oldChild);
|
12701 | if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
|
12702 | debugEl.removeChild(debugChildEl);
|
12703 | }
|
12704 | this.delegate.removeChild(parent, oldChild);
|
12705 | }
|
12706 | |
12707 |
|
12708 |
|
12709 |
|
12710 | selectRootElement(selectorOrNode) {
|
12711 | const el = this.delegate.selectRootElement(selectorOrNode);
|
12712 | const debugCtx = getCurrentDebugContext();
|
12713 | if (debugCtx) {
|
12714 | indexDebugNode(new DebugElement(el, null, debugCtx));
|
12715 | }
|
12716 | return el;
|
12717 | }
|
12718 | |
12719 |
|
12720 |
|
12721 |
|
12722 |
|
12723 |
|
12724 |
|
12725 | setAttribute(el, name, value, namespace) {
|
12726 | const debugEl = getDebugNode(el);
|
12727 | if (debugEl && debugEl instanceof DebugElement) {
|
12728 | const fullName = namespace ? namespace + ':' + name : name;
|
12729 | debugEl.attributes[fullName] = value;
|
12730 | }
|
12731 | this.delegate.setAttribute(el, name, value, namespace);
|
12732 | }
|
12733 | |
12734 |
|
12735 |
|
12736 |
|
12737 |
|
12738 |
|
12739 | removeAttribute(el, name, namespace) {
|
12740 | const debugEl = getDebugNode(el);
|
12741 | if (debugEl && debugEl instanceof DebugElement) {
|
12742 | const fullName = namespace ? namespace + ':' + name : name;
|
12743 | debugEl.attributes[fullName] = null;
|
12744 | }
|
12745 | this.delegate.removeAttribute(el, name, namespace);
|
12746 | }
|
12747 | |
12748 |
|
12749 |
|
12750 |
|
12751 |
|
12752 | addClass(el, name) {
|
12753 | const debugEl = getDebugNode(el);
|
12754 | if (debugEl && debugEl instanceof DebugElement) {
|
12755 | debugEl.classes[name] = true;
|
12756 | }
|
12757 | this.delegate.addClass(el, name);
|
12758 | }
|
12759 | |
12760 |
|
12761 |
|
12762 |
|
12763 |
|
12764 | removeClass(el, name) {
|
12765 | const debugEl = getDebugNode(el);
|
12766 | if (debugEl && debugEl instanceof DebugElement) {
|
12767 | debugEl.classes[name] = false;
|
12768 | }
|
12769 | this.delegate.removeClass(el, name);
|
12770 | }
|
12771 | |
12772 |
|
12773 |
|
12774 |
|
12775 |
|
12776 |
|
12777 |
|
12778 | setStyle(el, style, value, flags) {
|
12779 | const debugEl = getDebugNode(el);
|
12780 | if (debugEl && debugEl instanceof DebugElement) {
|
12781 | debugEl.styles[style] = value;
|
12782 | }
|
12783 | this.delegate.setStyle(el, style, value, flags);
|
12784 | }
|
12785 | |
12786 |
|
12787 |
|
12788 |
|
12789 |
|
12790 |
|
12791 | removeStyle(el, style, flags) {
|
12792 | const debugEl = getDebugNode(el);
|
12793 | if (debugEl && debugEl instanceof DebugElement) {
|
12794 | debugEl.styles[style] = null;
|
12795 | }
|
12796 | this.delegate.removeStyle(el, style, flags);
|
12797 | }
|
12798 | |
12799 |
|
12800 |
|
12801 |
|
12802 |
|
12803 |
|
12804 | setProperty(el, name, value) {
|
12805 | const debugEl = getDebugNode(el);
|
12806 | if (debugEl && debugEl instanceof DebugElement) {
|
12807 | debugEl.properties[name] = value;
|
12808 | }
|
12809 | this.delegate.setProperty(el, name, value);
|
12810 | }
|
12811 | |
12812 |
|
12813 |
|
12814 |
|
12815 |
|
12816 |
|
12817 | listen(target, eventName, callback) {
|
12818 | if (typeof target !== 'string') {
|
12819 | const debugEl = getDebugNode(target);
|
12820 | if (debugEl) {
|
12821 | debugEl.listeners.push(new EventListener(eventName, callback));
|
12822 | }
|
12823 | }
|
12824 | return this.delegate.listen(target, eventName, callback);
|
12825 | }
|
12826 | |
12827 |
|
12828 |
|
12829 |
|
12830 | parentNode(node) { return this.delegate.parentNode(node); }
|
12831 | |
12832 |
|
12833 |
|
12834 |
|
12835 | nextSibling(node) { return this.delegate.nextSibling(node); }
|
12836 | |
12837 |
|
12838 |
|
12839 |
|
12840 |
|
12841 | setValue(node, value) { return this.delegate.setValue(node, value); }
|
12842 | }
|
12843 |
|
12844 |
|
12845 |
|
12846 |
|
12847 |
|
12848 |
|
12849 |
|
12850 |
|
12851 |
|
12852 |
|
12853 |
|
12854 |
|
12855 |
|
12856 |
|
12857 |
|
12858 |
|
12859 |
|
12860 |
|
12861 |
|
12862 | function _iterableDiffersFactory() {
|
12863 | return defaultIterableDiffers;
|
12864 | }
|
12865 |
|
12866 |
|
12867 |
|
12868 | function _keyValueDiffersFactory() {
|
12869 | return defaultKeyValueDiffers;
|
12870 | }
|
12871 |
|
12872 |
|
12873 |
|
12874 |
|
12875 | function _localeFactory(locale) {
|
12876 | return locale || 'en-US';
|
12877 | }
|
12878 |
|
12879 |
|
12880 |
|
12881 | function _initViewEngine() {
|
12882 | initServicesIfNeeded();
|
12883 | }
|
12884 |
|
12885 |
|
12886 |
|
12887 |
|
12888 |
|
12889 |
|
12890 | class ApplicationModule {
|
12891 | |
12892 |
|
12893 |
|
12894 | constructor(appRef) { }
|
12895 | }
|
12896 | ApplicationModule.decorators = [
|
12897 | { type: NgModule, args: [{
|
12898 | providers: [
|
12899 | ApplicationRef_,
|
12900 | { provide: ApplicationRef, useExisting: ApplicationRef_ },
|
12901 | ApplicationInitStatus,
|
12902 | Compiler,
|
12903 | APP_ID_RANDOM_PROVIDER,
|
12904 | { provide: IterableDiffers, useFactory: _iterableDiffersFactory },
|
12905 | { provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory },
|
12906 | {
|
12907 | provide: LOCALE_ID,
|
12908 | useFactory: _localeFactory,
|
12909 | deps: [[new Inject(LOCALE_ID), new Optional(), new SkipSelf()]]
|
12910 | },
|
12911 | { provide: APP_INITIALIZER, useValue: _initViewEngine, multi: true },
|
12912 | ]
|
12913 | },] },
|
12914 | ];
|
12915 |
|
12916 |
|
12917 |
|
12918 | ApplicationModule.ctorParameters = () => [
|
12919 | { type: ApplicationRef, },
|
12920 | ];
|
12921 |
|
12922 |
|
12923 |
|
12924 |
|
12925 |
|
12926 |
|
12927 |
|
12928 |
|
12929 | let LifecycleHooks = {};
|
12930 | LifecycleHooks.OnInit = 0;
|
12931 | LifecycleHooks.OnDestroy = 1;
|
12932 | LifecycleHooks.DoCheck = 2;
|
12933 | LifecycleHooks.OnChanges = 3;
|
12934 | LifecycleHooks.AfterContentInit = 4;
|
12935 | LifecycleHooks.AfterContentChecked = 5;
|
12936 | LifecycleHooks.AfterViewInit = 6;
|
12937 | LifecycleHooks.AfterViewChecked = 7;
|
12938 | LifecycleHooks[LifecycleHooks.OnInit] = "OnInit";
|
12939 | LifecycleHooks[LifecycleHooks.OnDestroy] = "OnDestroy";
|
12940 | LifecycleHooks[LifecycleHooks.DoCheck] = "DoCheck";
|
12941 | LifecycleHooks[LifecycleHooks.OnChanges] = "OnChanges";
|
12942 | LifecycleHooks[LifecycleHooks.AfterContentInit] = "AfterContentInit";
|
12943 | LifecycleHooks[LifecycleHooks.AfterContentChecked] = "AfterContentChecked";
|
12944 | LifecycleHooks[LifecycleHooks.AfterViewInit] = "AfterViewInit";
|
12945 | LifecycleHooks[LifecycleHooks.AfterViewChecked] = "AfterViewChecked";
|
12946 | const LIFECYCLE_HOOKS_VALUES = [
|
12947 | LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges,
|
12948 | LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit,
|
12949 | LifecycleHooks.AfterViewChecked
|
12950 | ];
|
12951 |
|
12952 |
|
12953 |
|
12954 |
|
12955 |
|
12956 |
|
12957 |
|
12958 |
|
12959 |
|
12960 |
|
12961 |
|
12962 |
|
12963 |
|
12964 |
|
12965 |
|
12966 |
|
12967 |
|
12968 |
|
12969 |
|
12970 |
|
12971 |
|
12972 |
|
12973 |
|
12974 |
|
12975 |
|
12976 |
|
12977 |
|
12978 |
|
12979 |
|
12980 |
|
12981 |
|
12982 |
|
12983 |
|
12984 |
|
12985 |
|
12986 |
|
12987 |
|
12988 |
|
12989 |
|
12990 |
|
12991 |
|
12992 |
|
12993 |
|
12994 |
|
12995 |
|
12996 |
|
12997 |
|
12998 |
|
12999 |
|
13000 |
|
13001 |
|
13002 |
|
13003 |
|
13004 |
|
13005 |
|
13006 |
|
13007 |
|
13008 |
|
13009 |
|
13010 |
|
13011 |
|
13012 |
|
13013 |
|
13014 |
|
13015 |
|
13016 |
|
13017 |
|
13018 |
|
13019 |
|
13020 |
|
13021 |
|
13022 |
|
13023 |
|
13024 |
|
13025 |
|
13026 | function trigger$1(name, definitions) {
|
13027 | return { name, definitions };
|
13028 | }
|
13029 |
|
13030 |
|
13031 |
|
13032 |
|
13033 |
|
13034 |
|
13035 |
|
13036 |
|
13037 |
|
13038 |
|
13039 |
|
13040 |
|
13041 |
|
13042 |
|
13043 |
|
13044 |
|
13045 |
|
13046 |
|
13047 |
|
13048 |
|
13049 |
|
13050 |
|
13051 |
|
13052 |
|
13053 |
|
13054 |
|
13055 |
|
13056 |
|
13057 |
|
13058 |
|
13059 |
|
13060 |
|
13061 |
|
13062 |
|
13063 |
|
13064 |
|
13065 |
|
13066 |
|
13067 |
|
13068 |
|
13069 |
|
13070 |
|
13071 |
|
13072 |
|
13073 |
|
13074 |
|
13075 |
|
13076 |
|
13077 | function animate$1(timings, styles = null) {
|
13078 | return { type: 4 , styles: styles, timings: timings };
|
13079 | }
|
13080 |
|
13081 |
|
13082 |
|
13083 |
|
13084 |
|
13085 |
|
13086 |
|
13087 |
|
13088 |
|
13089 |
|
13090 |
|
13091 |
|
13092 |
|
13093 |
|
13094 |
|
13095 |
|
13096 |
|
13097 |
|
13098 |
|
13099 |
|
13100 |
|
13101 |
|
13102 |
|
13103 |
|
13104 |
|
13105 |
|
13106 |
|
13107 |
|
13108 |
|
13109 |
|
13110 |
|
13111 |
|
13112 |
|
13113 | function group$1(steps) {
|
13114 | return { type: 3 , steps: steps };
|
13115 | }
|
13116 |
|
13117 |
|
13118 |
|
13119 |
|
13120 |
|
13121 |
|
13122 |
|
13123 |
|
13124 |
|
13125 |
|
13126 |
|
13127 |
|
13128 |
|
13129 |
|
13130 |
|
13131 |
|
13132 |
|
13133 |
|
13134 |
|
13135 |
|
13136 |
|
13137 |
|
13138 |
|
13139 |
|
13140 |
|
13141 |
|
13142 |
|
13143 |
|
13144 |
|
13145 |
|
13146 |
|
13147 |
|
13148 |
|
13149 |
|
13150 |
|
13151 |
|
13152 | function sequence$1(steps) {
|
13153 | return { type: 2 , steps: steps };
|
13154 | }
|
13155 |
|
13156 |
|
13157 |
|
13158 |
|
13159 |
|
13160 |
|
13161 |
|
13162 |
|
13163 |
|
13164 |
|
13165 |
|
13166 |
|
13167 |
|
13168 |
|
13169 |
|
13170 |
|
13171 |
|
13172 |
|
13173 |
|
13174 |
|
13175 |
|
13176 |
|
13177 |
|
13178 |
|
13179 |
|
13180 |
|
13181 |
|
13182 |
|
13183 |
|
13184 |
|
13185 |
|
13186 |
|
13187 |
|
13188 |
|
13189 |
|
13190 |
|
13191 |
|
13192 |
|
13193 |
|
13194 |
|
13195 |
|
13196 |
|
13197 |
|
13198 |
|
13199 | function style$1(tokens) {
|
13200 | return { type: 6 , styles: tokens };
|
13201 | }
|
13202 |
|
13203 |
|
13204 |
|
13205 |
|
13206 |
|
13207 |
|
13208 |
|
13209 |
|
13210 |
|
13211 |
|
13212 |
|
13213 |
|
13214 |
|
13215 |
|
13216 |
|
13217 |
|
13218 |
|
13219 |
|
13220 |
|
13221 |
|
13222 |
|
13223 |
|
13224 |
|
13225 |
|
13226 |
|
13227 |
|
13228 |
|
13229 |
|
13230 |
|
13231 |
|
13232 |
|
13233 |
|
13234 |
|
13235 |
|
13236 |
|
13237 |
|
13238 |
|
13239 |
|
13240 |
|
13241 |
|
13242 |
|
13243 |
|
13244 |
|
13245 |
|
13246 |
|
13247 |
|
13248 |
|
13249 |
|
13250 |
|
13251 |
|
13252 |
|
13253 | function state$1(name, styles) {
|
13254 | return { type: 0 , name: name, styles: styles };
|
13255 | }
|
13256 |
|
13257 |
|
13258 |
|
13259 |
|
13260 |
|
13261 |
|
13262 |
|
13263 |
|
13264 |
|
13265 |
|
13266 |
|
13267 |
|
13268 |
|
13269 |
|
13270 |
|
13271 |
|
13272 |
|
13273 |
|
13274 |
|
13275 |
|
13276 |
|
13277 |
|
13278 |
|
13279 |
|
13280 |
|
13281 |
|
13282 |
|
13283 |
|
13284 |
|
13285 |
|
13286 |
|
13287 |
|
13288 |
|
13289 |
|
13290 |
|
13291 |
|
13292 |
|
13293 |
|
13294 |
|
13295 |
|
13296 |
|
13297 |
|
13298 |
|
13299 |
|
13300 |
|
13301 |
|
13302 |
|
13303 | function keyframes$1(steps) {
|
13304 | return { type: 5 , steps: steps };
|
13305 | }
|
13306 |
|
13307 |
|
13308 |
|
13309 |
|
13310 |
|
13311 |
|
13312 |
|
13313 |
|
13314 |
|
13315 |
|
13316 |
|
13317 |
|
13318 |
|
13319 |
|
13320 |
|
13321 |
|
13322 |
|
13323 |
|
13324 |
|
13325 |
|
13326 |
|
13327 |
|
13328 |
|
13329 |
|
13330 |
|
13331 |
|
13332 |
|
13333 |
|
13334 |
|
13335 |
|
13336 |
|
13337 |
|
13338 |
|
13339 |
|
13340 |
|
13341 |
|
13342 |
|
13343 |
|
13344 |
|
13345 |
|
13346 |
|
13347 |
|
13348 |
|
13349 |
|
13350 |
|
13351 |
|
13352 |
|
13353 |
|
13354 |
|
13355 |
|
13356 |
|
13357 |
|
13358 |
|
13359 |
|
13360 |
|
13361 |
|
13362 |
|
13363 |
|
13364 |
|
13365 |
|
13366 |
|
13367 |
|
13368 |
|
13369 |
|
13370 |
|
13371 |
|
13372 |
|
13373 |
|
13374 |
|
13375 |
|
13376 |
|
13377 |
|
13378 |
|
13379 |
|
13380 |
|
13381 |
|
13382 |
|
13383 |
|
13384 |
|
13385 |
|
13386 |
|
13387 |
|
13388 |
|
13389 |
|
13390 |
|
13391 |
|
13392 |
|
13393 |
|
13394 |
|
13395 |
|
13396 |
|
13397 |
|
13398 |
|
13399 |
|
13400 |
|
13401 |
|
13402 |
|
13403 |
|
13404 |
|
13405 |
|
13406 |
|
13407 |
|
13408 |
|
13409 |
|
13410 |
|
13411 |
|
13412 |
|
13413 |
|
13414 |
|
13415 |
|
13416 | function transition$1(stateChangeExpr, steps) {
|
13417 | return { type: 1 , expr: stateChangeExpr, animation: steps };
|
13418 | }
|
13419 |
|
13420 |
|
13421 |
|
13422 |
|
13423 |
|
13424 |
|
13425 |
|
13426 |
|
13427 |
|
13428 |
|
13429 |
|
13430 | const AUTO_STYLE$$1 = '*';
|
13431 |
|
13432 |
|
13433 |
|
13434 |
|
13435 |
|
13436 |
|
13437 | function trigger$$1(name, definitions) {
|
13438 | return trigger$1(name, definitions);
|
13439 | }
|
13440 |
|
13441 |
|
13442 |
|
13443 |
|
13444 |
|
13445 |
|
13446 | function animate$$1(timings, styles) {
|
13447 | return animate$1(timings, styles);
|
13448 | }
|
13449 |
|
13450 |
|
13451 |
|
13452 |
|
13453 |
|
13454 | function group$$1(steps) {
|
13455 | return group$1(steps);
|
13456 | }
|
13457 |
|
13458 |
|
13459 |
|
13460 |
|
13461 |
|
13462 | function sequence$$1(steps) {
|
13463 | return sequence$1(steps);
|
13464 | }
|
13465 |
|
13466 |
|
13467 |
|
13468 |
|
13469 |
|
13470 | function style$$1(tokens) {
|
13471 | return style$1(tokens);
|
13472 | }
|
13473 |
|
13474 |
|
13475 |
|
13476 |
|
13477 |
|
13478 |
|
13479 | function state$$1(name, styles) {
|
13480 | return state$1(name, styles);
|
13481 | }
|
13482 |
|
13483 |
|
13484 |
|
13485 |
|
13486 |
|
13487 | function keyframes$$1(steps) {
|
13488 | return keyframes$1(steps);
|
13489 | }
|
13490 |
|
13491 |
|
13492 |
|
13493 |
|
13494 |
|
13495 |
|
13496 | function transition$$1(stateChangeExpr, steps) {
|
13497 | return transition$1(stateChangeExpr, steps);
|
13498 | }
|
13499 |
|
13500 |
|
13501 |
|
13502 |
|
13503 |
|
13504 |
|
13505 |
|
13506 |
|
13507 |
|
13508 |
|
13509 |
|
13510 |
|
13511 |
|
13512 |
|
13513 |
|
13514 |
|
13515 |
|
13516 |
|
13517 |
|
13518 |
|
13519 |
|
13520 |
|
13521 |
|
13522 |
|
13523 |
|
13524 |
|
13525 |
|
13526 |
|
13527 |
|
13528 |
|
13529 |
|
13530 |
|
13531 |
|
13532 | export { Class, createPlatform, assertPlatform, destroyPlatform, getPlatform, PlatformRef, ApplicationRef, enableProdMode, isDevMode, createPlatformFactory, NgProbeToken, APP_ID, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER, PLATFORM_ID, APP_BOOTSTRAP_LISTENER, APP_INITIALIZER, ApplicationInitStatus, DebugElement, DebugNode, asNativeElements, getDebugNode, Testability, TestabilityRegistry, setTestabilityGetter, TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID, MissingTranslationStrategy, ApplicationModule, wtfCreateScope, wtfLeave, wtfStartTimeRange, wtfEndTimeRange, Type, EventEmitter, ErrorHandler, Sanitizer, SecurityContext, ANALYZE_FOR_ENTRY_COMPONENTS, Attribute, ContentChild, ContentChildren, Query, ViewChild, ViewChildren, Component, Directive, HostBinding, HostListener, Input, Output, Pipe, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule, ViewEncapsulation, Version, VERSION, forwardRef, resolveForwardRef, Injector, ReflectiveInjector, ResolvedReflectiveFactory, ReflectiveKey, InjectionToken, OpaqueToken, Inject, Optional, Injectable, Self, SkipSelf, Host, NgZone, RenderComponentType, Renderer, Renderer2, RendererFactory2, RendererStyleFlags2, RootRenderer, COMPILER_OPTIONS, Compiler, CompilerFactory, ModuleWithComponentFactories, ComponentFactory, ComponentRef, ComponentFactoryResolver, ElementRef, NgModuleFactory, NgModuleRef, NgModuleFactoryLoader, getModuleFactory, QueryList, SystemJsNgModuleLoader, SystemJsNgModuleLoaderConfig, TemplateRef, ViewContainerRef, EmbeddedViewRef, ViewRef, ChangeDetectionStrategy, ChangeDetectorRef, DefaultIterableDiffer, IterableDiffers, KeyValueDiffers, SimpleChange, WrappedValue, platformCore, ALLOW_MULTIPLE_PLATFORMS as ɵALLOW_MULTIPLE_PLATFORMS, APP_ID_RANDOM_PROVIDER as ɵAPP_ID_RANDOM_PROVIDER, ValueUnwrapper as ɵValueUnwrapper, devModeEqual as ɵdevModeEqual, isListLikeIterable as ɵisListLikeIterable, ChangeDetectorStatus as ɵChangeDetectorStatus, isDefaultChangeDetectionStrategy as ɵisDefaultChangeDetectionStrategy, Console as ɵConsole, ERROR_COMPONENT_TYPE as ɵERROR_COMPONENT_TYPE, ComponentFactory as ɵComponentFactory, CodegenComponentFactoryResolver as ɵCodegenComponentFactoryResolver, LIFECYCLE_HOOKS_VALUES as ɵLIFECYCLE_HOOKS_VALUES, LifecycleHooks as ɵLifecycleHooks, ViewMetadata as ɵViewMetadata, Reflector as ɵReflector, reflector as ɵreflector, ReflectionCapabilities as ɵReflectionCapabilities, ReflectorReader as ɵReflectorReader, RenderDebugInfo as ɵRenderDebugInfo, _global as ɵglobal, looseIdentical as ɵlooseIdentical, stringify as ɵstringify, makeDecorator as ɵmakeDecorator, isObservable as ɵisObservable, isPromise as ɵisPromise, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, NgModuleInjector as ɵNgModuleInjector, registerModuleFactory as ɵregisterModuleFactory, EMPTY_ARRAY as ɵEMPTY_ARRAY, EMPTY_MAP as ɵEMPTY_MAP, anchorDef as ɵand, createComponentFactory as ɵccf, createRendererType2 as ɵcrt, directiveDef as ɵdid, elementDef as ɵeld, elementEventFullName as ɵelementEventFullName, getComponentViewDefinitionFactory as ɵgetComponentViewDefinitionFactory, inlineInterpolate as ɵinlineInterpolate, interpolate as ɵinterpolate, ngContentDef as ɵncd, nodeValue as ɵnov, pipeDef as ɵpid, providerDef as ɵprd, pureArrayDef as ɵpad, pureObjectDef as ɵpod, purePipeDef as ɵppd, queryDef as ɵqud, textDef as ɵted, unwrapValue as ɵunv, viewDef as ɵvid, AUTO_STYLE$$1 as AUTO_STYLE, trigger$$1 as trigger, animate$$1 as animate, group$$1 as group, sequence$$1 as sequence, style$$1 as style, state$$1 as state, keyframes$$1 as keyframes, transition$$1 as transition, animate$1 as ɵba, group$1 as ɵbb, keyframes$1 as ɵbf, sequence$1 as ɵbc, state$1 as ɵbe, style$1 as ɵbd, transition$1 as ɵbg, trigger$1 as ɵz, _initViewEngine as ɵo, _iterableDiffersFactory as ɵl, _keyValueDiffersFactory as ɵm, _localeFactory as ɵn, ApplicationRef_ as ɵf, _appIdRandomProviderFactory as ɵg, defaultIterableDiffers as ɵh, defaultKeyValueDiffers as ɵi, DefaultIterableDifferFactory as ɵj, DefaultKeyValueDifferFactory as ɵk, ReflectiveInjector_ as ɵc, ReflectiveDependency as ɵd, resolveReflectiveProviders as ɵe, wtfEnabled as ɵp, createScope$1 as ɵr, detectWTF as ɵq, endTimeRange as ɵu, leave as ɵs, startTimeRange as ɵt, makeParamDecorator as ɵa, makePropDecorator as ɵb, _def as ɵw, DebugContext as ɵx };
|
13533 |
|