angular/devtools/projects/protocol/src/lib/messages.ts
AleksanderBodurri 2a1ff17b42 refactor(devtools): run tslint --fix on devtools codebase
This commit runs tslint --fix with the angular/angular tslint configuration on the files inside the devtools codebase.

Notably, the file-header rule in `tslint.json` was missing a default attribute. This commit adds that default attribute and sets it to the
license header that is present in all files in this repo. After running tslint --fix with this default added, this commit added the license header to all files in the devtools directory. Note for the reviewer: the automatically added license headers were added as comments with the "/*!" prefix. Since we want these comments removed in builds, and the rest of the codebase uses "/**", a simple find and replace was performed on the devtools directory to change these prefixes to "/**".
2022-01-26 16:35:31 -05:00

203 lines
4.4 KiB
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {ViewEncapsulation} from '@angular/core';
export interface DirectiveType {
name: string;
id: number;
}
export interface ComponentType {
name: string;
isElement: boolean;
id: number;
}
export interface DevToolsNode<DirType = DirectiveType, CmpType = ComponentType> {
element: string;
directives: DirType[];
component: CmpType|null;
children: DevToolsNode<DirType, CmpType>[];
nativeElement?: Node;
}
export enum PropType {
Number,
String,
Null,
Undefined,
Symbol,
HTMLNode,
Boolean,
BigInt,
Function,
Object,
Date,
Array,
Unknown,
}
export interface Descriptor {
expandable: boolean;
value?: any;
editable: boolean;
type: PropType;
preview: string;
}
export interface DirectivesProperties {
[name: string]: Properties;
}
export interface DirectiveMetadata {
inputs: {[name: string]: string};
outputs: {[name: string]: string};
encapsulation: ViewEncapsulation;
onPush: boolean;
}
export interface Properties {
props: {[name: string]: Descriptor};
metadata?: DirectiveMetadata;
}
export type ElementPosition = number[];
export interface DirectivePosition {
element: ElementPosition;
directive?: number;
}
export interface NestedProp {
name: string|number;
children: NestedProp[];
}
export interface ComponentExplorerViewProperties {
[directive: string]: NestedProp[];
}
export enum PropertyQueryTypes {
All,
Specified,
}
export interface AllPropertiesQuery {
type: PropertyQueryTypes.All;
}
export interface SelectedPropertiesQuery {
type: PropertyQueryTypes.Specified;
properties: ComponentExplorerViewProperties;
}
export type PropertyQuery = AllPropertiesQuery|SelectedPropertiesQuery;
export interface ComponentExplorerViewQuery {
selectedElement: ElementPosition;
propertyQuery: PropertyQuery;
}
export interface ComponentExplorerView {
forest: DevToolsNode[];
properties?: DirectivesProperties;
}
export interface LifecycleProfile {
ngOnInit?: number;
ngOnDestroy?: number;
ngOnChanges?: number;
ngDoCheck?: number;
ngAfterContentInit?: number;
ngAfterContentChecked?: number;
ngAfterViewInit?: number;
ngAfterViewChecked?: number;
}
export interface OutputProfile {
[outputName: string]: number;
}
export interface DirectiveProfile {
name: string;
isElement: boolean;
isComponent: boolean;
lifecycle: LifecycleProfile;
outputs: OutputProfile;
changeDetection?: number;
}
export interface ElementProfile {
directives: DirectiveProfile[];
children: ElementProfile[];
}
export interface ProfilerFrame {
source: string;
duration: number;
directives: ElementProfile[];
}
export interface UpdatedStateData {
directiveId: DirectivePosition;
keyPath: string[];
newValue: any;
}
export interface Route {
name: string;
hash: string|null;
path: string;
specificity: string|null;
handler: string;
data: any;
children?: Array<Route>;
isAux: boolean;
}
export type Topic = keyof Events;
export interface Events {
handshake: () => void;
shutdown: () => void;
queryNgAvailability: () => void;
ngAvailability:
(config: {version: string|undefined|boolean; devMode: boolean; ivy: boolean}) => void;
inspectorStart: () => void;
inspectorEnd: () => void;
getNestedProperties: (position: DirectivePosition, path: string[]) => void;
nestedProperties: (position: DirectivePosition, data: Properties, path: string[]) => void;
setSelectedComponent: (position: ElementPosition) => void;
getRoutes: () => void;
updateRouterTree: (routes: Route[]) => void;
componentTreeDirty: () => void;
getLatestComponentExplorerView: (query?: ComponentExplorerViewQuery) => void;
latestComponentExplorerView: (view: ComponentExplorerView) => void;
updateState: (value: UpdatedStateData) => void;
startProfiling: () => void;
stopProfiling: () => void;
sendProfilerChunk: (results: ProfilerFrame) => void;
profilerResults: (results: ProfilerFrame) => void;
createHighlightOverlay: (position: ElementPosition) => void;
removeHighlightOverlay: () => void;
highlightComponent: (id: number) => void;
selectComponent: (id: number) => void;
removeComponentHighlight: () => void;
enableTimingAPI: () => void;
disableTimingAPI: () => void;
}