@@ -46,17 +46,18 @@ import {HookResult} from "../transition/interface";
46
46
import { StateObject } from "../state/stateObject" ;
47
47
48
48
/** @hidden */
49
- function uiViewString ( viewData : ActiveUIView ) {
50
- if ( ! viewData ) return 'ui-view (defunct)' ;
51
- return `[ui-view#${ viewData . id } tag ` +
52
- `in template from '${ viewData . creationContext && viewData . creationContext . name || '(root)' } ' state]: ` +
53
- `fqn: '${ viewData . fqn } ', ` +
54
- `name: '${ viewData . name } @${ viewData . creationContext } ')` ;
49
+ function uiViewString ( uiview : ActiveUIView ) {
50
+ if ( ! uiview ) return 'ui-view (defunct)' ;
51
+ const state = uiview . creationContext ? uiview . creationContext . name || '(root)' : '(none)' ;
52
+ return `[ui-view#${ uiview . id } ${ uiview . $type } :${ uiview . fqn } (${ uiview . name } @${ state } )]` ;
55
53
}
56
54
57
55
/** @hidden */
58
- const viewConfigString = ( viewConfig : ViewConfig ) =>
59
- `[ViewConfig#${ viewConfig . $id } from '${ viewConfig . viewDecl . $context . name || '(root)' } ' state]: target ui-view: '${ viewConfig . viewDecl . $uiViewName } @${ viewConfig . viewDecl . $uiViewContextAnchor } '` ;
56
+ const viewConfigString = ( viewConfig : ViewConfig ) => {
57
+ let view = viewConfig . viewDecl ;
58
+ const state = view . $context . name || '(root)' ;
59
+ return `[View#${ viewConfig . $id } from '${ state } ' state]: target ui-view: '${ view . $uiViewName } @${ view . $uiViewContextAnchor } '` ;
60
+ } ;
60
61
61
62
/** @hidden */
62
63
function normalizedCat ( input : Category | string ) : string {
@@ -78,7 +79,7 @@ function normalizedCat(input: Category|string): string {
78
79
* `trace.enable(1)`
79
80
*/
80
81
export enum Category {
81
- RESOLVE , TRANSITION , HOOK , UIVIEW , VIEWCONFIG
82
+ RESOLVE , TRANSITION , HOOK , UIVIEW , VIEWCONFIG ,
82
83
}
83
84
84
85
/** @hidden */ const _tid = parse ( "$id" ) ;
@@ -121,7 +122,8 @@ export class Trace {
121
122
* @param categories categories to enable. If `categories` is omitted, all categories are enabled.
122
123
* Also takes strings (category name) or ordinal (category position)
123
124
*/
124
- enable ( ...categories : Category [ ] ) { this . _set ( true , categories ) }
125
+ enable ( ...categories : ( Category | string | number ) [ ] ) ;
126
+ enable ( ...categories : any [ ] ) { this . _set ( true , categories ) ; }
125
127
/**
126
128
* Disables a trace [[Category]]
127
129
*
@@ -132,7 +134,8 @@ export class Trace {
132
134
* @param categories categories to disable. If `categories` is omitted, all categories are disabled.
133
135
* Also takes strings (category name) or ordinal (category position)
134
136
*/
135
- disable ( ...categories : Category [ ] ) { this . _set ( false , categories ) }
137
+ disable ( ...categories : ( Category | string | number ) [ ] ) ;
138
+ disable ( ...categories : any [ ] ) { this . _set ( false , categories ) ; }
136
139
137
140
/**
138
141
* Retrieves the enabled stateus of a [[Category]]
@@ -143,7 +146,7 @@ export class Trace {
143
146
*
144
147
* @returns boolean true if the category is enabled
145
148
*/
146
- enabled ( category : Category ) : boolean {
149
+ enabled ( category : ( Category | string | number ) ) : boolean {
147
150
return ! ! this . _enabled [ normalizedCat ( category ) ] ;
148
151
}
149
152
@@ -216,6 +219,19 @@ export class Trace {
216
219
this . traceUIViewEvent ( "Fill" , viewData , ` with: ${ maxLength ( 200 , html ) } ` ) ;
217
220
}
218
221
222
+ /** @internalapi called by ui-router code */
223
+ traceViewSync ( pairs : any [ ] ) {
224
+ if ( ! this . enabled ( Category . VIEWCONFIG ) ) return ;
225
+ const mapping = pairs . map ( ( [ uiViewData , config ] ) => {
226
+ const uiView = `${ uiViewData . $type } :${ uiViewData . fqn } ` ;
227
+ const view = config && `${ config . viewDecl . $context . name } : ${ config . viewDecl . $name } (${ config . viewDecl . $type } )` ;
228
+
229
+ return { 'ui-view fqn' : uiView , 'state: view name' : view } ;
230
+ } ) . sort ( ( a , b ) => a [ 'ui-view fqn' ] . localeCompare ( b [ 'ui-view fqn' ] ) ) ;
231
+
232
+ console . table ( mapping ) ;
233
+ }
234
+
219
235
/** @internalapi called by ui-router code */
220
236
traceViewServiceEvent ( event : string , viewConfig : ViewConfig ) {
221
237
if ( ! this . enabled ( Category . VIEWCONFIG ) ) return ;
0 commit comments