devtools-tracing 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/generate.ts +32 -26
  2. package/index.ts +2 -1
  3. package/lib/extension-api/ExtensionAPI.d.ts +357 -0
  4. package/lib/front_end/models/bindings/CSSWorkspaceBinding.ts +318 -0
  5. package/lib/front_end/models/bindings/CompilerScriptMapping.ts +536 -0
  6. package/lib/front_end/models/bindings/ContentProviderBasedProject.ts +187 -0
  7. package/lib/front_end/models/bindings/DebuggerLanguagePlugins.ts +1197 -0
  8. package/lib/front_end/models/bindings/DebuggerWorkspaceBinding.ts +733 -0
  9. package/lib/front_end/models/bindings/DefaultScriptMapping.ts +141 -0
  10. package/lib/front_end/models/bindings/FileUtils.ts +228 -0
  11. package/lib/front_end/models/bindings/LiveLocation.ts +81 -0
  12. package/lib/front_end/models/bindings/NetworkProject.ts +157 -0
  13. package/lib/front_end/models/bindings/PresentationConsoleMessageHelper.ts +312 -0
  14. package/lib/front_end/models/bindings/ResourceMapping.ts +539 -0
  15. package/lib/front_end/models/bindings/ResourceScriptMapping.ts +491 -0
  16. package/lib/front_end/models/bindings/ResourceUtils.ts +103 -0
  17. package/lib/front_end/models/bindings/SASSSourceMapping.ts +222 -0
  18. package/lib/front_end/models/bindings/StylesSourceMapping.ts +316 -0
  19. package/lib/front_end/models/bindings/TempFile.ts +67 -0
  20. package/lib/front_end/models/bindings/bindings.ts +39 -0
  21. package/lib/front_end/models/source_map_scopes/NamesResolver.ts +765 -0
  22. package/lib/front_end/models/source_map_scopes/ScopeChainModel.ts +84 -0
  23. package/lib/front_end/models/source_map_scopes/source_map_scopes.ts +11 -0
  24. package/lib/front_end/models/stack_trace/StackTrace.ts +53 -0
  25. package/lib/front_end/models/stack_trace/StackTraceImpl.ts +85 -0
  26. package/lib/front_end/models/stack_trace/StackTraceModel.ts +128 -0
  27. package/lib/front_end/models/stack_trace/Trie.ts +163 -0
  28. package/lib/front_end/models/stack_trace/stack_trace.ts +9 -0
  29. package/lib/front_end/models/stack_trace/stack_trace_impl.ts +13 -0
  30. package/lib/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +240 -0
  31. package/lib/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.ts +5 -0
  32. package/lib/front_end/models/workspace/FileManager.ts +97 -0
  33. package/lib/front_end/models/workspace/IgnoreListManager.ts +628 -0
  34. package/lib/front_end/models/workspace/SearchConfig.ts +149 -0
  35. package/lib/front_end/models/workspace/UISourceCode.ts +698 -0
  36. package/lib/front_end/models/workspace/WorkspaceImpl.ts +339 -0
  37. package/lib/front_end/models/workspace/workspace.ts +17 -0
  38. package/lib/front_end/panels/timeline/TimelineUIUtils.ts +1029 -0
  39. package/lib/front_end/panels/timeline/extensions/ExtensionUI.ts +49 -0
  40. package/lib/front_end/panels/timeline/extensions/extensions.ts +9 -0
  41. package/lib/front_end/third_party/codemirror.next/LICENSE +21 -0
  42. package/lib/front_end/third_party/codemirror.next/README.chromium +30 -0
  43. package/lib/front_end/third_party/codemirror.next/bundle-tsconfig.json +24 -0
  44. package/lib/front_end/third_party/codemirror.next/bundle.ts +135 -0
  45. package/lib/front_end/third_party/codemirror.next/chunk/angular.js +2 -0
  46. package/lib/front_end/third_party/codemirror.next/chunk/angular.js.map +1 -0
  47. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js +2 -0
  48. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js.map +1 -0
  49. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js +2 -0
  50. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js.map +1 -0
  51. package/lib/front_end/third_party/codemirror.next/chunk/css.js +2 -0
  52. package/lib/front_end/third_party/codemirror.next/chunk/html.js +4 -0
  53. package/lib/front_end/third_party/codemirror.next/chunk/java.js +2 -0
  54. package/lib/front_end/third_party/codemirror.next/chunk/java.js.map +1 -0
  55. package/lib/front_end/third_party/codemirror.next/chunk/javascript.js +2 -0
  56. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js +2 -0
  57. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js.map +1 -0
  58. package/lib/front_end/third_party/codemirror.next/chunk/less.js +2 -0
  59. package/lib/front_end/third_party/codemirror.next/chunk/less.js.map +1 -0
  60. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js +2 -0
  61. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js.map +1 -0
  62. package/lib/front_end/third_party/codemirror.next/chunk/php.js +2 -0
  63. package/lib/front_end/third_party/codemirror.next/chunk/php.js.map +1 -0
  64. package/lib/front_end/third_party/codemirror.next/chunk/python.js +2 -0
  65. package/lib/front_end/third_party/codemirror.next/chunk/python.js.map +1 -0
  66. package/lib/front_end/third_party/codemirror.next/chunk/sass.js +2 -0
  67. package/lib/front_end/third_party/codemirror.next/chunk/sass.js.map +1 -0
  68. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js +2 -0
  69. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js.map +1 -0
  70. package/lib/front_end/third_party/codemirror.next/chunk/vue.js +2 -0
  71. package/lib/front_end/third_party/codemirror.next/chunk/vue.js.map +1 -0
  72. package/lib/front_end/third_party/codemirror.next/chunk/wast.js +2 -0
  73. package/lib/front_end/third_party/codemirror.next/chunk/wast.js.map +1 -0
  74. package/lib/front_end/third_party/codemirror.next/chunk/xml.js +2 -0
  75. package/lib/front_end/third_party/codemirror.next/chunk/xml.js.map +1 -0
  76. package/lib/front_end/third_party/codemirror.next/codemirror.next.d.ts +8057 -0
  77. package/lib/front_end/third_party/codemirror.next/codemirror.next.js +2 -0
  78. package/lib/front_end/third_party/codemirror.next/codemirror.next.js.map +1 -0
  79. package/lib/front_end/third_party/codemirror.next/package.json +43 -0
  80. package/lib/front_end/third_party/codemirror.next/rebuild.sh +6 -0
  81. package/lib/front_end/third_party/codemirror.next/rollup.config.mjs +49 -0
  82. package/lib/front_end/third_party/source-map-scopes-codec/LICENSE +26 -0
  83. package/lib/front_end/third_party/source-map-scopes-codec/README.chromium +31 -0
  84. package/lib/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +33 -0
  85. package/lib/front_end/third_party/source-map-scopes-codec/package/LICENSE +26 -0
  86. package/lib/front_end/third_party/source-map-scopes-codec/package/README.md +64 -0
  87. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +62 -0
  88. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -0
  89. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +37 -0
  90. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +1 -0
  91. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +29 -0
  92. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +1 -0
  93. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +8 -0
  94. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +1 -0
  95. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +6 -0
  96. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +1 -0
  97. package/lib/front_end/third_party/source-map-scopes-codec/package/deno.json +21 -0
  98. package/lib/front_end/third_party/source-map-scopes-codec/package/package.json +14 -0
  99. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +196 -0
  100. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +1 -0
  101. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +262 -0
  102. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +235 -0
  103. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +1 -0
  104. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +359 -0
  105. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js +39 -0
  106. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +1 -0
  107. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +53 -0
  108. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +438 -0
  109. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +1 -0
  110. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +539 -0
  111. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +23 -0
  112. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +1 -0
  113. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +35 -0
  114. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +257 -0
  115. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +1 -0
  116. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +348 -0
  117. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js +8 -0
  118. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +1 -0
  119. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +20 -0
  120. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes-tsconfig.json +8 -0
  121. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes.d.ts +184 -0
  122. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js +9 -0
  123. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +1 -0
  124. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.ts +12 -0
  125. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +82 -0
  126. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +1 -0
  127. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +99 -0
  128. package/lib/front_end/third_party/source-map-scopes-codec/source-map-scopes-codec.ts +5 -0
  129. package/lib/front_end/ui/legacy/theme_support/ThemeSupport.ts +222 -0
  130. package/lib/front_end/ui/legacy/theme_support/theme_support.ts +5 -0
  131. package/package.json +5 -5
  132. package/patches/chrome-devtools-frontend+1.0.1533544.patch +1549 -20
