chrome-devtools-frontend 1.0.927127 → 1.0.928589
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.
- package/AUTHORS +1 -0
- package/config/gni/all_devtools_files.gni +0 -1
- package/config/gni/devtools_grd_files.gni +30 -4
- package/config/gni/devtools_image_files.gni +1 -0
- package/front_end/Images/src/ic_preview_feature.svg +3 -0
- package/front_end/Tests.js +2 -3
- package/front_end/core/common/Settings.ts +26 -45
- package/front_end/core/host/UserMetrics.ts +2 -2
- package/front_end/core/i18n/locales/en-US.json +60 -15
- package/front_end/core/i18n/locales/en-XL.json +60 -15
- package/front_end/core/platform/keyboard-utilities.ts +1 -0
- package/front_end/core/root/Runtime.ts +62 -61
- package/front_end/core/sdk/AccessibilityModel.ts +73 -73
- package/front_end/core/sdk/CPUProfileDataModel.ts +14 -14
- package/front_end/core/sdk/CPUProfilerModel.ts +33 -33
- package/front_end/core/sdk/CPUThrottlingManager.ts +8 -8
- package/front_end/core/sdk/CSSFontFace.ts +10 -10
- package/front_end/core/sdk/CSSMatchedStyles.ts +114 -114
- package/front_end/core/sdk/CSSMedia.ts +22 -22
- package/front_end/core/sdk/CSSMetadata.ts +53 -49
- package/front_end/core/sdk/CSSModel.ts +139 -135
- package/front_end/core/sdk/CSSProperty.ts +18 -18
- package/front_end/core/sdk/CSSRule.ts +15 -15
- package/front_end/core/sdk/CSSStyleDeclaration.ts +49 -47
- package/front_end/core/sdk/CSSStyleSheetHeader.ts +12 -12
- package/front_end/core/sdk/ChildTargetManager.ts +41 -40
- package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +10 -10
- package/front_end/core/sdk/Connections.ts +81 -81
- package/front_end/core/sdk/ConsoleModel.ts +68 -68
- package/front_end/core/sdk/Cookie.ts +48 -48
- package/front_end/core/sdk/CookieModel.ts +13 -13
- package/front_end/core/sdk/CookieParser.ts +45 -45
- package/front_end/core/sdk/DOMDebuggerModel.ts +131 -131
- package/front_end/core/sdk/DOMModel.ts +264 -252
- package/front_end/core/sdk/DebuggerModel.ts +209 -205
- package/front_end/core/sdk/EmulationModel.ts +76 -76
- package/front_end/core/sdk/FilmStripModel.ts +29 -29
- package/front_end/core/sdk/FrameManager.ts +43 -42
- package/front_end/core/sdk/HeapProfilerModel.ts +36 -36
- package/front_end/core/sdk/IsolateManager.ts +82 -82
- package/front_end/core/sdk/IssuesModel.ts +6 -6
- package/front_end/core/sdk/LayerTreeBase.ts +37 -37
- package/front_end/core/sdk/LogModel.ts +5 -5
- package/front_end/core/sdk/NetworkManager.ts +229 -225
- package/front_end/core/sdk/NetworkRequest.ts +368 -360
- package/front_end/core/sdk/OverlayColorGenerator.ts +9 -9
- package/front_end/core/sdk/OverlayModel.ts +155 -153
- package/front_end/core/sdk/OverlayPersistentHighlighter.ts +100 -101
- package/front_end/core/sdk/PageResourceLoader.ts +30 -30
- package/front_end/core/sdk/PaintProfiler.ts +16 -16
- package/front_end/core/sdk/PerformanceMetricsModel.ts +12 -12
- package/front_end/core/sdk/ProfileTreeModel.ts +3 -3
- package/front_end/core/sdk/RemoteObject.ts +108 -104
- package/front_end/core/sdk/Resource.ts +85 -84
- package/front_end/core/sdk/ResourceTreeModel.ts +150 -145
- package/front_end/core/sdk/RuntimeModel.ts +38 -34
- package/front_end/core/sdk/SDKModel.ts +3 -3
- package/front_end/core/sdk/ScreenCaptureModel.ts +19 -19
- package/front_end/core/sdk/Script.ts +29 -29
- package/front_end/core/sdk/SecurityOriginManager.ts +19 -19
- package/front_end/core/sdk/ServerTiming.ts +2 -2
- package/front_end/core/sdk/ServiceWorkerCacheModel.ts +43 -43
- package/front_end/core/sdk/ServiceWorkerManager.ts +72 -68
- package/front_end/core/sdk/SourceMap.ts +40 -36
- package/front_end/core/sdk/SourceMapManager.ts +57 -57
- package/front_end/core/sdk/Target.ts +64 -63
- package/front_end/core/sdk/TargetManager.ts +60 -56
- package/front_end/core/sdk/TracingManager.ts +39 -39
- package/front_end/core/sdk/TracingModel.ts +125 -125
- package/front_end/core/sdk/WebAuthnModel.ts +9 -9
- package/front_end/entrypoints/lighthouse_worker/{LighthouseService.js → LighthouseService.ts} +20 -45
- package/front_end/entrypoints/lighthouse_worker/{lighthouse_worker.js → lighthouse_worker.ts} +0 -0
- package/front_end/entrypoints/main/MainImpl.ts +7 -2
- package/front_end/legacy_test_runner/elements_test_runner/ElementsTestRunner.js +4 -4
- package/front_end/legacy_test_runner/sdk_test_runner/sdk_test_runner.js +1 -1
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +0 -6
- package/front_end/models/issues_manager/GenericIssue.ts +86 -0
- package/front_end/models/issues_manager/Issue.ts +24 -0
- package/front_end/models/issues_manager/IssuesManager.ts +18 -6
- package/front_end/models/issues_manager/descriptions/genericCrossOriginPortalPostMessageError.md +3 -0
- package/front_end/models/issues_manager/issues_manager.ts +2 -0
- package/front_end/models/javascript_metadata/NativeFunctions.js +5422 -1
- package/front_end/panels/console/ConsoleSidebar.ts +0 -3
- package/front_end/panels/elements/ElementsTreeElement.ts +53 -61
- package/front_end/panels/elements/ElementsTreeOutline.ts +0 -1
- package/front_end/panels/elements/components/LayoutPane.ts +5 -1
- package/front_end/panels/issues/GenericIssueDetailsView.ts +68 -0
- package/front_end/panels/issues/IssueAggregator.ts +16 -0
- package/front_end/panels/issues/IssueKindView.ts +95 -0
- package/front_end/panels/issues/IssueView.ts +6 -0
- package/front_end/panels/issues/IssuesPane.ts +81 -18
- package/front_end/panels/issues/issuesTree.css +8 -3
- package/front_end/panels/lighthouse/LighthouseController.ts +3 -1
- package/front_end/panels/network/NetworkItemView.ts +1 -1
- package/front_end/panels/network/networkLogView.css +5 -0
- package/front_end/panels/sensors/LocationsSettingsTab.ts +1 -1
- package/front_end/panels/settings/SettingsScreen.ts +1 -0
- package/front_end/panels/settings/settingsScreen.css +24 -0
- package/front_end/panels/snippets/SnippetsQuickOpen.ts +8 -3
- package/front_end/panels/sources/TabbedEditorContainer.ts +1 -1
- package/front_end/panels/sources/sources-meta.ts +22 -7
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/package.json +4 -4
- package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +137 -0
- package/front_end/ui/components/code_highlighter/codeHighlighter.css +51 -0
- package/front_end/ui/components/code_highlighter/code_highlighter.ts +11 -0
- package/front_end/ui/components/docs/text_editor/basic.html +28 -0
- package/front_end/ui/components/docs/text_editor/basic.ts +14 -0
- package/front_end/ui/components/docs/text_prompt/basic.html +35 -0
- package/front_end/ui/components/docs/text_prompt/basic.ts +19 -0
- package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +1 -0
- package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +17 -0
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +1 -0
- package/front_end/ui/components/text_editor/TextEditor.ts +161 -0
- package/front_end/ui/components/text_editor/config.ts +264 -0
- package/front_end/{panels/console/components/components.ts → ui/components/text_editor/text_editor.ts} +2 -5
- package/front_end/ui/components/text_editor/theme.ts +113 -0
- package/front_end/ui/components/text_prompt/TextPrompt.ts +144 -0
- package/front_end/ui/components/text_prompt/textPrompt.css +33 -0
- package/front_end/ui/components/text_prompt/text_prompt.ts +9 -0
- package/front_end/ui/legacy/ARIAUtils.ts +14 -11
- package/front_end/ui/legacy/TabbedPane.ts +32 -3
- package/front_end/ui/legacy/UIUtils.ts +3 -1
- package/front_end/ui/legacy/View.ts +6 -0
- package/front_end/ui/legacy/ViewManager.ts +5 -1
- package/front_end/ui/legacy/ViewRegistration.ts +5 -0
- package/front_end/ui/legacy/XLink.ts +1 -1
- package/front_end/ui/legacy/closeButton.css +6 -0
- package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +8 -3
- package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +38 -38
- package/front_end/ui/legacy/components/quick_open/HelpQuickOpen.ts +10 -4
- package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +23 -6
- package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +14 -16
- package/front_end/ui/legacy/filter.css +1 -0
- package/front_end/ui/legacy/tabbedPane.css +24 -0
- package/front_end/ui/legacy/toolbar.css +5 -0
- package/inspector_overlay/main.ts +2 -1
- package/inspector_overlay/tool_screenshot.ts +8 -1
- package/package.json +1 -1
- package/scripts/build/rollup.config.js +9 -0
- package/scripts/migration/class-fields/migrate.js +56 -0
- package/scripts/migration/class-fields/package.json +5 -0
- package/front_end/panels/console/components/SidebarDeprecation.ts +0 -58
- package/front_end/panels/console/components/sidebarDeprecation.css +0 -17
|
@@ -15,34 +15,34 @@ import {SDKModel} from './SDKModel.js';
|
|
|
15
15
|
import {Events as TargetManagerEvents, TargetManager} from './TargetManager.js';
|
|
16
16
|
|
|
17
17
|
export class ChildTargetManager extends SDKModel<EventTypes> implements ProtocolProxyApi.TargetDispatcher {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
readonly #targetManager: TargetManager;
|
|
19
|
+
#parentTarget: Target;
|
|
20
|
+
readonly #targetAgent: ProtocolProxyApi.TargetApi;
|
|
21
|
+
readonly #targetInfosInternal: Map<Protocol.Target.TargetID, Protocol.Target.TargetInfo> = new Map();
|
|
22
|
+
readonly #childTargetsBySessionId: Map<Protocol.Target.SessionID, Target> = new Map();
|
|
23
|
+
readonly #childTargetsById: Map<Protocol.Target.TargetID|'main', Target> = new Map();
|
|
24
|
+
readonly #parallelConnections: Map<string, ProtocolClient.InspectorBackend.Connection> = new Map();
|
|
25
|
+
#parentTargetId: Protocol.Target.TargetID|null = null;
|
|
26
26
|
|
|
27
27
|
constructor(parentTarget: Target) {
|
|
28
28
|
super(parentTarget);
|
|
29
|
-
this
|
|
30
|
-
this
|
|
31
|
-
this
|
|
29
|
+
this.#targetManager = parentTarget.targetManager();
|
|
30
|
+
this.#parentTarget = parentTarget;
|
|
31
|
+
this.#targetAgent = parentTarget.targetAgent();
|
|
32
32
|
parentTarget.registerTargetDispatcher(this);
|
|
33
|
-
const browserTarget = this
|
|
33
|
+
const browserTarget = this.#targetManager.browserTarget();
|
|
34
34
|
if (browserTarget) {
|
|
35
35
|
if (browserTarget !== parentTarget) {
|
|
36
36
|
browserTarget.targetAgent().invoke_autoAttachRelated(
|
|
37
37
|
{targetId: parentTarget.id() as Protocol.Target.TargetID, waitForDebuggerOnStart: true});
|
|
38
38
|
}
|
|
39
39
|
} else {
|
|
40
|
-
this
|
|
40
|
+
this.#targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: true, flatten: true});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (!parentTarget.parentTarget() && !Host.InspectorFrontendHost.isUnderTest()) {
|
|
44
|
-
this
|
|
45
|
-
this
|
|
44
|
+
this.#targetAgent.invoke_setDiscoverTargets({discover: true});
|
|
45
|
+
this.#targetAgent.invoke_setRemoteLocations({locations: [{host: 'localhost', port: 9229}]});
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -55,32 +55,32 @@ export class ChildTargetManager extends SDKModel<EventTypes> implements Protocol
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
childTargets(): Target[] {
|
|
58
|
-
return Array.from(this
|
|
58
|
+
return Array.from(this.#childTargetsBySessionId.values());
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
async suspendModel(): Promise<void> {
|
|
62
|
-
await this
|
|
62
|
+
await this.#targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: false, flatten: true});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
async resumeModel(): Promise<void> {
|
|
66
|
-
await this
|
|
66
|
+
await this.#targetAgent.invoke_setAutoAttach({autoAttach: true, waitForDebuggerOnStart: true, flatten: true});
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
dispose(): void {
|
|
70
|
-
for (const sessionId of this
|
|
70
|
+
for (const sessionId of this.#childTargetsBySessionId.keys()) {
|
|
71
71
|
this.detachedFromTarget({sessionId, targetId: undefined});
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
targetCreated({targetInfo}: Protocol.Target.TargetCreatedEvent): void {
|
|
76
|
-
this
|
|
76
|
+
this.#targetInfosInternal.set(targetInfo.targetId, targetInfo);
|
|
77
77
|
this.fireAvailableTargetsChanged();
|
|
78
78
|
this.dispatchEventToListeners(Events.TargetCreated, targetInfo);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
targetInfoChanged({targetInfo}: Protocol.Target.TargetInfoChangedEvent): void {
|
|
82
|
-
this
|
|
83
|
-
const target = this
|
|
82
|
+
this.#targetInfosInternal.set(targetInfo.targetId, targetInfo);
|
|
83
|
+
const target = this.#childTargetsById.get(targetInfo.targetId);
|
|
84
84
|
if (target) {
|
|
85
85
|
target.updateTargetInfo(targetInfo);
|
|
86
86
|
}
|
|
@@ -89,7 +89,7 @@ export class ChildTargetManager extends SDKModel<EventTypes> implements Protocol
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
targetDestroyed({targetId}: Protocol.Target.TargetDestroyedEvent): void {
|
|
92
|
-
this
|
|
92
|
+
this.#targetInfosInternal.delete(targetId);
|
|
93
93
|
this.fireAvailableTargetsChanged();
|
|
94
94
|
this.dispatchEventToListeners(Events.TargetDestroyed, targetId);
|
|
95
95
|
}
|
|
@@ -100,19 +100,19 @@ export class ChildTargetManager extends SDKModel<EventTypes> implements Protocol
|
|
|
100
100
|
|
|
101
101
|
private fireAvailableTargetsChanged(): void {
|
|
102
102
|
TargetManager.instance().dispatchEventToListeners(
|
|
103
|
-
TargetManagerEvents.AvailableTargetsChanged, [...this
|
|
103
|
+
TargetManagerEvents.AvailableTargetsChanged, [...this.#targetInfosInternal.values()]);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
async getParentTargetId(): Promise<Protocol.Target.TargetID> {
|
|
107
|
-
if (!this
|
|
108
|
-
this
|
|
107
|
+
if (!this.#parentTargetId) {
|
|
108
|
+
this.#parentTargetId = (await this.#parentTarget.targetAgent().invoke_getTargetInfo({})).targetInfo.targetId;
|
|
109
109
|
}
|
|
110
|
-
return this
|
|
110
|
+
return this.#parentTargetId;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
async attachedToTarget({sessionId, targetInfo, waitingForDebugger}: Protocol.Target.AttachedToTargetEvent):
|
|
114
114
|
Promise<void> {
|
|
115
|
-
if (this
|
|
115
|
+
if (this.#parentTargetId === targetInfo.targetId) {
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
let targetName = '';
|
|
@@ -139,10 +139,10 @@ export class ChildTargetManager extends SDKModel<EventTypes> implements Protocol
|
|
|
139
139
|
type = Type.ServiceWorker;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
const target = this
|
|
143
|
-
targetInfo.targetId, targetName, type, this
|
|
144
|
-
this
|
|
145
|
-
this
|
|
142
|
+
const target = this.#targetManager.createTarget(
|
|
143
|
+
targetInfo.targetId, targetName, type, this.#parentTarget, sessionId, undefined, undefined, targetInfo);
|
|
144
|
+
this.#childTargetsBySessionId.set(sessionId, target);
|
|
145
|
+
this.#childTargetsById.set(target.id(), target);
|
|
146
146
|
|
|
147
147
|
if (ChildTargetManager.attachCallback) {
|
|
148
148
|
await ChildTargetManager.attachCallback({target, waitingForDebugger});
|
|
@@ -151,14 +151,14 @@ export class ChildTargetManager extends SDKModel<EventTypes> implements Protocol
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
detachedFromTarget({sessionId}: Protocol.Target.DetachedFromTargetEvent): void {
|
|
154
|
-
if (this
|
|
155
|
-
this
|
|
154
|
+
if (this.#parallelConnections.has(sessionId)) {
|
|
155
|
+
this.#parallelConnections.delete(sessionId);
|
|
156
156
|
} else {
|
|
157
|
-
const target = this
|
|
157
|
+
const target = this.#childTargetsBySessionId.get(sessionId);
|
|
158
158
|
if (target) {
|
|
159
159
|
target.dispose('target terminated');
|
|
160
|
-
this
|
|
161
|
-
this
|
|
160
|
+
this.#childTargetsBySessionId.delete(sessionId);
|
|
161
|
+
this.#childTargetsById.delete(target.id());
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -172,9 +172,10 @@ export class ChildTargetManager extends SDKModel<EventTypes> implements Protocol
|
|
|
172
172
|
// The main Target id is actually just `main`, instead of the real targetId.
|
|
173
173
|
// Get the real id (requires an async operation) so that it can be used synchronously later.
|
|
174
174
|
const targetId = await this.getParentTargetId();
|
|
175
|
-
const {connection, sessionId} =
|
|
175
|
+
const {connection, sessionId} =
|
|
176
|
+
await this.createParallelConnectionAndSessionForTarget(this.#parentTarget, targetId);
|
|
176
177
|
connection.setOnMessage(onMessage);
|
|
177
|
-
this
|
|
178
|
+
this.#parallelConnections.set(sessionId, connection);
|
|
178
179
|
return connection;
|
|
179
180
|
}
|
|
180
181
|
|
|
@@ -196,7 +197,7 @@ export class ChildTargetManager extends SDKModel<EventTypes> implements Protocol
|
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
targetInfos(): Protocol.Target.TargetInfo[] {
|
|
199
|
-
return Array.from(this
|
|
200
|
+
return Array.from(this.#targetInfosInternal.values());
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
private static lastAnonymousTargetId = 0;
|
|
@@ -48,22 +48,22 @@ const str_ = i18n.i18n.registerUIStrings('core/sdk/CompilerSourceMappingContentP
|
|
|
48
48
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
49
49
|
|
|
50
50
|
export class CompilerSourceMappingContentProvider implements TextUtils.ContentProvider.ContentProvider {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
readonly #sourceURL: string;
|
|
52
|
+
readonly #contentTypeInternal: Common.ResourceType.ResourceType;
|
|
53
|
+
readonly #initiator: PageResourceLoadInitiator;
|
|
54
54
|
|
|
55
55
|
constructor(sourceURL: string, contentType: Common.ResourceType.ResourceType, initiator: PageResourceLoadInitiator) {
|
|
56
|
-
this
|
|
57
|
-
this
|
|
58
|
-
this
|
|
56
|
+
this.#sourceURL = sourceURL;
|
|
57
|
+
this.#contentTypeInternal = contentType;
|
|
58
|
+
this.#initiator = initiator;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
contentURL(): string {
|
|
62
|
-
return this
|
|
62
|
+
return this.#sourceURL;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
contentType(): Common.ResourceType.ResourceType {
|
|
66
|
-
return this
|
|
66
|
+
return this.#contentTypeInternal;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
async contentEncoded(): Promise<boolean> {
|
|
@@ -72,10 +72,10 @@ export class CompilerSourceMappingContentProvider implements TextUtils.ContentPr
|
|
|
72
72
|
|
|
73
73
|
async requestContent(): Promise<TextUtils.ContentProvider.DeferredContent> {
|
|
74
74
|
try {
|
|
75
|
-
const {content} = await PageResourceLoader.instance().loadResource(this
|
|
75
|
+
const {content} = await PageResourceLoader.instance().loadResource(this.#sourceURL, this.#initiator);
|
|
76
76
|
return {content, isEncoded: false};
|
|
77
77
|
} catch (e) {
|
|
78
|
-
const error = i18nString(UIStrings.couldNotLoadContentForSS, {PH1: this
|
|
78
|
+
const error = i18nString(UIStrings.couldNotLoadContentForSS, {PH1: this.#sourceURL, PH2: e.message});
|
|
79
79
|
console.error(error);
|
|
80
80
|
return {content: null, error, isEncoded: false};
|
|
81
81
|
}
|
|
@@ -11,16 +11,16 @@ import {TargetManager} from './TargetManager.js';
|
|
|
11
11
|
|
|
12
12
|
export class MainConnection implements ProtocolClient.InspectorBackend.Connection {
|
|
13
13
|
onMessage: ((arg0: (Object|string)) => void)|null;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
#onDisconnect: ((arg0: string) => void)|null;
|
|
15
|
+
#messageBuffer: string;
|
|
16
|
+
#messageSize: number;
|
|
17
|
+
readonly #eventListeners: Common.EventTarget.EventDescriptor[];
|
|
18
18
|
constructor() {
|
|
19
19
|
this.onMessage = null;
|
|
20
|
-
this
|
|
21
|
-
this
|
|
22
|
-
this
|
|
23
|
-
this
|
|
20
|
+
this.#onDisconnect = null;
|
|
21
|
+
this.#messageBuffer = '';
|
|
22
|
+
this.#messageSize = 0;
|
|
23
|
+
this.#eventListeners = [
|
|
24
24
|
Host.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(
|
|
25
25
|
Host.InspectorFrontendHostAPI.Events.DispatchMessage, this.dispatchMessage, this),
|
|
26
26
|
Host.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(
|
|
@@ -33,7 +33,7 @@ export class MainConnection implements ProtocolClient.InspectorBackend.Connectio
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
setOnDisconnect(onDisconnect: (arg0: string) => void): void {
|
|
36
|
-
this
|
|
36
|
+
this.#onDisconnect = onDisconnect;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
sendRawMessage(message: string): void {
|
|
@@ -52,21 +52,21 @@ export class MainConnection implements ProtocolClient.InspectorBackend.Connectio
|
|
|
52
52
|
event: Common.EventTarget.EventTargetEvent<Host.InspectorFrontendHostAPI.DispatchMessageChunkEvent>): void {
|
|
53
53
|
const {messageChunk, messageSize} = event.data;
|
|
54
54
|
if (messageSize) {
|
|
55
|
-
this
|
|
56
|
-
this
|
|
55
|
+
this.#messageBuffer = '';
|
|
56
|
+
this.#messageSize = messageSize;
|
|
57
57
|
}
|
|
58
|
-
this
|
|
59
|
-
if (this
|
|
60
|
-
this.onMessage.call(null, this
|
|
61
|
-
this
|
|
62
|
-
this
|
|
58
|
+
this.#messageBuffer += messageChunk;
|
|
59
|
+
if (this.#messageBuffer.length === this.#messageSize && this.onMessage) {
|
|
60
|
+
this.onMessage.call(null, this.#messageBuffer);
|
|
61
|
+
this.#messageBuffer = '';
|
|
62
|
+
this.#messageSize = 0;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
async disconnect(): Promise<void> {
|
|
67
|
-
const onDisconnect = this
|
|
68
|
-
Common.EventTarget.removeEventListeners(this
|
|
69
|
-
this
|
|
67
|
+
const onDisconnect = this.#onDisconnect;
|
|
68
|
+
Common.EventTarget.removeEventListeners(this.#eventListeners);
|
|
69
|
+
this.#onDisconnect = null;
|
|
70
70
|
this.onMessage = null;
|
|
71
71
|
|
|
72
72
|
if (onDisconnect) {
|
|
@@ -76,28 +76,28 @@ export class MainConnection implements ProtocolClient.InspectorBackend.Connectio
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export class WebSocketConnection implements ProtocolClient.InspectorBackend.Connection {
|
|
79
|
-
|
|
79
|
+
#socket: WebSocket|null;
|
|
80
80
|
onMessage: ((arg0: (Object|string)) => void)|null;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
#onDisconnect: ((arg0: string) => void)|null;
|
|
82
|
+
#onWebSocketDisconnect: (() => void)|null;
|
|
83
|
+
#connected: boolean;
|
|
84
|
+
#messages: string[];
|
|
85
85
|
constructor(url: string, onWebSocketDisconnect: () => void) {
|
|
86
|
-
this
|
|
87
|
-
this
|
|
88
|
-
this
|
|
89
|
-
this
|
|
86
|
+
this.#socket = new WebSocket(url);
|
|
87
|
+
this.#socket.onerror = this.onError.bind(this);
|
|
88
|
+
this.#socket.onopen = this.onOpen.bind(this);
|
|
89
|
+
this.#socket.onmessage = (messageEvent: MessageEvent<string>): void => {
|
|
90
90
|
if (this.onMessage) {
|
|
91
91
|
this.onMessage.call(null, messageEvent.data);
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
this
|
|
94
|
+
this.#socket.onclose = this.onClose.bind(this);
|
|
95
95
|
|
|
96
96
|
this.onMessage = null;
|
|
97
|
-
this
|
|
98
|
-
this
|
|
99
|
-
this
|
|
100
|
-
this
|
|
97
|
+
this.#onDisconnect = null;
|
|
98
|
+
this.#onWebSocketDisconnect = onWebSocketDisconnect;
|
|
99
|
+
this.#connected = false;
|
|
100
|
+
this.#messages = [];
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
setOnMessage(onMessage: (arg0: (Object|string)) => void): void {
|
|
@@ -105,66 +105,66 @@ export class WebSocketConnection implements ProtocolClient.InspectorBackend.Conn
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
setOnDisconnect(onDisconnect: (arg0: string) => void): void {
|
|
108
|
-
this
|
|
108
|
+
this.#onDisconnect = onDisconnect;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
private onError(): void {
|
|
112
|
-
if (this
|
|
113
|
-
this
|
|
112
|
+
if (this.#onWebSocketDisconnect) {
|
|
113
|
+
this.#onWebSocketDisconnect.call(null);
|
|
114
114
|
}
|
|
115
|
-
if (this
|
|
115
|
+
if (this.#onDisconnect) {
|
|
116
116
|
// This is called if error occurred while connecting.
|
|
117
|
-
this
|
|
117
|
+
this.#onDisconnect.call(null, 'connection failed');
|
|
118
118
|
}
|
|
119
119
|
this.close();
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
private onOpen(): void {
|
|
123
|
-
this
|
|
124
|
-
if (this
|
|
125
|
-
this
|
|
126
|
-
for (const message of this
|
|
127
|
-
this
|
|
123
|
+
this.#connected = true;
|
|
124
|
+
if (this.#socket) {
|
|
125
|
+
this.#socket.onerror = console.error;
|
|
126
|
+
for (const message of this.#messages) {
|
|
127
|
+
this.#socket.send(message);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
this
|
|
130
|
+
this.#messages = [];
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
private onClose(): void {
|
|
134
|
-
if (this
|
|
135
|
-
this
|
|
134
|
+
if (this.#onWebSocketDisconnect) {
|
|
135
|
+
this.#onWebSocketDisconnect.call(null);
|
|
136
136
|
}
|
|
137
|
-
if (this
|
|
138
|
-
this
|
|
137
|
+
if (this.#onDisconnect) {
|
|
138
|
+
this.#onDisconnect.call(null, 'websocket closed');
|
|
139
139
|
}
|
|
140
140
|
this.close();
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
private close(callback?: (() => void)): void {
|
|
144
|
-
if (this
|
|
145
|
-
this
|
|
146
|
-
this
|
|
147
|
-
this
|
|
148
|
-
this
|
|
149
|
-
this
|
|
150
|
-
this
|
|
144
|
+
if (this.#socket) {
|
|
145
|
+
this.#socket.onerror = null;
|
|
146
|
+
this.#socket.onopen = null;
|
|
147
|
+
this.#socket.onclose = callback || null;
|
|
148
|
+
this.#socket.onmessage = null;
|
|
149
|
+
this.#socket.close();
|
|
150
|
+
this.#socket = null;
|
|
151
151
|
}
|
|
152
|
-
this
|
|
152
|
+
this.#onWebSocketDisconnect = null;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
sendRawMessage(message: string): void {
|
|
156
|
-
if (this
|
|
157
|
-
this
|
|
156
|
+
if (this.#connected && this.#socket) {
|
|
157
|
+
this.#socket.send(message);
|
|
158
158
|
} else {
|
|
159
|
-
this
|
|
159
|
+
this.#messages.push(message);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
disconnect(): Promise<void> {
|
|
164
164
|
return new Promise(fulfill => {
|
|
165
165
|
this.close(() => {
|
|
166
|
-
if (this
|
|
167
|
-
this
|
|
166
|
+
if (this.#onDisconnect) {
|
|
167
|
+
this.#onDisconnect.call(null, 'force disconnect');
|
|
168
168
|
}
|
|
169
169
|
fulfill();
|
|
170
170
|
});
|
|
@@ -174,10 +174,10 @@ export class WebSocketConnection implements ProtocolClient.InspectorBackend.Conn
|
|
|
174
174
|
|
|
175
175
|
export class StubConnection implements ProtocolClient.InspectorBackend.Connection {
|
|
176
176
|
onMessage: ((arg0: (Object|string)) => void)|null;
|
|
177
|
-
|
|
177
|
+
#onDisconnect: ((arg0: string) => void)|null;
|
|
178
178
|
constructor() {
|
|
179
179
|
this.onMessage = null;
|
|
180
|
-
this
|
|
180
|
+
this.#onDisconnect = null;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
setOnMessage(onMessage: (arg0: (Object|string)) => void): void {
|
|
@@ -185,7 +185,7 @@ export class StubConnection implements ProtocolClient.InspectorBackend.Connectio
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
setOnDisconnect(onDisconnect: (arg0: string) => void): void {
|
|
188
|
-
this
|
|
188
|
+
this.#onDisconnect = onDisconnect;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
sendRawMessage(message: string): void {
|
|
@@ -205,24 +205,24 @@ export class StubConnection implements ProtocolClient.InspectorBackend.Connectio
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
async disconnect(): Promise<void> {
|
|
208
|
-
if (this
|
|
209
|
-
this
|
|
208
|
+
if (this.#onDisconnect) {
|
|
209
|
+
this.#onDisconnect.call(null, 'force disconnect');
|
|
210
210
|
}
|
|
211
|
-
this
|
|
211
|
+
this.#onDisconnect = null;
|
|
212
212
|
this.onMessage = null;
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
export class ParallelConnection implements ProtocolClient.InspectorBackend.Connection {
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
readonly #connection: ProtocolClient.InspectorBackend.Connection;
|
|
218
|
+
#sessionId: string;
|
|
219
219
|
onMessage: ((arg0: Object) => void)|null;
|
|
220
|
-
|
|
220
|
+
#onDisconnect: ((arg0: string) => void)|null;
|
|
221
221
|
constructor(connection: ProtocolClient.InspectorBackend.Connection, sessionId: string) {
|
|
222
|
-
this
|
|
223
|
-
this
|
|
222
|
+
this.#connection = connection;
|
|
223
|
+
this.#sessionId = sessionId;
|
|
224
224
|
this.onMessage = null;
|
|
225
|
-
this
|
|
225
|
+
this.#onDisconnect = null;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
setOnMessage(onMessage: (arg0: Object) => void): void {
|
|
@@ -230,31 +230,31 @@ export class ParallelConnection implements ProtocolClient.InspectorBackend.Conne
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
setOnDisconnect(onDisconnect: (arg0: string) => void): void {
|
|
233
|
-
this
|
|
233
|
+
this.#onDisconnect = onDisconnect;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
getOnDisconnect(): ((arg0: string) => void)|null {
|
|
237
|
-
return this
|
|
237
|
+
return this.#onDisconnect;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
sendRawMessage(message: string): void {
|
|
241
241
|
const messageObject = JSON.parse(message);
|
|
242
242
|
// If the message isn't for a specific session, it must be for the root session.
|
|
243
243
|
if (!messageObject.sessionId) {
|
|
244
|
-
messageObject.sessionId = this
|
|
244
|
+
messageObject.sessionId = this.#sessionId;
|
|
245
245
|
}
|
|
246
|
-
this
|
|
246
|
+
this.#connection.sendRawMessage(JSON.stringify(messageObject));
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
getSessionId(): string {
|
|
250
|
-
return this
|
|
250
|
+
return this.#sessionId;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
async disconnect(): Promise<void> {
|
|
254
|
-
if (this
|
|
255
|
-
this
|
|
254
|
+
if (this.#onDisconnect) {
|
|
255
|
+
this.#onDisconnect.call(null, 'force disconnect');
|
|
256
256
|
}
|
|
257
|
-
this
|
|
257
|
+
this.#onDisconnect = null;
|
|
258
258
|
this.onMessage = null;
|
|
259
259
|
}
|
|
260
260
|
}
|