1
|
/**
|
2
|
* @license Angular v4.4.6
|
3
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
4
|
* License: MIT
|
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
|
* Creates a token that can be used in a DI Provider.
|
13
|
*
|
14
|
* ### Example ([live demo](http://plnkr.co/edit/Ys9ezXpj2Mnoy3Uc8KBp?p=preview))
|
15
|
*
|
16
|
* ```typescript
|
17
|
* var t = new OpaqueToken("value");
|
18
|
*
|
19
|
* var injector = Injector.resolveAndCreate([
|
20
|
* {provide: t, useValue: "bindingValue"}
|
21
|
* ]);
|
22
|
*
|
23
|
* expect(injector.get(t)).toEqual("bindingValue");
|
24
|
* ```
|
25
|
*
|
26
|
* Using an `OpaqueToken` is preferable to using strings as tokens because of possible collisions
|
27
|
* caused by multiple providers using the same string as two different tokens.
|
28
|
*
|
29
|
* Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better
|
30
|
* error messages.
|
31
|
* @deprecated since v4.0.0 because it does not support type information, use `InjectionToken<?>`
|
32
|
* instead.
|
33
|
*/
|
34
|
class OpaqueToken {
|
35
|
/**
|
36
|
* @param {?} _desc
|
37
|
*/
|
38
|
constructor(_desc) {
|
39
|
this._desc = _desc;
|
40
|
}
|
41
|
/**
|
42
|
* @return {?}
|
43
|
*/
|
44
|
toString() { return `Token ${this._desc}`; }
|
45
|
}
|
46
|
/**
|
47
|
* Creates a token that can be used in a DI Provider.
|
48
|
*
|
49
|
* Use an `InjectionToken` whenever the type you are injecting is not reified (does not have a
|
50
|
* runtime representation) such as when injecting an interface, callable type, array or
|
51
|
* parametrized type.
|
52
|
*
|
53
|
* `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
|
54
|
* the `Injector`. This provides additional level of type safety.
|
55
|
*
|
56
|
* ```
|
57
|
* interface MyInterface {...}
|
58
|
* var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
|
59
|
* // myInterface is inferred to be MyInterface.
|
60
|
* ```
|
61
|
*
|
62
|
* ### Example
|
63
|
*
|
64
|
* {\@example core/di/ts/injector_spec.ts region='InjectionToken'}
|
65
|
*
|
66
|
* \@stable
|
67
|
*/
|
68
|
class InjectionToken extends OpaqueToken {
|
69
|
/**
|
70
|
* @param {?} desc
|
71
|
*/
|
72
|
constructor(desc) { super(desc); }
|
73
|
/**
|
74
|
* @return {?}
|
75
|
*/
|
76
|
toString() { return `InjectionToken ${this._desc}`; }
|
77
|
}
|
78
|
|
79
|
/**
|
80
|
* @license
|
81
|
* Copyright Google Inc. All Rights Reserved.
|
82
|
*
|
83
|
* Use of this source code is governed by an MIT-style license that can be
|
84
|
* found in the LICENSE file at https://angular.io/license
|
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
|
* @return {?}
|
94
|
*/
|
95
|
function getSymbolIterator() {
|
96
|
if (!_symbolIterator) {
|
97
|
const /** @type {?} */ Symbol = _global['Symbol'];
|
98
|
if (Symbol && Symbol.iterator) {
|
99
|
_symbolIterator = Symbol.iterator;
|
100
|
}
|
101
|
else {
|
102
|
// es6-shim specific logic
|
103
|
const /** @type {?} */ keys = Object.getOwnPropertyNames(Map.prototype);
|
104
|
for (let /** @type {?} */ i = 0; i < keys.length; ++i) {
|
105
|
const /** @type {?} */ 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
|
* @param {?} fn
|
117
|
* @return {?}
|
118
|
*/
|
119
|
function scheduleMicroTask(fn) {
|
120
|
Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
|
121
|
}
|
122
|
/**
|
123
|
* @param {?} a
|
124
|
* @param {?} b
|
125
|
* @return {?}
|
126
|
*/
|
127
|
function looseIdentical(a, b) {
|
128
|
return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
|
129
|
}
|
130
|
/**
|
131
|
* @param {?} token
|
132
|
* @return {?}
|
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 /** @type {?} */ res = token.toString();
|
148
|
if (res == null) {
|
149
|
return '' + res;
|
150
|
}
|
151
|
const /** @type {?} */ newLineIndex = res.indexOf('\n');
|
152
|
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
153
|
}
|
154
|
|
155
|
/**
|
156
|
* @license
|
157
|
* Copyright Google Inc. All Rights Reserved.
|
158
|
*
|
159
|
* Use of this source code is governed by an MIT-style license that can be
|
160
|
* found in the LICENSE file at https://angular.io/license
|
161
|
*/
|
162
|
let _nextClassId = 0;
|
163
|
const Reflect = _global['Reflect'];
|
164
|
/**
|
165
|
* @param {?} annotation
|
166
|
* @return {?}
|
167
|
*/
|
168
|
function extractAnnotation(annotation) {
|
169
|
if (typeof annotation === 'function' && annotation.hasOwnProperty('annotation')) {
|
170
|
// it is a decorator, extract annotation
|
171
|
annotation = annotation.annotation;
|
172
|
}
|
173
|
return annotation;
|
174
|
}
|
175
|
/**
|
176
|
* @param {?} fnOrArray
|
177
|
* @param {?} key
|
178
|
* @return {?}
|
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 /** @type {?} */ annotations = (fnOrArray);
|
190
|
const /** @type {?} */ annoLength = annotations.length - 1;
|
191
|
const /** @type {?} */ 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 /** @type {?} */ paramsAnnotations = [];
|
199
|
for (let /** @type {?} */ i = 0, /** @type {?} */ ii = annotations.length - 1; i < ii; i++) {
|
200
|
const /** @type {?} */ paramAnnotations = [];
|
201
|
paramsAnnotations.push(paramAnnotations);
|
202
|
const /** @type {?} */ annotation = annotations[i];
|
203
|
if (Array.isArray(annotation)) {
|
204
|
for (let /** @type {?} */ 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
|
* Provides a way for expressing ES6 classes with parameter annotations in ES5.
|
222
|
*
|
223
|
* ## Basic Example
|
224
|
*
|
225
|
* ```
|
226
|
* var Greeter = ng.Class({
|
227
|
* constructor: function(name) {
|
228
|
* this.name = name;
|
229
|
* },
|
230
|
*
|
231
|
* greet: function() {
|
232
|
* alert('Hello ' + this.name + '!');
|
233
|
* }
|
234
|
* });
|
235
|
* ```
|
236
|
*
|
237
|
* is equivalent to ES6:
|
238
|
*
|
239
|
* ```
|
240
|
* class Greeter {
|
241
|
* constructor(name) {
|
242
|
* this.name = name;
|
243
|
* }
|
244
|
*
|
245
|
* greet() {
|
246
|
* alert('Hello ' + this.name + '!');
|
247
|
* }
|
248
|
* }
|
249
|
* ```
|
250
|
*
|
251
|
* or equivalent to ES5:
|
252
|
*
|
253
|
* ```
|
254
|
* var Greeter = function (name) {
|
255
|
* this.name = name;
|
256
|
* }
|
257
|
*
|
258
|
* Greeter.prototype.greet = function () {
|
259
|
* alert('Hello ' + this.name + '!');
|
260
|
* }
|
261
|
* ```
|
262
|
*
|
263
|
* ### Example with parameter annotations
|
264
|
*
|
265
|
* ```
|
266
|
* var MyService = ng.Class({
|
267
|
* constructor: [String, [new Optional(), Service], function(name, myService) {
|
268
|
* ...
|
269
|
* }]
|
270
|
* });
|
271
|
* ```
|
272
|
*
|
273
|
* is equivalent to ES6:
|
274
|
*
|
275
|
* ```
|
276
|
* class MyService {
|
277
|
* constructor(name: string, \@Optional() myService: Service) {
|
278
|
* ...
|
279
|
* }
|
280
|
* }
|
281
|
* ```
|
282
|
*
|
283
|
* ### Example with inheritance
|
284
|
*
|
285
|
* ```
|
286
|
* var Shape = ng.Class({
|
287
|
* constructor: (color) {
|
288
|
* this.color = color;
|
289
|
* }
|
290
|
* });
|
291
|
*
|
292
|
* var Square = ng.Class({
|
293
|
* extends: Shape,
|
294
|
* constructor: function(color, size) {
|
295
|
* Shape.call(this, color);
|
296
|
* this.size = size;
|
297
|
* }
|
298
|
* });
|
299
|
* ```
|
300
|
* @suppress {globalThis}
|
301
|
* \@stable
|
302
|
* @param {?} clsDef
|
303
|
* @return {?}
|
304
|
*/
|
305
|
function Class(clsDef) {
|
306
|
const /** @type {?} */ 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 /** @type {?} */ 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
|
if (props) {
|
382
|
const /** @type {?} */ values = props(...args);
|
383
|
for (const /** @type {?} */ propName in values) {
|
384
|
this[propName] = values[propName];
|
385
|
}
|
386
|
}
|
387
|
};
|
388
|
}
|
389
|
/**
|
390
|
* @param {?} name
|
391
|
* @param {?=} props
|
392
|
* @param {?=} parentClass
|
393
|
* @return {?}
|
394
|
*/
|
395
|
function makeParamDecorator(name, props, parentClass) {
|
396
|
const /** @type {?} */ metaCtor = makeMetadataCtor(props);
|
397
|
/**
|
398
|
* @param {...?} args
|
399
|
* @return {?}
|
400
|
*/
|
401
|
function ParamDecoratorFactory(...args) {
|
402
|
if (this instanceof ParamDecoratorFactory) {
|
403
|
metaCtor.apply(this, args);
|
404
|
return this;
|
405
|
}
|
406
|
const /** @type {?} */ annotationInstance = new ((ParamDecoratorFactory))(...args);
|
407
|
((ParamDecorator)).annotation = annotationInstance;
|
408
|
return ParamDecorator;
|
409
|
/**
|
410
|
* @param {?} cls
|
411
|
* @param {?} unusedKey
|
412
|
* @param {?} index
|
413
|
* @return {?}
|
414
|
*/
|
415
|
function ParamDecorator(cls, unusedKey, index) {
|
416
|
const /** @type {?} */ parameters = Reflect.getOwnMetadata('parameters', cls) || [];
|
417
|
// there might be gaps if some in between parameters do not have annotations.
|
418
|
// we pad with nulls.
|
419
|
while (parameters.length <= index) {
|
420
|
parameters.push(null);
|
421
|
}
|
422
|
parameters[index] = parameters[index] || []; /** @type {?} */
|
423
|
((parameters[index])).push(annotationInstance);
|
424
|
Reflect.defineMetadata('parameters', parameters, cls);
|
425
|
return cls;
|
426
|
}
|
427
|
}
|
428
|
if (parentClass) {
|
429
|
ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
|
430
|
}
|
431
|
ParamDecoratorFactory.prototype.toString = () => `@${name}`;
|
432
|
((ParamDecoratorFactory)).annotationCls = ParamDecoratorFactory;
|
433
|
return ParamDecoratorFactory;
|
434
|
}
|
435
|
/**
|
436
|
* @param {?} name
|
437
|
* @param {?=} props
|
438
|
* @param {?=} parentClass
|
439
|
* @return {?}
|
440
|
*/
|
441
|
function makePropDecorator(name, props, parentClass) {
|
442
|
const /** @type {?} */ metaCtor = makeMetadataCtor(props);
|
443
|
/**
|
444
|
* @param {...?} args
|
445
|
* @return {?}
|
446
|
*/
|
447
|
function PropDecoratorFactory(...args) {
|
448
|
if (this instanceof PropDecoratorFactory) {
|
449
|
metaCtor.apply(this, args);
|
450
|
return this;
|
451
|
}
|
452
|
const /** @type {?} */ decoratorInstance = new ((PropDecoratorFactory))(...args);
|
453
|
return function PropDecorator(target, name) {
|
454
|
const /** @type {?} */ meta = Reflect.getOwnMetadata('propMetadata', target.constructor) || {};
|
455
|
meta[name] = meta.hasOwnProperty(name) && meta[name] || [];
|
456
|
meta[name].unshift(decoratorInstance);
|
457
|
Reflect.defineMetadata('propMetadata', meta, target.constructor);
|
458
|
};
|
459
|
}
|
460
|
if (parentClass) {
|
461
|
PropDecoratorFactory.prototype = Object.create(parentClass.prototype);
|
462
|
}
|
463
|
PropDecoratorFactory.prototype.toString = () => `@${name}`;
|
464
|
((PropDecoratorFactory)).annotationCls = PropDecoratorFactory;
|
465
|
return PropDecoratorFactory;
|
466
|
}
|
467
|
|
468
|
/**
|
469
|
* @license
|
470
|
* Copyright Google Inc. All Rights Reserved.
|
471
|
*
|
472
|
* Use of this source code is governed by an MIT-style license that can be
|
473
|
* found in the LICENSE file at https://angular.io/license
|
474
|
*/
|
475
|
/**
|
476
|
* This token can be used to create a virtual provider that will populate the
|
477
|
* `entryComponents` fields of components and ng modules based on its `useValue`.
|
478
|
* All components that are referenced in the `useValue` value (either directly
|
479
|
* or in a nested array or map) will be added to the `entryComponents` property.
|
480
|
*
|
481
|
* ### Example
|
482
|
* The following example shows how the router can populate the `entryComponents`
|
483
|
* field of an NgModule based on the router configuration which refers
|
484
|
* to components.
|
485
|
*
|
486
|
* ```typescript
|
487
|
* // helper function inside the router
|
488
|
* function provideRoutes(routes) {
|
489
|
* return [
|
490
|
* {provide: ROUTES, useValue: routes},
|
491
|
* {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
|
492
|
* ];
|
493
|
* }
|
494
|
*
|
495
|
* // user code
|
496
|
* let routes = [
|
497
|
* {path: '/root', component: RootComp},
|
498
|
* {path: '/teams', component: TeamsComp}
|
499
|
* ];
|
500
|
*
|
501
|
* \@NgModule({
|
502
|
* providers: [provideRoutes(routes)]
|
503
|
* })
|
504
|
* class ModuleWithRoutes {}
|
505
|
* ```
|
506
|
*
|
507
|
* \@experimental
|
508
|
*/
|
509
|
const ANALYZE_FOR_ENTRY_COMPONENTS = new InjectionToken('AnalyzeForEntryComponents');
|
510
|
/**
|
511
|
* Attribute decorator and metadata.
|
512
|
*
|
513
|
* \@stable
|
514
|
* \@Annotation
|
515
|
*/
|
516
|
const Attribute = makeParamDecorator('Attribute', (attributeName) => ({ attributeName }));
|
517
|
/**
|
518
|
* Base class for query metadata.
|
519
|
*
|
520
|
* See {\@link ContentChildren}, {\@link ContentChild}, {\@link ViewChildren}, {\@link ViewChild} for
|
521
|
* more information.
|
522
|
*
|
523
|
* \@stable
|
524
|
* @abstract
|
525
|
*/
|
526
|
class Query {
|
527
|
}
|
528
|
/**
|
529
|
* ContentChildren decorator and metadata.
|
530
|
*
|
531
|
* \@stable
|
532
|
* \@Annotation
|
533
|
*/
|
534
|
const ContentChildren = makePropDecorator('ContentChildren', (selector, data = {}) => (Object.assign({ selector, first: false, isViewQuery: false, descendants: false }, data)), Query);
|
535
|
/**
|
536
|
* ContentChild decorator and metadata.
|
537
|
*
|
538
|
* \@stable
|
539
|
* \@Annotation
|
540
|
*/
|
541
|
const ContentChild = makePropDecorator('ContentChild', (selector, data = {}) => (Object.assign({ selector, first: true, isViewQuery: false, descendants: true }, data)), Query);
|
542
|
/**
|
543
|
* ViewChildren decorator and metadata.
|
544
|
*
|
545
|
* \@stable
|
546
|
* \@Annotation
|
547
|
*/
|
548
|
const ViewChildren = makePropDecorator('ViewChildren', (selector, data = {}) => (Object.assign({ selector, first: false, isViewQuery: true, descendants: true }, data)), Query);
|
549
|
/**
|
550
|
* ViewChild decorator and metadata.
|
551
|
*
|
552
|
* \@stable
|
553
|
* \@Annotation
|
554
|
*/
|
555
|
const ViewChild = makePropDecorator('ViewChild', (selector, data) => (Object.assign({ selector, first: true, isViewQuery: true, descendants: true }, data)), Query);
|
556
|
|
557
|
let ChangeDetectionStrategy = {};
|
558
|
ChangeDetectionStrategy.OnPush = 0;
|
559
|
ChangeDetectionStrategy.Default = 1;
|
560
|
ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
|
561
|
ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
|
562
|
let ChangeDetectorStatus = {};
|
563
|
ChangeDetectorStatus.CheckOnce = 0;
|
564
|
ChangeDetectorStatus.Checked = 1;
|
565
|
ChangeDetectorStatus.CheckAlways = 2;
|
566
|
ChangeDetectorStatus.Detached = 3;
|
567
|
ChangeDetectorStatus.Errored = 4;
|
568
|
ChangeDetectorStatus.Destroyed = 5;
|
569
|
ChangeDetectorStatus[ChangeDetectorStatus.CheckOnce] = "CheckOnce";
|
570
|
ChangeDetectorStatus[ChangeDetectorStatus.Checked] = "Checked";
|
571
|
ChangeDetectorStatus[ChangeDetectorStatus.CheckAlways] = "CheckAlways";
|
572
|
ChangeDetectorStatus[ChangeDetectorStatus.Detached] = "Detached";
|
573
|
ChangeDetectorStatus[ChangeDetectorStatus.Errored] = "Errored";
|
574
|
ChangeDetectorStatus[ChangeDetectorStatus.Destroyed] = "Destroyed";
|
575
|
/**
|
576
|
* @param {?} changeDetectionStrategy
|
577
|
* @return {?}
|
578
|
*/
|
579
|
function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
|
580
|
return changeDetectionStrategy == null ||
|
581
|
changeDetectionStrategy === ChangeDetectionStrategy.Default;
|
582
|
}
|
583
|
|
584
|
/**
|
585
|
* @license
|
586
|
* Copyright Google Inc. All Rights Reserved.
|
587
|
*
|
588
|
* Use of this source code is governed by an MIT-style license that can be
|
589
|
* found in the LICENSE file at https://angular.io/license
|
590
|
*/
|
591
|
/**
|
592
|
* Directive decorator and metadata.
|
593
|
*
|
594
|
* \@stable
|
595
|
* \@Annotation
|
596
|
*/
|
597
|
const Directive = makeDecorator('Directive', (dir = {}) => dir);
|
598
|
/**
|
599
|
* Component decorator and metadata.
|
600
|
*
|
601
|
* \@stable
|
602
|
* \@Annotation
|
603
|
*/
|
604
|
const Component = makeDecorator('Component', (c = {}) => (Object.assign({ changeDetection: ChangeDetectionStrategy.Default }, c)), Directive);
|
605
|
/**
|
606
|
* Pipe decorator and metadata.
|
607
|
*
|
608
|
* \@stable
|
609
|
* \@Annotation
|
610
|
*/
|
611
|
const Pipe = makeDecorator('Pipe', (p) => (Object.assign({ pure: true }, p)));
|
612
|
/**
|
613
|
* Input decorator and metadata.
|
614
|
*
|
615
|
* \@stable
|
616
|
* \@Annotation
|
617
|
*/
|
618
|
const Input = makePropDecorator('Input', (bindingPropertyName) => ({ bindingPropertyName }));
|
619
|
/**
|
620
|
* Output decorator and metadata.
|
621
|
*
|
622
|
* \@stable
|
623
|
* \@Annotation
|
624
|
*/
|
625
|
const Output = makePropDecorator('Output', (bindingPropertyName) => ({ bindingPropertyName }));
|
626
|
/**
|
627
|
* HostBinding decorator and metadata.
|
628
|
*
|
629
|
* \@stable
|
630
|
* \@Annotation
|
631
|
*/
|
632
|
const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ hostPropertyName }));
|
633
|
/**
|
634
|
* HostListener decorator and metadata.
|
635
|
*
|
636
|
* \@stable
|
637
|
* \@Annotation
|
638
|
*/
|
639
|
const HostListener = makePropDecorator('HostListener', (eventName, args) => ({ eventName, args }));
|
640
|
|
641
|
/**
|
642
|
* @license
|
643
|
* Copyright Google Inc. All Rights Reserved.
|
644
|
*
|
645
|
* Use of this source code is governed by an MIT-style license that can be
|
646
|
* found in the LICENSE file at https://angular.io/license
|
647
|
*/
|
648
|
/**
|
649
|
* Defines a schema that will allow:
|
650
|
* - any non-Angular elements with a `-` in their name,
|
651
|
* - any properties on elements with a `-` in their name which is the common rule for custom
|
652
|
* elements.
|
653
|
*
|
654
|
* \@stable
|
655
|
*/
|
656
|
const CUSTOM_ELEMENTS_SCHEMA = {
|
657
|
name: 'custom-elements'
|
658
|
};
|
659
|
/**
|
660
|
* Defines a schema that will allow any property on any element.
|
661
|
*
|
662
|
* \@experimental
|
663
|
*/
|
664
|
const NO_ERRORS_SCHEMA = {
|
665
|
name: 'no-errors-schema'
|
666
|
};
|
667
|
/**
|
668
|
* NgModule decorator and metadata.
|
669
|
*
|
670
|
* \@stable
|
671
|
* \@Annotation
|
672
|
*/
|
673
|
const NgModule = makeDecorator('NgModule', (ngModule) => ngModule);
|
674
|
|
675
|
let ViewEncapsulation = {};
|
676
|
ViewEncapsulation.Emulated = 0;
|
677
|
ViewEncapsulation.Native = 1;
|
678
|
ViewEncapsulation.None = 2;
|
679
|
ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
|
680
|
ViewEncapsulation[ViewEncapsulation.Native] = "Native";
|
681
|
ViewEncapsulation[ViewEncapsulation.None] = "None";
|
682
|
/**
|
683
|
* Metadata properties available for configuring Views.
|
684
|
*
|
685
|
* For details on the `\@Component` annotation, see {\@link Component}.
|
686
|
*
|
687
|
* ### Example
|
688
|
*
|
689
|
* ```
|
690
|
* \@Component({
|
691
|
* selector: 'greet',
|
692
|
* template: 'Hello {{name}}!',
|
693
|
* })
|
694
|
* class Greet {
|
695
|
* name: string;
|
696
|
*
|
697
|
* constructor() {
|
698
|
* this.name = 'World';
|
699
|
* }
|
700
|
* }
|
701
|
* ```
|
702
|
*
|
703
|
* @deprecated Use Component instead.
|
704
|
*
|
705
|
* {\@link Component}
|
706
|
*/
|
707
|
class ViewMetadata {
|
708
|
/**
|
709
|
* @param {?=} opts
|
710
|
*/
|
711
|
constructor(opts = {}) {
|
712
|
this.templateUrl = opts.templateUrl;
|
713
|
this.template = opts.template;
|
714
|
this.styleUrls = opts.styleUrls;
|
715
|
this.styles = opts.styles;
|
716
|
this.encapsulation = opts.encapsulation;
|
717
|
this.animations = opts.animations;
|
718
|
this.interpolation = opts.interpolation;
|
719
|
}
|
720
|
}
|
721
|
|
722
|
/**
|
723
|
* @license
|
724
|
* Copyright Google Inc. All Rights Reserved.
|
725
|
*
|
726
|
* Use of this source code is governed by an MIT-style license that can be
|
727
|
* found in the LICENSE file at https://angular.io/license
|
728
|
*/
|
729
|
|
730
|
/**
|
731
|
* \@whatItDoes Represents the version of Angular
|
732
|
*
|
733
|
* \@stable
|
734
|
*/
|
735
|
class Version {
|
736
|
/**
|
737
|
* @param {?} full
|
738
|
*/
|
739
|
constructor(full) {
|
740
|
this.full = full;
|
741
|
}
|
742
|
/**
|
743
|
* @return {?}
|
744
|
*/
|
745
|
get major() { return this.full.split('.')[0]; }
|
746
|
/**
|
747
|
* @return {?}
|
748
|
*/
|
749
|
get minor() { return this.full.split('.')[1]; }
|
750
|
/**
|
751
|
* @return {?}
|
752
|
*/
|
753
|
get patch() { return this.full.split('.').slice(2).join('.'); }
|
754
|
}
|
755
|
/**
|
756
|
* \@stable
|
757
|
*/
|
758
|
const VERSION = new Version('4.4.6');
|
759
|
|
760
|
/**
|
761
|
* @license
|
762
|
* Copyright Google Inc. All Rights Reserved.
|
763
|
*
|
764
|
* Use of this source code is governed by an MIT-style license that can be
|
765
|
* found in the LICENSE file at https://angular.io/license
|
766
|
*/
|
767
|
/**
|
768
|
* Inject decorator and metadata.
|
769
|
*
|
770
|
* \@stable
|
771
|
* \@Annotation
|
772
|
*/
|
773
|
const Inject = makeParamDecorator('Inject', (token) => ({ token }));
|
774
|
/**
|
775
|
* Optional decorator and metadata.
|
776
|
*
|
777
|
* \@stable
|
778
|
* \@Annotation
|
779
|
*/
|
780
|
const Optional = makeParamDecorator('Optional');
|
781
|
/**
|
782
|
* Injectable decorator and metadata.
|
783
|
*
|
784
|
* \@stable
|
785
|
* \@Annotation
|
786
|
*/
|
787
|
const Injectable = makeDecorator('Injectable');
|
788
|
/**
|
789
|
* Self decorator and metadata.
|
790
|
*
|
791
|
* \@stable
|
792
|
* \@Annotation
|
793
|
*/
|
794
|
const Self = makeParamDecorator('Self');
|
795
|
/**
|
796
|
* SkipSelf decorator and metadata.
|
797
|
*
|
798
|
* \@stable
|
799
|
* \@Annotation
|
800
|
*/
|
801
|
const SkipSelf = makeParamDecorator('SkipSelf');
|
802
|
/**
|
803
|
* Host decorator and metadata.
|
804
|
*
|
805
|
* \@stable
|
806
|
* \@Annotation
|
807
|
*/
|
808
|
const Host = makeParamDecorator('Host');
|
809
|
|
810
|
/**
|
811
|
* @license
|
812
|
* Copyright Google Inc. All Rights Reserved.
|
813
|
*
|
814
|
* Use of this source code is governed by an MIT-style license that can be
|
815
|
* found in the LICENSE file at https://angular.io/license
|
816
|
*/
|
817
|
/**
|
818
|
* Allows to refer to references which are not yet defined.
|
819
|
*
|
820
|
* For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
|
821
|
* DI is declared,
|
822
|
* but not yet defined. It is also used when the `token` which we use when creating a query is not
|
823
|
* yet defined.
|
824
|
*
|
825
|
* ### Example
|
826
|
* {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
|
827
|
* \@experimental
|
828
|
* @param {?} forwardRefFn
|
829
|
* @return {?}
|
830
|
*/
|
831
|
function forwardRef(forwardRefFn) {
|
832
|
((forwardRefFn)).__forward_ref__ = forwardRef;
|
833
|
((forwardRefFn)).toString = function () { return stringify(this()); };
|
834
|
return (((forwardRefFn)));
|
835
|
}
|
836
|
/**
|
837
|
* Lazily retrieves the reference value from a forwardRef.
|
838
|
*
|
839
|
* Acts as the identity function when given a non-forward-ref value.
|
840
|
*
|
841
|
* ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
|
842
|
*
|
843
|
* {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
|
844
|
*
|
845
|
* See: {\@link forwardRef}
|
846
|
* \@experimental
|
847
|
* @param {?} type
|
848
|
* @return {?}
|
849
|
*/
|
850
|
function resolveForwardRef(type) {
|
851
|
if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') &&
|
852
|
type.__forward_ref__ === forwardRef) {
|
853
|
return ((type))();
|
854
|
}
|
855
|
else {
|
856
|
return type;
|
857
|
}
|
858
|
}
|
859
|
|
860
|
/**
|
861
|
* @license
|
862
|
* Copyright Google Inc. All Rights Reserved.
|
863
|
*
|
864
|
* Use of this source code is governed by an MIT-style license that can be
|
865
|
* found in the LICENSE file at https://angular.io/license
|
866
|
*/
|
867
|
const _THROW_IF_NOT_FOUND = new Object();
|
868
|
const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
869
|
class _NullInjector {
|
870
|
/**
|
871
|
* @param {?} token
|
872
|
* @param {?=} notFoundValue
|
873
|
* @return {?}
|
874
|
*/
|
875
|
get(token, notFoundValue = _THROW_IF_NOT_FOUND) {
|
876
|
if (notFoundValue === _THROW_IF_NOT_FOUND) {
|
877
|
throw new Error(`No provider for ${stringify(token)}!`);
|
878
|
}
|
879
|
return notFoundValue;
|
880
|
}
|
881
|
}
|
882
|
/**
|
883
|
* \@whatItDoes Injector interface
|
884
|
* \@howToUse
|
885
|
* ```
|
886
|
* const injector: Injector = ...;
|
887
|
* injector.get(...);
|
888
|
* ```
|
889
|
*
|
890
|
* \@description
|
891
|
* For more details, see the {\@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
|
892
|
*
|
893
|
* ### Example
|
894
|
*
|
895
|
* {\@example core/di/ts/injector_spec.ts region='Injector'}
|
896
|
*
|
897
|
* `Injector` returns itself when given `Injector` as a token:
|
898
|
* {\@example core/di/ts/injector_spec.ts region='injectInjector'}
|
899
|
*
|
900
|
* \@stable
|
901
|
* @abstract
|
902
|
*/
|
903
|
class Injector {
|
904
|
/**
|
905
|
* Retrieves an instance from the injector based on the provided token.
|
906
|
* If not found:
|
907
|
* - Throws an error if no `notFoundValue` that is not equal to
|
908
|
* Injector.THROW_IF_NOT_FOUND is given
|
909
|
* - Returns the `notFoundValue` otherwise
|
910
|
* @abstract
|
911
|
* @template T
|
912
|
* @param {?} token
|
913
|
* @param {?=} notFoundValue
|
914
|
* @return {?}
|
915
|
*/
|
916
|
get(token, notFoundValue) { }
|
917
|
/**
|
918
|
* @deprecated from v4.0.0 use Type<T> or InjectionToken<T>
|
919
|
* @suppress {duplicate}
|
920
|
* @abstract
|
921
|
* @param {?} token
|
922
|
* @param {?=} notFoundValue
|
923
|
* @return {?}
|
924
|
*/
|
925
|
get(token, notFoundValue) { }
|
926
|
}
|
927
|
Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
928
|
Injector.NULL = new _NullInjector();
|
929
|
|
930
|
/**
|
931
|
* @license
|
932
|
* Copyright Google Inc. All Rights Reserved.
|
933
|
*
|
934
|
* Use of this source code is governed by an MIT-style license that can be
|
935
|
* found in the LICENSE file at https://angular.io/license
|
936
|
*/
|
937
|
|
938
|
const ERROR_COMPONENT_TYPE = 'ngComponentType';
|
939
|
const ERROR_DEBUG_CONTEXT = 'ngDebugContext';
|
940
|
const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
|
941
|
const ERROR_LOGGER = 'ngErrorLogger';
|
942
|
/**
|
943
|
* @param {?} error
|
944
|
* @return {?}
|
945
|
*/
|
946
|
|
947
|
/**
|
948
|
* @param {?} error
|
949
|
* @return {?}
|
950
|
*/
|
951
|
function getDebugContext(error) {
|
952
|
return ((error))[ERROR_DEBUG_CONTEXT];
|
953
|
}
|
954
|
/**
|
955
|
* @param {?} error
|
956
|
* @return {?}
|
957
|
*/
|
958
|
function getOriginalError(error) {
|
959
|
return ((error))[ERROR_ORIGINAL_ERROR];
|
960
|
}
|
961
|
/**
|
962
|
* @param {?} error
|
963
|
* @return {?}
|
964
|
*/
|
965
|
function getErrorLogger(error) {
|
966
|
return ((error))[ERROR_LOGGER] || defaultErrorLogger;
|
967
|
}
|
968
|
/**
|
969
|
* @param {?} console
|
970
|
* @param {...?} values
|
971
|
* @return {?}
|
972
|
*/
|
973
|
function defaultErrorLogger(console, ...values) {
|
974
|
((console.error))(...values);
|
975
|
}
|
976
|
|
977
|
/**
|
978
|
* @license
|
979
|
* Copyright Google Inc. All Rights Reserved.
|
980
|
*
|
981
|
* Use of this source code is governed by an MIT-style license that can be
|
982
|
* found in the LICENSE file at https://angular.io/license
|
983
|
*/
|
984
|
/**
|
985
|
* \@whatItDoes Provides a hook for centralized exception handling.
|
986
|
*
|
987
|
* \@description
|
988
|
*
|
989
|
* The default implementation of `ErrorHandler` prints error messages to the `console`. To
|
990
|
* intercept error handling, write a custom exception handler that replaces this default as
|
991
|
* appropriate for your app.
|
992
|
*
|
993
|
* ### Example
|
994
|
*
|
995
|
* ```
|
996
|
* class MyErrorHandler implements ErrorHandler {
|
997
|
* handleError(error) {
|
998
|
* // do something with the exception
|
999
|
* }
|
1000
|
* }
|
1001
|
*
|
1002
|
* \@NgModule({
|
1003
|
* providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
|
1004
|
* })
|
1005
|
* class MyModule {}
|
1006
|
* ```
|
1007
|
*
|
1008
|
* \@stable
|
1009
|
*/
|
1010
|
class ErrorHandler {
|
1011
|
/**
|
1012
|
* @param {?=} deprecatedParameter
|
1013
|
*/
|
1014
|
constructor(
|
1015
|
/**
|
1016
|
* @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never
|
1017
|
* rethrow.
|
1018
|
*/
|
1019
|
deprecatedParameter) {
|
1020
|
/**
|
1021
|
* \@internal
|
1022
|
*/
|
1023
|
this._console = console;
|
1024
|
}
|
1025
|
/**
|
1026
|
* @param {?} error
|
1027
|
* @return {?}
|
1028
|
*/
|
1029
|
handleError(error) {
|
1030
|
const /** @type {?} */ originalError = this._findOriginalError(error);
|
1031
|
const /** @type {?} */ context = this._findContext(error);
|
1032
|
// Note: Browser consoles show the place from where console.error was called.
|
1033
|
// We can use this to give users additional information about the error.
|
1034
|
const /** @type {?} */ errorLogger = getErrorLogger(error);
|
1035
|
errorLogger(this._console, `ERROR`, error);
|
1036
|
if (originalError) {
|
1037
|
errorLogger(this._console, `ORIGINAL ERROR`, originalError);
|
1038
|
}
|
1039
|
if (context) {
|
1040
|
errorLogger(this._console, 'ERROR CONTEXT', context);
|
1041
|
}
|
1042
|
}
|
1043
|
/**
|
1044
|
* \@internal
|
1045
|
* @param {?} error
|
1046
|
* @return {?}
|
1047
|
*/
|
1048
|
_findContext(error) {
|
1049
|
if (error) {
|
1050
|
return getDebugContext(error) ? getDebugContext(error) :
|
1051
|
this._findContext(getOriginalError(error));
|
1052
|
}
|
1053
|
return null;
|
1054
|
}
|
1055
|
/**
|
1056
|
* \@internal
|
1057
|
* @param {?} error
|
1058
|
* @return {?}
|
1059
|
*/
|
1060
|
_findOriginalError(error) {
|
1061
|
let /** @type {?} */ e = getOriginalError(error);
|
1062
|
while (e && getOriginalError(e)) {
|
1063
|
e = getOriginalError(e);
|
1064
|
}
|
1065
|
return e;
|
1066
|
}
|
1067
|
}
|
1068
|
/**
|
1069
|
* @param {?} message
|
1070
|
* @param {?} originalError
|
1071
|
* @return {?}
|
1072
|
*/
|
1073
|
function wrappedError(message, originalError) {
|
1074
|
const /** @type {?} */ msg = `${message} caused by: ${originalError instanceof Error ? originalError.message : originalError}`;
|
1075
|
const /** @type {?} */ error = Error(msg);
|
1076
|
((error))[ERROR_ORIGINAL_ERROR] = originalError;
|
1077
|
return error;
|
1078
|
}
|
1079
|
|
1080
|
/**
|
1081
|
* @license
|
1082
|
* Copyright Google Inc. All Rights Reserved.
|
1083
|
*
|
1084
|
* Use of this source code is governed by an MIT-style license that can be
|
1085
|
* found in the LICENSE file at https://angular.io/license
|
1086
|
*/
|
1087
|
/**
|
1088
|
* @param {?} keys
|
1089
|
* @return {?}
|
1090
|
*/
|
1091
|
function findFirstClosedCycle(keys) {
|
1092
|
const /** @type {?} */ res = [];
|
1093
|
for (let /** @type {?} */ i = 0; i < keys.length; ++i) {
|
1094
|
if (res.indexOf(keys[i]) > -1) {
|
1095
|
res.push(keys[i]);
|
1096
|
return res;
|
1097
|
}
|
1098
|
res.push(keys[i]);
|
1099
|
}
|
1100
|
return res;
|
1101
|
}
|
1102
|
/**
|
1103
|
* @param {?} keys
|
1104
|
* @return {?}
|
1105
|
*/
|
1106
|
function constructResolvingPath(keys) {
|
1107
|
if (keys.length > 1) {
|
1108
|
const /** @type {?} */ reversed = findFirstClosedCycle(keys.slice().reverse());
|
1109
|
const /** @type {?} */ tokenStrs = reversed.map(k => stringify(k.token));
|
1110
|
return ' (' + tokenStrs.join(' -> ') + ')';
|
1111
|
}
|
1112
|
return '';
|
1113
|
}
|
1114
|
/**
|
1115
|
* @param {?} injector
|
1116
|
* @param {?} key
|
1117
|
* @param {?} constructResolvingMessage
|
1118
|
* @param {?=} originalError
|
1119
|
* @return {?}
|
1120
|
*/
|
1121
|
function injectionError(injector, key, constructResolvingMessage, originalError) {
|
1122
|
const /** @type {?} */ keys = [key];
|
1123
|
const /** @type {?} */ errMsg = constructResolvingMessage(keys);
|
1124
|
const /** @type {?} */ error = ((originalError ? wrappedError(errMsg, originalError) : Error(errMsg)));
|
1125
|
error.addKey = addKey;
|
1126
|
error.keys = keys;
|
1127
|
error.injectors = [injector];
|
1128
|
error.constructResolvingMessage = constructResolvingMessage;
|
1129
|
((error))[ERROR_ORIGINAL_ERROR] = originalError;
|
1130
|
return error;
|
1131
|
}
|
1132
|
/**
|
1133
|
* @this {?}
|
1134
|
* @param {?} injector
|
1135
|
* @param {?} key
|
1136
|
* @return {?}
|
1137
|
*/
|
1138
|
function addKey(injector, key) {
|
1139
|
this.injectors.push(injector);
|
1140
|
this.keys.push(key);
|
1141
|
// Note: This updated message won't be reflected in the `.stack` property
|
1142
|
this.message = this.constructResolvingMessage(this.keys);
|
1143
|
}
|
1144
|
/**
|
1145
|
* Thrown when trying to retrieve a dependency by key from {\@link Injector}, but the
|
1146
|
* {\@link Injector} does not have a {\@link Provider} for the given key.
|
1147
|
*
|
1148
|
* ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
|
1149
|
*
|
1150
|
* ```typescript
|
1151
|
* class A {
|
1152
|
* constructor(b:B) {}
|
1153
|
* }
|
1154
|
*
|
1155
|
* expect(() => Injector.resolveAndCreate([A])).toThrowError();
|
1156
|
* ```
|
1157
|
* @param {?} injector
|
1158
|
* @param {?} key
|
1159
|
* @return {?}
|
1160
|
*/
|
1161
|
function noProviderError(injector, key) {
|
1162
|
return injectionError(injector, key, function (keys) {
|
1163
|
const /** @type {?} */ first = stringify(keys[0].token);
|
1164
|
return `No provider for ${first}!${constructResolvingPath(keys)}`;
|
1165
|
});
|
1166
|
}
|
1167
|
/**
|
1168
|
* Thrown when dependencies form a cycle.
|
1169
|
*
|
1170
|
* ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
|
1171
|
*
|
1172
|
* ```typescript
|
1173
|
* var injector = Injector.resolveAndCreate([
|
1174
|
* {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
|
1175
|
* {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
|
1176
|
* ]);
|
1177
|
*
|
1178
|
* expect(() => injector.get("one")).toThrowError();
|
1179
|
* ```
|
1180
|
*
|
1181
|
* Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
|
1182
|
* @param {?} injector
|
1183
|
* @param {?} key
|
1184
|
* @return {?}
|
1185
|
*/
|
1186
|
function cyclicDependencyError(injector, key) {
|
1187
|
return injectionError(injector, key, function (keys) {
|
1188
|
return `Cannot instantiate cyclic dependency!${constructResolvingPath(keys)}`;
|
1189
|
});
|
1190
|
}
|
1191
|
/**
|
1192
|
* Thrown when a constructing type returns with an Error.
|
1193
|
*
|
1194
|
* The `InstantiationError` class contains the original error plus the dependency graph which caused
|
1195
|
* this object to be instantiated.
|
1196
|
*
|
1197
|
* ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
|
1198
|
*
|
1199
|
* ```typescript
|
1200
|
* class A {
|
1201
|
* constructor() {
|
1202
|
* throw new Error('message');
|
1203
|
* }
|
1204
|
* }
|
1205
|
*
|
1206
|
* var injector = Injector.resolveAndCreate([A]);
|
1207
|
* try {
|
1208
|
* injector.get(A);
|
1209
|
* } catch (e) {
|
1210
|
* expect(e instanceof InstantiationError).toBe(true);
|
1211
|
* expect(e.originalException.message).toEqual("message");
|
1212
|
* expect(e.originalStack).toBeDefined();
|
1213
|
* }
|
1214
|
* ```
|
1215
|
* @param {?} injector
|
1216
|
* @param {?} originalException
|
1217
|
* @param {?} originalStack
|
1218
|
* @param {?} key
|
1219
|
* @return {?}
|
1220
|
*/
|
1221
|
function instantiationError(injector, originalException, originalStack, key) {
|
1222
|
return injectionError(injector, key, function (keys) {
|
1223
|
const /** @type {?} */ first = stringify(keys[0].token);
|
1224
|
return `${originalException.message}: Error during instantiation of ${first}!${constructResolvingPath(keys)}.`;
|
1225
|
}, originalException);
|
1226
|
}
|
1227
|
/**
|
1228
|
* Thrown when an object other then {\@link Provider} (or `Type`) is passed to {\@link Injector}
|
1229
|
* creation.
|
1230
|
*
|
1231
|
* ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
|
1232
|
*
|
1233
|
* ```typescript
|
1234
|
* expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
|
1235
|
* ```
|
1236
|
* @param {?} provider
|
1237
|
* @return {?}
|
1238
|
*/
|
1239
|
function invalidProviderError(provider) {
|
1240
|
return Error(`Invalid provider - only instances of Provider and Type are allowed, got: ${provider}`);
|
1241
|
}
|
1242
|
/**
|
1243
|
* Thrown when the class has no annotation information.
|
1244
|
*
|
1245
|
* Lack of annotation information prevents the {\@link Injector} from determining which dependencies
|
1246
|
* need to be injected into the constructor.
|
1247
|
*
|
1248
|
* ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
|
1249
|
*
|
1250
|
* ```typescript
|
1251
|
* class A {
|
1252
|
* constructor(b) {}
|
1253
|
* }
|
1254
|
*
|
1255
|
* expect(() => Injector.resolveAndCreate([A])).toThrowError();
|
1256
|
* ```
|
1257
|
*
|
1258
|
* This error is also thrown when the class not marked with {\@link Injectable} has parameter types.
|
1259
|
*
|
1260
|
* ```typescript
|
1261
|
* class B {}
|
1262
|
*
|
1263
|
* class A {
|
1264
|
* constructor(b:B) {} // no information about the parameter types of A is available at runtime.
|
1265
|
* }
|
1266
|
*
|
1267
|
* expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
|
1268
|
* ```
|
1269
|
* \@stable
|
1270
|
* @param {?} typeOrFunc
|
1271
|
* @param {?} params
|
1272
|
* @return {?}
|
1273
|
*/
|
1274
|
function noAnnotationError(typeOrFunc, params) {
|
1275
|
const /** @type {?} */ signature = [];
|
1276
|
for (let /** @type {?} */ i = 0, /** @type {?} */ ii = params.length; i < ii; i++) {
|
1277
|
const /** @type {?} */ parameter = params[i];
|
1278
|
if (!parameter || parameter.length == 0) {
|
1279
|
signature.push('?');
|
1280
|
}
|
1281
|
else {
|
1282
|
signature.push(parameter.map(stringify).join(' '));
|
1283
|
}
|
1284
|
}
|
1285
|
return Error('Cannot resolve all parameters for \'' + stringify(typeOrFunc) + '\'(' +
|
1286
|
signature.join(', ') + '). ' +
|
1287
|
'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' +
|
1288
|
stringify(typeOrFunc) + '\' is decorated with Injectable.');
|
1289
|
}
|
1290
|
/**
|
1291
|
* Thrown when getting an object by index.
|
1292
|
*
|
1293
|
* ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
|
1294
|
*
|
1295
|
* ```typescript
|
1296
|
* class A {}
|
1297
|
*
|
1298
|
* var injector = Injector.resolveAndCreate([A]);
|
1299
|
*
|
1300
|
* expect(() => injector.getAt(100)).toThrowError();
|
1301
|
* ```
|
1302
|
* \@stable
|
1303
|
* @param {?} index
|
1304
|
* @return {?}
|
1305
|
*/
|
1306
|
function outOfBoundsError(index) {
|
1307
|
return Error(`Index ${index} is out-of-bounds.`);
|
1308
|
}
|
1309
|
/**
|
1310
|
* Thrown when a multi provider and a regular provider are bound to the same token.
|
1311
|
*
|
1312
|
* ### Example
|
1313
|
*
|
1314
|
* ```typescript
|
1315
|
* expect(() => Injector.resolveAndCreate([
|
1316
|
* { provide: "Strings", useValue: "string1", multi: true},
|
1317
|
* { provide: "Strings", useValue: "string2", multi: false}
|
1318
|
* ])).toThrowError();
|
1319
|
* ```
|
1320
|
* @param {?} provider1
|
1321
|
* @param {?} provider2
|
1322
|
* @return {?}
|
1323
|
*/
|
1324
|
function mixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
|
1325
|
return Error(`Cannot mix multi providers and regular providers, got: ${provider1} ${provider2}`);
|
1326
|
}
|
1327
|
|
1328
|
/**
|
1329
|
* @license
|
1330
|
* Copyright Google Inc. All Rights Reserved.
|
1331
|
*
|
1332
|
* Use of this source code is governed by an MIT-style license that can be
|
1333
|
* found in the LICENSE file at https://angular.io/license
|
1334
|
*/
|
1335
|
/**
|
1336
|
* A unique object used for retrieving items from the {\@link ReflectiveInjector}.
|
1337
|
*
|
1338
|
* Keys have:
|
1339
|
* - a system-wide unique `id`.
|
1340
|
* - a `token`.
|
1341
|
*
|
1342
|
* `Key` is used internally by {\@link ReflectiveInjector} because its system-wide unique `id` allows
|
1343
|
* the
|
1344
|
* injector to store created objects in a more efficient way.
|
1345
|
*
|
1346
|
* `Key` should not be created directly. {\@link ReflectiveInjector} creates keys automatically when
|
1347
|
* resolving
|
1348
|
* providers.
|
1349
|
* \@experimental
|
1350
|
*/
|
1351
|
class ReflectiveKey {
|
1352
|
/**
|
1353
|
* Private
|
1354
|
* @param {?} token
|
1355
|
* @param {?} id
|
1356
|
*/
|
1357
|
constructor(token, id) {
|
1358
|
this.token = token;
|
1359
|
this.id = id;
|
1360
|
if (!token) {
|
1361
|
throw new Error('Token must be defined!');
|
1362
|
}
|
1363
|
}
|
1364
|
/**
|
1365
|
* Returns a stringified token.
|
1366
|
* @return {?}
|
1367
|
*/
|
1368
|
get displayName() { return stringify(this.token); }
|
1369
|
/**
|
1370
|
* Retrieves a `Key` for a token.
|
1371
|
* @param {?} token
|
1372
|
* @return {?}
|
1373
|
*/
|
1374
|
static get(token) {
|
1375
|
return _globalKeyRegistry.get(resolveForwardRef(token));
|
1376
|
}
|
1377
|
/**
|
1378
|
* @return {?} the number of keys registered in the system.
|
1379
|
*/
|
1380
|
static get numberOfKeys() { return _globalKeyRegistry.numberOfKeys; }
|
1381
|
}
|
1382
|
/**
|
1383
|
* \@internal
|
1384
|
*/
|
1385
|
class KeyRegistry {
|
1386
|
constructor() {
|
1387
|
this._allKeys = new Map();
|
1388
|
}
|
1389
|
/**
|
1390
|
* @param {?} token
|
1391
|
* @return {?}
|
1392
|
*/
|
1393
|
get(token) {
|
1394
|
if (token instanceof ReflectiveKey)
|
1395
|
return token;
|
1396
|
if (this._allKeys.has(token)) {
|
1397
|
return ((this._allKeys.get(token)));
|
1398
|
}
|
1399
|
const /** @type {?} */ newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
|
1400
|
this._allKeys.set(token, newKey);
|
1401
|
return newKey;
|
1402
|
}
|
1403
|
/**
|
1404
|
* @return {?}
|
1405
|
*/
|
1406
|
get numberOfKeys() { return this._allKeys.size; }
|
1407
|
}
|
1408
|
const _globalKeyRegistry = new KeyRegistry();
|
1409
|
|
1410
|
/**
|
1411
|
* \@whatItDoes Represents a type that a Component or other object is instances of.
|
1412
|
*
|
1413
|
* \@description
|
1414
|
*
|
1415
|
* An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
|
1416
|
* the `MyCustomComponent` constructor function.
|
1417
|
*
|
1418
|
* \@stable
|
1419
|
*/
|
1420
|
const Type = Function;
|
1421
|
/**
|
1422
|
* @param {?} v
|
1423
|
* @return {?}
|
1424
|
*/
|
1425
|
function isType(v) {
|
1426
|
return typeof v === 'function';
|
1427
|
}
|
1428
|
|
1429
|
/**
|
1430
|
* @license
|
1431
|
* Copyright Google Inc. All Rights Reserved.
|
1432
|
*
|
1433
|
* Use of this source code is governed by an MIT-style license that can be
|
1434
|
* found in the LICENSE file at https://angular.io/license
|
1435
|
*/
|
1436
|
/**
|
1437
|
* Attention: This regex has to hold even if the code is minified!
|
1438
|
*/
|
1439
|
const DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/;
|
1440
|
class ReflectionCapabilities {
|
1441
|
/**
|
1442
|
* @param {?=} reflect
|
1443
|
*/
|
1444
|
constructor(reflect) { this._reflect = reflect || _global['Reflect']; }
|
1445
|
/**
|
1446
|
* @return {?}
|
1447
|
*/
|
1448
|
isReflectionEnabled() { return true; }
|
1449
|
/**
|
1450
|
* @template T
|
1451
|
* @param {?} t
|
1452
|
* @return {?}
|
1453
|
*/
|
1454
|
factory(t) { return (...args) => new t(...args); }
|
1455
|
/**
|
1456
|
* \@internal
|
1457
|
* @param {?} paramTypes
|
1458
|
* @param {?} paramAnnotations
|
1459
|
* @return {?}
|
1460
|
*/
|
1461
|
_zipTypesAndAnnotations(paramTypes, paramAnnotations) {
|
1462
|
let /** @type {?} */ result;
|
1463
|
if (typeof paramTypes === 'undefined') {
|
1464
|
result = new Array(paramAnnotations.length);
|
1465
|
}
|
1466
|
else {
|
1467
|
result = new Array(paramTypes.length);
|
1468
|
}
|
1469
|
for (let /** @type {?} */ i = 0; i < result.length; i++) {
|
1470
|
// TS outputs Object for parameters without types, while Traceur omits
|
1471
|
// the annotations. For now we preserve the Traceur behavior to aid
|
1472
|
// migration, but this can be revisited.
|
1473
|
if (typeof paramTypes === 'undefined') {
|
1474
|
result[i] = [];
|
1475
|
}
|
1476
|
else if (paramTypes[i] != Object) {
|
1477
|
result[i] = [paramTypes[i]];
|
1478
|
}
|
1479
|
else {
|
1480
|
result[i] = [];
|
1481
|
}
|
1482
|
if (paramAnnotations && paramAnnotations[i] != null) {
|
1483
|
result[i] = result[i].concat(paramAnnotations[i]);
|
1484
|
}
|
1485
|
}
|
1486
|
return result;
|
1487
|
}
|
1488
|
/**
|
1489
|
* @param {?} type
|
1490
|
* @param {?} parentCtor
|
1491
|
* @return {?}
|
1492
|
*/
|
1493
|
_ownParameters(type, parentCtor) {
|
1494
|
// If we have no decorators, we only have function.length as metadata.
|
1495
|
// In that case, to detect whether a child class declared an own constructor or not,
|
1496
|
// we need to look inside of that constructor to check whether it is
|
1497
|
// just calling the parent.
|
1498
|
// This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439
|
1499
|
// that sets 'design:paramtypes' to []
|
1500
|
// if a class inherits from another class but has no ctor declared itself.
|
1501
|
if (DELEGATE_CTOR.exec(type.toString())) {
|
1502
|
return null;
|
1503
|
}
|
1504
|
// Prefer the direct API.
|
1505
|
if (((type)).parameters && ((type)).parameters !== parentCtor.parameters) {
|
1506
|
return ((type)).parameters;
|
1507
|
}
|
1508
|
// API of tsickle for lowering decorators to properties on the class.
|
1509
|
const /** @type {?} */ tsickleCtorParams = ((type)).ctorParameters;
|
1510
|
if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) {
|
1511
|
// Newer tsickle uses a function closure
|
1512
|
// Retain the non-function case for compatibility with older tsickle
|
1513
|
const /** @type {?} */ ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;
|
1514
|
const /** @type {?} */ paramTypes = ctorParameters.map((ctorParam) => ctorParam && ctorParam.type);
|
1515
|
const /** @type {?} */ paramAnnotations = ctorParameters.map((ctorParam) => ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators));
|
1516
|
return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
|
1517
|
}
|
1518
|
// API for metadata created by invoking the decorators.
|
1519
|
if (this._reflect != null && this._reflect.getOwnMetadata != null) {
|
1520
|
const /** @type {?} */ paramAnnotations = this._reflect.getOwnMetadata('parameters', type);
|
1521
|
const /** @type {?} */ paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type);
|
1522
|
if (paramTypes || paramAnnotations) {
|
1523
|
return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
|
1524
|
}
|
1525
|
}
|
1526
|
// If a class has no decorators, at least create metadata
|
1527
|
// based on function.length.
|
1528
|
// Note: We know that this is a real constructor as we checked
|
1529
|
// the content of the constructor above.
|
1530
|
return new Array(((type.length))).fill(undefined);
|
1531
|
}
|
1532
|
/**
|
1533
|
* @param {?} type
|
1534
|
* @return {?}
|
1535
|
*/
|
1536
|
parameters(type) {
|
1537
|
// Note: only report metadata if we have at least one class decorator
|
1538
|
// to stay in sync with the static reflector.
|
1539
|
if (!isType(type)) {
|
1540
|
return [];
|
1541
|
}
|
1542
|
const /** @type {?} */ parentCtor = getParentCtor(type);
|
1543
|
let /** @type {?} */ parameters = this._ownParameters(type, parentCtor);
|
1544
|
if (!parameters && parentCtor !== Object) {
|
1545
|
parameters = this.parameters(parentCtor);
|
1546
|
}
|
1547
|
return parameters || [];
|
1548
|
}
|
1549
|
/**
|
1550
|
* @param {?} typeOrFunc
|
1551
|
* @param {?} parentCtor
|
1552
|
* @return {?}
|
1553
|
*/
|
1554
|
_ownAnnotations(typeOrFunc, parentCtor) {
|
1555
|
// Prefer the direct API.
|
1556
|
if (((typeOrFunc)).annotations && ((typeOrFunc)).annotations !== parentCtor.annotations) {
|
1557
|
let /** @type {?} */ annotations = ((typeOrFunc)).annotations;
|
1558
|
if (typeof annotations === 'function' && annotations.annotations) {
|
1559
|
annotations = annotations.annotations;
|
1560
|
}
|
1561
|
return annotations;
|
1562
|
}
|
1563
|
// API of tsickle for lowering decorators to properties on the class.
|
1564
|
if (((typeOrFunc)).decorators && ((typeOrFunc)).decorators !== parentCtor.decorators) {
|
1565
|
return convertTsickleDecoratorIntoMetadata(((typeOrFunc)).decorators);
|
1566
|
}
|
1567
|
// API for metadata created by invoking the decorators.
|
1568
|
if (this._reflect && this._reflect.getOwnMetadata) {
|
1569
|
return this._reflect.getOwnMetadata('annotations', typeOrFunc);
|
1570
|
}
|
1571
|
return null;
|
1572
|
}
|
1573
|
/**
|
1574
|
* @param {?} typeOrFunc
|
1575
|
* @return {?}
|
1576
|
*/
|
1577
|
annotations(typeOrFunc) {
|
1578
|
if (!isType(typeOrFunc)) {
|
1579
|
return [];
|
1580
|
}
|
1581
|
const /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
|
1582
|
const /** @type {?} */ ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];
|
1583
|
const /** @type {?} */ parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];
|
1584
|
return parentAnnotations.concat(ownAnnotations);
|
1585
|
}
|
1586
|
/**
|
1587
|
* @param {?} typeOrFunc
|
1588
|
* @param {?} parentCtor
|
1589
|
* @return {?}
|
1590
|
*/
|
1591
|
_ownPropMetadata(typeOrFunc, parentCtor) {
|
1592
|
// Prefer the direct API.
|
1593
|
if (((typeOrFunc)).propMetadata &&
|
1594
|
((typeOrFunc)).propMetadata !== parentCtor.propMetadata) {
|
1595
|
let /** @type {?} */ propMetadata = ((typeOrFunc)).propMetadata;
|
1596
|
if (typeof propMetadata === 'function' && propMetadata.propMetadata) {
|
1597
|
propMetadata = propMetadata.propMetadata;
|
1598
|
}
|
1599
|
return propMetadata;
|
1600
|
}
|
1601
|
// API of tsickle for lowering decorators to properties on the class.
|
1602
|
if (((typeOrFunc)).propDecorators &&
|
1603
|
((typeOrFunc)).propDecorators !== parentCtor.propDecorators) {
|
1604
|
const /** @type {?} */ propDecorators = ((typeOrFunc)).propDecorators;
|
1605
|
const /** @type {?} */ propMetadata = ({});
|
1606
|
Object.keys(propDecorators).forEach(prop => {
|
1607
|
propMetadata[prop] = convertTsickleDecoratorIntoMetadata(propDecorators[prop]);
|
1608
|
});
|
1609
|
return propMetadata;
|
1610
|
}
|
1611
|
// API for metadata created by invoking the decorators.
|
1612
|
if (this._reflect && this._reflect.getOwnMetadata) {
|
1613
|
return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);
|
1614
|
}
|
1615
|
return null;
|
1616
|
}
|
1617
|
/**
|
1618
|
* @param {?} typeOrFunc
|
1619
|
* @return {?}
|
1620
|
*/
|
1621
|
propMetadata(typeOrFunc) {
|
1622
|
if (!isType(typeOrFunc)) {
|
1623
|
return {};
|
1624
|
}
|
1625
|
const /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
|
1626
|
const /** @type {?} */ propMetadata = {};
|
1627
|
if (parentCtor !== Object) {
|
1628
|
const /** @type {?} */ parentPropMetadata = this.propMetadata(parentCtor);
|
1629
|
Object.keys(parentPropMetadata).forEach((propName) => {
|
1630
|
propMetadata[propName] = parentPropMetadata[propName];
|
1631
|
});
|
1632
|
}
|
1633
|
const /** @type {?} */ ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
|
1634
|
if (ownPropMetadata) {
|
1635
|
Object.keys(ownPropMetadata).forEach((propName) => {
|
1636
|
const /** @type {?} */ decorators = [];
|
1637
|
if (propMetadata.hasOwnProperty(propName)) {
|
1638
|
decorators.push(...propMetadata[propName]);
|
1639
|
}
|
1640
|
decorators.push(...ownPropMetadata[propName]);
|
1641
|
propMetadata[propName] = decorators;
|
1642
|
});
|
1643
|
}
|
1644
|
return propMetadata;
|
1645
|
}
|
1646
|
/**
|
1647
|
* @param {?} type
|
1648
|
* @param {?} lcProperty
|
1649
|
* @return {?}
|
1650
|
*/
|
1651
|
hasLifecycleHook(type, lcProperty) {
|
1652
|
return type instanceof Type && lcProperty in type.prototype;
|
1653
|
}
|
1654
|
/**
|
1655
|
* @param {?} name
|
1656
|
* @return {?}
|
1657
|
*/
|
1658
|
getter(name) { return (new Function('o', 'return o.' + name + ';')); }
|
1659
|
/**
|
1660
|
* @param {?} name
|
1661
|
* @return {?}
|
1662
|
*/
|
1663
|
setter(name) {
|
1664
|
return (new Function('o', 'v', 'return o.' + name + ' = v;'));
|
1665
|
}
|
1666
|
/**
|
1667
|
* @param {?} name
|
1668
|
* @return {?}
|
1669
|
*/
|
1670
|
method(name) {
|
1671
|
const /** @type {?} */ functionBody = `if (!o.${name}) throw new Error('"${name}" is undefined');
|
1672
|
return o.${name}.apply(o, args);`;
|
1673
|
return (new Function('o', 'args', functionBody));
|
1674
|
}
|
1675
|
/**
|
1676
|
* @param {?} type
|
1677
|
* @return {?}
|
1678
|
*/
|
1679
|
importUri(type) {
|
1680
|
// StaticSymbol
|
1681
|
if (typeof type === 'object' && type['filePath']) {
|
1682
|
return type['filePath'];
|
1683
|
}
|
1684
|
// Runtime type
|
1685
|
return `./${stringify(type)}`;
|
1686
|
}
|
1687
|
/**
|
1688
|
* @param {?} type
|
1689
|
* @return {?}
|
1690
|
*/
|
1691
|
resourceUri(type) { return `./${stringify(type)}`; }
|
1692
|
/**
|
1693
|
* @param {?} name
|
1694
|
* @param {?} moduleUrl
|
1695
|
* @param {?} members
|
1696
|
* @param {?} runtime
|
1697
|
* @return {?}
|
1698
|
*/
|
1699
|
resolveIdentifier(name, moduleUrl, members, runtime) {
|
1700
|
return runtime;
|
1701
|
}
|
1702
|
/**
|
1703
|
* @param {?} enumIdentifier
|
1704
|
* @param {?} name
|
1705
|
* @return {?}
|
1706
|
*/
|
1707
|
resolveEnum(enumIdentifier, name) { return enumIdentifier[name]; }
|
1708
|
}
|
1709
|
/**
|
1710
|
* @param {?} decoratorInvocations
|
1711
|
* @return {?}
|
1712
|
*/
|
1713
|
function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
|
1714
|
if (!decoratorInvocations) {
|
1715
|
return [];
|
1716
|
}
|
1717
|
return decoratorInvocations.map(decoratorInvocation => {
|
1718
|
const /** @type {?} */ decoratorType = decoratorInvocation.type;
|
1719
|
const /** @type {?} */ annotationCls = decoratorType.annotationCls;
|
1720
|
const /** @type {?} */ annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
|
1721
|
return new annotationCls(...annotationArgs);
|
1722
|
});
|
1723
|
}
|
1724
|
/**
|
1725
|
* @param {?} ctor
|
1726
|
* @return {?}
|
1727
|
*/
|
1728
|
function getParentCtor(ctor) {
|
1729
|
const /** @type {?} */ parentProto = Object.getPrototypeOf(ctor.prototype);
|
1730
|
const /** @type {?} */ parentCtor = parentProto ? parentProto.constructor : null;
|
1731
|
// Note: We always use `Object` as the null value
|
1732
|
// to simplify checking later on.
|
1733
|
return parentCtor || Object;
|
1734
|
}
|
1735
|
|
1736
|
/**
|
1737
|
* @license
|
1738
|
* Copyright Google Inc. All Rights Reserved.
|
1739
|
*
|
1740
|
* Use of this source code is governed by an MIT-style license that can be
|
1741
|
* found in the LICENSE file at https://angular.io/license
|
1742
|
*/
|
1743
|
/**
|
1744
|
* Provides access to reflection data about symbols. Used internally by Angular
|
1745
|
* to power dependency injection and compilation.
|
1746
|
*/
|
1747
|
class Reflector {
|
1748
|
/**
|
1749
|
* @param {?} reflectionCapabilities
|
1750
|
*/
|
1751
|
constructor(reflectionCapabilities) {
|
1752
|
this.reflectionCapabilities = reflectionCapabilities;
|
1753
|
}
|
1754
|
/**
|
1755
|
* @param {?} caps
|
1756
|
* @return {?}
|
1757
|
*/
|
1758
|
updateCapabilities(caps) { this.reflectionCapabilities = caps; }
|
1759
|
/**
|
1760
|
* @param {?} type
|
1761
|
* @return {?}
|
1762
|
*/
|
1763
|
factory(type) { return this.reflectionCapabilities.factory(type); }
|
1764
|
/**
|
1765
|
* @param {?} typeOrFunc
|
1766
|
* @return {?}
|
1767
|
*/
|
1768
|
parameters(typeOrFunc) {
|
1769
|
return this.reflectionCapabilities.parameters(typeOrFunc);
|
1770
|
}
|
1771
|
/**
|
1772
|
* @param {?} typeOrFunc
|
1773
|
* @return {?}
|
1774
|
*/
|
1775
|
annotations(typeOrFunc) {
|
1776
|
return this.reflectionCapabilities.annotations(typeOrFunc);
|
1777
|
}
|
1778
|
/**
|
1779
|
* @param {?} typeOrFunc
|
1780
|
* @return {?}
|
1781
|
*/
|
1782
|
propMetadata(typeOrFunc) {
|
1783
|
return this.reflectionCapabilities.propMetadata(typeOrFunc);
|
1784
|
}
|
1785
|
/**
|
1786
|
* @param {?} type
|
1787
|
* @param {?} lcProperty
|
1788
|
* @return {?}
|
1789
|
*/
|
1790
|
hasLifecycleHook(type, lcProperty) {
|
1791
|
return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
|
1792
|
}
|
1793
|
/**
|
1794
|
* @param {?} name
|
1795
|
* @return {?}
|
1796
|
*/
|
1797
|
getter(name) { return this.reflectionCapabilities.getter(name); }
|
1798
|
/**
|
1799
|
* @param {?} name
|
1800
|
* @return {?}
|
1801
|
*/
|
1802
|
setter(name) { return this.reflectionCapabilities.setter(name); }
|
1803
|
/**
|
1804
|
* @param {?} name
|
1805
|
* @return {?}
|
1806
|
*/
|
1807
|
method(name) { return this.reflectionCapabilities.method(name); }
|
1808
|
/**
|
1809
|
* @param {?} type
|
1810
|
* @return {?}
|
1811
|
*/
|
1812
|
importUri(type) { return this.reflectionCapabilities.importUri(type); }
|
1813
|
/**
|
1814
|
* @param {?} type
|
1815
|
* @return {?}
|
1816
|
*/
|
1817
|
resourceUri(type) { return this.reflectionCapabilities.resourceUri(type); }
|
1818
|
/**
|
1819
|
* @param {?} name
|
1820
|
* @param {?} moduleUrl
|
1821
|
* @param {?} members
|
1822
|
* @param {?} runtime
|
1823
|
* @return {?}
|
1824
|
*/
|
1825
|
resolveIdentifier(name, moduleUrl, members, runtime) {
|
1826
|
return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
|
1827
|
}
|
1828
|
/**
|
1829
|
* @param {?} identifier
|
1830
|
* @param {?} name
|
1831
|
* @return {?}
|
1832
|
*/
|
1833
|
resolveEnum(identifier, name) {
|
1834
|
return this.reflectionCapabilities.resolveEnum(identifier, name);
|
1835
|
}
|
1836
|
}
|
1837
|
|
1838
|
/**
|
1839
|
* @license
|
1840
|
* Copyright Google Inc. All Rights Reserved.
|
1841
|
*
|
1842
|
* Use of this source code is governed by an MIT-style license that can be
|
1843
|
* found in the LICENSE file at https://angular.io/license
|
1844
|
*/
|
1845
|
/**
|
1846
|
* The {\@link Reflector} used internally in Angular to access metadata
|
1847
|
* about symbols.
|
1848
|
*/
|
1849
|
const reflector = new Reflector(new ReflectionCapabilities());
|
1850
|
|
1851
|
/**
|
1852
|
* @license
|
1853
|
* Copyright Google Inc. All Rights Reserved.
|
1854
|
*
|
1855
|
* Use of this source code is governed by an MIT-style license that can be
|
1856
|
* found in the LICENSE file at https://angular.io/license
|
1857
|
*/
|
1858
|
/**
|
1859
|
* `Dependency` is used by the framework to extend DI.
|
1860
|
* This is internal to Angular and should not be used directly.
|
1861
|
*/
|
1862
|
class ReflectiveDependency {
|
1863
|
/**
|
1864
|
* @param {?} key
|
1865
|
* @param {?} optional
|
1866
|
* @param {?} visibility
|
1867
|
*/
|
1868
|
constructor(key, optional, visibility) {
|
1869
|
this.key = key;
|
1870
|
this.optional = optional;
|
1871
|
this.visibility = visibility;
|
1872
|
}
|
1873
|
/**
|
1874
|
* @param {?} key
|
1875
|
* @return {?}
|
1876
|
*/
|
1877
|
static fromKey(key) {
|
1878
|
return new ReflectiveDependency(key, false, null);
|
1879
|
}
|
1880
|
}
|
1881
|
const _EMPTY_LIST = [];
|
1882
|
class ResolvedReflectiveProvider_ {
|
1883
|
/**
|
1884
|
* @param {?} key
|
1885
|
* @param {?} resolvedFactories
|
1886
|
* @param {?} multiProvider
|
1887
|
*/
|
1888
|
constructor(key, resolvedFactories, multiProvider) {
|
1889
|
this.key = key;
|
1890
|
this.resolvedFactories = resolvedFactories;
|
1891
|
this.multiProvider = multiProvider;
|
1892
|
}
|
1893
|
/**
|
1894
|
* @return {?}
|
1895
|
*/
|
1896
|
get resolvedFactory() { return this.resolvedFactories[0]; }
|
1897
|
}
|
1898
|
/**
|
1899
|
* An internal resolved representation of a factory function created by resolving {\@link
|
1900
|
* Provider}.
|
1901
|
* \@experimental
|
1902
|
*/
|
1903
|
class ResolvedReflectiveFactory {
|
1904
|
/**
|
1905
|
* @param {?} factory
|
1906
|
* @param {?} dependencies
|
1907
|
*/
|
1908
|
constructor(factory, dependencies) {
|
1909
|
this.factory = factory;
|
1910
|
this.dependencies = dependencies;
|
1911
|
}
|
1912
|
}
|
1913
|
/**
|
1914
|
* Resolve a single provider.
|
1915
|
* @param {?} provider
|
1916
|
* @return {?}
|
1917
|
*/
|
1918
|
function resolveReflectiveFactory(provider) {
|
1919
|
let /** @type {?} */ factoryFn;
|
1920
|
let /** @type {?} */ resolvedDeps;
|
1921
|
if (provider.useClass) {
|
1922
|
const /** @type {?} */ useClass = resolveForwardRef(provider.useClass);
|
1923
|
factoryFn = reflector.factory(useClass);
|
1924
|
resolvedDeps = _dependenciesFor(useClass);
|
1925
|
}
|
1926
|
else if (provider.useExisting) {
|
1927
|
factoryFn = (aliasInstance) => aliasInstance;
|
1928
|
resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
|
1929
|
}
|
1930
|
else if (provider.useFactory) {
|
1931
|
factoryFn = provider.useFactory;
|
1932
|
resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
|
1933
|
}
|
1934
|
else {
|
1935
|
factoryFn = () => provider.useValue;
|
1936
|
resolvedDeps = _EMPTY_LIST;
|
1937
|
}
|
1938
|
return new ResolvedReflectiveFactory(factoryFn, resolvedDeps);
|
1939
|
}
|
1940
|
/**
|
1941
|
* Converts the {\@link Provider} into {\@link ResolvedProvider}.
|
1942
|
*
|
1943
|
* {\@link Injector} internally only uses {\@link ResolvedProvider}, {\@link Provider} contains
|
1944
|
* convenience provider syntax.
|
1945
|
* @param {?} provider
|
1946
|
* @return {?}
|
1947
|
*/
|
1948
|
function resolveReflectiveProvider(provider) {
|
1949
|
return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi || false);
|
1950
|
}
|
1951
|
/**
|
1952
|
* Resolve a list of Providers.
|
1953
|
* @param {?} providers
|
1954
|
* @return {?}
|
1955
|
*/
|
1956
|
function resolveReflectiveProviders(providers) {
|
1957
|
const /** @type {?} */ normalized = _normalizeProviders(providers, []);
|
1958
|
const /** @type {?} */ resolved = normalized.map(resolveReflectiveProvider);
|
1959
|
const /** @type {?} */ resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
|
1960
|
return Array.from(resolvedProviderMap.values());
|
1961
|
}
|
1962
|
/**
|
1963
|
* Merges a list of ResolvedProviders into a list where
|
1964
|
* each key is contained exactly once and multi providers
|
1965
|
* have been merged.
|
1966
|
* @param {?} providers
|
1967
|
* @param {?} normalizedProvidersMap
|
1968
|
* @return {?}
|
1969
|
*/
|
1970
|
function mergeResolvedReflectiveProviders(providers, normalizedProvidersMap) {
|
1971
|
for (let /** @type {?} */ i = 0; i < providers.length; i++) {
|
1972
|
const /** @type {?} */ provider = providers[i];
|
1973
|
const /** @type {?} */ existing = normalizedProvidersMap.get(provider.key.id);
|
1974
|
if (existing) {
|
1975
|
if (provider.multiProvider !== existing.multiProvider) {
|
1976
|
throw mixingMultiProvidersWithRegularProvidersError(existing, provider);
|
1977
|
}
|
1978
|
if (provider.multiProvider) {
|
1979
|
for (let /** @type {?} */ j = 0; j < provider.resolvedFactories.length; j++) {
|
1980
|
existing.resolvedFactories.push(provider.resolvedFactories[j]);
|
1981
|
}
|
1982
|
}
|
1983
|
else {
|
1984
|
normalizedProvidersMap.set(provider.key.id, provider);
|
1985
|
}
|
1986
|
}
|
1987
|
else {
|
1988
|
let /** @type {?} */ resolvedProvider;
|
1989
|
if (provider.multiProvider) {
|
1990
|
resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
|
1991
|
}
|
1992
|
else {
|
1993
|
resolvedProvider = provider;
|
1994
|
}
|
1995
|
normalizedProvidersMap.set(provider.key.id, resolvedProvider);
|
1996
|
}
|
1997
|
}
|
1998
|
return normalizedProvidersMap;
|
1999
|
}
|
2000
|
/**
|
2001
|
* @param {?} providers
|
2002
|
* @param {?} res
|
2003
|
* @return {?}
|
2004
|
*/
|
2005
|
function _normalizeProviders(providers, res) {
|
2006
|
providers.forEach(b => {
|
2007
|
if (b instanceof Type) {
|
2008
|
res.push({ provide: b, useClass: b });
|
2009
|
}
|
2010
|
else if (b && typeof b == 'object' && ((b)).provide !== undefined) {
|
2011
|
res.push(/** @type {?} */ (b));
|
2012
|
}
|
2013
|
else if (b instanceof Array) {
|
2014
|
_normalizeProviders(b, res);
|
2015
|
}
|
2016
|
else {
|
2017
|
throw invalidProviderError(b);
|
2018
|
}
|
2019
|
});
|
2020
|
return res;
|
2021
|
}
|
2022
|
/**
|
2023
|
* @param {?} typeOrFunc
|
2024
|
* @param {?=} dependencies
|
2025
|
* @return {?}
|
2026
|
*/
|
2027
|
function constructDependencies(typeOrFunc, dependencies) {
|
2028
|
if (!dependencies) {
|
2029
|
return _dependenciesFor(typeOrFunc);
|
2030
|
}
|
2031
|
else {
|
2032
|
const /** @type {?} */ params = dependencies.map(t => [t]);
|
2033
|
return dependencies.map(t => _extractToken(typeOrFunc, t, params));
|
2034
|
}
|
2035
|
}
|
2036
|
/**
|
2037
|
* @param {?} typeOrFunc
|
2038
|
* @return {?}
|
2039
|
*/
|
2040
|
function _dependenciesFor(typeOrFunc) {
|
2041
|
const /** @type {?} */ params = reflector.parameters(typeOrFunc);
|
2042
|
if (!params)
|
2043
|
return [];
|
2044
|
if (params.some(p => p == null)) {
|
2045
|
throw noAnnotationError(typeOrFunc, params);
|
2046
|
}
|
2047
|
return params.map(p => _extractToken(typeOrFunc, p, params));
|
2048
|
}
|
2049
|
/**
|
2050
|
* @param {?} typeOrFunc
|
2051
|
* @param {?} metadata
|
2052
|
* @param {?} params
|
2053
|
* @return {?}
|
2054
|
*/
|
2055
|
function _extractToken(typeOrFunc, metadata, params) {
|
2056
|
let /** @type {?} */ token = null;
|
2057
|
let /** @type {?} */ optional = false;
|
2058
|
if (!Array.isArray(metadata)) {
|
2059
|
if (metadata instanceof Inject) {
|
2060
|
return _createDependency(metadata.token, optional, null);
|
2061
|
}
|
2062
|
else {
|
2063
|
return _createDependency(metadata, optional, null);
|
2064
|
}
|
2065
|
}
|
2066
|
let /** @type {?} */ visibility = null;
|
2067
|
for (let /** @type {?} */ i = 0; i < metadata.length; ++i) {
|
2068
|
const /** @type {?} */ paramMetadata = metadata[i];
|
2069
|
if (paramMetadata instanceof Type) {
|
2070
|
token = paramMetadata;
|
2071
|
}
|
2072
|
else if (paramMetadata instanceof Inject) {
|
2073
|
token = paramMetadata.token;
|
2074
|
}
|
2075
|
else if (paramMetadata instanceof Optional) {
|
2076
|
optional = true;
|
2077
|
}
|
2078
|
else if (paramMetadata instanceof Self || paramMetadata instanceof SkipSelf) {
|
2079
|
visibility = paramMetadata;
|
2080
|
}
|
2081
|
else if (paramMetadata instanceof InjectionToken) {
|
2082
|
token = paramMetadata;
|
2083
|
}
|
2084
|
}
|
2085
|
token = resolveForwardRef(token);
|
2086
|
if (token != null) {
|
2087
|
return _createDependency(token, optional, visibility);
|
2088
|
}
|
2089
|
else {
|
2090
|
throw noAnnotationError(typeOrFunc, params);
|
2091
|
}
|
2092
|
}
|
2093
|
/**
|
2094
|
* @param {?} token
|
2095
|
* @param {?} optional
|
2096
|
* @param {?} visibility
|
2097
|
* @return {?}
|
2098
|
*/
|
2099
|
function _createDependency(token, optional, visibility) {
|
2100
|
return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
|
2101
|
}
|
2102
|
|
2103
|
/**
|
2104
|
* @license
|
2105
|
* Copyright Google Inc. All Rights Reserved.
|
2106
|
*
|
2107
|
* Use of this source code is governed by an MIT-style license that can be
|
2108
|
* found in the LICENSE file at https://angular.io/license
|
2109
|
*/
|
2110
|
// Threshold for the dynamic version
|
2111
|
const UNDEFINED = new Object();
|
2112
|
/**
|
2113
|
* A ReflectiveDependency injection container used for instantiating objects and resolving
|
2114
|
* dependencies.
|
2115
|
*
|
2116
|
* An `Injector` is a replacement for a `new` operator, which can automatically resolve the
|
2117
|
* constructor dependencies.
|
2118
|
*
|
2119
|
* In typical use, application code asks for the dependencies in the constructor and they are
|
2120
|
* resolved by the `Injector`.
|
2121
|
*
|
2122
|
* ### Example ([live demo](http://plnkr.co/edit/jzjec0?p=preview))
|
2123
|
*
|
2124
|
* The following example creates an `Injector` configured to create `Engine` and `Car`.
|
2125
|
*
|
2126
|
* ```typescript
|
2127
|
* \@Injectable()
|
2128
|
* class Engine {
|
2129
|
* }
|
2130
|
*
|
2131
|
* \@Injectable()
|
2132
|
* class Car {
|
2133
|
* constructor(public engine:Engine) {}
|
2134
|
* }
|
2135
|
*
|
2136
|
* var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
2137
|
* var car = injector.get(Car);
|
2138
|
* expect(car instanceof Car).toBe(true);
|
2139
|
* expect(car.engine instanceof Engine).toBe(true);
|
2140
|
* ```
|
2141
|
*
|
2142
|
* Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
|
2143
|
* resolve all of the object's dependencies automatically.
|
2144
|
*
|
2145
|
* \@stable
|
2146
|
* @abstract
|
2147
|
*/
|
2148
|
class ReflectiveInjector {
|
2149
|
/**
|
2150
|
* Turns an array of provider definitions into an array of resolved providers.
|
2151
|
*
|
2152
|
* A resolution is a process of flattening multiple nested arrays and converting individual
|
2153
|
* providers into an array of {\@link ResolvedReflectiveProvider}s.
|
2154
|
*
|
2155
|
* ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
|
2156
|
*
|
2157
|
* ```typescript
|
2158
|
* \@Injectable()
|
2159
|
* class Engine {
|
2160
|
* }
|
2161
|
*
|
2162
|
* \@Injectable()
|
2163
|
* class Car {
|
2164
|
* constructor(public engine:Engine) {}
|
2165
|
* }
|
2166
|
*
|
2167
|
* var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
|
2168
|
*
|
2169
|
* expect(providers.length).toEqual(2);
|
2170
|
*
|
2171
|
* expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
|
2172
|
* expect(providers[0].key.displayName).toBe("Car");
|
2173
|
* expect(providers[0].dependencies.length).toEqual(1);
|
2174
|
* expect(providers[0].factory).toBeDefined();
|
2175
|
*
|
2176
|
* expect(providers[1].key.displayName).toBe("Engine");
|
2177
|
* });
|
2178
|
* ```
|
2179
|
*
|
2180
|
* See {\@link ReflectiveInjector#fromResolvedProviders} for more info.
|
2181
|
* @param {?} providers
|
2182
|
* @return {?}
|
2183
|
*/
|
2184
|
static resolve(providers) {
|
2185
|
return resolveReflectiveProviders(providers);
|
2186
|
}
|
2187
|
/**
|
2188
|
* Resolves an array of providers and creates an injector from those providers.
|
2189
|
*
|
2190
|
* The passed-in providers can be an array of `Type`, {\@link Provider},
|
2191
|
* or a recursive array of more providers.
|
2192
|
*
|
2193
|
* ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
|
2194
|
*
|
2195
|
* ```typescript
|
2196
|
* \@Injectable()
|
2197
|
* class Engine {
|
2198
|
* }
|
2199
|
*
|
2200
|
* \@Injectable()
|
2201
|
* class Car {
|
2202
|
* constructor(public engine:Engine) {}
|
2203
|
* }
|
2204
|
*
|
2205
|
* var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
|
2206
|
* expect(injector.get(Car) instanceof Car).toBe(true);
|
2207
|
* ```
|
2208
|
*
|
2209
|
* This function is slower than the corresponding `fromResolvedProviders`
|
2210
|
* because it needs to resolve the passed-in providers first.
|
2211
|
* See {\@link ReflectiveInjector#resolve} and {\@link ReflectiveInjector#fromResolvedProviders}.
|
2212
|
* @param {?} providers
|
2213
|
* @param {?=} parent
|
2214
|
* @return {?}
|
2215
|
*/
|
2216
|
static resolveAndCreate(providers, parent) {
|
2217
|
const /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
2218
|
return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
|
2219
|
}
|
2220
|
/**
|
2221
|
* Creates an injector from previously resolved providers.
|
2222
|
*
|
2223
|
* This API is the recommended way to construct injectors in performance-sensitive parts.
|
2224
|
*
|
2225
|
* ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
|
2226
|
*
|
2227
|
* ```typescript
|
2228
|
* \@Injectable()
|
2229
|
* class Engine {
|
2230
|
* }
|
2231
|
*
|
2232
|
* \@Injectable()
|
2233
|
* class Car {
|
2234
|
* constructor(public engine:Engine) {}
|
2235
|
* }
|
2236
|
*
|
2237
|
* var providers = ReflectiveInjector.resolve([Car, Engine]);
|
2238
|
* var injector = ReflectiveInjector.fromResolvedProviders(providers);
|
2239
|
* expect(injector.get(Car) instanceof Car).toBe(true);
|
2240
|
* ```
|
2241
|
* \@experimental
|
2242
|
* @param {?} providers
|
2243
|
* @param {?=} parent
|
2244
|
* @return {?}
|
2245
|
*/
|
2246
|
static fromResolvedProviders(providers, parent) {
|
2247
|
return new ReflectiveInjector_(providers, parent);
|
2248
|
}
|
2249
|
/**
|
2250
|
* Parent of this injector.
|
2251
|
*
|
2252
|
* <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
|
2253
|
* -->
|
2254
|
*
|
2255
|
* ### Example ([live demo](http://plnkr.co/edit/eosMGo?p=preview))
|
2256
|
*
|
2257
|
* ```typescript
|
2258
|
* var parent = ReflectiveInjector.resolveAndCreate([]);
|
2259
|
* var child = parent.resolveAndCreateChild([]);
|
2260
|
* expect(child.parent).toBe(parent);
|
2261
|
* ```
|
2262
|
* @abstract
|
2263
|
* @return {?}
|
2264
|
*/
|
2265
|
parent() { }
|
2266
|
/**
|
2267
|
* Resolves an array of providers and creates a child injector from those providers.
|
2268
|
*
|
2269
|
* <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
|
2270
|
* -->
|
2271
|
*
|
2272
|
* The passed-in providers can be an array of `Type`, {\@link Provider},
|
2273
|
* or a recursive array of more providers.
|
2274
|
*
|
2275
|
* ### Example ([live demo](http://plnkr.co/edit/opB3T4?p=preview))
|
2276
|
*
|
2277
|
* ```typescript
|
2278
|
* class ParentProvider {}
|
2279
|
* class ChildProvider {}
|
2280
|
*
|
2281
|
* var parent = ReflectiveInjector.resolveAndCreate([ParentProvider]);
|
2282
|
* var child = parent.resolveAndCreateChild([ChildProvider]);
|
2283
|
*
|
2284
|
* expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
|
2285
|
* expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
|
2286
|
* expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
|
2287
|
* ```
|
2288
|
*
|
2289
|
* This function is slower than the corresponding `createChildFromResolved`
|
2290
|
* because it needs to resolve the passed-in providers first.
|
2291
|
* See {\@link ReflectiveInjector#resolve} and {\@link ReflectiveInjector#createChildFromResolved}.
|
2292
|
* @abstract
|
2293
|
* @param {?} providers
|
2294
|
* @return {?}
|
2295
|
*/
|
2296
|
resolveAndCreateChild(providers) { }
|
2297
|
/**
|
2298
|
* Creates a child injector from previously resolved providers.
|
2299
|
*
|
2300
|
* <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
|
2301
|
* -->
|
2302
|
*
|
2303
|
* This API is the recommended way to construct injectors in performance-sensitive parts.
|
2304
|
*
|
2305
|
* ### Example ([live demo](http://plnkr.co/edit/VhyfjN?p=preview))
|
2306
|
*
|
2307
|
* ```typescript
|
2308
|
* class ParentProvider {}
|
2309
|
* class ChildProvider {}
|
2310
|
*
|
2311
|
* var parentProviders = ReflectiveInjector.resolve([ParentProvider]);
|
2312
|
* var childProviders = ReflectiveInjector.resolve([ChildProvider]);
|
2313
|
*
|
2314
|
* var parent = ReflectiveInjector.fromResolvedProviders(parentProviders);
|
2315
|
* var child = parent.createChildFromResolved(childProviders);
|
2316
|
*
|
2317
|
* expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
|
2318
|
* expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
|
2319
|
* expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
|
2320
|
* ```
|
2321
|
* @abstract
|
2322
|
* @param {?} providers
|
2323
|
* @return {?}
|
2324
|
*/
|
2325
|
createChildFromResolved(providers) { }
|
2326
|
/**
|
2327
|
* Resolves a provider and instantiates an object in the context of the injector.
|
2328
|
*
|
2329
|
* The created object does not get cached by the injector.
|
2330
|
*
|
2331
|
* ### Example ([live demo](http://plnkr.co/edit/yvVXoB?p=preview))
|
2332
|
*
|
2333
|
* ```typescript
|
2334
|
* \@Injectable()
|
2335
|
* class Engine {
|
2336
|
* }
|
2337
|
*
|
2338
|
* \@Injectable()
|
2339
|
* class Car {
|
2340
|
* constructor(public engine:Engine) {}
|
2341
|
* }
|
2342
|
*
|
2343
|
* var injector = ReflectiveInjector.resolveAndCreate([Engine]);
|
2344
|
*
|
2345
|
* var car = injector.resolveAndInstantiate(Car);
|
2346
|
* expect(car.engine).toBe(injector.get(Engine));
|
2347
|
* expect(car).not.toBe(injector.resolveAndInstantiate(Car));
|
2348
|
* ```
|
2349
|
* @abstract
|
2350
|
* @param {?} provider
|
2351
|
* @return {?}
|
2352
|
*/
|
2353
|
resolveAndInstantiate(provider) { }
|
2354
|
/**
|
2355
|
* Instantiates an object using a resolved provider in the context of the injector.
|
2356
|
*
|
2357
|
* The created object does not get cached by the injector.
|
2358
|
*
|
2359
|
* ### Example ([live demo](http://plnkr.co/edit/ptCImQ?p=preview))
|
2360
|
*
|
2361
|
* ```typescript
|
2362
|
* \@Injectable()
|
2363
|
* class Engine {
|
2364
|
* }
|
2365
|
*
|
2366
|
* \@Injectable()
|
2367
|
* class Car {
|
2368
|
* constructor(public engine:Engine) {}
|
2369
|
* }
|
2370
|
*
|
2371
|
* var injector = ReflectiveInjector.resolveAndCreate([Engine]);
|
2372
|
* var carProvider = ReflectiveInjector.resolve([Car])[0];
|
2373
|
* var car = injector.instantiateResolved(carProvider);
|
2374
|
* expect(car.engine).toBe(injector.get(Engine));
|
2375
|
* expect(car).not.toBe(injector.instantiateResolved(carProvider));
|
2376
|
* ```
|
2377
|
* @abstract
|
2378
|
* @param {?} provider
|
2379
|
* @return {?}
|
2380
|
*/
|
2381
|
instantiateResolved(provider) { }
|
2382
|
/**
|
2383
|
* @abstract
|
2384
|
* @param {?} token
|
2385
|
* @param {?=} notFoundValue
|
2386
|
* @return {?}
|
2387
|
*/
|
2388
|
get(token, notFoundValue) { }
|
2389
|
}
|
2390
|
class ReflectiveInjector_ {
|
2391
|
/**
|
2392
|
* Private
|
2393
|
* @param {?} _providers
|
2394
|
* @param {?=} _parent
|
2395
|
*/
|
2396
|
constructor(_providers, _parent) {
|
2397
|
/**
|
2398
|
* \@internal
|
2399
|
*/
|
2400
|
this._constructionCounter = 0;
|
2401
|
this._providers = _providers;
|
2402
|
this._parent = _parent || null;
|
2403
|
const len = _providers.length;
|
2404
|
this.keyIds = new Array(len);
|
2405
|
this.objs = new Array(len);
|
2406
|
for (let i = 0; i < len; i++) {
|
2407
|
this.keyIds[i] = _providers[i].key.id;
|
2408
|
this.objs[i] = UNDEFINED;
|
2409
|
}
|
2410
|
}
|
2411
|
/**
|
2412
|
* @param {?} token
|
2413
|
* @param {?=} notFoundValue
|
2414
|
* @return {?}
|
2415
|
*/
|
2416
|
get(token, notFoundValue = THROW_IF_NOT_FOUND) {
|
2417
|
return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
|
2418
|
}
|
2419
|
/**
|
2420
|
* @return {?}
|
2421
|
*/
|
2422
|
get parent() { return this._parent; }
|
2423
|
/**
|
2424
|
* @param {?} providers
|
2425
|
* @return {?}
|
2426
|
*/
|
2427
|
resolveAndCreateChild(providers) {
|
2428
|
const /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
|
2429
|
return this.createChildFromResolved(ResolvedReflectiveProviders);
|
2430
|
}
|
2431
|
/**
|
2432
|
* @param {?} providers
|
2433
|
* @return {?}
|
2434
|
*/
|
2435
|
createChildFromResolved(providers) {
|
2436
|
const /** @type {?} */ inj = new ReflectiveInjector_(providers);
|
2437
|
inj._parent = this;
|
2438
|
return inj;
|
2439
|
}
|
2440
|
/**
|
2441
|
* @param {?} provider
|
2442
|
* @return {?}
|
2443
|
*/
|
2444
|
resolveAndInstantiate(provider) {
|
2445
|
return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
|
2446
|
}
|
2447
|
/**
|
2448
|
* @param {?} provider
|
2449
|
* @return {?}
|
2450
|
*/
|
2451
|
instantiateResolved(provider) {
|
2452
|
return this._instantiateProvider(provider);
|
2453
|
}
|
2454
|
/**
|
2455
|
* @param {?} index
|
2456
|
* @return {?}
|
2457
|
*/
|
2458
|
getProviderAtIndex(index) {
|
2459
|
if (index < 0 || index >= this._providers.length) {
|
2460
|
throw outOfBoundsError(index);
|
2461
|
}
|
2462
|
return this._providers[index];
|
2463
|
}
|
2464
|
/**
|
2465
|
* \@internal
|
2466
|
* @param {?} provider
|
2467
|
* @return {?}
|
2468
|
*/
|
2469
|
_new(provider) {
|
2470
|
if (this._constructionCounter++ > this._getMaxNumberOfObjects()) {
|
2471
|
throw cyclicDependencyError(this, provider.key);
|
2472
|
}
|
2473
|
return this._instantiateProvider(provider);
|
2474
|
}
|
2475
|
/**
|
2476
|
* @return {?}
|
2477
|
*/
|
2478
|
_getMaxNumberOfObjects() { return this.objs.length; }
|
2479
|
/**
|
2480
|
* @param {?} provider
|
2481
|
* @return {?}
|
2482
|
*/
|
2483
|
_instantiateProvider(provider) {
|
2484
|
if (provider.multiProvider) {
|
2485
|
const /** @type {?} */ res = new Array(provider.resolvedFactories.length);
|
2486
|
for (let /** @type {?} */ i = 0; i < provider.resolvedFactories.length; ++i) {
|
2487
|
res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
|
2488
|
}
|
2489
|
return res;
|
2490
|
}
|
2491
|
else {
|
2492
|
return this._instantiate(provider, provider.resolvedFactories[0]);
|
2493
|
}
|
2494
|
}
|
2495
|
/**
|
2496
|
* @param {?} provider
|
2497
|
* @param {?} ResolvedReflectiveFactory
|
2498
|
* @return {?}
|
2499
|
*/
|
2500
|
_instantiate(provider, ResolvedReflectiveFactory$$1) {
|
2501
|
const /** @type {?} */ factory = ResolvedReflectiveFactory$$1.factory;
|
2502
|
let /** @type {?} */ deps;
|
2503
|
try {
|
2504
|
deps =
|
2505
|
ResolvedReflectiveFactory$$1.dependencies.map(dep => this._getByReflectiveDependency(dep));
|
2506
|
}
|
2507
|
catch (e) {
|
2508
|
if (e.addKey) {
|
2509
|
e.addKey(this, provider.key);
|
2510
|
}
|
2511
|
throw e;
|
2512
|
}
|
2513
|
let /** @type {?} */ obj;
|
2514
|
try {
|
2515
|
obj = factory(...deps);
|
2516
|
}
|
2517
|
catch (e) {
|
2518
|
throw instantiationError(this, e, e.stack, provider.key);
|
2519
|
}
|
2520
|
return obj;
|
2521
|
}
|
2522
|
/**
|
2523
|
* @param {?} dep
|
2524
|
* @return {?}
|
2525
|
*/
|
2526
|
_getByReflectiveDependency(dep) {
|
2527
|
return this._getByKey(dep.key, dep.visibility, dep.optional ? null : THROW_IF_NOT_FOUND);
|
2528
|
}
|
2529
|
/**
|
2530
|
* @param {?} key
|
2531
|
* @param {?} visibility
|
2532
|
* @param {?} notFoundValue
|
2533
|
* @return {?}
|
2534
|
*/
|
2535
|
_getByKey(key, visibility, notFoundValue) {
|
2536
|
if (key === INJECTOR_KEY) {
|
2537
|
return this;
|
2538
|
}
|
2539
|
if (visibility instanceof Self) {
|
2540
|
return this._getByKeySelf(key, notFoundValue);
|
2541
|
}
|
2542
|
else {
|
2543
|
return this._getByKeyDefault(key, notFoundValue, visibility);
|
2544
|
}
|
2545
|
}
|
2546
|
/**
|
2547
|
* @param {?} keyId
|
2548
|
* @return {?}
|
2549
|
*/
|
2550
|
_getObjByKeyId(keyId) {
|
2551
|
for (let /** @type {?} */ i = 0; i < this.keyIds.length; i++) {
|
2552
|
if (this.keyIds[i] === keyId) {
|
2553
|
if (this.objs[i] === UNDEFINED) {
|
2554
|
this.objs[i] = this._new(this._providers[i]);
|
2555
|
}
|
2556
|
return this.objs[i];
|
2557
|
}
|
2558
|
}
|
2559
|
return UNDEFINED;
|
2560
|
}
|
2561
|
/**
|
2562
|
* \@internal
|
2563
|
* @param {?} key
|
2564
|
* @param {?} notFoundValue
|
2565
|
* @return {?}
|
2566
|
*/
|
2567
|
_throwOrNull(key, notFoundValue) {
|
2568
|
if (notFoundValue !== THROW_IF_NOT_FOUND) {
|
2569
|
return notFoundValue;
|
2570
|
}
|
2571
|
else {
|
2572
|
throw noProviderError(this, key);
|
2573
|
}
|
2574
|
}
|
2575
|
/**
|
2576
|
* \@internal
|
2577
|
* @param {?} key
|
2578
|
* @param {?} notFoundValue
|
2579
|
* @return {?}
|
2580
|
*/
|
2581
|
_getByKeySelf(key, notFoundValue) {
|
2582
|
const /** @type {?} */ obj = this._getObjByKeyId(key.id);
|
2583
|
return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, notFoundValue);
|
2584
|
}
|
2585
|
/**
|
2586
|
* \@internal
|
2587
|
* @param {?} key
|
2588
|
* @param {?} notFoundValue
|
2589
|
* @param {?} visibility
|
2590
|
* @return {?}
|
2591
|
*/
|
2592
|
_getByKeyDefault(key, notFoundValue, visibility) {
|
2593
|
let /** @type {?} */ inj;
|
2594
|
if (visibility instanceof SkipSelf) {
|
2595
|
inj = this._parent;
|
2596
|
}
|
2597
|
else {
|
2598
|
inj = this;
|
2599
|
}
|
2600
|
while (inj instanceof ReflectiveInjector_) {
|
2601
|
const /** @type {?} */ inj_ = (inj);
|
2602
|
const /** @type {?} */ obj = inj_._getObjByKeyId(key.id);
|
2603
|
if (obj !== UNDEFINED)
|
2604
|
return obj;
|
2605
|
inj = inj_._parent;
|
2606
|
}
|
2607
|
if (inj !== null) {
|
2608
|
return inj.get(key.token, notFoundValue);
|
2609
|
}
|
2610
|
else {
|
2611
|
return this._throwOrNull(key, notFoundValue);
|
2612
|
}
|
2613
|
}
|
2614
|
/**
|
2615
|
* @return {?}
|
2616
|
*/
|
2617
|
get displayName() {
|
2618
|
const /** @type {?} */ providers = _mapProviders(this, (b) => ' "' + b.key.displayName + '" ')
|
2619
|
.join(', ');
|
2620
|
return `ReflectiveInjector(providers: [${providers}])`;
|
2621
|
}
|
2622
|
/**
|
2623
|
* @return {?}
|
2624
|
*/
|
2625
|
toString() { return this.displayName; }
|
2626
|
}
|
2627
|
const INJECTOR_KEY = ReflectiveKey.get(Injector);
|
2628
|
/**
|
2629
|
* @param {?} injector
|
2630
|
* @param {?} fn
|
2631
|
* @return {?}
|
2632
|
*/
|
2633
|
function _mapProviders(injector, fn) {
|
2634
|
const /** @type {?} */ res = new Array(injector._providers.length);
|
2635
|
for (let /** @type {?} */ i = 0; i < injector._providers.length; ++i) {
|
2636
|
res[i] = fn(injector.getProviderAtIndex(i));
|
2637
|
}
|
2638
|
return res;
|
2639
|
}
|
2640
|
|
2641
|
/**
|
2642
|
* @license
|
2643
|
* Copyright Google Inc. All Rights Reserved.
|
2644
|
*
|
2645
|
* Use of this source code is governed by an MIT-style license that can be
|
2646
|
* found in the LICENSE file at https://angular.io/license
|
2647
|
*/
|
2648
|
/**
|
2649
|
* @module
|
2650
|
* @description
|
2651
|
* The `di` module provides dependency injection container services.
|
2652
|
*/
|
2653
|
|
2654
|
/**
|
2655
|
* @license
|
2656
|
* Copyright Google Inc. All Rights Reserved.
|
2657
|
*
|
2658
|
* Use of this source code is governed by an MIT-style license that can be
|
2659
|
* found in the LICENSE file at https://angular.io/license
|
2660
|
*/
|
2661
|
/**
|
2662
|
* Determine if the argument is shaped like a Promise
|
2663
|
* @param {?} obj
|
2664
|
* @return {?}
|
2665
|
*/
|
2666
|
function isPromise(obj) {
|
2667
|
// allow any Promise/A+ compliant thenable.
|
2668
|
// It's up to the caller to ensure that obj.then conforms to the spec
|
2669
|
return !!obj && typeof obj.then === 'function';
|
2670
|
}
|
2671
|
/**
|
2672
|
* Determine if the argument is an Observable
|
2673
|
* @param {?} obj
|
2674
|
* @return {?}
|
2675
|
*/
|
2676
|
function isObservable(obj) {
|
2677
|
// TODO use Symbol.observable when https://github.com/ReactiveX/rxjs/issues/2415 will be resolved
|
2678
|
return !!obj && typeof obj.subscribe === 'function';
|
2679
|
}
|
2680
|
|
2681
|
/**
|
2682
|
* @license
|
2683
|
* Copyright Google Inc. All Rights Reserved.
|
2684
|
*
|
2685
|
* Use of this source code is governed by an MIT-style license that can be
|
2686
|
* found in the LICENSE file at https://angular.io/license
|
2687
|
*/
|
2688
|
/**
|
2689
|
* A function that will be executed when an application is initialized.
|
2690
|
* \@experimental
|
2691
|
*/
|
2692
|
const APP_INITIALIZER = new InjectionToken('Application Initializer');
|
2693
|
/**
|
2694
|
* A class that reflects the state of running {\@link APP_INITIALIZER}s.
|
2695
|
*
|
2696
|
* \@experimental
|
2697
|
*/
|
2698
|
class ApplicationInitStatus {
|
2699
|
/**
|
2700
|
* @param {?} appInits
|
2701
|
*/
|
2702
|
constructor(appInits) {
|
2703
|
this.appInits = appInits;
|
2704
|
this.initialized = false;
|
2705
|
this._done = false;
|
2706
|
this._donePromise = new Promise((res, rej) => {
|
2707
|
this.resolve = res;
|
2708
|
this.reject = rej;
|
2709
|
});
|
2710
|
}
|
2711
|
/**
|
2712
|
* \@internal
|
2713
|
* @return {?}
|
2714
|
*/
|
2715
|
runInitializers() {
|
2716
|
if (this.initialized) {
|
2717
|
return;
|
2718
|
}
|
2719
|
const /** @type {?} */ asyncInitPromises = [];
|
2720
|
const /** @type {?} */ complete = () => {
|
2721
|
this._done = true;
|
2722
|
this.resolve();
|
2723
|
};
|
2724
|
if (this.appInits) {
|
2725
|
for (let /** @type {?} */ i = 0; i < this.appInits.length; i++) {
|
2726
|
const /** @type {?} */ initResult = this.appInits[i]();
|
2727
|
if (isPromise(initResult)) {
|
2728
|
asyncInitPromises.push(initResult);
|
2729
|
}
|
2730
|
}
|
2731
|
}
|
2732
|
Promise.all(asyncInitPromises).then(() => { complete(); }).catch(e => { this.reject(e); });
|
2733
|
if (asyncInitPromises.length === 0) {
|
2734
|
complete();
|
2735
|
}
|
2736
|
this.initialized = true;
|
2737
|
}
|
2738
|
/**
|
2739
|
* @return {?}
|
2740
|
*/
|
2741
|
get done() { return this._done; }
|
2742
|
/**
|
2743
|
* @return {?}
|
2744
|
*/
|
2745
|
get donePromise() { return this._donePromise; }
|
2746
|
}
|
2747
|
ApplicationInitStatus.decorators = [
|
2748
|
{ type: Injectable },
|
2749
|
];
|
2750
|
/**
|
2751
|
* @nocollapse
|
2752
|
*/
|
2753
|
ApplicationInitStatus.ctorParameters = () => [
|
2754
|
{ type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER,] }, { type: Optional },] },
|
2755
|
];
|
2756
|
|
2757
|
/**
|
2758
|
* @license
|
2759
|
* Copyright Google Inc. All Rights Reserved.
|
2760
|
*
|
2761
|
* Use of this source code is governed by an MIT-style license that can be
|
2762
|
* found in the LICENSE file at https://angular.io/license
|
2763
|
*/
|
2764
|
/**
|
2765
|
* A DI Token representing a unique string id assigned to the application by Angular and used
|
2766
|
* primarily for prefixing application attributes and CSS styles when
|
2767
|
* {\@link ViewEncapsulation#Emulated} is being used.
|
2768
|
*
|
2769
|
* If you need to avoid randomly generated value to be used as an application id, you can provide
|
2770
|
* a custom value via a DI provider <!-- TODO: provider --> configuring the root {\@link Injector}
|
2771
|
* using this token.
|
2772
|
* \@experimental
|
2773
|
*/
|
2774
|
const APP_ID = new InjectionToken('AppId');
|
2775
|
/**
|
2776
|
* @return {?}
|
2777
|
*/
|
2778
|
function _appIdRandomProviderFactory() {
|
2779
|
return `${_randomChar()}${_randomChar()}${_randomChar()}`;
|
2780
|
}
|
2781
|
/**
|
2782
|
* Providers that will generate a random APP_ID_TOKEN.
|
2783
|
* \@experimental
|
2784
|
*/
|
2785
|
const APP_ID_RANDOM_PROVIDER = {
|
2786
|
provide: APP_ID,
|
2787
|
useFactory: _appIdRandomProviderFactory,
|
2788
|
deps: [],
|
2789
|
};
|
2790
|
/**
|
2791
|
* @return {?}
|
2792
|
*/
|
2793
|
function _randomChar() {
|
2794
|
return String.fromCharCode(97 + Math.floor(Math.random() * 25));
|
2795
|
}
|
2796
|
/**
|
2797
|
* A function that will be executed when a platform is initialized.
|
2798
|
* \@experimental
|
2799
|
*/
|
2800
|
const PLATFORM_INITIALIZER = new InjectionToken('Platform Initializer');
|
2801
|
/**
|
2802
|
* A token that indicates an opaque platform id.
|
2803
|
* \@experimental
|
2804
|
*/
|
2805
|
const PLATFORM_ID = new InjectionToken('Platform ID');
|
2806
|
/**
|
2807
|
* All callbacks provided via this token will be called for every component that is bootstrapped.
|
2808
|
* Signature of the callback:
|
2809
|
*
|
2810
|
* `(componentRef: ComponentRef) => void`.
|
2811
|
*
|
2812
|
* \@experimental
|
2813
|
*/
|
2814
|
const APP_BOOTSTRAP_LISTENER = new InjectionToken('appBootstrapListener');
|
2815
|
/**
|
2816
|
* A token which indicates the root directory of the application
|
2817
|
* \@experimental
|
2818
|
*/
|
2819
|
const PACKAGE_ROOT_URL = new InjectionToken('Application Packages Root URL');
|
2820
|
|
2821
|
/**
|
2822
|
* @license
|
2823
|
* Copyright Google Inc. All Rights Reserved.
|
2824
|
*
|
2825
|
* Use of this source code is governed by an MIT-style license that can be
|
2826
|
* found in the LICENSE file at https://angular.io/license
|
2827
|
*/
|
2828
|
class Console {
|
2829
|
/**
|
2830
|
* @param {?} message
|
2831
|
* @return {?}
|
2832
|
*/
|
2833
|
log(message) {
|
2834
|
// tslint:disable-next-line:no-console
|
2835
|
console.log(message);
|
2836
|
}
|
2837
|
/**
|
2838
|
* @param {?} message
|
2839
|
* @return {?}
|
2840
|
*/
|
2841
|
warn(message) {
|
2842
|
// tslint:disable-next-line:no-console
|
2843
|
console.warn(message);
|
2844
|
}
|
2845
|
}
|
2846
|
Console.decorators = [
|
2847
|
{ type: Injectable },
|
2848
|
];
|
2849
|
/**
|
2850
|
* @nocollapse
|
2851
|
*/
|
2852
|
Console.ctorParameters = () => [];
|
2853
|
|
2854
|
/**
|
2855
|
* @license
|
2856
|
* Copyright Google Inc. All Rights Reserved.
|
2857
|
*
|
2858
|
* Use of this source code is governed by an MIT-style license that can be
|
2859
|
* found in the LICENSE file at https://angular.io/license
|
2860
|
*/
|
2861
|
/**
|
2862
|
* Combination of NgModuleFactory and ComponentFactorys.
|
2863
|
*
|
2864
|
* \@experimental
|
2865
|
*/
|
2866
|
class ModuleWithComponentFactories {
|
2867
|
/**
|
2868
|
* @param {?} ngModuleFactory
|
2869
|
* @param {?} componentFactories
|
2870
|
*/
|
2871
|
constructor(ngModuleFactory, componentFactories) {
|
2872
|
this.ngModuleFactory = ngModuleFactory;
|
2873
|
this.componentFactories = componentFactories;
|
2874
|
}
|
2875
|
}
|
2876
|
/**
|
2877
|
* @return {?}
|
2878
|
*/
|
2879
|
function _throwError() {
|
2880
|
throw new Error(`Runtime compiler is not loaded`);
|
2881
|
}
|
2882
|
/**
|
2883
|
* Low-level service for running the angular compiler during runtime
|
2884
|
* to create {\@link ComponentFactory}s, which
|
2885
|
* can later be used to create and render a Component instance.
|
2886
|
*
|
2887
|
* Each `\@NgModule` provides an own `Compiler` to its injector,
|
2888
|
* that will use the directives/pipes of the ng module for compilation
|
2889
|
* of components.
|
2890
|
* \@stable
|
2891
|
*/
|
2892
|
class Compiler {
|
2893
|
/**
|
2894
|
* Compiles the given NgModule and all of its components. All templates of the components listed
|
2895
|
* in `entryComponents` have to be inlined.
|
2896
|
* @template T
|
2897
|
* @param {?} moduleType
|
2898
|
* @return {?}
|
2899
|
*/
|
2900
|
compileModuleSync(moduleType) { throw _throwError(); }
|
2901
|
/**
|
2902
|
* Compiles the given NgModule and all of its components
|
2903
|
* @template T
|
2904
|
* @param {?} moduleType
|
2905
|
* @return {?}
|
2906
|
*/
|
2907
|
compileModuleAsync(moduleType) { throw _throwError(); }
|
2908
|
/**
|
2909
|
* Same as {\@link #compileModuleSync} but also creates ComponentFactories for all components.
|
2910
|
* @template T
|
2911
|
* @param {?} moduleType
|
2912
|
* @return {?}
|
2913
|
*/
|
2914
|
compileModuleAndAllComponentsSync(moduleType) {
|
2915
|
throw _throwError();
|
2916
|
}
|
2917
|
/**
|
2918
|
* Same as {\@link #compileModuleAsync} but also creates ComponentFactories for all components.
|
2919
|
* @template T
|
2920
|
* @param {?} moduleType
|
2921
|
* @return {?}
|
2922
|
*/
|
2923
|
compileModuleAndAllComponentsAsync(moduleType) {
|
2924
|
throw _throwError();
|
2925
|
}
|
2926
|
/**
|
2927
|
* Exposes the CSS-style selectors that have been used in `ngContent` directives within
|
2928
|
* the template of the given component.
|
2929
|
* This is used by the `upgrade` library to compile the appropriate transclude content
|
2930
|
* in the AngularJS wrapper component.
|
2931
|
*
|
2932
|
* @deprecated since v4. Use ComponentFactory.ngContentSelectors instead.
|
2933
|
* @param {?} component
|
2934
|
* @return {?}
|
2935
|
*/
|
2936
|
getNgContentSelectors(component) { throw _throwError(); }
|
2937
|
/**
|
2938
|
* Clears all caches.
|
2939
|
* @return {?}
|
2940
|
*/
|
2941
|
clearCache() { }
|
2942
|
/**
|
2943
|
* Clears the cache for the given component/ngModule.
|
2944
|
* @param {?} type
|
2945
|
* @return {?}
|
2946
|
*/
|
2947
|
clearCacheFor(type) { }
|
2948
|
}
|
2949
|
Compiler.decorators = [
|
2950
|
{ type: Injectable },
|
2951
|
];
|
2952
|
/**
|
2953
|
* @nocollapse
|
2954
|
*/
|
2955
|
Compiler.ctorParameters = () => [];
|
2956
|
/**
|
2957
|
* Token to provide CompilerOptions in the platform injector.
|
2958
|
*
|
2959
|
* \@experimental
|
2960
|
*/
|
2961
|
const COMPILER_OPTIONS = new InjectionToken('compilerOptions');
|
2962
|
/**
|
2963
|
* A factory for creating a Compiler
|
2964
|
*
|
2965
|
* \@experimental
|
2966
|
* @abstract
|
2967
|
*/
|
2968
|
class CompilerFactory {
|
2969
|
/**
|
2970
|
* @abstract
|
2971
|
* @param {?=} options
|
2972
|
* @return {?}
|
2973
|
*/
|
2974
|
createCompiler(options) { }
|
2975
|
}
|
2976
|
|
2977
|
/**
|
2978
|
* @license
|
2979
|
* Copyright Google Inc. All Rights Reserved.
|
2980
|
*
|
2981
|
* Use of this source code is governed by an MIT-style license that can be
|
2982
|
* found in the LICENSE file at https://angular.io/license
|
2983
|
*/
|
2984
|
/**
|
2985
|
* Represents an instance of a Component created via a {\@link ComponentFactory}.
|
2986
|
*
|
2987
|
* `ComponentRef` provides access to the Component Instance as well other objects related to this
|
2988
|
* Component Instance and allows you to destroy the Component Instance via the {\@link #destroy}
|
2989
|
* method.
|
2990
|
* \@stable
|
2991
|
* @abstract
|
2992
|
*/
|
2993
|
class ComponentRef {
|
2994
|
/**
|
2995
|
* Location of the Host Element of this Component Instance.
|
2996
|
* @abstract
|
2997
|
* @return {?}
|
2998
|
*/
|
2999
|
location() { }
|
3000
|
/**
|
3001
|
* The injector on which the component instance exists.
|
3002
|
* @abstract
|
3003
|
* @return {?}
|
3004
|
*/
|
3005
|
injector() { }
|
3006
|
/**
|
3007
|
* The instance of the Component.
|
3008
|
* @abstract
|
3009
|
* @return {?}
|
3010
|
*/
|
3011
|
instance() { }
|
3012
|
/**
|
3013
|
* The {\@link ViewRef} of the Host View of this Component instance.
|
3014
|
* @abstract
|
3015
|
* @return {?}
|
3016
|
*/
|
3017
|
hostView() { }
|
3018
|
/**
|
3019
|
* The {\@link ChangeDetectorRef} of the Component instance.
|
3020
|
* @abstract
|
3021
|
* @return {?}
|
3022
|
*/
|
3023
|
changeDetectorRef() { }
|
3024
|
/**
|
3025
|
* The component type.
|
3026
|
* @abstract
|
3027
|
* @return {?}
|
3028
|
*/
|
3029
|
componentType() { }
|
3030
|
/**
|
3031
|
* Destroys the component instance and all of the data structures associated with it.
|
3032
|
* @abstract
|
3033
|
* @return {?}
|
3034
|
*/
|
3035
|
destroy() { }
|
3036
|
/**
|
3037
|
* Allows to register a callback that will be called when the component is destroyed.
|
3038
|
* @abstract
|
3039
|
* @param {?} callback
|
3040
|
* @return {?}
|
3041
|
*/
|
3042
|
onDestroy(callback) { }
|
3043
|
}
|
3044
|
/**
|
3045
|
* \@stable
|
3046
|
* @abstract
|
3047
|
*/
|
3048
|
class ComponentFactory {
|
3049
|
/**
|
3050
|
* @abstract
|
3051
|
* @return {?}
|
3052
|
*/
|
3053
|
selector() { }
|
3054
|
/**
|
3055
|
* @abstract
|
3056
|
* @return {?}
|
3057
|
*/
|
3058
|
componentType() { }
|
3059
|
/**
|
3060
|
* selector for all <ng-content> elements in the component.
|
3061
|
* @abstract
|
3062
|
* @return {?}
|
3063
|
*/
|
3064
|
ngContentSelectors() { }
|
3065
|
/**
|
3066
|
* the inputs of the component.
|
3067
|
* @abstract
|
3068
|
* @return {?}
|
3069
|
*/
|
3070
|
inputs() { }
|
3071
|
/**
|
3072
|
* the outputs of the component.
|
3073
|
* @abstract
|
3074
|
* @return {?}
|
3075
|
*/
|
3076
|
outputs() { }
|
3077
|
/**
|
3078
|
* Creates a new component.
|
3079
|
* @abstract
|
3080
|
* @param {?} injector
|
3081
|
* @param {?=} projectableNodes
|
3082
|
* @param {?=} rootSelectorOrNode
|
3083
|
* @param {?=} ngModule
|
3084
|
* @return {?}
|
3085
|
*/
|
3086
|
create(injector, projectableNodes, rootSelectorOrNode, ngModule) { }
|
3087
|
}
|
3088
|
|
3089
|
/**
|
3090
|
* @license
|
3091
|
* Copyright Google Inc. All Rights Reserved.
|
3092
|
*
|
3093
|
* Use of this source code is governed by an MIT-style license that can be
|
3094
|
* found in the LICENSE file at https://angular.io/license
|
3095
|
*/
|
3096
|
/**
|
3097
|
* @param {?} component
|
3098
|
* @return {?}
|
3099
|
*/
|
3100
|
function noComponentFactoryError(component) {
|
3101
|
const /** @type {?} */ error = Error(`No component factory found for ${stringify(component)}. Did you add it to @NgModule.entryComponents?`);
|
3102
|
((error))[ERROR_COMPONENT] = component;
|
3103
|
return error;
|
3104
|
}
|
3105
|
const ERROR_COMPONENT = 'ngComponent';
|
3106
|
/**
|
3107
|
* @param {?} error
|
3108
|
* @return {?}
|
3109
|
*/
|
3110
|
|
3111
|
class _NullComponentFactoryResolver {
|
3112
|
/**
|
3113
|
* @template T
|
3114
|
* @param {?} component
|
3115
|
* @return {?}
|
3116
|
*/
|
3117
|
resolveComponentFactory(component) {
|
3118
|
throw noComponentFactoryError(component);
|
3119
|
}
|
3120
|
}
|
3121
|
/**
|
3122
|
* \@stable
|
3123
|
* @abstract
|
3124
|
*/
|
3125
|
class ComponentFactoryResolver {
|
3126
|
/**
|
3127
|
* @abstract
|
3128
|
* @template T
|
3129
|
* @param {?} component
|
3130
|
* @return {?}
|
3131
|
*/
|
3132
|
resolveComponentFactory(component) { }
|
3133
|
}
|
3134
|
ComponentFactoryResolver.NULL = new _NullComponentFactoryResolver();
|
3135
|
class CodegenComponentFactoryResolver {
|
3136
|
/**
|
3137
|
* @param {?} factories
|
3138
|
* @param {?} _parent
|
3139
|
* @param {?} _ngModule
|
3140
|
*/
|
3141
|
constructor(factories, _parent, _ngModule) {
|
3142
|
this._parent = _parent;
|
3143
|
this._ngModule = _ngModule;
|
3144
|
this._factories = new Map();
|
3145
|
for (let i = 0; i < factories.length; i++) {
|
3146
|
const factory = factories[i];
|
3147
|
this._factories.set(factory.componentType, factory);
|
3148
|
}
|
3149
|
}
|
3150
|
/**
|
3151
|
* @template T
|
3152
|
* @param {?} component
|
3153
|
* @return {?}
|
3154
|
*/
|
3155
|
resolveComponentFactory(component) {
|
3156
|
let /** @type {?} */ factory = this._factories.get(component);
|
3157
|
if (!factory && this._parent) {
|
3158
|
factory = this._parent.resolveComponentFactory(component);
|
3159
|
}
|
3160
|
if (!factory) {
|
3161
|
throw noComponentFactoryError(component);
|
3162
|
}
|
3163
|
return new ComponentFactoryBoundToModule(factory, this._ngModule);
|
3164
|
}
|
3165
|
}
|
3166
|
class ComponentFactoryBoundToModule extends ComponentFactory {
|
3167
|
/**
|
3168
|
* @param {?} factory
|
3169
|
* @param {?} ngModule
|
3170
|
*/
|
3171
|
constructor(factory, ngModule) {
|
3172
|
super();
|
3173
|
this.factory = factory;
|
3174
|
this.ngModule = ngModule;
|
3175
|
}
|
3176
|
/**
|
3177
|
* @return {?}
|
3178
|
*/
|
3179
|
get selector() { return this.factory.selector; }
|
3180
|
/**
|
3181
|
* @return {?}
|
3182
|
*/
|
3183
|
get componentType() { return this.factory.componentType; }
|
3184
|
/**
|
3185
|
* @return {?}
|
3186
|
*/
|
3187
|
get ngContentSelectors() { return this.factory.ngContentSelectors; }
|
3188
|
/**
|
3189
|
* @return {?}
|
3190
|
*/
|
3191
|
get inputs() { return this.factory.inputs; }
|
3192
|
/**
|
3193
|
* @return {?}
|
3194
|
*/
|
3195
|
get outputs() { return this.factory.outputs; }
|
3196
|
/**
|
3197
|
* @param {?} injector
|
3198
|
* @param {?=} projectableNodes
|
3199
|
* @param {?=} rootSelectorOrNode
|
3200
|
* @param {?=} ngModule
|
3201
|
* @return {?}
|
3202
|
*/
|
3203
|
create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
|
3204
|
return this.factory.create(injector, projectableNodes, rootSelectorOrNode, ngModule || this.ngModule);
|
3205
|
}
|
3206
|
}
|
3207
|
|
3208
|
/**
|
3209
|
* @license
|
3210
|
* Copyright Google Inc. All Rights Reserved.
|
3211
|
*
|
3212
|
* Use of this source code is governed by an MIT-style license that can be
|
3213
|
* found in the LICENSE file at https://angular.io/license
|
3214
|
*/
|
3215
|
/**
|
3216
|
* Represents an instance of an NgModule created via a {\@link NgModuleFactory}.
|
3217
|
*
|
3218
|
* `NgModuleRef` provides access to the NgModule Instance as well other objects related to this
|
3219
|
* NgModule Instance.
|
3220
|
*
|
3221
|
* \@stable
|
3222
|
* @abstract
|
3223
|
*/
|
3224
|
class NgModuleRef {
|
3225
|
/**
|
3226
|
* The injector that contains all of the providers of the NgModule.
|
3227
|
* @abstract
|
3228
|
* @return {?}
|
3229
|
*/
|
3230
|
injector() { }
|
3231
|
/**
|
3232
|
* The ComponentFactoryResolver to get hold of the ComponentFactories
|
3233
|
* declared in the `entryComponents` property of the module.
|
3234
|
* @abstract
|
3235
|
* @return {?}
|
3236
|
*/
|
3237
|
componentFactoryResolver() { }
|
3238
|
/**
|
3239
|
* The NgModule instance.
|
3240
|
* @abstract
|
3241
|
* @return {?}
|
3242
|
*/
|
3243
|
instance() { }
|
3244
|
/**
|
3245
|
* Destroys the module instance and all of the data structures associated with it.
|
3246
|
* @abstract
|
3247
|
* @return {?}
|
3248
|
*/
|
3249
|
destroy() { }
|
3250
|
/**
|
3251
|
* Allows to register a callback that will be called when the module is destroyed.
|
3252
|
* @abstract
|
3253
|
* @param {?} callback
|
3254
|
* @return {?}
|
3255
|
*/
|
3256
|
onDestroy(callback) { }
|
3257
|
}
|
3258
|
/**
|
3259
|
* \@experimental
|
3260
|
* @abstract
|
3261
|
*/
|
3262
|
class NgModuleFactory {
|
3263
|
/**
|
3264
|
* @abstract
|
3265
|
* @return {?}
|
3266
|
*/
|
3267
|
moduleType() { }
|
3268
|
/**
|
3269
|
* @abstract
|
3270
|
* @param {?} parentInjector
|
3271
|
* @return {?}
|
3272
|
*/
|
3273
|
create(parentInjector) { }
|
3274
|
}
|
3275
|
|
3276
|
/**
|
3277
|
* @license
|
3278
|
* Copyright Google Inc. All Rights Reserved.
|
3279
|
*
|
3280
|
* Use of this source code is governed by an MIT-style license that can be
|
3281
|
* found in the LICENSE file at https://angular.io/license
|
3282
|
*/
|
3283
|
let trace;
|
3284
|
let events;
|
3285
|
/**
|
3286
|
* @return {?}
|
3287
|
*/
|
3288
|
function detectWTF() {
|
3289
|
const /** @type {?} */ wtf = ((_global) /** TODO #9100 */)['wtf'];
|
3290
|
if (wtf) {
|
3291
|
trace = wtf['trace'];
|
3292
|
if (trace) {
|
3293
|
events = trace['events'];
|
3294
|
return true;
|
3295
|
}
|
3296
|
}
|
3297
|
return false;
|
3298
|
}
|
3299
|
/**
|
3300
|
* @param {?} signature
|
3301
|
* @param {?=} flags
|
3302
|
* @return {?}
|
3303
|
*/
|
3304
|
function createScope$1(signature, flags = null) {
|
3305
|
return events.createScope(signature, flags);
|
3306
|
}
|
3307
|
/**
|
3308
|
* @template T
|
3309
|
* @param {?} scope
|
3310
|
* @param {?=} returnValue
|
3311
|
* @return {?}
|
3312
|
*/
|
3313
|
function leave(scope, returnValue) {
|
3314
|
trace.leaveScope(scope, returnValue);
|
3315
|
return returnValue;
|
3316
|
}
|
3317
|
/**
|
3318
|
* @param {?} rangeType
|
3319
|
* @param {?} action
|
3320
|
* @return {?}
|
3321
|
*/
|
3322
|
function startTimeRange(rangeType, action) {
|
3323
|
return trace.beginTimeRange(rangeType, action);
|
3324
|
}
|
3325
|
/**
|
3326
|
* @param {?} range
|
3327
|
* @return {?}
|
3328
|
*/
|
3329
|
function endTimeRange(range) {
|
3330
|
trace.endTimeRange(range);
|
3331
|
}
|
3332
|
|
3333
|
/**
|
3334
|
* @license
|
3335
|
* Copyright Google Inc. All Rights Reserved.
|
3336
|
*
|
3337
|
* Use of this source code is governed by an MIT-style license that can be
|
3338
|
* found in the LICENSE file at https://angular.io/license
|
3339
|
*/
|
3340
|
/**
|
3341
|
* True if WTF is enabled.
|
3342
|
*/
|
3343
|
const wtfEnabled = detectWTF();
|
3344
|
/**
|
3345
|
* @param {?=} arg0
|
3346
|
* @param {?=} arg1
|
3347
|
* @return {?}
|
3348
|
*/
|
3349
|
function noopScope(arg0, arg1) {
|
3350
|
return null;
|
3351
|
}
|
3352
|
/**
|
3353
|
* Create trace scope.
|
3354
|
*
|
3355
|
* Scopes must be strictly nested and are analogous to stack frames, but
|
3356
|
* do not have to follow the stack frames. Instead it is recommended that they follow logical
|
3357
|
* nesting. You may want to use
|
3358
|
* [Event
|
3359
|
* Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
|
3360
|
* as they are defined in WTF.
|
3361
|
*
|
3362
|
* Used to mark scope entry. The return value is used to leave the scope.
|
3363
|
*
|
3364
|
* var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
|
3365
|
*
|
3366
|
* someMethod() {
|
3367
|
* var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
|
3368
|
* // DO SOME WORK HERE
|
3369
|
* return wtfLeave(s, 123); // Return value 123
|
3370
|
* }
|
3371
|
*
|
3372
|
* Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
|
3373
|
* negatively impact the performance of your application. For this reason we recommend that
|
3374
|
* you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
|
3375
|
* so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
|
3376
|
* exception, will produce incorrect trace, but presence of exception signifies logic error which
|
3377
|
* needs to be fixed before the app should be profiled. Add try-finally only when you expect that
|
3378
|
* an exception is expected during normal execution while profiling.
|
3379
|
*
|
3380
|
* \@experimental
|
3381
|
*/
|
3382
|
const wtfCreateScope = wtfEnabled ? createScope$1 : (signature, flags) => noopScope;
|
3383
|
/**
|
3384
|
* Used to mark end of Scope.
|
3385
|
*
|
3386
|
* - `scope` to end.
|
3387
|
* - `returnValue` (optional) to be passed to the WTF.
|
3388
|
*
|
3389
|
* Returns the `returnValue for easy chaining.
|
3390
|
* \@experimental
|
3391
|
*/
|
3392
|
const wtfLeave = wtfEnabled ? leave : (s, r) => r;
|
3393
|
/**
|
3394
|
* Used to mark Async start. Async are similar to scope but they don't have to be strictly nested.
|
3395
|
* The return value is used in the call to [endAsync]. Async ranges only work if WTF has been
|
3396
|
* enabled.
|
3397
|
*
|
3398
|
* someMethod() {
|
3399
|
* var s = wtfStartTimeRange('HTTP:GET', 'some.url');
|
3400
|
* var future = new Future.delay(5).then((_) {
|
3401
|
* wtfEndTimeRange(s);
|
3402
|
* });
|
3403
|
* }
|
3404
|
* \@experimental
|
3405
|
*/
|
3406
|
const wtfStartTimeRange = wtfEnabled ? startTimeRange : (rangeType, action) => null;
|
3407
|
/**
|
3408
|
* Ends a async time range operation.
|
3409
|
* [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been
|
3410
|
* enabled.
|
3411
|
* \@experimental
|
3412
|
*/
|
3413
|
const wtfEndTimeRange = wtfEnabled ? endTimeRange : (r) => null;
|
3414
|
|
3415
|
/**
|
3416
|
* @license
|
3417
|
* Copyright Google Inc. All Rights Reserved.
|
3418
|
*
|
3419
|
* Use of this source code is governed by an MIT-style license that can be
|
3420
|
* found in the LICENSE file at https://angular.io/license
|
3421
|
*/
|
3422
|
/**
|
3423
|
* Use by directives and components to emit custom Events.
|
3424
|
*
|
3425
|
* ### Examples
|
3426
|
*
|
3427
|
* In the following example, `Zippy` alternatively emits `open` and `close` events when its
|
3428
|
* title gets clicked:
|
3429
|
*
|
3430
|
* ```
|
3431
|
* \@Component({
|
3432
|
* selector: 'zippy',
|
3433
|
* template: `
|
3434
|
* <div class="zippy">
|
3435
|
* <div (click)="toggle()">Toggle</div>
|
3436
|
* <div [hidden]="!visible">
|
3437
|
* <ng-content></ng-content>
|
3438
|
* </div>
|
3439
|
* </div>`})
|
3440
|
* export class Zippy {
|
3441
|
* visible: boolean = true;
|
3442
|
* \@Output() open: EventEmitter<any> = new EventEmitter();
|
3443
|
* \@Output() close: EventEmitter<any> = new EventEmitter();
|
3444
|
*
|
3445
|
* toggle() {
|
3446
|
* this.visible = !this.visible;
|
3447
|
* if (this.visible) {
|
3448
|
* this.open.emit(null);
|
3449
|
* } else {
|
3450
|
* this.close.emit(null);
|
3451
|
* }
|
3452
|
* }
|
3453
|
* }
|
3454
|
* ```
|
3455
|
*
|
3456
|
* The events payload can be accessed by the parameter `$event` on the components output event
|
3457
|
* handler:
|
3458
|
*
|
3459
|
* ```
|
3460
|
* <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
|
3461
|
* ```
|
3462
|
*
|
3463
|
* Uses Rx.Observable but provides an adapter to make it work as specified here:
|
3464
|
* https://github.com/jhusain/observable-spec
|
3465
|
*
|
3466
|
* Once a reference implementation of the spec is available, switch to it.
|
3467
|
* \@stable
|
3468
|
*/
|
3469
|
class EventEmitter extends Subject {
|
3470
|
/**
|
3471
|
* Creates an instance of {\@link EventEmitter}, which depending on `isAsync`,
|
3472
|
* delivers events synchronously or asynchronously.
|
3473
|
*
|
3474
|
* @param {?=} isAsync By default, events are delivered synchronously (default value: `false`).
|
3475
|
* Set to `true` for asynchronous event delivery.
|
3476
|
*/
|
3477
|
constructor(isAsync = false) {
|
3478
|
super();
|
3479
|
this.__isAsync = isAsync;
|
3480
|
}
|
3481
|
/**
|
3482
|
* @param {?=} value
|
3483
|
* @return {?}
|
3484
|
*/
|
3485
|
emit(value) { super.next(value); }
|
3486
|
/**
|
3487
|
* @param {?=} generatorOrNext
|
3488
|
* @param {?=} error
|
3489
|
* @param {?=} complete
|
3490
|
* @return {?}
|
3491
|
*/
|
3492
|
subscribe(generatorOrNext, error, complete) {
|
3493
|
let /** @type {?} */ schedulerFn;
|
3494
|
let /** @type {?} */ errorFn = (err) => null;
|
3495
|
let /** @type {?} */ completeFn = () => null;
|
3496
|
if (generatorOrNext && typeof generatorOrNext === 'object') {
|
3497
|
schedulerFn = this.__isAsync ? (value) => {
|
3498
|
setTimeout(() => generatorOrNext.next(value));
|
3499
|
} : (value) => { generatorOrNext.next(value); };
|
3500
|
if (generatorOrNext.error) {
|
3501
|
errorFn = this.__isAsync ? (err) => { setTimeout(() => generatorOrNext.error(err)); } :
|
3502
|
(err) => { generatorOrNext.error(err); };
|
3503
|
}
|
3504
|
if (generatorOrNext.complete) {
|
3505
|
completeFn = this.__isAsync ? () => { setTimeout(() => generatorOrNext.complete()); } :
|
3506
|
() => { generatorOrNext.complete(); };
|
3507
|
}
|
3508
|
}
|
3509
|
else {
|
3510
|
schedulerFn = this.__isAsync ? (value) => { setTimeout(() => generatorOrNext(value)); } :
|
3511
|
(value) => { generatorOrNext(value); };
|
3512
|
if (error) {
|
3513
|
errorFn =
|
3514
|
this.__isAsync ? (err) => { setTimeout(() => error(err)); } : (err) => { error(err); };
|
3515
|
}
|
3516
|
if (complete) {
|
3517
|
completeFn =
|
3518
|
this.__isAsync ? () => { setTimeout(() => complete()); } : () => { complete(); };
|
3519
|
}
|
3520
|
}
|
3521
|
return super.subscribe(schedulerFn, errorFn, completeFn);
|
3522
|
}
|
3523
|
}
|
3524
|
|
3525
|
/**
|
3526
|
* @license
|
3527
|
* Copyright Google Inc. All Rights Reserved.
|
3528
|
*
|
3529
|
* Use of this source code is governed by an MIT-style license that can be
|
3530
|
* found in the LICENSE file at https://angular.io/license
|
3531
|
*/
|
3532
|
/**
|
3533
|
* An injectable service for executing work inside or outside of the Angular zone.
|
3534
|
*
|
3535
|
* The most common use of this service is to optimize performance when starting a work consisting of
|
3536
|
* one or more asynchronous tasks that don't require UI updates or error handling to be handled by
|
3537
|
* Angular. Such tasks can be kicked off via {\@link #runOutsideAngular} and if needed, these tasks
|
3538
|
* can reenter the Angular zone via {\@link #run}.
|
3539
|
*
|
3540
|
* <!-- TODO: add/fix links to:
|
3541
|
* - docs explaining zones and the use of zones in Angular and change-detection
|
3542
|
* - link to runOutsideAngular/run (throughout this file!)
|
3543
|
* -->
|
3544
|
*
|
3545
|
* ### Example
|
3546
|
*
|
3547
|
* ```
|
3548
|
* import {Component, NgZone} from '\@angular/core';
|
3549
|
* import {NgIf} from '\@angular/common';
|
3550
|
*
|
3551
|
* \@Component({
|
3552
|
* selector: 'ng-zone-demo'.
|
3553
|
* template: `
|
3554
|
* <h2>Demo: NgZone</h2>
|
3555
|
*
|
3556
|
* <p>Progress: {{progress}}%</p>
|
3557
|
* <p *ngIf="progress >= 100">Done processing {{label}} of Angular zone!</p>
|
3558
|
*
|
3559
|
* <button (click)="processWithinAngularZone()">Process within Angular zone</button>
|
3560
|
* <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
|
3561
|
* `,
|
3562
|
* })
|
3563
|
* export class NgZoneDemo {
|
3564
|
* progress: number = 0;
|
3565
|
* label: string;
|
3566
|
*
|
3567
|
* constructor(private _ngZone: NgZone) {}
|
3568
|
*
|
3569
|
* // Loop inside the Angular zone
|
3570
|
* // so the UI DOES refresh after each setTimeout cycle
|
3571
|
* processWithinAngularZone() {
|
3572
|
* this.label = 'inside';
|
3573
|
* this.progress = 0;
|
3574
|
* this._increaseProgress(() => console.log('Inside Done!'));
|
3575
|
* }
|
3576
|
*
|
3577
|
* // Loop outside of the Angular zone
|
3578
|
* // so the UI DOES NOT refresh after each setTimeout cycle
|
3579
|
* processOutsideOfAngularZone() {
|
3580
|
* this.label = 'outside';
|
3581
|
* this.progress = 0;
|
3582
|
* this._ngZone.runOutsideAngular(() => {
|
3583
|
* this._increaseProgress(() => {
|
3584
|
* // reenter the Angular zone and display done
|
3585
|
* this._ngZone.run(() => {console.log('Outside Done!') });
|
3586
|
* }}));
|
3587
|
* }
|
3588
|
*
|
3589
|
* _increaseProgress(doneCallback: () => void) {
|
3590
|
* this.progress += 1;
|
3591
|
* console.log(`Current progress: ${this.progress}%`);
|
3592
|
*
|
3593
|
* if (this.progress < 100) {
|
3594
|
* window.setTimeout(() => this._increaseProgress(doneCallback)), 10)
|
3595
|
* } else {
|
3596
|
* doneCallback();
|
3597
|
* }
|
3598
|
* }
|
3599
|
* }
|
3600
|
* ```
|
3601
|
*
|
3602
|
* \@experimental
|
3603
|
*/
|
3604
|
class NgZone {
|
3605
|
/**
|
3606
|
* @param {?} __0
|
3607
|
*/
|
3608
|
constructor({ enableLongStackTrace = false }) {
|
3609
|
this.hasPendingMicrotasks = false;
|
3610
|
this.hasPendingMacrotasks = false;
|
3611
|
/**
|
3612
|
* Whether there are no outstanding microtasks or macrotasks.
|
3613
|
*/
|
3614
|
this.isStable = true;
|
3615
|
/**
|
3616
|
* Notifies when code enters Angular Zone. This gets fired first on VM Turn.
|
3617
|
*/
|
3618
|
this.onUnstable = new EventEmitter(false);
|
3619
|
/**
|
3620
|
* Notifies when there is no more microtasks enqueue in the current VM Turn.
|
3621
|
* This is a hint for Angular to do change detection, which may enqueue more microtasks.
|
3622
|
* For this reason this event can fire multiple times per VM Turn.
|
3623
|
*/
|
3624
|
this.onMicrotaskEmpty = new EventEmitter(false);
|
3625
|
/**
|
3626
|
* Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
|
3627
|
* implies we are about to relinquish VM turn.
|
3628
|
* This event gets called just once.
|
3629
|
*/
|
3630
|
this.onStable = new EventEmitter(false);
|
3631
|
/**
|
3632
|
* Notifies that an error has been delivered.
|
3633
|
*/
|
3634
|
this.onError = new EventEmitter(false);
|
3635
|
if (typeof Zone == 'undefined') {
|
3636
|
throw new Error('Angular requires Zone.js prolyfill.');
|
3637
|
}
|
3638
|
Zone.assertZonePatched();
|
3639
|
const self = this;
|
3640
|
self._nesting = 0;
|
3641
|
self._outer = self._inner = Zone.current;
|
3642
|
if (Zone['wtfZoneSpec']) {
|
3643
|
self._inner = self._inner.fork(Zone['wtfZoneSpec']);
|
3644
|
}
|
3645
|
if (enableLongStackTrace && Zone['longStackTraceZoneSpec']) {
|
3646
|
self._inner = self._inner.fork(Zone['longStackTraceZoneSpec']);
|
3647
|
}
|
3648
|
forkInnerZoneWithAngularBehavior(self);
|
3649
|
}
|
3650
|
/**
|
3651
|
* @return {?}
|
3652
|
*/
|
3653
|
static isInAngularZone() { return Zone.current.get('isAngularZone') === true; }
|
3654
|
/**
|
3655
|
* @return {?}
|
3656
|
*/
|
3657
|
static assertInAngularZone() {
|
3658
|
if (!NgZone.isInAngularZone()) {
|
3659
|
throw new Error('Expected to be in Angular Zone, but it is not!');
|
3660
|
}
|
3661
|
}
|
3662
|
/**
|
3663
|
* @return {?}
|
3664
|
*/
|
3665
|
static assertNotInAngularZone() {
|
3666
|
if (NgZone.isInAngularZone()) {
|
3667
|
throw new Error('Expected to not be in Angular Zone, but it is!');
|
3668
|
}
|
3669
|
}
|
3670
|
/**
|
3671
|
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
|
3672
|
* the function.
|
3673
|
*
|
3674
|
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
|
3675
|
* outside of the Angular zone (typically started via {\@link #runOutsideAngular}).
|
3676
|
*
|
3677
|
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
3678
|
* within the Angular zone.
|
3679
|
*
|
3680
|
* If a synchronous error happens it will be rethrown and not reported via `onError`.
|
3681
|
* @param {?} fn
|
3682
|
* @return {?}
|
3683
|
*/
|
3684
|
run(fn) { return (((this)))._inner.run(fn); }
|
3685
|
/**
|
3686
|
* Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
|
3687
|
* rethrown.
|
3688
|
* @param {?} fn
|
3689
|
* @return {?}
|
3690
|
*/
|
3691
|
runGuarded(fn) { return (((this)))._inner.runGuarded(fn); }
|
3692
|
/**
|
3693
|
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
|
3694
|
* the function.
|
3695
|
*
|
3696
|
* Running functions via {\@link #runOutsideAngular} allows you to escape Angular's zone and do
|
3697
|
* work that
|
3698
|
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
|
3699
|
*
|
3700
|
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
3701
|
* outside of the Angular zone.
|
3702
|
*
|
3703
|
* Use {\@link #run} to reenter the Angular zone and do work that updates the application model.
|
3704
|
* @param {?} fn
|
3705
|
* @return {?}
|
3706
|
*/
|
3707
|
runOutsideAngular(fn) { return (((this)))._outer.run(fn); }
|
3708
|
}
|
3709
|
/**
|
3710
|
* @param {?} zone
|
3711
|
* @return {?}
|
3712
|
*/
|
3713
|
function checkStable(zone) {
|
3714
|
if (zone._nesting == 0 && !zone.hasPendingMicrotasks && !zone.isStable) {
|
3715
|
try {
|
3716
|
zone._nesting++;
|
3717
|
zone.onMicrotaskEmpty.emit(null);
|
3718
|
}
|
3719
|
finally {
|
3720
|
zone._nesting--;
|
3721
|
if (!zone.hasPendingMicrotasks) {
|
3722
|
try {
|
3723
|
zone.runOutsideAngular(() => zone.onStable.emit(null));
|
3724
|
}
|
3725
|
finally {
|
3726
|
zone.isStable = true;
|
3727
|
}
|
3728
|
}
|
3729
|
}
|
3730
|
}
|
3731
|
}
|
3732
|
/**
|
3733
|
* @param {?} zone
|
3734
|
* @return {?}
|
3735
|
*/
|
3736
|
function forkInnerZoneWithAngularBehavior(zone) {
|
3737
|
zone._inner = zone._inner.fork({
|
3738
|
name: 'angular',
|
3739
|
properties: /** @type {?} */ ({ 'isAngularZone': true }),
|
3740
|
onInvokeTask: (delegate, current, target, task, applyThis, applyArgs) => {
|
3741
|
try {
|
3742
|
onEnter(zone);
|
3743
|
return delegate.invokeTask(target, task, applyThis, applyArgs);
|
3744
|
}
|
3745
|
finally {
|
3746
|
onLeave(zone);
|
3747
|
}
|
3748
|
},
|
3749
|
onInvoke: (delegate, current, target, callback, applyThis, applyArgs, source) => {
|
3750
|
try {
|
3751
|
onEnter(zone);
|
3752
|
return delegate.invoke(target, callback, applyThis, applyArgs, source);
|
3753
|
}
|
3754
|
finally {
|
3755
|
onLeave(zone);
|
3756
|
}
|
3757
|
},
|
3758
|
onHasTask: (delegate, current, target, hasTaskState) => {
|
3759
|
delegate.hasTask(target, hasTaskState);
|
3760
|
if (current === target) {
|
3761
|
// We are only interested in hasTask events which originate from our zone
|
3762
|
// (A child hasTask event is not interesting to us)
|
3763
|
if (hasTaskState.change == 'microTask') {
|
3764
|
zone.hasPendingMicrotasks = hasTaskState.microTask;
|
3765
|
checkStable(zone);
|
3766
|
}
|
3767
|
else if (hasTaskState.change == 'macroTask') {
|
3768
|
zone.hasPendingMacrotasks = hasTaskState.macroTask;
|
3769
|
}
|
3770
|
}
|
3771
|
},
|
3772
|
onHandleError: (delegate, current, target, error) => {
|
3773
|
delegate.handleError(target, error);
|
3774
|
zone.runOutsideAngular(() => zone.onError.emit(error));
|
3775
|
return false;
|
3776
|
}
|
3777
|
});
|
3778
|
}
|
3779
|
/**
|
3780
|
* @param {?} zone
|
3781
|
* @return {?}
|
3782
|
*/
|
3783
|
function onEnter(zone) {
|
3784
|
zone._nesting++;
|
3785
|
if (zone.isStable) {
|
3786
|
zone.isStable = false;
|
3787
|
zone.onUnstable.emit(null);
|
3788
|
}
|
3789
|
}
|
3790
|
/**
|
3791
|
* @param {?} zone
|
3792
|
* @return {?}
|
3793
|
*/
|
3794
|
function onLeave(zone) {
|
3795
|
zone._nesting--;
|
3796
|
checkStable(zone);
|
3797
|
}
|
3798
|
|
3799
|
/**
|
3800
|
* @license
|
3801
|
* Copyright Google Inc. All Rights Reserved.
|
3802
|
*
|
3803
|
* Use of this source code is governed by an MIT-style license that can be
|
3804
|
* found in the LICENSE file at https://angular.io/license
|
3805
|
*/
|
3806
|
/**
|
3807
|
* The Testability service provides testing hooks that can be accessed from
|
3808
|
* the browser and by services such as Protractor. Each bootstrapped Angular
|
3809
|
* application on the page will have an instance of Testability.
|
3810
|
* \@experimental
|
3811
|
*/
|
3812
|
class Testability {
|
3813
|
/**
|
3814
|
* @param {?} _ngZone
|
3815
|
*/
|
3816
|
constructor(_ngZone) {
|
3817
|
this._ngZone = _ngZone;
|
3818
|
/**
|
3819
|
* \@internal
|
3820
|
*/
|
3821
|
this._pendingCount = 0;
|
3822
|
/**
|
3823
|
* \@internal
|
3824
|
*/
|
3825
|
this._isZoneStable = true;
|
3826
|
/**
|
3827
|
* Whether any work was done since the last 'whenStable' callback. This is
|
3828
|
* useful to detect if this could have potentially destabilized another
|
3829
|
* component while it is stabilizing.
|
3830
|
* \@internal
|
3831
|
*/
|
3832
|
this._didWork = false;
|
3833
|
/**
|
3834
|
* \@internal
|
3835
|
*/
|
3836
|
this._callbacks = [];
|
3837
|
this._watchAngularEvents();
|
3838
|
}
|
3839
|
/**
|
3840
|
* \@internal
|
3841
|
* @return {?}
|
3842
|
*/
|
3843
|
_watchAngularEvents() {
|
3844
|
this._ngZone.onUnstable.subscribe({
|
3845
|
next: () => {
|
3846
|
this._didWork = true;
|
3847
|
this._isZoneStable = false;
|
3848
|
}
|
3849
|
});
|
3850
|
this._ngZone.runOutsideAngular(() => {
|
3851
|
this._ngZone.onStable.subscribe({
|
3852
|
next: () => {
|
3853
|
NgZone.assertNotInAngularZone();
|
3854
|
scheduleMicroTask(() => {
|
3855
|
this._isZoneStable = true;
|
3856
|
this._runCallbacksIfReady();
|
3857
|
});
|
3858
|
}
|
3859
|
});
|
3860
|
});
|
3861
|
}
|
3862
|
/**
|
3863
|
* @return {?}
|
3864
|
*/
|
3865
|
increasePendingRequestCount() {
|
3866
|
this._pendingCount += 1;
|
3867
|
this._didWork = true;
|
3868
|
return this._pendingCount;
|
3869
|
}
|
3870
|
/**
|
3871
|
* @return {?}
|
3872
|
*/
|
3873
|
decreasePendingRequestCount() {
|
3874
|
this._pendingCount -= 1;
|
3875
|
if (this._pendingCount < 0) {
|
3876
|
throw new Error('pending async requests below zero');
|
3877
|
}
|
3878
|
this._runCallbacksIfReady();
|
3879
|
return this._pendingCount;
|
3880
|
}
|
3881
|
/**
|
3882
|
* @return {?}
|
3883
|
*/
|
3884
|
isStable() {
|
3885
|
return this._isZoneStable && this._pendingCount == 0 && !this._ngZone.hasPendingMacrotasks;
|
3886
|
}
|
3887
|
/**
|
3888
|
* \@internal
|
3889
|
* @return {?}
|
3890
|
*/
|
3891
|
_runCallbacksIfReady() {
|
3892
|
if (this.isStable()) {
|
3893
|
// Schedules the call backs in a new frame so that it is always async.
|
3894
|
scheduleMicroTask(() => {
|
3895
|
while (this._callbacks.length !== 0) {
|
3896
|
(((this._callbacks.pop())))(this._didWork);
|
3897
|
}
|
3898
|
this._didWork = false;
|
3899
|
});
|
3900
|
}
|
3901
|
else {
|
3902
|
// Not Ready
|
3903
|
this._didWork = true;
|
3904
|
}
|
3905
|
}
|
3906
|
/**
|
3907
|
* @param {?} callback
|
3908
|
* @return {?}
|
3909
|
*/
|
3910
|
whenStable(callback) {
|
3911
|
this._callbacks.push(callback);
|
3912
|
this._runCallbacksIfReady();
|
3913
|
}
|
3914
|
/**
|
3915
|
* @return {?}
|
3916
|
*/
|
3917
|
getPendingRequestCount() { return this._pendingCount; }
|
3918
|
/**
|
3919
|
* @deprecated use findProviders
|
3920
|
* @param {?} using
|
3921
|
* @param {?} provider
|
3922
|
* @param {?} exactMatch
|
3923
|
* @return {?}
|
3924
|
*/
|
3925
|
findBindings(using, provider, exactMatch) {
|
3926
|
// TODO(juliemr): implement.
|
3927
|
return [];
|
3928
|
}
|
3929
|
/**
|
3930
|
* @param {?} using
|
3931
|
* @param {?} provider
|
3932
|
* @param {?} exactMatch
|
3933
|
* @return {?}
|
3934
|
*/
|
3935
|
findProviders(using, provider, exactMatch) {
|
3936
|
// TODO(juliemr): implement.
|
3937
|
return [];
|
3938
|
}
|
3939
|
}
|
3940
|
Testability.decorators = [
|
3941
|
{ type: Injectable },
|
3942
|
];
|
3943
|
/**
|
3944
|
* @nocollapse
|
3945
|
*/
|
3946
|
Testability.ctorParameters = () => [
|
3947
|
{ type: NgZone, },
|
3948
|
];
|
3949
|
/**
|
3950
|
* A global registry of {\@link Testability} instances for specific elements.
|
3951
|
* \@experimental
|
3952
|
*/
|
3953
|
class TestabilityRegistry {
|
3954
|
constructor() {
|
3955
|
/**
|
3956
|
* \@internal
|
3957
|
*/
|
3958
|
this._applications = new Map();
|
3959
|
_testabilityGetter.addToWindow(this);
|
3960
|
}
|
3961
|
/**
|
3962
|
* @param {?} token
|
3963
|
* @param {?} testability
|
3964
|
* @return {?}
|
3965
|
*/
|
3966
|
registerApplication(token, testability) {
|
3967
|
this._applications.set(token, testability);
|
3968
|
}
|
3969
|
/**
|
3970
|
* @param {?} elem
|
3971
|
* @return {?}
|
3972
|
*/
|
3973
|
getTestability(elem) { return this._applications.get(elem) || null; }
|
3974
|
/**
|
3975
|
* @return {?}
|
3976
|
*/
|
3977
|
getAllTestabilities() { return Array.from(this._applications.values()); }
|
3978
|
/**
|
3979
|
* @return {?}
|
3980
|
*/
|
3981
|
getAllRootElements() { return Array.from(this._applications.keys()); }
|
3982
|
/**
|
3983
|
* @param {?} elem
|
3984
|
* @param {?=} findInAncestors
|
3985
|
* @return {?}
|
3986
|
*/
|
3987
|
findTestabilityInTree(elem, findInAncestors = true) {
|
3988
|
return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
|
3989
|
}
|
3990
|
}
|
3991
|
TestabilityRegistry.decorators = [
|
3992
|
{ type: Injectable },
|
3993
|
];
|
3994
|
/**
|
3995
|
* @nocollapse
|
3996
|
*/
|
3997
|
TestabilityRegistry.ctorParameters = () => [];
|
3998
|
class _NoopGetTestability {
|
3999
|
/**
|
4000
|
* @param {?} registry
|
4001
|
* @return {?}
|
4002
|
*/
|
4003
|
addToWindow(registry) { }
|
4004
|
/**
|
4005
|
* @param {?} registry
|
4006
|
* @param {?} elem
|
4007
|
* @param {?} findInAncestors
|
4008
|
* @return {?}
|
4009
|
*/
|
4010
|
findTestabilityInTree(registry, elem, findInAncestors) {
|
4011
|
return null;
|
4012
|
}
|
4013
|
}
|
4014
|
/**
|
4015
|
* Set the {\@link GetTestability} implementation used by the Angular testing framework.
|
4016
|
* \@experimental
|
4017
|
* @param {?} getter
|
4018
|
* @return {?}
|
4019
|
*/
|
4020
|
function setTestabilityGetter(getter) {
|
4021
|
_testabilityGetter = getter;
|
4022
|
}
|
4023
|
let _testabilityGetter = new _NoopGetTestability();
|
4024
|
|
4025
|
/**
|
4026
|
* @license
|
4027
|
* Copyright Google Inc. All Rights Reserved.
|
4028
|
*
|
4029
|
* Use of this source code is governed by an MIT-style license that can be
|
4030
|
* found in the LICENSE file at https://angular.io/license
|
4031
|
*/
|
4032
|
let _devMode = true;
|
4033
|
let _runModeLocked = false;
|
4034
|
let _platform;
|
4035
|
const ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
|
4036
|
/**
|
4037
|
* Disable Angular's development mode, which turns off assertions and other
|
4038
|
* checks within the framework.
|
4039
|
*
|
4040
|
* One important assertion this disables verifies that a change detection pass
|
4041
|
* does not result in additional changes to any bindings (also known as
|
4042
|
* unidirectional data flow).
|
4043
|
*
|
4044
|
* \@stable
|
4045
|
* @return {?}
|
4046
|
*/
|
4047
|
function enableProdMode() {
|
4048
|
if (_runModeLocked) {
|
4049
|
throw new Error('Cannot enable prod mode after platform setup.');
|
4050
|
}
|
4051
|
_devMode = false;
|
4052
|
}
|
4053
|
/**
|
4054
|
* Returns whether Angular is in development mode. After called once,
|
4055
|
* the value is locked and won't change any more.
|
4056
|
*
|
4057
|
* By default, this is true, unless a user calls `enableProdMode` before calling this.
|
4058
|
*
|
4059
|
* \@experimental APIs related to application bootstrap are currently under review.
|
4060
|
* @return {?}
|
4061
|
*/
|
4062
|
function isDevMode() {
|
4063
|
_runModeLocked = true;
|
4064
|
return _devMode;
|
4065
|
}
|
4066
|
/**
|
4067
|
* A token for third-party components that can register themselves with NgProbe.
|
4068
|
*
|
4069
|
* \@experimental
|
4070
|
*/
|
4071
|
class NgProbeToken {
|
4072
|
/**
|
4073
|
* @param {?} name
|
4074
|
* @param {?} token
|
4075
|
*/
|
4076
|
constructor(name, token) {
|
4077
|
this.name = name;
|
4078
|
this.token = token;
|
4079
|
}
|
4080
|
}
|
4081
|
/**
|
4082
|
* Creates a platform.
|
4083
|
* Platforms have to be eagerly created via this function.
|
4084
|
*
|
4085
|
* \@experimental APIs related to application bootstrap are currently under review.
|
4086
|
* @param {?} injector
|
4087
|
* @return {?}
|
4088
|
*/
|
4089
|
function createPlatform(injector) {
|
4090
|
if (_platform && !_platform.destroyed &&
|
4091
|
!_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
|
4092
|
throw new Error('There can be only one platform. Destroy the previous one to create a new one.');
|
4093
|
}
|
4094
|
_platform = injector.get(PlatformRef);
|
4095
|
const /** @type {?} */ inits = injector.get(PLATFORM_INITIALIZER, null);
|
4096
|
if (inits)
|
4097
|
inits.forEach((init) => init());
|
4098
|
return _platform;
|
4099
|
}
|
4100
|
/**
|
4101
|
* Creates a factory for a platform
|
4102
|
*
|
4103
|
* \@experimental APIs related to application bootstrap are currently under review.
|
4104
|
* @param {?} parentPlatformFactory
|
4105
|
* @param {?} name
|
4106
|
* @param {?=} providers
|
4107
|
* @return {?}
|
4108
|
*/
|
4109
|
function createPlatformFactory(parentPlatformFactory, name, providers = []) {
|
4110
|
const /** @type {?} */ marker = new InjectionToken(`Platform: ${name}`);
|
4111
|
return (extraProviders = []) => {
|
4112
|
let /** @type {?} */ platform = getPlatform();
|
4113
|
if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
|
4114
|
if (parentPlatformFactory) {
|
4115
|
parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
|
4116
|
}
|
4117
|
else {
|
4118
|
createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
|
4119
|
}
|
4120
|
}
|
4121
|
return assertPlatform(marker);
|
4122
|
};
|
4123
|
}
|
4124
|
/**
|
4125
|
* Checks that there currently is a platform which contains the given token as a provider.
|
4126
|
*
|
4127
|
* \@experimental APIs related to application bootstrap are currently under review.
|
4128
|
* @param {?} requiredToken
|
4129
|
* @return {?}
|
4130
|
*/
|
4131
|
function assertPlatform(requiredToken) {
|
4132
|
const /** @type {?} */ platform = getPlatform();
|
4133
|
if (!platform) {
|
4134
|
throw new Error('No platform exists!');
|
4135
|
}
|
4136
|
if (!platform.injector.get(requiredToken, null)) {
|
4137
|
throw new Error('A platform with a different configuration has been created. Please destroy it first.');
|
4138
|
}
|
4139
|
return platform;
|
4140
|
}
|
4141
|
/**
|
4142
|
* Destroy the existing platform.
|
4143
|
*
|
4144
|
* \@experimental APIs related to application bootstrap are currently under review.
|
4145
|
* @return {?}
|
4146
|
*/
|
4147
|
function destroyPlatform() {
|
4148
|
if (_platform && !_platform.destroyed) {
|
4149
|
_platform.destroy();
|
4150
|
}
|
4151
|
}
|
4152
|
/**
|
4153
|
* Returns the current platform.
|
4154
|
*
|
4155
|
* \@experimental APIs related to application bootstrap are currently under review.
|
4156
|
* @return {?}
|
4157
|
*/
|
4158
|
function getPlatform() {
|
4159
|
return _platform && !_platform.destroyed ? _platform : null;
|
4160
|
}
|
4161
|
/**
|
4162
|
* The Angular platform is the entry point for Angular on a web page. Each page
|
4163
|
* has exactly one platform, and services (such as reflection) which are common
|
4164
|
* to every Angular application running on the page are bound in its scope.
|
4165
|
*
|
4166
|
* A page's platform is initialized implicitly when a platform is created via a platform factory
|
4167
|
* (e.g. {\@link platformBrowser}), or explicitly by calling the {\@link createPlatform} function.
|
4168
|
*
|
4169
|
* \@stable
|
4170
|
* @abstract
|
4171
|
*/
|
4172
|
class PlatformRef {
|
4173
|
/**
|
4174
|
* Creates an instance of an `\@NgModule` for the given platform
|
4175
|
* for offline compilation.
|
4176
|
*
|
4177
|
* ## Simple Example
|
4178
|
*
|
4179
|
* ```typescript
|
4180
|
* my_module.ts:
|
4181
|
*
|
4182
|
* \@NgModule({
|
4183
|
* imports: [BrowserModule]
|
4184
|
* })
|
4185
|
* class MyModule {}
|
4186
|
*
|
4187
|
* main.ts:
|
4188
|
* import {MyModuleNgFactory} from './my_module.ngfactory';
|
4189
|
* import {platformBrowser} from '\@angular/platform-browser';
|
4190
|
*
|
4191
|
* let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
|
4192
|
* ```
|
4193
|
*
|
4194
|
* \@experimental APIs related to application bootstrap are currently under review.
|
4195
|
* @abstract
|
4196
|
* @template M
|
4197
|
* @param {?} moduleFactory
|
4198
|
* @return {?}
|
4199
|
*/
|
4200
|
bootstrapModuleFactory(moduleFactory) { }
|
4201
|
/**
|
4202
|
* Creates an instance of an `\@NgModule` for a given platform using the given runtime compiler.
|
4203
|
*
|
4204
|
* ## Simple Example
|
4205
|
*
|
4206
|
* ```typescript
|
4207
|
* \@NgModule({
|
4208
|
* imports: [BrowserModule]
|
4209
|
* })
|
4210
|
* class MyModule {}
|
4211
|
*
|
4212
|
* let moduleRef = platformBrowser().bootstrapModule(MyModule);
|
4213
|
* ```
|
4214
|
* \@stable
|
4215
|
* @abstract
|
4216
|
* @template M
|
4217
|
* @param {?} moduleType
|
4218
|
* @param {?=} compilerOptions
|
4219
|
* @return {?}
|
4220
|
*/
|
4221
|
bootstrapModule(moduleType, compilerOptions) { }
|
4222
|
/**
|
4223
|
* Register a listener to be called when the platform is disposed.
|
4224
|
* @abstract
|
4225
|
* @param {?} callback
|
4226
|
* @return {?}
|
4227
|
*/
|
4228
|
onDestroy(callback) { }
|
4229
|
/**
|
4230
|
* Retrieve the platform {\@link Injector}, which is the parent injector for
|
4231
|
* every Angular application on the page and provides singleton providers.
|
4232
|
* @abstract
|
4233
|
* @return {?}
|
4234
|
*/
|
4235
|
injector() { }
|
4236
|
/**
|
4237
|
* Destroy the Angular platform and all Angular applications on the page.
|
4238
|
* @abstract
|
4239
|
* @return {?}
|
4240
|
*/
|
4241
|
destroy() { }
|
4242
|
/**
|
4243
|
* @abstract
|
4244
|
* @return {?}
|
4245
|
*/
|
4246
|
destroyed() { }
|
4247
|
}
|
4248
|
/**
|
4249
|
* @param {?} errorHandler
|
4250
|
* @param {?} ngZone
|
4251
|
* @param {?} callback
|
4252
|
* @return {?}
|
4253
|
*/
|
4254
|
function _callAndReportToErrorHandler(errorHandler, ngZone, callback) {
|
4255
|
try {
|
4256
|
const /** @type {?} */ result = callback();
|
4257
|
if (isPromise(result)) {
|
4258
|
return result.catch((e) => {
|
4259
|
ngZone.runOutsideAngular(() => errorHandler.handleError(e));
|
4260
|
// rethrow as the exception handler might not do it
|
4261
|
throw e;
|
4262
|
});
|
4263
|
}
|
4264
|
return result;
|
4265
|
}
|
4266
|
catch (e) {
|
4267
|
ngZone.runOutsideAngular(() => errorHandler.handleError(e));
|
4268
|
// rethrow as the exception handler might not do it
|
4269
|
throw e;
|
4270
|
}
|
4271
|
}
|
4272
|
/**
|
4273
|
* workaround https://github.com/angular/tsickle/issues/350
|
4274
|
* @suppress {checkTypes}
|
4275
|
*/
|
4276
|
class PlatformRef_ extends PlatformRef {
|
4277
|
/**
|
4278
|
* @param {?} _injector
|
4279
|
*/
|
4280
|
constructor(_injector) {
|
4281
|
super();
|
4282
|
this._injector = _injector;
|
4283
|
this._modules = [];
|
4284
|
this._destroyListeners = [];
|
4285
|
this._destroyed = false;
|
4286
|
}
|
4287
|
/**
|
4288
|
* @param {?} callback
|
4289
|
* @return {?}
|
4290
|
*/
|
4291
|
onDestroy(callback) { this._destroyListeners.push(callback); }
|
4292
|
/**
|
4293
|
* @return {?}
|
4294
|
*/
|
4295
|
get injector() { return this._injector; }
|
4296
|
/**
|
4297
|
* @return {?}
|
4298
|
*/
|
4299
|
get destroyed() { return this._destroyed; }
|
4300
|
/**
|
4301
|
* @return {?}
|
4302
|
*/
|
4303
|
destroy() {
|
4304
|
if (this._destroyed) {
|
4305
|
throw new Error('The platform has already been destroyed!');
|
4306
|
}
|
4307
|
this._modules.slice().forEach(module => module.destroy());
|
4308
|
this._destroyListeners.forEach(listener => listener());
|
4309
|
this._destroyed = true;
|
4310
|
}
|
4311
|
/**
|
4312
|
* @template M
|
4313
|
* @param {?} moduleFactory
|
4314
|
* @return {?}
|
4315
|
*/
|
4316
|
bootstrapModuleFactory(moduleFactory) {
|
4317
|
return this._bootstrapModuleFactoryWithZone(moduleFactory);
|
4318
|
}
|
4319
|
/**
|
4320
|
* @template M
|
4321
|
* @param {?} moduleFactory
|
4322
|
* @param {?=} ngZone
|
4323
|
* @return {?}
|
4324
|
*/
|
4325
|
_bootstrapModuleFactoryWithZone(moduleFactory, ngZone) {
|
4326
|
// Note: We need to create the NgZone _before_ we instantiate the module,
|
4327
|
// as instantiating the module creates some providers eagerly.
|
4328
|
// So we create a mini parent injector that just contains the new NgZone and
|
4329
|
// pass that as parent to the NgModuleFactory.
|
4330
|
if (!ngZone)
|
4331
|
ngZone = new NgZone({ enableLongStackTrace: isDevMode() });
|
4332
|
// Attention: Don't use ApplicationRef.run here,
|
4333
|
// as we want to be sure that all possible constructor calls are inside `ngZone.run`!
|
4334
|
return ngZone.run(() => {
|
4335
|
const /** @type {?} */ ngZoneInjector = ReflectiveInjector.resolveAndCreate([{ provide: NgZone, useValue: ngZone }], this.injector);
|
4336
|
const /** @type {?} */ moduleRef = (moduleFactory.create(ngZoneInjector));
|
4337
|
const /** @type {?} */ exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
|
4338
|
if (!exceptionHandler) {
|
4339
|
throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
|
4340
|
}
|
4341
|
moduleRef.onDestroy(() => remove(this._modules, moduleRef)); /** @type {?} */
|
4342
|
((ngZone)).runOutsideAngular(() => ((ngZone)).onError.subscribe({ next: (error) => { exceptionHandler.handleError(error); } }));
|
4343
|
return _callAndReportToErrorHandler(exceptionHandler, /** @type {?} */ ((ngZone)), () => {
|
4344
|
const /** @type {?} */ initStatus = moduleRef.injector.get(ApplicationInitStatus);
|
4345
|
initStatus.runInitializers();
|
4346
|
return initStatus.donePromise.then(() => {
|
4347
|
this._moduleDoBootstrap(moduleRef);
|
4348
|
return moduleRef;
|
4349
|
});
|
4350
|
});
|
4351
|
});
|
4352
|
}
|
4353
|
/**
|
4354
|
* @template M
|
4355
|
* @param {?} moduleType
|
4356
|
* @param {?=} compilerOptions
|
4357
|
* @return {?}
|
4358
|
*/
|
4359
|
bootstrapModule(moduleType, compilerOptions = []) {
|
4360
|
return this._bootstrapModuleWithZone(moduleType, compilerOptions);
|
4361
|
}
|
4362
|
/**
|
4363
|
* @template M
|
4364
|
* @param {?} moduleType
|
4365
|
* @param {?=} compilerOptions
|
4366
|
* @param {?=} ngZone
|
4367
|
* @return {?}
|
4368
|
*/
|
4369
|
_bootstrapModuleWithZone(moduleType, compilerOptions = [], ngZone) {
|
4370
|
const /** @type {?} */ compilerFactory = this.injector.get(CompilerFactory);
|
4371
|
const /** @type {?} */ compiler = compilerFactory.createCompiler(Array.isArray(compilerOptions) ? compilerOptions : [compilerOptions]);
|
4372
|
return compiler.compileModuleAsync(moduleType)
|
4373
|
.then((moduleFactory) => this._bootstrapModuleFactoryWithZone(moduleFactory, ngZone));
|
4374
|
}
|
4375
|
/**
|
4376
|
* @param {?} moduleRef
|
4377
|
* @return {?}
|
4378
|
*/
|
4379
|
_moduleDoBootstrap(moduleRef) {
|
4380
|
const /** @type {?} */ appRef = (moduleRef.injector.get(ApplicationRef));
|
4381
|
if (moduleRef._bootstrapComponents.length > 0) {
|
4382
|
moduleRef._bootstrapComponents.forEach(f => appRef.bootstrap(f));
|
4383
|
}
|
4384
|
else if (moduleRef.instance.ngDoBootstrap) {
|
4385
|
moduleRef.instance.ngDoBootstrap(appRef);
|
4386
|
}
|
4387
|
else {
|
4388
|
throw new Error(`The module ${stringify(moduleRef.instance.constructor)} was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` +
|
4389
|
`Please define one of these.`);
|
4390
|
}
|
4391
|
this._modules.push(moduleRef);
|
4392
|
}
|
4393
|
}
|
4394
|
PlatformRef_.decorators = [
|
4395
|
{ type: Injectable },
|
4396
|
];
|
4397
|
/**
|
4398
|
* @nocollapse
|
4399
|
*/
|
4400
|
PlatformRef_.ctorParameters = () => [
|
4401
|
{ type: Injector, },
|
4402
|
];
|
4403
|
/**
|
4404
|
* A reference to an Angular application running on a page.
|
4405
|
*
|
4406
|
* \@stable
|
4407
|
* @abstract
|
4408
|
*/
|
4409
|
class ApplicationRef {
|
4410
|
/**
|
4411
|
* Bootstrap a new component at the root level of the application.
|
4412
|
*
|
4413
|
* ### Bootstrap process
|
4414
|
*
|
4415
|
* When bootstrapping a new root component into an application, Angular mounts the
|
4416
|
* specified application component onto DOM elements identified by the [componentType]'s
|
4417
|
* selector and kicks off automatic change detection to finish initializing the component.
|
4418
|
*
|
4419
|
* Optionally, a component can be mounted onto a DOM element that does not match the
|
4420
|
* [componentType]'s selector.
|
4421
|
*
|
4422
|
* ### Example
|
4423
|
* {\@example core/ts/platform/platform.ts region='longform'}
|
4424
|
* @abstract
|
4425
|
* @template C
|
4426
|
* @param {?} componentFactory
|
4427
|
* @param {?=} rootSelectorOrNode
|
4428
|
* @return {?}
|
4429
|
*/
|
4430
|
bootstrap(componentFactory, rootSelectorOrNode) { }
|
4431
|
/**
|
4432
|
* Invoke this method to explicitly process change detection and its side-effects.
|
4433
|
*
|
4434
|
* In development mode, `tick()` also performs a second change detection cycle to ensure that no
|
4435
|
* further changes are detected. If additional changes are picked up during this second cycle,
|
4436
|
* bindings in the app have side-effects that cannot be resolved in a single change detection
|
4437
|
* pass.
|
4438
|
* In this case, Angular throws an error, since an Angular application can only have one change
|
4439
|
* detection pass during which all change detection must complete.
|
4440
|
* @abstract
|
4441
|
* @return {?}
|
4442
|
*/
|
4443
|
tick() { }
|
4444
|
/**
|
4445
|
* Get a list of component types registered to this application.
|
4446
|
* This list is populated even before the component is created.
|
4447
|
* @abstract
|
4448
|
* @return {?}
|
4449
|
*/
|
4450
|
componentTypes() { }
|
4451
|
/**
|
4452
|
* Get a list of components registered to this application.
|
4453
|
* @abstract
|
4454
|
* @return {?}
|
4455
|
*/
|
4456
|
components() { }
|
4457
|
/**
|
4458
|
* Attaches a view so that it will be dirty checked.
|
4459
|
* The view will be automatically detached when it is destroyed.
|
4460
|
* This will throw if the view is already attached to a ViewContainer.
|
4461
|
* @abstract
|
4462
|
* @param {?} view
|
4463
|
* @return {?}
|
4464
|
*/
|
4465
|
attachView(view) { }
|
4466
|
/**
|
4467
|
* Detaches a view from dirty checking again.
|
4468
|
* @abstract
|
4469
|
* @param {?} view
|
4470
|
* @return {?}
|
4471
|
*/
|
4472
|
detachView(view) { }
|
4473
|
/**
|
4474
|
* Returns the number of attached views.
|
4475
|
* @abstract
|
4476
|
* @return {?}
|
4477
|
*/
|
4478
|
viewCount() { }
|
4479
|
/**
|
4480
|
* Returns an Observable that indicates when the application is stable or unstable.
|
4481
|
* @abstract
|
4482
|
* @return {?}
|
4483
|
*/
|
4484
|
isStable() { }
|
4485
|
}
|
4486
|
/**
|
4487
|
* workaround https://github.com/angular/tsickle/issues/350
|
4488
|
* @suppress {checkTypes}
|
4489
|
*/
|
4490
|
class ApplicationRef_ extends ApplicationRef {
|
4491
|
/**
|
4492
|
* @param {?} _zone
|
4493
|
* @param {?} _console
|
4494
|
* @param {?} _injector
|
4495
|
* @param {?} _exceptionHandler
|
4496
|
* @param {?} _componentFactoryResolver
|
4497
|
* @param {?} _initStatus
|
4498
|
*/
|
4499
|
constructor(_zone, _console, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
|
4500
|
super();
|
4501
|
this._zone = _zone;
|
4502
|
this._console = _console;
|
4503
|
this._injector = _injector;
|
4504
|
this._exceptionHandler = _exceptionHandler;
|
4505
|
this._componentFactoryResolver = _componentFactoryResolver;
|
4506
|
this._initStatus = _initStatus;
|
4507
|
this._bootstrapListeners = [];
|
4508
|
this._rootComponents = [];
|
4509
|
this._rootComponentTypes = [];
|
4510
|
this._views = [];
|
4511
|
this._runningTick = false;
|
4512
|
this._enforceNoNewChanges = false;
|
4513
|
this._stable = true;
|
4514
|
this._enforceNoNewChanges = isDevMode();
|
4515
|
this._zone.onMicrotaskEmpty.subscribe({ next: () => { this._zone.run(() => { this.tick(); }); } });
|
4516
|
const isCurrentlyStable = new Observable((observer) => {
|
4517
|
this._stable = this._zone.isStable && !this._zone.hasPendingMacrotasks &&
|
4518
|
!this._zone.hasPendingMicrotasks;
|
4519
|
this._zone.runOutsideAngular(() => {
|
4520
|
observer.next(this._stable);
|
4521
|
observer.complete();
|
4522
|
});
|
4523
|
});
|
4524
|
const isStable = new Observable((observer) => {
|
4525
|
// Create the subscription to onStable outside the Angular Zone so that
|
4526
|
// the callback is run outside the Angular Zone.
|
4527
|
let stableSub;
|
4528
|
this._zone.runOutsideAngular(() => {
|
4529
|
stableSub = this._zone.onStable.subscribe(() => {
|
4530
|
NgZone.assertNotInAngularZone();
|
4531
|
// Check whether there are no pending macro/micro tasks in the next tick
|
4532
|
// to allow for NgZone to update the state.
|
4533
|
scheduleMicroTask(() => {
|
4534
|
if (!this._stable && !this._zone.hasPendingMacrotasks &&
|
4535
|
!this._zone.hasPendingMicrotasks) {
|
4536
|
this._stable = true;
|
4537
|
observer.next(true);
|
4538
|
}
|
4539
|
});
|
4540
|
});
|
4541
|
});
|
4542
|
const unstableSub = this._zone.onUnstable.subscribe(() => {
|
4543
|
NgZone.assertInAngularZone();
|
4544
|
if (this._stable) {
|
4545
|
this._stable = false;
|
4546
|
this._zone.runOutsideAngular(() => { observer.next(false); });
|
4547
|
}
|
4548
|
});
|
4549
|
return () => {
|
4550
|
stableSub.unsubscribe();
|
4551
|
unstableSub.unsubscribe();
|
4552
|
};
|
4553
|
});
|
4554
|
this._isStable = merge(isCurrentlyStable, share.call(isStable));
|
4555
|
}
|
4556
|
/**
|
4557
|
* @param {?} viewRef
|
4558
|
* @return {?}
|
4559
|
*/
|
4560
|
attachView(viewRef) {
|
4561
|
const /** @type {?} */ view = ((viewRef));
|
4562
|
this._views.push(view);
|
4563
|
view.attachToAppRef(this);
|
4564
|
}
|
4565
|
/**
|
4566
|
* @param {?} viewRef
|
4567
|
* @return {?}
|
4568
|
*/
|
4569
|
detachView(viewRef) {
|
4570
|
const /** @type {?} */ view = ((viewRef));
|
4571
|
remove(this._views, view);
|
4572
|
view.detachFromAppRef();
|
4573
|
}
|
4574
|
/**
|
4575
|
* @template C
|
4576
|
* @param {?} componentOrFactory
|
4577
|
* @param {?=} rootSelectorOrNode
|
4578
|
* @return {?}
|
4579
|
*/
|
4580
|
bootstrap(componentOrFactory, rootSelectorOrNode) {
|
4581
|
if (!this._initStatus.done) {
|
4582
|
throw new Error('Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
|
4583
|
}
|
4584
|
let /** @type {?} */ componentFactory;
|
4585
|
if (componentOrFactory instanceof ComponentFactory) {
|
4586
|
componentFactory = componentOrFactory;
|
4587
|
}
|
4588
|
else {
|
4589
|
componentFactory = ((this._componentFactoryResolver.resolveComponentFactory(componentOrFactory)));
|
4590
|
}
|
4591
|
this._rootComponentTypes.push(componentFactory.componentType);
|
4592
|
// Create a factory associated with the current module if it's not bound to some other
|
4593
|
const /** @type {?} */ ngModule = componentFactory instanceof ComponentFactoryBoundToModule ?
|
4594
|
null :
|
4595
|
this._injector.get(NgModuleRef);
|
4596
|
const /** @type {?} */ selectorOrNode = rootSelectorOrNode || componentFactory.selector;
|
4597
|
const /** @type {?} */ compRef = componentFactory.create(Injector.NULL, [], selectorOrNode, ngModule);
|
4598
|
compRef.onDestroy(() => { this._unloadComponent(compRef); });
|
4599
|
const /** @type {?} */ testability = compRef.injector.get(Testability, null);
|
4600
|
if (testability) {
|
4601
|
compRef.injector.get(TestabilityRegistry)
|
4602
|
.registerApplication(compRef.location.nativeElement, testability);
|
4603
|
}
|
4604
|
this._loadComponent(compRef);
|
4605
|
if (isDevMode()) {
|
4606
|
this._console.log(`Angular is running in the development mode. Call enableProdMode() to enable the production mode.`);
|
4607
|
}
|
4608
|
return compRef;
|
4609
|
}
|
4610
|
/**
|
4611
|
* @param {?} componentRef
|
4612
|
* @return {?}
|
4613
|
*/
|
4614
|
_loadComponent(componentRef) {
|
4615
|
this.attachView(componentRef.hostView);
|
4616
|
this.tick();
|
4617
|
this._rootComponents.push(componentRef);
|
4618
|
// Get the listeners lazily to prevent DI cycles.
|
4619
|
const /** @type {?} */ listeners = this._injector.get(APP_BOOTSTRAP_LISTENER, []).concat(this._bootstrapListeners);
|
4620
|
listeners.forEach((listener) => listener(componentRef));
|
4621
|
}
|
4622
|
/**
|
4623
|
* @param {?} componentRef
|
4624
|
* @return {?}
|
4625
|
*/
|
4626
|
_unloadComponent(componentRef) {
|
4627
|
this.detachView(componentRef.hostView);
|
4628
|
remove(this._rootComponents, componentRef);
|
4629
|
}
|
4630
|
/**
|
4631
|
* @return {?}
|
4632
|
*/
|
4633
|
tick() {
|
4634
|
if (this._runningTick) {
|
4635
|
throw new Error('ApplicationRef.tick is called recursively');
|
4636
|
}
|
4637
|
const /** @type {?} */ scope = ApplicationRef_._tickScope();
|
4638
|
try {
|
4639
|
this._runningTick = true;
|
4640
|
this._views.forEach((view) => view.detectChanges());
|
4641
|
if (this._enforceNoNewChanges) {
|
4642
|
this._views.forEach((view) => view.checkNoChanges());
|
4643
|
}
|
4644
|
}
|
4645
|
catch (e) {
|
4646
|
// Attention: Don't rethrow as it could cancel subscriptions to Observables!
|
4647
|
this._zone.runOutsideAngular(() => this._exceptionHandler.handleError(e));
|
4648
|
}
|
4649
|
finally {
|
4650
|
this._runningTick = false;
|
4651
|
wtfLeave(scope);
|
4652
|
}
|
4653
|
}
|
4654
|
/**
|
4655
|
* @return {?}
|
4656
|
*/
|
4657
|
ngOnDestroy() {
|
4658
|
// TODO(alxhub): Dispose of the NgZone.
|
4659
|
this._views.slice().forEach((view) => view.destroy());
|
4660
|
}
|
4661
|
/**
|
4662
|
* @return {?}
|
4663
|
*/
|
4664
|
get viewCount() { return this._views.length; }
|
4665
|
/**
|
4666
|
* @return {?}
|
4667
|
*/
|
4668
|
get componentTypes() { return this._rootComponentTypes; }
|
4669
|
/**
|
4670
|
* @return {?}
|
4671
|
*/
|
4672
|
get components() { return this._rootComponents; }
|
4673
|
/**
|
4674
|
* @return {?}
|
4675
|
*/
|
4676
|
get isStable() { return this._isStable; }
|
4677
|
}
|
4678
|
/**
|
4679
|
* \@internal
|
4680
|
*/
|
4681
|
ApplicationRef_._tickScope = wtfCreateScope('ApplicationRef#tick()');
|
4682
|
ApplicationRef_.decorators = [
|
4683
|
{ type: Injectable },
|
4684
|
];
|
4685
|
/**
|
4686
|
* @nocollapse
|
4687
|
*/
|
4688
|
ApplicationRef_.ctorParameters = () => [
|
4689
|
{ type: NgZone, },
|
4690
|
{ type: Console, },
|
4691
|
{ type: Injector, },
|
4692
|
{ type: ErrorHandler, },
|
4693
|
{ type: ComponentFactoryResolver, },
|
4694
|
{ type: ApplicationInitStatus, },
|
4695
|
];
|
4696
|
/**
|
4697
|
* @template T
|
4698
|
* @param {?} list
|
4699
|
* @param {?} el
|
4700
|
* @return {?}
|
4701
|
*/
|
4702
|
function remove(list, el) {
|
4703
|
const /** @type {?} */ index = list.indexOf(el);
|
4704
|
if (index > -1) {
|
4705
|
list.splice(index, 1);
|
4706
|
}
|
4707
|
}
|
4708
|
|
4709
|
/**
|
4710
|
* @license
|
4711
|
* Copyright Google Inc. All Rights Reserved.
|
4712
|
*
|
4713
|
* Use of this source code is governed by an MIT-style license that can be
|
4714
|
* found in the LICENSE file at https://angular.io/license
|
4715
|
*/
|
4716
|
// Public API for Zone
|
4717
|
|
4718
|
/**
|
4719
|
* @license
|
4720
|
* Copyright Google Inc. All Rights Reserved.
|
4721
|
*
|
4722
|
* Use of this source code is governed by an MIT-style license that can be
|
4723
|
* found in the LICENSE file at https://angular.io/license
|
4724
|
*/
|
4725
|
/**
|
4726
|
* @deprecated Use `RendererType2` (and `Renderer2`) instead.
|
4727
|
*/
|
4728
|
class RenderComponentType {
|
4729
|
/**
|
4730
|
* @param {?} id
|
4731
|
* @param {?} templateUrl
|
4732
|
* @param {?} slotCount
|
4733
|
* @param {?} encapsulation
|
4734
|
* @param {?} styles
|
4735
|
* @param {?} animations
|
4736
|
*/
|
4737
|
constructor(id, templateUrl, slotCount, encapsulation, styles, animations) {
|
4738
|
this.id = id;
|
4739
|
this.templateUrl = templateUrl;
|
4740
|
this.slotCount = slotCount;
|
4741
|
this.encapsulation = encapsulation;
|
4742
|
this.styles = styles;
|
4743
|
this.animations = animations;
|
4744
|
}
|
4745
|
}
|
4746
|
/**
|
4747
|
* @deprecated Debug info is handeled internally in the view engine now.
|
4748
|
* @abstract
|
4749
|
*/
|
4750
|
class RenderDebugInfo {
|
4751
|
/**
|
4752
|
* @abstract
|
4753
|
* @return {?}
|
4754
|
*/
|
4755
|
injector() { }
|
4756
|
/**
|
4757
|
* @abstract
|
4758
|
* @return {?}
|
4759
|
*/
|
4760
|
component() { }
|
4761
|
/**
|
4762
|
* @abstract
|
4763
|
* @return {?}
|
4764
|
*/
|
4765
|
providerTokens() { }
|
4766
|
/**
|
4767
|
* @abstract
|
4768
|
* @return {?}
|
4769
|
*/
|
4770
|
references() { }
|
4771
|
/**
|
4772
|
* @abstract
|
4773
|
* @return {?}
|
4774
|
*/
|
4775
|
context() { }
|
4776
|
/**
|
4777
|
* @abstract
|
4778
|
* @return {?}
|
4779
|
*/
|
4780
|
source() { }
|
4781
|
}
|
4782
|
/**
|
4783
|
* @deprecated Use the `Renderer2` instead.
|
4784
|
* @abstract
|
4785
|
*/
|
4786
|
class Renderer {
|
4787
|
/**
|
4788
|
* @abstract
|
4789
|
* @param {?} selectorOrNode
|
4790
|
* @param {?=} debugInfo
|
4791
|
* @return {?}
|
4792
|
*/
|
4793
|
selectRootElement(selectorOrNode, debugInfo) { }
|
4794
|
/**
|
4795
|
* @abstract
|
4796
|
* @param {?} parentElement
|
4797
|
* @param {?} name
|
4798
|
* @param {?=} debugInfo
|
4799
|
* @return {?}
|
4800
|
*/
|
4801
|
createElement(parentElement, name, debugInfo) { }
|
4802
|
/**
|
4803
|
* @abstract
|
4804
|
* @param {?} hostElement
|
4805
|
* @return {?}
|
4806
|
*/
|
4807
|
createViewRoot(hostElement) { }
|
4808
|
/**
|
4809
|
* @abstract
|
4810
|
* @param {?} parentElement
|
4811
|
* @param {?=} debugInfo
|
4812
|
* @return {?}
|
4813
|
*/
|
4814
|
createTemplateAnchor(parentElement, debugInfo) { }
|
4815
|
/**
|
4816
|
* @abstract
|
4817
|
* @param {?} parentElement
|
4818
|
* @param {?} value
|
4819
|
* @param {?=} debugInfo
|
4820
|
* @return {?}
|
4821
|
*/
|
4822
|
createText(parentElement, value, debugInfo) { }
|
4823
|
/**
|
4824
|
* @abstract
|
4825
|
* @param {?} parentElement
|
4826
|
* @param {?} nodes
|
4827
|
* @return {?}
|
4828
|
*/
|
4829
|
projectNodes(parentElement, nodes) { }
|
4830
|
/**
|
4831
|
* @abstract
|
4832
|
* @param {?} node
|
4833
|
* @param {?} viewRootNodes
|
4834
|
* @return {?}
|
4835
|
*/
|
4836
|
attachViewAfter(node, viewRootNodes) { }
|
4837
|
/**
|
4838
|
* @abstract
|
4839
|
* @param {?} viewRootNodes
|
4840
|
* @return {?}
|
4841
|
*/
|
4842
|
detachView(viewRootNodes) { }
|
4843
|
/**
|
4844
|
* @abstract
|
4845
|
* @param {?} hostElement
|
4846
|
* @param {?} viewAllNodes
|
4847
|
* @return {?}
|
4848
|
*/
|
4849
|
destroyView(hostElement, viewAllNodes) { }
|
4850
|
/**
|
4851
|
* @abstract
|
4852
|
* @param {?} renderElement
|
4853
|
* @param {?} name
|
4854
|
* @param {?} callback
|
4855
|
* @return {?}
|
4856
|
*/
|
4857
|
listen(renderElement, name, callback) { }
|
4858
|
/**
|
4859
|
* @abstract
|
4860
|
* @param {?} target
|
4861
|
* @param {?} name
|
4862
|
* @param {?} callback
|
4863
|
* @return {?}
|
4864
|
*/
|
4865
|
listenGlobal(target, name, callback) { }
|
4866
|
/**
|
4867
|
* @abstract
|
4868
|
* @param {?} renderElement
|
4869
|
* @param {?} propertyName
|
4870
|
* @param {?} propertyValue
|
4871
|
* @return {?}
|
4872
|
*/
|
4873
|
setElementProperty(renderElement, propertyName, propertyValue) { }
|
4874
|
/**
|
4875
|
* @abstract
|
4876
|
* @param {?} renderElement
|
4877
|
* @param {?} attributeName
|
4878
|
* @param {?} attributeValue
|
4879
|
* @return {?}
|
4880
|
*/
|
4881
|
setElementAttribute(renderElement, attributeName, attributeValue) { }
|
4882
|
/**
|
4883
|
* Used only in debug mode to serialize property changes to dom nodes as attributes.
|
4884
|
* @abstract
|
4885
|
* @param {?} renderElement
|
4886
|
* @param {?} propertyName
|
4887
|
* @param {?} propertyValue
|
4888
|
* @return {?}
|
4889
|
*/
|
4890
|
setBindingDebugInfo(renderElement, propertyName, propertyValue) { }
|
4891
|
/**
|
4892
|
* @abstract
|
4893
|
* @param {?} renderElement
|
4894
|
* @param {?} className
|
4895
|
* @param {?} isAdd
|
4896
|
* @return {?}
|
4897
|
*/
|
4898
|
setElementClass(renderElement, className, isAdd) { }
|
4899
|
/**
|
4900
|
* @abstract
|
4901
|
* @param {?} renderElement
|
4902
|
* @param {?} styleName
|
4903
|
* @param {?} styleValue
|
4904
|
* @return {?}
|
4905
|
*/
|
4906
|
setElementStyle(renderElement, styleName, styleValue) { }
|
4907
|
/**
|
4908
|
* @abstract
|
4909
|
* @param {?} renderElement
|
4910
|
* @param {?} methodName
|
4911
|
* @param {?=} args
|
4912
|
* @return {?}
|
4913
|
*/
|
4914
|
invokeElementMethod(renderElement, methodName, args) { }
|
4915
|
/**
|
4916
|
* @abstract
|
4917
|
* @param {?} renderNode
|
4918
|
* @param {?} text
|
4919
|
* @return {?}
|
4920
|
*/
|
4921
|
setText(renderNode, text) { }
|
4922
|
/**
|
4923
|
* @abstract
|
4924
|
* @param {?} element
|
4925
|
* @param {?} startingStyles
|
4926
|
* @param {?} keyframes
|
4927
|
* @param {?} duration
|
4928
|
* @param {?} delay
|
4929
|
* @param {?} easing
|
4930
|
* @param {?=} previousPlayers
|
4931
|
* @return {?}
|
4932
|
*/
|
4933
|
animate(element, startingStyles, keyframes, duration, delay, easing, previousPlayers) { }
|
4934
|
}
|
4935
|
const Renderer2Interceptor = new InjectionToken('Renderer2Interceptor');
|
4936
|
/**
|
4937
|
* Injectable service that provides a low-level interface for modifying the UI.
|
4938
|
*
|
4939
|
* Use this service to bypass Angular's templating and make custom UI changes that can't be
|
4940
|
* expressed declaratively. For example if you need to set a property or an attribute whose name is
|
4941
|
* not statically known, use {\@link Renderer#setElementProperty} or {\@link
|
4942
|
* Renderer#setElementAttribute}
|
4943
|
* respectively.
|
4944
|
*
|
4945
|
* If you are implementing a custom renderer, you must implement this interface.
|
4946
|
*
|
4947
|
* The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
|
4948
|
*
|
4949
|
* @deprecated Use `RendererFactory2` instead.
|
4950
|
* @abstract
|
4951
|
*/
|
4952
|
class RootRenderer {
|
4953
|
/**
|
4954
|
* @abstract
|
4955
|
* @param {?} componentType
|
4956
|
* @return {?}
|
4957
|
*/
|
4958
|
renderComponent(componentType) { }
|
4959
|
}
|
4960
|
/**
|
4961
|
* \@experimental
|
4962
|
* @abstract
|
4963
|
*/
|
4964
|
class RendererFactory2 {
|
4965
|
/**
|
4966
|
* @abstract
|
4967
|
* @param {?} hostElement
|
4968
|
* @param {?} type
|
4969
|
* @return {?}
|
4970
|
*/
|
4971
|
createRenderer(hostElement, type) { }
|
4972
|
/**
|
4973
|
* @abstract
|
4974
|
* @return {?}
|
4975
|
*/
|
4976
|
begin() { }
|
4977
|
/**
|
4978
|
* @abstract
|
4979
|
* @return {?}
|
4980
|
*/
|
4981
|
end() { }
|
4982
|
/**
|
4983
|
* @abstract
|
4984
|
* @return {?}
|
4985
|
*/
|
4986
|
whenRenderingDone() { }
|
4987
|
}
|
4988
|
let RendererStyleFlags2 = {};
|
4989
|
RendererStyleFlags2.Important = 1;
|
4990
|
RendererStyleFlags2.DashCase = 2;
|
4991
|
RendererStyleFlags2[RendererStyleFlags2.Important] = "Important";
|
4992
|
RendererStyleFlags2[RendererStyleFlags2.DashCase] = "DashCase";
|
4993
|
/**
|
4994
|
* \@experimental
|
4995
|
* @abstract
|
4996
|
*/
|
4997
|
class Renderer2 {
|
4998
|
/**
|
4999
|
* This field can be used to store arbitrary data on this renderer instance.
|
5000
|
* This is useful for renderers that delegate to other renderers.
|
5001
|
* @abstract
|
5002
|
* @return {?}
|
5003
|
*/
|
5004
|
data() { }
|
5005
|
/**
|
5006
|
* @abstract
|
5007
|
* @return {?}
|
5008
|
*/
|
5009
|
destroy() { }
|
5010
|
/**
|
5011
|
* @abstract
|
5012
|
* @param {?} name
|
5013
|
* @param {?=} namespace
|
5014
|
* @return {?}
|
5015
|
*/
|
5016
|
createElement(name, namespace) { }
|
5017
|
/**
|
5018
|
* @abstract
|
5019
|
* @param {?} value
|
5020
|
* @return {?}
|
5021
|
*/
|
5022
|
createComment(value) { }
|
5023
|
/**
|
5024
|
* @abstract
|
5025
|
* @param {?} value
|
5026
|
* @return {?}
|
5027
|
*/
|
5028
|
createText(value) { }
|
5029
|
/**
|
5030
|
* @abstract
|
5031
|
* @param {?} parent
|
5032
|
* @param {?} newChild
|
5033
|
* @return {?}
|
5034
|
*/
|
5035
|
appendChild(parent, newChild) { }
|
5036
|
/**
|
5037
|
* @abstract
|
5038
|
* @param {?} parent
|
5039
|
* @param {?} newChild
|
5040
|
* @param {?} refChild
|
5041
|
* @return {?}
|
5042
|
*/
|
5043
|
insertBefore(parent, newChild, refChild) { }
|
5044
|
/**
|
5045
|
* @abstract
|
5046
|
* @param {?} parent
|
5047
|
* @param {?} oldChild
|
5048
|
* @return {?}
|
5049
|
*/
|
5050
|
removeChild(parent, oldChild) { }
|
5051
|
/**
|
5052
|
* @abstract
|
5053
|
* @param {?} selectorOrNode
|
5054
|
* @return {?}
|
5055
|
*/
|
5056
|
selectRootElement(selectorOrNode) { }
|
5057
|
/**
|
5058
|
* Attention: On WebWorkers, this will always return a value,
|
5059
|
* as we are asking for a result synchronously. I.e.
|
5060
|
* the caller can't rely on checking whether this is null or not.
|
5061
|
* @abstract
|
5062
|
* @param {?} node
|
5063
|
* @return {?}
|
5064
|
*/
|
5065
|
parentNode(node) { }
|
5066
|
/**
|
5067
|
* Attention: On WebWorkers, this will always return a value,
|
5068
|
* as we are asking for a result synchronously. I.e.
|
5069
|
* the caller can't rely on checking whether this is null or not.
|
5070
|
* @abstract
|
5071
|
* @param {?} node
|
5072
|
* @return {?}
|
5073
|
*/
|
5074
|
nextSibling(node) { }
|
5075
|
/**
|
5076
|
* @abstract
|
5077
|
* @param {?} el
|
5078
|
* @param {?} name
|
5079
|
* @param {?} value
|
5080
|
* @param {?=} namespace
|
5081
|
* @return {?}
|
5082
|
*/
|
5083
|
setAttribute(el, name, value, namespace) { }
|
5084
|
/**
|
5085
|
* @abstract
|
5086
|
* @param {?} el
|
5087
|
* @param {?} name
|
5088
|
* @param {?=} namespace
|
5089
|
* @return {?}
|
5090
|
*/
|
5091
|
removeAttribute(el, name, namespace) { }
|
5092
|
/**
|
5093
|
* @abstract
|
5094
|
* @param {?} el
|
5095
|
* @param {?} name
|
5096
|
* @return {?}
|
5097
|
*/
|
5098
|
addClass(el, name) { }
|
5099
|
/**
|
5100
|
* @abstract
|
5101
|
* @param {?} el
|
5102
|
* @param {?} name
|
5103
|
* @return {?}
|
5104
|
*/
|
5105
|
removeClass(el, name) { }
|
5106
|
/**
|
5107
|
* @abstract
|
5108
|
* @param {?} el
|
5109
|
* @param {?} style
|
5110
|
* @param {?} value
|
5111
|
* @param {?=} flags
|
5112
|
* @return {?}
|
5113
|
*/
|
5114
|
setStyle(el, style, value, flags) { }
|
5115
|
/**
|
5116
|
* @abstract
|
5117
|
* @param {?} el
|
5118
|
* @param {?} style
|
5119
|
* @param {?=} flags
|
5120
|
* @return {?}
|
5121
|
*/
|
5122
|
removeStyle(el, style, flags) { }
|
5123
|
/**
|
5124
|
* @abstract
|
5125
|
* @param {?} el
|
5126
|
* @param {?} name
|
5127
|
* @param {?} value
|
5128
|
* @return {?}
|
5129
|
*/
|
5130
|
setProperty(el, name, value) { }
|
5131
|
/**
|
5132
|
* @abstract
|
5133
|
* @param {?} node
|
5134
|
* @param {?} value
|
5135
|
* @return {?}
|
5136
|
*/
|
5137
|
setValue(node, value) { }
|
5138
|
/**
|
5139
|
* @abstract
|
5140
|
* @param {?} target
|
5141
|
* @param {?} eventName
|
5142
|
* @param {?} callback
|
5143
|
* @return {?}
|
5144
|
*/
|
5145
|
listen(target, eventName, callback) { }
|
5146
|
}
|
5147
|
|
5148
|
/**
|
5149
|
* @license
|
5150
|
* Copyright Google Inc. All Rights Reserved.
|
5151
|
*
|
5152
|
* Use of this source code is governed by an MIT-style license that can be
|
5153
|
* found in the LICENSE file at https://angular.io/license
|
5154
|
*/
|
5155
|
// Public API for render
|
5156
|
|
5157
|
class ElementRef {
|
5158
|
/**
|
5159
|
* @param {?} nativeElement
|
5160
|
*/
|
5161
|
constructor(nativeElement) { this.nativeElement = nativeElement; }
|
5162
|
}
|
5163
|
|
5164
|
/**
|
5165
|
* @license
|
5166
|
* Copyright Google Inc. All Rights Reserved.
|
5167
|
*
|
5168
|
* Use of this source code is governed by an MIT-style license that can be
|
5169
|
* found in the LICENSE file at https://angular.io/license
|
5170
|
*/
|
5171
|
/**
|
5172
|
* Used to load ng module factories.
|
5173
|
* \@stable
|
5174
|
* @abstract
|
5175
|
*/
|
5176
|
class NgModuleFactoryLoader {
|
5177
|
/**
|
5178
|
* @abstract
|
5179
|
* @param {?} path
|
5180
|
* @return {?}
|
5181
|
*/
|
5182
|
load(path) { }
|
5183
|
}
|
5184
|
let moduleFactories = new Map();
|
5185
|
/**
|
5186
|
* Registers a loaded module. Should only be called from generated NgModuleFactory code.
|
5187
|
* \@experimental
|
5188
|
* @param {?} id
|
5189
|
* @param {?} factory
|
5190
|
* @return {?}
|
5191
|
*/
|
5192
|
function registerModuleFactory(id, factory) {
|
5193
|
const /** @type {?} */ existing = moduleFactories.get(id);
|
5194
|
if (existing) {
|
5195
|
throw new Error(`Duplicate module registered for ${id} - ${existing.moduleType.name} vs ${factory.moduleType.name}`);
|
5196
|
}
|
5197
|
moduleFactories.set(id, factory);
|
5198
|
}
|
5199
|
/**
|
5200
|
* @return {?}
|
5201
|
*/
|
5202
|
|
5203
|
/**
|
5204
|
* Returns the NgModuleFactory with the given id, if it exists and has been loaded.
|
5205
|
* Factories for modules that do not specify an `id` cannot be retrieved. Throws if the module
|
5206
|
* cannot be found.
|
5207
|
* \@experimental
|
5208
|
* @param {?} id
|
5209
|
* @return {?}
|
5210
|
*/
|
5211
|
function getModuleFactory(id) {
|
5212
|
const /** @type {?} */ factory = moduleFactories.get(id);
|
5213
|
if (!factory)
|
5214
|
throw new Error(`No module with ID ${id} loaded`);
|
5215
|
return factory;
|
5216
|
}
|
5217
|
|
5218
|
/**
|
5219
|
* @license
|
5220
|
* Copyright Google Inc. All Rights Reserved.
|
5221
|
*
|
5222
|
* Use of this source code is governed by an MIT-style license that can be
|
5223
|
* found in the LICENSE file at https://angular.io/license
|
5224
|
*/
|
5225
|
/**
|
5226
|
* An unmodifiable list of items that Angular keeps up to date when the state
|
5227
|
* of the application changes.
|
5228
|
*
|
5229
|
* The type of object that {\@link ViewChildren}, {\@link ContentChildren}, and {\@link QueryList}
|
5230
|
* provide.
|
5231
|
*
|
5232
|
* Implements an iterable interface, therefore it can be used in both ES6
|
5233
|
* javascript `for (var i of items)` loops as well as in Angular templates with
|
5234
|
* `*ngFor="let i of myList"`.
|
5235
|
*
|
5236
|
* Changes can be observed by subscribing to the changes `Observable`.
|
5237
|
*
|
5238
|
* NOTE: In the future this class will implement an `Observable` interface.
|
5239
|
*
|
5240
|
* ### Example ([live demo](http://plnkr.co/edit/RX8sJnQYl9FWuSCWme5z?p=preview))
|
5241
|
* ```typescript
|
5242
|
* \@Component({...})
|
5243
|
* class Container {
|
5244
|
* \@ViewChildren(Item) items:QueryList<Item>;
|
5245
|
* }
|
5246
|
* ```
|
5247
|
* \@stable
|
5248
|
*/
|
5249
|
class QueryList {
|
5250
|
constructor() {
|
5251
|
this._dirty = true;
|
5252
|
this._results = [];
|
5253
|
this._emitter = new EventEmitter();
|
5254
|
}
|
5255
|
/**
|
5256
|
* @return {?}
|
5257
|
*/
|
5258
|
get changes() { return this._emitter; }
|
5259
|
/**
|
5260
|
* @return {?}
|
5261
|
*/
|
5262
|
get length() { return this._results.length; }
|
5263
|
/**
|
5264
|
* @return {?}
|
5265
|
*/
|
5266
|
get first() { return this._results[0]; }
|
5267
|
/**
|
5268
|
* @return {?}
|
5269
|
*/
|
5270
|
get last() { return this._results[this.length - 1]; }
|
5271
|
/**
|
5272
|
* See
|
5273
|
* [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
|
5274
|
* @template U
|
5275
|
* @param {?} fn
|
5276
|
* @return {?}
|
5277
|
*/
|
5278
|
map(fn) { return this._results.map(fn); }
|
5279
|
/**
|
5280
|
* See
|
5281
|
* [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
|
5282
|
* @param {?} fn
|
5283
|
* @return {?}
|
5284
|
*/
|
5285
|
filter(fn) {
|
5286
|
return this._results.filter(fn);
|
5287
|
}
|
5288
|
/**
|
5289
|
* See
|
5290
|
* [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
|
5291
|
* @param {?} fn
|
5292
|
* @return {?}
|
5293
|
*/
|
5294
|
find(fn) {
|
5295
|
return this._results.find(fn);
|
5296
|
}
|
5297
|
/**
|
5298
|
* See
|
5299
|
* [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
|
5300
|
* @template U
|
5301
|
* @param {?} fn
|
5302
|
* @param {?} init
|
5303
|
* @return {?}
|
5304
|
*/
|
5305
|
reduce(fn, init) {
|
5306
|
return this._results.reduce(fn, init);
|
5307
|
}
|
5308
|
/**
|
5309
|
* See
|
5310
|
* [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
|
5311
|
* @param {?} fn
|
5312
|
* @return {?}
|
5313
|
*/
|
5314
|
forEach(fn) { this._results.forEach(fn); }
|
5315
|
/**
|
5316
|
* See
|
5317
|
* [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
|
5318
|
* @param {?} fn
|
5319
|
* @return {?}
|
5320
|
*/
|
5321
|
some(fn) {
|
5322
|
return this._results.some(fn);
|
5323
|
}
|
5324
|
/**
|
5325
|
* @return {?}
|
5326
|
*/
|
5327
|
toArray() { return this._results.slice(); }
|
5328
|
/**
|
5329
|
* @return {?}
|
5330
|
*/
|
5331
|
[getSymbolIterator()]() { return ((this._results))[getSymbolIterator()](); }
|
5332
|
/**
|
5333
|
* @return {?}
|
5334
|
*/
|
5335
|
toString() { return this._results.toString(); }
|
5336
|
/**
|
5337
|
* @param {?} res
|
5338
|
* @return {?}
|
5339
|
*/
|
5340
|
reset(res) {
|
5341
|
this._results = flatten(res);
|
5342
|
this._dirty = false;
|
5343
|
}
|
5344
|
/**
|
5345
|
* @return {?}
|
5346
|
*/
|
5347
|
notifyOnChanges() { this._emitter.emit(this); }
|
5348
|
/**
|
5349
|
* internal
|
5350
|
* @return {?}
|
5351
|
*/
|
5352
|
setDirty() { this._dirty = true; }
|
5353
|
/**
|
5354
|
* internal
|
5355
|
* @return {?}
|
5356
|
*/
|
5357
|
get dirty() { return this._dirty; }
|
5358
|
/**
|
5359
|
* internal
|
5360
|
* @return {?}
|
5361
|
*/
|
5362
|
destroy() {
|
5363
|
this._emitter.complete();
|
5364
|
this._emitter.unsubscribe();
|
5365
|
}
|
5366
|
}
|
5367
|
/**
|
5368
|
* @template T
|
5369
|
* @param {?} list
|
5370
|
* @return {?}
|
5371
|
*/
|
5372
|
function flatten(list) {
|
5373
|
return list.reduce((flat, item) => {
|
5374
|
const /** @type {?} */ flatItem = Array.isArray(item) ? flatten(item) : item;
|
5375
|
return ((flat)).concat(flatItem);
|
5376
|
}, []);
|
5377
|
}
|
5378
|
|
5379
|
/**
|
5380
|
* @license
|
5381
|
* Copyright Google Inc. All Rights Reserved.
|
5382
|
*
|
5383
|
* Use of this source code is governed by an MIT-style license that can be
|
5384
|
* found in the LICENSE file at https://angular.io/license
|
5385
|
*/
|
5386
|
const _SEPARATOR = '#';
|
5387
|
const FACTORY_CLASS_SUFFIX = 'NgFactory';
|
5388
|
/**
|
5389
|
* Configuration for SystemJsNgModuleLoader.
|
5390
|
* token.
|
5391
|
*
|
5392
|
* \@experimental
|
5393
|
* @abstract
|
5394
|
*/
|
5395
|
class SystemJsNgModuleLoaderConfig {
|
5396
|
}
|
5397
|
const DEFAULT_CONFIG = {
|
5398
|
factoryPathPrefix: '',
|
5399
|
factoryPathSuffix: '.ngfactory',
|
5400
|
};
|
5401
|
/**
|
5402
|
* NgModuleFactoryLoader that uses SystemJS to load NgModuleFactory
|
5403
|
* \@experimental
|
5404
|
*/
|
5405
|
class SystemJsNgModuleLoader {
|
5406
|
/**
|
5407
|
* @param {?} _compiler
|
5408
|
* @param {?=} config
|
5409
|
*/
|
5410
|
constructor(_compiler, config) {
|
5411
|
this._compiler = _compiler;
|
5412
|
this._config = config || DEFAULT_CONFIG;
|
5413
|
}
|
5414
|
/**
|
5415
|
* @param {?} path
|
5416
|
* @return {?}
|
5417
|
*/
|
5418
|
load(path) {
|
5419
|
const /** @type {?} */ offlineMode = this._compiler instanceof Compiler;
|
5420
|
return offlineMode ? this.loadFactory(path) : this.loadAndCompile(path);
|
5421
|
}
|
5422
|
/**
|
5423
|
* @param {?} path
|
5424
|
* @return {?}
|
5425
|
*/
|
5426
|
loadAndCompile(path) {
|
5427
|
let [module, exportName] = path.split(_SEPARATOR);
|
5428
|
if (exportName === undefined) {
|
5429
|
exportName = 'default';
|
5430
|
}
|
5431
|
return System.import(module)
|
5432
|
.then((module) => module[exportName])
|
5433
|
.then((type) => checkNotEmpty(type, module, exportName))
|
5434
|
.then((type) => this._compiler.compileModuleAsync(type));
|
5435
|
}
|
5436
|
/**
|
5437
|
* @param {?} path
|
5438
|
* @return {?}
|
5439
|
*/
|
5440
|
loadFactory(path) {
|
5441
|
let [module, exportName] = path.split(_SEPARATOR);
|
5442
|
let /** @type {?} */ factoryClassSuffix = FACTORY_CLASS_SUFFIX;
|
5443
|
if (exportName === undefined) {
|
5444
|
exportName = 'default';
|
5445
|
factoryClassSuffix = '';
|
5446
|
}
|
5447
|
return System.import(this._config.factoryPathPrefix + module + this._config.factoryPathSuffix)
|
5448
|
.then((module) => module[exportName + factoryClassSuffix])
|
5449
|
.then((factory) => checkNotEmpty(factory, module, exportName));
|
5450
|
}
|
5451
|
}
|
5452
|
SystemJsNgModuleLoader.decorators = [
|
5453
|
{ type: Injectable },
|
5454
|
];
|
5455
|
/**
|
5456
|
* @nocollapse
|
5457
|
*/
|
5458
|
SystemJsNgModuleLoader.ctorParameters = () => [
|
5459
|
{ type: Compiler, },
|
5460
|
{ type: SystemJsNgModuleLoaderConfig, decorators: [{ type: Optional },] },
|
5461
|
];
|
5462
|
/**
|
5463
|
* @param {?} value
|
5464
|
* @param {?} modulePath
|
5465
|
* @param {?} exportName
|
5466
|
* @return {?}
|
5467
|
*/
|
5468
|
function checkNotEmpty(value, modulePath, exportName) {
|
5469
|
if (!value) {
|
5470
|
throw new Error(`Cannot find '${exportName}' in '${modulePath}'`);
|
5471
|
}
|
5472
|
return value;
|
5473
|
}
|
5474
|
|
5475
|
/**
|
5476
|
* @license
|
5477
|
* Copyright Google Inc. All Rights Reserved.
|
5478
|
*
|
5479
|
* Use of this source code is governed by an MIT-style license that can be
|
5480
|
* found in the LICENSE file at https://angular.io/license
|
5481
|
*/
|
5482
|
/**
|
5483
|
* Represents an Embedded Template that can be used to instantiate Embedded Views.
|
5484
|
*
|
5485
|
* You can access a `TemplateRef`, in two ways. Via a directive placed on a `<ng-template>` element
|
5486
|
* (or directive prefixed with `*`) and have the `TemplateRef` for this Embedded View injected into
|
5487
|
* the constructor of the directive using the `TemplateRef` Token. Alternatively you can query for
|
5488
|
* the `TemplateRef` from a Component or a Directive via {\@link Query}.
|
5489
|
*
|
5490
|
* To instantiate Embedded Views based on a Template, use
|
5491
|
* {\@link ViewContainerRef#createEmbeddedView}, which will create the View and attach it to the
|
5492
|
* View Container.
|
5493
|
* \@stable
|
5494
|
* @abstract
|
5495
|
*/
|
5496
|
class TemplateRef {
|
5497
|
/**
|
5498
|
* @abstract
|
5499
|
* @return {?}
|
5500
|
*/
|
5501
|
elementRef() { }
|
5502
|
/**
|
5503
|
* @abstract
|
5504
|
* @param {?} context
|
5505
|
* @return {?}
|
5506
|
*/
|
5507
|
createEmbeddedView(context) { }
|
5508
|
}
|
5509
|
|
5510
|
/**
|
5511
|
* @license
|
5512
|
* Copyright Google Inc. All Rights Reserved.
|
5513
|
*
|
5514
|
* Use of this source code is governed by an MIT-style license that can be
|
5515
|
* found in the LICENSE file at https://angular.io/license
|
5516
|
*/
|
5517
|
/**
|
5518
|
* Represents a container where one or more Views can be attached.
|
5519
|
*
|
5520
|
* The container can contain two kinds of Views. Host Views, created by instantiating a
|
5521
|
* {\@link Component} via {\@link #createComponent}, and Embedded Views, created by instantiating an
|
5522
|
* {\@link TemplateRef Embedded Template} via {\@link #createEmbeddedView}.
|
5523
|
*
|
5524
|
* The location of the View Container within the containing View is specified by the Anchor
|
5525
|
* `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
|
5526
|
* have a single View Container.
|
5527
|
*
|
5528
|
* Root elements of Views attached to this container become siblings of the Anchor Element in
|
5529
|
* the Rendered View.
|
5530
|
*
|
5531
|
* To access a `ViewContainerRef` of an Element, you can either place a {\@link Directive} injected
|
5532
|
* with `ViewContainerRef` on the Element, or you obtain it via a {\@link ViewChild} query.
|
5533
|
* \@stable
|
5534
|
* @abstract
|
5535
|
*/
|
5536
|
class ViewContainerRef {
|
5537
|
/**
|
5538
|
* Anchor element that specifies the location of this container in the containing View.
|
5539
|
* <!-- TODO: rename to anchorElement -->
|
5540
|
* @abstract
|
5541
|
* @return {?}
|
5542
|
*/
|
5543
|
element() { }
|
5544
|
/**
|
5545
|
* @abstract
|
5546
|
* @return {?}
|
5547
|
*/
|
5548
|
injector() { }
|
5549
|
/**
|
5550
|
* @abstract
|
5551
|
* @return {?}
|
5552
|
*/
|
5553
|
parentInjector() { }
|
5554
|
/**
|
5555
|
* Destroys all Views in this container.
|
5556
|
* @abstract
|
5557
|
* @return {?}
|
5558
|
*/
|
5559
|
clear() { }
|
5560
|
/**
|
5561
|
* Returns the {\@link ViewRef} for the View located in this container at the specified index.
|
5562
|
* @abstract
|
5563
|
* @param {?} index
|
5564
|
* @return {?}
|
5565
|
*/
|
5566
|
get(index) { }
|
5567
|
/**
|
5568
|
* Returns the number of Views currently attached to this container.
|
5569
|
* @abstract
|
5570
|
* @return {?}
|
5571
|
*/
|
5572
|
length() { }
|
5573
|
/**
|
5574
|
* Instantiates an Embedded View based on the {\@link TemplateRef `templateRef`} and inserts it
|
5575
|
* into this container at the specified `index`.
|
5576
|
*
|
5577
|
* If `index` is not specified, the new View will be inserted as the last View in the container.
|
5578
|
*
|
5579
|
* Returns the {\@link ViewRef} for the newly created View.
|
5580
|
* @abstract
|
5581
|
* @template C
|
5582
|
* @param {?} templateRef
|
5583
|
* @param {?=} context
|
5584
|
* @param {?=} index
|
5585
|
* @return {?}
|
5586
|
*/
|
5587
|
createEmbeddedView(templateRef, context, index) { }
|
5588
|
/**
|
5589
|
* Instantiates a single {\@link Component} and inserts its Host View into this container at the
|
5590
|
* specified `index`.
|
5591
|
*
|
5592
|
* The component is instantiated using its {\@link ComponentFactory} which can be
|
5593
|
* obtained via {\@link ComponentFactoryResolver#resolveComponentFactory}.
|
5594
|
*
|
5595
|
* If `index` is not specified, the new View will be inserted as the last View in the container.
|
5596
|
*
|
5597
|
* You can optionally specify the {\@link Injector} that will be used as parent for the Component.
|
5598
|
*
|
5599
|
* Returns the {\@link ComponentRef} of the Host View created for the newly instantiated Component.
|
5600
|
* @abstract
|
5601
|
* @template C
|
5602
|
* @param {?} componentFactory
|
5603
|
* @param {?=} index
|
5604
|
* @param {?=} injector
|
5605
|
* @param {?=} projectableNodes
|
5606
|
* @param {?=} ngModule
|
5607
|
* @return {?}
|
5608
|
*/
|
5609
|
createComponent(componentFactory, index, injector, projectableNodes, ngModule) { }
|
5610
|
/**
|
5611
|
* Inserts a View identified by a {\@link ViewRef} into the container at the specified `index`.
|
5612
|
*
|
5613
|
* If `index` is not specified, the new View will be inserted as the last View in the container.
|
5614
|
*
|
5615
|
* Returns the inserted {\@link ViewRef}.
|
5616
|
* @abstract
|
5617
|
* @param {?} viewRef
|
5618
|
* @param {?=} index
|
5619
|
* @return {?}
|
5620
|
*/
|
5621
|
insert(viewRef, index) { }
|
5622
|
/**
|
5623
|
* Moves a View identified by a {\@link ViewRef} into the container at the specified `index`.
|
5624
|
*
|
5625
|
* Returns the inserted {\@link ViewRef}.
|
5626
|
* @abstract
|
5627
|
* @param {?} viewRef
|
5628
|
* @param {?} currentIndex
|
5629
|
* @return {?}
|
5630
|
*/
|
5631
|
move(viewRef, currentIndex) { }
|
5632
|
/**
|
5633
|
* Returns the index of the View, specified via {\@link ViewRef}, within the current container or
|
5634
|
* `-1` if this container doesn't contain the View.
|
5635
|
* @abstract
|
5636
|
* @param {?} viewRef
|
5637
|
* @return {?}
|
5638
|
*/
|
5639
|
indexOf(viewRef) { }
|
5640
|
/**
|
5641
|
* Destroys a View attached to this container at the specified `index`.
|
5642
|
*
|
5643
|
* If `index` is not specified, the last View in the container will be removed.
|
5644
|
* @abstract
|
5645
|
* @param {?=} index
|
5646
|
* @return {?}
|
5647
|
*/
|
5648
|
remove(index) { }
|
5649
|
/**
|
5650
|
* Use along with {\@link #insert} to move a View within the current container.
|
5651
|
*
|
5652
|
* If the `index` param is omitted, the last {\@link ViewRef} is detached.
|
5653
|
* @abstract
|
5654
|
* @param {?=} index
|
5655
|
* @return {?}
|
5656
|
*/
|
5657
|
detach(index) { }
|
5658
|
}
|
5659
|
|
5660
|
/**
|
5661
|
* \@stable
|
5662
|
* @abstract
|
5663
|
*/
|
5664
|
class ChangeDetectorRef {
|
5665
|
/**
|
5666
|
* Marks all {\@link ChangeDetectionStrategy#OnPush} ancestors as to be checked.
|
5667
|
*
|
5668
|
* <!-- TODO: Add a link to a chapter on OnPush components -->
|
5669
|
*
|
5670
|
* ### Example ([live demo](http://plnkr.co/edit/GC512b?p=preview))
|
5671
|
*
|
5672
|
* ```typescript
|
5673
|
* \@Component({
|
5674
|
* selector: 'cmp',
|
5675
|
* changeDetection: ChangeDetectionStrategy.OnPush,
|
5676
|
* template: `Number of ticks: {{numberOfTicks}}`
|
5677
|
* })
|
5678
|
* class Cmp {
|
5679
|
* numberOfTicks = 0;
|
5680
|
*
|
5681
|
* constructor(private ref: ChangeDetectorRef) {
|
5682
|
* setInterval(() => {
|
5683
|
* this.numberOfTicks++;
|
5684
|
* // the following is required, otherwise the view will not be updated
|
5685
|
* this.ref.markForCheck();
|
5686
|
* }, 1000);
|
5687
|
* }
|
5688
|
* }
|
5689
|
*
|
5690
|
* \@Component({
|
5691
|
* selector: 'app',
|
5692
|
* changeDetection: ChangeDetectionStrategy.OnPush,
|
5693
|
* template: `
|
5694
|
* <cmp><cmp>
|
5695
|
* `,
|
5696
|
* })
|
5697
|
* class App {
|
5698
|
* }
|
5699
|
* ```
|
5700
|
* @abstract
|
5701
|
* @return {?}
|
5702
|
*/
|
5703
|
markForCheck() { }
|
5704
|
/**
|
5705
|
* Detaches the change detector from the change detector tree.
|
5706
|
*
|
5707
|
* The detached change detector will not be checked until it is reattached.
|
5708
|
*
|
5709
|
* This can also be used in combination with {\@link ChangeDetectorRef#detectChanges} to implement
|
5710
|
* local change
|
5711
|
* detection checks.
|
5712
|
*
|
5713
|
* <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
|
5714
|
* <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
|
5715
|
*
|
5716
|
* ### Example
|
5717
|
*
|
5718
|
* The following example defines a component with a large list of readonly data.
|
5719
|
* Imagine the data changes constantly, many times per second. For performance reasons,
|
5720
|
* we want to check and update the list every five seconds. We can do that by detaching
|
5721
|
* the component's change detector and doing a local check every five seconds.
|
5722
|
*
|
5723
|
* ```typescript
|
5724
|
* class DataProvider {
|
5725
|
* // in a real application the returned data will be different every time
|
5726
|
* get data() {
|
5727
|
* return [1,2,3,4,5];
|
5728
|
* }
|
5729
|
* }
|
5730
|
*
|
5731
|
* \@Component({
|
5732
|
* selector: 'giant-list',
|
5733
|
* template: `
|
5734
|
* <li *ngFor="let d of dataProvider.data">Data {{d}}</li>
|
5735
|
* `,
|
5736
|
* })
|
5737
|
* class GiantList {
|
5738
|
* constructor(private ref: ChangeDetectorRef, private dataProvider: DataProvider) {
|
5739
|
* ref.detach();
|
5740
|
* setInterval(() => {
|
5741
|
* this.ref.detectChanges();
|
5742
|
* }, 5000);
|
5743
|
* }
|
5744
|
* }
|
5745
|
*
|
5746
|
* \@Component({
|
5747
|
* selector: 'app',
|
5748
|
* providers: [DataProvider],
|
5749
|
* template: `
|
5750
|
* <giant-list><giant-list>
|
5751
|
* `,
|
5752
|
* })
|
5753
|
* class App {
|
5754
|
* }
|
5755
|
* ```
|
5756
|
* @abstract
|
5757
|
* @return {?}
|
5758
|
*/
|
5759
|
detach() { }
|
5760
|
/**
|
5761
|
* Checks the change detector and its children.
|
5762
|
*
|
5763
|
* This can also be used in combination with {\@link ChangeDetectorRef#detach} to implement local
|
5764
|
* change detection
|
5765
|
* checks.
|
5766
|
*
|
5767
|
* <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
|
5768
|
* <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
|
5769
|
*
|
5770
|
* ### Example
|
5771
|
*
|
5772
|
* The following example defines a component with a large list of readonly data.
|
5773
|
* Imagine, the data changes constantly, many times per second. For performance reasons,
|
5774
|
* we want to check and update the list every five seconds.
|
5775
|
*
|
5776
|
* We can do that by detaching the component's change detector and doing a local change detection
|
5777
|
* check
|
5778
|
* every five seconds.
|
5779
|
*
|
5780
|
* See {\@link ChangeDetectorRef#detach} for more information.
|
5781
|
* @abstract
|
5782
|
* @return {?}
|
5783
|
*/
|
5784
|
detectChanges() { }
|
5785
|
/**
|
5786
|
* Checks the change detector and its children, and throws if any changes are detected.
|
5787
|
*
|
5788
|
* This is used in development mode to verify that running change detection doesn't introduce
|
5789
|
* other changes.
|
5790
|
* @abstract
|
5791
|
* @return {?}
|
5792
|
*/
|
5793
|
checkNoChanges() { }
|
5794
|
/**
|
5795
|
* Reattach the change detector to the change detector tree.
|
5796
|
*
|
5797
|
* This also marks OnPush ancestors as to be checked. This reattached change detector will be
|
5798
|
* checked during the next change detection run.
|
5799
|
*
|
5800
|
* <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
|
5801
|
*
|
5802
|
* ### Example ([live demo](http://plnkr.co/edit/aUhZha?p=preview))
|
5803
|
*
|
5804
|
* The following example creates a component displaying `live` data. The component will detach
|
5805
|
* its change detector from the main change detector tree when the component's live property
|
5806
|
* is set to false.
|
5807
|
*
|
5808
|
* ```typescript
|
5809
|
* class DataProvider {
|
5810
|
* data = 1;
|
5811
|
*
|
5812
|
* constructor() {
|
5813
|
* setInterval(() => {
|
5814
|
* this.data = this.data * 2;
|
5815
|
* }, 500);
|
5816
|
* }
|
5817
|
* }
|
5818
|
*
|
5819
|
* \@Component({
|
5820
|
* selector: 'live-data',
|
5821
|
* inputs: ['live'],
|
5822
|
* template: 'Data: {{dataProvider.data}}'
|
5823
|
* })
|
5824
|
* class LiveData {
|
5825
|
* constructor(private ref: ChangeDetectorRef, private dataProvider: DataProvider) {}
|
5826
|
*
|
5827
|
* set live(value) {
|
5828
|
* if (value) {
|
5829
|
* this.ref.reattach();
|
5830
|
* } else {
|
5831
|
* this.ref.detach();
|
5832
|
* }
|
5833
|
* }
|
5834
|
* }
|
5835
|
*
|
5836
|
* \@Component({
|
5837
|
* selector: 'app',
|
5838
|
* providers: [DataProvider],
|
5839
|
* template: `
|
5840
|
* Live Update: <input type="checkbox" [(ngModel)]="live">
|
5841
|
* <live-data [live]="live"><live-data>
|
5842
|
* `,
|
5843
|
* })
|
5844
|
* class App {
|
5845
|
* live = true;
|
5846
|
* }
|
5847
|
* ```
|
5848
|
* @abstract
|
5849
|
* @return {?}
|
5850
|
*/
|
5851
|
reattach() { }
|
5852
|
}
|
5853
|
|
5854
|
/**
|
5855
|
* @license
|
5856
|
* Copyright Google Inc. All Rights Reserved.
|
5857
|
*
|
5858
|
* Use of this source code is governed by an MIT-style license that can be
|
5859
|
* found in the LICENSE file at https://angular.io/license
|
5860
|
*/
|
5861
|
/**
|
5862
|
* \@stable
|
5863
|
* @abstract
|
5864
|
*/
|
5865
|
class ViewRef extends ChangeDetectorRef {
|
5866
|
/**
|
5867
|
* Destroys the view and all of the data structures associated with it.
|
5868
|
* @abstract
|
5869
|
* @return {?}
|
5870
|
*/
|
5871
|
destroy() { }
|
5872
|
/**
|
5873
|
* @abstract
|
5874
|
* @return {?}
|
5875
|
*/
|
5876
|
destroyed() { }
|
5877
|
/**
|
5878
|
* @abstract
|
5879
|
* @param {?} callback
|
5880
|
* @return {?}
|
5881
|
*/
|
5882
|
onDestroy(callback) { }
|
5883
|
}
|
5884
|
/**
|
5885
|
* Represents an Angular View.
|
5886
|
*
|
5887
|
* <!-- TODO: move the next two paragraphs to the dev guide -->
|
5888
|
* A View is a fundamental building block of the application UI. It is the smallest grouping of
|
5889
|
* Elements which are created and destroyed together.
|
5890
|
*
|
5891
|
* Properties of elements in a View can change, but the structure (number and order) of elements in
|
5892
|
* a View cannot. Changing the structure of Elements can only be done by inserting, moving or
|
5893
|
* removing nested Views via a {\@link ViewContainerRef}. Each View can contain many View Containers.
|
5894
|
* <!-- /TODO -->
|
5895
|
*
|
5896
|
* ### Example
|
5897
|
*
|
5898
|
* Given this template...
|
5899
|
*
|
5900
|
* ```
|
5901
|
* Count: {{items.length}}
|
5902
|
* <ul>
|
5903
|
* <li *ngFor="let item of items">{{item}}</li>
|
5904
|
* </ul>
|
5905
|
* ```
|
5906
|
*
|
5907
|
* We have two {\@link TemplateRef}s:
|
5908
|
*
|
5909
|
* Outer {\@link TemplateRef}:
|
5910
|
* ```
|
5911
|
* Count: {{items.length}}
|
5912
|
* <ul>
|
5913
|
* <ng-template ngFor let-item [ngForOf]="items"></ng-template>
|
5914
|
* </ul>
|
5915
|
* ```
|
5916
|
*
|
5917
|
* Inner {\@link TemplateRef}:
|
5918
|
* ```
|
5919
|
* <li>{{item}}</li>
|
5920
|
* ```
|
5921
|
*
|
5922
|
* Notice that the original template is broken down into two separate {\@link TemplateRef}s.
|
5923
|
*
|
5924
|
* The outer/inner {\@link TemplateRef}s are then assembled into views like so:
|
5925
|
*
|
5926
|
* ```
|
5927
|
* <!-- ViewRef: outer-0 -->
|
5928
|
* Count: 2
|
5929
|
* <ul>
|
5930
|
* <ng-template view-container-ref></ng-template>
|
5931
|
* <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
|
5932
|
* <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
|
5933
|
* </ul>
|
5934
|
* <!-- /ViewRef: outer-0 -->
|
5935
|
* ```
|
5936
|
* \@experimental
|
5937
|
* @abstract
|
5938
|
*/
|
5939
|
class EmbeddedViewRef extends ViewRef {
|
5940
|
/**
|
5941
|
* @abstract
|
5942
|
* @return {?}
|
5943
|
*/
|
5944
|
context() { }
|
5945
|
/**
|
5946
|
* @abstract
|
5947
|
* @return {?}
|
5948
|
*/
|
5949
|
rootNodes() { }
|
5950
|
}
|
5951
|
|
5952
|
/**
|
5953
|
* @license
|
5954
|
* Copyright Google Inc. All Rights Reserved.
|
5955
|
*
|
5956
|
* Use of this source code is governed by an MIT-style license that can be
|
5957
|
* found in the LICENSE file at https://angular.io/license
|
5958
|
*/
|
5959
|
// Public API for compiler
|
5960
|
|
5961
|
/**
|
5962
|
* @license
|
5963
|
* Copyright Google Inc. All Rights Reserved.
|
5964
|
*
|
5965
|
* Use of this source code is governed by an MIT-style license that can be
|
5966
|
* found in the LICENSE file at https://angular.io/license
|
5967
|
*/
|
5968
|
class EventListener {
|
5969
|
/**
|
5970
|
* @param {?} name
|
5971
|
* @param {?} callback
|
5972
|
*/
|
5973
|
constructor(name, callback) {
|
5974
|
this.name = name;
|
5975
|
this.callback = callback;
|
5976
|
}
|
5977
|
}
|
5978
|
/**
|
5979
|
* \@experimental All debugging apis are currently experimental.
|
5980
|
*/
|
5981
|
class DebugNode {
|
5982
|
/**
|
5983
|
* @param {?} nativeNode
|
5984
|
* @param {?} parent
|
5985
|
* @param {?} _debugContext
|
5986
|
*/
|
5987
|
constructor(nativeNode, parent, _debugContext) {
|
5988
|
this._debugContext = _debugContext;
|
5989
|
this.nativeNode = nativeNode;
|
5990
|
if (parent && parent instanceof DebugElement) {
|
5991
|
parent.addChild(this);
|
5992
|
}
|
5993
|
else {
|
5994
|
this.parent = null;
|
5995
|
}
|
5996
|
this.listeners = [];
|
5997
|
}
|
5998
|
/**
|
5999
|
* @return {?}
|
6000
|
*/
|
6001
|
get injector() { return this._debugContext.injector; }
|
6002
|
/**
|
6003
|
* @return {?}
|
6004
|
*/
|
6005
|
get componentInstance() { return this._debugContext.component; }
|
6006
|
/**
|
6007
|
* @return {?}
|
6008
|
*/
|
6009
|
get context() { return this._debugContext.context; }
|
6010
|
/**
|
6011
|
* @return {?}
|
6012
|
*/
|
6013
|
get references() { return this._debugContext.references; }
|
6014
|
/**
|
6015
|
* @return {?}
|
6016
|
*/
|
6017
|
get providerTokens() { return this._debugContext.providerTokens; }
|
6018
|
/**
|
6019
|
* @deprecated since v4
|
6020
|
* @return {?}
|
6021
|
*/
|
6022
|
get source() { return 'Deprecated since v4'; }
|
6023
|
}
|
6024
|
/**
|
6025
|
* \@experimental All debugging apis are currently experimental.
|
6026
|
*/
|
6027
|
class DebugElement extends DebugNode {
|
6028
|
/**
|
6029
|
* @param {?} nativeNode
|
6030
|
* @param {?} parent
|
6031
|
* @param {?} _debugContext
|
6032
|
*/
|
6033
|
constructor(nativeNode, parent, _debugContext) {
|
6034
|
super(nativeNode, parent, _debugContext);
|
6035
|
this.properties = {};
|
6036
|
this.attributes = {};
|
6037
|
this.classes = {};
|
6038
|
this.styles = {};
|
6039
|
this.childNodes = [];
|
6040
|
this.nativeElement = nativeNode;
|
6041
|
}
|
6042
|
/**
|
6043
|
* @param {?} child
|
6044
|
* @return {?}
|
6045
|
*/
|
6046
|
addChild(child) {
|
6047
|
if (child) {
|
6048
|
this.childNodes.push(child);
|
6049
|
child.parent = this;
|
6050
|
}
|
6051
|
}
|
6052
|
/**
|
6053
|
* @param {?} child
|
6054
|
* @return {?}
|
6055
|
*/
|
6056
|
removeChild(child) {
|
6057
|
const /** @type {?} */ childIndex = this.childNodes.indexOf(child);
|
6058
|
if (childIndex !== -1) {
|
6059
|
child.parent = null;
|
6060
|
this.childNodes.splice(childIndex, 1);
|
6061
|
}
|
6062
|
}
|
6063
|
/**
|
6064
|
* @param {?} child
|
6065
|
* @param {?} newChildren
|
6066
|
* @return {?}
|
6067
|
*/
|
6068
|
insertChildrenAfter(child, newChildren) {
|
6069
|
const /** @type {?} */ siblingIndex = this.childNodes.indexOf(child);
|
6070
|
if (siblingIndex !== -1) {
|
6071
|
this.childNodes.splice(siblingIndex + 1, 0, ...newChildren);
|
6072
|
newChildren.forEach(c => {
|
6073
|
if (c.parent) {
|
6074
|
c.parent.removeChild(c);
|
6075
|
}
|
6076
|
c.parent = this;
|
6077
|
});
|
6078
|
}
|
6079
|
}
|
6080
|
/**
|
6081
|
* @param {?} refChild
|
6082
|
* @param {?} newChild
|
6083
|
* @return {?}
|
6084
|
*/
|
6085
|
insertBefore(refChild, newChild) {
|
6086
|
const /** @type {?} */ refIndex = this.childNodes.indexOf(refChild);
|
6087
|
if (refIndex === -1) {
|
6088
|
this.addChild(newChild);
|
6089
|
}
|
6090
|
else {
|
6091
|
if (newChild.parent) {
|
6092
|
newChild.parent.removeChild(newChild);
|
6093
|
}
|
6094
|
newChild.parent = this;
|
6095
|
this.childNodes.splice(refIndex, 0, newChild);
|
6096
|
}
|
6097
|
}
|
6098
|
/**
|
6099
|
* @param {?} predicate
|
6100
|
* @return {?}
|
6101
|
*/
|
6102
|
query(predicate) {
|
6103
|
const /** @type {?} */ results = this.queryAll(predicate);
|
6104
|
return results[0] || null;
|
6105
|
}
|
6106
|
/**
|
6107
|
* @param {?} predicate
|
6108
|
* @return {?}
|
6109
|
*/
|
6110
|
queryAll(predicate) {
|
6111
|
const /** @type {?} */ matches = [];
|
6112
|
_queryElementChildren(this, predicate, matches);
|
6113
|
return matches;
|
6114
|
}
|
6115
|
/**
|
6116
|
* @param {?} predicate
|
6117
|
* @return {?}
|
6118
|
*/
|
6119
|
queryAllNodes(predicate) {
|
6120
|
const /** @type {?} */ matches = [];
|
6121
|
_queryNodeChildren(this, predicate, matches);
|
6122
|
return matches;
|
6123
|
}
|
6124
|
/**
|
6125
|
* @return {?}
|
6126
|
*/
|
6127
|
get children() {
|
6128
|
return (this.childNodes.filter((node) => node instanceof DebugElement));
|
6129
|
}
|
6130
|
/**
|
6131
|
* @param {?} eventName
|
6132
|
* @param {?} eventObj
|
6133
|
* @return {?}
|
6134
|
*/
|
6135
|
triggerEventHandler(eventName, eventObj) {
|
6136
|
this.listeners.forEach((listener) => {
|
6137
|
if (listener.name == eventName) {
|
6138
|
listener.callback(eventObj);
|
6139
|
}
|
6140
|
});
|
6141
|
}
|
6142
|
}
|
6143
|
/**
|
6144
|
* \@experimental
|
6145
|
* @param {?} debugEls
|
6146
|
* @return {?}
|
6147
|
*/
|
6148
|
function asNativeElements(debugEls) {
|
6149
|
return debugEls.map((el) => el.nativeElement);
|
6150
|
}
|
6151
|
/**
|
6152
|
* @param {?} element
|
6153
|
* @param {?} predicate
|
6154
|
* @param {?} matches
|
6155
|
* @return {?}
|
6156
|
*/
|
6157
|
function _queryElementChildren(element, predicate, matches) {
|
6158
|
element.childNodes.forEach(node => {
|
6159
|
if (node instanceof DebugElement) {
|
6160
|
if (predicate(node)) {
|
6161
|
matches.push(node);
|
6162
|
}
|
6163
|
_queryElementChildren(node, predicate, matches);
|
6164
|
}
|
6165
|
});
|
6166
|
}
|
6167
|
/**
|
6168
|
* @param {?} parentNode
|
6169
|
* @param {?} predicate
|
6170
|
* @param {?} matches
|
6171
|
* @return {?}
|
6172
|
*/
|
6173
|
function _queryNodeChildren(parentNode, predicate, matches) {
|
6174
|
if (parentNode instanceof DebugElement) {
|
6175
|
parentNode.childNodes.forEach(node => {
|
6176
|
if (predicate(node)) {
|
6177
|
matches.push(node);
|
6178
|
}
|
6179
|
if (node instanceof DebugElement) {
|
6180
|
_queryNodeChildren(node, predicate, matches);
|
6181
|
}
|
6182
|
});
|
6183
|
}
|
6184
|
}
|
6185
|
// Need to keep the nodes in a global Map so that multiple angular apps are supported.
|
6186
|
const _nativeNodeToDebugNode = new Map();
|
6187
|
/**
|
6188
|
* \@experimental
|
6189
|
* @param {?} nativeNode
|
6190
|
* @return {?}
|
6191
|
*/
|
6192
|
function getDebugNode(nativeNode) {
|
6193
|
return _nativeNodeToDebugNode.get(nativeNode) || null;
|
6194
|
}
|
6195
|
/**
|
6196
|
* @return {?}
|
6197
|
*/
|
6198
|
|
6199
|
/**
|
6200
|
* @param {?} node
|
6201
|
* @return {?}
|
6202
|
*/
|
6203
|
function indexDebugNode(node) {
|
6204
|
_nativeNodeToDebugNode.set(node.nativeNode, node);
|
6205
|
}
|
6206
|
/**
|
6207
|
* @param {?} node
|
6208
|
* @return {?}
|
6209
|
*/
|
6210
|
function removeDebugNodeFromIndex(node) {
|
6211
|
_nativeNodeToDebugNode.delete(node.nativeNode);
|
6212
|
}
|
6213
|
|
6214
|
/**
|
6215
|
* @license
|
6216
|
* Copyright Google Inc. All Rights Reserved.
|
6217
|
*
|
6218
|
* Use of this source code is governed by an MIT-style license that can be
|
6219
|
* found in the LICENSE file at https://angular.io/license
|
6220
|
*/
|
6221
|
/**
|
6222
|
* @param {?} a
|
6223
|
* @param {?} b
|
6224
|
* @return {?}
|
6225
|
*/
|
6226
|
function devModeEqual(a, b) {
|
6227
|
const /** @type {?} */ isListLikeIterableA = isListLikeIterable(a);
|
6228
|
const /** @type {?} */ isListLikeIterableB = isListLikeIterable(b);
|
6229
|
if (isListLikeIterableA && isListLikeIterableB) {
|
6230
|
return areIterablesEqual(a, b, devModeEqual);
|
6231
|
}
|
6232
|
else {
|
6233
|
const /** @type {?} */ isAObject = a && (typeof a === 'object' || typeof a === 'function');
|
6234
|
const /** @type {?} */ isBObject = b && (typeof b === 'object' || typeof b === 'function');
|
6235
|
if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
|
6236
|
return true;
|
6237
|
}
|
6238
|
else {
|
6239
|
return looseIdentical(a, b);
|
6240
|
}
|
6241
|
}
|
6242
|
}
|
6243
|
/**
|
6244
|
* Indicates that the result of a {\@link Pipe} transformation has changed even though the
|
6245
|
* reference
|
6246
|
* has not changed.
|
6247
|
*
|
6248
|
* The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
|
6249
|
*
|
6250
|
* Example:
|
6251
|
*
|
6252
|
* ```
|
6253
|
* if (this._latestValue === this._latestReturnedValue) {
|
6254
|
* return this._latestReturnedValue;
|
6255
|
* } else {
|
6256
|
* this._latestReturnedValue = this._latestValue;
|
6257
|
* return WrappedValue.wrap(this._latestValue); // this will force update
|
6258
|
* }
|
6259
|
* ```
|
6260
|
* \@stable
|
6261
|
*/
|
6262
|
class WrappedValue {
|
6263
|
/**
|
6264
|
* @param {?} wrapped
|
6265
|
*/
|
6266
|
constructor(wrapped) {
|
6267
|
this.wrapped = wrapped;
|
6268
|
}
|
6269
|
/**
|
6270
|
* @param {?} value
|
6271
|
* @return {?}
|
6272
|
*/
|
6273
|
static wrap(value) { return new WrappedValue(value); }
|
6274
|
}
|
6275
|
/**
|
6276
|
* Helper class for unwrapping WrappedValue s
|
6277
|
*/
|
6278
|
class ValueUnwrapper {
|
6279
|
constructor() {
|
6280
|
this.hasWrappedValue = false;
|
6281
|
}
|
6282
|
/**
|
6283
|
* @param {?} value
|
6284
|
* @return {?}
|
6285
|
*/
|
6286
|
unwrap(value) {
|
6287
|
if (value instanceof WrappedValue) {
|
6288
|
this.hasWrappedValue = true;
|
6289
|
return value.wrapped;
|
6290
|
}
|
6291
|
return value;
|
6292
|
}
|
6293
|
/**
|
6294
|
* @return {?}
|
6295
|
*/
|
6296
|
reset() { this.hasWrappedValue = false; }
|
6297
|
}
|
6298
|
/**
|
6299
|
* Represents a basic change from a previous to a new value.
|
6300
|
* \@stable
|
6301
|
*/
|
6302
|
class SimpleChange {
|
6303
|
/**
|
6304
|
* @param {?} previousValue
|
6305
|
* @param {?} currentValue
|
6306
|
* @param {?} firstChange
|
6307
|
*/
|
6308
|
constructor(previousValue, currentValue, firstChange) {
|
6309
|
this.previousValue = previousValue;
|
6310
|
this.currentValue = currentValue;
|
6311
|
this.firstChange = firstChange;
|
6312
|
}
|
6313
|
/**
|
6314
|
* Check whether the new value is the first value assigned.
|
6315
|
* @return {?}
|
6316
|
*/
|
6317
|
isFirstChange() { return this.firstChange; }
|
6318
|
}
|
6319
|
/**
|
6320
|
* @param {?} obj
|
6321
|
* @return {?}
|
6322
|
*/
|
6323
|
function isListLikeIterable(obj) {
|
6324
|
if (!isJsObject(obj))
|
6325
|
return false;
|
6326
|
return Array.isArray(obj) ||
|
6327
|
(!(obj instanceof Map) &&
|
6328
|
getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
|
6329
|
}
|
6330
|
/**
|
6331
|
* @param {?} a
|
6332
|
* @param {?} b
|
6333
|
* @param {?} comparator
|
6334
|
* @return {?}
|
6335
|
*/
|
6336
|
function areIterablesEqual(a, b, comparator) {
|
6337
|
const /** @type {?} */ iterator1 = a[getSymbolIterator()]();
|
6338
|
const /** @type {?} */ iterator2 = b[getSymbolIterator()]();
|
6339
|
while (true) {
|
6340
|
const /** @type {?} */ item1 = iterator1.next();
|
6341
|
const /** @type {?} */ item2 = iterator2.next();
|
6342
|
if (item1.done && item2.done)
|
6343
|
return true;
|
6344
|
if (item1.done || item2.done)
|
6345
|
return false;
|
6346
|
if (!comparator(item1.value, item2.value))
|
6347
|
return false;
|
6348
|
}
|
6349
|
}
|
6350
|
/**
|
6351
|
* @param {?} obj
|
6352
|
* @param {?} fn
|
6353
|
* @return {?}
|
6354
|
*/
|
6355
|
function iterateListLike(obj, fn) {
|
6356
|
if (Array.isArray(obj)) {
|
6357
|
for (let /** @type {?} */ i = 0; i < obj.length; i++) {
|
6358
|
fn(obj[i]);
|
6359
|
}
|
6360
|
}
|
6361
|
else {
|
6362
|
const /** @type {?} */ iterator = obj[getSymbolIterator()]();
|
6363
|
let /** @type {?} */ item;
|
6364
|
while (!((item = iterator.next()).done)) {
|
6365
|
fn(item.value);
|
6366
|
}
|
6367
|
}
|
6368
|
}
|
6369
|
/**
|
6370
|
* @param {?} o
|
6371
|
* @return {?}
|
6372
|
*/
|
6373
|
function isJsObject(o) {
|
6374
|
return o !== null && (typeof o === 'function' || typeof o === 'object');
|
6375
|
}
|
6376
|
|
6377
|
/**
|
6378
|
* @license
|
6379
|
* Copyright Google Inc. All Rights Reserved.
|
6380
|
*
|
6381
|
* Use of this source code is governed by an MIT-style license that can be
|
6382
|
* found in the LICENSE file at https://angular.io/license
|
6383
|
*/
|
6384
|
class DefaultIterableDifferFactory {
|
6385
|
constructor() { }
|
6386
|
/**
|
6387
|
* @param {?} obj
|
6388
|
* @return {?}
|
6389
|
*/
|
6390
|
supports(obj) { return isListLikeIterable(obj); }
|
6391
|
/**
|
6392
|
* @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
|
6393
|
* @template V
|
6394
|
* @param {?=} cdRefOrTrackBy
|
6395
|
* @param {?=} trackByFn
|
6396
|
* @return {?}
|
6397
|
*/
|
6398
|
create(cdRefOrTrackBy, trackByFn) {
|
6399
|
return new DefaultIterableDiffer(trackByFn || (cdRefOrTrackBy));
|
6400
|
}
|
6401
|
}
|
6402
|
const trackByIdentity = (index, item) => item;
|
6403
|
/**
|
6404
|
* @deprecated v4.0.0 - Should not be part of public API.
|
6405
|
*/
|
6406
|
class DefaultIterableDiffer {
|
6407
|
/**
|
6408
|
* @param {?=} trackByFn
|
6409
|
*/
|
6410
|
constructor(trackByFn) {
|
6411
|
this._length = 0;
|
6412
|
this._collection = null;
|
6413
|
this._linkedRecords = null;
|
6414
|
this._unlinkedRecords = null;
|
6415
|
this._previousItHead = null;
|
6416
|
this._itHead = null;
|
6417
|
this._itTail = null;
|
6418
|
this._additionsHead = null;
|
6419
|
this._additionsTail = null;
|
6420
|
this._movesHead = null;
|
6421
|
this._movesTail = null;
|
6422
|
this._removalsHead = null;
|
6423
|
this._removalsTail = null;
|
6424
|
this._identityChangesHead = null;
|
6425
|
this._identityChangesTail = null;
|
6426
|
this._trackByFn = trackByFn || trackByIdentity;
|
6427
|
}
|
6428
|
/**
|
6429
|
* @return {?}
|
6430
|
*/
|
6431
|
get collection() { return this._collection; }
|
6432
|
/**
|
6433
|
* @return {?}
|
6434
|
*/
|
6435
|
get length() { return this._length; }
|
6436
|
/**
|
6437
|
* @param {?} fn
|
6438
|
* @return {?}
|
6439
|
*/
|
6440
|
forEachItem(fn) {
|
6441
|
let /** @type {?} */ record;
|
6442
|
for (record = this._itHead; record !== null; record = record._next) {
|
6443
|
fn(record);
|
6444
|
}
|
6445
|
}
|
6446
|
/**
|
6447
|
* @param {?} fn
|
6448
|
* @return {?}
|
6449
|
*/
|
6450
|
forEachOperation(fn) {
|
6451
|
let /** @type {?} */ nextIt = this._itHead;
|
6452
|
let /** @type {?} */ nextRemove = this._removalsHead;
|
6453
|
let /** @type {?} */ addRemoveOffset = 0;
|
6454
|
let /** @type {?} */ moveOffsets = null;
|
6455
|
while (nextIt || nextRemove) {
|
6456
|
// Figure out which is the next record to process
|
6457
|
// Order: remove, add, move
|
6458
|
const /** @type {?} */ record = !nextRemove ||
|
6459
|
nextIt && ((nextIt.currentIndex)) <
|
6460
|
getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ? ((nextIt)) :
|
6461
|
nextRemove;
|
6462
|
const /** @type {?} */ adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
|
6463
|
const /** @type {?} */ currentIndex = record.currentIndex;
|
6464
|
// consume the item, and adjust the addRemoveOffset and update moveDistance if necessary
|
6465
|
if (record === nextRemove) {
|
6466
|
addRemoveOffset--;
|
6467
|
nextRemove = nextRemove._nextRemoved;
|
6468
|
}
|
6469
|
else {
|
6470
|
nextIt = ((nextIt))._next;
|
6471
|
if (record.previousIndex == null) {
|
6472
|
addRemoveOffset++;
|
6473
|
}
|
6474
|
else {
|
6475
|
// INVARIANT: currentIndex < previousIndex
|
6476
|
if (!moveOffsets)
|
6477
|
moveOffsets = [];
|
6478
|
const /** @type {?} */ localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
|
6479
|
const /** @type {?} */ localCurrentIndex = ((currentIndex)) - addRemoveOffset;
|
6480
|
if (localMovePreviousIndex != localCurrentIndex) {
|
6481
|
for (let /** @type {?} */ i = 0; i < localMovePreviousIndex; i++) {
|
6482
|
const /** @type {?} */ offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
|
6483
|
const /** @type {?} */ index = offset + i;
|
6484
|
if (localCurrentIndex <= index && index < localMovePreviousIndex) {
|
6485
|
moveOffsets[i] = offset + 1;
|
6486
|
}
|
6487
|
}
|
6488
|
const /** @type {?} */ previousIndex = record.previousIndex;
|
6489
|
moveOffsets[previousIndex] = localCurrentIndex - localMovePreviousIndex;
|
6490
|
}
|
6491
|
}
|
6492
|
}
|
6493
|
if (adjPreviousIndex !== currentIndex) {
|
6494
|
fn(record, adjPreviousIndex, currentIndex);
|
6495
|
}
|
6496
|
}
|
6497
|
}
|
6498
|
/**
|
6499
|
* @param {?} fn
|
6500
|
* @return {?}
|
6501
|
*/
|
6502
|
forEachPreviousItem(fn) {
|
6503
|
let /** @type {?} */ record;
|
6504
|
for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
|
6505
|
fn(record);
|
6506
|
}
|
6507
|
}
|
6508
|
/**
|
6509
|
* @param {?} fn
|
6510
|
* @return {?}
|
6511
|
*/
|
6512
|
forEachAddedItem(fn) {
|
6513
|
let /** @type {?} */ record;
|
6514
|
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
6515
|
fn(record);
|
6516
|
}
|
6517
|
}
|
6518
|
/**
|
6519
|
* @param {?} fn
|
6520
|
* @return {?}
|
6521
|
*/
|
6522
|
forEachMovedItem(fn) {
|
6523
|
let /** @type {?} */ record;
|
6524
|
for (record = this._movesHead; record !== null; record = record._nextMoved) {
|
6525
|
fn(record);
|
6526
|
}
|
6527
|
}
|
6528
|
/**
|
6529
|
* @param {?} fn
|
6530
|
* @return {?}
|
6531
|
*/
|
6532
|
forEachRemovedItem(fn) {
|
6533
|
let /** @type {?} */ record;
|
6534
|
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
6535
|
fn(record);
|
6536
|
}
|
6537
|
}
|
6538
|
/**
|
6539
|
* @param {?} fn
|
6540
|
* @return {?}
|
6541
|
*/
|
6542
|
forEachIdentityChange(fn) {
|
6543
|
let /** @type {?} */ record;
|
6544
|
for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
|
6545
|
fn(record);
|
6546
|
}
|
6547
|
}
|
6548
|
/**
|
6549
|
* @param {?} collection
|
6550
|
* @return {?}
|
6551
|
*/
|
6552
|
diff(collection) {
|
6553
|
if (collection == null)
|
6554
|
collection = [];
|
6555
|
if (!isListLikeIterable(collection)) {
|
6556
|
throw new Error(`Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed`);
|
6557
|
}
|
6558
|
if (this.check(collection)) {
|
6559
|
return this;
|
6560
|
}
|
6561
|
else {
|
6562
|
return null;
|
6563
|
}
|
6564
|
}
|
6565
|
/**
|
6566
|
* @return {?}
|
6567
|
*/
|
6568
|
onDestroy() { }
|
6569
|
/**
|
6570
|
* @param {?} collection
|
6571
|
* @return {?}
|
6572
|
*/
|
6573
|
check(collection) {
|
6574
|
this._reset();
|
6575
|
let /** @type {?} */ record = this._itHead;
|
6576
|
let /** @type {?} */ mayBeDirty = false;
|
6577
|
let /** @type {?} */ index;
|
6578
|
let /** @type {?} */ item;
|
6579
|
let /** @type {?} */ itemTrackBy;
|
6580
|
if (Array.isArray(collection)) {
|
6581
|
this._length = collection.length;
|
6582
|
for (let /** @type {?} */ index = 0; index < this._length; index++) {
|
6583
|
item = collection[index];
|
6584
|
itemTrackBy = this._trackByFn(index, item);
|
6585
|
if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
|
6586
|
record = this._mismatch(record, item, itemTrackBy, index);
|
6587
|
mayBeDirty = true;
|
6588
|
}
|
6589
|
else {
|
6590
|
if (mayBeDirty) {
|
6591
|
// TODO(misko): can we limit this to duplicates only?
|
6592
|
record = this._verifyReinsertion(record, item, itemTrackBy, index);
|
6593
|
}
|
6594
|
if (!looseIdentical(record.item, item))
|
6595
|
this._addIdentityChange(record, item);
|
6596
|
}
|
6597
|
record = record._next;
|
6598
|
}
|
6599
|
}
|
6600
|
else {
|
6601
|
index = 0;
|
6602
|
iterateListLike(collection, (item) => {
|
6603
|
itemTrackBy = this._trackByFn(index, item);
|
6604
|
if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
|
6605
|
record = this._mismatch(record, item, itemTrackBy, index);
|
6606
|
mayBeDirty = true;
|
6607
|
}
|
6608
|
else {
|
6609
|
if (mayBeDirty) {
|
6610
|
// TODO(misko): can we limit this to duplicates only?
|
6611
|
record = this._verifyReinsertion(record, item, itemTrackBy, index);
|
6612
|
}
|
6613
|
if (!looseIdentical(record.item, item))
|
6614
|
this._addIdentityChange(record, item);
|
6615
|
}
|
6616
|
record = record._next;
|
6617
|
index++;
|
6618
|
});
|
6619
|
this._length = index;
|
6620
|
}
|
6621
|
this._truncate(record);
|
6622
|
this._collection = collection;
|
6623
|
return this.isDirty;
|
6624
|
}
|
6625
|
/**
|
6626
|
* @return {?}
|
6627
|
*/
|
6628
|
get isDirty() {
|
6629
|
return this._additionsHead !== null || this._movesHead !== null ||
|
6630
|
this._removalsHead !== null || this._identityChangesHead !== null;
|
6631
|
}
|
6632
|
/**
|
6633
|
* Reset the state of the change objects to show no changes. This means set previousKey to
|
6634
|
* currentKey, and clear all of the queues (additions, moves, removals).
|
6635
|
* Set the previousIndexes of moved and added items to their currentIndexes
|
6636
|
* Reset the list of additions, moves and removals
|
6637
|
*
|
6638
|
* \@internal
|
6639
|
* @return {?}
|
6640
|
*/
|
6641
|
_reset() {
|
6642
|
if (this.isDirty) {
|
6643
|
let /** @type {?} */ record;
|
6644
|
let /** @type {?} */ nextRecord;
|
6645
|
for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
|
6646
|
record._nextPrevious = record._next;
|
6647
|
}
|
6648
|
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
6649
|
record.previousIndex = record.currentIndex;
|
6650
|
}
|
6651
|
this._additionsHead = this._additionsTail = null;
|
6652
|
for (record = this._movesHead; record !== null; record = nextRecord) {
|
6653
|
record.previousIndex = record.currentIndex;
|
6654
|
nextRecord = record._nextMoved;
|
6655
|
}
|
6656
|
this._movesHead = this._movesTail = null;
|
6657
|
this._removalsHead = this._removalsTail = null;
|
6658
|
this._identityChangesHead = this._identityChangesTail = null;
|
6659
|
// todo(vicb) when assert gets supported
|
6660
|
// assert(!this.isDirty);
|
6661
|
}
|
6662
|
}
|
6663
|
/**
|
6664
|
* This is the core function which handles differences between collections.
|
6665
|
*
|
6666
|
* - `record` is the record which we saw at this position last time. If null then it is a new
|
6667
|
* item.
|
6668
|
* - `item` is the current item in the collection
|
6669
|
* - `index` is the position of the item in the collection
|
6670
|
*
|
6671
|
* \@internal
|
6672
|
* @param {?} record
|
6673
|
* @param {?} item
|
6674
|
* @param {?} itemTrackBy
|
6675
|
* @param {?} index
|
6676
|
* @return {?}
|
6677
|
*/
|
6678
|
_mismatch(record, item, itemTrackBy, index) {
|
6679
|
// The previous record after which we will append the current one.
|
6680
|
let /** @type {?} */ previousRecord;
|
6681
|
if (record === null) {
|
6682
|
previousRecord = this._itTail;
|
6683
|
}
|
6684
|
else {
|
6685
|
previousRecord = record._prev;
|
6686
|
// Remove the record from the collection since we know it does not match the item.
|
6687
|
this._remove(record);
|
6688
|
}
|
6689
|
// Attempt to see if we have seen the item before.
|
6690
|
record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
|
6691
|
if (record !== null) {
|
6692
|
// We have seen this before, we need to move it forward in the collection.
|
6693
|
// But first we need to check if identity changed, so we can update in view if necessary
|
6694
|
if (!looseIdentical(record.item, item))
|
6695
|
this._addIdentityChange(record, item);
|
6696
|
this._moveAfter(record, previousRecord, index);
|
6697
|
}
|
6698
|
else {
|
6699
|
// Never seen it, check evicted list.
|
6700
|
record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
|
6701
|
if (record !== null) {
|
6702
|
// It is an item which we have evicted earlier: reinsert it back into the list.
|
6703
|
// But first we need to check if identity changed, so we can update in view if necessary
|
6704
|
if (!looseIdentical(record.item, item))
|
6705
|
this._addIdentityChange(record, item);
|
6706
|
this._reinsertAfter(record, previousRecord, index);
|
6707
|
}
|
6708
|
else {
|
6709
|
// It is a new item: add it.
|
6710
|
record =
|
6711
|
this._addAfter(new IterableChangeRecord_(item, itemTrackBy), previousRecord, index);
|
6712
|
}
|
6713
|
}
|
6714
|
return record;
|
6715
|
}
|
6716
|
/**
|
6717
|
* This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
|
6718
|
*
|
6719
|
* Use case: `[a, a]` => `[b, a, a]`
|
6720
|
*
|
6721
|
* If we did not have this check then the insertion of `b` would:
|
6722
|
* 1) evict first `a`
|
6723
|
* 2) insert `b` at `0` index.
|
6724
|
* 3) leave `a` at index `1` as is. <-- this is wrong!
|
6725
|
* 3) reinsert `a` at index 2. <-- this is wrong!
|
6726
|
*
|
6727
|
* The correct behavior is:
|
6728
|
* 1) evict first `a`
|
6729
|
* 2) insert `b` at `0` index.
|
6730
|
* 3) reinsert `a` at index 1.
|
6731
|
* 3) move `a` at from `1` to `2`.
|
6732
|
*
|
6733
|
*
|
6734
|
* Double check that we have not evicted a duplicate item. We need to check if the item type may
|
6735
|
* have already been removed:
|
6736
|
* The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
|
6737
|
* at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
|
6738
|
* better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
|
6739
|
* at the end.
|
6740
|
*
|
6741
|
* \@internal
|
6742
|
* @param {?} record
|
6743
|
* @param {?} item
|
6744
|
* @param {?} itemTrackBy
|
6745
|
* @param {?} index
|
6746
|
* @return {?}
|
6747
|
*/
|
6748
|
_verifyReinsertion(record, item, itemTrackBy, index) {
|
6749
|
let /** @type {?} */ reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
|
6750
|
if (reinsertRecord !== null) {
|
6751
|
record = this._reinsertAfter(reinsertRecord, /** @type {?} */ ((record._prev)), index);
|
6752
|
}
|
6753
|
else if (record.currentIndex != index) {
|
6754
|
record.currentIndex = index;
|
6755
|
this._addToMoves(record, index);
|
6756
|
}
|
6757
|
return record;
|
6758
|
}
|
6759
|
/**
|
6760
|
* Get rid of any excess {\@link IterableChangeRecord_}s from the previous collection
|
6761
|
*
|
6762
|
* - `record` The first excess {\@link IterableChangeRecord_}.
|
6763
|
*
|
6764
|
* \@internal
|
6765
|
* @param {?} record
|
6766
|
* @return {?}
|
6767
|
*/
|
6768
|
_truncate(record) {
|
6769
|
// Anything after that needs to be removed;
|
6770
|
while (record !== null) {
|
6771
|
const /** @type {?} */ nextRecord = record._next;
|
6772
|
this._addToRemovals(this._unlink(record));
|
6773
|
record = nextRecord;
|
6774
|
}
|
6775
|
if (this._unlinkedRecords !== null) {
|
6776
|
this._unlinkedRecords.clear();
|
6777
|
}
|
6778
|
if (this._additionsTail !== null) {
|
6779
|
this._additionsTail._nextAdded = null;
|
6780
|
}
|
6781
|
if (this._movesTail !== null) {
|
6782
|
this._movesTail._nextMoved = null;
|
6783
|
}
|
6784
|
if (this._itTail !== null) {
|
6785
|
this._itTail._next = null;
|
6786
|
}
|
6787
|
if (this._removalsTail !== null) {
|
6788
|
this._removalsTail._nextRemoved = null;
|
6789
|
}
|
6790
|
if (this._identityChangesTail !== null) {
|
6791
|
this._identityChangesTail._nextIdentityChange = null;
|
6792
|
}
|
6793
|
}
|
6794
|
/**
|
6795
|
* \@internal
|
6796
|
* @param {?} record
|
6797
|
* @param {?} prevRecord
|
6798
|
* @param {?} index
|
6799
|
* @return {?}
|
6800
|
*/
|
6801
|
_reinsertAfter(record, prevRecord, index) {
|
6802
|
if (this._unlinkedRecords !== null) {
|
6803
|
this._unlinkedRecords.remove(record);
|
6804
|
}
|
6805
|
const /** @type {?} */ prev = record._prevRemoved;
|
6806
|
const /** @type {?} */ next = record._nextRemoved;
|
6807
|
if (prev === null) {
|
6808
|
this._removalsHead = next;
|
6809
|
}
|
6810
|
else {
|
6811
|
prev._nextRemoved = next;
|
6812
|
}
|
6813
|
if (next === null) {
|
6814
|
this._removalsTail = prev;
|
6815
|
}
|
6816
|
else {
|
6817
|
next._prevRemoved = prev;
|
6818
|
}
|
6819
|
this._insertAfter(record, prevRecord, index);
|
6820
|
this._addToMoves(record, index);
|
6821
|
return record;
|
6822
|
}
|
6823
|
/**
|
6824
|
* \@internal
|
6825
|
* @param {?} record
|
6826
|
* @param {?} prevRecord
|
6827
|
* @param {?} index
|
6828
|
* @return {?}
|
6829
|
*/
|
6830
|
_moveAfter(record, prevRecord, index) {
|
6831
|
this._unlink(record);
|
6832
|
this._insertAfter(record, prevRecord, index);
|
6833
|
this._addToMoves(record, index);
|
6834
|
return record;
|
6835
|
}
|
6836
|
/**
|
6837
|
* \@internal
|
6838
|
* @param {?} record
|
6839
|
* @param {?} prevRecord
|
6840
|
* @param {?} index
|
6841
|
* @return {?}
|
6842
|
*/
|
6843
|
_addAfter(record, prevRecord, index) {
|
6844
|
this._insertAfter(record, prevRecord, index);
|
6845
|
if (this._additionsTail === null) {
|
6846
|
// todo(vicb)
|
6847
|
// assert(this._additionsHead === null);
|
6848
|
this._additionsTail = this._additionsHead = record;
|
6849
|
}
|
6850
|
else {
|
6851
|
// todo(vicb)
|
6852
|
// assert(_additionsTail._nextAdded === null);
|
6853
|
// assert(record._nextAdded === null);
|
6854
|
this._additionsTail = this._additionsTail._nextAdded = record;
|
6855
|
}
|
6856
|
return record;
|
6857
|
}
|
6858
|
/**
|
6859
|
* \@internal
|
6860
|
* @param {?} record
|
6861
|
* @param {?} prevRecord
|
6862
|
* @param {?} index
|
6863
|
* @return {?}
|
6864
|
*/
|
6865
|
_insertAfter(record, prevRecord, index) {
|
6866
|
// todo(vicb)
|
6867
|
// assert(record != prevRecord);
|
6868
|
// assert(record._next === null);
|
6869
|
// assert(record._prev === null);
|
6870
|
const /** @type {?} */ next = prevRecord === null ? this._itHead : prevRecord._next;
|
6871
|
// todo(vicb)
|
6872
|
// assert(next != record);
|
6873
|
// assert(prevRecord != record);
|
6874
|
record._next = next;
|
6875
|
record._prev = prevRecord;
|
6876
|
if (next === null) {
|
6877
|
this._itTail = record;
|
6878
|
}
|
6879
|
else {
|
6880
|
next._prev = record;
|
6881
|
}
|
6882
|
if (prevRecord === null) {
|
6883
|
this._itHead = record;
|
6884
|
}
|
6885
|
else {
|
6886
|
prevRecord._next = record;
|
6887
|
}
|
6888
|
if (this._linkedRecords === null) {
|
6889
|
this._linkedRecords = new _DuplicateMap();
|
6890
|
}
|
6891
|
this._linkedRecords.put(record);
|
6892
|
record.currentIndex = index;
|
6893
|
return record;
|
6894
|
}
|
6895
|
/**
|
6896
|
* \@internal
|
6897
|
* @param {?} record
|
6898
|
* @return {?}
|
6899
|
*/
|
6900
|
_remove(record) {
|
6901
|
return this._addToRemovals(this._unlink(record));
|
6902
|
}
|
6903
|
/**
|
6904
|
* \@internal
|
6905
|
* @param {?} record
|
6906
|
* @return {?}
|
6907
|
*/
|
6908
|
_unlink(record) {
|
6909
|
if (this._linkedRecords !== null) {
|
6910
|
this._linkedRecords.remove(record);
|
6911
|
}
|
6912
|
const /** @type {?} */ prev = record._prev;
|
6913
|
const /** @type {?} */ next = record._next;
|
6914
|
// todo(vicb)
|
6915
|
// assert((record._prev = null) === null);
|
6916
|
// assert((record._next = null) === null);
|
6917
|
if (prev === null) {
|
6918
|
this._itHead = next;
|
6919
|
}
|
6920
|
else {
|
6921
|
prev._next = next;
|
6922
|
}
|
6923
|
if (next === null) {
|
6924
|
this._itTail = prev;
|
6925
|
}
|
6926
|
else {
|
6927
|
next._prev = prev;
|
6928
|
}
|
6929
|
return record;
|
6930
|
}
|
6931
|
/**
|
6932
|
* \@internal
|
6933
|
* @param {?} record
|
6934
|
* @param {?} toIndex
|
6935
|
* @return {?}
|
6936
|
*/
|
6937
|
_addToMoves(record, toIndex) {
|
6938
|
// todo(vicb)
|
6939
|
// assert(record._nextMoved === null);
|
6940
|
if (record.previousIndex === toIndex) {
|
6941
|
return record;
|
6942
|
}
|
6943
|
if (this._movesTail === null) {
|
6944
|
// todo(vicb)
|
6945
|
// assert(_movesHead === null);
|
6946
|
this._movesTail = this._movesHead = record;
|
6947
|
}
|
6948
|
else {
|
6949
|
// todo(vicb)
|
6950
|
// assert(_movesTail._nextMoved === null);
|
6951
|
this._movesTail = this._movesTail._nextMoved = record;
|
6952
|
}
|
6953
|
return record;
|
6954
|
}
|
6955
|
/**
|
6956
|
* @param {?} record
|
6957
|
* @return {?}
|
6958
|
*/
|
6959
|
_addToRemovals(record) {
|
6960
|
if (this._unlinkedRecords === null) {
|
6961
|
this._unlinkedRecords = new _DuplicateMap();
|
6962
|
}
|
6963
|
this._unlinkedRecords.put(record);
|
6964
|
record.currentIndex = null;
|
6965
|
record._nextRemoved = null;
|
6966
|
if (this._removalsTail === null) {
|
6967
|
// todo(vicb)
|
6968
|
// assert(_removalsHead === null);
|
6969
|
this._removalsTail = this._removalsHead = record;
|
6970
|
record._prevRemoved = null;
|
6971
|
}
|
6972
|
else {
|
6973
|
// todo(vicb)
|
6974
|
// assert(_removalsTail._nextRemoved === null);
|
6975
|
// assert(record._nextRemoved === null);
|
6976
|
record._prevRemoved = this._removalsTail;
|
6977
|
this._removalsTail = this._removalsTail._nextRemoved = record;
|
6978
|
}
|
6979
|
return record;
|
6980
|
}
|
6981
|
/**
|
6982
|
* \@internal
|
6983
|
* @param {?} record
|
6984
|
* @param {?} item
|
6985
|
* @return {?}
|
6986
|
*/
|
6987
|
_addIdentityChange(record, item) {
|
6988
|
record.item = item;
|
6989
|
if (this._identityChangesTail === null) {
|
6990
|
this._identityChangesTail = this._identityChangesHead = record;
|
6991
|
}
|
6992
|
else {
|
6993
|
this._identityChangesTail = this._identityChangesTail._nextIdentityChange = record;
|
6994
|
}
|
6995
|
return record;
|
6996
|
}
|
6997
|
/**
|
6998
|
* @return {?}
|
6999
|
*/
|
7000
|
toString() {
|
7001
|
const /** @type {?} */ list = [];
|
7002
|
this.forEachItem((record) => list.push(record));
|
7003
|
const /** @type {?} */ previous = [];
|
7004
|
this.forEachPreviousItem((record) => previous.push(record));
|
7005
|
const /** @type {?} */ additions = [];
|
7006
|
this.forEachAddedItem((record) => additions.push(record));
|
7007
|
const /** @type {?} */ moves = [];
|
7008
|
this.forEachMovedItem((record) => moves.push(record));
|
7009
|
const /** @type {?} */ removals = [];
|
7010
|
this.forEachRemovedItem((record) => removals.push(record));
|
7011
|
const /** @type {?} */ identityChanges = [];
|
7012
|
this.forEachIdentityChange((record) => identityChanges.push(record));
|
7013
|
return 'collection: ' + list.join(', ') + '\n' +
|
7014
|
'previous: ' + previous.join(', ') + '\n' +
|
7015
|
'additions: ' + additions.join(', ') + '\n' +
|
7016
|
'moves: ' + moves.join(', ') + '\n' +
|
7017
|
'removals: ' + removals.join(', ') + '\n' +
|
7018
|
'identityChanges: ' + identityChanges.join(', ') + '\n';
|
7019
|
}
|
7020
|
}
|
7021
|
/**
|
7022
|
* \@stable
|
7023
|
*/
|
7024
|
class IterableChangeRecord_ {
|
7025
|
/**
|
7026
|
* @param {?} item
|
7027
|
* @param {?} trackById
|
7028
|
*/
|
7029
|
constructor(item, trackById) {
|
7030
|
this.item = item;
|
7031
|
this.trackById = trackById;
|
7032
|
this.currentIndex = null;
|
7033
|
this.previousIndex = null;
|
7034
|
/**
|
7035
|
* \@internal
|
7036
|
*/
|
7037
|
this._nextPrevious = null;
|
7038
|
/**
|
7039
|
* \@internal
|
7040
|
*/
|
7041
|
this._prev = null;
|
7042
|
/**
|
7043
|
* \@internal
|
7044
|
*/
|
7045
|
this._next = null;
|
7046
|
/**
|
7047
|
* \@internal
|
7048
|
*/
|
7049
|
this._prevDup = null;
|
7050
|
/**
|
7051
|
* \@internal
|
7052
|
*/
|
7053
|
this._nextDup = null;
|
7054
|
/**
|
7055
|
* \@internal
|
7056
|
*/
|
7057
|
this._prevRemoved = null;
|
7058
|
/**
|
7059
|
* \@internal
|
7060
|
*/
|
7061
|
this._nextRemoved = null;
|
7062
|
/**
|
7063
|
* \@internal
|
7064
|
*/
|
7065
|
this._nextAdded = null;
|
7066
|
/**
|
7067
|
* \@internal
|
7068
|
*/
|
7069
|
this._nextMoved = null;
|
7070
|
/**
|
7071
|
* \@internal
|
7072
|
*/
|
7073
|
this._nextIdentityChange = null;
|
7074
|
}
|
7075
|
/**
|
7076
|
* @return {?}
|
7077
|
*/
|
7078
|
toString() {
|
7079
|
return this.previousIndex === this.currentIndex ? stringify(this.item) :
|
7080
|
stringify(this.item) + '[' +
|
7081
|
stringify(this.previousIndex) + '->' + stringify(this.currentIndex) + ']';
|
7082
|
}
|
7083
|
}
|
7084
|
class _DuplicateItemRecordList {
|
7085
|
constructor() {
|
7086
|
/**
|
7087
|
* \@internal
|
7088
|
*/
|
7089
|
this._head = null;
|
7090
|
/**
|
7091
|
* \@internal
|
7092
|
*/
|
7093
|
this._tail = null;
|
7094
|
}
|
7095
|
/**
|
7096
|
* Append the record to the list of duplicates.
|
7097
|
*
|
7098
|
* Note: by design all records in the list of duplicates hold the same value in record.item.
|
7099
|
* @param {?} record
|
7100
|
* @return {?}
|
7101
|
*/
|
7102
|
add(record) {
|
7103
|
if (this._head === null) {
|
7104
|
this._head = this._tail = record;
|
7105
|
record._nextDup = null;
|
7106
|
record._prevDup = null;
|
7107
|
}
|
7108
|
else {
|
7109
|
((
|
7110
|
// todo(vicb)
|
7111
|
// assert(record.item == _head.item ||
|
7112
|
// record.item is num && record.item.isNaN && _head.item is num && _head.item.isNaN);
|
7113
|
this._tail))._nextDup = record;
|
7114
|
record._prevDup = this._tail;
|
7115
|
record._nextDup = null;
|
7116
|
this._tail = record;
|
7117
|
}
|
7118
|
}
|
7119
|
/**
|
7120
|
* @param {?} trackById
|
7121
|
* @param {?} atOrAfterIndex
|
7122
|
* @return {?}
|
7123
|
*/
|
7124
|
get(trackById, atOrAfterIndex) {
|
7125
|
let /** @type {?} */ record;
|
7126
|
for (record = this._head; record !== null; record = record._nextDup) {
|
7127
|
if ((atOrAfterIndex === null || atOrAfterIndex <= ((record.currentIndex))) &&
|
7128
|
looseIdentical(record.trackById, trackById)) {
|
7129
|
return record;
|
7130
|
}
|
7131
|
}
|
7132
|
return null;
|
7133
|
}
|
7134
|
/**
|
7135
|
* Remove one {\@link IterableChangeRecord_} from the list of duplicates.
|
7136
|
*
|
7137
|
* Returns whether the list of duplicates is empty.
|
7138
|
* @param {?} record
|
7139
|
* @return {?}
|
7140
|
*/
|
7141
|
remove(record) {
|
7142
|
// todo(vicb)
|
7143
|
// assert(() {
|
7144
|
// // verify that the record being removed is in the list.
|
7145
|
// for (IterableChangeRecord_ cursor = _head; cursor != null; cursor = cursor._nextDup) {
|
7146
|
// if (identical(cursor, record)) return true;
|
7147
|
// }
|
7148
|
// return false;
|
7149
|
//});
|
7150
|
const /** @type {?} */ prev = record._prevDup;
|
7151
|
const /** @type {?} */ next = record._nextDup;
|
7152
|
if (prev === null) {
|
7153
|
this._head = next;
|
7154
|
}
|
7155
|
else {
|
7156
|
prev._nextDup = next;
|
7157
|
}
|
7158
|
if (next === null) {
|
7159
|
this._tail = prev;
|
7160
|
}
|
7161
|
else {
|
7162
|
next._prevDup = prev;
|
7163
|
}
|
7164
|
return this._head === null;
|
7165
|
}
|
7166
|
}
|
7167
|
class _DuplicateMap {
|
7168
|
constructor() {
|
7169
|
this.map = new Map();
|
7170
|
}
|
7171
|
/**
|
7172
|
* @param {?} record
|
7173
|
* @return {?}
|
7174
|
*/
|
7175
|
put(record) {
|
7176
|
const /** @type {?} */ key = record.trackById;
|
7177
|
let /** @type {?} */ duplicates = this.map.get(key);
|
7178
|
if (!duplicates) {
|
7179
|
duplicates = new _DuplicateItemRecordList();
|
7180
|
this.map.set(key, duplicates);
|
7181
|
}
|
7182
|
duplicates.add(record);
|
7183
|
}
|
7184
|
/**
|
7185
|
* Retrieve the `value` using key. Because the IterableChangeRecord_ value may be one which we
|
7186
|
* have already iterated over, we use the `atOrAfterIndex` to pretend it is not there.
|
7187
|
*
|
7188
|
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
|
7189
|
* have any more `a`s needs to return the second `a`.
|
7190
|
* @param {?} trackById
|
7191
|
* @param {?} atOrAfterIndex
|
7192
|
* @return {?}
|
7193
|
*/
|
7194
|
get(trackById, atOrAfterIndex) {
|
7195
|
const /** @type {?} */ key = trackById;
|
7196
|
const /** @type {?} */ recordList = this.map.get(key);
|
7197
|
return recordList ? recordList.get(trackById, atOrAfterIndex) : null;
|
7198
|
}
|
7199
|
/**
|
7200
|
* Removes a {\@link IterableChangeRecord_} from the list of duplicates.
|
7201
|
*
|
7202
|
* The list of duplicates also is removed from the map if it gets empty.
|
7203
|
* @param {?} record
|
7204
|
* @return {?}
|
7205
|
*/
|
7206
|
remove(record) {
|
7207
|
const /** @type {?} */ key = record.trackById;
|
7208
|
const /** @type {?} */ recordList = ((this.map.get(key)));
|
7209
|
// Remove the list of duplicates when it gets empty
|
7210
|
if (recordList.remove(record)) {
|
7211
|
this.map.delete(key);
|
7212
|
}
|
7213
|
return record;
|
7214
|
}
|
7215
|
/**
|
7216
|
* @return {?}
|
7217
|
*/
|
7218
|
get isEmpty() { return this.map.size === 0; }
|
7219
|
/**
|
7220
|
* @return {?}
|
7221
|
*/
|
7222
|
clear() { this.map.clear(); }
|
7223
|
/**
|
7224
|
* @return {?}
|
7225
|
*/
|
7226
|
toString() { return '_DuplicateMap(' + stringify(this.map) + ')'; }
|
7227
|
}
|
7228
|
/**
|
7229
|
* @param {?} item
|
7230
|
* @param {?} addRemoveOffset
|
7231
|
* @param {?} moveOffsets
|
7232
|
* @return {?}
|
7233
|
*/
|
7234
|
function getPreviousIndex(item, addRemoveOffset, moveOffsets) {
|
7235
|
const /** @type {?} */ previousIndex = item.previousIndex;
|
7236
|
if (previousIndex === null)
|
7237
|
return previousIndex;
|
7238
|
let /** @type {?} */ moveOffset = 0;
|
7239
|
if (moveOffsets && previousIndex < moveOffsets.length) {
|
7240
|
moveOffset = moveOffsets[previousIndex];
|
7241
|
}
|
7242
|
return previousIndex + addRemoveOffset + moveOffset;
|
7243
|
}
|
7244
|
|
7245
|
/**
|
7246
|
* @license
|
7247
|
* Copyright Google Inc. All Rights Reserved.
|
7248
|
*
|
7249
|
* Use of this source code is governed by an MIT-style license that can be
|
7250
|
* found in the LICENSE file at https://angular.io/license
|
7251
|
*/
|
7252
|
class DefaultKeyValueDifferFactory {
|
7253
|
constructor() { }
|
7254
|
/**
|
7255
|
* @param {?} obj
|
7256
|
* @return {?}
|
7257
|
*/
|
7258
|
supports(obj) { return obj instanceof Map || isJsObject(obj); }
|
7259
|
/**
|
7260
|
* @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
|
7261
|
* @template K, V
|
7262
|
* @param {?=} cd
|
7263
|
* @return {?}
|
7264
|
*/
|
7265
|
create(cd) {
|
7266
|
return new DefaultKeyValueDiffer();
|
7267
|
}
|
7268
|
}
|
7269
|
class DefaultKeyValueDiffer {
|
7270
|
constructor() {
|
7271
|
this._records = new Map();
|
7272
|
this._mapHead = null;
|
7273
|
this._appendAfter = null;
|
7274
|
this._previousMapHead = null;
|
7275
|
this._changesHead = null;
|
7276
|
this._changesTail = null;
|
7277
|
this._additionsHead = null;
|
7278
|
this._additionsTail = null;
|
7279
|
this._removalsHead = null;
|
7280
|
this._removalsTail = null;
|
7281
|
}
|
7282
|
/**
|
7283
|
* @return {?}
|
7284
|
*/
|
7285
|
get isDirty() {
|
7286
|
return this._additionsHead !== null || this._changesHead !== null ||
|
7287
|
this._removalsHead !== null;
|
7288
|
}
|
7289
|
/**
|
7290
|
* @param {?} fn
|
7291
|
* @return {?}
|
7292
|
*/
|
7293
|
forEachItem(fn) {
|
7294
|
let /** @type {?} */ record;
|
7295
|
for (record = this._mapHead; record !== null; record = record._next) {
|
7296
|
fn(record);
|
7297
|
}
|
7298
|
}
|
7299
|
/**
|
7300
|
* @param {?} fn
|
7301
|
* @return {?}
|
7302
|
*/
|
7303
|
forEachPreviousItem(fn) {
|
7304
|
let /** @type {?} */ record;
|
7305
|
for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
|
7306
|
fn(record);
|
7307
|
}
|
7308
|
}
|
7309
|
/**
|
7310
|
* @param {?} fn
|
7311
|
* @return {?}
|
7312
|
*/
|
7313
|
forEachChangedItem(fn) {
|
7314
|
let /** @type {?} */ record;
|
7315
|
for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
7316
|
fn(record);
|
7317
|
}
|
7318
|
}
|
7319
|
/**
|
7320
|
* @param {?} fn
|
7321
|
* @return {?}
|
7322
|
*/
|
7323
|
forEachAddedItem(fn) {
|
7324
|
let /** @type {?} */ record;
|
7325
|
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
7326
|
fn(record);
|
7327
|
}
|
7328
|
}
|
7329
|
/**
|
7330
|
* @param {?} fn
|
7331
|
* @return {?}
|
7332
|
*/
|
7333
|
forEachRemovedItem(fn) {
|
7334
|
let /** @type {?} */ record;
|
7335
|
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
7336
|
fn(record);
|
7337
|
}
|
7338
|
}
|
7339
|
/**
|
7340
|
* @param {?=} map
|
7341
|
* @return {?}
|
7342
|
*/
|
7343
|
diff(map) {
|
7344
|
if (!map) {
|
7345
|
map = new Map();
|
7346
|
}
|
7347
|
else if (!(map instanceof Map || isJsObject(map))) {
|
7348
|
throw new Error(`Error trying to diff '${stringify(map)}'. Only maps and objects are allowed`);
|
7349
|
}
|
7350
|
return this.check(map) ? this : null;
|
7351
|
}
|
7352
|
/**
|
7353
|
* @return {?}
|
7354
|
*/
|
7355
|
onDestroy() { }
|
7356
|
/**
|
7357
|
* Check the current state of the map vs the previous.
|
7358
|
* The algorithm is optimised for when the keys do no change.
|
7359
|
* @param {?} map
|
7360
|
* @return {?}
|
7361
|
*/
|
7362
|
check(map) {
|
7363
|
this._reset();
|
7364
|
let /** @type {?} */ insertBefore = this._mapHead;
|
7365
|
this._appendAfter = null;
|
7366
|
this._forEach(map, (value, key) => {
|
7367
|
if (insertBefore && insertBefore.key === key) {
|
7368
|
this._maybeAddToChanges(insertBefore, value);
|
7369
|
this._appendAfter = insertBefore;
|
7370
|
insertBefore = insertBefore._next;
|
7371
|
}
|
7372
|
else {
|
7373
|
const /** @type {?} */ record = this._getOrCreateRecordForKey(key, value);
|
7374
|
insertBefore = this._insertBeforeOrAppend(insertBefore, record);
|
7375
|
}
|
7376
|
});
|
7377
|
// Items remaining at the end of the list have been deleted
|
7378
|
if (insertBefore) {
|
7379
|
if (insertBefore._prev) {
|
7380
|
insertBefore._prev._next = null;
|
7381
|
}
|
7382
|
this._removalsHead = insertBefore;
|
7383
|
for (let /** @type {?} */ record = insertBefore; record !== null; record = record._nextRemoved) {
|
7384
|
if (record === this._mapHead) {
|
7385
|
this._mapHead = null;
|
7386
|
}
|
7387
|
this._records.delete(record.key);
|
7388
|
record._nextRemoved = record._next;
|
7389
|
record.previousValue = record.currentValue;
|
7390
|
record.currentValue = null;
|
7391
|
record._prev = null;
|
7392
|
record._next = null;
|
7393
|
}
|
7394
|
}
|
7395
|
// Make sure tails have no next records from previous runs
|
7396
|
if (this._changesTail)
|
7397
|
this._changesTail._nextChanged = null;
|
7398
|
if (this._additionsTail)
|
7399
|
this._additionsTail._nextAdded = null;
|
7400
|
return this.isDirty;
|
7401
|
}
|
7402
|
/**
|
7403
|
* Inserts a record before `before` or append at the end of the list when `before` is null.
|
7404
|
*
|
7405
|
* Notes:
|
7406
|
* - This method appends at `this._appendAfter`,
|
7407
|
* - This method updates `this._appendAfter`,
|
7408
|
* - The return value is the new value for the insertion pointer.
|
7409
|
* @param {?} before
|
7410
|
* @param {?} record
|
7411
|
* @return {?}
|
7412
|
*/
|
7413
|
_insertBeforeOrAppend(before, record) {
|
7414
|
if (before) {
|
7415
|
const /** @type {?} */ prev = before._prev;
|
7416
|
record._next = before;
|
7417
|
record._prev = prev;
|
7418
|
before._prev = record;
|
7419
|
if (prev) {
|
7420
|
prev._next = record;
|
7421
|
}
|
7422
|
if (before === this._mapHead) {
|
7423
|
this._mapHead = record;
|
7424
|
}
|
7425
|
this._appendAfter = before;
|
7426
|
return before;
|
7427
|
}
|
7428
|
if (this._appendAfter) {
|
7429
|
this._appendAfter._next = record;
|
7430
|
record._prev = this._appendAfter;
|
7431
|
}
|
7432
|
else {
|
7433
|
this._mapHead = record;
|
7434
|
}
|
7435
|
this._appendAfter = record;
|
7436
|
return null;
|
7437
|
}
|
7438
|
/**
|
7439
|
* @param {?} key
|
7440
|
* @param {?} value
|
7441
|
* @return {?}
|
7442
|
*/
|
7443
|
_getOrCreateRecordForKey(key, value) {
|
7444
|
if (this._records.has(key)) {
|
7445
|
const /** @type {?} */ record = ((this._records.get(key)));
|
7446
|
this._maybeAddToChanges(record, value);
|
7447
|
const /** @type {?} */ prev = record._prev;
|
7448
|
const /** @type {?} */ next = record._next;
|
7449
|
if (prev) {
|
7450
|
prev._next = next;
|
7451
|
}
|
7452
|
if (next) {
|
7453
|
next._prev = prev;
|
7454
|
}
|
7455
|
record._next = null;
|
7456
|
record._prev = null;
|
7457
|
return record;
|
7458
|
}
|
7459
|
const /** @type {?} */ record = new KeyValueChangeRecord_(key);
|
7460
|
this._records.set(key, record);
|
7461
|
record.currentValue = value;
|
7462
|
this._addToAdditions(record);
|
7463
|
return record;
|
7464
|
}
|
7465
|
/**
|
7466
|
* \@internal
|
7467
|
* @return {?}
|
7468
|
*/
|
7469
|
_reset() {
|
7470
|
if (this.isDirty) {
|
7471
|
let /** @type {?} */ record;
|
7472
|
// let `_previousMapHead` contain the state of the map before the changes
|
7473
|
this._previousMapHead = this._mapHead;
|
7474
|
for (record = this._previousMapHead; record !== null; record = record._next) {
|
7475
|
record._nextPrevious = record._next;
|
7476
|
}
|
7477
|
// Update `record.previousValue` with the value of the item before the changes
|
7478
|
// We need to update all changed items (that's those which have been added and changed)
|
7479
|
for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
7480
|
record.previousValue = record.currentValue;
|
7481
|
}
|
7482
|
for (record = this._additionsHead; record != null; record = record._nextAdded) {
|
7483
|
record.previousValue = record.currentValue;
|
7484
|
}
|
7485
|
this._changesHead = this._changesTail = null;
|
7486
|
this._additionsHead = this._additionsTail = null;
|
7487
|
this._removalsHead = null;
|
7488
|
}
|
7489
|
}
|
7490
|
/**
|
7491
|
* @param {?} record
|
7492
|
* @param {?} newValue
|
7493
|
* @return {?}
|
7494
|
*/
|
7495
|
_maybeAddToChanges(record, newValue) {
|
7496
|
if (!looseIdentical(newValue, record.currentValue)) {
|
7497
|
record.previousValue = record.currentValue;
|
7498
|
record.currentValue = newValue;
|
7499
|
this._addToChanges(record);
|
7500
|
}
|
7501
|
}
|
7502
|
/**
|
7503
|
* @param {?} record
|
7504
|
* @return {?}
|
7505
|
*/
|
7506
|
_addToAdditions(record) {
|
7507
|
if (this._additionsHead === null) {
|
7508
|
this._additionsHead = this._additionsTail = record;
|
7509
|
}
|
7510
|
else {
|
7511
|
((this._additionsTail))._nextAdded = record;
|
7512
|
this._additionsTail = record;
|
7513
|
}
|
7514
|
}
|
7515
|
/**
|
7516
|
* @param {?} record
|
7517
|
* @return {?}
|
7518
|
*/
|
7519
|
_addToChanges(record) {
|
7520
|
if (this._changesHead === null) {
|
7521
|
this._changesHead = this._changesTail = record;
|
7522
|
}
|
7523
|
else {
|
7524
|
((this._changesTail))._nextChanged = record;
|
7525
|
this._changesTail = record;
|
7526
|
}
|
7527
|
}
|
7528
|
/**
|
7529
|
* \@internal
|
7530
|
* @template K, V
|
7531
|
* @param {?} obj
|
7532
|
* @param {?} fn
|
7533
|
* @return {?}
|
7534
|
*/
|
7535
|
_forEach(obj, fn) {
|
7536
|
if (obj instanceof Map) {
|
7537
|
obj.forEach(fn);
|
7538
|
}
|
7539
|
else {
|
7540
|
Object.keys(obj).forEach(k => fn(obj[k], k));
|
7541
|
}
|
7542
|
}
|
7543
|
}
|
7544
|
/**
|
7545
|
* \@stable
|
7546
|
*/
|
7547
|
class KeyValueChangeRecord_ {
|
7548
|
/**
|
7549
|
* @param {?} key
|
7550
|
*/
|
7551
|
constructor(key) {
|
7552
|
this.key = key;
|
7553
|
this.previousValue = null;
|
7554
|
this.currentValue = null;
|
7555
|
/**
|
7556
|
* \@internal
|
7557
|
*/
|
7558
|
this._nextPrevious = null;
|
7559
|
/**
|
7560
|
* \@internal
|
7561
|
*/
|
7562
|
this._next = null;
|
7563
|
/**
|
7564
|
* \@internal
|
7565
|
*/
|
7566
|
this._prev = null;
|
7567
|
/**
|
7568
|
* \@internal
|
7569
|
*/
|
7570
|
this._nextAdded = null;
|
7571
|
/**
|
7572
|
* \@internal
|
7573
|
*/
|
7574
|
this._nextRemoved = null;
|
7575
|
/**
|
7576
|
* \@internal
|
7577
|
*/
|
7578
|
this._nextChanged = null;
|
7579
|
}
|
7580
|
}
|
7581
|
|
7582
|
/**
|
7583
|
* @license
|
7584
|
* Copyright Google Inc. All Rights Reserved.
|
7585
|
*
|
7586
|
* Use of this source code is governed by an MIT-style license that can be
|
7587
|
* found in the LICENSE file at https://angular.io/license
|
7588
|
*/
|
7589
|
/**
|
7590
|
* A repository of different iterable diffing strategies used by NgFor, NgClass, and others.
|
7591
|
* \@stable
|
7592
|
*/
|
7593
|
class IterableDiffers {
|
7594
|
/**
|
7595
|
* @param {?} factories
|
7596
|
*/
|
7597
|
constructor(factories) { this.factories = factories; }
|
7598
|
/**
|
7599
|
* @param {?} factories
|
7600
|
* @param {?=} parent
|
7601
|
* @return {?}
|
7602
|
*/
|
7603
|
static create(factories, parent) {
|
7604
|
if (parent != null) {
|
7605
|
const /** @type {?} */ copied = parent.factories.slice();
|
7606
|
factories = factories.concat(copied);
|
7607
|
return new IterableDiffers(factories);
|
7608
|
}
|
7609
|
else {
|
7610
|
return new IterableDiffers(factories);
|
7611
|
}
|
7612
|
}
|
7613
|
/**
|
7614
|
* Takes an array of {\@link IterableDifferFactory} and returns a provider used to extend the
|
7615
|
* inherited {\@link IterableDiffers} instance with the provided factories and return a new
|
7616
|
* {\@link IterableDiffers} instance.
|
7617
|
*
|
7618
|
* The following example shows how to extend an existing list of factories,
|
7619
|
* which will only be applied to the injector for this component and its children.
|
7620
|
* This step is all that's required to make a new {\@link IterableDiffer} available.
|
7621
|
*
|
7622
|
* ### Example
|
7623
|
*
|
7624
|
* ```
|
7625
|
* \@Component({
|
7626
|
* viewProviders: [
|
7627
|
* IterableDiffers.extend([new ImmutableListDiffer()])
|
7628
|
* ]
|
7629
|
* })
|
7630
|
* ```
|
7631
|
* @param {?} factories
|
7632
|
* @return {?}
|
7633
|
*/
|
7634
|
static extend(factories) {
|
7635
|
return {
|
7636
|
provide: IterableDiffers,
|
7637
|
useFactory: (parent) => {
|
7638
|
if (!parent) {
|
7639
|
// Typically would occur when calling IterableDiffers.extend inside of dependencies passed
|
7640
|
// to
|
7641
|
// bootstrap(), which would override default pipes instead of extending them.
|
7642
|
throw new Error('Cannot extend IterableDiffers without a parent injector');
|
7643
|
}
|
7644
|
return IterableDiffers.create(factories, parent);
|
7645
|
},
|
7646
|
// Dependency technically isn't optional, but we can provide a better error message this way.
|
7647
|
deps: [[IterableDiffers, new SkipSelf(), new Optional()]]
|
7648
|
};
|
7649
|
}
|
7650
|
/**
|
7651
|
* @param {?} iterable
|
7652
|
* @return {?}
|
7653
|
*/
|
7654
|
find(iterable) {
|
7655
|
const /** @type {?} */ factory = this.factories.find(f => f.supports(iterable));
|
7656
|
if (factory != null) {
|
7657
|
return factory;
|
7658
|
}
|
7659
|
else {
|
7660
|
throw new Error(`Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'`);
|
7661
|
}
|
7662
|
}
|
7663
|
}
|
7664
|
/**
|
7665
|
* @param {?} type
|
7666
|
* @return {?}
|
7667
|
*/
|
7668
|
function getTypeNameForDebugging(type) {
|
7669
|
return type['name'] || typeof type;
|
7670
|
}
|
7671
|
|
7672
|
/**
|
7673
|
* @license
|
7674
|
* Copyright Google Inc. All Rights Reserved.
|
7675
|
*
|
7676
|
* Use of this source code is governed by an MIT-style license that can be
|
7677
|
* found in the LICENSE file at https://angular.io/license
|
7678
|
*/
|
7679
|
/**
|
7680
|
* A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
|
7681
|
* \@stable
|
7682
|
*/
|
7683
|
class KeyValueDiffers {
|
7684
|
/**
|
7685
|
* @param {?} factories
|
7686
|
*/
|
7687
|
constructor(factories) { this.factories = factories; }
|
7688
|
/**
|
7689
|
* @template S
|
7690
|
* @param {?} factories
|
7691
|
* @param {?=} parent
|
7692
|
* @return {?}
|
7693
|
*/
|
7694
|
static create(factories, parent) {
|
7695
|
if (parent) {
|
7696
|
const /** @type {?} */ copied = parent.factories.slice();
|
7697
|
factories = factories.concat(copied);
|
7698
|
}
|
7699
|
return new KeyValueDiffers(factories);
|
7700
|
}
|
7701
|
/**
|
7702
|
* Takes an array of {\@link KeyValueDifferFactory} and returns a provider used to extend the
|
7703
|
* inherited {\@link KeyValueDiffers} instance with the provided factories and return a new
|
7704
|
* {\@link KeyValueDiffers} instance.
|
7705
|
*
|
7706
|
* The following example shows how to extend an existing list of factories,
|
7707
|
* which will only be applied to the injector for this component and its children.
|
7708
|
* This step is all that's required to make a new {\@link KeyValueDiffer} available.
|
7709
|
*
|
7710
|
* ### Example
|
7711
|
*
|
7712
|
* ```
|
7713
|
* \@Component({
|
7714
|
* viewProviders: [
|
7715
|
* KeyValueDiffers.extend([new ImmutableMapDiffer()])
|
7716
|
* ]
|
7717
|
* })
|
7718
|
* ```
|
7719
|
* @template S
|
7720
|
* @param {?} factories
|
7721
|
* @return {?}
|
7722
|
*/
|
7723
|
static extend(factories) {
|
7724
|
return {
|
7725
|
provide: KeyValueDiffers,
|
7726
|
useFactory: (parent) => {
|
7727
|
if (!parent) {
|
7728
|
// Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
|
7729
|
// to bootstrap(), which would override default pipes instead of extending them.
|
7730
|
throw new Error('Cannot extend KeyValueDiffers without a parent injector');
|
7731
|
}
|
7732
|
return KeyValueDiffers.create(factories, parent);
|
7733
|
},
|
7734
|
// Dependency technically isn't optional, but we can provide a better error message this way.
|
7735
|
deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
|
7736
|
};
|
7737
|
}
|
7738
|
/**
|
7739
|
* @param {?} kv
|
7740
|
* @return {?}
|
7741
|
*/
|
7742
|
find(kv) {
|
7743
|
const /** @type {?} */ factory = this.factories.find(f => f.supports(kv));
|
7744
|
if (factory) {
|
7745
|
return factory;
|
7746
|
}
|
7747
|
throw new Error(`Cannot find a differ supporting object '${kv}'`);
|
7748
|
}
|
7749
|
}
|
7750
|
|
7751
|
/**
|
7752
|
* @license
|
7753
|
* Copyright Google Inc. All Rights Reserved.
|
7754
|
*
|
7755
|
* Use of this source code is governed by an MIT-style license that can be
|
7756
|
* found in the LICENSE file at https://angular.io/license
|
7757
|
*/
|
7758
|
/**
|
7759
|
* Structural diffing for `Object`s and `Map`s.
|
7760
|
*/
|
7761
|
const keyValDiff = [new DefaultKeyValueDifferFactory()];
|
7762
|
/**
|
7763
|
* Structural diffing for `Iterable` types such as `Array`s.
|
7764
|
*/
|
7765
|
const iterableDiff = [new DefaultIterableDifferFactory()];
|
7766
|
const defaultIterableDiffers = new IterableDiffers(iterableDiff);
|
7767
|
const defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
|
7768
|
|
7769
|
/**
|
7770
|
* @license
|
7771
|
* Copyright Google Inc. All Rights Reserved.
|
7772
|
*
|
7773
|
* Use of this source code is governed by an MIT-style license that can be
|
7774
|
* found in the LICENSE file at https://angular.io/license
|
7775
|
*/
|
7776
|
/**
|
7777
|
* @module
|
7778
|
* @description
|
7779
|
* Change detection enables data binding in Angular.
|
7780
|
*/
|
7781
|
|
7782
|
/**
|
7783
|
* @license
|
7784
|
* Copyright Google Inc. All Rights Reserved.
|
7785
|
*
|
7786
|
* Use of this source code is governed by an MIT-style license that can be
|
7787
|
* found in the LICENSE file at https://angular.io/license
|
7788
|
*/
|
7789
|
/**
|
7790
|
* @return {?}
|
7791
|
*/
|
7792
|
function _reflector() {
|
7793
|
return reflector;
|
7794
|
}
|
7795
|
const _CORE_PLATFORM_PROVIDERS = [
|
7796
|
// Set a default platform name for platforms that don't set it explicitly.
|
7797
|
{ provide: PLATFORM_ID, useValue: 'unknown' },
|
7798
|
PlatformRef_,
|
7799
|
{ provide: PlatformRef, useExisting: PlatformRef_ },
|
7800
|
{ provide: Reflector, useFactory: _reflector, deps: [] },
|
7801
|
TestabilityRegistry,
|
7802
|
Console,
|
7803
|
];
|
7804
|
/**
|
7805
|
* This platform has to be included in any other platform
|
7806
|
*
|
7807
|
* \@experimental
|
7808
|
*/
|
7809
|
const platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
|
7810
|
|
7811
|
/**
|
7812
|
* @license
|
7813
|
* Copyright Google Inc. All Rights Reserved.
|
7814
|
*
|
7815
|
* Use of this source code is governed by an MIT-style license that can be
|
7816
|
* found in the LICENSE file at https://angular.io/license
|
7817
|
*/
|
7818
|
/**
|
7819
|
* \@experimental i18n support is experimental.
|
7820
|
*/
|
7821
|
const LOCALE_ID = new InjectionToken('LocaleId');
|
7822
|
/**
|
7823
|
* \@experimental i18n support is experimental.
|
7824
|
*/
|
7825
|
const TRANSLATIONS = new InjectionToken('Translations');
|
7826
|
/**
|
7827
|
* \@experimental i18n support is experimental.
|
7828
|
*/
|
7829
|
const TRANSLATIONS_FORMAT = new InjectionToken('TranslationsFormat');
|
7830
|
let MissingTranslationStrategy = {};
|
7831
|
MissingTranslationStrategy.Error = 0;
|
7832
|
MissingTranslationStrategy.Warning = 1;
|
7833
|
MissingTranslationStrategy.Ignore = 2;
|
7834
|
MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
|
7835
|
MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
|
7836
|
MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
|
7837
|
|
7838
|
/**
|
7839
|
* @license
|
7840
|
* Copyright Google Inc. All Rights Reserved.
|
7841
|
*
|
7842
|
* Use of this source code is governed by an MIT-style license that can be
|
7843
|
* found in the LICENSE file at https://angular.io/license
|
7844
|
*/
|
7845
|
/**
|
7846
|
* @return {?}
|
7847
|
*/
|
7848
|
function _iterableDiffersFactory() {
|
7849
|
return defaultIterableDiffers;
|
7850
|
}
|
7851
|
/**
|
7852
|
* @return {?}
|
7853
|
*/
|
7854
|
function _keyValueDiffersFactory() {
|
7855
|
return defaultKeyValueDiffers;
|
7856
|
}
|
7857
|
/**
|
7858
|
* @param {?=} locale
|
7859
|
* @return {?}
|
7860
|
*/
|
7861
|
function _localeFactory(locale) {
|
7862
|
return locale || 'en-US';
|
7863
|
}
|
7864
|
/**
|
7865
|
* This module includes the providers of \@angular/core that are needed
|
7866
|
* to bootstrap components via `ApplicationRef`.
|
7867
|
*
|
7868
|
* \@experimental
|
7869
|
*/
|
7870
|
class ApplicationModule {
|
7871
|
/**
|
7872
|
* @param {?} appRef
|
7873
|
*/
|
7874
|
constructor(appRef) { }
|
7875
|
}
|
7876
|
ApplicationModule.decorators = [
|
7877
|
{ type: NgModule, args: [{
|
7878
|
providers: [
|
7879
|
ApplicationRef_,
|
7880
|
{ provide: ApplicationRef, useExisting: ApplicationRef_ },
|
7881
|
ApplicationInitStatus,
|
7882
|
Compiler,
|
7883
|
APP_ID_RANDOM_PROVIDER,
|
7884
|
{ provide: IterableDiffers, useFactory: _iterableDiffersFactory },
|
7885
|
{ provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory },
|
7886
|
{
|
7887
|
provide: LOCALE_ID,
|
7888
|
useFactory: _localeFactory,
|
7889
|
deps: [[new Inject(LOCALE_ID), new Optional(), new SkipSelf()]]
|
7890
|
},
|
7891
|
]
|
7892
|
},] },
|
7893
|
];
|
7894
|
/**
|
7895
|
* @nocollapse
|
7896
|
*/
|
7897
|
ApplicationModule.ctorParameters = () => [
|
7898
|
{ type: ApplicationRef, },
|
7899
|
];
|
7900
|
|
7901
|
let SecurityContext = {};
|
7902
|
SecurityContext.NONE = 0;
|
7903
|
SecurityContext.HTML = 1;
|
7904
|
SecurityContext.STYLE = 2;
|
7905
|
SecurityContext.SCRIPT = 3;
|
7906
|
SecurityContext.URL = 4;
|
7907
|
SecurityContext.RESOURCE_URL = 5;
|
7908
|
SecurityContext[SecurityContext.NONE] = "NONE";
|
7909
|
SecurityContext[SecurityContext.HTML] = "HTML";
|
7910
|
SecurityContext[SecurityContext.STYLE] = "STYLE";
|
7911
|
SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
|
7912
|
SecurityContext[SecurityContext.URL] = "URL";
|
7913
|
SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
|
7914
|
/**
|
7915
|
* Sanitizer is used by the views to sanitize potentially dangerous values.
|
7916
|
*
|
7917
|
* \@stable
|
7918
|
* @abstract
|
7919
|
*/
|
7920
|
class Sanitizer {
|
7921
|
/**
|
7922
|
* @abstract
|
7923
|
* @param {?} context
|
7924
|
* @param {?} value
|
7925
|
* @return {?}
|
7926
|
*/
|
7927
|
sanitize(context, value) { }
|
7928
|
}
|
7929
|
|
7930
|
/**
|
7931
|
* @license
|
7932
|
* Copyright Google Inc. All Rights Reserved.
|
7933
|
*
|
7934
|
* Use of this source code is governed by an MIT-style license that can be
|
7935
|
* found in the LICENSE file at https://angular.io/license
|
7936
|
*/
|
7937
|
/**
|
7938
|
* Node instance data.
|
7939
|
*
|
7940
|
* We have a separate type per NodeType to save memory
|
7941
|
* (TextData | ElementData | ProviderData | PureExpressionData | QueryList<any>)
|
7942
|
*
|
7943
|
* To keep our code monomorphic,
|
7944
|
* we prohibit using `NodeData` directly but enforce the use of accessors (`asElementData`, ...).
|
7945
|
* This way, no usage site can get a `NodeData` from view.nodes and then use it for different
|
7946
|
* purposes.
|
7947
|
*/
|
7948
|
|
7949
|
/**
|
7950
|
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
|
7951
|
* @param {?} view
|
7952
|
* @param {?} index
|
7953
|
* @return {?}
|
7954
|
*/
|
7955
|
function asTextData(view, index) {
|
7956
|
return (view.nodes[index]);
|
7957
|
}
|
7958
|
/**
|
7959
|
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
|
7960
|
* @param {?} view
|
7961
|
* @param {?} index
|
7962
|
* @return {?}
|
7963
|
*/
|
7964
|
function asElementData(view, index) {
|
7965
|
return (view.nodes[index]);
|
7966
|
}
|
7967
|
/**
|
7968
|
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
|
7969
|
* @param {?} view
|
7970
|
* @param {?} index
|
7971
|
* @return {?}
|
7972
|
*/
|
7973
|
function asProviderData(view, index) {
|
7974
|
return (view.nodes[index]);
|
7975
|
}
|
7976
|
/**
|
7977
|
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
|
7978
|
* @param {?} view
|
7979
|
* @param {?} index
|
7980
|
* @return {?}
|
7981
|
*/
|
7982
|
function asPureExpressionData(view, index) {
|
7983
|
return (view.nodes[index]);
|
7984
|
}
|
7985
|
/**
|
7986
|
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
|
7987
|
* @param {?} view
|
7988
|
* @param {?} index
|
7989
|
* @return {?}
|
7990
|
*/
|
7991
|
function asQueryList(view, index) {
|
7992
|
return (view.nodes[index]);
|
7993
|
}
|
7994
|
/**
|
7995
|
* @abstract
|
7996
|
*/
|
7997
|
class DebugContext {
|
7998
|
/**
|
7999
|
* @abstract
|
8000
|
* @return {?}
|
8001
|
*/
|
8002
|
view() { }
|
8003
|
/**
|
8004
|
* @abstract
|
8005
|
* @return {?}
|
8006
|
*/
|
8007
|
nodeIndex() { }
|
8008
|
/**
|
8009
|
* @abstract
|
8010
|
* @return {?}
|
8011
|
*/
|
8012
|
injector() { }
|
8013
|
/**
|
8014
|
* @abstract
|
8015
|
* @return {?}
|
8016
|
*/
|
8017
|
component() { }
|
8018
|
/**
|
8019
|
* @abstract
|
8020
|
* @return {?}
|
8021
|
*/
|
8022
|
providerTokens() { }
|
8023
|
/**
|
8024
|
* @abstract
|
8025
|
* @return {?}
|
8026
|
*/
|
8027
|
references() { }
|
8028
|
/**
|
8029
|
* @abstract
|
8030
|
* @return {?}
|
8031
|
*/
|
8032
|
context() { }
|
8033
|
/**
|
8034
|
* @abstract
|
8035
|
* @return {?}
|
8036
|
*/
|
8037
|
componentRenderElement() { }
|
8038
|
/**
|
8039
|
* @abstract
|
8040
|
* @return {?}
|
8041
|
*/
|
8042
|
renderNode() { }
|
8043
|
/**
|
8044
|
* @abstract
|
8045
|
* @param {?} console
|
8046
|
* @param {...?} values
|
8047
|
* @return {?}
|
8048
|
*/
|
8049
|
logError(console, ...values) { }
|
8050
|
}
|
8051
|
/**
|
8052
|
* This object is used to prevent cycles in the source files and to have a place where
|
8053
|
* debug mode can hook it. It is lazily filled when `isDevMode` is known.
|
8054
|
*/
|
8055
|
const Services = {
|
8056
|
setCurrentNode: undefined,
|
8057
|
createRootView: undefined,
|
8058
|
createEmbeddedView: undefined,
|
8059
|
createComponentView: undefined,
|
8060
|
createNgModuleRef: undefined,
|
8061
|
overrideProvider: undefined,
|
8062
|
clearProviderOverrides: undefined,
|
8063
|
checkAndUpdateView: undefined,
|
8064
|
checkNoChangesView: undefined,
|
8065
|
destroyView: undefined,
|
8066
|
resolveDep: undefined,
|
8067
|
createDebugContext: undefined,
|
8068
|
handleEvent: undefined,
|
8069
|
updateDirectives: undefined,
|
8070
|
updateRenderer: undefined,
|
8071
|
dirtyParentQueries: undefined,
|
8072
|
};
|
8073
|
|
8074
|
/**
|
8075
|
* @license
|
8076
|
* Copyright Google Inc. All Rights Reserved.
|
8077
|
*
|
8078
|
* Use of this source code is governed by an MIT-style license that can be
|
8079
|
* found in the LICENSE file at https://angular.io/license
|
8080
|
*/
|
8081
|
/**
|
8082
|
* @param {?} context
|
8083
|
* @param {?} oldValue
|
8084
|
* @param {?} currValue
|
8085
|
* @param {?} isFirstCheck
|
8086
|
* @return {?}
|
8087
|
*/
|
8088
|
function expressionChangedAfterItHasBeenCheckedError(context, oldValue, currValue, isFirstCheck) {
|
8089
|
let /** @type {?} */ msg = `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '${oldValue}'. Current value: '${currValue}'.`;
|
8090
|
if (isFirstCheck) {
|
8091
|
msg +=
|
8092
|
` It seems like the view has been created after its parent and its children have been dirty checked.` +
|
8093
|
` Has it been created in a change detection hook ?`;
|
8094
|
}
|
8095
|
return viewDebugError(msg, context);
|
8096
|
}
|
8097
|
/**
|
8098
|
* @param {?} err
|
8099
|
* @param {?} context
|
8100
|
* @return {?}
|
8101
|
*/
|
8102
|
function viewWrappedDebugError(err, context) {
|
8103
|
if (!(err instanceof Error)) {
|
8104
|
// errors that are not Error instances don't have a stack,
|
8105
|
// so it is ok to wrap them into a new Error object...
|
8106
|
err = new Error(err.toString());
|
8107
|
}
|
8108
|
_addDebugContext(err, context);
|
8109
|
return err;
|
8110
|
}
|
8111
|
/**
|
8112
|
* @param {?} msg
|
8113
|
* @param {?} context
|
8114
|
* @return {?}
|
8115
|
*/
|
8116
|
function viewDebugError(msg, context) {
|
8117
|
const /** @type {?} */ err = new Error(msg);
|
8118
|
_addDebugContext(err, context);
|
8119
|
return err;
|
8120
|
}
|
8121
|
/**
|
8122
|
* @param {?} err
|
8123
|
* @param {?} context
|
8124
|
* @return {?}
|
8125
|
*/
|
8126
|
function _addDebugContext(err, context) {
|
8127
|
((err))[ERROR_DEBUG_CONTEXT] = context;
|
8128
|
((err))[ERROR_LOGGER] = context.logError.bind(context);
|
8129
|
}
|
8130
|
/**
|
8131
|
* @param {?} err
|
8132
|
* @return {?}
|
8133
|
*/
|
8134
|
function isViewDebugError(err) {
|
8135
|
return !!getDebugContext(err);
|
8136
|
}
|
8137
|
/**
|
8138
|
* @param {?} action
|
8139
|
* @return {?}
|
8140
|
*/
|
8141
|
function viewDestroyedError(action) {
|
8142
|
return new Error(`ViewDestroyedError: Attempt to use a destroyed view: ${action}`);
|
8143
|
}
|
8144
|
|
8145
|
/**
|
8146
|
* @license
|
8147
|
* Copyright Google Inc. All Rights Reserved.
|
8148
|
*
|
8149
|
* Use of this source code is governed by an MIT-style license that can be
|
8150
|
* found in the LICENSE file at https://angular.io/license
|
8151
|
*/
|
8152
|
const NOOP = () => { };
|
8153
|
const _tokenKeyCache = new Map();
|
8154
|
/**
|
8155
|
* @param {?} token
|
8156
|
* @return {?}
|
8157
|
*/
|
8158
|
function tokenKey(token) {
|
8159
|
let /** @type {?} */ key = _tokenKeyCache.get(token);
|
8160
|
if (!key) {
|
8161
|
key = stringify(token) + '_' + _tokenKeyCache.size;
|
8162
|
_tokenKeyCache.set(token, key);
|
8163
|
}
|
8164
|
return key;
|
8165
|
}
|
8166
|
/**
|
8167
|
* @param {?} view
|
8168
|
* @param {?} nodeIdx
|
8169
|
* @param {?} bindingIdx
|
8170
|
* @param {?} value
|
8171
|
* @return {?}
|
8172
|
*/
|
8173
|
function unwrapValue(view, nodeIdx, bindingIdx, value) {
|
8174
|
if (value instanceof WrappedValue) {
|
8175
|
value = value.wrapped;
|
8176
|
let /** @type {?} */ globalBindingIdx = view.def.nodes[nodeIdx].bindingIndex + bindingIdx;
|
8177
|
let /** @type {?} */ oldValue = view.oldValues[globalBindingIdx];
|
8178
|
if (oldValue instanceof WrappedValue) {
|
8179
|
oldValue = oldValue.wrapped;
|
8180
|
}
|
8181
|
view.oldValues[globalBindingIdx] = new WrappedValue(oldValue);
|
8182
|
}
|
8183
|
return value;
|
8184
|
}
|
8185
|
const UNDEFINED_RENDERER_TYPE_ID = '$$undefined';
|
8186
|
const EMPTY_RENDERER_TYPE_ID = '$$empty';
|
8187
|
/**
|
8188
|
* @param {?} values
|
8189
|
* @return {?}
|
8190
|
*/
|
8191
|
function createRendererType2(values) {
|
8192
|
return {
|
8193
|
id: UNDEFINED_RENDERER_TYPE_ID,
|
8194
|
styles: values.styles,
|
8195
|
encapsulation: values.encapsulation,
|
8196
|
data: values.data
|
8197
|
};
|
8198
|
}
|
8199
|
let _renderCompCount = 0;
|
8200
|
/**
|
8201
|
* @param {?=} type
|
8202
|
* @return {?}
|
8203
|
*/
|
8204
|
function resolveRendererType2(type) {
|
8205
|
if (type && type.id === UNDEFINED_RENDERER_TYPE_ID) {
|
8206
|
// first time we see this RendererType2. Initialize it...
|
8207
|
const /** @type {?} */ isFilled = ((type.encapsulation != null && type.encapsulation !== ViewEncapsulation.None) ||
|
8208
|
type.styles.length || Object.keys(type.data).length);
|
8209
|
if (isFilled) {
|
8210
|
type.id = `c${_renderCompCount++}`;
|
8211
|
}
|
8212
|
else {
|
8213
|
type.id = EMPTY_RENDERER_TYPE_ID;
|
8214
|
}
|
8215
|
}
|
8216
|
if (type && type.id === EMPTY_RENDERER_TYPE_ID) {
|
8217
|
type = null;
|
8218
|
}
|
8219
|
return type || null;
|
8220
|
}
|
8221
|
/**
|
8222
|
* @param {?} view
|
8223
|
* @param {?} def
|
8224
|
* @param {?} bindingIdx
|
8225
|
* @param {?} value
|
8226
|
* @return {?}
|
8227
|
*/
|
8228
|
function checkBinding(view, def, bindingIdx, value) {
|
8229
|
const /** @type {?} */ oldValues = view.oldValues;
|
8230
|
if ((view.state & 2 /* FirstCheck */) ||
|
8231
|
!looseIdentical(oldValues[def.bindingIndex + bindingIdx], value)) {
|
8232
|
return true;
|
8233
|
}
|
8234
|
return false;
|
8235
|
}
|
8236
|
/**
|
8237
|
* @param {?} view
|
8238
|
* @param {?} def
|
8239
|
* @param {?} bindingIdx
|
8240
|
* @param {?} value
|
8241
|
* @return {?}
|
8242
|
*/
|
8243
|
function checkAndUpdateBinding(view, def, bindingIdx, value) {
|
8244
|
if (checkBinding(view, def, bindingIdx, value)) {
|
8245
|
view.oldValues[def.bindingIndex + bindingIdx] = value;
|
8246
|
return true;
|
8247
|
}
|
8248
|
return false;
|
8249
|
}
|
8250
|
/**
|
8251
|
* @param {?} view
|
8252
|
* @param {?} def
|
8253
|
* @param {?} bindingIdx
|
8254
|
* @param {?} value
|
8255
|
* @return {?}
|
8256
|
*/
|
8257
|
function checkBindingNoChanges(view, def, bindingIdx, value) {
|
8258
|
const /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
|
8259
|
if ((view.state & 1 /* BeforeFirstCheck */) || !devModeEqual(oldValue, value)) {
|
8260
|
throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, def.nodeIndex), oldValue, value, (view.state & 1 /* BeforeFirstCheck */) !== 0);
|
8261
|
}
|
8262
|
}
|
8263
|
/**
|
8264
|
* @param {?} view
|
8265
|
* @return {?}
|
8266
|
*/
|
8267
|
function markParentViewsForCheck(view) {
|
8268
|
let /** @type {?} */ currView = view;
|
8269
|
while (currView) {
|
8270
|
if (currView.def.flags & 2 /* OnPush */) {
|
8271
|
currView.state |= 8 /* ChecksEnabled */;
|
8272
|
}
|
8273
|
currView = currView.viewContainerParent || currView.parent;
|
8274
|
}
|
8275
|
}
|
8276
|
/**
|
8277
|
* @param {?} view
|
8278
|
* @param {?} endView
|
8279
|
* @return {?}
|
8280
|
*/
|
8281
|
function markParentViewsForCheckProjectedViews(view, endView) {
|
8282
|
let /** @type {?} */ currView = view;
|
8283
|
while (currView && currView !== endView) {
|
8284
|
currView.state |= 64 /* CheckProjectedViews */;
|
8285
|
currView = currView.viewContainerParent || currView.parent;
|
8286
|
}
|
8287
|
}
|
8288
|
/**
|
8289
|
* @param {?} view
|
8290
|
* @param {?} nodeIndex
|
8291
|
* @param {?} eventName
|
8292
|
* @param {?} event
|
8293
|
* @return {?}
|
8294
|
*/
|
8295
|
function dispatchEvent(view, nodeIndex, eventName, event) {
|
8296
|
const /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
|
8297
|
const /** @type {?} */ startView = nodeDef.flags & 33554432 /* ComponentView */ ? asElementData(view, nodeIndex).componentView : view;
|
8298
|
markParentViewsForCheck(startView);
|
8299
|
return Services.handleEvent(view, nodeIndex, eventName, event);
|
8300
|
}
|
8301
|
/**
|
8302
|
* @param {?} view
|
8303
|
* @return {?}
|
8304
|
*/
|
8305
|
function declaredViewContainer(view) {
|
8306
|
if (view.parent) {
|
8307
|
const /** @type {?} */ parentView = view.parent;
|
8308
|
return asElementData(parentView, /** @type {?} */ ((view.parentNodeDef)).nodeIndex);
|
8309
|
}
|
8310
|
return null;
|
8311
|
}
|
8312
|
/**
|
8313
|
* for component views, this is the host element.
|
8314
|
* for embedded views, this is the index of the parent node
|
8315
|
* that contains the view container.
|
8316
|
* @param {?} view
|
8317
|
* @return {?}
|
8318
|
*/
|
8319
|
function viewParentEl(view) {
|
8320
|
const /** @type {?} */ parentView = view.parent;
|
8321
|
if (parentView) {
|
8322
|
return ((view.parentNodeDef)).parent;
|
8323
|
}
|
8324
|
else {
|
8325
|
return null;
|
8326
|
}
|
8327
|
}
|
8328
|
/**
|
8329
|
* @param {?} view
|
8330
|
* @param {?} def
|
8331
|
* @return {?}
|
8332
|
*/
|
8333
|
function renderNode(view, def) {
|
8334
|
switch (def.flags & 201347067 /* Types */) {
|
8335
|
case 1 /* TypeElement */:
|
8336
|
return asElementData(view, def.nodeIndex).renderElement;
|
8337
|
case 2 /* TypeText */:
|
8338
|
return asTextData(view, def.nodeIndex).renderText;
|
8339
|
}
|
8340
|
}
|
8341
|
/**
|
8342
|
* @param {?} target
|
8343
|
* @param {?} name
|
8344
|
* @return {?}
|
8345
|
*/
|
8346
|
function elementEventFullName(target, name) {
|
8347
|
return target ? `${target}:${name}` : name;
|
8348
|
}
|
8349
|
/**
|
8350
|
* @param {?} view
|
8351
|
* @return {?}
|
8352
|
*/
|
8353
|
function isComponentView(view) {
|
8354
|
return !!view.parent && !!(((view.parentNodeDef)).flags & 32768 /* Component */);
|
8355
|
}
|
8356
|
/**
|
8357
|
* @param {?} view
|
8358
|
* @return {?}
|
8359
|
*/
|
8360
|
function isEmbeddedView(view) {
|
8361
|
return !!view.parent && !(((view.parentNodeDef)).flags & 32768 /* Component */);
|
8362
|
}
|
8363
|
/**
|
8364
|
* @param {?} queryId
|
8365
|
* @return {?}
|
8366
|
*/
|
8367
|
function filterQueryId(queryId) {
|
8368
|
return 1 << (queryId % 32);
|
8369
|
}
|
8370
|
/**
|
8371
|
* @param {?} matchedQueriesDsl
|
8372
|
* @return {?}
|
8373
|
*/
|
8374
|
function splitMatchedQueriesDsl(matchedQueriesDsl) {
|
8375
|
const /** @type {?} */ matchedQueries = {};
|
8376
|
let /** @type {?} */ matchedQueryIds = 0;
|
8377
|
const /** @type {?} */ references = {};
|
8378
|
if (matchedQueriesDsl) {
|
8379
|
matchedQueriesDsl.forEach(([queryId, valueType]) => {
|
8380
|
if (typeof queryId === 'number') {
|
8381
|
matchedQueries[queryId] = valueType;
|
8382
|
matchedQueryIds |= filterQueryId(queryId);
|
8383
|
}
|
8384
|
else {
|
8385
|
references[queryId] = valueType;
|
8386
|
}
|
8387
|
});
|
8388
|
}
|
8389
|
return { matchedQueries, references, matchedQueryIds };
|
8390
|
}
|
8391
|
/**
|
8392
|
* @param {?} deps
|
8393
|
* @return {?}
|
8394
|
*/
|
8395
|
function splitDepsDsl(deps) {
|
8396
|
return deps.map(value => {
|
8397
|
let /** @type {?} */ token;
|
8398
|
let /** @type {?} */ flags;
|
8399
|
if (Array.isArray(value)) {
|
8400
|
[flags, token] = value;
|
8401
|
}
|
8402
|
else {
|
8403
|
flags = 0 /* None */;
|
8404
|
token = value;
|
8405
|
}
|
8406
|
return { flags, token, tokenKey: tokenKey(token) };
|
8407
|
});
|
8408
|
}
|
8409
|
/**
|
8410
|
* @param {?} view
|
8411
|
* @param {?} renderHost
|
8412
|
* @param {?} def
|
8413
|
* @return {?}
|
8414
|
*/
|
8415
|
function getParentRenderElement(view, renderHost, def) {
|
8416
|
let /** @type {?} */ renderParent = def.renderParent;
|
8417
|
if (renderParent) {
|
8418
|
if ((renderParent.flags & 1 /* TypeElement */) === 0 ||
|
8419
|
(renderParent.flags & 33554432 /* ComponentView */) === 0 ||
|
8420
|
(((renderParent.element)).componentRendererType && ((((renderParent.element)).componentRendererType)).encapsulation ===
|
8421
|
ViewEncapsulation.Native)) {
|
8422
|
// only children of non components, or children of components with native encapsulation should
|
8423
|
// be attached.
|
8424
|
return asElementData(view, /** @type {?} */ ((def.renderParent)).nodeIndex).renderElement;
|
8425
|
}
|
8426
|
}
|
8427
|
else {
|
8428
|
return renderHost;
|
8429
|
}
|
8430
|
}
|
8431
|
const DEFINITION_CACHE = new WeakMap();
|
8432
|
/**
|
8433
|
* @template D
|
8434
|
* @param {?} factory
|
8435
|
* @return {?}
|
8436
|
*/
|
8437
|
function resolveDefinition(factory) {
|
8438
|
let /** @type {?} */ value = (((DEFINITION_CACHE.get(factory))));
|
8439
|
if (!value) {
|
8440
|
value = factory(() => NOOP);
|
8441
|
value.factory = factory;
|
8442
|
DEFINITION_CACHE.set(factory, value);
|
8443
|
}
|
8444
|
return value;
|
8445
|
}
|
8446
|
/**
|
8447
|
* @param {?} view
|
8448
|
* @return {?}
|
8449
|
*/
|
8450
|
function rootRenderNodes(view) {
|
8451
|
const /** @type {?} */ renderNodes = [];
|
8452
|
visitRootRenderNodes(view, 0 /* Collect */, undefined, undefined, renderNodes);
|
8453
|
return renderNodes;
|
8454
|
}
|
8455
|
/**
|
8456
|
* @param {?} view
|
8457
|
* @param {?} action
|
8458
|
* @param {?} parentNode
|
8459
|
* @param {?} nextSibling
|
8460
|
* @param {?=} target
|
8461
|
* @return {?}
|
8462
|
*/
|
8463
|
function visitRootRenderNodes(view, action, parentNode, nextSibling, target) {
|
8464
|
// We need to re-compute the parent node in case the nodes have been moved around manually
|
8465
|
if (action === 3 /* RemoveChild */) {
|
8466
|
parentNode = view.renderer.parentNode(renderNode(view, /** @type {?} */ ((view.def.lastRenderRootNode))));
|
8467
|
}
|
8468
|
visitSiblingRenderNodes(view, action, 0, view.def.nodes.length - 1, parentNode, nextSibling, target);
|
8469
|
}
|
8470
|
/**
|
8471
|
* @param {?} view
|
8472
|
* @param {?} action
|
8473
|
* @param {?} startIndex
|
8474
|
* @param {?} endIndex
|
8475
|
* @param {?} parentNode
|
8476
|
* @param {?} nextSibling
|
8477
|
* @param {?=} target
|
8478
|
* @return {?}
|
8479
|
*/
|
8480
|
function visitSiblingRenderNodes(view, action, startIndex, endIndex, parentNode, nextSibling, target) {
|
8481
|
for (let /** @type {?} */ i = startIndex; i <= endIndex; i++) {
|
8482
|
const /** @type {?} */ nodeDef = view.def.nodes[i];
|
8483
|
if (nodeDef.flags & (1 /* TypeElement */ | 2 /* TypeText */ | 8 /* TypeNgContent */)) {
|
8484
|
visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target);
|
8485
|
}
|
8486
|
// jump to next sibling
|
8487
|
i += nodeDef.childCount;
|
8488
|
}
|
8489
|
}
|
8490
|
/**
|
8491
|
* @param {?} view
|
8492
|
* @param {?} ngContentIndex
|
8493
|
* @param {?} action
|
8494
|
* @param {?} parentNode
|
8495
|
* @param {?} nextSibling
|
8496
|
* @param {?=} target
|
8497
|
* @return {?}
|
8498
|
*/
|
8499
|
function visitProjectedRenderNodes(view, ngContentIndex, action, parentNode, nextSibling, target) {
|
8500
|
let /** @type {?} */ compView = view;
|
8501
|
while (compView && !isComponentView(compView)) {
|
8502
|
compView = compView.parent;
|
8503
|
}
|
8504
|
const /** @type {?} */ hostView = ((compView)).parent;
|
8505
|
const /** @type {?} */ hostElDef = viewParentEl(/** @type {?} */ ((compView)));
|
8506
|
const /** @type {?} */ startIndex = ((hostElDef)).nodeIndex + 1;
|
8507
|
const /** @type {?} */ endIndex = ((hostElDef)).nodeIndex + ((hostElDef)).childCount;
|
8508
|
for (let /** @type {?} */ i = startIndex; i <= endIndex; i++) {
|
8509
|
const /** @type {?} */ nodeDef = ((hostView)).def.nodes[i];
|
8510
|
if (nodeDef.ngContentIndex === ngContentIndex) {
|
8511
|
visitRenderNode(/** @type {?} */ ((hostView)), nodeDef, action, parentNode, nextSibling, target);
|
8512
|
}
|
8513
|
// jump to next sibling
|
8514
|
i += nodeDef.childCount;
|
8515
|
}
|
8516
|
if (!((hostView)).parent) {
|
8517
|
// a root view
|
8518
|
const /** @type {?} */ projectedNodes = view.root.projectableNodes[ngContentIndex];
|
8519
|
if (projectedNodes) {
|
8520
|
for (let /** @type {?} */ i = 0; i < projectedNodes.length; i++) {
|
8521
|
execRenderNodeAction(view, projectedNodes[i], action, parentNode, nextSibling, target);
|
8522
|
}
|
8523
|
}
|
8524
|
}
|
8525
|
}
|
8526
|
/**
|
8527
|
* @param {?} view
|
8528
|
* @param {?} nodeDef
|
8529
|
* @param {?} action
|
8530
|
* @param {?} parentNode
|
8531
|
* @param {?} nextSibling
|
8532
|
* @param {?=} target
|
8533
|
* @return {?}
|
8534
|
*/
|
8535
|
function visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target) {
|
8536
|
if (nodeDef.flags & 8 /* TypeNgContent */) {
|
8537
|
visitProjectedRenderNodes(view, /** @type {?} */ ((nodeDef.ngContent)).index, action, parentNode, nextSibling, target);
|
8538
|
}
|
8539
|
else {
|
8540
|
const /** @type {?} */ rn = renderNode(view, nodeDef);
|
8541
|
if (action === 3 /* RemoveChild */ && (nodeDef.flags & 33554432 /* ComponentView */) &&
|
8542
|
(nodeDef.bindingFlags & 48 /* CatSyntheticProperty */)) {
|
8543
|
// Note: we might need to do both actions.
|
8544
|
if (nodeDef.bindingFlags & (16 /* SyntheticProperty */)) {
|
8545
|
execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
|
8546
|
}
|
8547
|
if (nodeDef.bindingFlags & (32 /* SyntheticHostProperty */)) {
|
8548
|
const /** @type {?} */ compView = asElementData(view, nodeDef.nodeIndex).componentView;
|
8549
|
execRenderNodeAction(compView, rn, action, parentNode, nextSibling, target);
|
8550
|
}
|
8551
|
}
|
8552
|
else {
|
8553
|
execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
|
8554
|
}
|
8555
|
if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
|
8556
|
const /** @type {?} */ embeddedViews = ((asElementData(view, nodeDef.nodeIndex).viewContainer))._embeddedViews;
|
8557
|
for (let /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
|
8558
|
visitRootRenderNodes(embeddedViews[k], action, parentNode, nextSibling, target);
|
8559
|
}
|
8560
|
}
|
8561
|
if (nodeDef.flags & 1 /* TypeElement */ && !((nodeDef.element)).name) {
|
8562
|
visitSiblingRenderNodes(view, action, nodeDef.nodeIndex + 1, nodeDef.nodeIndex + nodeDef.childCount, parentNode, nextSibling, target);
|
8563
|
}
|
8564
|
}
|
8565
|
}
|
8566
|
/**
|
8567
|
* @param {?} view
|
8568
|
* @param {?} renderNode
|
8569
|
* @param {?} action
|
8570
|
* @param {?} parentNode
|
8571
|
* @param {?} nextSibling
|
8572
|
* @param {?=} target
|
8573
|
* @return {?}
|
8574
|
*/
|
8575
|
function execRenderNodeAction(view, renderNode, action, parentNode, nextSibling, target) {
|
8576
|
const /** @type {?} */ renderer = view.renderer;
|
8577
|
switch (action) {
|
8578
|
case 1 /* AppendChild */:
|
8579
|
renderer.appendChild(parentNode, renderNode);
|
8580
|
break;
|
8581
|
case 2 /* InsertBefore */:
|
8582
|
renderer.insertBefore(parentNode, renderNode, nextSibling);
|
8583
|
break;
|
8584
|
case 3 /* RemoveChild */:
|
8585
|
renderer.removeChild(parentNode, renderNode);
|
8586
|
break;
|
8587
|
case 0 /* Collect */:
|
8588
|
((target)).push(renderNode);
|
8589
|
break;
|
8590
|
}
|
8591
|
}
|
8592
|
const NS_PREFIX_RE = /^:([^:]+):(.+)$/;
|
8593
|
/**
|
8594
|
* @param {?} name
|
8595
|
* @return {?}
|
8596
|
*/
|
8597
|
function splitNamespace(name) {
|
8598
|
if (name[0] === ':') {
|
8599
|
const /** @type {?} */ match = ((name.match(NS_PREFIX_RE)));
|
8600
|
return [match[1], match[2]];
|
8601
|
}
|
8602
|
return ['', name];
|
8603
|
}
|
8604
|
/**
|
8605
|
* @param {?} bindings
|
8606
|
* @return {?}
|
8607
|
*/
|
8608
|
function calcBindingFlags(bindings) {
|
8609
|
let /** @type {?} */ flags = 0;
|
8610
|
for (let /** @type {?} */ i = 0; i < bindings.length; i++) {
|
8611
|
flags |= bindings[i].flags;
|
8612
|
}
|
8613
|
return flags;
|
8614
|
}
|
8615
|
/**
|
8616
|
* @param {?} valueCount
|
8617
|
* @param {?} constAndInterp
|
8618
|
* @return {?}
|
8619
|
*/
|
8620
|
function interpolate(valueCount, constAndInterp) {
|
8621
|
let /** @type {?} */ result = '';
|
8622
|
for (let /** @type {?} */ i = 0; i < valueCount * 2; i = i + 2) {
|
8623
|
result = result + constAndInterp[i] + _toStringWithNull(constAndInterp[i + 1]);
|
8624
|
}
|
8625
|
return result + constAndInterp[valueCount * 2];
|
8626
|
}
|
8627
|
/**
|
8628
|
* @param {?} valueCount
|
8629
|
* @param {?} c0
|
8630
|
* @param {?} a1
|
8631
|
* @param {?} c1
|
8632
|
* @param {?=} a2
|
8633
|
* @param {?=} c2
|
8634
|
* @param {?=} a3
|
8635
|
* @param {?=} c3
|
8636
|
* @param {?=} a4
|
8637
|
* @param {?=} c4
|
8638
|
* @param {?=} a5
|
8639
|
* @param {?=} c5
|
8640
|
* @param {?=} a6
|
8641
|
* @param {?=} c6
|
8642
|
* @param {?=} a7
|
8643
|
* @param {?=} c7
|
8644
|
* @param {?=} a8
|
8645
|
* @param {?=} c8
|
8646
|
* @param {?=} a9
|
8647
|
* @param {?=} c9
|
8648
|
* @return {?}
|
8649
|
*/
|
8650
|
function inlineInterpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) {
|
8651
|
switch (valueCount) {
|
8652
|
case 1:
|
8653
|
return c0 + _toStringWithNull(a1) + c1;
|
8654
|
case 2:
|
8655
|
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2;
|
8656
|
case 3:
|
8657
|
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8658
|
c3;
|
8659
|
case 4:
|
8660
|
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8661
|
c3 + _toStringWithNull(a4) + c4;
|
8662
|
case 5:
|
8663
|
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8664
|
c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5;
|
8665
|
case 6:
|
8666
|
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8667
|
c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6;
|
8668
|
case 7:
|
8669
|
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8670
|
c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
|
8671
|
c6 + _toStringWithNull(a7) + c7;
|
8672
|
case 8:
|
8673
|
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8674
|
c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
|
8675
|
c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8;
|
8676
|
case 9:
|
8677
|
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
|
8678
|
c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
|
8679
|
c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8 + _toStringWithNull(a9) + c9;
|
8680
|
default:
|
8681
|
throw new Error(`Does not support more than 9 expressions`);
|
8682
|
}
|
8683
|
}
|
8684
|
/**
|
8685
|
* @param {?} v
|
8686
|
* @return {?}
|
8687
|
*/
|
8688
|
function _toStringWithNull(v) {
|
8689
|
return v != null ? v.toString() : '';
|
8690
|
}
|
8691
|
const EMPTY_ARRAY = [];
|
8692
|
const EMPTY_MAP = {};
|
8693
|
|
8694
|
/**
|
8695
|
* @license
|
8696
|
* Copyright Google Inc. All Rights Reserved.
|
8697
|
*
|
8698
|
* Use of this source code is governed by an MIT-style license that can be
|
8699
|
* found in the LICENSE file at https://angular.io/license
|
8700
|
*/
|
8701
|
/**
|
8702
|
* @param {?} flags
|
8703
|
* @param {?} matchedQueriesDsl
|
8704
|
* @param {?} ngContentIndex
|
8705
|
* @param {?} childCount
|
8706
|
* @param {?=} handleEvent
|
8707
|
* @param {?=} templateFactory
|
8708
|
* @return {?}
|
8709
|
*/
|
8710
|
function anchorDef(flags, matchedQueriesDsl, ngContentIndex, childCount, handleEvent, templateFactory) {
|
8711
|
flags |= 1 /* TypeElement */;
|
8712
|
const { matchedQueries, references, matchedQueryIds } = splitMatchedQueriesDsl(matchedQueriesDsl);
|
8713
|
const /** @type {?} */ template = templateFactory ? resolveDefinition(templateFactory) : null;
|
8714
|
return {
|
8715
|
// will bet set by the view definition
|
8716
|
nodeIndex: -1,
|
8717
|
parent: null,
|
8718
|
renderParent: null,
|
8719
|
bindingIndex: -1,
|
8720
|
outputIndex: -1,
|
8721
|
// regular values
|
8722
|
flags,
|
8723
|
checkIndex: -1,
|
8724
|
childFlags: 0,
|
8725
|
directChildFlags: 0,
|
8726
|
childMatchedQueries: 0, matchedQueries, matchedQueryIds, references, ngContentIndex, childCount,
|
8727
|
bindings: [],
|
8728
|
bindingFlags: 0,
|
8729
|
outputs: [],
|
8730
|
element: {
|
8731
|
ns: null,
|
8732
|
name: null,
|
8733
|
attrs: null, template,
|
8734
|
componentProvider: null,
|
8735
|
componentView: null,
|
8736
|
componentRendererType: null,
|
8737
|
publicProviders: null,
|
8738
|
allProviders: null,
|
8739
|
handleEvent: handleEvent || NOOP
|
8740
|
},
|
8741
|
provider: null,
|
8742
|
text: null,
|
8743
|
query: null,
|
8744
|
ngContent: null
|
8745
|
};
|
8746
|
}
|
8747
|
/**
|
8748
|
* @param {?} checkIndex
|
8749
|
* @param {?} flags
|
8750
|
* @param {?} matchedQueriesDsl
|
8751
|
* @param {?} ngContentIndex
|
8752
|
* @param {?} childCount
|
8753
|
* @param {?} namespaceAndName
|
8754
|
* @param {?=} fixedAttrs
|
8755
|
* @param {?=} bindings
|
8756
|
* @param {?=} outputs
|
8757
|
* @param {?=} handleEvent
|
8758
|
* @param {?=} componentView
|
8759
|
* @param {?=} componentRendererType
|
8760
|
* @return {?}
|
8761
|
*/
|
8762
|
function elementDef(checkIndex, flags, matchedQueriesDsl, ngContentIndex, childCount, namespaceAndName, fixedAttrs = [], bindings, outputs, handleEvent, componentView, componentRendererType) {
|
8763
|
if (!handleEvent) {
|
8764
|
handleEvent = NOOP;
|
8765
|
}
|
8766
|
const { matchedQueries, references, matchedQueryIds } = splitMatchedQueriesDsl(matchedQueriesDsl);
|
8767
|
let /** @type {?} */ ns = ((null));
|
8768
|
let /** @type {?} */ name = ((null));
|
8769
|
if (namespaceAndName) {
|
8770
|
[ns, name] = splitNamespace(namespaceAndName);
|
8771
|
}
|
8772
|
bindings = bindings || [];
|
8773
|
const /** @type {?} */ bindingDefs = new Array(bindings.length);
|
8774
|
for (let /** @type {?} */ i = 0; i < bindings.length; i++) {
|
8775
|
const [bindingFlags, namespaceAndName, suffixOrSecurityContext] = bindings[i];
|
8776
|
const [ns, name] = splitNamespace(namespaceAndName);
|
8777
|
let /** @type {?} */ securityContext = ((undefined));
|
8778
|
let /** @type {?} */ suffix = ((undefined));
|
8779
|
switch (bindingFlags & 15 /* Types */) {
|
8780
|
case 4 /* TypeElementStyle */:
|
8781
|
suffix = (suffixOrSecurityContext);
|
8782
|
break;
|
8783
|
case 1 /* TypeElementAttribute */:
|
8784
|
case 8 /* TypeProperty */:
|
8785
|
securityContext = (suffixOrSecurityContext);
|
8786
|
break;
|
8787
|
}
|
8788
|
bindingDefs[i] =
|
8789
|
{ flags: bindingFlags, ns, name, nonMinifiedName: name, securityContext, suffix };
|
8790
|
}
|
8791
|
outputs = outputs || [];
|
8792
|
const /** @type {?} */ outputDefs = new Array(outputs.length);
|
8793
|
for (let /** @type {?} */ i = 0; i < outputs.length; i++) {
|
8794
|
const [target, eventName] = outputs[i];
|
8795
|
outputDefs[i] = {
|
8796
|
type: 0 /* ElementOutput */,
|
8797
|
target: /** @type {?} */ (target), eventName,
|
8798
|
propName: null
|
8799
|
};
|
8800
|
}
|
8801
|
fixedAttrs = fixedAttrs || [];
|
8802
|
const /** @type {?} */ attrs = (fixedAttrs.map(([namespaceAndName, value]) => {
|
8803
|
const [ns, name] = splitNamespace(namespaceAndName);
|
8804
|
return [ns, name, value];
|
8805
|
}));
|
8806
|
componentRendererType = resolveRendererType2(componentRendererType);
|
8807
|
if (componentView) {
|
8808
|
flags |= 33554432 /* ComponentView */;
|
8809
|
}
|
8810
|
flags |= 1 /* TypeElement */;
|
8811
|
return {
|
8812
|
// will bet set by the view definition
|
8813
|
nodeIndex: -1,
|
8814
|
parent: null,
|
8815
|
renderParent: null,
|
8816
|
bindingIndex: -1,
|
8817
|
outputIndex: -1,
|
8818
|
// regular values
|
8819
|
checkIndex,
|
8820
|
flags,
|
8821
|
childFlags: 0,
|
8822
|
directChildFlags: 0,
|
8823
|
childMatchedQueries: 0, matchedQueries, matchedQueryIds, references, ngContentIndex, childCount,
|
8824
|
bindings: bindingDefs,
|
8825
|
bindingFlags: calcBindingFlags(bindingDefs),
|
8826
|
outputs: outputDefs,
|
8827
|
element: {
|
8828
|
ns,
|
8829
|
name,
|
8830
|
attrs,
|
8831
|
template: null,
|
8832
|
// will bet set by the view definition
|
8833
|
componentProvider: null,
|
8834
|
componentView: componentView || null,
|
8835
|
componentRendererType: componentRendererType,
|
8836
|
publicProviders: null,
|
8837
|
allProviders: null,
|
8838
|
handleEvent: handleEvent || NOOP,
|
8839
|
},
|
8840
|
provider: null,
|
8841
|
text: null,
|
8842
|
query: null,
|
8843
|
ngContent: null
|
8844
|
};
|
8845
|
}
|
8846
|
/**
|
8847
|
* @param {?} view
|
8848
|
* @param {?} renderHost
|
8849
|
* @param {?} def
|
8850
|
* @return {?}
|
8851
|
*/
|
8852
|
function createElement(view, renderHost, def) {
|
8853
|
const /** @type {?} */ elDef = ((def.element));
|
8854
|
const /** @type {?} */ rootSelectorOrNode = view.root.selectorOrNode;
|
8855
|
const /** @type {?} */ renderer = view.renderer;
|
8856
|
let /** @type {?} */ el;
|
8857
|
if (view.parent || !rootSelectorOrNode) {
|
8858
|
if (elDef.name) {
|
8859
|
el = renderer.createElement(elDef.name, elDef.ns);
|
8860
|
}
|
8861
|
else {
|
8862
|
el = renderer.createComment('');
|
8863
|
}
|
8864
|
const /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
|
8865
|
if (parentEl) {
|
8866
|
renderer.appendChild(parentEl, el);
|
8867
|
}
|
8868
|
}
|
8869
|
else {
|
8870
|
el = renderer.selectRootElement(rootSelectorOrNode);
|
8871
|
}
|
8872
|
if (elDef.attrs) {
|
8873
|
for (let /** @type {?} */ i = 0; i < elDef.attrs.length; i++) {
|
8874
|
const [ns, name, value] = elDef.attrs[i];
|
8875
|
renderer.setAttribute(el, name, value, ns);
|
8876
|
}
|
8877
|
}
|
8878
|
return el;
|
8879
|
}
|
8880
|
/**
|
8881
|
* @param {?} view
|
8882
|
* @param {?} compView
|
8883
|
* @param {?} def
|
8884
|
* @param {?} el
|
8885
|
* @return {?}
|
8886
|
*/
|
8887
|
function listenToElementOutputs(view, compView, def, el) {
|
8888
|
for (let /** @type {?} */ i = 0; i < def.outputs.length; i++) {
|
8889
|
const /** @type {?} */ output = def.outputs[i];
|
8890
|
const /** @type {?} */ handleEventClosure = renderEventHandlerClosure(view, def.nodeIndex, elementEventFullName(output.target, output.eventName));
|
8891
|
let /** @type {?} */ listenTarget = output.target;
|
8892
|
let /** @type {?} */ listenerView = view;
|
8893
|
if (output.target === 'component') {
|
8894
|
listenTarget = null;
|
8895
|
listenerView = compView;
|
8896
|
}
|
8897
|
const /** @type {?} */ disposable = (listenerView.renderer.listen(listenTarget || el, output.eventName, handleEventClosure)); /** @type {?} */
|
8898
|
((view.disposables))[def.outputIndex + i] = disposable;
|
8899
|
}
|
8900
|
}
|
8901
|
/**
|
8902
|
* @param {?} view
|
8903
|
* @param {?} index
|
8904
|
* @param {?} eventName
|
8905
|
* @return {?}
|
8906
|
*/
|
8907
|
function renderEventHandlerClosure(view, index, eventName) {
|
8908
|
return (event) => {
|
8909
|
try {
|
8910
|
return dispatchEvent(view, index, eventName, event);
|
8911
|
}
|
8912
|
catch (e) {
|
8913
|
// Attention: Don't rethrow, to keep in sync with directive events.
|
8914
|
view.root.errorHandler.handleError(e);
|
8915
|
}
|
8916
|
};
|
8917
|
}
|
8918
|
/**
|
8919
|
* @param {?} view
|
8920
|
* @param {?} def
|
8921
|
* @param {?} v0
|
8922
|
* @param {?} v1
|
8923
|
* @param {?} v2
|
8924
|
* @param {?} v3
|
8925
|
* @param {?} v4
|
8926
|
* @param {?} v5
|
8927
|
* @param {?} v6
|
8928
|
* @param {?} v7
|
8929
|
* @param {?} v8
|
8930
|
* @param {?} v9
|
8931
|
* @return {?}
|
8932
|
*/
|
8933
|
function checkAndUpdateElementInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
8934
|
const /** @type {?} */ bindLen = def.bindings.length;
|
8935
|
let /** @type {?} */ changed = false;
|
8936
|
if (bindLen > 0 && checkAndUpdateElementValue(view, def, 0, v0))
|
8937
|
changed = true;
|
8938
|
if (bindLen > 1 && checkAndUpdateElementValue(view, def, 1, v1))
|
8939
|
changed = true;
|
8940
|
if (bindLen > 2 && checkAndUpdateElementValue(view, def, 2, v2))
|
8941
|
changed = true;
|
8942
|
if (bindLen > 3 && checkAndUpdateElementValue(view, def, 3, v3))
|
8943
|
changed = true;
|
8944
|
if (bindLen > 4 && checkAndUpdateElementValue(view, def, 4, v4))
|
8945
|
changed = true;
|
8946
|
if (bindLen > 5 && checkAndUpdateElementValue(view, def, 5, v5))
|
8947
|
changed = true;
|
8948
|
if (bindLen > 6 && checkAndUpdateElementValue(view, def, 6, v6))
|
8949
|
changed = true;
|
8950
|
if (bindLen > 7 && checkAndUpdateElementValue(view, def, 7, v7))
|
8951
|
changed = true;
|
8952
|
if (bindLen > 8 && checkAndUpdateElementValue(view, def, 8, v8))
|
8953
|
changed = true;
|
8954
|
if (bindLen > 9 && checkAndUpdateElementValue(view, def, 9, v9))
|
8955
|
changed = true;
|
8956
|
return changed;
|
8957
|
}
|
8958
|
/**
|
8959
|
* @param {?} view
|
8960
|
* @param {?} def
|
8961
|
* @param {?} values
|
8962
|
* @return {?}
|
8963
|
*/
|
8964
|
function checkAndUpdateElementDynamic(view, def, values) {
|
8965
|
let /** @type {?} */ changed = false;
|
8966
|
for (let /** @type {?} */ i = 0; i < values.length; i++) {
|
8967
|
if (checkAndUpdateElementValue(view, def, i, values[i]))
|
8968
|
changed = true;
|
8969
|
}
|
8970
|
return changed;
|
8971
|
}
|
8972
|
/**
|
8973
|
* @param {?} view
|
8974
|
* @param {?} def
|
8975
|
* @param {?} bindingIdx
|
8976
|
* @param {?} value
|
8977
|
* @return {?}
|
8978
|
*/
|
8979
|
function checkAndUpdateElementValue(view, def, bindingIdx, value) {
|
8980
|
if (!checkAndUpdateBinding(view, def, bindingIdx, value)) {
|
8981
|
return false;
|
8982
|
}
|
8983
|
const /** @type {?} */ binding = def.bindings[bindingIdx];
|
8984
|
const /** @type {?} */ elData = asElementData(view, def.nodeIndex);
|
8985
|
const /** @type {?} */ renderNode$$1 = elData.renderElement;
|
8986
|
const /** @type {?} */ name = ((binding.name));
|
8987
|
switch (binding.flags & 15 /* Types */) {
|
8988
|
case 1 /* TypeElementAttribute */:
|
8989
|
setElementAttribute(view, binding, renderNode$$1, binding.ns, name, value);
|
8990
|
break;
|
8991
|
case 2 /* TypeElementClass */:
|
8992
|
setElementClass(view, renderNode$$1, name, value);
|
8993
|
break;
|
8994
|
case 4 /* TypeElementStyle */:
|
8995
|
setElementStyle(view, binding, renderNode$$1, name, value);
|
8996
|
break;
|
8997
|
case 8 /* TypeProperty */:
|
8998
|
const /** @type {?} */ bindView = (def.flags & 33554432 /* ComponentView */ &&
|
8999
|
binding.flags & 32 /* SyntheticHostProperty */) ?
|
9000
|
elData.componentView :
|
9001
|
view;
|
9002
|
setElementProperty(bindView, binding, renderNode$$1, name, value);
|
9003
|
break;
|
9004
|
}
|
9005
|
return true;
|
9006
|
}
|
9007
|
/**
|
9008
|
* @param {?} view
|
9009
|
* @param {?} binding
|
9010
|
* @param {?} renderNode
|
9011
|
* @param {?} ns
|
9012
|
* @param {?} name
|
9013
|
* @param {?} value
|
9014
|
* @return {?}
|
9015
|
*/
|
9016
|
function setElementAttribute(view, binding, renderNode$$1, ns, name, value) {
|
9017
|
const /** @type {?} */ securityContext = binding.securityContext;
|
9018
|
let /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
|
9019
|
renderValue = renderValue != null ? renderValue.toString() : null;
|
9020
|
const /** @type {?} */ renderer = view.renderer;
|
9021
|
if (value != null) {
|
9022
|
renderer.setAttribute(renderNode$$1, name, renderValue, ns);
|
9023
|
}
|
9024
|
else {
|
9025
|
renderer.removeAttribute(renderNode$$1, name, ns);
|
9026
|
}
|
9027
|
}
|
9028
|
/**
|
9029
|
* @param {?} view
|
9030
|
* @param {?} renderNode
|
9031
|
* @param {?} name
|
9032
|
* @param {?} value
|
9033
|
* @return {?}
|
9034
|
*/
|
9035
|
function setElementClass(view, renderNode$$1, name, value) {
|
9036
|
const /** @type {?} */ renderer = view.renderer;
|
9037
|
if (value) {
|
9038
|
renderer.addClass(renderNode$$1, name);
|
9039
|
}
|
9040
|
else {
|
9041
|
renderer.removeClass(renderNode$$1, name);
|
9042
|
}
|
9043
|
}
|
9044
|
/**
|
9045
|
* @param {?} view
|
9046
|
* @param {?} binding
|
9047
|
* @param {?} renderNode
|
9048
|
* @param {?} name
|
9049
|
* @param {?} value
|
9050
|
* @return {?}
|
9051
|
*/
|
9052
|
function setElementStyle(view, binding, renderNode$$1, name, value) {
|
9053
|
let /** @type {?} */ renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, /** @type {?} */ (value));
|
9054
|
if (renderValue != null) {
|
9055
|
renderValue = renderValue.toString();
|
9056
|
const /** @type {?} */ unit = binding.suffix;
|
9057
|
if (unit != null) {
|
9058
|
renderValue = renderValue + unit;
|
9059
|
}
|
9060
|
}
|
9061
|
else {
|
9062
|
renderValue = null;
|
9063
|
}
|
9064
|
const /** @type {?} */ renderer = view.renderer;
|
9065
|
if (renderValue != null) {
|
9066
|
renderer.setStyle(renderNode$$1, name, renderValue);
|
9067
|
}
|
9068
|
else {
|
9069
|
renderer.removeStyle(renderNode$$1, name);
|
9070
|
}
|
9071
|
}
|
9072
|
/**
|
9073
|
* @param {?} view
|
9074
|
* @param {?} binding
|
9075
|
* @param {?} renderNode
|
9076
|
* @param {?} name
|
9077
|
* @param {?} value
|
9078
|
* @return {?}
|
9079
|
*/
|
9080
|
function setElementProperty(view, binding, renderNode$$1, name, value) {
|
9081
|
const /** @type {?} */ securityContext = binding.securityContext;
|
9082
|
let /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
|
9083
|
view.renderer.setProperty(renderNode$$1, name, renderValue);
|
9084
|
}
|
9085
|
|
9086
|
/**
|
9087
|
* @license
|
9088
|
* Copyright Google Inc. All Rights Reserved.
|
9089
|
*
|
9090
|
* Use of this source code is governed by an MIT-style license that can be
|
9091
|
* found in the LICENSE file at https://angular.io/license
|
9092
|
*/
|
9093
|
const UNDEFINED_VALUE = new Object();
|
9094
|
const InjectorRefTokenKey$1 = tokenKey(Injector);
|
9095
|
const NgModuleRefTokenKey = tokenKey(NgModuleRef);
|
9096
|
/**
|
9097
|
* @param {?} flags
|
9098
|
* @param {?} token
|
9099
|
* @param {?} value
|
9100
|
* @param {?} deps
|
9101
|
* @return {?}
|
9102
|
*/
|
9103
|
function moduleProvideDef(flags, token, value, deps) {
|
9104
|
const /** @type {?} */ depDefs = splitDepsDsl(deps);
|
9105
|
return {
|
9106
|
// will bet set by the module definition
|
9107
|
index: -1,
|
9108
|
deps: depDefs, flags, token, value
|
9109
|
};
|
9110
|
}
|
9111
|
/**
|
9112
|
* @param {?} providers
|
9113
|
* @return {?}
|
9114
|
*/
|
9115
|
function moduleDef(providers) {
|
9116
|
const /** @type {?} */ providersByKey = {};
|
9117
|
for (let /** @type {?} */ i = 0; i < providers.length; i++) {
|
9118
|
const /** @type {?} */ provider = providers[i];
|
9119
|
provider.index = i;
|
9120
|
providersByKey[tokenKey(provider.token)] = provider;
|
9121
|
}
|
9122
|
return {
|
9123
|
// Will be filled later...
|
9124
|
factory: null,
|
9125
|
providersByKey,
|
9126
|
providers
|
9127
|
};
|
9128
|
}
|
9129
|
/**
|
9130
|
* @param {?} data
|
9131
|
* @return {?}
|
9132
|
*/
|
9133
|
function initNgModule(data) {
|
9134
|
const /** @type {?} */ def = data._def;
|
9135
|
const /** @type {?} */ providers = data._providers = new Array(def.providers.length);
|
9136
|
for (let /** @type {?} */ i = 0; i < def.providers.length; i++) {
|
9137
|
const /** @type {?} */ provDef = def.providers[i];
|
9138
|
if (!(provDef.flags & 4096 /* LazyProvider */)) {
|
9139
|
providers[i] = _createProviderInstance$1(data, provDef);
|
9140
|
}
|
9141
|
}
|
9142
|
}
|
9143
|
/**
|
9144
|
* @param {?} data
|
9145
|
* @param {?} depDef
|
9146
|
* @param {?=} notFoundValue
|
9147
|
* @return {?}
|
9148
|
*/
|
9149
|
function resolveNgModuleDep(data, depDef, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
|
9150
|
if (depDef.flags & 8 /* Value */) {
|
9151
|
return depDef.token;
|
9152
|
}
|
9153
|
if (depDef.flags & 2 /* Optional */) {
|
9154
|
notFoundValue = null;
|
9155
|
}
|
9156
|
if (depDef.flags & 1 /* SkipSelf */) {
|
9157
|
return data._parent.get(depDef.token, notFoundValue);
|
9158
|
}
|
9159
|
const /** @type {?} */ tokenKey$$1 = depDef.tokenKey;
|
9160
|
switch (tokenKey$$1) {
|
9161
|
case InjectorRefTokenKey$1:
|
9162
|
case NgModuleRefTokenKey:
|
9163
|
return data;
|
9164
|
}
|
9165
|
const /** @type {?} */ providerDef = data._def.providersByKey[tokenKey$$1];
|
9166
|
if (providerDef) {
|
9167
|
let /** @type {?} */ providerInstance = data._providers[providerDef.index];
|
9168
|
if (providerInstance === undefined) {
|
9169
|
providerInstance = data._providers[providerDef.index] =
|
9170
|
_createProviderInstance$1(data, providerDef);
|
9171
|
}
|
9172
|
return providerInstance === UNDEFINED_VALUE ? undefined : providerInstance;
|
9173
|
}
|
9174
|
return data._parent.get(depDef.token, notFoundValue);
|
9175
|
}
|
9176
|
/**
|
9177
|
* @param {?} ngModule
|
9178
|
* @param {?} providerDef
|
9179
|
* @return {?}
|
9180
|
*/
|
9181
|
function _createProviderInstance$1(ngModule, providerDef) {
|
9182
|
let /** @type {?} */ injectable;
|
9183
|
switch (providerDef.flags & 201347067 /* Types */) {
|
9184
|
case 512 /* TypeClassProvider */:
|
9185
|
injectable = _createClass(ngModule, providerDef.value, providerDef.deps);
|
9186
|
break;
|
9187
|
case 1024 /* TypeFactoryProvider */:
|
9188
|
injectable = _callFactory(ngModule, providerDef.value, providerDef.deps);
|
9189
|
break;
|
9190
|
case 2048 /* TypeUseExistingProvider */:
|
9191
|
injectable = resolveNgModuleDep(ngModule, providerDef.deps[0]);
|
9192
|
break;
|
9193
|
case 256 /* TypeValueProvider */:
|
9194
|
injectable = providerDef.value;
|
9195
|
break;
|
9196
|
}
|
9197
|
return injectable === undefined ? UNDEFINED_VALUE : injectable;
|
9198
|
}
|
9199
|
/**
|
9200
|
* @param {?} ngModule
|
9201
|
* @param {?} ctor
|
9202
|
* @param {?} deps
|
9203
|
* @return {?}
|
9204
|
*/
|
9205
|
function _createClass(ngModule, ctor, deps) {
|
9206
|
const /** @type {?} */ len = deps.length;
|
9207
|
switch (len) {
|
9208
|
case 0:
|
9209
|
return new ctor();
|
9210
|
case 1:
|
9211
|
return new ctor(resolveNgModuleDep(ngModule, deps[0]));
|
9212
|
case 2:
|
9213
|
return new ctor(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]));
|
9214
|
case 3:
|
9215
|
return new ctor(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]), resolveNgModuleDep(ngModule, deps[2]));
|
9216
|
default:
|
9217
|
const /** @type {?} */ depValues = new Array(len);
|
9218
|
for (let /** @type {?} */ i = 0; i < len; i++) {
|
9219
|
depValues[i] = resolveNgModuleDep(ngModule, deps[i]);
|
9220
|
}
|
9221
|
return new ctor(...depValues);
|
9222
|
}
|
9223
|
}
|
9224
|
/**
|
9225
|
* @param {?} ngModule
|
9226
|
* @param {?} factory
|
9227
|
* @param {?} deps
|
9228
|
* @return {?}
|
9229
|
*/
|
9230
|
function _callFactory(ngModule, factory, deps) {
|
9231
|
const /** @type {?} */ len = deps.length;
|
9232
|
switch (len) {
|
9233
|
case 0:
|
9234
|
return factory();
|
9235
|
case 1:
|
9236
|
return factory(resolveNgModuleDep(ngModule, deps[0]));
|
9237
|
case 2:
|
9238
|
return factory(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]));
|
9239
|
case 3:
|
9240
|
return factory(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]), resolveNgModuleDep(ngModule, deps[2]));
|
9241
|
default:
|
9242
|
const /** @type {?} */ depValues = Array(len);
|
9243
|
for (let /** @type {?} */ i = 0; i < len; i++) {
|
9244
|
depValues[i] = resolveNgModuleDep(ngModule, deps[i]);
|
9245
|
}
|
9246
|
return factory(...depValues);
|
9247
|
}
|
9248
|
}
|
9249
|
/**
|
9250
|
* @param {?} ngModule
|
9251
|
* @param {?} lifecycles
|
9252
|
* @return {?}
|
9253
|
*/
|
9254
|
function callNgModuleLifecycle(ngModule, lifecycles) {
|
9255
|
const /** @type {?} */ def = ngModule._def;
|
9256
|
for (let /** @type {?} */ i = 0; i < def.providers.length; i++) {
|
9257
|
const /** @type {?} */ provDef = def.providers[i];
|
9258
|
if (provDef.flags & 131072 /* OnDestroy */) {
|
9259
|
const /** @type {?} */ instance = ngModule._providers[i];
|
9260
|
if (instance && instance !== UNDEFINED_VALUE) {
|
9261
|
instance.ngOnDestroy();
|
9262
|
}
|
9263
|
}
|
9264
|
}
|
9265
|
}
|
9266
|
|
9267
|
/**
|
9268
|
* @license
|
9269
|
* Copyright Google Inc. All Rights Reserved.
|
9270
|
*
|
9271
|
* Use of this source code is governed by an MIT-style license that can be
|
9272
|
* found in the LICENSE file at https://angular.io/license
|
9273
|
*/
|
9274
|
/**
|
9275
|
* @param {?} parentView
|
9276
|
* @param {?} elementData
|
9277
|
* @param {?} viewIndex
|
9278
|
* @param {?} view
|
9279
|
* @return {?}
|
9280
|
*/
|
9281
|
function attachEmbeddedView(parentView, elementData, viewIndex, view) {
|
9282
|
let /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
|
9283
|
if (viewIndex === null || viewIndex === undefined) {
|
9284
|
viewIndex = embeddedViews.length;
|
9285
|
}
|
9286
|
view.viewContainerParent = parentView;
|
9287
|
addToArray(embeddedViews, /** @type {?} */ ((viewIndex)), view);
|
9288
|
attachProjectedView(elementData, view);
|
9289
|
Services.dirtyParentQueries(view);
|
9290
|
const /** @type {?} */ prevView = ((viewIndex)) > 0 ? embeddedViews[((viewIndex)) - 1] : null;
|
9291
|
renderAttachEmbeddedView(elementData, prevView, view);
|
9292
|
}
|
9293
|
/**
|
9294
|
* @param {?} vcElementData
|
9295
|
* @param {?} view
|
9296
|
* @return {?}
|
9297
|
*/
|
9298
|
function attachProjectedView(vcElementData, view) {
|
9299
|
const /** @type {?} */ dvcElementData = declaredViewContainer(view);
|
9300
|
if (!dvcElementData || dvcElementData === vcElementData ||
|
9301
|
view.state & 16 /* IsProjectedView */) {
|
9302
|
return;
|
9303
|
}
|
9304
|
// Note: For performance reasons, we
|
9305
|
// - add a view to template._projectedViews only 1x throughout its lifetime,
|
9306
|
// and remove it not until the view is destroyed.
|
9307
|
// (hard, as when a parent view is attached/detached we would need to attach/detach all
|
9308
|
// nested projected views as well, even accross component boundaries).
|
9309
|
// - don't track the insertion order of views in the projected views array
|
9310
|
// (hard, as when the views of the same template are inserted different view containers)
|
9311
|
view.state |= 16 /* IsProjectedView */;
|
9312
|
let /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
|
9313
|
if (!projectedViews) {
|
9314
|
projectedViews = dvcElementData.template._projectedViews = [];
|
9315
|
}
|
9316
|
projectedViews.push(view);
|
9317
|
// Note: we are changing the NodeDef here as we cannot calculate
|
9318
|
// the fact whether a template is used for projection during compilation.
|
9319
|
markNodeAsProjectedTemplate(/** @type {?} */ ((view.parent)).def, /** @type {?} */ ((view.parentNodeDef)));
|
9320
|
}
|
9321
|
/**
|
9322
|
* @param {?} viewDef
|
9323
|
* @param {?} nodeDef
|
9324
|
* @return {?}
|
9325
|
*/
|
9326
|
function markNodeAsProjectedTemplate(viewDef, nodeDef) {
|
9327
|
if (nodeDef.flags & 4 /* ProjectedTemplate */) {
|
9328
|
return;
|
9329
|
}
|
9330
|
viewDef.nodeFlags |= 4 /* ProjectedTemplate */;
|
9331
|
nodeDef.flags |= 4 /* ProjectedTemplate */;
|
9332
|
let /** @type {?} */ parentNodeDef = nodeDef.parent;
|
9333
|
while (parentNodeDef) {
|
9334
|
parentNodeDef.childFlags |= 4 /* ProjectedTemplate */;
|
9335
|
parentNodeDef = parentNodeDef.parent;
|
9336
|
}
|
9337
|
}
|
9338
|
/**
|
9339
|
* @param {?} elementData
|
9340
|
* @param {?=} viewIndex
|
9341
|
* @return {?}
|
9342
|
*/
|
9343
|
function detachEmbeddedView(elementData, viewIndex) {
|
9344
|
const /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
|
9345
|
if (viewIndex == null || viewIndex >= embeddedViews.length) {
|
9346
|
viewIndex = embeddedViews.length - 1;
|
9347
|
}
|
9348
|
if (viewIndex < 0) {
|
9349
|
return null;
|
9350
|
}
|
9351
|
const /** @type {?} */ view = embeddedViews[viewIndex];
|
9352
|
view.viewContainerParent = null;
|
9353
|
removeFromArray(embeddedViews, viewIndex);
|
9354
|
// See attachProjectedView for why we don't update projectedViews here.
|
9355
|
Services.dirtyParentQueries(view);
|
9356
|
renderDetachView(view);
|
9357
|
return view;
|
9358
|
}
|
9359
|
/**
|
9360
|
* @param {?} view
|
9361
|
* @return {?}
|
9362
|
*/
|
9363
|
function detachProjectedView(view) {
|
9364
|
if (!(view.state & 16 /* IsProjectedView */)) {
|
9365
|
return;
|
9366
|
}
|
9367
|
const /** @type {?} */ dvcElementData = declaredViewContainer(view);
|
9368
|
if (dvcElementData) {
|
9369
|
const /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
|
9370
|
if (projectedViews) {
|
9371
|
removeFromArray(projectedViews, projectedViews.indexOf(view));
|
9372
|
Services.dirtyParentQueries(view);
|
9373
|
}
|
9374
|
}
|
9375
|
}
|
9376
|
/**
|
9377
|
* @param {?} elementData
|
9378
|
* @param {?} oldViewIndex
|
9379
|
* @param {?} newViewIndex
|
9380
|
* @return {?}
|
9381
|
*/
|
9382
|
function moveEmbeddedView(elementData, oldViewIndex, newViewIndex) {
|
9383
|
const /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
|
9384
|
const /** @type {?} */ view = embeddedViews[oldViewIndex];
|
9385
|
removeFromArray(embeddedViews, oldViewIndex);
|
9386
|
if (newViewIndex == null) {
|
9387
|
newViewIndex = embeddedViews.length;
|
9388
|
}
|
9389
|
addToArray(embeddedViews, newViewIndex, view);
|
9390
|
// Note: Don't need to change projectedViews as the order in there
|
9391
|
// as always invalid...
|
9392
|
Services.dirtyParentQueries(view);
|
9393
|
renderDetachView(view);
|
9394
|
const /** @type {?} */ prevView = newViewIndex > 0 ? embeddedViews[newViewIndex - 1] : null;
|
9395
|
renderAttachEmbeddedView(elementData, prevView, view);
|
9396
|
return view;
|
9397
|
}
|
9398
|
/**
|
9399
|
* @param {?} elementData
|
9400
|
* @param {?} prevView
|
9401
|
* @param {?} view
|
9402
|
* @return {?}
|
9403
|
*/
|
9404
|
function renderAttachEmbeddedView(elementData, prevView, view) {
|
9405
|
const /** @type {?} */ prevRenderNode = prevView ? renderNode(prevView, /** @type {?} */ ((prevView.def.lastRenderRootNode))) :
|
9406
|
elementData.renderElement;
|
9407
|
const /** @type {?} */ parentNode = view.renderer.parentNode(prevRenderNode);
|
9408
|
const /** @type {?} */ nextSibling = view.renderer.nextSibling(prevRenderNode);
|
9409
|
// Note: We can't check if `nextSibling` is present, as on WebWorkers it will always be!
|
9410
|
// However, browsers automatically do `appendChild` when there is no `nextSibling`.
|
9411
|
visitRootRenderNodes(view, 2 /* InsertBefore */, parentNode, nextSibling, undefined);
|
9412
|
}
|
9413
|
/**
|
9414
|
* @param {?} view
|
9415
|
* @return {?}
|
9416
|
*/
|
9417
|
function renderDetachView(view) {
|
9418
|
visitRootRenderNodes(view, 3 /* RemoveChild */, null, null, undefined);
|
9419
|
}
|
9420
|
/**
|
9421
|
* @param {?} arr
|
9422
|
* @param {?} index
|
9423
|
* @param {?} value
|
9424
|
* @return {?}
|
9425
|
*/
|
9426
|
function addToArray(arr, index, value) {
|
9427
|
// perf: array.push is faster than array.splice!
|
9428
|
if (index >= arr.length) {
|
9429
|
arr.push(value);
|
9430
|
}
|
9431
|
else {
|
9432
|
arr.splice(index, 0, value);
|
9433
|
}
|
9434
|
}
|
9435
|
/**
|
9436
|
* @param {?} arr
|
9437
|
* @param {?} index
|
9438
|
* @return {?}
|
9439
|
*/
|
9440
|
function removeFromArray(arr, index) {
|
9441
|
// perf: array.pop is faster than array.splice!
|
9442
|
if (index >= arr.length - 1) {
|
9443
|
arr.pop();
|
9444
|
}
|
9445
|
else {
|
9446
|
arr.splice(index, 1);
|
9447
|
}
|
9448
|
}
|
9449
|
|
9450
|
/**
|
9451
|
* @license
|
9452
|
* Copyright Google Inc. All Rights Reserved.
|
9453
|
*
|
9454
|
* Use of this source code is governed by an MIT-style license that can be
|
9455
|
* found in the LICENSE file at https://angular.io/license
|
9456
|
*/
|
9457
|
const EMPTY_CONTEXT = new Object();
|
9458
|
/**
|
9459
|
* @param {?} selector
|
9460
|
* @param {?} componentType
|
9461
|
* @param {?} viewDefFactory
|
9462
|
* @param {?} inputs
|
9463
|
* @param {?} outputs
|
9464
|
* @param {?} ngContentSelectors
|
9465
|
* @return {?}
|
9466
|
*/
|
9467
|
function createComponentFactory(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors) {
|
9468
|
return new ComponentFactory_(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors);
|
9469
|
}
|
9470
|
/**
|
9471
|
* @param {?} componentFactory
|
9472
|
* @return {?}
|
9473
|
*/
|
9474
|
function getComponentViewDefinitionFactory(componentFactory) {
|
9475
|
return ((componentFactory)).viewDefFactory;
|
9476
|
}
|
9477
|
class ComponentFactory_ extends ComponentFactory {
|
9478
|
/**
|
9479
|
* @param {?} selector
|
9480
|
* @param {?} componentType
|
9481
|
* @param {?} viewDefFactory
|
9482
|
* @param {?} _inputs
|
9483
|
* @param {?} _outputs
|
9484
|
* @param {?} ngContentSelectors
|
9485
|
*/
|
9486
|
constructor(selector, componentType, viewDefFactory, _inputs, _outputs, ngContentSelectors) {
|
9487
|
// Attention: this ctor is called as top level function.
|
9488
|
// Putting any logic in here will destroy closure tree shaking!
|
9489
|
super();
|
9490
|
this.selector = selector;
|
9491
|
this.componentType = componentType;
|
9492
|
this._inputs = _inputs;
|
9493
|
this._outputs = _outputs;
|
9494
|
this.ngContentSelectors = ngContentSelectors;
|
9495
|
this.viewDefFactory = viewDefFactory;
|
9496
|
}
|
9497
|
/**
|
9498
|
* @return {?}
|
9499
|
*/
|
9500
|
get inputs() {
|
9501
|
const /** @type {?} */ inputsArr = [];
|
9502
|
const /** @type {?} */ inputs = ((this._inputs));
|
9503
|
for (let /** @type {?} */ propName in inputs) {
|
9504
|
const /** @type {?} */ templateName = inputs[propName];
|
9505
|
inputsArr.push({ propName, templateName });
|
9506
|
}
|
9507
|
return inputsArr;
|
9508
|
}
|
9509
|
/**
|
9510
|
* @return {?}
|
9511
|
*/
|
9512
|
get outputs() {
|
9513
|
const /** @type {?} */ outputsArr = [];
|
9514
|
for (let /** @type {?} */ propName in this._outputs) {
|
9515
|
const /** @type {?} */ templateName = this._outputs[propName];
|
9516
|
outputsArr.push({ propName, templateName });
|
9517
|
}
|
9518
|
return outputsArr;
|
9519
|
}
|
9520
|
/**
|
9521
|
* Creates a new component.
|
9522
|
* @param {?} injector
|
9523
|
* @param {?=} projectableNodes
|
9524
|
* @param {?=} rootSelectorOrNode
|
9525
|
* @param {?=} ngModule
|
9526
|
* @return {?}
|
9527
|
*/
|
9528
|
create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
|
9529
|
if (!ngModule) {
|
9530
|
throw new Error('ngModule should be provided');
|
9531
|
}
|
9532
|
const /** @type {?} */ viewDef = resolveDefinition(this.viewDefFactory);
|
9533
|
const /** @type {?} */ componentNodeIndex = ((((viewDef.nodes[0].element)).componentProvider)).nodeIndex;
|
9534
|
const /** @type {?} */ view = Services.createRootView(injector, projectableNodes || [], rootSelectorOrNode, viewDef, ngModule, EMPTY_CONTEXT);
|
9535
|
const /** @type {?} */ component = asProviderData(view, componentNodeIndex).instance;
|
9536
|
if (rootSelectorOrNode) {
|
9537
|
view.renderer.setAttribute(asElementData(view, 0).renderElement, 'ng-version', VERSION.full);
|
9538
|
}
|
9539
|
return new ComponentRef_(view, new ViewRef_(view), component);
|
9540
|
}
|
9541
|
}
|
9542
|
class ComponentRef_ extends ComponentRef {
|
9543
|
/**
|
9544
|
* @param {?} _view
|
9545
|
* @param {?} _viewRef
|
9546
|
* @param {?} _component
|
9547
|
*/
|
9548
|
constructor(_view, _viewRef, _component) {
|
9549
|
super();
|
9550
|
this._view = _view;
|
9551
|
this._viewRef = _viewRef;
|
9552
|
this._component = _component;
|
9553
|
this._elDef = this._view.def.nodes[0];
|
9554
|
}
|
9555
|
/**
|
9556
|
* @return {?}
|
9557
|
*/
|
9558
|
get location() {
|
9559
|
return new ElementRef(asElementData(this._view, this._elDef.nodeIndex).renderElement);
|
9560
|
}
|
9561
|
/**
|
9562
|
* @return {?}
|
9563
|
*/
|
9564
|
get injector() { return new Injector_(this._view, this._elDef); }
|
9565
|
/**
|
9566
|
* @return {?}
|
9567
|
*/
|
9568
|
get instance() { return this._component; }
|
9569
|
/**
|
9570
|
* @return {?}
|
9571
|
*/
|
9572
|
get hostView() { return this._viewRef; }
|
9573
|
/**
|
9574
|
* @return {?}
|
9575
|
*/
|
9576
|
get changeDetectorRef() { return this._viewRef; }
|
9577
|
/**
|
9578
|
* @return {?}
|
9579
|
*/
|
9580
|
get componentType() { return (this._component.constructor); }
|
9581
|
/**
|
9582
|
* @return {?}
|
9583
|
*/
|
9584
|
destroy() { this._viewRef.destroy(); }
|
9585
|
/**
|
9586
|
* @param {?} callback
|
9587
|
* @return {?}
|
9588
|
*/
|
9589
|
onDestroy(callback) { this._viewRef.onDestroy(callback); }
|
9590
|
}
|
9591
|
/**
|
9592
|
* @param {?} view
|
9593
|
* @param {?} elDef
|
9594
|
* @param {?} elData
|
9595
|
* @return {?}
|
9596
|
*/
|
9597
|
function createViewContainerData(view, elDef, elData) {
|
9598
|
return new ViewContainerRef_(view, elDef, elData);
|
9599
|
}
|
9600
|
class ViewContainerRef_ {
|
9601
|
/**
|
9602
|
* @param {?} _view
|
9603
|
* @param {?} _elDef
|
9604
|
* @param {?} _data
|
9605
|
*/
|
9606
|
constructor(_view, _elDef, _data) {
|
9607
|
this._view = _view;
|
9608
|
this._elDef = _elDef;
|
9609
|
this._data = _data;
|
9610
|
/**
|
9611
|
* \@internal
|
9612
|
*/
|
9613
|
this._embeddedViews = [];
|
9614
|
}
|
9615
|
/**
|
9616
|
* @return {?}
|
9617
|
*/
|
9618
|
get element() { return new ElementRef(this._data.renderElement); }
|
9619
|
/**
|
9620
|
* @return {?}
|
9621
|
*/
|
9622
|
get injector() { return new Injector_(this._view, this._elDef); }
|
9623
|
/**
|
9624
|
* @return {?}
|
9625
|
*/
|
9626
|
get parentInjector() {
|
9627
|
let /** @type {?} */ view = this._view;
|
9628
|
let /** @type {?} */ elDef = this._elDef.parent;
|
9629
|
while (!elDef && view) {
|
9630
|
elDef = viewParentEl(view);
|
9631
|
view = ((view.parent));
|
9632
|
}
|
9633
|
return view ? new Injector_(view, elDef) : new Injector_(this._view, null);
|
9634
|
}
|
9635
|
/**
|
9636
|
* @return {?}
|
9637
|
*/
|
9638
|
clear() {
|
9639
|
const /** @type {?} */ len = this._embeddedViews.length;
|
9640
|
for (let /** @type {?} */ i = len - 1; i >= 0; i--) {
|
9641
|
const /** @type {?} */ view = ((detachEmbeddedView(this._data, i)));
|
9642
|
Services.destroyView(view);
|
9643
|
}
|
9644
|
}
|
9645
|
/**
|
9646
|
* @param {?} index
|
9647
|
* @return {?}
|
9648
|
*/
|
9649
|
get(index) {
|
9650
|
const /** @type {?} */ view = this._embeddedViews[index];
|
9651
|
if (view) {
|
9652
|
const /** @type {?} */ ref = new ViewRef_(view);
|
9653
|
ref.attachToViewContainerRef(this);
|
9654
|
return ref;
|
9655
|
}
|
9656
|
return null;
|
9657
|
}
|
9658
|
/**
|
9659
|
* @return {?}
|
9660
|
*/
|
9661
|
get length() { return this._embeddedViews.length; }
|
9662
|
/**
|
9663
|
* @template C
|
9664
|
* @param {?} templateRef
|
9665
|
* @param {?=} context
|
9666
|
* @param {?=} index
|
9667
|
* @return {?}
|
9668
|
*/
|
9669
|
createEmbeddedView(templateRef, context, index) {
|
9670
|
const /** @type {?} */ viewRef = templateRef.createEmbeddedView(context || ({}));
|
9671
|
this.insert(viewRef, index);
|
9672
|
return viewRef;
|
9673
|
}
|
9674
|
/**
|
9675
|
* @template C
|
9676
|
* @param {?} componentFactory
|
9677
|
* @param {?=} index
|
9678
|
* @param {?=} injector
|
9679
|
* @param {?=} projectableNodes
|
9680
|
* @param {?=} ngModuleRef
|
9681
|
* @return {?}
|
9682
|
*/
|
9683
|
createComponent(componentFactory, index, injector, projectableNodes, ngModuleRef) {
|
9684
|
const /** @type {?} */ contextInjector = injector || this.parentInjector;
|
9685
|
if (!ngModuleRef && !(componentFactory instanceof ComponentFactoryBoundToModule)) {
|
9686
|
ngModuleRef = contextInjector.get(NgModuleRef);
|
9687
|
}
|
9688
|
const /** @type {?} */ componentRef = componentFactory.create(contextInjector, projectableNodes, undefined, ngModuleRef);
|
9689
|
this.insert(componentRef.hostView, index);
|
9690
|
return componentRef;
|
9691
|
}
|
9692
|
/**
|
9693
|
* @param {?} viewRef
|
9694
|
* @param {?=} index
|
9695
|
* @return {?}
|
9696
|
*/
|
9697
|
insert(viewRef, index) {
|
9698
|
if (viewRef.destroyed) {
|
9699
|
throw new Error('Cannot insert a destroyed View in a ViewContainer!');
|
9700
|
}
|
9701
|
const /** @type {?} */ viewRef_ = (viewRef);
|
9702
|
const /** @type {?} */ viewData = viewRef_._view;
|
9703
|
attachEmbeddedView(this._view, this._data, index, viewData);
|
9704
|
viewRef_.attachToViewContainerRef(this);
|
9705
|
return viewRef;
|
9706
|
}
|
9707
|
/**
|
9708
|
* @param {?} viewRef
|
9709
|
* @param {?} currentIndex
|
9710
|
* @return {?}
|
9711
|
*/
|
9712
|
move(viewRef, currentIndex) {
|
9713
|
if (viewRef.destroyed) {
|
9714
|
throw new Error('Cannot move a destroyed View in a ViewContainer!');
|
9715
|
}
|
9716
|
const /** @type {?} */ previousIndex = this._embeddedViews.indexOf(viewRef._view);
|
9717
|
moveEmbeddedView(this._data, previousIndex, currentIndex);
|
9718
|
return viewRef;
|
9719
|
}
|
9720
|
/**
|
9721
|
* @param {?} viewRef
|
9722
|
* @return {?}
|
9723
|
*/
|
9724
|
indexOf(viewRef) {
|
9725
|
return this._embeddedViews.indexOf(((viewRef))._view);
|
9726
|
}
|
9727
|
/**
|
9728
|
* @param {?=} index
|
9729
|
* @return {?}
|
9730
|
*/
|
9731
|
remove(index) {
|
9732
|
const /** @type {?} */ viewData = detachEmbeddedView(this._data, index);
|
9733
|
if (viewData) {
|
9734
|
Services.destroyView(viewData);
|
9735
|
}
|
9736
|
}
|
9737
|
/**
|
9738
|
* @param {?=} index
|
9739
|
* @return {?}
|
9740
|
*/
|
9741
|
detach(index) {
|
9742
|
const /** @type {?} */ view = detachEmbeddedView(this._data, index);
|
9743
|
return view ? new ViewRef_(view) : null;
|
9744
|
}
|
9745
|
}
|
9746
|
/**
|
9747
|
* @param {?} view
|
9748
|
* @return {?}
|
9749
|
*/
|
9750
|
function createChangeDetectorRef(view) {
|
9751
|
return new ViewRef_(view);
|
9752
|
}
|
9753
|
class ViewRef_ {
|
9754
|
/**
|
9755
|
* @param {?} _view
|
9756
|
*/
|
9757
|
constructor(_view) {
|
9758
|
this._view = _view;
|
9759
|
this._viewContainerRef = null;
|
9760
|
this._appRef = null;
|
9761
|
}
|
9762
|
/**
|
9763
|
* @return {?}
|
9764
|
*/
|
9765
|
get rootNodes() { return rootRenderNodes(this._view); }
|
9766
|
/**
|
9767
|
* @return {?}
|
9768
|
*/
|
9769
|
get context() { return this._view.context; }
|
9770
|
/**
|
9771
|
* @return {?}
|
9772
|
*/
|
9773
|
get destroyed() { return (this._view.state & 128 /* Destroyed */) !== 0; }
|
9774
|
/**
|
9775
|
* @return {?}
|
9776
|
*/
|
9777
|
markForCheck() { markParentViewsForCheck(this._view); }
|
9778
|
/**
|
9779
|
* @return {?}
|
9780
|
*/
|
9781
|
detach() { this._view.state &= ~4 /* Attached */; }
|
9782
|
/**
|
9783
|
* @return {?}
|
9784
|
*/
|
9785
|
detectChanges() {
|
9786
|
const /** @type {?} */ fs = this._view.root.rendererFactory;
|
9787
|
if (fs.begin) {
|
9788
|
fs.begin();
|
9789
|
}
|
9790
|
Services.checkAndUpdateView(this._view);
|
9791
|
if (fs.end) {
|
9792
|
fs.end();
|
9793
|
}
|
9794
|
}
|
9795
|
/**
|
9796
|
* @return {?}
|
9797
|
*/
|
9798
|
checkNoChanges() { Services.checkNoChangesView(this._view); }
|
9799
|
/**
|
9800
|
* @return {?}
|
9801
|
*/
|
9802
|
reattach() { this._view.state |= 4 /* Attached */; }
|
9803
|
/**
|
9804
|
* @param {?} callback
|
9805
|
* @return {?}
|
9806
|
*/
|
9807
|
onDestroy(callback) {
|
9808
|
if (!this._view.disposables) {
|
9809
|
this._view.disposables = [];
|
9810
|
}
|
9811
|
this._view.disposables.push(/** @type {?} */ (callback));
|
9812
|
}
|
9813
|
/**
|
9814
|
* @return {?}
|
9815
|
*/
|
9816
|
destroy() {
|
9817
|
if (this._appRef) {
|
9818
|
this._appRef.detachView(this);
|
9819
|
}
|
9820
|
else if (this._viewContainerRef) {
|
9821
|
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this));
|
9822
|
}
|
9823
|
Services.destroyView(this._view);
|
9824
|
}
|
9825
|
/**
|
9826
|
* @return {?}
|
9827
|
*/
|
9828
|
detachFromAppRef() {
|
9829
|
this._appRef = null;
|
9830
|
renderDetachView(this._view);
|
9831
|
Services.dirtyParentQueries(this._view);
|
9832
|
}
|
9833
|
/**
|
9834
|
* @param {?} appRef
|
9835
|
* @return {?}
|
9836
|
*/
|
9837
|
attachToAppRef(appRef) {
|
9838
|
if (this._viewContainerRef) {
|
9839
|
throw new Error('This view is already attached to a ViewContainer!');
|
9840
|
}
|
9841
|
this._appRef = appRef;
|
9842
|
}
|
9843
|
/**
|
9844
|
* @param {?} vcRef
|
9845
|
* @return {?}
|
9846
|
*/
|
9847
|
attachToViewContainerRef(vcRef) {
|
9848
|
if (this._appRef) {
|
9849
|
throw new Error('This view is already attached directly to the ApplicationRef!');
|
9850
|
}
|
9851
|
this._viewContainerRef = vcRef;
|
9852
|
}
|
9853
|
}
|
9854
|
/**
|
9855
|
* @param {?} view
|
9856
|
* @param {?} def
|
9857
|
* @return {?}
|
9858
|
*/
|
9859
|
function createTemplateData(view, def) {
|
9860
|
return new TemplateRef_(view, def);
|
9861
|
}
|
9862
|
class TemplateRef_ extends TemplateRef {
|
9863
|
/**
|
9864
|
* @param {?} _parentView
|
9865
|
* @param {?} _def
|
9866
|
*/
|
9867
|
constructor(_parentView, _def) {
|
9868
|
super();
|
9869
|
this._parentView = _parentView;
|
9870
|
this._def = _def;
|
9871
|
}
|
9872
|
/**
|
9873
|
* @param {?} context
|
9874
|
* @return {?}
|
9875
|
*/
|
9876
|
createEmbeddedView(context) {
|
9877
|
return new ViewRef_(Services.createEmbeddedView(this._parentView, this._def, /** @type {?} */ ((((this._def.element)).template)), context));
|
9878
|
}
|
9879
|
/**
|
9880
|
* @return {?}
|
9881
|
*/
|
9882
|
get elementRef() {
|
9883
|
return new ElementRef(asElementData(this._parentView, this._def.nodeIndex).renderElement);
|
9884
|
}
|
9885
|
}
|
9886
|
/**
|
9887
|
* @param {?} view
|
9888
|
* @param {?} elDef
|
9889
|
* @return {?}
|
9890
|
*/
|
9891
|
function createInjector(view, elDef) {
|
9892
|
return new Injector_(view, elDef);
|
9893
|
}
|
9894
|
class Injector_ {
|
9895
|
/**
|
9896
|
* @param {?} view
|
9897
|
* @param {?} elDef
|
9898
|
*/
|
9899
|
constructor(view, elDef) {
|
9900
|
this.view = view;
|
9901
|
this.elDef = elDef;
|
9902
|
}
|
9903
|
/**
|
9904
|
* @param {?} token
|
9905
|
* @param {?=} notFoundValue
|
9906
|
* @return {?}
|
9907
|
*/
|
9908
|
get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
|
9909
|
const /** @type {?} */ allowPrivateServices = this.elDef ? (this.elDef.flags & 33554432 /* ComponentView */) !== 0 : false;
|
9910
|
return Services.resolveDep(this.view, this.elDef, allowPrivateServices, { flags: 0 /* None */, token, tokenKey: tokenKey(token) }, notFoundValue);
|
9911
|
}
|
9912
|
}
|
9913
|
/**
|
9914
|
* @param {?} view
|
9915
|
* @param {?} index
|
9916
|
* @return {?}
|
9917
|
*/
|
9918
|
function nodeValue(view, index) {
|
9919
|
const /** @type {?} */ def = view.def.nodes[index];
|
9920
|
if (def.flags & 1 /* TypeElement */) {
|
9921
|
const /** @type {?} */ elData = asElementData(view, def.nodeIndex);
|
9922
|
return ((def.element)).template ? elData.template : elData.renderElement;
|
9923
|
}
|
9924
|
else if (def.flags & 2 /* TypeText */) {
|
9925
|
return asTextData(view, def.nodeIndex).renderText;
|
9926
|
}
|
9927
|
else if (def.flags & (20224 /* CatProvider */ | 16 /* TypePipe */)) {
|
9928
|
return asProviderData(view, def.nodeIndex).instance;
|
9929
|
}
|
9930
|
throw new Error(`Illegal state: read nodeValue for node index ${index}`);
|
9931
|
}
|
9932
|
/**
|
9933
|
* @param {?} view
|
9934
|
* @return {?}
|
9935
|
*/
|
9936
|
function createRendererV1(view) {
|
9937
|
return new RendererAdapter(view.renderer);
|
9938
|
}
|
9939
|
class RendererAdapter {
|
9940
|
/**
|
9941
|
* @param {?} delegate
|
9942
|
*/
|
9943
|
constructor(delegate) {
|
9944
|
this.delegate = delegate;
|
9945
|
}
|
9946
|
/**
|
9947
|
* @param {?} selectorOrNode
|
9948
|
* @return {?}
|
9949
|
*/
|
9950
|
selectRootElement(selectorOrNode) {
|
9951
|
return this.delegate.selectRootElement(selectorOrNode);
|
9952
|
}
|
9953
|
/**
|
9954
|
* @param {?} parent
|
9955
|
* @param {?} namespaceAndName
|
9956
|
* @return {?}
|
9957
|
*/
|
9958
|
createElement(parent, namespaceAndName) {
|
9959
|
const [ns, name] = splitNamespace(namespaceAndName);
|
9960
|
const /** @type {?} */ el = this.delegate.createElement(name, ns);
|
9961
|
if (parent) {
|
9962
|
this.delegate.appendChild(parent, el);
|
9963
|
}
|
9964
|
return el;
|
9965
|
}
|
9966
|
/**
|
9967
|
* @param {?} hostElement
|
9968
|
* @return {?}
|
9969
|
*/
|
9970
|
createViewRoot(hostElement) { return hostElement; }
|
9971
|
/**
|
9972
|
* @param {?} parentElement
|
9973
|
* @return {?}
|
9974
|
*/
|
9975
|
createTemplateAnchor(parentElement) {
|
9976
|
const /** @type {?} */ comment = this.delegate.createComment('');
|
9977
|
if (parentElement) {
|
9978
|
this.delegate.appendChild(parentElement, comment);
|
9979
|
}
|
9980
|
return comment;
|
9981
|
}
|
9982
|
/**
|
9983
|
* @param {?} parentElement
|
9984
|
* @param {?} value
|
9985
|
* @return {?}
|
9986
|
*/
|
9987
|
createText(parentElement, value) {
|
9988
|
const /** @type {?} */ node = this.delegate.createText(value);
|
9989
|
if (parentElement) {
|
9990
|
this.delegate.appendChild(parentElement, node);
|
9991
|
}
|
9992
|
return node;
|
9993
|
}
|
9994
|
/**
|
9995
|
* @param {?} parentElement
|
9996
|
* @param {?} nodes
|
9997
|
* @return {?}
|
9998
|
*/
|
9999
|
projectNodes(parentElement, nodes) {
|
10000
|
for (let /** @type {?} */ i = 0; i < nodes.length; i++) {
|
10001
|
this.delegate.appendChild(parentElement, nodes[i]);
|
10002
|
}
|
10003
|
}
|
10004
|
/**
|
10005
|
* @param {?} node
|
10006
|
* @param {?} viewRootNodes
|
10007
|
* @return {?}
|
10008
|
*/
|
10009
|
attachViewAfter(node, viewRootNodes) {
|
10010
|
const /** @type {?} */ parentElement = this.delegate.parentNode(node);
|
10011
|
const /** @type {?} */ nextSibling = this.delegate.nextSibling(node);
|
10012
|
for (let /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
|
10013
|
this.delegate.insertBefore(parentElement, viewRootNodes[i], nextSibling);
|
10014
|
}
|
10015
|
}
|
10016
|
/**
|
10017
|
* @param {?} viewRootNodes
|
10018
|
* @return {?}
|
10019
|
*/
|
10020
|
detachView(viewRootNodes) {
|
10021
|
for (let /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
|
10022
|
const /** @type {?} */ node = viewRootNodes[i];
|
10023
|
const /** @type {?} */ parentElement = this.delegate.parentNode(node);
|
10024
|
this.delegate.removeChild(parentElement, node);
|
10025
|
}
|
10026
|
}
|
10027
|
/**
|
10028
|
* @param {?} hostElement
|
10029
|
* @param {?} viewAllNodes
|
10030
|
* @return {?}
|
10031
|
*/
|
10032
|
destroyView(hostElement, viewAllNodes) {
|
10033
|
for (let /** @type {?} */ i = 0; i < viewAllNodes.length; i++) {
|
10034
|
((this.delegate.destroyNode))(viewAllNodes[i]);
|
10035
|
}
|
10036
|
}
|
10037
|
/**
|
10038
|
* @param {?} renderElement
|
10039
|
* @param {?} name
|
10040
|
* @param {?} callback
|
10041
|
* @return {?}
|
10042
|
*/
|
10043
|
listen(renderElement, name, callback) {
|
10044
|
return this.delegate.listen(renderElement, name, /** @type {?} */ (callback));
|
10045
|
}
|
10046
|
/**
|
10047
|
* @param {?} target
|
10048
|
* @param {?} name
|
10049
|
* @param {?} callback
|
10050
|
* @return {?}
|
10051
|
*/
|
10052
|
listenGlobal(target, name, callback) {
|
10053
|
return this.delegate.listen(target, name, /** @type {?} */ (callback));
|
10054
|
}
|
10055
|
/**
|
10056
|
* @param {?} renderElement
|
10057
|
* @param {?} propertyName
|
10058
|
* @param {?} propertyValue
|
10059
|
* @return {?}
|
10060
|
*/
|
10061
|
setElementProperty(renderElement, propertyName, propertyValue) {
|
10062
|
this.delegate.setProperty(renderElement, propertyName, propertyValue);
|
10063
|
}
|
10064
|
/**
|
10065
|
* @param {?} renderElement
|
10066
|
* @param {?} namespaceAndName
|
10067
|
* @param {?} attributeValue
|
10068
|
* @return {?}
|
10069
|
*/
|
10070
|
setElementAttribute(renderElement, namespaceAndName, attributeValue) {
|
10071
|
const [ns, name] = splitNamespace(namespaceAndName);
|
10072
|
if (attributeValue != null) {
|
10073
|
this.delegate.setAttribute(renderElement, name, attributeValue, ns);
|
10074
|
}
|
10075
|
else {
|
10076
|
this.delegate.removeAttribute(renderElement, name, ns);
|
10077
|
}
|
10078
|
}
|
10079
|
/**
|
10080
|
* @param {?} renderElement
|
10081
|
* @param {?} propertyName
|
10082
|
* @param {?} propertyValue
|
10083
|
* @return {?}
|
10084
|
*/
|
10085
|
setBindingDebugInfo(renderElement, propertyName, propertyValue) { }
|
10086
|
/**
|
10087
|
* @param {?} renderElement
|
10088
|
* @param {?} className
|
10089
|
* @param {?} isAdd
|
10090
|
* @return {?}
|
10091
|
*/
|
10092
|
setElementClass(renderElement, className, isAdd) {
|
10093
|
if (isAdd) {
|
10094
|
this.delegate.addClass(renderElement, className);
|
10095
|
}
|
10096
|
else {
|
10097
|
this.delegate.removeClass(renderElement, className);
|
10098
|
}
|
10099
|
}
|
10100
|
/**
|
10101
|
* @param {?} renderElement
|
10102
|
* @param {?} styleName
|
10103
|
* @param {?} styleValue
|
10104
|
* @return {?}
|
10105
|
*/
|
10106
|
setElementStyle(renderElement, styleName, styleValue) {
|
10107
|
if (styleValue != null) {
|
10108
|
this.delegate.setStyle(renderElement, styleName, styleValue);
|
10109
|
}
|
10110
|
else {
|
10111
|
this.delegate.removeStyle(renderElement, styleName);
|
10112
|
}
|
10113
|
}
|
10114
|
/**
|
10115
|
* @param {?} renderElement
|
10116
|
* @param {?} methodName
|
10117
|
* @param {?} args
|
10118
|
* @return {?}
|
10119
|
*/
|
10120
|
invokeElementMethod(renderElement, methodName, args) {
|
10121
|
((renderElement))[methodName].apply(renderElement, args);
|
10122
|
}
|
10123
|
/**
|
10124
|
* @param {?} renderNode
|
10125
|
* @param {?} text
|
10126
|
* @return {?}
|
10127
|
*/
|
10128
|
setText(renderNode$$1, text) { this.delegate.setValue(renderNode$$1, text); }
|
10129
|
/**
|
10130
|
* @return {?}
|
10131
|
*/
|
10132
|
animate() { throw new Error('Renderer.animate is no longer supported!'); }
|
10133
|
}
|
10134
|
/**
|
10135
|
* @param {?} moduleType
|
10136
|
* @param {?} parent
|
10137
|
* @param {?} bootstrapComponents
|
10138
|
* @param {?} def
|
10139
|
* @return {?}
|
10140
|
*/
|
10141
|
function createNgModuleRef(moduleType, parent, bootstrapComponents, def) {
|
10142
|
return new NgModuleRef_(moduleType, parent, bootstrapComponents, def);
|
10143
|
}
|
10144
|
class NgModuleRef_ {
|
10145
|
/**
|
10146
|
* @param {?} _moduleType
|
10147
|
* @param {?} _parent
|
10148
|
* @param {?} _bootstrapComponents
|
10149
|
* @param {?} _def
|
10150
|
*/
|
10151
|
constructor(_moduleType, _parent, _bootstrapComponents, _def) {
|
10152
|
this._moduleType = _moduleType;
|
10153
|
this._parent = _parent;
|
10154
|
this._bootstrapComponents = _bootstrapComponents;
|
10155
|
this._def = _def;
|
10156
|
this._destroyListeners = [];
|
10157
|
this._destroyed = false;
|
10158
|
initNgModule(this);
|
10159
|
}
|
10160
|
/**
|
10161
|
* @param {?} token
|
10162
|
* @param {?=} notFoundValue
|
10163
|
* @return {?}
|
10164
|
*/
|
10165
|
get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
|
10166
|
return resolveNgModuleDep(this, { token: token, tokenKey: tokenKey(token), flags: 0 /* None */ }, notFoundValue);
|
10167
|
}
|
10168
|
/**
|
10169
|
* @return {?}
|
10170
|
*/
|
10171
|
get instance() { return this.get(this._moduleType); }
|
10172
|
/**
|
10173
|
* @return {?}
|
10174
|
*/
|
10175
|
get componentFactoryResolver() { return this.get(ComponentFactoryResolver); }
|
10176
|
/**
|
10177
|
* @return {?}
|
10178
|
*/
|
10179
|
get injector() { return this; }
|
10180
|
/**
|
10181
|
* @return {?}
|
10182
|
*/
|
10183
|
destroy() {
|
10184
|
if (this._destroyed) {
|
10185
|
throw new Error(`The ng module ${stringify(this.instance.constructor)} has already been destroyed.`);
|
10186
|
}
|
10187
|
this._destroyed = true;
|
10188
|
callNgModuleLifecycle(this, 131072 /* OnDestroy */);
|
10189
|
this._destroyListeners.forEach((listener) => listener());
|
10190
|
}
|
10191
|
/**
|
10192
|
* @param {?} callback
|
10193
|
* @return {?}
|
10194
|
*/
|
10195
|
onDestroy(callback) { this._destroyListeners.push(callback); }
|
10196
|
}
|
10197
|
|
10198
|
/**
|
10199
|
* @license
|
10200
|
* Copyright Google Inc. All Rights Reserved.
|
10201
|
*
|
10202
|
* Use of this source code is governed by an MIT-style license that can be
|
10203
|
* found in the LICENSE file at https://angular.io/license
|
10204
|
*/
|
10205
|
const RendererV1TokenKey = tokenKey(Renderer);
|
10206
|
const Renderer2TokenKey = tokenKey(Renderer2);
|
10207
|
const ElementRefTokenKey = tokenKey(ElementRef);
|
10208
|
const ViewContainerRefTokenKey = tokenKey(ViewContainerRef);
|
10209
|
const TemplateRefTokenKey = tokenKey(TemplateRef);
|
10210
|
const ChangeDetectorRefTokenKey = tokenKey(ChangeDetectorRef);
|
10211
|
const InjectorRefTokenKey = tokenKey(Injector);
|
10212
|
/**
|
10213
|
* @param {?} checkIndex
|
10214
|
* @param {?} flags
|
10215
|
* @param {?} matchedQueries
|
10216
|
* @param {?} childCount
|
10217
|
* @param {?} ctor
|
10218
|
* @param {?} deps
|
10219
|
* @param {?=} props
|
10220
|
* @param {?=} outputs
|
10221
|
* @return {?}
|
10222
|
*/
|
10223
|
function directiveDef(checkIndex, flags, matchedQueries, childCount, ctor, deps, props, outputs) {
|
10224
|
const /** @type {?} */ bindings = [];
|
10225
|
if (props) {
|
10226
|
for (let /** @type {?} */ prop in props) {
|
10227
|
const [bindingIndex, nonMinifiedName] = props[prop];
|
10228
|
bindings[bindingIndex] = {
|
10229
|
flags: 8 /* TypeProperty */,
|
10230
|
name: prop, nonMinifiedName,
|
10231
|
ns: null,
|
10232
|
securityContext: null,
|
10233
|
suffix: null
|
10234
|
};
|
10235
|
}
|
10236
|
}
|
10237
|
const /** @type {?} */ outputDefs = [];
|
10238
|
if (outputs) {
|
10239
|
for (let /** @type {?} */ propName in outputs) {
|
10240
|
outputDefs.push({ type: 1 /* DirectiveOutput */, propName, target: null, eventName: outputs[propName] });
|
10241
|
}
|
10242
|
}
|
10243
|
flags |= 16384 /* TypeDirective */;
|
10244
|
return _def(checkIndex, flags, matchedQueries, childCount, ctor, ctor, deps, bindings, outputDefs);
|
10245
|
}
|
10246
|
/**
|
10247
|
* @param {?} flags
|
10248
|
* @param {?} ctor
|
10249
|
* @param {?} deps
|
10250
|
* @return {?}
|
10251
|
*/
|
10252
|
function pipeDef(flags, ctor, deps) {
|
10253
|
flags |= 16 /* TypePipe */;
|
10254
|
return _def(-1, flags, null, 0, ctor, ctor, deps);
|
10255
|
}
|
10256
|
/**
|
10257
|
* @param {?} flags
|
10258
|
* @param {?} matchedQueries
|
10259
|
* @param {?} token
|
10260
|
* @param {?} value
|
10261
|
* @param {?} deps
|
10262
|
* @return {?}
|
10263
|
*/
|
10264
|
function providerDef(flags, matchedQueries, token, value, deps) {
|
10265
|
return _def(-1, flags, matchedQueries, 0, token, value, deps);
|
10266
|
}
|
10267
|
/**
|
10268
|
* @param {?} checkIndex
|
10269
|
* @param {?} flags
|
10270
|
* @param {?} matchedQueriesDsl
|
10271
|
* @param {?} childCount
|
10272
|
* @param {?} token
|
10273
|
* @param {?} value
|
10274
|
* @param {?} deps
|
10275
|
* @param {?=} bindings
|
10276
|
* @param {?=} outputs
|
10277
|
* @return {?}
|
10278
|
*/
|
10279
|
function _def(checkIndex, flags, matchedQueriesDsl, childCount, token, value, deps, bindings, outputs) {
|
10280
|
const { matchedQueries, references, matchedQueryIds } = splitMatchedQueriesDsl(matchedQueriesDsl);
|
10281
|
if (!outputs) {
|
10282
|
outputs = [];
|
10283
|
}
|
10284
|
if (!bindings) {
|
10285
|
bindings = [];
|
10286
|
}
|
10287
|
const /** @type {?} */ depDefs = splitDepsDsl(deps);
|
10288
|
return {
|
10289
|
// will bet set by the view definition
|
10290
|
nodeIndex: -1,
|
10291
|
parent: null,
|
10292
|
renderParent: null,
|
10293
|
bindingIndex: -1,
|
10294
|
outputIndex: -1,
|
10295
|
// regular values
|
10296
|
checkIndex,
|
10297
|
flags,
|
10298
|
childFlags: 0,
|
10299
|
directChildFlags: 0,
|
10300
|
childMatchedQueries: 0, matchedQueries, matchedQueryIds, references,
|
10301
|
ngContentIndex: -1, childCount, bindings,
|
10302
|
bindingFlags: calcBindingFlags(bindings), outputs,
|
10303
|
element: null,
|
10304
|
provider: { token, value, deps: depDefs },
|
10305
|
text: null,
|
10306
|
query: null,
|
10307
|
ngContent: null
|
10308
|
};
|
10309
|
}
|
10310
|
/**
|
10311
|
* @param {?} view
|
10312
|
* @param {?} def
|
10313
|
* @return {?}
|
10314
|
*/
|
10315
|
function createProviderInstance(view, def) {
|
10316
|
return _createProviderInstance(view, def);
|
10317
|
}
|
10318
|
/**
|
10319
|
* @param {?} view
|
10320
|
* @param {?} def
|
10321
|
* @return {?}
|
10322
|
*/
|
10323
|
function createPipeInstance(view, def) {
|
10324
|
// deps are looked up from component.
|
10325
|
let /** @type {?} */ compView = view;
|
10326
|
while (compView.parent && !isComponentView(compView)) {
|
10327
|
compView = compView.parent;
|
10328
|
}
|
10329
|
// pipes can see the private services of the component
|
10330
|
const /** @type {?} */ allowPrivateServices = true;
|
10331
|
// pipes are always eager and classes!
|
10332
|
return createClass(/** @type {?} */ ((compView.parent)), /** @type {?} */ ((viewParentEl(compView))), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
|
10333
|
}
|
10334
|
/**
|
10335
|
* @param {?} view
|
10336
|
* @param {?} def
|
10337
|
* @return {?}
|
10338
|
*/
|
10339
|
function createDirectiveInstance(view, def) {
|
10340
|
// components can see other private services, other directives can't.
|
10341
|
const /** @type {?} */ allowPrivateServices = (def.flags & 32768 /* Component */) > 0;
|
10342
|
// directives are always eager and classes!
|
10343
|
const /** @type {?} */ instance = createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
|
10344
|
if (def.outputs.length) {
|
10345
|
for (let /** @type {?} */ i = 0; i < def.outputs.length; i++) {
|
10346
|
const /** @type {?} */ output = def.outputs[i];
|
10347
|
const /** @type {?} */ subscription = instance[((output.propName))].subscribe(eventHandlerClosure(view, /** @type {?} */ ((def.parent)).nodeIndex, output.eventName)); /** @type {?} */
|
10348
|
((view.disposables))[def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
|
10349
|
}
|
10350
|
}
|
10351
|
return instance;
|
10352
|
}
|
10353
|
/**
|
10354
|
* @param {?} view
|
10355
|
* @param {?} index
|
10356
|
* @param {?} eventName
|
10357
|
* @return {?}
|
10358
|
*/
|
10359
|
function eventHandlerClosure(view, index, eventName) {
|
10360
|
return (event) => {
|
10361
|
try {
|
10362
|
return dispatchEvent(view, index, eventName, event);
|
10363
|
}
|
10364
|
catch (e) {
|
10365
|
// Attention: Don't rethrow, as it would cancel Observable subscriptions!
|
10366
|
view.root.errorHandler.handleError(e);
|
10367
|
}
|
10368
|
};
|
10369
|
}
|
10370
|
/**
|
10371
|
* @param {?} view
|
10372
|
* @param {?} def
|
10373
|
* @param {?} v0
|
10374
|
* @param {?} v1
|
10375
|
* @param {?} v2
|
10376
|
* @param {?} v3
|
10377
|
* @param {?} v4
|
10378
|
* @param {?} v5
|
10379
|
* @param {?} v6
|
10380
|
* @param {?} v7
|
10381
|
* @param {?} v8
|
10382
|
* @param {?} v9
|
10383
|
* @return {?}
|
10384
|
*/
|
10385
|
function checkAndUpdateDirectiveInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
10386
|
const /** @type {?} */ providerData = asProviderData(view, def.nodeIndex);
|
10387
|
const /** @type {?} */ directive = providerData.instance;
|
10388
|
let /** @type {?} */ changed = false;
|
10389
|
let /** @type {?} */ changes = ((undefined));
|
10390
|
const /** @type {?} */ bindLen = def.bindings.length;
|
10391
|
if (bindLen > 0 && checkBinding(view, def, 0, v0)) {
|
10392
|
changed = true;
|
10393
|
changes = updateProp(view, providerData, def, 0, v0, changes);
|
10394
|
}
|
10395
|
if (bindLen > 1 && checkBinding(view, def, 1, v1)) {
|
10396
|
changed = true;
|
10397
|
changes = updateProp(view, providerData, def, 1, v1, changes);
|
10398
|
}
|
10399
|
if (bindLen > 2 && checkBinding(view, def, 2, v2)) {
|
10400
|
changed = true;
|
10401
|
changes = updateProp(view, providerData, def, 2, v2, changes);
|
10402
|
}
|
10403
|
if (bindLen > 3 && checkBinding(view, def, 3, v3)) {
|
10404
|
changed = true;
|
10405
|
changes = updateProp(view, providerData, def, 3, v3, changes);
|
10406
|
}
|
10407
|
if (bindLen > 4 && checkBinding(view, def, 4, v4)) {
|
10408
|
changed = true;
|
10409
|
changes = updateProp(view, providerData, def, 4, v4, changes);
|
10410
|
}
|
10411
|
if (bindLen > 5 && checkBinding(view, def, 5, v5)) {
|
10412
|
changed = true;
|
10413
|
changes = updateProp(view, providerData, def, 5, v5, changes);
|
10414
|
}
|
10415
|
if (bindLen > 6 && checkBinding(view, def, 6, v6)) {
|
10416
|
changed = true;
|
10417
|
changes = updateProp(view, providerData, def, 6, v6, changes);
|
10418
|
}
|
10419
|
if (bindLen > 7 && checkBinding(view, def, 7, v7)) {
|
10420
|
changed = true;
|
10421
|
changes = updateProp(view, providerData, def, 7, v7, changes);
|
10422
|
}
|
10423
|
if (bindLen > 8 && checkBinding(view, def, 8, v8)) {
|
10424
|
changed = true;
|
10425
|
changes = updateProp(view, providerData, def, 8, v8, changes);
|
10426
|
}
|
10427
|
if (bindLen > 9 && checkBinding(view, def, 9, v9)) {
|
10428
|
changed = true;
|
10429
|
changes = updateProp(view, providerData, def, 9, v9, changes);
|
10430
|
}
|
10431
|
if (changes) {
|
10432
|
directive.ngOnChanges(changes);
|
10433
|
}
|
10434
|
if ((view.state & 2 /* FirstCheck */) && (def.flags & 65536 /* OnInit */)) {
|
10435
|
directive.ngOnInit();
|
10436
|
}
|
10437
|
if (def.flags & 262144 /* DoCheck */) {
|
10438
|
directive.ngDoCheck();
|
10439
|
}
|
10440
|
return changed;
|
10441
|
}
|
10442
|
/**
|
10443
|
* @param {?} view
|
10444
|
* @param {?} def
|
10445
|
* @param {?} values
|
10446
|
* @return {?}
|
10447
|
*/
|
10448
|
function checkAndUpdateDirectiveDynamic(view, def, values) {
|
10449
|
const /** @type {?} */ providerData = asProviderData(view, def.nodeIndex);
|
10450
|
const /** @type {?} */ directive = providerData.instance;
|
10451
|
let /** @type {?} */ changed = false;
|
10452
|
let /** @type {?} */ changes = ((undefined));
|
10453
|
for (let /** @type {?} */ i = 0; i < values.length; i++) {
|
10454
|
if (checkBinding(view, def, i, values[i])) {
|
10455
|
changed = true;
|
10456
|
changes = updateProp(view, providerData, def, i, values[i], changes);
|
10457
|
}
|
10458
|
}
|
10459
|
if (changes) {
|
10460
|
directive.ngOnChanges(changes);
|
10461
|
}
|
10462
|
if ((view.state & 2 /* FirstCheck */) && (def.flags & 65536 /* OnInit */)) {
|
10463
|
directive.ngOnInit();
|
10464
|
}
|
10465
|
if (def.flags & 262144 /* DoCheck */) {
|
10466
|
directive.ngDoCheck();
|
10467
|
}
|
10468
|
return changed;
|
10469
|
}
|
10470
|
/**
|
10471
|
* @param {?} view
|
10472
|
* @param {?} def
|
10473
|
* @return {?}
|
10474
|
*/
|
10475
|
function _createProviderInstance(view, def) {
|
10476
|
// private services can see other private services
|
10477
|
const /** @type {?} */ allowPrivateServices = (def.flags & 8192 /* PrivateProvider */) > 0;
|
10478
|
const /** @type {?} */ providerDef = def.provider;
|
10479
|
switch (def.flags & 201347067 /* Types */) {
|
10480
|
case 512 /* TypeClassProvider */:
|
10481
|
return createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
|
10482
|
case 1024 /* TypeFactoryProvider */:
|
10483
|
return callFactory(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
|
10484
|
case 2048 /* TypeUseExistingProvider */:
|
10485
|
return resolveDep(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).deps[0]);
|
10486
|
case 256 /* TypeValueProvider */:
|
10487
|
return ((providerDef)).value;
|
10488
|
}
|
10489
|
}
|
10490
|
/**
|
10491
|
* @param {?} view
|
10492
|
* @param {?} elDef
|
10493
|
* @param {?} allowPrivateServices
|
10494
|
* @param {?} ctor
|
10495
|
* @param {?} deps
|
10496
|
* @return {?}
|
10497
|
*/
|
10498
|
function createClass(view, elDef, allowPrivateServices, ctor, deps) {
|
10499
|
const /** @type {?} */ len = deps.length;
|
10500
|
switch (len) {
|
10501
|
case 0:
|
10502
|
return new ctor();
|
10503
|
case 1:
|
10504
|
return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]));
|
10505
|
case 2:
|
10506
|
return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
|
10507
|
case 3:
|
10508
|
return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
|
10509
|
default:
|
10510
|
const /** @type {?} */ depValues = new Array(len);
|
10511
|
for (let /** @type {?} */ i = 0; i < len; i++) {
|
10512
|
depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
|
10513
|
}
|
10514
|
return new ctor(...depValues);
|
10515
|
}
|
10516
|
}
|
10517
|
/**
|
10518
|
* @param {?} view
|
10519
|
* @param {?} elDef
|
10520
|
* @param {?} allowPrivateServices
|
10521
|
* @param {?} factory
|
10522
|
* @param {?} deps
|
10523
|
* @return {?}
|
10524
|
*/
|
10525
|
function callFactory(view, elDef, allowPrivateServices, factory, deps) {
|
10526
|
const /** @type {?} */ len = deps.length;
|
10527
|
switch (len) {
|
10528
|
case 0:
|
10529
|
return factory();
|
10530
|
case 1:
|
10531
|
return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]));
|
10532
|
case 2:
|
10533
|
return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
|
10534
|
case 3:
|
10535
|
return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
|
10536
|
default:
|
10537
|
const /** @type {?} */ depValues = Array(len);
|
10538
|
for (let /** @type {?} */ i = 0; i < len; i++) {
|
10539
|
depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
|
10540
|
}
|
10541
|
return factory(...depValues);
|
10542
|
}
|
10543
|
}
|
10544
|
// This default value is when checking the hierarchy for a token.
|
10545
|
//
|
10546
|
// It means both:
|
10547
|
// - the token is not provided by the current injector,
|
10548
|
// - only the element injectors should be checked (ie do not check module injectors
|
10549
|
//
|
10550
|
// mod1
|
10551
|
// /
|
10552
|
// el1 mod2
|
10553
|
// \ /
|
10554
|
// el2
|
10555
|
//
|
10556
|
// When requesting el2.injector.get(token), we should check in the following order and return the
|
10557
|
// first found value:
|
10558
|
// - el2.injector.get(token, default)
|
10559
|
// - el1.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) -> do not check the module
|
10560
|
// - mod2.injector.get(token, default)
|
10561
|
const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
|
10562
|
/**
|
10563
|
* @param {?} view
|
10564
|
* @param {?} elDef
|
10565
|
* @param {?} allowPrivateServices
|
10566
|
* @param {?} depDef
|
10567
|
* @param {?=} notFoundValue
|
10568
|
* @return {?}
|
10569
|
*/
|
10570
|
function resolveDep(view, elDef, allowPrivateServices, depDef, notFoundValue = Injector.THROW_IF_NOT_FOUND) {
|
10571
|
if (depDef.flags & 8 /* Value */) {
|
10572
|
return depDef.token;
|
10573
|
}
|
10574
|
const /** @type {?} */ startView = view;
|
10575
|
if (depDef.flags & 2 /* Optional */) {
|
10576
|
notFoundValue = null;
|
10577
|
}
|
10578
|
const /** @type {?} */ tokenKey$$1 = depDef.tokenKey;
|
10579
|
if (tokenKey$$1 === ChangeDetectorRefTokenKey) {
|
10580
|
// directives on the same element as a component should be able to control the change detector
|
10581
|
// of that component as well.
|
10582
|
allowPrivateServices = !!(elDef && ((elDef.element)).componentView);
|
10583
|
}
|
10584
|
if (elDef && (depDef.flags & 1 /* SkipSelf */)) {
|
10585
|
allowPrivateServices = false;
|
10586
|
elDef = ((elDef.parent));
|
10587
|
}
|
10588
|
while (view) {
|
10589
|
if (elDef) {
|
10590
|
switch (tokenKey$$1) {
|
10591
|
case RendererV1TokenKey: {
|
10592
|
const /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
|
10593
|
return createRendererV1(compView);
|
10594
|
}
|
10595
|
case Renderer2TokenKey: {
|
10596
|
const /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
|
10597
|
return compView.renderer;
|
10598
|
}
|
10599
|
case ElementRefTokenKey:
|
10600
|
return new ElementRef(asElementData(view, elDef.nodeIndex).renderElement);
|
10601
|
case ViewContainerRefTokenKey:
|
10602
|
return asElementData(view, elDef.nodeIndex).viewContainer;
|
10603
|
case TemplateRefTokenKey: {
|
10604
|
if (((elDef.element)).template) {
|
10605
|
return asElementData(view, elDef.nodeIndex).template;
|
10606
|
}
|
10607
|
break;
|
10608
|
}
|
10609
|
case ChangeDetectorRefTokenKey: {
|
10610
|
let /** @type {?} */ cdView = findCompView(view, elDef, allowPrivateServices);
|
10611
|
return createChangeDetectorRef(cdView);
|
10612
|
}
|
10613
|
case InjectorRefTokenKey:
|
10614
|
return createInjector(view, elDef);
|
10615
|
default:
|
10616
|
const /** @type {?} */ providerDef = (((allowPrivateServices ? ((elDef.element)).allProviders : ((elDef.element)).publicProviders)))[tokenKey$$1];
|
10617
|
if (providerDef) {
|
10618
|
let /** @type {?} */ providerData = asProviderData(view, providerDef.nodeIndex);
|
10619
|
if (!providerData) {
|
10620
|
providerData = { instance: _createProviderInstance(view, providerDef) };
|
10621
|
view.nodes[providerDef.nodeIndex] = (providerData);
|
10622
|
}
|
10623
|
return providerData.instance;
|
10624
|
}
|
10625
|
}
|
10626
|
}
|
10627
|
allowPrivateServices = isComponentView(view);
|
10628
|
elDef = ((viewParentEl(view)));
|
10629
|
view = ((view.parent));
|
10630
|
}
|
10631
|
const /** @type {?} */ value = startView.root.injector.get(depDef.token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR);
|
10632
|
if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
|
10633
|
notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
|
10634
|
// Return the value from the root element injector when
|
10635
|
// - it provides it
|
10636
|
// (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
|
10637
|
// - the module injector should not be checked
|
10638
|
// (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
|
10639
|
return value;
|
10640
|
}
|
10641
|
return startView.root.ngModule.injector.get(depDef.token, notFoundValue);
|
10642
|
}
|
10643
|
/**
|
10644
|
* @param {?} view
|
10645
|
* @param {?} elDef
|
10646
|
* @param {?} allowPrivateServices
|
10647
|
* @return {?}
|
10648
|
*/
|
10649
|
function findCompView(view, elDef, allowPrivateServices) {
|
10650
|
let /** @type {?} */ compView;
|
10651
|
if (allowPrivateServices) {
|
10652
|
compView = asElementData(view, elDef.nodeIndex).componentView;
|
10653
|
}
|
10654
|
else {
|
10655
|
compView = view;
|
10656
|
while (compView.parent && !isComponentView(compView)) {
|
10657
|
compView = compView.parent;
|
10658
|
}
|
10659
|
}
|
10660
|
return compView;
|
10661
|
}
|
10662
|
/**
|
10663
|
* @param {?} view
|
10664
|
* @param {?} providerData
|
10665
|
* @param {?} def
|
10666
|
* @param {?} bindingIdx
|
10667
|
* @param {?} value
|
10668
|
* @param {?} changes
|
10669
|
* @return {?}
|
10670
|
*/
|
10671
|
function updateProp(view, providerData, def, bindingIdx, value, changes) {
|
10672
|
if (def.flags & 32768 /* Component */) {
|
10673
|
const /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((def.parent)).nodeIndex).componentView;
|
10674
|
if (compView.def.flags & 2 /* OnPush */) {
|
10675
|
compView.state |= 8 /* ChecksEnabled */;
|
10676
|
}
|
10677
|
}
|
10678
|
const /** @type {?} */ binding = def.bindings[bindingIdx];
|
10679
|
const /** @type {?} */ propName = ((binding.name));
|
10680
|
// Note: This is still safe with Closure Compiler as
|
10681
|
// the user passed in the property name as an object has to `providerDef`,
|
10682
|
// so Closure Compiler will have renamed the property correctly already.
|
10683
|
providerData.instance[propName] = value;
|
10684
|
if (def.flags & 524288 /* OnChanges */) {
|
10685
|
changes = changes || {};
|
10686
|
let /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
|
10687
|
if (oldValue instanceof WrappedValue) {
|
10688
|
oldValue = oldValue.wrapped;
|
10689
|
}
|
10690
|
const /** @type {?} */ binding = def.bindings[bindingIdx];
|
10691
|
changes[((binding.nonMinifiedName))] =
|
10692
|
new SimpleChange(oldValue, value, (view.state & 2 /* FirstCheck */) !== 0);
|
10693
|
}
|
10694
|
view.oldValues[def.bindingIndex + bindingIdx] = value;
|
10695
|
return changes;
|
10696
|
}
|
10697
|
/**
|
10698
|
* @param {?} view
|
10699
|
* @param {?} lifecycles
|
10700
|
* @return {?}
|
10701
|
*/
|
10702
|
function callLifecycleHooksChildrenFirst(view, lifecycles) {
|
10703
|
if (!(view.def.nodeFlags & lifecycles)) {
|
10704
|
return;
|
10705
|
}
|
10706
|
const /** @type {?} */ nodes = view.def.nodes;
|
10707
|
for (let /** @type {?} */ i = 0; i < nodes.length; i++) {
|
10708
|
const /** @type {?} */ nodeDef = nodes[i];
|
10709
|
let /** @type {?} */ parent = nodeDef.parent;
|
10710
|
if (!parent && nodeDef.flags & lifecycles) {
|
10711
|
// matching root node (e.g. a pipe)
|
10712
|
callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
|
10713
|
}
|
10714
|
if ((nodeDef.childFlags & lifecycles) === 0) {
|
10715
|
// no child matches one of the lifecycles
|
10716
|
i += nodeDef.childCount;
|
10717
|
}
|
10718
|
while (parent && (parent.flags & 1 /* TypeElement */) &&
|
10719
|
i === parent.nodeIndex + parent.childCount) {
|
10720
|
// last child of an element
|
10721
|
if (parent.directChildFlags & lifecycles) {
|
10722
|
callElementProvidersLifecycles(view, parent, lifecycles);
|
10723
|
}
|
10724
|
parent = parent.parent;
|
10725
|
}
|
10726
|
}
|
10727
|
}
|
10728
|
/**
|
10729
|
* @param {?} view
|
10730
|
* @param {?} elDef
|
10731
|
* @param {?} lifecycles
|
10732
|
* @return {?}
|
10733
|
*/
|
10734
|
function callElementProvidersLifecycles(view, elDef, lifecycles) {
|
10735
|
for (let /** @type {?} */ i = elDef.nodeIndex + 1; i <= elDef.nodeIndex + elDef.childCount; i++) {
|
10736
|
const /** @type {?} */ nodeDef = view.def.nodes[i];
|
10737
|
if (nodeDef.flags & lifecycles) {
|
10738
|
callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
|
10739
|
}
|
10740
|
// only visit direct children
|
10741
|
i += nodeDef.childCount;
|
10742
|
}
|
10743
|
}
|
10744
|
/**
|
10745
|
* @param {?} view
|
10746
|
* @param {?} index
|
10747
|
* @param {?} lifecycles
|
10748
|
* @return {?}
|
10749
|
*/
|
10750
|
function callProviderLifecycles(view, index, lifecycles) {
|
10751
|
const /** @type {?} */ providerData = asProviderData(view, index);
|
10752
|
if (!providerData) {
|
10753
|
return;
|
10754
|
}
|
10755
|
const /** @type {?} */ provider = providerData.instance;
|
10756
|
if (!provider) {
|
10757
|
return;
|
10758
|
}
|
10759
|
Services.setCurrentNode(view, index);
|
10760
|
if (lifecycles & 1048576 /* AfterContentInit */) {
|
10761
|
provider.ngAfterContentInit();
|
10762
|
}
|
10763
|
if (lifecycles & 2097152 /* AfterContentChecked */) {
|
10764
|
provider.ngAfterContentChecked();
|
10765
|
}
|
10766
|
if (lifecycles & 4194304 /* AfterViewInit */) {
|
10767
|
provider.ngAfterViewInit();
|
10768
|
}
|
10769
|
if (lifecycles & 8388608 /* AfterViewChecked */) {
|
10770
|
provider.ngAfterViewChecked();
|
10771
|
}
|
10772
|
if (lifecycles & 131072 /* OnDestroy */) {
|
10773
|
provider.ngOnDestroy();
|
10774
|
}
|
10775
|
}
|
10776
|
|
10777
|
/**
|
10778
|
* @license
|
10779
|
* Copyright Google Inc. All Rights Reserved.
|
10780
|
*
|
10781
|
* Use of this source code is governed by an MIT-style license that can be
|
10782
|
* found in the LICENSE file at https://angular.io/license
|
10783
|
*/
|
10784
|
/**
|
10785
|
* @param {?} flags
|
10786
|
* @param {?} id
|
10787
|
* @param {?} bindings
|
10788
|
* @return {?}
|
10789
|
*/
|
10790
|
function queryDef(flags, id, bindings) {
|
10791
|
let /** @type {?} */ bindingDefs = [];
|
10792
|
for (let /** @type {?} */ propName in bindings) {
|
10793
|
const /** @type {?} */ bindingType = bindings[propName];
|
10794
|
bindingDefs.push({ propName, bindingType });
|
10795
|
}
|
10796
|
return {
|
10797
|
// will bet set by the view definition
|
10798
|
nodeIndex: -1,
|
10799
|
parent: null,
|
10800
|
renderParent: null,
|
10801
|
bindingIndex: -1,
|
10802
|
outputIndex: -1,
|
10803
|
// regular values
|
10804
|
// TODO(vicb): check
|
10805
|
checkIndex: -1, flags,
|
10806
|
childFlags: 0,
|
10807
|
directChildFlags: 0,
|
10808
|
childMatchedQueries: 0,
|
10809
|
ngContentIndex: -1,
|
10810
|
matchedQueries: {},
|
10811
|
matchedQueryIds: 0,
|
10812
|
references: {},
|
10813
|
childCount: 0,
|
10814
|
bindings: [],
|
10815
|
bindingFlags: 0,
|
10816
|
outputs: [],
|
10817
|
element: null,
|
10818
|
provider: null,
|
10819
|
text: null,
|
10820
|
query: { id, filterId: filterQueryId(id), bindings: bindingDefs },
|
10821
|
ngContent: null
|
10822
|
};
|
10823
|
}
|
10824
|
/**
|
10825
|
* @return {?}
|
10826
|
*/
|
10827
|
function createQuery() {
|
10828
|
return new QueryList();
|
10829
|
}
|
10830
|
/**
|
10831
|
* @param {?} view
|
10832
|
* @return {?}
|
10833
|
*/
|
10834
|
function dirtyParentQueries(view) {
|
10835
|
const /** @type {?} */ queryIds = view.def.nodeMatchedQueries;
|
10836
|
while (view.parent && isEmbeddedView(view)) {
|
10837
|
let /** @type {?} */ tplDef = ((view.parentNodeDef));
|
10838
|
view = view.parent;
|
10839
|
// content queries
|
10840
|
const /** @type {?} */ end = tplDef.nodeIndex + tplDef.childCount;
|
10841
|
for (let /** @type {?} */ i = 0; i <= end; i++) {
|
10842
|
const /** @type {?} */ nodeDef = view.def.nodes[i];
|
10843
|
if ((nodeDef.flags & 67108864 /* TypeContentQuery */) &&
|
10844
|
(nodeDef.flags & 536870912 /* DynamicQuery */) &&
|
10845
|
(((nodeDef.query)).filterId & queryIds) === ((nodeDef.query)).filterId) {
|
10846
|
asQueryList(view, i).setDirty();
|
10847
|
}
|
10848
|
if ((nodeDef.flags & 1 /* TypeElement */ && i + nodeDef.childCount < tplDef.nodeIndex) ||
|
10849
|
!(nodeDef.childFlags & 67108864 /* TypeContentQuery */) ||
|
10850
|
!(nodeDef.childFlags & 536870912 /* DynamicQuery */)) {
|
10851
|
// skip elements that don't contain the template element or no query.
|
10852
|
i += nodeDef.childCount;
|
10853
|
}
|
10854
|
}
|
10855
|
}
|
10856
|
// view queries
|
10857
|
if (view.def.nodeFlags & 134217728 /* TypeViewQuery */) {
|
10858
|
for (let /** @type {?} */ i = 0; i < view.def.nodes.length; i++) {
|
10859
|
const /** @type {?} */ nodeDef = view.def.nodes[i];
|
10860
|
if ((nodeDef.flags & 134217728 /* TypeViewQuery */) && (nodeDef.flags & 536870912 /* DynamicQuery */)) {
|
10861
|
asQueryList(view, i).setDirty();
|
10862
|
}
|
10863
|
// only visit the root nodes
|
10864
|
i += nodeDef.childCount;
|
10865
|
}
|
10866
|
}
|
10867
|
}
|
10868
|
/**
|
10869
|
* @param {?} view
|
10870
|
* @param {?} nodeDef
|
10871
|
* @return {?}
|
10872
|
*/
|
10873
|
function checkAndUpdateQuery(view, nodeDef) {
|
10874
|
const /** @type {?} */ queryList = asQueryList(view, nodeDef.nodeIndex);
|
10875
|
if (!queryList.dirty) {
|
10876
|
return;
|
10877
|
}
|
10878
|
let /** @type {?} */ directiveInstance;
|
10879
|
let /** @type {?} */ newValues = ((undefined));
|
10880
|
if (nodeDef.flags & 67108864 /* TypeContentQuery */) {
|
10881
|
const /** @type {?} */ elementDef = ((((nodeDef.parent)).parent));
|
10882
|
newValues = calcQueryValues(view, elementDef.nodeIndex, elementDef.nodeIndex + elementDef.childCount, /** @type {?} */ ((nodeDef.query)), []);
|
10883
|
directiveInstance = asProviderData(view, /** @type {?} */ ((nodeDef.parent)).nodeIndex).instance;
|
10884
|
}
|
10885
|
else if (nodeDef.flags & 134217728 /* TypeViewQuery */) {
|
10886
|
newValues = calcQueryValues(view, 0, view.def.nodes.length - 1, /** @type {?} */ ((nodeDef.query)), []);
|
10887
|
directiveInstance = view.component;
|
10888
|
}
|
10889
|
queryList.reset(newValues);
|
10890
|
const /** @type {?} */ bindings = ((nodeDef.query)).bindings;
|
10891
|
let /** @type {?} */ notify = false;
|
10892
|
for (let /** @type {?} */ i = 0; i < bindings.length; i++) {
|
10893
|
const /** @type {?} */ binding = bindings[i];
|
10894
|
let /** @type {?} */ boundValue;
|
10895
|
switch (binding.bindingType) {
|
10896
|
case 0 /* First */:
|
10897
|
boundValue = queryList.first;
|
10898
|
break;
|
10899
|
case 1 /* All */:
|
10900
|
boundValue = queryList;
|
10901
|
notify = true;
|
10902
|
break;
|
10903
|
}
|
10904
|
directiveInstance[binding.propName] = boundValue;
|
10905
|
}
|
10906
|
if (notify) {
|
10907
|
queryList.notifyOnChanges();
|
10908
|
}
|
10909
|
}
|
10910
|
/**
|
10911
|
* @param {?} view
|
10912
|
* @param {?} startIndex
|
10913
|
* @param {?} endIndex
|
10914
|
* @param {?} queryDef
|
10915
|
* @param {?} values
|
10916
|
* @return {?}
|
10917
|
*/
|
10918
|
function calcQueryValues(view, startIndex, endIndex, queryDef, values) {
|
10919
|
for (let /** @type {?} */ i = startIndex; i <= endIndex; i++) {
|
10920
|
const /** @type {?} */ nodeDef = view.def.nodes[i];
|
10921
|
const /** @type {?} */ valueType = nodeDef.matchedQueries[queryDef.id];
|
10922
|
if (valueType != null) {
|
10923
|
values.push(getQueryValue(view, nodeDef, valueType));
|
10924
|
}
|
10925
|
if (nodeDef.flags & 1 /* TypeElement */ && ((nodeDef.element)).template &&
|
10926
|
(((((nodeDef.element)).template)).nodeMatchedQueries & queryDef.filterId) ===
|
10927
|
queryDef.filterId) {
|
10928
|
const /** @type {?} */ elementData = asElementData(view, i);
|
10929
|
// check embedded views that were attached at the place of their template,
|
10930
|
// but process child nodes first if some match the query (see issue #16568)
|
10931
|
if ((nodeDef.childMatchedQueries & queryDef.filterId) === queryDef.filterId) {
|
10932
|
calcQueryValues(view, i + 1, i + nodeDef.childCount, queryDef, values);
|
10933
|
i += nodeDef.childCount;
|
10934
|
}
|
10935
|
if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
|
10936
|
const /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
|
10937
|
for (let /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
|
10938
|
const /** @type {?} */ embeddedView = embeddedViews[k];
|
10939
|
const /** @type {?} */ dvc = declaredViewContainer(embeddedView);
|
10940
|
if (dvc && dvc === elementData) {
|
10941
|
calcQueryValues(embeddedView, 0, embeddedView.def.nodes.length - 1, queryDef, values);
|
10942
|
}
|
10943
|
}
|
10944
|
}
|
10945
|
const /** @type {?} */ projectedViews = elementData.template._projectedViews;
|
10946
|
if (projectedViews) {
|
10947
|
for (let /** @type {?} */ k = 0; k < projectedViews.length; k++) {
|
10948
|
const /** @type {?} */ projectedView = projectedViews[k];
|
10949
|
calcQueryValues(projectedView, 0, projectedView.def.nodes.length - 1, queryDef, values);
|
10950
|
}
|
10951
|
}
|
10952
|
}
|
10953
|
if ((nodeDef.childMatchedQueries & queryDef.filterId) !== queryDef.filterId) {
|
10954
|
// if no child matches the query, skip the children.
|
10955
|
i += nodeDef.childCount;
|
10956
|
}
|
10957
|
}
|
10958
|
return values;
|
10959
|
}
|
10960
|
/**
|
10961
|
* @param {?} view
|
10962
|
* @param {?} nodeDef
|
10963
|
* @param {?} queryValueType
|
10964
|
* @return {?}
|
10965
|
*/
|
10966
|
function getQueryValue(view, nodeDef, queryValueType) {
|
10967
|
if (queryValueType != null) {
|
10968
|
// a match
|
10969
|
switch (queryValueType) {
|
10970
|
case 1 /* RenderElement */:
|
10971
|
return asElementData(view, nodeDef.nodeIndex).renderElement;
|
10972
|
case 0 /* ElementRef */:
|
10973
|
return new ElementRef(asElementData(view, nodeDef.nodeIndex).renderElement);
|
10974
|
case 2 /* TemplateRef */:
|
10975
|
return asElementData(view, nodeDef.nodeIndex).template;
|
10976
|
case 3 /* ViewContainerRef */:
|
10977
|
return asElementData(view, nodeDef.nodeIndex).viewContainer;
|
10978
|
case 4 /* Provider */:
|
10979
|
return asProviderData(view, nodeDef.nodeIndex).instance;
|
10980
|
}
|
10981
|
}
|
10982
|
}
|
10983
|
|
10984
|
/**
|
10985
|
* @license
|
10986
|
* Copyright Google Inc. All Rights Reserved.
|
10987
|
*
|
10988
|
* Use of this source code is governed by an MIT-style license that can be
|
10989
|
* found in the LICENSE file at https://angular.io/license
|
10990
|
*/
|
10991
|
/**
|
10992
|
* @param {?} ngContentIndex
|
10993
|
* @param {?} index
|
10994
|
* @return {?}
|
10995
|
*/
|
10996
|
function ngContentDef(ngContentIndex, index) {
|
10997
|
return {
|
10998
|
// will bet set by the view definition
|
10999
|
nodeIndex: -1,
|
11000
|
parent: null,
|
11001
|
renderParent: null,
|
11002
|
bindingIndex: -1,
|
11003
|
outputIndex: -1,
|
11004
|
// regular values
|
11005
|
checkIndex: -1,
|
11006
|
flags: 8 /* TypeNgContent */,
|
11007
|
childFlags: 0,
|
11008
|
directChildFlags: 0,
|
11009
|
childMatchedQueries: 0,
|
11010
|
matchedQueries: {},
|
11011
|
matchedQueryIds: 0,
|
11012
|
references: {}, ngContentIndex,
|
11013
|
childCount: 0,
|
11014
|
bindings: [],
|
11015
|
bindingFlags: 0,
|
11016
|
outputs: [],
|
11017
|
element: null,
|
11018
|
provider: null,
|
11019
|
text: null,
|
11020
|
query: null,
|
11021
|
ngContent: { index }
|
11022
|
};
|
11023
|
}
|
11024
|
/**
|
11025
|
* @param {?} view
|
11026
|
* @param {?} renderHost
|
11027
|
* @param {?} def
|
11028
|
* @return {?}
|
11029
|
*/
|
11030
|
function appendNgContent(view, renderHost, def) {
|
11031
|
const /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
|
11032
|
if (!parentEl) {
|
11033
|
// Nothing to do if there is no parent element.
|
11034
|
return;
|
11035
|
}
|
11036
|
const /** @type {?} */ ngContentIndex = ((def.ngContent)).index;
|
11037
|
visitProjectedRenderNodes(view, ngContentIndex, 1 /* AppendChild */, parentEl, null, undefined);
|
11038
|
}
|
11039
|
|
11040
|
/**
|
11041
|
* @license
|
11042
|
* Copyright Google Inc. All Rights Reserved.
|
11043
|
*
|
11044
|
* Use of this source code is governed by an MIT-style license that can be
|
11045
|
* found in the LICENSE file at https://angular.io/license
|
11046
|
*/
|
11047
|
/**
|
11048
|
* @param {?} checkIndex
|
11049
|
* @param {?} argCount
|
11050
|
* @return {?}
|
11051
|
*/
|
11052
|
function purePipeDef(checkIndex, argCount) {
|
11053
|
// argCount + 1 to include the pipe as first arg
|
11054
|
return _pureExpressionDef(128 /* TypePurePipe */, checkIndex, new Array(argCount + 1));
|
11055
|
}
|
11056
|
/**
|
11057
|
* @param {?} checkIndex
|
11058
|
* @param {?} argCount
|
11059
|
* @return {?}
|
11060
|
*/
|
11061
|
function pureArrayDef(checkIndex, argCount) {
|
11062
|
return _pureExpressionDef(32 /* TypePureArray */, checkIndex, new Array(argCount));
|
11063
|
}
|
11064
|
/**
|
11065
|
* @param {?} checkIndex
|
11066
|
* @param {?} propToIndex
|
11067
|
* @return {?}
|
11068
|
*/
|
11069
|
function pureObjectDef(checkIndex, propToIndex) {
|
11070
|
const /** @type {?} */ keys = Object.keys(propToIndex);
|
11071
|
const /** @type {?} */ nbKeys = keys.length;
|
11072
|
const /** @type {?} */ propertyNames = new Array(nbKeys);
|
11073
|
for (let /** @type {?} */ i = 0; i < nbKeys; i++) {
|
11074
|
const /** @type {?} */ key = keys[i];
|
11075
|
const /** @type {?} */ index = propToIndex[key];
|
11076
|
propertyNames[index] = key;
|
11077
|
}
|
11078
|
return _pureExpressionDef(64 /* TypePureObject */, checkIndex, propertyNames);
|
11079
|
}
|
11080
|
/**
|
11081
|
* @param {?} flags
|
11082
|
* @param {?} checkIndex
|
11083
|
* @param {?} propertyNames
|
11084
|
* @return {?}
|
11085
|
*/
|
11086
|
function _pureExpressionDef(flags, checkIndex, propertyNames) {
|
11087
|
const /** @type {?} */ bindings = new Array(propertyNames.length);
|
11088
|
for (let /** @type {?} */ i = 0; i < propertyNames.length; i++) {
|
11089
|
const /** @type {?} */ prop = propertyNames[i];
|
11090
|
bindings[i] = {
|
11091
|
flags: 8 /* TypeProperty */,
|
11092
|
name: prop,
|
11093
|
ns: null,
|
11094
|
nonMinifiedName: prop,
|
11095
|
securityContext: null,
|
11096
|
suffix: null
|
11097
|
};
|
11098
|
}
|
11099
|
return {
|
11100
|
// will bet set by the view definition
|
11101
|
nodeIndex: -1,
|
11102
|
parent: null,
|
11103
|
renderParent: null,
|
11104
|
bindingIndex: -1,
|
11105
|
outputIndex: -1,
|
11106
|
// regular values
|
11107
|
checkIndex,
|
11108
|
flags,
|
11109
|
childFlags: 0,
|
11110
|
directChildFlags: 0,
|
11111
|
childMatchedQueries: 0,
|
11112
|
matchedQueries: {},
|
11113
|
matchedQueryIds: 0,
|
11114
|
references: {},
|
11115
|
ngContentIndex: -1,
|
11116
|
childCount: 0, bindings,
|
11117
|
bindingFlags: calcBindingFlags(bindings),
|
11118
|
outputs: [],
|
11119
|
element: null,
|
11120
|
provider: null,
|
11121
|
text: null,
|
11122
|
query: null,
|
11123
|
ngContent: null
|
11124
|
};
|
11125
|
}
|
11126
|
/**
|
11127
|
* @param {?} view
|
11128
|
* @param {?} def
|
11129
|
* @return {?}
|
11130
|
*/
|
11131
|
function createPureExpression(view, def) {
|
11132
|
return { value: undefined };
|
11133
|
}
|
11134
|
/**
|
11135
|
* @param {?} view
|
11136
|
* @param {?} def
|
11137
|
* @param {?} v0
|
11138
|
* @param {?} v1
|
11139
|
* @param {?} v2
|
11140
|
* @param {?} v3
|
11141
|
* @param {?} v4
|
11142
|
* @param {?} v5
|
11143
|
* @param {?} v6
|
11144
|
* @param {?} v7
|
11145
|
* @param {?} v8
|
11146
|
* @param {?} v9
|
11147
|
* @return {?}
|
11148
|
*/
|
11149
|
function checkAndUpdatePureExpressionInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11150
|
const /** @type {?} */ bindings = def.bindings;
|
11151
|
let /** @type {?} */ changed = false;
|
11152
|
const /** @type {?} */ bindLen = bindings.length;
|
11153
|
if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
|
11154
|
changed = true;
|
11155
|
if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
|
11156
|
changed = true;
|
11157
|
if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
|
11158
|
changed = true;
|
11159
|
if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
|
11160
|
changed = true;
|
11161
|
if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
|
11162
|
changed = true;
|
11163
|
if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
|
11164
|
changed = true;
|
11165
|
if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
|
11166
|
changed = true;
|
11167
|
if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
|
11168
|
changed = true;
|
11169
|
if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
|
11170
|
changed = true;
|
11171
|
if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
|
11172
|
changed = true;
|
11173
|
if (changed) {
|
11174
|
const /** @type {?} */ data = asPureExpressionData(view, def.nodeIndex);
|
11175
|
let /** @type {?} */ value;
|
11176
|
switch (def.flags & 201347067 /* Types */) {
|
11177
|
case 32 /* TypePureArray */:
|
11178
|
value = new Array(bindings.length);
|
11179
|
if (bindLen > 0)
|
11180
|
value[0] = v0;
|
11181
|
if (bindLen > 1)
|
11182
|
value[1] = v1;
|
11183
|
if (bindLen > 2)
|
11184
|
value[2] = v2;
|
11185
|
if (bindLen > 3)
|
11186
|
value[3] = v3;
|
11187
|
if (bindLen > 4)
|
11188
|
value[4] = v4;
|
11189
|
if (bindLen > 5)
|
11190
|
value[5] = v5;
|
11191
|
if (bindLen > 6)
|
11192
|
value[6] = v6;
|
11193
|
if (bindLen > 7)
|
11194
|
value[7] = v7;
|
11195
|
if (bindLen > 8)
|
11196
|
value[8] = v8;
|
11197
|
if (bindLen > 9)
|
11198
|
value[9] = v9;
|
11199
|
break;
|
11200
|
case 64 /* TypePureObject */:
|
11201
|
value = {};
|
11202
|
if (bindLen > 0)
|
11203
|
value[((bindings[0].name))] = v0;
|
11204
|
if (bindLen > 1)
|
11205
|
value[((bindings[1].name))] = v1;
|
11206
|
if (bindLen > 2)
|
11207
|
value[((bindings[2].name))] = v2;
|
11208
|
if (bindLen > 3)
|
11209
|
value[((bindings[3].name))] = v3;
|
11210
|
if (bindLen > 4)
|
11211
|
value[((bindings[4].name))] = v4;
|
11212
|
if (bindLen > 5)
|
11213
|
value[((bindings[5].name))] = v5;
|
11214
|
if (bindLen > 6)
|
11215
|
value[((bindings[6].name))] = v6;
|
11216
|
if (bindLen > 7)
|
11217
|
value[((bindings[7].name))] = v7;
|
11218
|
if (bindLen > 8)
|
11219
|
value[((bindings[8].name))] = v8;
|
11220
|
if (bindLen > 9)
|
11221
|
value[((bindings[9].name))] = v9;
|
11222
|
break;
|
11223
|
case 128 /* TypePurePipe */:
|
11224
|
const /** @type {?} */ pipe = v0;
|
11225
|
switch (bindLen) {
|
11226
|
case 1:
|
11227
|
value = pipe.transform(v0);
|
11228
|
break;
|
11229
|
case 2:
|
11230
|
value = pipe.transform(v1);
|
11231
|
break;
|
11232
|
case 3:
|
11233
|
value = pipe.transform(v1, v2);
|
11234
|
break;
|
11235
|
case 4:
|
11236
|
value = pipe.transform(v1, v2, v3);
|
11237
|
break;
|
11238
|
case 5:
|
11239
|
value = pipe.transform(v1, v2, v3, v4);
|
11240
|
break;
|
11241
|
case 6:
|
11242
|
value = pipe.transform(v1, v2, v3, v4, v5);
|
11243
|
break;
|
11244
|
case 7:
|
11245
|
value = pipe.transform(v1, v2, v3, v4, v5, v6);
|
11246
|
break;
|
11247
|
case 8:
|
11248
|
value = pipe.transform(v1, v2, v3, v4, v5, v6, v7);
|
11249
|
break;
|
11250
|
case 9:
|
11251
|
value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8);
|
11252
|
break;
|
11253
|
case 10:
|
11254
|
value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11255
|
break;
|
11256
|
}
|
11257
|
break;
|
11258
|
}
|
11259
|
data.value = value;
|
11260
|
}
|
11261
|
return changed;
|
11262
|
}
|
11263
|
/**
|
11264
|
* @param {?} view
|
11265
|
* @param {?} def
|
11266
|
* @param {?} values
|
11267
|
* @return {?}
|
11268
|
*/
|
11269
|
function checkAndUpdatePureExpressionDynamic(view, def, values) {
|
11270
|
const /** @type {?} */ bindings = def.bindings;
|
11271
|
let /** @type {?} */ changed = false;
|
11272
|
for (let /** @type {?} */ i = 0; i < values.length; i++) {
|
11273
|
// Note: We need to loop over all values, so that
|
11274
|
// the old values are updates as well!
|
11275
|
if (checkAndUpdateBinding(view, def, i, values[i])) {
|
11276
|
changed = true;
|
11277
|
}
|
11278
|
}
|
11279
|
if (changed) {
|
11280
|
const /** @type {?} */ data = asPureExpressionData(view, def.nodeIndex);
|
11281
|
let /** @type {?} */ value;
|
11282
|
switch (def.flags & 201347067 /* Types */) {
|
11283
|
case 32 /* TypePureArray */:
|
11284
|
value = values;
|
11285
|
break;
|
11286
|
case 64 /* TypePureObject */:
|
11287
|
value = {};
|
11288
|
for (let /** @type {?} */ i = 0; i < values.length; i++) {
|
11289
|
value[((bindings[i].name))] = values[i];
|
11290
|
}
|
11291
|
break;
|
11292
|
case 128 /* TypePurePipe */:
|
11293
|
const /** @type {?} */ pipe = values[0];
|
11294
|
const /** @type {?} */ params = values.slice(1);
|
11295
|
value = ((pipe.transform))(...params);
|
11296
|
break;
|
11297
|
}
|
11298
|
data.value = value;
|
11299
|
}
|
11300
|
return changed;
|
11301
|
}
|
11302
|
|
11303
|
/**
|
11304
|
* @license
|
11305
|
* Copyright Google Inc. All Rights Reserved.
|
11306
|
*
|
11307
|
* Use of this source code is governed by an MIT-style license that can be
|
11308
|
* found in the LICENSE file at https://angular.io/license
|
11309
|
*/
|
11310
|
/**
|
11311
|
* @param {?} checkIndex
|
11312
|
* @param {?} ngContentIndex
|
11313
|
* @param {?} staticText
|
11314
|
* @return {?}
|
11315
|
*/
|
11316
|
function textDef(checkIndex, ngContentIndex, staticText) {
|
11317
|
const /** @type {?} */ bindings = new Array(staticText.length - 1);
|
11318
|
for (let /** @type {?} */ i = 1; i < staticText.length; i++) {
|
11319
|
bindings[i - 1] = {
|
11320
|
flags: 8 /* TypeProperty */,
|
11321
|
name: null,
|
11322
|
ns: null,
|
11323
|
nonMinifiedName: null,
|
11324
|
securityContext: null,
|
11325
|
suffix: staticText[i],
|
11326
|
};
|
11327
|
}
|
11328
|
return {
|
11329
|
// will bet set by the view definition
|
11330
|
nodeIndex: -1,
|
11331
|
parent: null,
|
11332
|
renderParent: null,
|
11333
|
bindingIndex: -1,
|
11334
|
outputIndex: -1,
|
11335
|
// regular values
|
11336
|
checkIndex,
|
11337
|
flags: 2 /* TypeText */,
|
11338
|
childFlags: 0,
|
11339
|
directChildFlags: 0,
|
11340
|
childMatchedQueries: 0,
|
11341
|
matchedQueries: {},
|
11342
|
matchedQueryIds: 0,
|
11343
|
references: {}, ngContentIndex,
|
11344
|
childCount: 0, bindings,
|
11345
|
bindingFlags: 8 /* TypeProperty */,
|
11346
|
outputs: [],
|
11347
|
element: null,
|
11348
|
provider: null,
|
11349
|
text: { prefix: staticText[0] },
|
11350
|
query: null,
|
11351
|
ngContent: null,
|
11352
|
};
|
11353
|
}
|
11354
|
/**
|
11355
|
* @param {?} view
|
11356
|
* @param {?} renderHost
|
11357
|
* @param {?} def
|
11358
|
* @return {?}
|
11359
|
*/
|
11360
|
function createText(view, renderHost, def) {
|
11361
|
let /** @type {?} */ renderNode$$1;
|
11362
|
const /** @type {?} */ renderer = view.renderer;
|
11363
|
renderNode$$1 = renderer.createText(/** @type {?} */ ((def.text)).prefix);
|
11364
|
const /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
|
11365
|
if (parentEl) {
|
11366
|
renderer.appendChild(parentEl, renderNode$$1);
|
11367
|
}
|
11368
|
return { renderText: renderNode$$1 };
|
11369
|
}
|
11370
|
/**
|
11371
|
* @param {?} view
|
11372
|
* @param {?} def
|
11373
|
* @param {?} v0
|
11374
|
* @param {?} v1
|
11375
|
* @param {?} v2
|
11376
|
* @param {?} v3
|
11377
|
* @param {?} v4
|
11378
|
* @param {?} v5
|
11379
|
* @param {?} v6
|
11380
|
* @param {?} v7
|
11381
|
* @param {?} v8
|
11382
|
* @param {?} v9
|
11383
|
* @return {?}
|
11384
|
*/
|
11385
|
function checkAndUpdateTextInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11386
|
let /** @type {?} */ changed = false;
|
11387
|
const /** @type {?} */ bindings = def.bindings;
|
11388
|
const /** @type {?} */ bindLen = bindings.length;
|
11389
|
if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
|
11390
|
changed = true;
|
11391
|
if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
|
11392
|
changed = true;
|
11393
|
if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
|
11394
|
changed = true;
|
11395
|
if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
|
11396
|
changed = true;
|
11397
|
if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
|
11398
|
changed = true;
|
11399
|
if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
|
11400
|
changed = true;
|
11401
|
if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
|
11402
|
changed = true;
|
11403
|
if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
|
11404
|
changed = true;
|
11405
|
if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
|
11406
|
changed = true;
|
11407
|
if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
|
11408
|
changed = true;
|
11409
|
if (changed) {
|
11410
|
let /** @type {?} */ value = ((def.text)).prefix;
|
11411
|
if (bindLen > 0)
|
11412
|
value += _addInterpolationPart(v0, bindings[0]);
|
11413
|
if (bindLen > 1)
|
11414
|
value += _addInterpolationPart(v1, bindings[1]);
|
11415
|
if (bindLen > 2)
|
11416
|
value += _addInterpolationPart(v2, bindings[2]);
|
11417
|
if (bindLen > 3)
|
11418
|
value += _addInterpolationPart(v3, bindings[3]);
|
11419
|
if (bindLen > 4)
|
11420
|
value += _addInterpolationPart(v4, bindings[4]);
|
11421
|
if (bindLen > 5)
|
11422
|
value += _addInterpolationPart(v5, bindings[5]);
|
11423
|
if (bindLen > 6)
|
11424
|
value += _addInterpolationPart(v6, bindings[6]);
|
11425
|
if (bindLen > 7)
|
11426
|
value += _addInterpolationPart(v7, bindings[7]);
|
11427
|
if (bindLen > 8)
|
11428
|
value += _addInterpolationPart(v8, bindings[8]);
|
11429
|
if (bindLen > 9)
|
11430
|
value += _addInterpolationPart(v9, bindings[9]);
|
11431
|
const /** @type {?} */ renderNode$$1 = asTextData(view, def.nodeIndex).renderText;
|
11432
|
view.renderer.setValue(renderNode$$1, value);
|
11433
|
}
|
11434
|
return changed;
|
11435
|
}
|
11436
|
/**
|
11437
|
* @param {?} view
|
11438
|
* @param {?} def
|
11439
|
* @param {?} values
|
11440
|
* @return {?}
|
11441
|
*/
|
11442
|
function checkAndUpdateTextDynamic(view, def, values) {
|
11443
|
const /** @type {?} */ bindings = def.bindings;
|
11444
|
let /** @type {?} */ changed = false;
|
11445
|
for (let /** @type {?} */ i = 0; i < values.length; i++) {
|
11446
|
// Note: We need to loop over all values, so that
|
11447
|
// the old values are updates as well!
|
11448
|
if (checkAndUpdateBinding(view, def, i, values[i])) {
|
11449
|
changed = true;
|
11450
|
}
|
11451
|
}
|
11452
|
if (changed) {
|
11453
|
let /** @type {?} */ value = '';
|
11454
|
for (let /** @type {?} */ i = 0; i < values.length; i++) {
|
11455
|
value = value + _addInterpolationPart(values[i], bindings[i]);
|
11456
|
}
|
11457
|
value = ((def.text)).prefix + value;
|
11458
|
const /** @type {?} */ renderNode$$1 = asTextData(view, def.nodeIndex).renderText;
|
11459
|
view.renderer.setValue(renderNode$$1, value);
|
11460
|
}
|
11461
|
return changed;
|
11462
|
}
|
11463
|
/**
|
11464
|
* @param {?} value
|
11465
|
* @param {?} binding
|
11466
|
* @return {?}
|
11467
|
*/
|
11468
|
function _addInterpolationPart(value, binding) {
|
11469
|
const /** @type {?} */ valueStr = value != null ? value.toString() : '';
|
11470
|
return valueStr + binding.suffix;
|
11471
|
}
|
11472
|
|
11473
|
/**
|
11474
|
* @license
|
11475
|
* Copyright Google Inc. All Rights Reserved.
|
11476
|
*
|
11477
|
* Use of this source code is governed by an MIT-style license that can be
|
11478
|
* found in the LICENSE file at https://angular.io/license
|
11479
|
*/
|
11480
|
/**
|
11481
|
* @param {?} flags
|
11482
|
* @param {?} nodes
|
11483
|
* @param {?=} updateDirectives
|
11484
|
* @param {?=} updateRenderer
|
11485
|
* @return {?}
|
11486
|
*/
|
11487
|
function viewDef(flags, nodes, updateDirectives, updateRenderer) {
|
11488
|
// clone nodes and set auto calculated values
|
11489
|
let /** @type {?} */ viewBindingCount = 0;
|
11490
|
let /** @type {?} */ viewDisposableCount = 0;
|
11491
|
let /** @type {?} */ viewNodeFlags = 0;
|
11492
|
let /** @type {?} */ viewRootNodeFlags = 0;
|
11493
|
let /** @type {?} */ viewMatchedQueries = 0;
|
11494
|
let /** @type {?} */ currentParent = null;
|
11495
|
let /** @type {?} */ currentRenderParent = null;
|
11496
|
let /** @type {?} */ currentElementHasPublicProviders = false;
|
11497
|
let /** @type {?} */ currentElementHasPrivateProviders = false;
|
11498
|
let /** @type {?} */ lastRenderRootNode = null;
|
11499
|
for (let /** @type {?} */ i = 0; i < nodes.length; i++) {
|
11500
|
const /** @type {?} */ node = nodes[i];
|
11501
|
node.nodeIndex = i;
|
11502
|
node.parent = currentParent;
|
11503
|
node.bindingIndex = viewBindingCount;
|
11504
|
node.outputIndex = viewDisposableCount;
|
11505
|
node.renderParent = currentRenderParent;
|
11506
|
viewNodeFlags |= node.flags;
|
11507
|
viewMatchedQueries |= node.matchedQueryIds;
|
11508
|
if (node.element) {
|
11509
|
const /** @type {?} */ elDef = node.element;
|
11510
|
elDef.publicProviders =
|
11511
|
currentParent ? ((currentParent.element)).publicProviders : Object.create(null);
|
11512
|
elDef.allProviders = elDef.publicProviders;
|
11513
|
// Note: We assume that all providers of an element are before any child element!
|
11514
|
currentElementHasPublicProviders = false;
|
11515
|
currentElementHasPrivateProviders = false;
|
11516
|
if (node.element.template) {
|
11517
|
viewMatchedQueries |= node.element.template.nodeMatchedQueries;
|
11518
|
}
|
11519
|
}
|
11520
|
validateNode(currentParent, node, nodes.length);
|
11521
|
viewBindingCount += node.bindings.length;
|
11522
|
viewDisposableCount += node.outputs.length;
|
11523
|
if (!currentRenderParent && (node.flags & 3 /* CatRenderNode */)) {
|
11524
|
lastRenderRootNode = node;
|
11525
|
}
|
11526
|
if (node.flags & 20224 /* CatProvider */) {
|
11527
|
if (!currentElementHasPublicProviders) {
|
11528
|
currentElementHasPublicProviders = true; /** @type {?} */
|
11529
|
((((
|
11530
|
// Use prototypical inheritance to not get O(n^2) complexity...
|
11531
|
currentParent)).element)).publicProviders =
|
11532
|
Object.create(/** @type {?} */ ((((currentParent)).element)).publicProviders); /** @type {?} */
|
11533
|
((((currentParent)).element)).allProviders = ((((currentParent)).element)).publicProviders;
|
11534
|
}
|
11535
|
const /** @type {?} */ isPrivateService = (node.flags & 8192 /* PrivateProvider */) !== 0;
|
11536
|
const /** @type {?} */ isComponent = (node.flags & 32768 /* Component */) !== 0;
|
11537
|
if (!isPrivateService || isComponent) {
|
11538
|
((((((currentParent)).element)).publicProviders))[tokenKey(/** @type {?} */ ((node.provider)).token)] = node;
|
11539
|
}
|
11540
|
else {
|
11541
|
if (!currentElementHasPrivateProviders) {
|
11542
|
currentElementHasPrivateProviders = true; /** @type {?} */
|
11543
|
((((
|
11544
|
// Use prototypical inheritance to not get O(n^2) complexity...
|
11545
|
currentParent)).element)).allProviders =
|
11546
|
Object.create(/** @type {?} */ ((((currentParent)).element)).publicProviders);
|
11547
|
} /** @type {?} */
|
11548
|
((((((currentParent)).element)).allProviders))[tokenKey(/** @type {?} */ ((node.provider)).token)] = node;
|
11549
|
}
|
11550
|
if (isComponent) {
|
11551
|
((((currentParent)).element)).componentProvider = node;
|
11552
|
}
|
11553
|
}
|
11554
|
if (currentParent) {
|
11555
|
currentParent.childFlags |= node.flags;
|
11556
|
currentParent.directChildFlags |= node.flags;
|
11557
|
currentParent.childMatchedQueries |= node.matchedQueryIds;
|
11558
|
if (node.element && node.element.template) {
|
11559
|
currentParent.childMatchedQueries |= node.element.template.nodeMatchedQueries;
|
11560
|
}
|
11561
|
}
|
11562
|
else {
|
11563
|
viewRootNodeFlags |= node.flags;
|
11564
|
}
|
11565
|
if (node.childCount > 0) {
|
11566
|
currentParent = node;
|
11567
|
if (!isNgContainer(node)) {
|
11568
|
currentRenderParent = node;
|
11569
|
}
|
11570
|
}
|
11571
|
else {
|
11572
|
// When the current node has no children, check if it is the last children of its parent.
|
11573
|
// When it is, propagate the flags up.
|
11574
|
// The loop is required because an element could be the last transitive children of several
|
11575
|
// elements. We loop to either the root or the highest opened element (= with remaining
|
11576
|
// children)
|
11577
|
while (currentParent && i === currentParent.nodeIndex + currentParent.childCount) {
|
11578
|
const /** @type {?} */ newParent = currentParent.parent;
|
11579
|
if (newParent) {
|
11580
|
newParent.childFlags |= currentParent.childFlags;
|
11581
|
newParent.childMatchedQueries |= currentParent.childMatchedQueries;
|
11582
|
}
|
11583
|
currentParent = newParent;
|
11584
|
// We also need to update the render parent & account for ng-container
|
11585
|
if (currentParent && isNgContainer(currentParent)) {
|
11586
|
currentRenderParent = currentParent.renderParent;
|
11587
|
}
|
11588
|
else {
|
11589
|
currentRenderParent = currentParent;
|
11590
|
}
|
11591
|
}
|
11592
|
}
|
11593
|
}
|
11594
|
const /** @type {?} */ handleEvent = (view, nodeIndex, eventName, event) => ((((nodes[nodeIndex].element)).handleEvent))(view, eventName, event);
|
11595
|
return {
|
11596
|
// Will be filled later...
|
11597
|
factory: null,
|
11598
|
nodeFlags: viewNodeFlags,
|
11599
|
rootNodeFlags: viewRootNodeFlags,
|
11600
|
nodeMatchedQueries: viewMatchedQueries, flags,
|
11601
|
nodes: nodes,
|
11602
|
updateDirectives: updateDirectives || NOOP,
|
11603
|
updateRenderer: updateRenderer || NOOP, handleEvent,
|
11604
|
bindingCount: viewBindingCount,
|
11605
|
outputCount: viewDisposableCount, lastRenderRootNode
|
11606
|
};
|
11607
|
}
|
11608
|
/**
|
11609
|
* @param {?} node
|
11610
|
* @return {?}
|
11611
|
*/
|
11612
|
function isNgContainer(node) {
|
11613
|
return (node.flags & 1 /* TypeElement */) !== 0 && ((node.element)).name === null;
|
11614
|
}
|
11615
|
/**
|
11616
|
* @param {?} parent
|
11617
|
* @param {?} node
|
11618
|
* @param {?} nodeCount
|
11619
|
* @return {?}
|
11620
|
*/
|
11621
|
function validateNode(parent, node, nodeCount) {
|
11622
|
const /** @type {?} */ template = node.element && node.element.template;
|
11623
|
if (template) {
|
11624
|
if (!template.lastRenderRootNode) {
|
11625
|
throw new Error(`Illegal State: Embedded templates without nodes are not allowed!`);
|
11626
|
}
|
11627
|
if (template.lastRenderRootNode &&
|
11628
|
template.lastRenderRootNode.flags & 16777216 /* EmbeddedViews */) {
|
11629
|
throw new Error(`Illegal State: Last root node of a template can't have embedded views, at index ${node.nodeIndex}!`);
|
11630
|
}
|
11631
|
}
|
11632
|
if (node.flags & 20224 /* CatProvider */) {
|
11633
|
const /** @type {?} */ parentFlags = parent ? parent.flags : 0;
|
11634
|
if ((parentFlags & 1 /* TypeElement */) === 0) {
|
11635
|
throw new Error(`Illegal State: StaticProvider/Directive nodes need to be children of elements or anchors, at index ${node.nodeIndex}!`);
|
11636
|
}
|
11637
|
}
|
11638
|
if (node.query) {
|
11639
|
if (node.flags & 67108864 /* TypeContentQuery */ &&
|
11640
|
(!parent || (parent.flags & 16384 /* TypeDirective */) === 0)) {
|
11641
|
throw new Error(`Illegal State: Content Query nodes need to be children of directives, at index ${node.nodeIndex}!`);
|
11642
|
}
|
11643
|
if (node.flags & 134217728 /* TypeViewQuery */ && parent) {
|
11644
|
throw new Error(`Illegal State: View Query nodes have to be top level nodes, at index ${node.nodeIndex}!`);
|
11645
|
}
|
11646
|
}
|
11647
|
if (node.childCount) {
|
11648
|
const /** @type {?} */ parentEnd = parent ? parent.nodeIndex + parent.childCount : nodeCount - 1;
|
11649
|
if (node.nodeIndex <= parentEnd && node.nodeIndex + node.childCount > parentEnd) {
|
11650
|
throw new Error(`Illegal State: childCount of node leads outside of parent, at index ${node.nodeIndex}!`);
|
11651
|
}
|
11652
|
}
|
11653
|
}
|
11654
|
/**
|
11655
|
* @param {?} parent
|
11656
|
* @param {?} anchorDef
|
11657
|
* @param {?} viewDef
|
11658
|
* @param {?=} context
|
11659
|
* @return {?}
|
11660
|
*/
|
11661
|
function createEmbeddedView(parent, anchorDef$$1, viewDef, context) {
|
11662
|
// embedded views are seen as siblings to the anchor, so we need
|
11663
|
// to get the parent of the anchor and use it as parentIndex.
|
11664
|
const /** @type {?} */ view = createView(parent.root, parent.renderer, parent, anchorDef$$1, viewDef);
|
11665
|
initView(view, parent.component, context);
|
11666
|
createViewNodes(view);
|
11667
|
return view;
|
11668
|
}
|
11669
|
/**
|
11670
|
* @param {?} root
|
11671
|
* @param {?} def
|
11672
|
* @param {?=} context
|
11673
|
* @return {?}
|
11674
|
*/
|
11675
|
function createRootView(root, def, context) {
|
11676
|
const /** @type {?} */ view = createView(root, root.renderer, null, null, def);
|
11677
|
initView(view, context, context);
|
11678
|
createViewNodes(view);
|
11679
|
return view;
|
11680
|
}
|
11681
|
/**
|
11682
|
* @param {?} parentView
|
11683
|
* @param {?} nodeDef
|
11684
|
* @param {?} viewDef
|
11685
|
* @param {?} hostElement
|
11686
|
* @return {?}
|
11687
|
*/
|
11688
|
function createComponentView(parentView, nodeDef, viewDef, hostElement) {
|
11689
|
const /** @type {?} */ rendererType = ((nodeDef.element)).componentRendererType;
|
11690
|
let /** @type {?} */ compRenderer;
|
11691
|
if (!rendererType) {
|
11692
|
compRenderer = parentView.root.renderer;
|
11693
|
}
|
11694
|
else {
|
11695
|
compRenderer = parentView.root.rendererFactory.createRenderer(hostElement, rendererType);
|
11696
|
}
|
11697
|
return createView(parentView.root, compRenderer, parentView, /** @type {?} */ ((nodeDef.element)).componentProvider, viewDef);
|
11698
|
}
|
11699
|
/**
|
11700
|
* @param {?} root
|
11701
|
* @param {?} renderer
|
11702
|
* @param {?} parent
|
11703
|
* @param {?} parentNodeDef
|
11704
|
* @param {?} def
|
11705
|
* @return {?}
|
11706
|
*/
|
11707
|
function createView(root, renderer, parent, parentNodeDef, def) {
|
11708
|
const /** @type {?} */ nodes = new Array(def.nodes.length);
|
11709
|
const /** @type {?} */ disposables = def.outputCount ? new Array(def.outputCount) : null;
|
11710
|
const /** @type {?} */ view = {
|
11711
|
def,
|
11712
|
parent,
|
11713
|
viewContainerParent: null, parentNodeDef,
|
11714
|
context: null,
|
11715
|
component: null, nodes,
|
11716
|
state: 13 /* CatInit */, root, renderer,
|
11717
|
oldValues: new Array(def.bindingCount), disposables
|
11718
|
};
|
11719
|
return view;
|
11720
|
}
|
11721
|
/**
|
11722
|
* @param {?} view
|
11723
|
* @param {?} component
|
11724
|
* @param {?} context
|
11725
|
* @return {?}
|
11726
|
*/
|
11727
|
function initView(view, component, context) {
|
11728
|
view.component = component;
|
11729
|
view.context = context;
|
11730
|
}
|
11731
|
/**
|
11732
|
* @param {?} view
|
11733
|
* @return {?}
|
11734
|
*/
|
11735
|
function createViewNodes(view) {
|
11736
|
let /** @type {?} */ renderHost;
|
11737
|
if (isComponentView(view)) {
|
11738
|
const /** @type {?} */ hostDef = view.parentNodeDef;
|
11739
|
renderHost = asElementData(/** @type {?} */ ((view.parent)), /** @type {?} */ ((((hostDef)).parent)).nodeIndex).renderElement;
|
11740
|
}
|
11741
|
const /** @type {?} */ def = view.def;
|
11742
|
const /** @type {?} */ nodes = view.nodes;
|
11743
|
for (let /** @type {?} */ i = 0; i < def.nodes.length; i++) {
|
11744
|
const /** @type {?} */ nodeDef = def.nodes[i];
|
11745
|
Services.setCurrentNode(view, i);
|
11746
|
let /** @type {?} */ nodeData;
|
11747
|
switch (nodeDef.flags & 201347067 /* Types */) {
|
11748
|
case 1 /* TypeElement */:
|
11749
|
const /** @type {?} */ el = (createElement(view, renderHost, nodeDef));
|
11750
|
let /** @type {?} */ componentView = ((undefined));
|
11751
|
if (nodeDef.flags & 33554432 /* ComponentView */) {
|
11752
|
const /** @type {?} */ compViewDef = resolveDefinition(/** @type {?} */ ((((nodeDef.element)).componentView)));
|
11753
|
componentView = Services.createComponentView(view, nodeDef, compViewDef, el);
|
11754
|
}
|
11755
|
listenToElementOutputs(view, componentView, nodeDef, el);
|
11756
|
nodeData = ({
|
11757
|
renderElement: el,
|
11758
|
componentView,
|
11759
|
viewContainer: null,
|
11760
|
template: /** @type {?} */ ((nodeDef.element)).template ? createTemplateData(view, nodeDef) : undefined
|
11761
|
});
|
11762
|
if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
|
11763
|
nodeData.viewContainer = createViewContainerData(view, nodeDef, nodeData);
|
11764
|
}
|
11765
|
break;
|
11766
|
case 2 /* TypeText */:
|
11767
|
nodeData = (createText(view, renderHost, nodeDef));
|
11768
|
break;
|
11769
|
case 512 /* TypeClassProvider */:
|
11770
|
case 1024 /* TypeFactoryProvider */:
|
11771
|
case 2048 /* TypeUseExistingProvider */:
|
11772
|
case 256 /* TypeValueProvider */: {
|
11773
|
nodeData = nodes[i];
|
11774
|
if (!nodeData && !(nodeDef.flags & 4096 /* LazyProvider */)) {
|
11775
|
const /** @type {?} */ instance = createProviderInstance(view, nodeDef);
|
11776
|
nodeData = ({ instance });
|
11777
|
}
|
11778
|
break;
|
11779
|
}
|
11780
|
case 16 /* TypePipe */: {
|
11781
|
const /** @type {?} */ instance = createPipeInstance(view, nodeDef);
|
11782
|
nodeData = ({ instance });
|
11783
|
break;
|
11784
|
}
|
11785
|
case 16384 /* TypeDirective */: {
|
11786
|
nodeData = nodes[i];
|
11787
|
if (!nodeData) {
|
11788
|
const /** @type {?} */ instance = createDirectiveInstance(view, nodeDef);
|
11789
|
nodeData = ({ instance });
|
11790
|
}
|
11791
|
if (nodeDef.flags & 32768 /* Component */) {
|
11792
|
const /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((nodeDef.parent)).nodeIndex).componentView;
|
11793
|
initView(compView, nodeData.instance, nodeData.instance);
|
11794
|
}
|
11795
|
break;
|
11796
|
}
|
11797
|
case 32 /* TypePureArray */:
|
11798
|
case 64 /* TypePureObject */:
|
11799
|
case 128 /* TypePurePipe */:
|
11800
|
nodeData = (createPureExpression(view, nodeDef));
|
11801
|
break;
|
11802
|
case 67108864 /* TypeContentQuery */:
|
11803
|
case 134217728 /* TypeViewQuery */:
|
11804
|
nodeData = (createQuery());
|
11805
|
break;
|
11806
|
case 8 /* TypeNgContent */:
|
11807
|
appendNgContent(view, renderHost, nodeDef);
|
11808
|
// no runtime data needed for NgContent...
|
11809
|
nodeData = undefined;
|
11810
|
break;
|
11811
|
}
|
11812
|
nodes[i] = nodeData;
|
11813
|
}
|
11814
|
// Create the ViewData.nodes of component views after we created everything else,
|
11815
|
// so that e.g. ng-content works
|
11816
|
execComponentViewsAction(view, ViewAction.CreateViewNodes);
|
11817
|
// fill static content and view queries
|
11818
|
execQueriesAction(view, 67108864 /* TypeContentQuery */ | 134217728 /* TypeViewQuery */, 268435456 /* StaticQuery */, 0 /* CheckAndUpdate */);
|
11819
|
}
|
11820
|
/**
|
11821
|
* @param {?} view
|
11822
|
* @return {?}
|
11823
|
*/
|
11824
|
function checkNoChangesView(view) {
|
11825
|
markProjectedViewsForCheck(view);
|
11826
|
Services.updateDirectives(view, 1 /* CheckNoChanges */);
|
11827
|
execEmbeddedViewsAction(view, ViewAction.CheckNoChanges);
|
11828
|
Services.updateRenderer(view, 1 /* CheckNoChanges */);
|
11829
|
execComponentViewsAction(view, ViewAction.CheckNoChanges);
|
11830
|
// Note: We don't check queries for changes as we didn't do this in v2.x.
|
11831
|
// TODO(tbosch): investigate if we can enable the check again in v5.x with a nicer error message.
|
11832
|
view.state &= ~(64 /* CheckProjectedViews */ | 32 /* CheckProjectedView */);
|
11833
|
}
|
11834
|
/**
|
11835
|
* @param {?} view
|
11836
|
* @return {?}
|
11837
|
*/
|
11838
|
function checkAndUpdateView(view) {
|
11839
|
if (view.state & 1 /* BeforeFirstCheck */) {
|
11840
|
view.state &= ~1 /* BeforeFirstCheck */;
|
11841
|
view.state |= 2 /* FirstCheck */;
|
11842
|
}
|
11843
|
else {
|
11844
|
view.state &= ~2 /* FirstCheck */;
|
11845
|
}
|
11846
|
markProjectedViewsForCheck(view);
|
11847
|
Services.updateDirectives(view, 0 /* CheckAndUpdate */);
|
11848
|
execEmbeddedViewsAction(view, ViewAction.CheckAndUpdate);
|
11849
|
execQueriesAction(view, 67108864 /* TypeContentQuery */, 536870912 /* DynamicQuery */, 0 /* CheckAndUpdate */);
|
11850
|
callLifecycleHooksChildrenFirst(view, 2097152 /* AfterContentChecked */ |
|
11851
|
(view.state & 2 /* FirstCheck */ ? 1048576 /* AfterContentInit */ : 0));
|
11852
|
Services.updateRenderer(view, 0 /* CheckAndUpdate */);
|
11853
|
execComponentViewsAction(view, ViewAction.CheckAndUpdate);
|
11854
|
execQueriesAction(view, 134217728 /* TypeViewQuery */, 536870912 /* DynamicQuery */, 0 /* CheckAndUpdate */);
|
11855
|
callLifecycleHooksChildrenFirst(view, 8388608 /* AfterViewChecked */ |
|
11856
|
(view.state & 2 /* FirstCheck */ ? 4194304 /* AfterViewInit */ : 0));
|
11857
|
if (view.def.flags & 2 /* OnPush */) {
|
11858
|
view.state &= ~8 /* ChecksEnabled */;
|
11859
|
}
|
11860
|
view.state &= ~(64 /* CheckProjectedViews */ | 32 /* CheckProjectedView */);
|
11861
|
}
|
11862
|
/**
|
11863
|
* @param {?} view
|
11864
|
* @param {?} nodeDef
|
11865
|
* @param {?} argStyle
|
11866
|
* @param {?=} v0
|
11867
|
* @param {?=} v1
|
11868
|
* @param {?=} v2
|
11869
|
* @param {?=} v3
|
11870
|
* @param {?=} v4
|
11871
|
* @param {?=} v5
|
11872
|
* @param {?=} v6
|
11873
|
* @param {?=} v7
|
11874
|
* @param {?=} v8
|
11875
|
* @param {?=} v9
|
11876
|
* @return {?}
|
11877
|
*/
|
11878
|
function checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11879
|
if (argStyle === 0 /* Inline */) {
|
11880
|
return checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11881
|
}
|
11882
|
else {
|
11883
|
return checkAndUpdateNodeDynamic(view, nodeDef, v0);
|
11884
|
}
|
11885
|
}
|
11886
|
/**
|
11887
|
* @param {?} view
|
11888
|
* @return {?}
|
11889
|
*/
|
11890
|
function markProjectedViewsForCheck(view) {
|
11891
|
const /** @type {?} */ def = view.def;
|
11892
|
if (!(def.nodeFlags & 4 /* ProjectedTemplate */)) {
|
11893
|
return;
|
11894
|
}
|
11895
|
for (let /** @type {?} */ i = 0; i < def.nodes.length; i++) {
|
11896
|
const /** @type {?} */ nodeDef = def.nodes[i];
|
11897
|
if (nodeDef.flags & 4 /* ProjectedTemplate */) {
|
11898
|
const /** @type {?} */ projectedViews = asElementData(view, i).template._projectedViews;
|
11899
|
if (projectedViews) {
|
11900
|
for (let /** @type {?} */ i = 0; i < projectedViews.length; i++) {
|
11901
|
const /** @type {?} */ projectedView = projectedViews[i];
|
11902
|
projectedView.state |= 32 /* CheckProjectedView */;
|
11903
|
markParentViewsForCheckProjectedViews(projectedView, view);
|
11904
|
}
|
11905
|
}
|
11906
|
}
|
11907
|
else if ((nodeDef.childFlags & 4 /* ProjectedTemplate */) === 0) {
|
11908
|
// a parent with leafs
|
11909
|
// no child is a component,
|
11910
|
// then skip the children
|
11911
|
i += nodeDef.childCount;
|
11912
|
}
|
11913
|
}
|
11914
|
}
|
11915
|
/**
|
11916
|
* @param {?} view
|
11917
|
* @param {?} nodeDef
|
11918
|
* @param {?=} v0
|
11919
|
* @param {?=} v1
|
11920
|
* @param {?=} v2
|
11921
|
* @param {?=} v3
|
11922
|
* @param {?=} v4
|
11923
|
* @param {?=} v5
|
11924
|
* @param {?=} v6
|
11925
|
* @param {?=} v7
|
11926
|
* @param {?=} v8
|
11927
|
* @param {?=} v9
|
11928
|
* @return {?}
|
11929
|
*/
|
11930
|
function checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11931
|
switch (nodeDef.flags & 201347067 /* Types */) {
|
11932
|
case 1 /* TypeElement */:
|
11933
|
return checkAndUpdateElementInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11934
|
case 2 /* TypeText */:
|
11935
|
return checkAndUpdateTextInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11936
|
case 16384 /* TypeDirective */:
|
11937
|
return checkAndUpdateDirectiveInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11938
|
case 32 /* TypePureArray */:
|
11939
|
case 64 /* TypePureObject */:
|
11940
|
case 128 /* TypePurePipe */:
|
11941
|
return checkAndUpdatePureExpressionInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11942
|
default:
|
11943
|
throw 'unreachable';
|
11944
|
}
|
11945
|
}
|
11946
|
/**
|
11947
|
* @param {?} view
|
11948
|
* @param {?} nodeDef
|
11949
|
* @param {?} values
|
11950
|
* @return {?}
|
11951
|
*/
|
11952
|
function checkAndUpdateNodeDynamic(view, nodeDef, values) {
|
11953
|
switch (nodeDef.flags & 201347067 /* Types */) {
|
11954
|
case 1 /* TypeElement */:
|
11955
|
return checkAndUpdateElementDynamic(view, nodeDef, values);
|
11956
|
case 2 /* TypeText */:
|
11957
|
return checkAndUpdateTextDynamic(view, nodeDef, values);
|
11958
|
case 16384 /* TypeDirective */:
|
11959
|
return checkAndUpdateDirectiveDynamic(view, nodeDef, values);
|
11960
|
case 32 /* TypePureArray */:
|
11961
|
case 64 /* TypePureObject */:
|
11962
|
case 128 /* TypePurePipe */:
|
11963
|
return checkAndUpdatePureExpressionDynamic(view, nodeDef, values);
|
11964
|
default:
|
11965
|
throw 'unreachable';
|
11966
|
}
|
11967
|
}
|
11968
|
/**
|
11969
|
* @param {?} view
|
11970
|
* @param {?} nodeDef
|
11971
|
* @param {?} argStyle
|
11972
|
* @param {?=} v0
|
11973
|
* @param {?=} v1
|
11974
|
* @param {?=} v2
|
11975
|
* @param {?=} v3
|
11976
|
* @param {?=} v4
|
11977
|
* @param {?=} v5
|
11978
|
* @param {?=} v6
|
11979
|
* @param {?=} v7
|
11980
|
* @param {?=} v8
|
11981
|
* @param {?=} v9
|
11982
|
* @return {?}
|
11983
|
*/
|
11984
|
function checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
11985
|
if (argStyle === 0 /* Inline */) {
|
11986
|
checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
11987
|
}
|
11988
|
else {
|
11989
|
checkNoChangesNodeDynamic(view, nodeDef, v0);
|
11990
|
}
|
11991
|
// Returning false is ok here as we would have thrown in case of a change.
|
11992
|
return false;
|
11993
|
}
|
11994
|
/**
|
11995
|
* @param {?} view
|
11996
|
* @param {?} nodeDef
|
11997
|
* @param {?} v0
|
11998
|
* @param {?} v1
|
11999
|
* @param {?} v2
|
12000
|
* @param {?} v3
|
12001
|
* @param {?} v4
|
12002
|
* @param {?} v5
|
12003
|
* @param {?} v6
|
12004
|
* @param {?} v7
|
12005
|
* @param {?} v8
|
12006
|
* @param {?} v9
|
12007
|
* @return {?}
|
12008
|
*/
|
12009
|
function checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
12010
|
const /** @type {?} */ bindLen = nodeDef.bindings.length;
|
12011
|
if (bindLen > 0)
|
12012
|
checkBindingNoChanges(view, nodeDef, 0, v0);
|
12013
|
if (bindLen > 1)
|
12014
|
checkBindingNoChanges(view, nodeDef, 1, v1);
|
12015
|
if (bindLen > 2)
|
12016
|
checkBindingNoChanges(view, nodeDef, 2, v2);
|
12017
|
if (bindLen > 3)
|
12018
|
checkBindingNoChanges(view, nodeDef, 3, v3);
|
12019
|
if (bindLen > 4)
|
12020
|
checkBindingNoChanges(view, nodeDef, 4, v4);
|
12021
|
if (bindLen > 5)
|
12022
|
checkBindingNoChanges(view, nodeDef, 5, v5);
|
12023
|
if (bindLen > 6)
|
12024
|
checkBindingNoChanges(view, nodeDef, 6, v6);
|
12025
|
if (bindLen > 7)
|
12026
|
checkBindingNoChanges(view, nodeDef, 7, v7);
|
12027
|
if (bindLen > 8)
|
12028
|
checkBindingNoChanges(view, nodeDef, 8, v8);
|
12029
|
if (bindLen > 9)
|
12030
|
checkBindingNoChanges(view, nodeDef, 9, v9);
|
12031
|
}
|
12032
|
/**
|
12033
|
* @param {?} view
|
12034
|
* @param {?} nodeDef
|
12035
|
* @param {?} values
|
12036
|
* @return {?}
|
12037
|
*/
|
12038
|
function checkNoChangesNodeDynamic(view, nodeDef, values) {
|
12039
|
for (let /** @type {?} */ i = 0; i < values.length; i++) {
|
12040
|
checkBindingNoChanges(view, nodeDef, i, values[i]);
|
12041
|
}
|
12042
|
}
|
12043
|
/**
|
12044
|
* Workaround https://github.com/angular/tsickle/issues/497
|
12045
|
* @suppress {misplacedTypeAnnotation}
|
12046
|
* @param {?} view
|
12047
|
* @param {?} nodeDef
|
12048
|
* @return {?}
|
12049
|
*/
|
12050
|
function checkNoChangesQuery(view, nodeDef) {
|
12051
|
const /** @type {?} */ queryList = asQueryList(view, nodeDef.nodeIndex);
|
12052
|
if (queryList.dirty) {
|
12053
|
throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, nodeDef.nodeIndex), `Query ${ /** @type {?} */((nodeDef.query)).id} not dirty`, `Query ${ /** @type {?} */((nodeDef.query)).id} dirty`, (view.state & 1 /* BeforeFirstCheck */) !== 0);
|
12054
|
}
|
12055
|
}
|
12056
|
/**
|
12057
|
* @param {?} view
|
12058
|
* @return {?}
|
12059
|
*/
|
12060
|
function destroyView(view) {
|
12061
|
if (view.state & 128 /* Destroyed */) {
|
12062
|
return;
|
12063
|
}
|
12064
|
execEmbeddedViewsAction(view, ViewAction.Destroy);
|
12065
|
execComponentViewsAction(view, ViewAction.Destroy);
|
12066
|
callLifecycleHooksChildrenFirst(view, 131072 /* OnDestroy */);
|
12067
|
if (view.disposables) {
|
12068
|
for (let /** @type {?} */ i = 0; i < view.disposables.length; i++) {
|
12069
|
view.disposables[i]();
|
12070
|
}
|
12071
|
}
|
12072
|
detachProjectedView(view);
|
12073
|
if (view.renderer.destroyNode) {
|
12074
|
destroyViewNodes(view);
|
12075
|
}
|
12076
|
if (isComponentView(view)) {
|
12077
|
view.renderer.destroy();
|
12078
|
}
|
12079
|
view.state |= 128 /* Destroyed */;
|
12080
|
}
|
12081
|
/**
|
12082
|
* @param {?} view
|
12083
|
* @return {?}
|
12084
|
*/
|
12085
|
function destroyViewNodes(view) {
|
12086
|
const /** @type {?} */ len = view.def.nodes.length;
|
12087
|
for (let /** @type {?} */ i = 0; i < len; i++) {
|
12088
|
const /** @type {?} */ def = view.def.nodes[i];
|
12089
|
if (def.flags & 1 /* TypeElement */) {
|
12090
|
((view.renderer.destroyNode))(asElementData(view, i).renderElement);
|
12091
|
}
|
12092
|
else if (def.flags & 2 /* TypeText */) {
|
12093
|
((view.renderer.destroyNode))(asTextData(view, i).renderText);
|
12094
|
}
|
12095
|
else if (def.flags & 67108864 /* TypeContentQuery */ || def.flags & 134217728 /* TypeViewQuery */) {
|
12096
|
asQueryList(view, i).destroy();
|
12097
|
}
|
12098
|
}
|
12099
|
}
|
12100
|
let ViewAction = {};
|
12101
|
ViewAction.CreateViewNodes = 0;
|
12102
|
ViewAction.CheckNoChanges = 1;
|
12103
|
ViewAction.CheckNoChangesProjectedViews = 2;
|
12104
|
ViewAction.CheckAndUpdate = 3;
|
12105
|
ViewAction.CheckAndUpdateProjectedViews = 4;
|
12106
|
ViewAction.Destroy = 5;
|
12107
|
ViewAction[ViewAction.CreateViewNodes] = "CreateViewNodes";
|
12108
|
ViewAction[ViewAction.CheckNoChanges] = "CheckNoChanges";
|
12109
|
ViewAction[ViewAction.CheckNoChangesProjectedViews] = "CheckNoChangesProjectedViews";
|
12110
|
ViewAction[ViewAction.CheckAndUpdate] = "CheckAndUpdate";
|
12111
|
ViewAction[ViewAction.CheckAndUpdateProjectedViews] = "CheckAndUpdateProjectedViews";
|
12112
|
ViewAction[ViewAction.Destroy] = "Destroy";
|
12113
|
/**
|
12114
|
* @param {?} view
|
12115
|
* @param {?} action
|
12116
|
* @return {?}
|
12117
|
*/
|
12118
|
function execComponentViewsAction(view, action) {
|
12119
|
const /** @type {?} */ def = view.def;
|
12120
|
if (!(def.nodeFlags & 33554432 /* ComponentView */)) {
|
12121
|
return;
|
12122
|
}
|
12123
|
for (let /** @type {?} */ i = 0; i < def.nodes.length; i++) {
|
12124
|
const /** @type {?} */ nodeDef = def.nodes[i];
|
12125
|
if (nodeDef.flags & 33554432 /* ComponentView */) {
|
12126
|
// a leaf
|
12127
|
callViewAction(asElementData(view, i).componentView, action);
|
12128
|
}
|
12129
|
else if ((nodeDef.childFlags & 33554432 /* ComponentView */) === 0) {
|
12130
|
// a parent with leafs
|
12131
|
// no child is a component,
|
12132
|
// then skip the children
|
12133
|
i += nodeDef.childCount;
|
12134
|
}
|
12135
|
}
|
12136
|
}
|
12137
|
/**
|
12138
|
* @param {?} view
|
12139
|
* @param {?} action
|
12140
|
* @return {?}
|
12141
|
*/
|
12142
|
function execEmbeddedViewsAction(view, action) {
|
12143
|
const /** @type {?} */ def = view.def;
|
12144
|
if (!(def.nodeFlags & 16777216 /* EmbeddedViews */)) {
|
12145
|
return;
|
12146
|
}
|
12147
|
for (let /** @type {?} */ i = 0; i < def.nodes.length; i++) {
|
12148
|
const /** @type {?} */ nodeDef = def.nodes[i];
|
12149
|
if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
|
12150
|
// a leaf
|
12151
|
const /** @type {?} */ embeddedViews = ((asElementData(view, i).viewContainer))._embeddedViews;
|
12152
|
for (let /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
|
12153
|
callViewAction(embeddedViews[k], action);
|
12154
|
}
|
12155
|
}
|
12156
|
else if ((nodeDef.childFlags & 16777216 /* EmbeddedViews */) === 0) {
|
12157
|
// a parent with leafs
|
12158
|
// no child is a component,
|
12159
|
// then skip the children
|
12160
|
i += nodeDef.childCount;
|
12161
|
}
|
12162
|
}
|
12163
|
}
|
12164
|
/**
|
12165
|
* @param {?} view
|
12166
|
* @param {?} action
|
12167
|
* @return {?}
|
12168
|
*/
|
12169
|
function callViewAction(view, action) {
|
12170
|
const /** @type {?} */ viewState = view.state;
|
12171
|
switch (action) {
|
12172
|
case ViewAction.CheckNoChanges:
|
12173
|
if ((viewState & 128 /* Destroyed */) === 0) {
|
12174
|
if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */) {
|
12175
|
checkNoChangesView(view);
|
12176
|
}
|
12177
|
else if (viewState & 64 /* CheckProjectedViews */) {
|
12178
|
execProjectedViewsAction(view, ViewAction.CheckNoChangesProjectedViews);
|
12179
|
}
|
12180
|
}
|
12181
|
break;
|
12182
|
case ViewAction.CheckNoChangesProjectedViews:
|
12183
|
if ((viewState & 128 /* Destroyed */) === 0) {
|
12184
|
if (viewState & 32 /* CheckProjectedView */) {
|
12185
|
checkNoChangesView(view);
|
12186
|
}
|
12187
|
else if (viewState & 64 /* CheckProjectedViews */) {
|
12188
|
execProjectedViewsAction(view, action);
|
12189
|
}
|
12190
|
}
|
12191
|
break;
|
12192
|
case ViewAction.CheckAndUpdate:
|
12193
|
if ((viewState & 128 /* Destroyed */) === 0) {
|
12194
|
if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */) {
|
12195
|
checkAndUpdateView(view);
|
12196
|
}
|
12197
|
else if (viewState & 64 /* CheckProjectedViews */) {
|
12198
|
execProjectedViewsAction(view, ViewAction.CheckAndUpdateProjectedViews);
|
12199
|
}
|
12200
|
}
|
12201
|
break;
|
12202
|
case ViewAction.CheckAndUpdateProjectedViews:
|
12203
|
if ((viewState & 128 /* Destroyed */) === 0) {
|
12204
|
if (viewState & 32 /* CheckProjectedView */) {
|
12205
|
checkAndUpdateView(view);
|
12206
|
}
|
12207
|
else if (viewState & 64 /* CheckProjectedViews */) {
|
12208
|
execProjectedViewsAction(view, action);
|
12209
|
}
|
12210
|
}
|
12211
|
break;
|
12212
|
case ViewAction.Destroy:
|
12213
|
// Note: destroyView recurses over all views,
|
12214
|
// so we don't need to special case projected views here.
|
12215
|
destroyView(view);
|
12216
|
break;
|
12217
|
case ViewAction.CreateViewNodes:
|
12218
|
createViewNodes(view);
|
12219
|
break;
|
12220
|
}
|
12221
|
}
|
12222
|
/**
|
12223
|
* @param {?} view
|
12224
|
* @param {?} action
|
12225
|
* @return {?}
|
12226
|
*/
|
12227
|
function execProjectedViewsAction(view, action) {
|
12228
|
execEmbeddedViewsAction(view, action);
|
12229
|
execComponentViewsAction(view, action);
|
12230
|
}
|
12231
|
/**
|
12232
|
* @param {?} view
|
12233
|
* @param {?} queryFlags
|
12234
|
* @param {?} staticDynamicQueryFlag
|
12235
|
* @param {?} checkType
|
12236
|
* @return {?}
|
12237
|
*/
|
12238
|
function execQueriesAction(view, queryFlags, staticDynamicQueryFlag, checkType) {
|
12239
|
if (!(view.def.nodeFlags & queryFlags) || !(view.def.nodeFlags & staticDynamicQueryFlag)) {
|
12240
|
return;
|
12241
|
}
|
12242
|
const /** @type {?} */ nodeCount = view.def.nodes.length;
|
12243
|
for (let /** @type {?} */ i = 0; i < nodeCount; i++) {
|
12244
|
const /** @type {?} */ nodeDef = view.def.nodes[i];
|
12245
|
if ((nodeDef.flags & queryFlags) && (nodeDef.flags & staticDynamicQueryFlag)) {
|
12246
|
Services.setCurrentNode(view, nodeDef.nodeIndex);
|
12247
|
switch (checkType) {
|
12248
|
case 0 /* CheckAndUpdate */:
|
12249
|
checkAndUpdateQuery(view, nodeDef);
|
12250
|
break;
|
12251
|
case 1 /* CheckNoChanges */:
|
12252
|
checkNoChangesQuery(view, nodeDef);
|
12253
|
break;
|
12254
|
}
|
12255
|
}
|
12256
|
if (!(nodeDef.childFlags & queryFlags) || !(nodeDef.childFlags & staticDynamicQueryFlag)) {
|
12257
|
// no child has a matching query
|
12258
|
// then skip the children
|
12259
|
i += nodeDef.childCount;
|
12260
|
}
|
12261
|
}
|
12262
|
}
|
12263
|
|
12264
|
/**
|
12265
|
* @license
|
12266
|
* Copyright Google Inc. All Rights Reserved.
|
12267
|
*
|
12268
|
* Use of this source code is governed by an MIT-style license that can be
|
12269
|
* found in the LICENSE file at https://angular.io/license
|
12270
|
*/
|
12271
|
let initialized = false;
|
12272
|
/**
|
12273
|
* @return {?}
|
12274
|
*/
|
12275
|
function initServicesIfNeeded() {
|
12276
|
if (initialized) {
|
12277
|
return;
|
12278
|
}
|
12279
|
initialized = true;
|
12280
|
const /** @type {?} */ services = isDevMode() ? createDebugServices() : createProdServices();
|
12281
|
Services.setCurrentNode = services.setCurrentNode;
|
12282
|
Services.createRootView = services.createRootView;
|
12283
|
Services.createEmbeddedView = services.createEmbeddedView;
|
12284
|
Services.createComponentView = services.createComponentView;
|
12285
|
Services.createNgModuleRef = services.createNgModuleRef;
|
12286
|
Services.overrideProvider = services.overrideProvider;
|
12287
|
Services.clearProviderOverrides = services.clearProviderOverrides;
|
12288
|
Services.checkAndUpdateView = services.checkAndUpdateView;
|
12289
|
Services.checkNoChangesView = services.checkNoChangesView;
|
12290
|
Services.destroyView = services.destroyView;
|
12291
|
Services.resolveDep = resolveDep;
|
12292
|
Services.createDebugContext = services.createDebugContext;
|
12293
|
Services.handleEvent = services.handleEvent;
|
12294
|
Services.updateDirectives = services.updateDirectives;
|
12295
|
Services.updateRenderer = services.updateRenderer;
|
12296
|
Services.dirtyParentQueries = dirtyParentQueries;
|
12297
|
}
|
12298
|
/**
|
12299
|
* @return {?}
|
12300
|
*/
|
12301
|
function createProdServices() {
|
12302
|
return {
|
12303
|
setCurrentNode: () => { },
|
12304
|
createRootView: createProdRootView,
|
12305
|
createEmbeddedView: createEmbeddedView,
|
12306
|
createComponentView: createComponentView,
|
12307
|
createNgModuleRef: createNgModuleRef,
|
12308
|
overrideProvider: NOOP,
|
12309
|
clearProviderOverrides: NOOP,
|
12310
|
checkAndUpdateView: checkAndUpdateView,
|
12311
|
checkNoChangesView: checkNoChangesView,
|
12312
|
destroyView: destroyView,
|
12313
|
createDebugContext: (view, nodeIndex) => new DebugContext_(view, nodeIndex),
|
12314
|
handleEvent: (view, nodeIndex, eventName, event) => view.def.handleEvent(view, nodeIndex, eventName, event),
|
12315
|
updateDirectives: (view, checkType) => view.def.updateDirectives(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
|
12316
|
prodCheckNoChangesNode, view),
|
12317
|
updateRenderer: (view, checkType) => view.def.updateRenderer(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
|
12318
|
prodCheckNoChangesNode, view),
|
12319
|
};
|
12320
|
}
|
12321
|
/**
|
12322
|
* @return {?}
|
12323
|
*/
|
12324
|
function createDebugServices() {
|
12325
|
return {
|
12326
|
setCurrentNode: debugSetCurrentNode,
|
12327
|
createRootView: debugCreateRootView,
|
12328
|
createEmbeddedView: debugCreateEmbeddedView,
|
12329
|
createComponentView: debugCreateComponentView,
|
12330
|
createNgModuleRef: debugCreateNgModuleRef,
|
12331
|
overrideProvider: debugOverrideProvider,
|
12332
|
clearProviderOverrides: debugClearProviderOverrides,
|
12333
|
checkAndUpdateView: debugCheckAndUpdateView,
|
12334
|
checkNoChangesView: debugCheckNoChangesView,
|
12335
|
destroyView: debugDestroyView,
|
12336
|
createDebugContext: (view, nodeIndex) => new DebugContext_(view, nodeIndex),
|
12337
|
handleEvent: debugHandleEvent,
|
12338
|
updateDirectives: debugUpdateDirectives,
|
12339
|
updateRenderer: debugUpdateRenderer,
|
12340
|
};
|
12341
|
}
|
12342
|
/**
|
12343
|
* @param {?} elInjector
|
12344
|
* @param {?} projectableNodes
|
12345
|
* @param {?} rootSelectorOrNode
|
12346
|
* @param {?} def
|
12347
|
* @param {?} ngModule
|
12348
|
* @param {?=} context
|
12349
|
* @return {?}
|
12350
|
*/
|
12351
|
function createProdRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
|
12352
|
const /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
|
12353
|
return createRootView(createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode), def, context);
|
12354
|
}
|
12355
|
/**
|
12356
|
* @param {?} elInjector
|
12357
|
* @param {?} projectableNodes
|
12358
|
* @param {?} rootSelectorOrNode
|
12359
|
* @param {?} def
|
12360
|
* @param {?} ngModule
|
12361
|
* @param {?=} context
|
12362
|
* @return {?}
|
12363
|
*/
|
12364
|
function debugCreateRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
|
12365
|
const /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
|
12366
|
const /** @type {?} */ root = createRootData(elInjector, ngModule, new DebugRendererFactory2(rendererFactory), projectableNodes, rootSelectorOrNode);
|
12367
|
const /** @type {?} */ defWithOverride = applyProviderOverridesToView(def);
|
12368
|
return callWithDebugContext(DebugAction.create, createRootView, null, [root, defWithOverride, context]);
|
12369
|
}
|
12370
|
/**
|
12371
|
* @param {?} elInjector
|
12372
|
* @param {?} ngModule
|
12373
|
* @param {?} rendererFactory
|
12374
|
* @param {?} projectableNodes
|
12375
|
* @param {?} rootSelectorOrNode
|
12376
|
* @return {?}
|
12377
|
*/
|
12378
|
function createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode) {
|
12379
|
const /** @type {?} */ sanitizer = ngModule.injector.get(Sanitizer);
|
12380
|
const /** @type {?} */ errorHandler = ngModule.injector.get(ErrorHandler);
|
12381
|
const /** @type {?} */ renderer = rendererFactory.createRenderer(null, null);
|
12382
|
return {
|
12383
|
ngModule,
|
12384
|
injector: elInjector, projectableNodes,
|
12385
|
selectorOrNode: rootSelectorOrNode, sanitizer, rendererFactory, renderer, errorHandler
|
12386
|
};
|
12387
|
}
|
12388
|
/**
|
12389
|
* @param {?} parentView
|
12390
|
* @param {?} anchorDef
|
12391
|
* @param {?} viewDef
|
12392
|
* @param {?=} context
|
12393
|
* @return {?}
|
12394
|
*/
|
12395
|
function debugCreateEmbeddedView(parentView, anchorDef, viewDef$$1, context) {
|
12396
|
const /** @type {?} */ defWithOverride = applyProviderOverridesToView(viewDef$$1);
|
12397
|
return callWithDebugContext(DebugAction.create, createEmbeddedView, null, [parentView, anchorDef, defWithOverride, context]);
|
12398
|
}
|
12399
|
/**
|
12400
|
* @param {?} parentView
|
12401
|
* @param {?} nodeDef
|
12402
|
* @param {?} viewDef
|
12403
|
* @param {?} hostElement
|
12404
|
* @return {?}
|
12405
|
*/
|
12406
|
function debugCreateComponentView(parentView, nodeDef, viewDef$$1, hostElement) {
|
12407
|
const /** @type {?} */ defWithOverride = applyProviderOverridesToView(viewDef$$1);
|
12408
|
return callWithDebugContext(DebugAction.create, createComponentView, null, [parentView, nodeDef, defWithOverride, hostElement]);
|
12409
|
}
|
12410
|
/**
|
12411
|
* @param {?} moduleType
|
12412
|
* @param {?} parentInjector
|
12413
|
* @param {?} bootstrapComponents
|
12414
|
* @param {?} def
|
12415
|
* @return {?}
|
12416
|
*/
|
12417
|
function debugCreateNgModuleRef(moduleType, parentInjector, bootstrapComponents, def) {
|
12418
|
const /** @type {?} */ defWithOverride = applyProviderOverridesToNgModule(def);
|
12419
|
return createNgModuleRef(moduleType, parentInjector, bootstrapComponents, defWithOverride);
|
12420
|
}
|
12421
|
const providerOverrides = new Map();
|
12422
|
/**
|
12423
|
* @param {?} override
|
12424
|
* @return {?}
|
12425
|
*/
|
12426
|
function debugOverrideProvider(override) {
|
12427
|
providerOverrides.set(override.token, override);
|
12428
|
}
|
12429
|
/**
|
12430
|
* @return {?}
|
12431
|
*/
|
12432
|
function debugClearProviderOverrides() {
|
12433
|
providerOverrides.clear();
|
12434
|
}
|
12435
|
/**
|
12436
|
* @param {?} def
|
12437
|
* @return {?}
|
12438
|
*/
|
12439
|
function applyProviderOverridesToView(def) {
|
12440
|
if (providerOverrides.size === 0) {
|
12441
|
return def;
|
12442
|
}
|
12443
|
const /** @type {?} */ elementIndicesWithOverwrittenProviders = findElementIndicesWithOverwrittenProviders(def);
|
12444
|
if (elementIndicesWithOverwrittenProviders.length === 0) {
|
12445
|
return def;
|
12446
|
}
|
12447
|
// clone the whole view definition,
|
12448
|
// as it maintains references between the nodes that are hard to update.
|
12449
|
def = ((def.factory))(() => NOOP);
|
12450
|
for (let /** @type {?} */ i = 0; i < elementIndicesWithOverwrittenProviders.length; i++) {
|
12451
|
applyProviderOverridesToElement(def, elementIndicesWithOverwrittenProviders[i]);
|
12452
|
}
|
12453
|
return def;
|
12454
|
/**
|
12455
|
* @param {?} def
|
12456
|
* @return {?}
|
12457
|
*/
|
12458
|
function findElementIndicesWithOverwrittenProviders(def) {
|
12459
|
const /** @type {?} */ elIndicesWithOverwrittenProviders = [];
|
12460
|
let /** @type {?} */ lastElementDef = null;
|
12461
|
for (let /** @type {?} */ i = 0; i < def.nodes.length; i++) {
|
12462
|
const /** @type {?} */ nodeDef = def.nodes[i];
|
12463
|
if (nodeDef.flags & 1 /* TypeElement */) {
|
12464
|
lastElementDef = nodeDef;
|
12465
|
}
|
12466
|
if (lastElementDef && nodeDef.flags & 3840 /* CatProviderNoDirective */ &&
|
12467
|
providerOverrides.has(/** @type {?} */ ((nodeDef.provider)).token)) {
|
12468
|
elIndicesWithOverwrittenProviders.push(/** @type {?} */ ((lastElementDef)).nodeIndex);
|
12469
|
lastElementDef = null;
|
12470
|
}
|
12471
|
}
|
12472
|
return elIndicesWithOverwrittenProviders;
|
12473
|
}
|
12474
|
/**
|
12475
|
* @param {?} viewDef
|
12476
|
* @param {?} elIndex
|
12477
|
* @return {?}
|
12478
|
*/
|
12479
|
function applyProviderOverridesToElement(viewDef$$1, elIndex) {
|
12480
|
for (let /** @type {?} */ i = elIndex + 1; i < viewDef$$1.nodes.length; i++) {
|
12481
|
const /** @type {?} */ nodeDef = viewDef$$1.nodes[i];
|
12482
|
if (nodeDef.flags & 1 /* TypeElement */) {
|
12483
|
// stop at the next element
|
12484
|
return;
|
12485
|
}
|
12486
|
if (nodeDef.flags & 3840 /* CatProviderNoDirective */) {
|
12487
|
const /** @type {?} */ provider = ((nodeDef.provider));
|
12488
|
const /** @type {?} */ override = providerOverrides.get(provider.token);
|
12489
|
if (override) {
|
12490
|
nodeDef.flags = (nodeDef.flags & ~3840 /* CatProviderNoDirective */) | override.flags;
|
12491
|
provider.deps = splitDepsDsl(override.deps);
|
12492
|
provider.value = override.value;
|
12493
|
}
|
12494
|
}
|
12495
|
}
|
12496
|
}
|
12497
|
}
|
12498
|
/**
|
12499
|
* @param {?} def
|
12500
|
* @return {?}
|
12501
|
*/
|
12502
|
function applyProviderOverridesToNgModule(def) {
|
12503
|
const { hasOverrides, hasDeprecatedOverrides } = calcHasOverrides(def);
|
12504
|
if (!hasOverrides) {
|
12505
|
return def;
|
12506
|
}
|
12507
|
// clone the whole view definition,
|
12508
|
// as it maintains references between the nodes that are hard to update.
|
12509
|
def = ((def.factory))(() => NOOP);
|
12510
|
applyProviderOverrides(def);
|
12511
|
return def;
|
12512
|
/**
|
12513
|
* @param {?} def
|
12514
|
* @return {?}
|
12515
|
*/
|
12516
|
function calcHasOverrides(def) {
|
12517
|
let /** @type {?} */ hasOverrides = false;
|
12518
|
let /** @type {?} */ hasDeprecatedOverrides = false;
|
12519
|
if (providerOverrides.size === 0) {
|
12520
|
return { hasOverrides, hasDeprecatedOverrides };
|
12521
|
}
|
12522
|
def.providers.forEach(node => {
|
12523
|
const /** @type {?} */ override = providerOverrides.get(node.token);
|
12524
|
if ((node.flags & 3840 /* CatProviderNoDirective */) && override) {
|
12525
|
hasOverrides = true;
|
12526
|
hasDeprecatedOverrides = hasDeprecatedOverrides || override.deprecatedBehavior;
|
12527
|
}
|
12528
|
});
|
12529
|
return { hasOverrides, hasDeprecatedOverrides };
|
12530
|
}
|
12531
|
/**
|
12532
|
* @param {?} def
|
12533
|
* @return {?}
|
12534
|
*/
|
12535
|
function applyProviderOverrides(def) {
|
12536
|
for (let /** @type {?} */ i = 0; i < def.providers.length; i++) {
|
12537
|
const /** @type {?} */ provider = def.providers[i];
|
12538
|
if (hasDeprecatedOverrides) {
|
12539
|
// We had a bug where me made
|
12540
|
// all providers lazy. Keep this logic behind a flag
|
12541
|
// for migrating existing users.
|
12542
|
provider.flags |= 4096 /* LazyProvider */;
|
12543
|
}
|
12544
|
const /** @type {?} */ override = providerOverrides.get(provider.token);
|
12545
|
if (override) {
|
12546
|
provider.flags = (provider.flags & ~3840 /* CatProviderNoDirective */) | override.flags;
|
12547
|
provider.deps = splitDepsDsl(override.deps);
|
12548
|
provider.value = override.value;
|
12549
|
}
|
12550
|
}
|
12551
|
}
|
12552
|
}
|
12553
|
/**
|
12554
|
* @param {?} view
|
12555
|
* @param {?} checkIndex
|
12556
|
* @param {?} argStyle
|
12557
|
* @param {?=} v0
|
12558
|
* @param {?=} v1
|
12559
|
* @param {?=} v2
|
12560
|
* @param {?=} v3
|
12561
|
* @param {?=} v4
|
12562
|
* @param {?=} v5
|
12563
|
* @param {?=} v6
|
12564
|
* @param {?=} v7
|
12565
|
* @param {?=} v8
|
12566
|
* @param {?=} v9
|
12567
|
* @return {?}
|
12568
|
*/
|
12569
|
function prodCheckAndUpdateNode(view, checkIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
12570
|
const /** @type {?} */ nodeDef = view.def.nodes[checkIndex];
|
12571
|
checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
12572
|
return (nodeDef.flags & 224 /* CatPureExpression */) ?
|
12573
|
asPureExpressionData(view, checkIndex).value :
|
12574
|
undefined;
|
12575
|
}
|
12576
|
/**
|
12577
|
* @param {?} view
|
12578
|
* @param {?} checkIndex
|
12579
|
* @param {?} argStyle
|
12580
|
* @param {?=} v0
|
12581
|
* @param {?=} v1
|
12582
|
* @param {?=} v2
|
12583
|
* @param {?=} v3
|
12584
|
* @param {?=} v4
|
12585
|
* @param {?=} v5
|
12586
|
* @param {?=} v6
|
12587
|
* @param {?=} v7
|
12588
|
* @param {?=} v8
|
12589
|
* @param {?=} v9
|
12590
|
* @return {?}
|
12591
|
*/
|
12592
|
function prodCheckNoChangesNode(view, checkIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
12593
|
const /** @type {?} */ nodeDef = view.def.nodes[checkIndex];
|
12594
|
checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
12595
|
return (nodeDef.flags & 224 /* CatPureExpression */) ?
|
12596
|
asPureExpressionData(view, checkIndex).value :
|
12597
|
undefined;
|
12598
|
}
|
12599
|
/**
|
12600
|
* @param {?} view
|
12601
|
* @return {?}
|
12602
|
*/
|
12603
|
function debugCheckAndUpdateView(view) {
|
12604
|
return callWithDebugContext(DebugAction.detectChanges, checkAndUpdateView, null, [view]);
|
12605
|
}
|
12606
|
/**
|
12607
|
* @param {?} view
|
12608
|
* @return {?}
|
12609
|
*/
|
12610
|
function debugCheckNoChangesView(view) {
|
12611
|
return callWithDebugContext(DebugAction.checkNoChanges, checkNoChangesView, null, [view]);
|
12612
|
}
|
12613
|
/**
|
12614
|
* @param {?} view
|
12615
|
* @return {?}
|
12616
|
*/
|
12617
|
function debugDestroyView(view) {
|
12618
|
return callWithDebugContext(DebugAction.destroy, destroyView, null, [view]);
|
12619
|
}
|
12620
|
let DebugAction = {};
|
12621
|
DebugAction.create = 0;
|
12622
|
DebugAction.detectChanges = 1;
|
12623
|
DebugAction.checkNoChanges = 2;
|
12624
|
DebugAction.destroy = 3;
|
12625
|
DebugAction.handleEvent = 4;
|
12626
|
DebugAction[DebugAction.create] = "create";
|
12627
|
DebugAction[DebugAction.detectChanges] = "detectChanges";
|
12628
|
DebugAction[DebugAction.checkNoChanges] = "checkNoChanges";
|
12629
|
DebugAction[DebugAction.destroy] = "destroy";
|
12630
|
DebugAction[DebugAction.handleEvent] = "handleEvent";
|
12631
|
let _currentAction;
|
12632
|
let _currentView;
|
12633
|
let _currentNodeIndex;
|
12634
|
/**
|
12635
|
* @param {?} view
|
12636
|
* @param {?} nodeIndex
|
12637
|
* @return {?}
|
12638
|
*/
|
12639
|
function debugSetCurrentNode(view, nodeIndex) {
|
12640
|
_currentView = view;
|
12641
|
_currentNodeIndex = nodeIndex;
|
12642
|
}
|
12643
|
/**
|
12644
|
* @param {?} view
|
12645
|
* @param {?} nodeIndex
|
12646
|
* @param {?} eventName
|
12647
|
* @param {?} event
|
12648
|
* @return {?}
|
12649
|
*/
|
12650
|
function debugHandleEvent(view, nodeIndex, eventName, event) {
|
12651
|
debugSetCurrentNode(view, nodeIndex);
|
12652
|
return callWithDebugContext(DebugAction.handleEvent, view.def.handleEvent, null, [view, nodeIndex, eventName, event]);
|
12653
|
}
|
12654
|
/**
|
12655
|
* @param {?} view
|
12656
|
* @param {?} checkType
|
12657
|
* @return {?}
|
12658
|
*/
|
12659
|
function debugUpdateDirectives(view, checkType) {
|
12660
|
if (view.state & 128 /* Destroyed */) {
|
12661
|
throw viewDestroyedError(DebugAction[_currentAction]);
|
12662
|
}
|
12663
|
debugSetCurrentNode(view, nextDirectiveWithBinding(view, 0));
|
12664
|
return view.def.updateDirectives(debugCheckDirectivesFn, view);
|
12665
|
/**
|
12666
|
* @param {?} view
|
12667
|
* @param {?} nodeIndex
|
12668
|
* @param {?} argStyle
|
12669
|
* @param {...?} values
|
12670
|
* @return {?}
|
12671
|
*/
|
12672
|
function debugCheckDirectivesFn(view, nodeIndex, argStyle, ...values) {
|
12673
|
const /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
|
12674
|
if (checkType === 0 /* CheckAndUpdate */) {
|
12675
|
debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
|
12676
|
}
|
12677
|
else {
|
12678
|
debugCheckNoChangesNode(view, nodeDef, argStyle, values);
|
12679
|
}
|
12680
|
if (nodeDef.flags & 16384 /* TypeDirective */) {
|
12681
|
debugSetCurrentNode(view, nextDirectiveWithBinding(view, nodeIndex));
|
12682
|
}
|
12683
|
return (nodeDef.flags & 224 /* CatPureExpression */) ?
|
12684
|
asPureExpressionData(view, nodeDef.nodeIndex).value :
|
12685
|
undefined;
|
12686
|
}
|
12687
|
}
|
12688
|
/**
|
12689
|
* @param {?} view
|
12690
|
* @param {?} checkType
|
12691
|
* @return {?}
|
12692
|
*/
|
12693
|
function debugUpdateRenderer(view, checkType) {
|
12694
|
if (view.state & 128 /* Destroyed */) {
|
12695
|
throw viewDestroyedError(DebugAction[_currentAction]);
|
12696
|
}
|
12697
|
debugSetCurrentNode(view, nextRenderNodeWithBinding(view, 0));
|
12698
|
return view.def.updateRenderer(debugCheckRenderNodeFn, view);
|
12699
|
/**
|
12700
|
* @param {?} view
|
12701
|
* @param {?} nodeIndex
|
12702
|
* @param {?} argStyle
|
12703
|
* @param {...?} values
|
12704
|
* @return {?}
|
12705
|
*/
|
12706
|
function debugCheckRenderNodeFn(view, nodeIndex, argStyle, ...values) {
|
12707
|
const /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
|
12708
|
if (checkType === 0 /* CheckAndUpdate */) {
|
12709
|
debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
|
12710
|
}
|
12711
|
else {
|
12712
|
debugCheckNoChangesNode(view, nodeDef, argStyle, values);
|
12713
|
}
|
12714
|
if (nodeDef.flags & 3 /* CatRenderNode */) {
|
12715
|
debugSetCurrentNode(view, nextRenderNodeWithBinding(view, nodeIndex));
|
12716
|
}
|
12717
|
return (nodeDef.flags & 224 /* CatPureExpression */) ?
|
12718
|
asPureExpressionData(view, nodeDef.nodeIndex).value :
|
12719
|
undefined;
|
12720
|
}
|
12721
|
}
|
12722
|
/**
|
12723
|
* @param {?} view
|
12724
|
* @param {?} nodeDef
|
12725
|
* @param {?} argStyle
|
12726
|
* @param {?} givenValues
|
12727
|
* @return {?}
|
12728
|
*/
|
12729
|
function debugCheckAndUpdateNode(view, nodeDef, argStyle, givenValues) {
|
12730
|
const /** @type {?} */ changed = ((checkAndUpdateNode))(view, nodeDef, argStyle, ...givenValues);
|
12731
|
if (changed) {
|
12732
|
const /** @type {?} */ values = argStyle === 1 /* Dynamic */ ? givenValues[0] : givenValues;
|
12733
|
if (nodeDef.flags & 16384 /* TypeDirective */) {
|
12734
|
const /** @type {?} */ bindingValues = {};
|
12735
|
for (let /** @type {?} */ i = 0; i < nodeDef.bindings.length; i++) {
|
12736
|
const /** @type {?} */ binding = nodeDef.bindings[i];
|
12737
|
const /** @type {?} */ value = values[i];
|
12738
|
if (binding.flags & 8 /* TypeProperty */) {
|
12739
|
bindingValues[normalizeDebugBindingName(/** @type {?} */ ((binding.nonMinifiedName)))] =
|
12740
|
normalizeDebugBindingValue(value);
|
12741
|
}
|
12742
|
}
|
12743
|
const /** @type {?} */ elDef = ((nodeDef.parent));
|
12744
|
const /** @type {?} */ el = asElementData(view, elDef.nodeIndex).renderElement;
|
12745
|
if (!((elDef.element)).name) {
|
12746
|
// a comment.
|
12747
|
view.renderer.setValue(el, `bindings=${JSON.stringify(bindingValues, null, 2)}`);
|
12748
|
}
|
12749
|
else {
|
12750
|
// a regular element.
|
12751
|
for (let /** @type {?} */ attr in bindingValues) {
|
12752
|
const /** @type {?} */ value = bindingValues[attr];
|
12753
|
if (value != null) {
|
12754
|
view.renderer.setAttribute(el, attr, value);
|
12755
|
}
|
12756
|
else {
|
12757
|
view.renderer.removeAttribute(el, attr);
|
12758
|
}
|
12759
|
}
|
12760
|
}
|
12761
|
}
|
12762
|
}
|
12763
|
}
|
12764
|
/**
|
12765
|
* @param {?} view
|
12766
|
* @param {?} nodeDef
|
12767
|
* @param {?} argStyle
|
12768
|
* @param {?} values
|
12769
|
* @return {?}
|
12770
|
*/
|
12771
|
function debugCheckNoChangesNode(view, nodeDef, argStyle, values) {
|
12772
|
((checkNoChangesNode))(view, nodeDef, argStyle, ...values);
|
12773
|
}
|
12774
|
/**
|
12775
|
* @param {?} name
|
12776
|
* @return {?}
|
12777
|
*/
|
12778
|
function normalizeDebugBindingName(name) {
|
12779
|
// Attribute names with `$` (eg `x-y$`) are valid per spec, but unsupported by some browsers
|
12780
|
name = camelCaseToDashCase(name.replace(/[$@]/g, '_'));
|
12781
|
return `ng-reflect-${name}`;
|
12782
|
}
|
12783
|
const CAMEL_CASE_REGEXP = /([A-Z])/g;
|
12784
|
/**
|
12785
|
* @param {?} input
|
12786
|
* @return {?}
|
12787
|
*/
|
12788
|
function camelCaseToDashCase(input) {
|
12789
|
return input.replace(CAMEL_CASE_REGEXP, (...m) => '-' + m[1].toLowerCase());
|
12790
|
}
|
12791
|
/**
|
12792
|
* @param {?} value
|
12793
|
* @return {?}
|
12794
|
*/
|
12795
|
function normalizeDebugBindingValue(value) {
|
12796
|
try {
|
12797
|
// Limit the size of the value as otherwise the DOM just gets polluted.
|
12798
|
return value != null ? value.toString().slice(0, 30) : value;
|
12799
|
}
|
12800
|
catch (e) {
|
12801
|
return '[ERROR] Exception while trying to serialize the value';
|
12802
|
}
|
12803
|
}
|
12804
|
/**
|
12805
|
* @param {?} view
|
12806
|
* @param {?} nodeIndex
|
12807
|
* @return {?}
|
12808
|
*/
|
12809
|
function nextDirectiveWithBinding(view, nodeIndex) {
|
12810
|
for (let /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
|
12811
|
const /** @type {?} */ nodeDef = view.def.nodes[i];
|
12812
|
if (nodeDef.flags & 16384 /* TypeDirective */ && nodeDef.bindings && nodeDef.bindings.length) {
|
12813
|
return i;
|
12814
|
}
|
12815
|
}
|
12816
|
return null;
|
12817
|
}
|
12818
|
/**
|
12819
|
* @param {?} view
|
12820
|
* @param {?} nodeIndex
|
12821
|
* @return {?}
|
12822
|
*/
|
12823
|
function nextRenderNodeWithBinding(view, nodeIndex) {
|
12824
|
for (let /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
|
12825
|
const /** @type {?} */ nodeDef = view.def.nodes[i];
|
12826
|
if ((nodeDef.flags & 3 /* CatRenderNode */) && nodeDef.bindings && nodeDef.bindings.length) {
|
12827
|
return i;
|
12828
|
}
|
12829
|
}
|
12830
|
return null;
|
12831
|
}
|
12832
|
class DebugContext_ {
|
12833
|
/**
|
12834
|
* @param {?} view
|
12835
|
* @param {?} nodeIndex
|
12836
|
*/
|
12837
|
constructor(view, nodeIndex) {
|
12838
|
this.view = view;
|
12839
|
this.nodeIndex = nodeIndex;
|
12840
|
if (nodeIndex == null) {
|
12841
|
this.nodeIndex = nodeIndex = 0;
|
12842
|
}
|
12843
|
this.nodeDef = view.def.nodes[nodeIndex];
|
12844
|
let elDef = this.nodeDef;
|
12845
|
let elView = view;
|
12846
|
while (elDef && (elDef.flags & 1 /* TypeElement */) === 0) {
|
12847
|
elDef = elDef.parent;
|
12848
|
}
|
12849
|
if (!elDef) {
|
12850
|
while (!elDef && elView) {
|
12851
|
elDef = viewParentEl(elView);
|
12852
|
elView = elView.parent;
|
12853
|
}
|
12854
|
}
|
12855
|
this.elDef = elDef;
|
12856
|
this.elView = elView;
|
12857
|
}
|
12858
|
/**
|
12859
|
* @return {?}
|
12860
|
*/
|
12861
|
get elOrCompView() {
|
12862
|
// Has to be done lazily as we use the DebugContext also during creation of elements...
|
12863
|
return asElementData(this.elView, this.elDef.nodeIndex).componentView || this.view;
|
12864
|
}
|
12865
|
/**
|
12866
|
* @return {?}
|
12867
|
*/
|
12868
|
get injector() { return createInjector(this.elView, this.elDef); }
|
12869
|
/**
|
12870
|
* @return {?}
|
12871
|
*/
|
12872
|
get component() { return this.elOrCompView.component; }
|
12873
|
/**
|
12874
|
* @return {?}
|
12875
|
*/
|
12876
|
get context() { return this.elOrCompView.context; }
|
12877
|
/**
|
12878
|
* @return {?}
|
12879
|
*/
|
12880
|
get providerTokens() {
|
12881
|
const /** @type {?} */ tokens = [];
|
12882
|
if (this.elDef) {
|
12883
|
for (let /** @type {?} */ i = this.elDef.nodeIndex + 1; i <= this.elDef.nodeIndex + this.elDef.childCount; i++) {
|
12884
|
const /** @type {?} */ childDef = this.elView.def.nodes[i];
|
12885
|
if (childDef.flags & 20224 /* CatProvider */) {
|
12886
|
tokens.push(/** @type {?} */ ((childDef.provider)).token);
|
12887
|
}
|
12888
|
i += childDef.childCount;
|
12889
|
}
|
12890
|
}
|
12891
|
return tokens;
|
12892
|
}
|
12893
|
/**
|
12894
|
* @return {?}
|
12895
|
*/
|
12896
|
get references() {
|
12897
|
const /** @type {?} */ references = {};
|
12898
|
if (this.elDef) {
|
12899
|
collectReferences(this.elView, this.elDef, references);
|
12900
|
for (let /** @type {?} */ i = this.elDef.nodeIndex + 1; i <= this.elDef.nodeIndex + this.elDef.childCount; i++) {
|
12901
|
const /** @type {?} */ childDef = this.elView.def.nodes[i];
|
12902
|
if (childDef.flags & 20224 /* CatProvider */) {
|
12903
|
collectReferences(this.elView, childDef, references);
|
12904
|
}
|
12905
|
i += childDef.childCount;
|
12906
|
}
|
12907
|
}
|
12908
|
return references;
|
12909
|
}
|
12910
|
/**
|
12911
|
* @return {?}
|
12912
|
*/
|
12913
|
get componentRenderElement() {
|
12914
|
const /** @type {?} */ elData = findHostElement(this.elOrCompView);
|
12915
|
return elData ? elData.renderElement : undefined;
|
12916
|
}
|
12917
|
/**
|
12918
|
* @return {?}
|
12919
|
*/
|
12920
|
get renderNode() {
|
12921
|
return this.nodeDef.flags & 2 /* TypeText */ ? renderNode(this.view, this.nodeDef) :
|
12922
|
renderNode(this.elView, this.elDef);
|
12923
|
}
|
12924
|
/**
|
12925
|
* @param {?} console
|
12926
|
* @param {...?} values
|
12927
|
* @return {?}
|
12928
|
*/
|
12929
|
logError(console, ...values) {
|
12930
|
let /** @type {?} */ logViewDef;
|
12931
|
let /** @type {?} */ logNodeIndex;
|
12932
|
if (this.nodeDef.flags & 2 /* TypeText */) {
|
12933
|
logViewDef = this.view.def;
|
12934
|
logNodeIndex = this.nodeDef.nodeIndex;
|
12935
|
}
|
12936
|
else {
|
12937
|
logViewDef = this.elView.def;
|
12938
|
logNodeIndex = this.elDef.nodeIndex;
|
12939
|
}
|
12940
|
// Note: we only generate a log function for text and element nodes
|
12941
|
// to make the generated code as small as possible.
|
12942
|
const /** @type {?} */ renderNodeIndex = getRenderNodeIndex(logViewDef, logNodeIndex);
|
12943
|
let /** @type {?} */ currRenderNodeIndex = -1;
|
12944
|
let /** @type {?} */ nodeLogger = () => {
|
12945
|
currRenderNodeIndex++;
|
12946
|
if (currRenderNodeIndex === renderNodeIndex) {
|
12947
|
return console.error.bind(console, ...values);
|
12948
|
}
|
12949
|
else {
|
12950
|
return NOOP;
|
12951
|
}
|
12952
|
}; /** @type {?} */
|
12953
|
((logViewDef.factory))(nodeLogger);
|
12954
|
if (currRenderNodeIndex < renderNodeIndex) {
|
12955
|
console.error('Illegal state: the ViewDefinitionFactory did not call the logger!');
|
12956
|
((console.error))(...values);
|
12957
|
}
|
12958
|
}
|
12959
|
}
|
12960
|
/**
|
12961
|
* @param {?} viewDef
|
12962
|
* @param {?} nodeIndex
|
12963
|
* @return {?}
|
12964
|
*/
|
12965
|
function getRenderNodeIndex(viewDef$$1, nodeIndex) {
|
12966
|
let /** @type {?} */ renderNodeIndex = -1;
|
12967
|
for (let /** @type {?} */ i = 0; i <= nodeIndex; i++) {
|
12968
|
const /** @type {?} */ nodeDef = viewDef$$1.nodes[i];
|
12969
|
if (nodeDef.flags & 3 /* CatRenderNode */) {
|
12970
|
renderNodeIndex++;
|
12971
|
}
|
12972
|
}
|
12973
|
return renderNodeIndex;
|
12974
|
}
|
12975
|
/**
|
12976
|
* @param {?} view
|
12977
|
* @return {?}
|
12978
|
*/
|
12979
|
function findHostElement(view) {
|
12980
|
while (view && !isComponentView(view)) {
|
12981
|
view = ((view.parent));
|
12982
|
}
|
12983
|
if (view.parent) {
|
12984
|
return asElementData(view.parent, /** @type {?} */ ((viewParentEl(view))).nodeIndex);
|
12985
|
}
|
12986
|
return null;
|
12987
|
}
|
12988
|
/**
|
12989
|
* @param {?} view
|
12990
|
* @param {?} nodeDef
|
12991
|
* @param {?} references
|
12992
|
* @return {?}
|
12993
|
*/
|
12994
|
function collectReferences(view, nodeDef, references) {
|
12995
|
for (let /** @type {?} */ refName in nodeDef.references) {
|
12996
|
references[refName] = getQueryValue(view, nodeDef, nodeDef.references[refName]);
|
12997
|
}
|
12998
|
}
|
12999
|
/**
|
13000
|
* @param {?} action
|
13001
|
* @param {?} fn
|
13002
|
* @param {?} self
|
13003
|
* @param {?} args
|
13004
|
* @return {?}
|
13005
|
*/
|
13006
|
function callWithDebugContext(action, fn, self, args) {
|
13007
|
const /** @type {?} */ oldAction = _currentAction;
|
13008
|
const /** @type {?} */ oldView = _currentView;
|
13009
|
const /** @type {?} */ oldNodeIndex = _currentNodeIndex;
|
13010
|
try {
|
13011
|
_currentAction = action;
|
13012
|
const /** @type {?} */ result = fn.apply(self, args);
|
13013
|
_currentView = oldView;
|
13014
|
_currentNodeIndex = oldNodeIndex;
|
13015
|
_currentAction = oldAction;
|
13016
|
return result;
|
13017
|
}
|
13018
|
catch (e) {
|
13019
|
if (isViewDebugError(e) || !_currentView) {
|
13020
|
throw e;
|
13021
|
}
|
13022
|
throw viewWrappedDebugError(e, /** @type {?} */ ((getCurrentDebugContext())));
|
13023
|
}
|
13024
|
}
|
13025
|
/**
|
13026
|
* @return {?}
|
13027
|
*/
|
13028
|
function getCurrentDebugContext() {
|
13029
|
return _currentView ? new DebugContext_(_currentView, _currentNodeIndex) : null;
|
13030
|
}
|
13031
|
class DebugRendererFactory2 {
|
13032
|
/**
|
13033
|
* @param {?} delegate
|
13034
|
*/
|
13035
|
constructor(delegate) {
|
13036
|
this.delegate = delegate;
|
13037
|
}
|
13038
|
/**
|
13039
|
* @param {?} element
|
13040
|
* @param {?} renderData
|
13041
|
* @return {?}
|
13042
|
*/
|
13043
|
createRenderer(element, renderData) {
|
13044
|
return new DebugRenderer2(this.delegate.createRenderer(element, renderData));
|
13045
|
}
|
13046
|
/**
|
13047
|
* @return {?}
|
13048
|
*/
|
13049
|
begin() {
|
13050
|
if (this.delegate.begin) {
|
13051
|
this.delegate.begin();
|
13052
|
}
|
13053
|
}
|
13054
|
/**
|
13055
|
* @return {?}
|
13056
|
*/
|
13057
|
end() {
|
13058
|
if (this.delegate.end) {
|
13059
|
this.delegate.end();
|
13060
|
}
|
13061
|
}
|
13062
|
/**
|
13063
|
* @return {?}
|
13064
|
*/
|
13065
|
whenRenderingDone() {
|
13066
|
if (this.delegate.whenRenderingDone) {
|
13067
|
return this.delegate.whenRenderingDone();
|
13068
|
}
|
13069
|
return Promise.resolve(null);
|
13070
|
}
|
13071
|
}
|
13072
|
class DebugRenderer2 {
|
13073
|
/**
|
13074
|
* @param {?} delegate
|
13075
|
*/
|
13076
|
constructor(delegate) {
|
13077
|
this.delegate = delegate;
|
13078
|
}
|
13079
|
/**
|
13080
|
* @return {?}
|
13081
|
*/
|
13082
|
get data() { return this.delegate.data; }
|
13083
|
/**
|
13084
|
* @param {?} node
|
13085
|
* @return {?}
|
13086
|
*/
|
13087
|
destroyNode(node) {
|
13088
|
removeDebugNodeFromIndex(/** @type {?} */ ((getDebugNode(node))));
|
13089
|
if (this.delegate.destroyNode) {
|
13090
|
this.delegate.destroyNode(node);
|
13091
|
}
|
13092
|
}
|
13093
|
/**
|
13094
|
* @return {?}
|
13095
|
*/
|
13096
|
destroy() { this.delegate.destroy(); }
|
13097
|
/**
|
13098
|
* @param {?} name
|
13099
|
* @param {?=} namespace
|
13100
|
* @return {?}
|
13101
|
*/
|
13102
|
createElement(name, namespace) {
|
13103
|
const /** @type {?} */ el = this.delegate.createElement(name, namespace);
|
13104
|
const /** @type {?} */ debugCtx = getCurrentDebugContext();
|
13105
|
if (debugCtx) {
|
13106
|
const /** @type {?} */ debugEl = new DebugElement(el, null, debugCtx);
|
13107
|
debugEl.name = name;
|
13108
|
indexDebugNode(debugEl);
|
13109
|
}
|
13110
|
return el;
|
13111
|
}
|
13112
|
/**
|
13113
|
* @param {?} value
|
13114
|
* @return {?}
|
13115
|
*/
|
13116
|
createComment(value) {
|
13117
|
const /** @type {?} */ comment = this.delegate.createComment(value);
|
13118
|
const /** @type {?} */ debugCtx = getCurrentDebugContext();
|
13119
|
if (debugCtx) {
|
13120
|
indexDebugNode(new DebugNode(comment, null, debugCtx));
|
13121
|
}
|
13122
|
return comment;
|
13123
|
}
|
13124
|
/**
|
13125
|
* @param {?} value
|
13126
|
* @return {?}
|
13127
|
*/
|
13128
|
createText(value) {
|
13129
|
const /** @type {?} */ text = this.delegate.createText(value);
|
13130
|
const /** @type {?} */ debugCtx = getCurrentDebugContext();
|
13131
|
if (debugCtx) {
|
13132
|
indexDebugNode(new DebugNode(text, null, debugCtx));
|
13133
|
}
|
13134
|
return text;
|
13135
|
}
|
13136
|
/**
|
13137
|
* @param {?} parent
|
13138
|
* @param {?} newChild
|
13139
|
* @return {?}
|
13140
|
*/
|
13141
|
appendChild(parent, newChild) {
|
13142
|
const /** @type {?} */ debugEl = getDebugNode(parent);
|
13143
|
const /** @type {?} */ debugChildEl = getDebugNode(newChild);
|
13144
|
if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
|
13145
|
debugEl.addChild(debugChildEl);
|
13146
|
}
|
13147
|
this.delegate.appendChild(parent, newChild);
|
13148
|
}
|
13149
|
/**
|
13150
|
* @param {?} parent
|
13151
|
* @param {?} newChild
|
13152
|
* @param {?} refChild
|
13153
|
* @return {?}
|
13154
|
*/
|
13155
|
insertBefore(parent, newChild, refChild) {
|
13156
|
const /** @type {?} */ debugEl = getDebugNode(parent);
|
13157
|
const /** @type {?} */ debugChildEl = getDebugNode(newChild);
|
13158
|
const /** @type {?} */ debugRefEl = ((getDebugNode(refChild)));
|
13159
|
if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
|
13160
|
debugEl.insertBefore(debugRefEl, debugChildEl);
|
13161
|
}
|
13162
|
this.delegate.insertBefore(parent, newChild, refChild);
|
13163
|
}
|
13164
|
/**
|
13165
|
* @param {?} parent
|
13166
|
* @param {?} oldChild
|
13167
|
* @return {?}
|
13168
|
*/
|
13169
|
removeChild(parent, oldChild) {
|
13170
|
const /** @type {?} */ debugEl = getDebugNode(parent);
|
13171
|
const /** @type {?} */ debugChildEl = getDebugNode(oldChild);
|
13172
|
if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
|
13173
|
debugEl.removeChild(debugChildEl);
|
13174
|
}
|
13175
|
this.delegate.removeChild(parent, oldChild);
|
13176
|
}
|
13177
|
/**
|
13178
|
* @param {?} selectorOrNode
|
13179
|
* @return {?}
|
13180
|
*/
|
13181
|
selectRootElement(selectorOrNode) {
|
13182
|
const /** @type {?} */ el = this.delegate.selectRootElement(selectorOrNode);
|
13183
|
const /** @type {?} */ debugCtx = getCurrentDebugContext();
|
13184
|
if (debugCtx) {
|
13185
|
indexDebugNode(new DebugElement(el, null, debugCtx));
|
13186
|
}
|
13187
|
return el;
|
13188
|
}
|
13189
|
/**
|
13190
|
* @param {?} el
|
13191
|
* @param {?} name
|
13192
|
* @param {?} value
|
13193
|
* @param {?=} namespace
|
13194
|
* @return {?}
|
13195
|
*/
|
13196
|
setAttribute(el, name, value, namespace) {
|
13197
|
const /** @type {?} */ debugEl = getDebugNode(el);
|
13198
|
if (debugEl && debugEl instanceof DebugElement) {
|
13199
|
const /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
|
13200
|
debugEl.attributes[fullName] = value;
|
13201
|
}
|
13202
|
this.delegate.setAttribute(el, name, value, namespace);
|
13203
|
}
|
13204
|
/**
|
13205
|
* @param {?} el
|
13206
|
* @param {?} name
|
13207
|
* @param {?=} namespace
|
13208
|
* @return {?}
|
13209
|
*/
|
13210
|
removeAttribute(el, name, namespace) {
|
13211
|
const /** @type {?} */ debugEl = getDebugNode(el);
|
13212
|
if (debugEl && debugEl instanceof DebugElement) {
|
13213
|
const /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
|
13214
|
debugEl.attributes[fullName] = null;
|
13215
|
}
|
13216
|
this.delegate.removeAttribute(el, name, namespace);
|
13217
|
}
|
13218
|
/**
|
13219
|
* @param {?} el
|
13220
|
* @param {?} name
|
13221
|
* @return {?}
|
13222
|
*/
|
13223
|
addClass(el, name) {
|
13224
|
const /** @type {?} */ debugEl = getDebugNode(el);
|
13225
|
if (debugEl && debugEl instanceof DebugElement) {
|
13226
|
debugEl.classes[name] = true;
|
13227
|
}
|
13228
|
this.delegate.addClass(el, name);
|
13229
|
}
|
13230
|
/**
|
13231
|
* @param {?} el
|
13232
|
* @param {?} name
|
13233
|
* @return {?}
|
13234
|
*/
|
13235
|
removeClass(el, name) {
|
13236
|
const /** @type {?} */ debugEl = getDebugNode(el);
|
13237
|
if (debugEl && debugEl instanceof DebugElement) {
|
13238
|
debugEl.classes[name] = false;
|
13239
|
}
|
13240
|
this.delegate.removeClass(el, name);
|
13241
|
}
|
13242
|
/**
|
13243
|
* @param {?} el
|
13244
|
* @param {?} style
|
13245
|
* @param {?} value
|
13246
|
* @param {?} flags
|
13247
|
* @return {?}
|
13248
|
*/
|
13249
|
setStyle(el, style, value, flags) {
|
13250
|
const /** @type {?} */ debugEl = getDebugNode(el);
|
13251
|
if (debugEl && debugEl instanceof DebugElement) {
|
13252
|
debugEl.styles[style] = value;
|
13253
|
}
|
13254
|
this.delegate.setStyle(el, style, value, flags);
|
13255
|
}
|
13256
|
/**
|
13257
|
* @param {?} el
|
13258
|
* @param {?} style
|
13259
|
* @param {?} flags
|
13260
|
* @return {?}
|
13261
|
*/
|
13262
|
removeStyle(el, style, flags) {
|
13263
|
const /** @type {?} */ debugEl = getDebugNode(el);
|
13264
|
if (debugEl && debugEl instanceof DebugElement) {
|
13265
|
debugEl.styles[style] = null;
|
13266
|
}
|
13267
|
this.delegate.removeStyle(el, style, flags);
|
13268
|
}
|
13269
|
/**
|
13270
|
* @param {?} el
|
13271
|
* @param {?} name
|
13272
|
* @param {?} value
|
13273
|
* @return {?}
|
13274
|
*/
|
13275
|
setProperty(el, name, value) {
|
13276
|
const /** @type {?} */ debugEl = getDebugNode(el);
|
13277
|
if (debugEl && debugEl instanceof DebugElement) {
|
13278
|
debugEl.properties[name] = value;
|
13279
|
}
|
13280
|
this.delegate.setProperty(el, name, value);
|
13281
|
}
|
13282
|
/**
|
13283
|
* @param {?} target
|
13284
|
* @param {?} eventName
|
13285
|
* @param {?} callback
|
13286
|
* @return {?}
|
13287
|
*/
|
13288
|
listen(target, eventName, callback) {
|
13289
|
if (typeof target !== 'string') {
|
13290
|
const /** @type {?} */ debugEl = getDebugNode(target);
|
13291
|
if (debugEl) {
|
13292
|
debugEl.listeners.push(new EventListener(eventName, callback));
|
13293
|
}
|
13294
|
}
|
13295
|
return this.delegate.listen(target, eventName, callback);
|
13296
|
}
|
13297
|
/**
|
13298
|
* @param {?} node
|
13299
|
* @return {?}
|
13300
|
*/
|
13301
|
parentNode(node) { return this.delegate.parentNode(node); }
|
13302
|
/**
|
13303
|
* @param {?} node
|
13304
|
* @return {?}
|
13305
|
*/
|
13306
|
nextSibling(node) { return this.delegate.nextSibling(node); }
|
13307
|
/**
|
13308
|
* @param {?} node
|
13309
|
* @param {?} value
|
13310
|
* @return {?}
|
13311
|
*/
|
13312
|
setValue(node, value) { return this.delegate.setValue(node, value); }
|
13313
|
}
|
13314
|
|
13315
|
/**
|
13316
|
* @license
|
13317
|
* Copyright Google Inc. All Rights Reserved.
|
13318
|
*
|
13319
|
* Use of this source code is governed by an MIT-style license that can be
|
13320
|
* found in the LICENSE file at https://angular.io/license
|
13321
|
*/
|
13322
|
/**
|
13323
|
* @param {?} override
|
13324
|
* @return {?}
|
13325
|
*/
|
13326
|
function overrideProvider(override) {
|
13327
|
initServicesIfNeeded();
|
13328
|
return Services.overrideProvider(override);
|
13329
|
}
|
13330
|
/**
|
13331
|
* @return {?}
|
13332
|
*/
|
13333
|
function clearProviderOverrides() {
|
13334
|
initServicesIfNeeded();
|
13335
|
return Services.clearProviderOverrides();
|
13336
|
}
|
13337
|
/**
|
13338
|
* @param {?} ngModuleType
|
13339
|
* @param {?} bootstrapComponents
|
13340
|
* @param {?} defFactory
|
13341
|
* @return {?}
|
13342
|
*/
|
13343
|
function createNgModuleFactory(ngModuleType, bootstrapComponents, defFactory) {
|
13344
|
return new NgModuleFactory_(ngModuleType, bootstrapComponents, defFactory);
|
13345
|
}
|
13346
|
class NgModuleFactory_ extends NgModuleFactory {
|
13347
|
/**
|
13348
|
* @param {?} moduleType
|
13349
|
* @param {?} _bootstrapComponents
|
13350
|
* @param {?} _ngModuleDefFactory
|
13351
|
*/
|
13352
|
constructor(moduleType, _bootstrapComponents, _ngModuleDefFactory) {
|
13353
|
// Attention: this ctor is called as top level function.
|
13354
|
// Putting any logic in here will destroy closure tree shaking!
|
13355
|
super();
|
13356
|
this.moduleType = moduleType;
|
13357
|
this._bootstrapComponents = _bootstrapComponents;
|
13358
|
this._ngModuleDefFactory = _ngModuleDefFactory;
|
13359
|
}
|
13360
|
/**
|
13361
|
* @param {?} parentInjector
|
13362
|
* @return {?}
|
13363
|
*/
|
13364
|
create(parentInjector) {
|
13365
|
initServicesIfNeeded();
|
13366
|
const /** @type {?} */ def = resolveDefinition(this._ngModuleDefFactory);
|
13367
|
return Services.createNgModuleRef(this.moduleType, parentInjector || Injector.NULL, this._bootstrapComponents, def);
|
13368
|
}
|
13369
|
}
|
13370
|
|
13371
|
/**
|
13372
|
* @license
|
13373
|
* Copyright Google Inc. All Rights Reserved.
|
13374
|
*
|
13375
|
* Use of this source code is governed by an MIT-style license that can be
|
13376
|
* found in the LICENSE file at https://angular.io/license
|
13377
|
*/
|
13378
|
|
13379
|
/**
|
13380
|
* @license
|
13381
|
* Copyright Google Inc. All Rights Reserved.
|
13382
|
*
|
13383
|
* Use of this source code is governed by an MIT-style license that can be
|
13384
|
* found in the LICENSE file at https://angular.io/license
|
13385
|
*/
|
13386
|
|
13387
|
/**
|
13388
|
* @license
|
13389
|
* Copyright Google Inc. All Rights Reserved.
|
13390
|
*
|
13391
|
* Use of this source code is governed by an MIT-style license that can be
|
13392
|
* found in the LICENSE file at https://angular.io/license
|
13393
|
*/
|
13394
|
|
13395
|
/**
|
13396
|
* \@experimental Animation support is experimental.
|
13397
|
*/
|
13398
|
|
13399
|
/**
|
13400
|
* `trigger` is an animation-specific function that is designed to be used inside of Angular's
|
13401
|
* animation DSL language. If this information is new, please navigate to the
|
13402
|
* {\@link Component#animations component animations metadata page} to gain a better
|
13403
|
* understanding of how animations in Angular are used.
|
13404
|
*
|
13405
|
* `trigger` Creates an animation trigger which will a list of {\@link state state} and
|
13406
|
* {\@link transition transition} entries that will be evaluated when the expression
|
13407
|
* bound to the trigger changes.
|
13408
|
*
|
13409
|
* Triggers are registered within the component annotation data under the
|
13410
|
* {\@link Component#animations animations section}. An animation trigger can be placed on an element
|
13411
|
* within a template by referencing the name of the trigger followed by the expression value that
|
13412
|
* the
|
13413
|
* trigger is bound to (in the form of `[\@triggerName]="expression"`.
|
13414
|
*
|
13415
|
* Animation trigger bindings strigify values and then match the previous and current values against
|
13416
|
* any linked transitions. If a boolean value is provided into the trigger binding then it will both
|
13417
|
* be represented as `1` or `true` and `0` or `false` for a true and false boolean values
|
13418
|
* respectively.
|
13419
|
*
|
13420
|
* ### Usage
|
13421
|
*
|
13422
|
* `trigger` will create an animation trigger reference based on the provided `name` value. The
|
13423
|
* provided `animation` value is expected to be an array consisting of {\@link state state} and
|
13424
|
* {\@link transition transition} declarations.
|
13425
|
*
|
13426
|
* ```typescript
|
13427
|
* \@Component({
|
13428
|
* selector: 'my-component',
|
13429
|
* templateUrl: 'my-component-tpl.html',
|
13430
|
* animations: [
|
13431
|
* trigger("myAnimationTrigger", [
|
13432
|
* state(...),
|
13433
|
* state(...),
|
13434
|
* transition(...),
|
13435
|
* transition(...)
|
13436
|
* ])
|
13437
|
* ]
|
13438
|
* })
|
13439
|
* class MyComponent {
|
13440
|
* myStatusExp = "something";
|
13441
|
* }
|
13442
|
* ```
|
13443
|
*
|
13444
|
* The template associated with this component will make use of the `myAnimationTrigger` animation
|
13445
|
* trigger by binding to an element within its template code.
|
13446
|
*
|
13447
|
* ```html
|
13448
|
* <!-- somewhere inside of my-component-tpl.html -->
|
13449
|
* <div [\@myAnimationTrigger]="myStatusExp">...</div>
|
13450
|
* ```
|
13451
|
*
|
13452
|
* ## Disable Animations
|
13453
|
* A special animation control binding called `\@.disabled` can be placed on an element which will
|
13454
|
* then disable animations for any inner animation triggers situated within the element as well as
|
13455
|
* any animations on the element itself.
|
13456
|
*
|
13457
|
* When true, the `\@.disabled` binding will prevent all animations from rendering. The example
|
13458
|
* below shows how to use this feature:
|
13459
|
*
|
13460
|
* ```ts
|
13461
|
* \@Component({
|
13462
|
* selector: 'my-component',
|
13463
|
* template: `
|
13464
|
* <div [\@.disabled]="isDisabled">
|
13465
|
* <div [\@childAnimation]="exp"></div>
|
13466
|
* </div>
|
13467
|
* `,
|
13468
|
* animations: [
|
13469
|
* trigger("childAnimation", [
|
13470
|
* // ...
|
13471
|
* ])
|
13472
|
* ]
|
13473
|
* })
|
13474
|
* class MyComponent {
|
13475
|
* isDisabled = true;
|
13476
|
* exp = '...';
|
13477
|
* }
|
13478
|
* ```
|
13479
|
*
|
13480
|
* The `\@childAnimation` trigger will not animate because `\@.disabled` prevents it from happening
|
13481
|
* (when true).
|
13482
|
*
|
13483
|
* Note that `\@.disbled` will only disable all animations (this means any animations running on
|
13484
|
* the same element will also be disabled).
|
13485
|
*
|
13486
|
* ### Disabling Animations Application-wide
|
13487
|
* When an area of the template is set to have animations disabled, **all** inner components will
|
13488
|
* also have their animations disabled as well. This means that all animations for an angular
|
13489
|
* application can be disabled by placing a host binding set on `\@.disabled` on the topmost Angular
|
13490
|
* component.
|
13491
|
*
|
13492
|
* ```ts
|
13493
|
* import {Component, HostBinding} from '\@angular/core';
|
13494
|
*
|
13495
|
* \@Component({
|
13496
|
* selector: 'app-component',
|
13497
|
* templateUrl: 'app.component.html',
|
13498
|
* })
|
13499
|
* class AppComponent {
|
13500
|
* \@HostBinding('\@.disabled')
|
13501
|
* public animationsDisabled = true;
|
13502
|
* }
|
13503
|
* ```
|
13504
|
*
|
13505
|
* ### What about animations that us `query()` and `animateChild()`?
|
13506
|
* Despite inner animations being disabled, a parent animation can {\@link query query} for inner
|
13507
|
* elements located in disabled areas of the template and still animate them as it sees fit. This is
|
13508
|
* also the case for when a sub animation is queried by a parent and then later animated using {\@link
|
13509
|
* animateChild animateChild}.
|
13510
|
*
|
13511
|
* \@experimental Animation support is experimental.
|
13512
|
* @param {?} name
|
13513
|
* @param {?} definitions
|
13514
|
* @return {?}
|
13515
|
*/
|
13516
|
function trigger$1(name, definitions) {
|
13517
|
return { type: 7 /* Trigger */, name, definitions, options: {} };
|
13518
|
}
|
13519
|
/**
|
13520
|
* `animate` is an animation-specific function that is designed to be used inside of Angular's
|
13521
|
* animation DSL language. If this information is new, please navigate to the {\@link
|
13522
|
* Component#animations component animations metadata page} to gain a better understanding of
|
13523
|
* how animations in Angular are used.
|
13524
|
*
|
13525
|
* `animate` specifies an animation step that will apply the provided `styles` data for a given
|
13526
|
* amount of time based on the provided `timing` expression value. Calls to `animate` are expected
|
13527
|
* to be used within {\@link sequence an animation sequence}, {\@link group group}, or {\@link
|
13528
|
* transition transition}.
|
13529
|
*
|
13530
|
* ### Usage
|
13531
|
*
|
13532
|
* The `animate` function accepts two input parameters: `timing` and `styles`:
|
13533
|
*
|
13534
|
* - `timing` is a string based value that can be a combination of a duration with optional delay
|
13535
|
* and easing values. The format for the expression breaks down to `duration delay easing`
|
13536
|
* (therefore a value such as `1s 100ms ease-out` will be parse itself into `duration=1000,
|
13537
|
* delay=100, easing=ease-out`. If a numeric value is provided then that will be used as the
|
13538
|
* `duration` value in millisecond form.
|
13539
|
* - `styles` is the style input data which can either be a call to {\@link style style} or {\@link
|
13540
|
* keyframes keyframes}. If left empty then the styles from the destination state will be collected
|
13541
|
* and used (this is useful when describing an animation step that will complete an animation by
|
13542
|
* {\@link transition#the-final-animate-call animating to the final state}).
|
13543
|
*
|
13544
|
* ```typescript
|
13545
|
* // various functions for specifying timing data
|
13546
|
* animate(500, style(...))
|
13547
|
* animate("1s", style(...))
|
13548
|
* animate("100ms 0.5s", style(...))
|
13549
|
* animate("5s ease", style(...))
|
13550
|
* animate("5s 10ms cubic-bezier(.17,.67,.88,.1)", style(...))
|
13551
|
*
|
13552
|
* // either style() of keyframes() can be used
|
13553
|
* animate(500, style({ background: "red" }))
|
13554
|
* animate(500, keyframes([
|
13555
|
* style({ background: "blue" })),
|
13556
|
* style({ background: "red" }))
|
13557
|
* ])
|
13558
|
* ```
|
13559
|
*
|
13560
|
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
13561
|
*
|
13562
|
* \@experimental Animation support is experimental.
|
13563
|
* @param {?} timings
|
13564
|
* @param {?=} styles
|
13565
|
* @return {?}
|
13566
|
*/
|
13567
|
function animate$1(timings, styles = null) {
|
13568
|
return { type: 4 /* Animate */, styles, timings };
|
13569
|
}
|
13570
|
/**
|
13571
|
* `group` is an animation-specific function that is designed to be used inside of Angular's
|
13572
|
* animation DSL language. If this information is new, please navigate to the {\@link
|
13573
|
* Component#animations component animations metadata page} to gain a better understanding of
|
13574
|
* how animations in Angular are used.
|
13575
|
*
|
13576
|
* `group` specifies a list of animation steps that are all run in parallel. Grouped animations are
|
13577
|
* useful when a series of styles must be animated/closed off at different starting/ending times.
|
13578
|
*
|
13579
|
* The `group` function can either be used within a {\@link sequence sequence} or a {\@link transition
|
13580
|
* transition} and it will only continue to the next instruction once all of the inner animation
|
13581
|
* steps have completed.
|
13582
|
*
|
13583
|
* ### Usage
|
13584
|
*
|
13585
|
* The `steps` data that is passed into the `group` animation function can either consist of {\@link
|
13586
|
* style style} or {\@link animate animate} function calls. Each call to `style()` or `animate()`
|
13587
|
* within a group will be executed instantly (use {\@link keyframes keyframes} or a {\@link
|
13588
|
* animate#usage animate() with a delay value} to offset styles to be applied at a later time).
|
13589
|
*
|
13590
|
* ```typescript
|
13591
|
* group([
|
13592
|
* animate("1s", { background: "black" }))
|
13593
|
* animate("2s", { color: "white" }))
|
13594
|
* ])
|
13595
|
* ```
|
13596
|
*
|
13597
|
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
13598
|
*
|
13599
|
* \@experimental Animation support is experimental.
|
13600
|
* @param {?} steps
|
13601
|
* @param {?=} options
|
13602
|
* @return {?}
|
13603
|
*/
|
13604
|
function group$1(steps, options = null) {
|
13605
|
return { type: 3 /* Group */, steps, options };
|
13606
|
}
|
13607
|
/**
|
13608
|
* `sequence` is an animation-specific function that is designed to be used inside of Angular's
|
13609
|
* animation DSL language. If this information is new, please navigate to the {\@link
|
13610
|
* Component#animations component animations metadata page} to gain a better understanding of
|
13611
|
* how animations in Angular are used.
|
13612
|
*
|
13613
|
* `sequence` Specifies a list of animation steps that are run one by one. (`sequence` is used by
|
13614
|
* default when an array is passed as animation data into {\@link transition transition}.)
|
13615
|
*
|
13616
|
* The `sequence` function can either be used within a {\@link group group} or a {\@link transition
|
13617
|
* transition} and it will only continue to the next instruction once each of the inner animation
|
13618
|
* steps have completed.
|
13619
|
*
|
13620
|
* To perform animation styling in parallel with other animation steps then have a look at the
|
13621
|
* {\@link group group} animation function.
|
13622
|
*
|
13623
|
* ### Usage
|
13624
|
*
|
13625
|
* The `steps` data that is passed into the `sequence` animation function can either consist of
|
13626
|
* {\@link style style} or {\@link animate animate} function calls. A call to `style()` will apply the
|
13627
|
* provided styling data immediately while a call to `animate()` will apply its styling data over a
|
13628
|
* given time depending on its timing data.
|
13629
|
*
|
13630
|
* ```typescript
|
13631
|
* sequence([
|
13632
|
* style({ opacity: 0 })),
|
13633
|
* animate("1s", { opacity: 1 }))
|
13634
|
* ])
|
13635
|
* ```
|
13636
|
*
|
13637
|
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
13638
|
*
|
13639
|
* \@experimental Animation support is experimental.
|
13640
|
* @param {?} steps
|
13641
|
* @param {?=} options
|
13642
|
* @return {?}
|
13643
|
*/
|
13644
|
function sequence$1(steps, options = null) {
|
13645
|
return { type: 2 /* Sequence */, steps, options };
|
13646
|
}
|
13647
|
/**
|
13648
|
* `style` is an animation-specific function that is designed to be used inside of Angular's
|
13649
|
* animation DSL language. If this information is new, please navigate to the {\@link
|
13650
|
* Component#animations component animations metadata page} to gain a better understanding of
|
13651
|
* how animations in Angular are used.
|
13652
|
*
|
13653
|
* `style` declares a key/value object containing CSS properties/styles that can then be used for
|
13654
|
* {\@link state animation states}, within an {\@link sequence animation sequence}, or as styling data
|
13655
|
* for both {\@link animate animate} and {\@link keyframes keyframes}.
|
13656
|
*
|
13657
|
* ### Usage
|
13658
|
*
|
13659
|
* `style` takes in a key/value string map as data and expects one or more CSS property/value pairs
|
13660
|
* to be defined.
|
13661
|
*
|
13662
|
* ```typescript
|
13663
|
* // string values are used for css properties
|
13664
|
* style({ background: "red", color: "blue" })
|
13665
|
*
|
13666
|
* // numerical (pixel) values are also supported
|
13667
|
* style({ width: 100, height: 0 })
|
13668
|
* ```
|
13669
|
*
|
13670
|
* #### Auto-styles (using `*`)
|
13671
|
*
|
13672
|
* When an asterix (`*`) character is used as a value then it will be detected from the element
|
13673
|
* being animated and applied as animation data when the animation starts.
|
13674
|
*
|
13675
|
* This feature proves useful for a state depending on layout and/or environment factors; in such
|
13676
|
* cases the styles are calculated just before the animation starts.
|
13677
|
*
|
13678
|
* ```typescript
|
13679
|
* // the steps below will animate from 0 to the
|
13680
|
* // actual height of the element
|
13681
|
* style({ height: 0 }),
|
13682
|
* animate("1s", style({ height: "*" }))
|
13683
|
* ```
|
13684
|
*
|
13685
|
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
13686
|
*
|
13687
|
* \@experimental Animation support is experimental.
|
13688
|
* @param {?} tokens
|
13689
|
* @return {?}
|
13690
|
*/
|
13691
|
function style$1(tokens) {
|
13692
|
return { type: 6 /* Style */, styles: tokens, offset: null };
|
13693
|
}
|
13694
|
/**
|
13695
|
* `state` is an animation-specific function that is designed to be used inside of Angular's
|
13696
|
* animation DSL language. If this information is new, please navigate to the {\@link
|
13697
|
* Component#animations component animations metadata page} to gain a better understanding of
|
13698
|
* how animations in Angular are used.
|
13699
|
*
|
13700
|
* `state` declares an animation state within the given trigger. When a state is active within a
|
13701
|
* component then its associated styles will persist on the element that the trigger is attached to
|
13702
|
* (even when the animation ends).
|
13703
|
*
|
13704
|
* To animate between states, have a look at the animation {\@link transition transition} DSL
|
13705
|
* function. To register states to an animation trigger please have a look at the {\@link trigger
|
13706
|
* trigger} function.
|
13707
|
*
|
13708
|
* #### The `void` state
|
13709
|
*
|
13710
|
* The `void` state value is a reserved word that angular uses to determine when the element is not
|
13711
|
* apart of the application anymore (e.g. when an `ngIf` evaluates to false then the state of the
|
13712
|
* associated element is void).
|
13713
|
*
|
13714
|
* #### The `*` (default) state
|
13715
|
*
|
13716
|
* The `*` state (when styled) is a fallback state that will be used if the state that is being
|
13717
|
* animated is not declared within the trigger.
|
13718
|
*
|
13719
|
* ### Usage
|
13720
|
*
|
13721
|
* `state` will declare an animation state with its associated styles
|
13722
|
* within the given trigger.
|
13723
|
*
|
13724
|
* - `stateNameExpr` can be one or more state names separated by commas.
|
13725
|
* - `styles` refers to the {\@link style styling data} that will be persisted on the element once
|
13726
|
* the state has been reached.
|
13727
|
*
|
13728
|
* ```typescript
|
13729
|
* // "void" is a reserved name for a state and is used to represent
|
13730
|
* // the state in which an element is detached from from the application.
|
13731
|
* state("void", style({ height: 0 }))
|
13732
|
*
|
13733
|
* // user-defined states
|
13734
|
* state("closed", style({ height: 0 }))
|
13735
|
* state("open, visible", style({ height: "*" }))
|
13736
|
* ```
|
13737
|
*
|
13738
|
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
13739
|
*
|
13740
|
* \@experimental Animation support is experimental.
|
13741
|
* @param {?} name
|
13742
|
* @param {?} styles
|
13743
|
* @param {?=} options
|
13744
|
* @return {?}
|
13745
|
*/
|
13746
|
function state$1(name, styles, options) {
|
13747
|
return { type: 0 /* State */, name, styles, options };
|
13748
|
}
|
13749
|
/**
|
13750
|
* `keyframes` is an animation-specific function that is designed to be used inside of Angular's
|
13751
|
* animation DSL language. If this information is new, please navigate to the {\@link
|
13752
|
* Component#animations component animations metadata page} to gain a better understanding of
|
13753
|
* how animations in Angular are used.
|
13754
|
*
|
13755
|
* `keyframes` specifies a collection of {\@link style style} entries each optionally characterized
|
13756
|
* by an `offset` value.
|
13757
|
*
|
13758
|
* ### Usage
|
13759
|
*
|
13760
|
* The `keyframes` animation function is designed to be used alongside the {\@link animate animate}
|
13761
|
* animation function. Instead of applying animations from where they are currently to their
|
13762
|
* destination, keyframes can describe how each style entry is applied and at what point within the
|
13763
|
* animation arc (much like CSS Keyframe Animations do).
|
13764
|
*
|
13765
|
* For each `style()` entry an `offset` value can be set. Doing so allows to specifiy at what
|
13766
|
* percentage of the animate time the styles will be applied.
|
13767
|
*
|
13768
|
* ```typescript
|
13769
|
* // the provided offset values describe when each backgroundColor value is applied.
|
13770
|
* animate("5s", keyframes([
|
13771
|
* style({ backgroundColor: "red", offset: 0 }),
|
13772
|
* style({ backgroundColor: "blue", offset: 0.2 }),
|
13773
|
* style({ backgroundColor: "orange", offset: 0.3 }),
|
13774
|
* style({ backgroundColor: "black", offset: 1 })
|
13775
|
* ]))
|
13776
|
* ```
|
13777
|
*
|
13778
|
* Alternatively, if there are no `offset` values used within the style entries then the offsets
|
13779
|
* will be calculated automatically.
|
13780
|
*
|
13781
|
* ```typescript
|
13782
|
* animate("5s", keyframes([
|
13783
|
* style({ backgroundColor: "red" }) // offset = 0
|
13784
|
* style({ backgroundColor: "blue" }) // offset = 0.33
|
13785
|
* style({ backgroundColor: "orange" }) // offset = 0.66
|
13786
|
* style({ backgroundColor: "black" }) // offset = 1
|
13787
|
* ]))
|
13788
|
* ```
|
13789
|
*
|
13790
|
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
13791
|
*
|
13792
|
* \@experimental Animation support is experimental.
|
13793
|
* @param {?} steps
|
13794
|
* @return {?}
|
13795
|
*/
|
13796
|
function keyframes$1(steps) {
|
13797
|
return { type: 5 /* Keyframes */, steps };
|
13798
|
}
|
13799
|
/**
|
13800
|
* `transition` is an animation-specific function that is designed to be used inside of Angular's
|
13801
|
* animation DSL language. If this information is new, please navigate to the {\@link
|
13802
|
* Component#animations component animations metadata page} to gain a better understanding of
|
13803
|
* how animations in Angular are used.
|
13804
|
*
|
13805
|
* `transition` declares the {\@link sequence sequence of animation steps} that will be run when the
|
13806
|
* provided `stateChangeExpr` value is satisfied. The `stateChangeExpr` consists of a `state1 =>
|
13807
|
* state2` which consists of two known states (use an asterix (`*`) to refer to a dynamic starting
|
13808
|
* and/or ending state).
|
13809
|
*
|
13810
|
* A function can also be provided as the `stateChangeExpr` argument for a transition and this
|
13811
|
* function will be executed each time a state change occurs. If the value returned within the
|
13812
|
* function is true then the associated animation will be run.
|
13813
|
*
|
13814
|
* Animation transitions are placed within an {\@link trigger animation trigger}. For an transition
|
13815
|
* to animate to a state value and persist its styles then one or more {\@link state animation
|
13816
|
* states} is expected to be defined.
|
13817
|
*
|
13818
|
* ### Usage
|
13819
|
*
|
13820
|
* An animation transition is kicked off the `stateChangeExpr` predicate evaluates to true based on
|
13821
|
* what the previous state is and what the current state has become. In other words, if a transition
|
13822
|
* is defined that matches the old/current state criteria then the associated animation will be
|
13823
|
* triggered.
|
13824
|
*
|
13825
|
* ```typescript
|
13826
|
* // all transition/state changes are defined within an animation trigger
|
13827
|
* trigger("myAnimationTrigger", [
|
13828
|
* // if a state is defined then its styles will be persisted when the
|
13829
|
* // animation has fully completed itself
|
13830
|
* state("on", style({ background: "green" })),
|
13831
|
* state("off", style({ background: "grey" })),
|
13832
|
*
|
13833
|
* // a transition animation that will be kicked off when the state value
|
13834
|
* // bound to "myAnimationTrigger" changes from "on" to "off"
|
13835
|
* transition("on => off", animate(500)),
|
13836
|
*
|
13837
|
* // it is also possible to do run the same animation for both directions
|
13838
|
* transition("on <=> off", animate(500)),
|
13839
|
*
|
13840
|
* // or to define multiple states pairs separated by commas
|
13841
|
* transition("on => off, off => void", animate(500)),
|
13842
|
*
|
13843
|
* // this is a catch-all state change for when an element is inserted into
|
13844
|
* // the page and the destination state is unknown
|
13845
|
* transition("void => *", [
|
13846
|
* style({ opacity: 0 }),
|
13847
|
* animate(500)
|
13848
|
* ]),
|
13849
|
*
|
13850
|
* // this will capture a state change between any states
|
13851
|
* transition("* => *", animate("1s 0s")),
|
13852
|
*
|
13853
|
* // you can also go full out and include a function
|
13854
|
* transition((fromState, toState) => {
|
13855
|
* // when `true` then it will allow the animation below to be invoked
|
13856
|
* return fromState == "off" && toState == "on";
|
13857
|
* }, animate("1s 0s"))
|
13858
|
* ])
|
13859
|
* ```
|
13860
|
*
|
13861
|
* The template associated with this component will make use of the `myAnimationTrigger` animation
|
13862
|
* trigger by binding to an element within its template code.
|
13863
|
*
|
13864
|
* ```html
|
13865
|
* <!-- somewhere inside of my-component-tpl.html -->
|
13866
|
* <div [\@myAnimationTrigger]="myStatusExp">...</div>
|
13867
|
* ```
|
13868
|
*
|
13869
|
* #### The final `animate` call
|
13870
|
*
|
13871
|
* If the final step within the transition steps is a call to `animate()` that **only** uses a
|
13872
|
* timing value with **no style data** then it will be automatically used as the final animation arc
|
13873
|
* for the element to animate itself to the final state. This involves an automatic mix of
|
13874
|
* adding/removing CSS styles so that the element will be in the exact state it should be for the
|
13875
|
* applied state to be presented correctly.
|
13876
|
*
|
13877
|
* ```
|
13878
|
* // start off by hiding the element, but make sure that it animates properly to whatever state
|
13879
|
* // is currently active for "myAnimationTrigger"
|
13880
|
* transition("void => *", [
|
13881
|
* style({ opacity: 0 }),
|
13882
|
* animate(500)
|
13883
|
* ])
|
13884
|
* ```
|
13885
|
*
|
13886
|
* ### Transition Aliases (`:enter` and `:leave`)
|
13887
|
*
|
13888
|
* Given that enter (insertion) and leave (removal) animations are so common, the `transition`
|
13889
|
* function accepts both `:enter` and `:leave` values which are aliases for the `void => *` and `*
|
13890
|
* => void` state changes.
|
13891
|
*
|
13892
|
* ```
|
13893
|
* transition(":enter", [
|
13894
|
* style({ opacity: 0 }),
|
13895
|
* animate(500, style({ opacity: 1 }))
|
13896
|
* ])
|
13897
|
* transition(":leave", [
|
13898
|
* animate(500, style({ opacity: 0 }))
|
13899
|
* ])
|
13900
|
* ```
|
13901
|
*
|
13902
|
* ### Boolean values
|
13903
|
* if a trigger binding value is a boolean value then it can be matched using a transition
|
13904
|
* expression that compares `true` and `false` or `1` and `0`.
|
13905
|
*
|
13906
|
* ```
|
13907
|
* // in the template
|
13908
|
* <div [\@openClose]="open ? true : false">...</div>
|
13909
|
*
|
13910
|
* // in the component metadata
|
13911
|
* trigger('openClose', [
|
13912
|
* state('true', style({ height: '*' })),
|
13913
|
* state('false', style({ height: '0px' })),
|
13914
|
* transition('false <=> true', animate(500))
|
13915
|
* ])
|
13916
|
* ```
|
13917
|
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
|
13918
|
*
|
13919
|
* \@experimental Animation support is experimental.
|
13920
|
* @param {?} stateChangeExpr
|
13921
|
* @param {?} steps
|
13922
|
* @param {?=} options
|
13923
|
* @return {?}
|
13924
|
*/
|
13925
|
function transition$1(stateChangeExpr, steps, options = null) {
|
13926
|
return { type: 1 /* Transition */, expr: stateChangeExpr, animation: steps, options };
|
13927
|
}
|
13928
|
/**
|
13929
|
* `animation` is an animation-specific function that is designed to be used inside of Angular's
|
13930
|
* animation DSL language.
|
13931
|
*
|
13932
|
* `var myAnimation = animation(...)` is designed to produce a reusable animation that can be later
|
13933
|
* invoked in another animation or sequence. Reusable animations are designed to make use of
|
13934
|
* animation parameters and the produced animation can be used via the `useAnimation` method.
|
13935
|
*
|
13936
|
* ```
|
13937
|
* var fadeAnimation = animation([
|
13938
|
* style({ opacity: '{{ start }}' }),
|
13939
|
* animate('{{ time }}',
|
13940
|
* style({ opacity: '{{ end }}'}))
|
13941
|
* ], { params: { time: '1000ms', start: 0, end: 1 }});
|
13942
|
* ```
|
13943
|
*
|
13944
|
* If parameters are attached to an animation then they act as **default parameter values**. When an
|
13945
|
* animation is invoked via `useAnimation` then parameter values are allowed to be passed in
|
13946
|
* directly. If any of the passed in parameter values are missing then the default values will be
|
13947
|
* used.
|
13948
|
*
|
13949
|
* ```
|
13950
|
* useAnimation(fadeAnimation, {
|
13951
|
* params: {
|
13952
|
* time: '2s',
|
13953
|
* start: 1,
|
13954
|
* end: 0
|
13955
|
* }
|
13956
|
* })
|
13957
|
* ```
|
13958
|
*
|
13959
|
* If one or more parameter values are missing before animated then an error will be thrown.
|
13960
|
*
|
13961
|
* \@experimental Animation support is experimental.
|
13962
|
* @param {?} steps
|
13963
|
* @param {?=} options
|
13964
|
* @return {?}
|
13965
|
*/
|
13966
|
|
13967
|
/**
|
13968
|
* `animateChild` is an animation-specific function that is designed to be used inside of Angular's
|
13969
|
* animation DSL language. It works by allowing a queried element to execute its own
|
13970
|
* animation within the animation sequence.
|
13971
|
*
|
13972
|
* Each time an animation is triggered in angular, the parent animation
|
13973
|
* will always get priority and any child animations will be blocked. In order
|
13974
|
* for a child animation to run, the parent animation must query each of the elements
|
13975
|
* containing child animations and then allow the animations to run using `animateChild`.
|
13976
|
*
|
13977
|
* The example HTML code below shows both parent and child elements that have animation
|
13978
|
* triggers that will execute at the same time.
|
13979
|
*
|
13980
|
* ```html
|
13981
|
* <!-- parent-child.component.html -->
|
13982
|
* <button (click)="exp =! exp">Toggle</button>
|
13983
|
* <hr>
|
13984
|
*
|
13985
|
* <div [\@parentAnimation]="exp">
|
13986
|
* <header>Hello</header>
|
13987
|
* <div [\@childAnimation]="exp">
|
13988
|
* one
|
13989
|
* </div>
|
13990
|
* <div [\@childAnimation]="exp">
|
13991
|
* two
|
13992
|
* </div>
|
13993
|
* <div [\@childAnimation]="exp">
|
13994
|
* three
|
13995
|
* </div>
|
13996
|
* </div>
|
13997
|
* ```
|
13998
|
*
|
13999
|
* Now when the `exp` value changes to true, only the `parentAnimation` animation will animate
|
14000
|
* because it has priority. However, using `query` and `animateChild` each of the inner animations
|
14001
|
* can also fire:
|
14002
|
*
|
14003
|
* ```ts
|
14004
|
* // parent-child.component.ts
|
14005
|
* import {trigger, transition, animate, style, query, animateChild} from '\@angular/animations';
|
14006
|
* \@Component({
|
14007
|
* selector: 'parent-child-component',
|
14008
|
* animations: [
|
14009
|
* trigger('parentAnimation', [
|
14010
|
* transition('false => true', [
|
14011
|
* query('header', [
|
14012
|
* style({ opacity: 0 }),
|
14013
|
* animate(500, style({ opacity: 1 }))
|
14014
|
* ]),
|
14015
|
* query('\@childAnimation', [
|
14016
|
* animateChild()
|
14017
|
* ])
|
14018
|
* ])
|
14019
|
* ]),
|
14020
|
* trigger('childAnimation', [
|
14021
|
* transition('false => true', [
|
14022
|
* style({ opacity: 0 }),
|
14023
|
* animate(500, style({ opacity: 1 }))
|
14024
|
* ])
|
14025
|
* ])
|
14026
|
* ]
|
14027
|
* })
|
14028
|
* class ParentChildCmp {
|
14029
|
* exp: boolean = false;
|
14030
|
* }
|
14031
|
* ```
|
14032
|
*
|
14033
|
* In the animation code above, when the `parentAnimation` transition kicks off it first queries to
|
14034
|
* find the header element and fades it in. It then finds each of the sub elements that contain the
|
14035
|
* `\@childAnimation` trigger and then allows for their animations to fire.
|
14036
|
*
|
14037
|
* This example can be further extended by using stagger:
|
14038
|
*
|
14039
|
* ```ts
|
14040
|
* query('\@childAnimation', stagger(100, [
|
14041
|
* animateChild()
|
14042
|
* ]))
|
14043
|
* ```
|
14044
|
*
|
14045
|
* Now each of the sub animations start off with respect to the `100ms` staggering step.
|
14046
|
*
|
14047
|
* ## The first frame of child animations
|
14048
|
* When sub animations are executed using `animateChild` the animation engine will always apply the
|
14049
|
* first frame of every sub animation immediately at the start of the animation sequence. This way
|
14050
|
* the parent animation does not need to set any initial styling data on the sub elements before the
|
14051
|
* sub animations kick off.
|
14052
|
*
|
14053
|
* In the example above the first frame of the `childAnimation`'s `false => true` transition
|
14054
|
* consists of a style of `opacity: 0`. This is applied immediately when the `parentAnimation`
|
14055
|
* animation transition sequence starts. Only then when the `\@childAnimation` is queried and called
|
14056
|
* with `animateChild` will it then animate to its destination of `opacity: 1`.
|
14057
|
*
|
14058
|
* Note that this feature designed to be used alongside {\@link query query()} and it will only work
|
14059
|
* with animations that are assigned using the Angular animation DSL (this means that CSS keyframes
|
14060
|
* and transitions are not handled by this API).
|
14061
|
*
|
14062
|
* \@experimental Animation support is experimental.
|
14063
|
* @param {?=} options
|
14064
|
* @return {?}
|
14065
|
*/
|
14066
|
|
14067
|
/**
|
14068
|
* `useAnimation` is an animation-specific function that is designed to be used inside of Angular's
|
14069
|
* animation DSL language. It is used to kick off a reusable animation that is created using {\@link
|
14070
|
* animation animation()}.
|
14071
|
*
|
14072
|
* \@experimental Animation support is experimental.
|
14073
|
* @param {?} animation
|
14074
|
* @param {?=} options
|
14075
|
* @return {?}
|
14076
|
*/
|
14077
|
|
14078
|
/**
|
14079
|
* `query` is an animation-specific function that is designed to be used inside of Angular's
|
14080
|
* animation DSL language.
|
14081
|
*
|
14082
|
* query() is used to find one or more inner elements within the current element that is
|
14083
|
* being animated within the sequence. The provided animation steps are applied
|
14084
|
* to the queried element (by default, an array is provided, then this will be
|
14085
|
* treated as an animation sequence).
|
14086
|
*
|
14087
|
* ### Usage
|
14088
|
*
|
14089
|
* query() is designed to collect mutiple elements and works internally by using
|
14090
|
* `element.querySelectorAll`. An additional options object can be provided which
|
14091
|
* can be used to limit the total amount of items to be collected.
|
14092
|
*
|
14093
|
* ```js
|
14094
|
* query('div', [
|
14095
|
* animate(...),
|
14096
|
* animate(...)
|
14097
|
* ], { limit: 1 })
|
14098
|
* ```
|
14099
|
*
|
14100
|
* query(), by default, will throw an error when zero items are found. If a query
|
14101
|
* has the `optional` flag set to true then this error will be ignored.
|
14102
|
*
|
14103
|
* ```js
|
14104
|
* query('.some-element-that-may-not-be-there', [
|
14105
|
* animate(...),
|
14106
|
* animate(...)
|
14107
|
* ], { optional: true })
|
14108
|
* ```
|
14109
|
*
|
14110
|
* ### Special Selector Values
|
14111
|
*
|
14112
|
* The selector value within a query can collect elements that contain angular-specific
|
14113
|
* characteristics
|
14114
|
* using special pseudo-selectors tokens.
|
14115
|
*
|
14116
|
* These include:
|
14117
|
*
|
14118
|
* - Querying for newly inserted/removed elements using `query(":enter")`/`query(":leave")`
|
14119
|
* - Querying all currently animating elements using `query(":animating")`
|
14120
|
* - Querying elements that contain an animation trigger using `query("\@triggerName")`
|
14121
|
* - Querying all elements that contain an animation triggers using `query("\@*")`
|
14122
|
* - Including the current element into the animation sequence using `query(":self")`
|
14123
|
*
|
14124
|
*
|
14125
|
* Each of these pseudo-selector tokens can be merged together into a combined query selector
|
14126
|
* string:
|
14127
|
*
|
14128
|
* ```
|
14129
|
* query(':self, .record:enter, .record:leave, \@subTrigger', [...])
|
14130
|
* ```
|
14131
|
*
|
14132
|
* ### Demo
|
14133
|
*
|
14134
|
* ```
|
14135
|
* \@Component({
|
14136
|
* selector: 'inner',
|
14137
|
* template: `
|
14138
|
* <div [\@queryAnimation]="exp">
|
14139
|
* <h1>Title</h1>
|
14140
|
* <div class="content">
|
14141
|
* Blah blah blah
|
14142
|
* </div>
|
14143
|
* </div>
|
14144
|
* `,
|
14145
|
* animations: [
|
14146
|
* trigger('queryAnimation', [
|
14147
|
* transition('* => goAnimate', [
|
14148
|
* // hide the inner elements
|
14149
|
* query('h1', style({ opacity: 0 })),
|
14150
|
* query('.content', style({ opacity: 0 })),
|
14151
|
*
|
14152
|
* // animate the inner elements in, one by one
|
14153
|
* query('h1', animate(1000, style({ opacity: 1 })),
|
14154
|
* query('.content', animate(1000, style({ opacity: 1 })),
|
14155
|
* ])
|
14156
|
* ])
|
14157
|
* ]
|
14158
|
* })
|
14159
|
* class Cmp {
|
14160
|
* exp = '';
|
14161
|
*
|
14162
|
* goAnimate() {
|
14163
|
* this.exp = 'goAnimate';
|
14164
|
* }
|
14165
|
* }
|
14166
|
* ```
|
14167
|
*
|
14168
|
* \@experimental Animation support is experimental.
|
14169
|
* @param {?} selector
|
14170
|
* @param {?} animation
|
14171
|
* @param {?=} options
|
14172
|
* @return {?}
|
14173
|
*/
|
14174
|
|
14175
|
/**
|
14176
|
* `stagger` is an animation-specific function that is designed to be used inside of Angular's
|
14177
|
* animation DSL language. It is designed to be used inside of an animation {\@link query query()}
|
14178
|
* and works by issuing a timing gap between after each queried item is animated.
|
14179
|
*
|
14180
|
* ### Usage
|
14181
|
*
|
14182
|
* In the example below there is a container element that wraps a list of items stamped out
|
14183
|
* by an ngFor. The container element contains an animation trigger that will later be set
|
14184
|
* to query for each of the inner items.
|
14185
|
*
|
14186
|
* ```html
|
14187
|
* <!-- list.component.html -->
|
14188
|
* <button (click)="toggle()">Show / Hide Items</button>
|
14189
|
* <hr />
|
14190
|
* <div [\@listAnimation]="items.length">
|
14191
|
* <div *ngFor="let item of items">
|
14192
|
* {{ item }}
|
14193
|
* </div>
|
14194
|
* </div>
|
14195
|
* ```
|
14196
|
*
|
14197
|
* The component code for this looks as such:
|
14198
|
*
|
14199
|
* ```ts
|
14200
|
* import {trigger, transition, style, animate, query, stagger} from '\@angular/animations';
|
14201
|
* \@Component({
|
14202
|
* templateUrl: 'list.component.html',
|
14203
|
* animations: [
|
14204
|
* trigger('listAnimation', [
|
14205
|
* //...
|
14206
|
* ])
|
14207
|
* ]
|
14208
|
* })
|
14209
|
* class ListComponent {
|
14210
|
* items = [];
|
14211
|
*
|
14212
|
* showItems() {
|
14213
|
* this.items = [0,1,2,3,4];
|
14214
|
* }
|
14215
|
*
|
14216
|
* hideItems() {
|
14217
|
* this.items = [];
|
14218
|
* }
|
14219
|
*
|
14220
|
* toggle() {
|
14221
|
* this.items.length ? this.hideItems() : this.showItems();
|
14222
|
* }
|
14223
|
* }
|
14224
|
* ```
|
14225
|
*
|
14226
|
* And now for the animation trigger code:
|
14227
|
*
|
14228
|
* ```ts
|
14229
|
* trigger('listAnimation', [
|
14230
|
* transition('* => *', [ // each time the binding value changes
|
14231
|
* query(':leave', [
|
14232
|
* stagger(100, [
|
14233
|
* animate('0.5s', style({ opacity: 0 }))
|
14234
|
* ])
|
14235
|
* ]),
|
14236
|
* query(':enter', [
|
14237
|
* style({ opacity: 0 }),
|
14238
|
* stagger(100, [
|
14239
|
* animate('0.5s', style({ opacity: 1 }))
|
14240
|
* ])
|
14241
|
* ])
|
14242
|
* ])
|
14243
|
* ])
|
14244
|
* ```
|
14245
|
*
|
14246
|
* Now each time the items are added/removed then either the opacity
|
14247
|
* fade-in animation will run or each removed item will be faded out.
|
14248
|
* When either of these animations occur then a stagger effect will be
|
14249
|
* applied after each item's animation is started.
|
14250
|
*
|
14251
|
* \@experimental Animation support is experimental.
|
14252
|
* @param {?} timings
|
14253
|
* @param {?} animation
|
14254
|
* @return {?}
|
14255
|
*/
|
14256
|
|
14257
|
/**
|
14258
|
* @license
|
14259
|
* Copyright Google Inc. All Rights Reserved.
|
14260
|
*
|
14261
|
* Use of this source code is governed by an MIT-style license that can be
|
14262
|
* found in the LICENSE file at https://angular.io/license
|
14263
|
*/
|
14264
|
/**
|
14265
|
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
|
14266
|
*/
|
14267
|
const AUTO_STYLE$$1 = '*';
|
14268
|
/**
|
14269
|
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
|
14270
|
* @param {?} name
|
14271
|
* @param {?} definitions
|
14272
|
* @return {?}
|
14273
|
*/
|
14274
|
function trigger$$1(name, definitions) {
|
14275
|
return trigger$1(name, definitions);
|
14276
|
}
|
14277
|
/**
|
14278
|
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
|
14279
|
* @param {?} timings
|
14280
|
* @param {?=} styles
|
14281
|
* @return {?}
|
14282
|
*/
|
14283
|
function animate$$1(timings, styles) {
|
14284
|
return animate$1(timings, styles);
|
14285
|
}
|
14286
|
/**
|
14287
|
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
|
14288
|
* @param {?} steps
|
14289
|
* @return {?}
|
14290
|
*/
|
14291
|
function group$$1(steps) {
|
14292
|
return group$1(steps);
|
14293
|
}
|
14294
|
/**
|
14295
|
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
|
14296
|
* @param {?} steps
|
14297
|
* @return {?}
|
14298
|
*/
|
14299
|
function sequence$$1(steps) {
|
14300
|
return sequence$1(steps);
|
14301
|
}
|
14302
|
/**
|
14303
|
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
|
14304
|
* @param {?} tokens
|
14305
|
* @return {?}
|
14306
|
*/
|
14307
|
function style$$1(tokens) {
|
14308
|
return style$1(tokens);
|
14309
|
}
|
14310
|
/**
|
14311
|
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
|
14312
|
* @param {?} name
|
14313
|
* @param {?} styles
|
14314
|
* @return {?}
|
14315
|
*/
|
14316
|
function state$$1(name, styles) {
|
14317
|
return state$1(name, styles);
|
14318
|
}
|
14319
|
/**
|
14320
|
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
|
14321
|
* @param {?} steps
|
14322
|
* @return {?}
|
14323
|
*/
|
14324
|
function keyframes$$1(steps) {
|
14325
|
return keyframes$1(steps);
|
14326
|
}
|
14327
|
/**
|
14328
|
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
|
14329
|
* @param {?} stateChangeExpr
|
14330
|
* @param {?} steps
|
14331
|
* @return {?}
|
14332
|
*/
|
14333
|
function transition$$1(stateChangeExpr, steps) {
|
14334
|
return transition$1(stateChangeExpr, steps);
|
14335
|
}
|
14336
|
|
14337
|
/**
|
14338
|
* @license
|
14339
|
* Copyright Google Inc. All Rights Reserved.
|
14340
|
*
|
14341
|
* Use of this source code is governed by an MIT-style license that can be
|
14342
|
* found in the LICENSE file at https://angular.io/license
|
14343
|
*/
|
14344
|
/**
|
14345
|
* @module
|
14346
|
* @description
|
14347
|
* Entry point from which you should import all public core APIs.
|
14348
|
*/
|
14349
|
|
14350
|
/**
|
14351
|
* @license
|
14352
|
* Copyright Google Inc. All Rights Reserved.
|
14353
|
*
|
14354
|
* Use of this source code is governed by an MIT-style license that can be
|
14355
|
* found in the LICENSE file at https://angular.io/license
|
14356
|
*/
|
14357
|
/**
|
14358
|
* @module
|
14359
|
* @description
|
14360
|
* Entry point for all public APIs of the core package.
|
14361
|
*/
|
14362
|
|
14363
|
// This file only reexports content of the `src` folder. Keep it that way.
|
14364
|
|
14365
|
/**
|
14366
|
* Generated bundle index. Do not edit.
|
14367
|
*/
|
14368
|
|
14369
|
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, ViewMetadata as ɵViewMetadata, ReflectionCapabilities as ɵReflectionCapabilities, RenderDebugInfo as ɵRenderDebugInfo, _global as ɵglobal, looseIdentical as ɵlooseIdentical, stringify as ɵstringify, makeDecorator as ɵmakeDecorator, isObservable as ɵisObservable, isPromise as ɵisPromise, clearProviderOverrides as ɵclearProviderOverrides, overrideProvider as ɵoverrideProvider, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, registerModuleFactory as ɵregisterModuleFactory, EMPTY_ARRAY as ɵEMPTY_ARRAY, EMPTY_MAP as ɵEMPTY_MAP, anchorDef as ɵand, createComponentFactory as ɵccf, createNgModuleFactory as ɵcmf, createRendererType2 as ɵcrt, directiveDef as ɵdid, elementDef as ɵeld, elementEventFullName as ɵelementEventFullName, getComponentViewDefinitionFactory as ɵgetComponentViewDefinitionFactory, inlineInterpolate as ɵinlineInterpolate, interpolate as ɵinterpolate, moduleDef as ɵmod, moduleProvideDef as ɵmpd, 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 ɵx, group$1 as ɵy, keyframes$1 as ɵbc, sequence$1 as ɵz, state$1 as ɵbb, style$1 as ɵba, transition$1 as ɵbd, trigger$1 as ɵw, _iterableDiffersFactory as ɵk, _keyValueDiffersFactory as ɵl, _localeFactory as ɵm, ApplicationRef_ as ɵe, _appIdRandomProviderFactory as ɵf, defaultIterableDiffers as ɵg, defaultKeyValueDiffers as ɵh, DefaultIterableDifferFactory as ɵi, DefaultKeyValueDifferFactory as ɵj, ReflectiveInjector_ as ɵb, ReflectiveDependency as ɵc, resolveReflectiveProviders as ɵd, wtfEnabled as ɵn, createScope$1 as ɵp, detectWTF as ɵo, endTimeRange as ɵs, leave as ɵq, startTimeRange as ɵr, makeParamDecorator as ɵa, _def as ɵt, DebugContext as ɵu };
|
14370
|
//# sourceMappingURL=core.js.map
|