forked from firefox-devtools/profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreducers.js
153 lines (139 loc) · 4.06 KB
/
reducers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// @flow
import type {
Action,
DataSource,
ProfileSelection,
ImplementationFilter,
TabSlug,
} from './actions';
import type { Milliseconds, StartEndRange } from './units';
import type { IndexIntoMarkersTable, Profile, ThreadIndex } from './profile';
import type { CallNodePath } from './profile-derived';
import type { Attempt } from '../utils/errors';
import type { GetLabel } from '../profile-logic/labeling-strategies';
import type { GetCategory } from '../profile-logic/color-categories';
import type { TransformStacksPerThread } from './transforms';
import type JSZip from 'jszip';
import type { IndexIntoZipFileTable } from '../profile-logic/zip-files';
import type { PathSet } from '../utils/path.js';
export type Reducer<T> = (T | void, Action) => T;
export type RequestedLib = { debugName: string, breakpadId: string };
export type SymbolicationStatus = 'DONE' | 'SYMBOLICATING';
export type ThreadViewOptions = {
selectedCallNodePath: CallNodePath,
expandedCallNodePaths: PathSet,
selectedMarker: IndexIntoMarkersTable | -1,
};
export type ProfileViewState = {
viewOptions: {
perThread: ThreadViewOptions[],
symbolicationStatus: SymbolicationStatus,
waitingForLibs: Set<RequestedLib>,
selection: ProfileSelection,
scrollToSelectionGeneration: number,
focusCallTreeGeneration: number,
rootRange: StartEndRange,
zeroAt: Milliseconds,
tabOrder: number[],
rightClickedThread: ThreadIndex,
isCallNodeContextMenuVisible: boolean,
},
profile: Profile | null,
};
export type AppViewState =
| {| +phase: 'ROUTE_NOT_FOUND' |}
| {| +phase: 'DATA_LOADED' |}
| {| +phase: 'FATAL_ERROR', +error: Error |}
| {|
+phase: 'INITIALIZING',
+additionalData?: {| +attempt: Attempt | null, +message: string |},
|};
/**
* This represents the finite state machine for loading zip files. The phase represents
* where the state is now.
*/
export type ZipFileState =
| {|
+phase: 'NO_ZIP_FILE',
+zip: null,
+pathInZipFile: null,
|}
| {|
+phase: 'LIST_FILES_IN_ZIP_FILE',
+zip: JSZip,
+pathInZipFile: null,
|}
| {|
+phase: 'PROCESS_PROFILE_FROM_ZIP_FILE',
+zip: JSZip,
+pathInZipFile: string,
|}
| {|
+phase: 'FAILED_TO_PROCESS_PROFILE_FROM_ZIP_FILE',
+zip: JSZip,
+pathInZipFile: string,
|}
| {|
+phase: 'FILE_NOT_FOUND_IN_ZIP_FILE',
+zip: JSZip,
+pathInZipFile: string,
|}
| {|
+phase: 'VIEW_PROFILE_IN_ZIP_FILE',
+zip: JSZip,
+pathInZipFile: string,
|};
export type AppState = {
view: AppViewState,
isUrlSetupDone: boolean,
hasZoomedViaMousewheel: boolean,
};
export type ZippedProfilesState = {
zipFile: ZipFileState,
selectedZipFileIndex: IndexIntoZipFileTable | null,
// In practice this should never contain null, but needs to support the
// TreeView interface.
expandedZipFileIndexes: Array<IndexIntoZipFileTable | null>,
};
export type RangeFilterState = {
start: number,
end: number,
};
export type UrlState = {|
dataSource: DataSource,
hash: string,
profileUrl: string,
selectedTab: TabSlug,
pathInZipFile: string | null,
profileSpecific: {|
implementation: ImplementationFilter,
invertCallstack: boolean,
rangeFilters: RangeFilterState[],
selectedThread: ThreadIndex | null,
callTreeSearchString: string,
threadOrder: ThreadIndex[],
hiddenThreads: ThreadIndex[],
markersSearchString: string,
transforms: TransformStacksPerThread,
|},
|};
export type IconState = Set<string>;
export type StackChartState = {
categoryColorStrategy: GetCategory,
labelingStrategy: GetLabel,
};
export type State = {|
app: AppState,
profileView: ProfileViewState,
urlState: UrlState,
stackChart: StackChartState,
icons: IconState,
zippedProfiles: ZippedProfilesState,
|};
export type IconWithClassName = {
icon: string,
className: string,
};