@@ -15,15 +15,14 @@ import {createNamedArrayType} from '../../util/named_array_type';
15
15
import { initNgDevMode } from '../../util/ng_dev_mode' ;
16
16
import { CONTAINER_HEADER_OFFSET , HAS_TRANSPLANTED_VIEWS , LContainer , MOVED_VIEWS , NATIVE } from '../interfaces/container' ;
17
17
import { DirectiveDefList , PipeDefList , ViewQueriesFunction } from '../interfaces/definition' ;
18
- import { COMMENT_MARKER , ELEMENT_MARKER , I18nMutateOpCode , I18nMutateOpCodes , I18nUpdateOpCode , I18nUpdateOpCodes , TIcu } from '../interfaces/i18n' ;
19
- import { PropertyAliases , TConstants , TContainerNode , TElementNode , TNode as ITNode , TNodeFlags , TNodeProviderIndexes , TNodeType , TViewNode } from '../interfaces/node' ;
18
+ import { PropertyAliases , TConstants , TContainerNode , TElementNode , TNode as ITNode , TNodeFlags , TNodeProviderIndexes , TNodeType , TNodeTypeAsString , TViewNode } from '../interfaces/node' ;
20
19
import { SelectorFlags } from '../interfaces/projection' ;
21
20
import { LQueries , TQueries } from '../interfaces/query' ;
22
21
import { RComment , RElement , Renderer3 , RendererFactory3 , RNode } from '../interfaces/renderer' ;
23
22
import { getTStylingRangeNext , getTStylingRangeNextDuplicate , getTStylingRangePrev , getTStylingRangePrevDuplicate , TStylingKey , TStylingRange } from '../interfaces/styling' ;
24
- import { CHILD_HEAD , CHILD_TAIL , CLEANUP , CONTEXT , DECLARATION_VIEW , DestroyHookData , ExpandoInstructions , FLAGS , HEADER_OFFSET , HookData , HOST , INJECTOR , LView , LViewFlags , NEXT , PARENT , QUERIES , RENDERER , RENDERER_FACTORY , SANITIZER , T_HOST , TData , TVIEW , TView as ITView , TView , TViewType } from '../interfaces/view' ;
23
+ import { CHILD_HEAD , CHILD_TAIL , CLEANUP , CONTEXT , DebugNode , DECLARATION_VIEW , DestroyHookData , ExpandoInstructions , FLAGS , HEADER_OFFSET , HookData , HOST , INJECTOR , LContainerDebug as ILContainerDebug , LView , LViewDebug as ILViewDebug , LViewDebugRange , LViewDebugRangeContent , LViewFlags , NEXT , PARENT , QUERIES , RENDERER , RENDERER_FACTORY , SANITIZER , T_HOST , TData , TView as ITView , TVIEW , TView , TViewType } from '../interfaces/view' ;
25
24
import { attachDebugObject } from '../util/debug_utils' ;
26
- import { getTNode , unwrapRNode } from '../util/view_utils' ;
25
+ import { unwrapRNode } from '../util/view_utils' ;
27
26
28
27
const NG_DEV_MODE = ( ( typeof ngDevMode === 'undefined' || ! ! ngDevMode ) && initNgDevMode ( ) ) ;
29
28
@@ -143,7 +142,10 @@ export const TViewConstructor = class TView implements ITView {
143
142
public firstChild : ITNode | null , //
144
143
public schemas : SchemaMetadata [ ] | null , //
145
144
public consts : TConstants | null , //
146
- public incompleteFirstPass : boolean //
145
+ public incompleteFirstPass : boolean , //
146
+ public _decls : number , //
147
+ public _vars : number , //
148
+
147
149
) { }
148
150
149
151
get template_ ( ) : string {
@@ -335,9 +337,9 @@ export function attachLContainerDebug(lContainer: LContainer) {
335
337
attachDebugObject ( lContainer , new LContainerDebug ( lContainer ) ) ;
336
338
}
337
339
338
- export function toDebug ( obj : LView ) : LViewDebug ;
339
- export function toDebug ( obj : LView | null ) : LViewDebug | null ;
340
- export function toDebug ( obj : LView | LContainer | null ) : LViewDebug | LContainerDebug | null ;
340
+ export function toDebug ( obj : LView ) : ILViewDebug ;
341
+ export function toDebug ( obj : LView | null ) : ILViewDebug | null ;
342
+ export function toDebug ( obj : LView | LContainer | null ) : ILViewDebug | ILContainerDebug | null ;
341
343
export function toDebug ( obj : any ) : any {
342
344
if ( obj ) {
343
345
const debug = ( obj as any ) . debug ;
@@ -375,7 +377,7 @@ function toHtml(value: any, includeChildren: boolean = false): string|null {
375
377
}
376
378
}
377
379
378
- export class LViewDebug {
380
+ export class LViewDebug implements ILViewDebug {
379
381
constructor ( private readonly _raw_lView : LView ) { }
380
382
381
383
/**
@@ -396,10 +398,10 @@ export class LViewDebug {
396
398
indexWithinInitPhase : flags >> LViewFlags . IndexWithinInitPhaseShift ,
397
399
} ;
398
400
}
399
- get parent ( ) : LViewDebug | LContainerDebug | null {
401
+ get parent ( ) : ILViewDebug | ILContainerDebug | null {
400
402
return toDebug ( this . _raw_lView [ PARENT ] ) ;
401
403
}
402
- get host ( ) : string | null {
404
+ get hostHTML ( ) : string | null {
403
405
return toHtml ( this . _raw_lView [ HOST ] , true ) ;
404
406
}
405
407
get html ( ) : string {
@@ -410,10 +412,9 @@ export class LViewDebug {
410
412
}
411
413
/**
412
414
* The tree of nodes associated with the current `LView`. The nodes have been normalized into
413
- * a
414
- * tree structure with relevant details pulled out for readability.
415
+ * a tree structure with relevant details pulled out for readability.
415
416
*/
416
- get nodes ( ) : DebugNode [ ] | null {
417
+ get nodes ( ) : DebugNode [ ] {
417
418
const lView = this . _raw_lView ;
418
419
const tNode = lView [ TVIEW ] . firstChild ;
419
420
return toDebugNodes ( tNode , lView ) ;
@@ -437,16 +438,16 @@ export class LViewDebug {
437
438
get sanitizer ( ) : Sanitizer | null {
438
439
return this . _raw_lView [ SANITIZER ] ;
439
440
}
440
- get childHead ( ) : LViewDebug | LContainerDebug | null {
441
+ get childHead ( ) : ILViewDebug | ILContainerDebug | null {
441
442
return toDebug ( this . _raw_lView [ CHILD_HEAD ] ) ;
442
443
}
443
- get next ( ) : LViewDebug | LContainerDebug | null {
444
+ get next ( ) : ILViewDebug | ILContainerDebug | null {
444
445
return toDebug ( this . _raw_lView [ NEXT ] ) ;
445
446
}
446
- get childTail ( ) : LViewDebug | LContainerDebug | null {
447
+ get childTail ( ) : ILViewDebug | ILContainerDebug | null {
447
448
return toDebug ( this . _raw_lView [ CHILD_TAIL ] ) ;
448
449
}
449
- get declarationView ( ) : LViewDebug | null {
450
+ get declarationView ( ) : ILViewDebug | null {
450
451
return toDebug ( this . _raw_lView [ DECLARATION_VIEW ] ) ;
451
452
}
452
453
get queries ( ) : LQueries | null {
@@ -456,11 +457,35 @@ export class LViewDebug {
456
457
return this . _raw_lView [ T_HOST ] ;
457
458
}
458
459
460
+ get decls ( ) : LViewDebugRange {
461
+ const tView = this . tView as any as { _decls : number , _vars : number } ;
462
+ const start = HEADER_OFFSET ;
463
+ return toLViewRange ( this . tView , this . _raw_lView , start , start + tView . _decls ) ;
464
+ }
465
+
466
+ get vars ( ) : LViewDebugRange {
467
+ const tView = this . tView as any as { _decls : number , _vars : number } ;
468
+ const start = HEADER_OFFSET + tView . _decls ;
469
+ return toLViewRange ( this . tView , this . _raw_lView , start , start + tView . _vars ) ;
470
+ }
471
+
472
+ get i18n ( ) : LViewDebugRange {
473
+ const tView = this . tView as any as { _decls : number , _vars : number } ;
474
+ const start = HEADER_OFFSET + tView . _decls + tView . _vars ;
475
+ return toLViewRange ( this . tView , this . _raw_lView , start , this . tView . expandoStartIndex ) ;
476
+ }
477
+
478
+ get expando ( ) : LViewDebugRange {
479
+ const tView = this . tView as any as { _decls : number , _vars : number } ;
480
+ return toLViewRange (
481
+ this . tView , this . _raw_lView , this . tView . expandoStartIndex , this . _raw_lView . length ) ;
482
+ }
483
+
459
484
/**
460
485
* Normalized view of child views (and containers) attached at this location.
461
486
*/
462
- get childViews ( ) : Array < LViewDebug | LContainerDebug > {
463
- const childViews : Array < LViewDebug | LContainerDebug > = [ ] ;
487
+ get childViews ( ) : Array < ILViewDebug | ILContainerDebug > {
488
+ const childViews : Array < ILViewDebug | ILContainerDebug > = [ ] ;
464
489
let child = this . childHead ;
465
490
while ( child ) {
466
491
childViews . push ( child ) ;
@@ -470,11 +495,12 @@ export class LViewDebug {
470
495
}
471
496
}
472
497
473
- export interface DebugNode {
474
- html : string | null ;
475
- native : Node ;
476
- nodes : DebugNode [ ] | null ;
477
- component : LViewDebug | null ;
498
+ function toLViewRange ( tView : TView , lView : LView , start : number , end : number ) : LViewDebugRange {
499
+ let content : LViewDebugRangeContent [ ] = [ ] ;
500
+ for ( let index = start ; index < end ; index ++ ) {
501
+ content . push ( { index : index , t : tView . data [ index ] , l : lView [ index ] } ) ;
502
+ }
503
+ return { start : start , end : end , length : end - start , content : content } ;
478
504
}
479
505
480
506
/**
@@ -483,7 +509,7 @@ export interface DebugNode {
483
509
* @param tNode
484
510
* @param lView
485
511
*/
486
- export function toDebugNodes ( tNode : ITNode | null , lView : LView ) : DebugNode [ ] | null {
512
+ export function toDebugNodes ( tNode : ITNode | null , lView : LView ) : DebugNode [ ] {
487
513
if ( tNode ) {
488
514
const debugNodes : DebugNode [ ] = [ ] ;
489
515
let tNodeCursor : ITNode | null = tNode ;
@@ -493,33 +519,32 @@ export function toDebugNodes(tNode: ITNode|null, lView: LView): DebugNode[]|null
493
519
}
494
520
return debugNodes ;
495
521
} else {
496
- return null ;
522
+ return [ ] ;
497
523
}
498
524
}
499
525
500
526
export function buildDebugNode ( tNode : ITNode , lView : LView , nodeIndex : number ) : DebugNode {
501
527
const rawValue = lView [ nodeIndex ] ;
502
528
const native = unwrapRNode ( rawValue ) ;
503
- const componentLViewDebug = toDebug ( readLViewValue ( rawValue ) ) ;
504
529
return {
505
530
html : toHtml ( native ) ,
531
+ type : TNodeTypeAsString [ tNode . type ] ,
506
532
native : native as any ,
507
- nodes : toDebugNodes ( tNode . child , lView ) ,
508
- component : componentLViewDebug ,
533
+ children : toDebugNodes ( tNode . child , lView ) ,
509
534
} ;
510
535
}
511
536
512
- export class LContainerDebug {
537
+ export class LContainerDebug implements ILContainerDebug {
513
538
constructor ( private readonly _raw_lContainer : LContainer ) { }
514
539
515
540
get hasTransplantedViews ( ) : boolean {
516
541
return this . _raw_lContainer [ HAS_TRANSPLANTED_VIEWS ] ;
517
542
}
518
- get views ( ) : LViewDebug [ ] {
543
+ get views ( ) : ILViewDebug [ ] {
519
544
return this . _raw_lContainer . slice ( CONTAINER_HEADER_OFFSET )
520
- . map ( toDebug as ( l : LView ) => LViewDebug ) ;
545
+ . map ( toDebug as ( l : LView ) => ILViewDebug ) ;
521
546
}
522
- get parent ( ) : LViewDebug | LContainerDebug | null {
547
+ get parent ( ) : ILViewDebug | null {
523
548
return toDebug ( this . _raw_lContainer [ PARENT ] ) ;
524
549
}
525
550
get movedViews ( ) : LView [ ] | null {
0 commit comments