@@ -0,0 +1,339 @@
1
+ // Copyright 2012 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as Common from '../../core/common/common.js';
6
+ import type * as Platform from '../../core/platform/platform.js';
7
+ import type * as TextUtils from '../text_utils/text_utils.js';
8
+
9
+ import type {SearchConfig} from './SearchConfig.js';
10
+ import {UISourceCode, type UISourceCodeMetadata} from './UISourceCode.js';
11
+
12
+ export interface Project {
13
+ workspace(): WorkspaceImpl;
14
+ id(): string;
15
+ type(): projectTypes;
16
+ isServiceProject(): boolean;
17
+ displayName(): string;
18
+ requestMetadata(uiSourceCode: UISourceCode): Promise<UISourceCodeMetadata|null>;
19
+ requestFileContent(uiSourceCode: UISourceCode): Promise<TextUtils.ContentData.ContentDataOrError>;
20
+ canSetFileContent(): boolean;
21
+ setFileContent(uiSourceCode: UISourceCode, newContent: string, isBase64: boolean): Promise<void>;
22
+ fullDisplayName(uiSourceCode: UISourceCode): string;
23
+ mimeType(uiSourceCode: UISourceCode): string;
24
+ canRename(): boolean;
25
+ rename(
26
+ uiSourceCode: UISourceCode, newName: Platform.DevToolsPath.RawPathString,
27
+ callback:
28
+ (arg0: boolean, arg1?: string, arg2?: Platform.DevToolsPath.UrlString,
29
+ arg3?: Common.ResourceType.ResourceType) => void): void;
30
+ excludeFolder(path: Platform.DevToolsPath.UrlString): void;
31
+ canExcludeFolder(path: Platform.DevToolsPath.EncodedPathString): boolean;
32
+ createFile(path: Platform.DevToolsPath.EncodedPathString, name: string|null, content: string, isBase64?: boolean):
33
+ Promise<UISourceCode|null>;
34
+ canCreateFile(): boolean;
35
+ deleteFile(uiSourceCode: UISourceCode): void;
36
+ deleteDirectoryRecursively(path: Platform.DevToolsPath.EncodedPathString): Promise<boolean>;
37
+ remove(): void;
38
+ removeUISourceCode(url: Platform.DevToolsPath.UrlString): void;
39
+ searchInFileContent(uiSourceCode: UISourceCode, query: string, caseSensitive: boolean, isRegex: boolean):
40
+ Promise<TextUtils.ContentProvider.SearchMatch[]>;
41
+ findFilesMatchingSearchRequest(
42
+ searchConfig: SearchConfig, filesMatchingFileQuery: UISourceCode[],
43
+ progress: Common.Progress.Progress): Promise<Map<UISourceCode, TextUtils.ContentProvider.SearchMatch[]|null>>;
44
+ indexContent(progress: Common.Progress.Progress): void;
45
+ uiSourceCodeForURL(url: Platform.DevToolsPath.UrlString): UISourceCode|null;
46
+
47
+ /**
48
+ * Returns an iterator for the currently registered {@link UISourceCode}s for this project. When
49
+ * new {@link UISourceCode}s are added while iterating, they might show up already. When removing
50
+ * {@link UISourceCode}s while iterating, these will no longer show up, and will have no effect
51
+ * on the other entries.
52
+ *
53
+ * @returns an iterator for the sources provided by this project.
54
+ */
55
+ uiSourceCodes(): Iterable<UISourceCode>;
56
+ }
57
+
58
+ /* eslint-disable @typescript-eslint/naming-convention -- Used by web_tests. */
59
+ export enum projectTypes {
60
+ Debugger = 'debugger',
61
+ Formatter = 'formatter',
62
+ Network = 'network',
63
+ FileSystem = 'filesystem',
64
+ ConnectableFileSystem = 'connectablefilesystem',
65
+ ContentScripts = 'contentscripts',
66
+ Service = 'service',
67
+ }
68
+ /* eslint-enable @typescript-eslint/naming-convention */
69
+
70
+ export abstract class ProjectStore implements Project {
71
+ readonly #workspace: WorkspaceImpl;
72
+ readonly #id: string;
73
+ readonly #type: projectTypes;
74
+ readonly #displayName: string;
75
+ readonly #uiSourceCodes = new Map<Platform.DevToolsPath.UrlString, UISourceCode>();
76
+
77
+ constructor(workspace: WorkspaceImpl, id: string, type: projectTypes, displayName: string) {
78
+ this.#workspace = workspace;
79
+ this.#id = id;
80
+ this.#type = type;
81
+ this.#displayName = displayName;
82
+ }
83
+
84
+ id(): string {
85
+ return this.#id;
86
+ }
87
+
88
+ type(): projectTypes {
89
+ return this.#type;
90
+ }
91
+
92
+ displayName(): string {
93
+ return this.#displayName;
94
+ }
95
+
96
+ workspace(): WorkspaceImpl {
97
+ return this.#workspace;
98
+ }
99
+
100
+ createUISourceCode(url: Platform.DevToolsPath.UrlString, contentType: Common.ResourceType.ResourceType):
101
+ UISourceCode {
102
+ return new UISourceCode(this, url, contentType);
103
+ }
104
+
105
+ addUISourceCode(uiSourceCode: UISourceCode): boolean {
106
+ const url = uiSourceCode.url();
107
+ if (this.uiSourceCodeForURL(url)) {
108
+ return false;
109
+ }
110
+ this.#uiSourceCodes.set(url, uiSourceCode);
111
+ this.#workspace.dispatchEventToListeners(Events.UISourceCodeAdded, uiSourceCode);
112
+ return true;
113
+ }
114
+
115
+ removeUISourceCode(url: Platform.DevToolsPath.UrlString): void {
116
+ const uiSourceCode = this.#uiSourceCodes.get(url);
117
+ if (uiSourceCode === undefined) {
118
+ return;
119
+ }
120
+ this.#uiSourceCodes.delete(url);
121
+ this.#workspace.dispatchEventToListeners(Events.UISourceCodeRemoved, uiSourceCode);
122
+ }
123
+
124
+ removeProject(): void {
125
+ this.#workspace.removeProject(this);
126
+ this.#uiSourceCodes.clear();
127
+ }
128
+
129
+ uiSourceCodeForURL(url: Platform.DevToolsPath.UrlString): UISourceCode|null {
130
+ return this.#uiSourceCodes.get(url) ?? null;
131
+ }
132
+
133
+ uiSourceCodes(): Iterable<UISourceCode> {
134
+ return this.#uiSourceCodes.values();
135
+ }
136
+
137
+ renameUISourceCode(uiSourceCode: UISourceCode, newName: string): void {
138
+ const oldPath = uiSourceCode.url();
139
+ const newPath = uiSourceCode.parentURL() ?
140
+ Common.ParsedURL.ParsedURL.urlFromParentUrlAndName(uiSourceCode.parentURL(), newName) :
141
+ Common.ParsedURL.ParsedURL.preEncodeSpecialCharactersInPath(newName) as Platform.DevToolsPath.UrlString;
142
+ this.#uiSourceCodes.set(newPath, uiSourceCode);
143
+ this.#uiSourceCodes.delete(oldPath);
144
+ }
145
+
146
+ // No-op implementation for a handful of interface methods.
147
+
148
+ rename(
149
+ _uiSourceCode: UISourceCode, _newName: string,
150
+ _callback:
151
+ (arg0: boolean, arg1?: string, arg2?: Platform.DevToolsPath.UrlString,
152
+ arg3?: Common.ResourceType.ResourceType) => void): void {
153
+ }
154
+ excludeFolder(_path: Platform.DevToolsPath.UrlString): void {
155
+ }
156
+ deleteFile(_uiSourceCode: UISourceCode): void {
157
+ }
158
+ deleteDirectoryRecursively(_path: Platform.DevToolsPath.EncodedPathString): Promise<boolean> {
159
+ return Promise.resolve(false);
160
+ }
161
+ remove(): void {
162
+ }
163
+ indexContent(_progress: Common.Progress.Progress): void {
164
+ }
165
+
166
+ abstract isServiceProject(): boolean;
167
+ abstract requestMetadata(uiSourceCode: UISourceCode): Promise<UISourceCodeMetadata|null>;
168
+ abstract requestFileContent(uiSourceCode: UISourceCode): Promise<TextUtils.ContentData.ContentDataOrError>;
169
+ abstract canSetFileContent(): boolean;
170
+ abstract setFileContent(uiSourceCode: UISourceCode, newContent: string, isBase64: boolean): Promise<void>;
171
+ abstract fullDisplayName(uiSourceCode: UISourceCode): string;
172
+ abstract mimeType(uiSourceCode: UISourceCode): string;
173
+ abstract canRename(): boolean;
174
+ abstract canExcludeFolder(path: Platform.DevToolsPath.EncodedPathString): boolean;
175
+ abstract createFile(
176
+ path: Platform.DevToolsPath.EncodedPathString, name: string|null, content: string,
177
+ isBase64?: boolean): Promise<UISourceCode|null>;
178
+ abstract canCreateFile(): boolean;
179
+ abstract searchInFileContent(uiSourceCode: UISourceCode, query: string, caseSensitive: boolean, isRegex: boolean):
180
+ Promise<TextUtils.ContentProvider.SearchMatch[]>;
181
+ abstract findFilesMatchingSearchRequest(
182
+ searchConfig: SearchConfig, filesMatchingFileQuery: UISourceCode[],
183
+ progress: Common.Progress.Progress): Promise<Map<UISourceCode, TextUtils.ContentProvider.SearchMatch[]|null>>;
184
+ }
185
+
186
+ let workspaceInstance: WorkspaceImpl|undefined;
187
+
188
+ export class WorkspaceImpl extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
189
+ #projects = new Map<string, Project>();
190
+ #hasResourceContentTrackingExtensions = false;
191
+
192
+ private constructor() {
193
+ super();
194
+ }
195
+
196
+ static instance(opts: {forceNew: boolean|null} = {forceNew: null}): WorkspaceImpl {
197
+ const {forceNew} = opts;
198
+ if (!workspaceInstance || forceNew) {
199
+ workspaceInstance = new WorkspaceImpl();
200
+ }
201
+
202
+ return workspaceInstance;
203
+ }
204
+
205
+ static removeInstance(): void {
206
+ workspaceInstance = undefined;
207
+ }
208
+
209
+ uiSourceCode(projectId: string, url: Platform.DevToolsPath.UrlString): UISourceCode|null {
210
+ const project = this.#projects.get(projectId);
211
+ return project ? project.uiSourceCodeForURL(url) : null;
212
+ }
213
+
214
+ uiSourceCodeForURL(url: Platform.DevToolsPath.UrlString): UISourceCode|null {
215
+ for (const project of this.#projects.values()) {
216
+ const uiSourceCode = project.uiSourceCodeForURL(url);
217
+ if (uiSourceCode) {
218
+ return uiSourceCode;
219
+ }
220
+ }
221
+ return null;
222
+ }
223
+
224
+ findCompatibleUISourceCodes(uiSourceCode: UISourceCode): UISourceCode[] {
225
+ const url = uiSourceCode.url();
226
+ const contentType = uiSourceCode.contentType();
227
+ const result: UISourceCode[] = [];
228
+ for (const project of this.#projects.values()) {
229
+ if (uiSourceCode.project().type() !== project.type()) {
230
+ continue;
231
+ }
232
+ const candidate = project.uiSourceCodeForURL(url);
233
+ if (candidate && candidate.url() === url && candidate.contentType() === contentType) {
234
+ result.push(candidate);
235
+ }
236
+ }
237
+ return result;
238
+ }
239
+
240
+ uiSourceCodesForProjectType(type: projectTypes): UISourceCode[] {
241
+ const result: UISourceCode[] = [];
242
+ for (const project of this.#projects.values()) {
243
+ if (project.type() === type) {
244
+ for (const uiSourceCode of project.uiSourceCodes()) {
245
+ result.push(uiSourceCode);
246
+ }
247
+ }
248
+ }
249
+ return result;
250
+ }
251
+
252
+ addProject(project: Project): void {
253
+ console.assert(!this.#projects.has(project.id()), `A project with id ${project.id()} already exists!`);
254
+ this.#projects.set(project.id(), project);
255
+ this.dispatchEventToListeners(Events.ProjectAdded, project);
256
+ }
257
+
258
+ removeProject(project: Project): void {
259
+ this.#projects.delete(project.id());
260
+ this.dispatchEventToListeners(Events.ProjectRemoved, project);
261
+ }
262
+
263
+ project(projectId: string): Project|null {
264
+ return this.#projects.get(projectId) || null;
265
+ }
266
+
267
+ projectForFileSystemRoot(root: Platform.DevToolsPath.RawPathString): Project|null {
268
+ const projectId = Common.ParsedURL.ParsedURL.rawPathToUrlString(root);
269
+ return this.project(projectId);
270
+ }
271
+
272
+ projects(): Project[] {
273
+ return [...this.#projects.values()];
274
+ }
275
+
276
+ projectsForType(type: string): Project[] {
277
+ function filterByType(project: Project): boolean {
278
+ return project.type() === type;
279
+ }
280
+ return this.projects().filter(filterByType);
281
+ }
282
+
283
+ uiSourceCodes(): UISourceCode[] {
284
+ const result: UISourceCode[] = [];
285
+ for (const project of this.#projects.values()) {
286
+ for (const uiSourceCode of project.uiSourceCodes()) {
287
+ result.push(uiSourceCode);
288
+ }
289
+ }
290
+ return result;
291
+ }
292
+
293
+ setHasResourceContentTrackingExtensions(hasExtensions: boolean): void {
294
+ this.#hasResourceContentTrackingExtensions = hasExtensions;
295
+ }
296
+
297
+ hasResourceContentTrackingExtensions(): boolean {
298
+ return this.#hasResourceContentTrackingExtensions;
299
+ }
300
+ }
301
+
302
+ export enum Events {
303
+ /* eslint-disable @typescript-eslint/naming-convention -- Used by web_tests. */
304
+ UISourceCodeAdded = 'UISourceCodeAdded',
305
+ UISourceCodeRemoved = 'UISourceCodeRemoved',
306
+ UISourceCodeRenamed = 'UISourceCodeRenamed',
307
+ WorkingCopyChanged = 'WorkingCopyChanged',
308
+ WorkingCopyCommitted = 'WorkingCopyCommitted',
309
+ WorkingCopyCommittedByUser = 'WorkingCopyCommittedByUser',
310
+ ProjectAdded = 'ProjectAdded',
311
+ ProjectRemoved = 'ProjectRemoved',
312
+ /* eslint-enable @typescript-eslint/naming-convention */
313
+ }
314
+
315
+ export interface UISourceCodeRenamedEvent {
316
+ oldURL: Platform.DevToolsPath.UrlString;
317
+ uiSourceCode: UISourceCode;
318
+ }
319
+
320
+ export interface WorkingCopyChangedEvent {
321
+ uiSourceCode: UISourceCode;
322
+ }
323
+
324
+ export interface WorkingCopyCommittedEvent {
325
+ uiSourceCode: UISourceCode;
326
+ content: string;
327
+ encoded?: boolean;
328
+ }
329
+
330
+ export interface EventTypes {
331
+ [Events.UISourceCodeAdded]: UISourceCode;
332
+ [Events.UISourceCodeRemoved]: UISourceCode;
333
+ [Events.UISourceCodeRenamed]: UISourceCodeRenamedEvent;
334
+ [Events.WorkingCopyChanged]: WorkingCopyChangedEvent;
335
+ [Events.WorkingCopyCommitted]: WorkingCopyCommittedEvent;
336
+ [Events.WorkingCopyCommittedByUser]: WorkingCopyCommittedEvent;
337
+ [Events.ProjectAdded]: Project;
338
+ [Events.ProjectRemoved]: Project;
339
+ }
@@ -0,0 +1,17 @@
1
+ // Copyright 2019 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as FileManager from './FileManager.js';
6
+ import * as IgnoreListManager from './IgnoreListManager.js';
7
+ import * as SearchConfig from './SearchConfig.js';
8
+ import * as UISourceCode from './UISourceCode.js';
9
+ import * as Workspace from './WorkspaceImpl.js';
10
+
11
+ export {
12
+ FileManager,
13
+ IgnoreListManager,
14
+ SearchConfig,
15
+ UISourceCode,
16
+ Workspace,
17
+ };