chrome-devtools-frontend 1.0.1585538 → 1.0.1586699
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/front_end/core/common/Srcset.ts +61 -0
- package/front_end/core/common/common.ts +2 -0
- package/front_end/generated/SupportedCSSProperties.js +4 -2
- package/front_end/models/ai_assistance/AiConversation.ts +6 -2
- package/front_end/models/ai_code_completion/AiCodeCompletion.ts +12 -0
- package/front_end/models/javascript_metadata/NativeFunctions.js +2 -2
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +1 -0
- package/front_end/panels/ai_assistance/components/ChatView.ts +13 -0
- package/front_end/panels/application/FrameDetailsView.ts +4 -9
- package/front_end/panels/console/ConsoleViewMessage.ts +2 -2
- package/front_end/panels/console/PromptBuilder.ts +15 -3
- package/front_end/panels/elements/ElementsTreeElement.ts +95 -106
- package/front_end/panels/elements/NodeStackTraceWidget.ts +3 -11
- package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +69 -0
- package/front_end/panels/elements/elements.ts +3 -1
- package/front_end/panels/network/RequestInitiatorView.ts +2 -10
- package/front_end/panels/network/components/RequestHeadersView.ts +85 -153
- package/front_end/panels/sources/CallStackSidebarPane.ts +3 -7
- package/front_end/panels/timeline/TimelineUIUtils.ts +2 -6
- package/front_end/panels/utils/utils.ts +13 -5
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/FrameManager.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/FrameManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/util.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/util.js +7 -7
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/util.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +7 -7
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/FrameManager.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/FrameManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/util.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/util.js +7 -7
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/util.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/package.json +2 -2
- package/front_end/third_party/puppeteer/package/src/cdp/FrameManager.ts +1 -1
- package/front_end/third_party/puppeteer/package/src/common/util.ts +9 -8
- package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/ui/legacy/UIUtils.ts +31 -14
- package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +96 -216
- package/front_end/ui/legacy/components/utils/Linkifier.ts +7 -3
- package/front_end/ui/legacy/components/utils/jsUtils.css +0 -9
- package/package.json +1 -1
|
@@ -41,6 +41,7 @@ import * as Host from '../../core/host/host.js';
|
|
|
41
41
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
42
42
|
import * as Platform from '../../core/platform/platform.js';
|
|
43
43
|
import * as Geometry from '../../models/geometry/geometry.js';
|
|
44
|
+
import type * as StackTrace from '../../models/stack_trace/stack_trace.js';
|
|
44
45
|
import * as Buttons from '../components/buttons/buttons.js';
|
|
45
46
|
import {Icon, type IconData} from '../kit/kit.js';
|
|
46
47
|
import * as Lit from '../lit/lit.js';
|
|
@@ -628,23 +629,39 @@ export function anotherProfilerActiveLabel(): string {
|
|
|
628
629
|
return i18nString(UIStrings.anotherProfilerIsAlreadyActive);
|
|
629
630
|
}
|
|
630
631
|
|
|
631
|
-
export function
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
632
|
+
export function asyncFragmentLabel(
|
|
633
|
+
stackTrace: StackTrace.StackTrace.StackTrace|StackTrace.StackTrace.DebuggableStackTrace,
|
|
634
|
+
asyncFragment: StackTrace.StackTrace.AsyncFragment): string {
|
|
635
|
+
const description = asyncFragment.description;
|
|
636
|
+
if (!description) {
|
|
637
|
+
return i18nString(UIStrings.asyncCall);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
if (description === 'Promise.resolve') {
|
|
641
|
+
return i18nString(UIStrings.promiseResolvedAsync);
|
|
642
|
+
}
|
|
643
|
+
if (description === 'Promise.reject') {
|
|
644
|
+
return i18nString(UIStrings.promiseRejectedAsync);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (description === 'await') {
|
|
648
|
+
const asyncFragments = stackTrace.asyncFragments;
|
|
649
|
+
const index = asyncFragments.indexOf(asyncFragment);
|
|
650
|
+
let previousFragment: StackTrace.StackTrace.Fragment|undefined;
|
|
651
|
+
|
|
652
|
+
if (index === 0) {
|
|
653
|
+
previousFragment = stackTrace.syncFragment;
|
|
654
|
+
} else if (index > 0) {
|
|
655
|
+
previousFragment = asyncFragments[index - 1];
|
|
639
656
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
657
|
+
|
|
658
|
+
const lastPreviousFrame = previousFragment?.frames.at(-1);
|
|
659
|
+
if (lastPreviousFrame) {
|
|
660
|
+
const lastPreviousFrameName = beautifyFunctionName(lastPreviousFrame.name || '');
|
|
661
|
+
return `await in ${lastPreviousFrameName}`;
|
|
644
662
|
}
|
|
645
|
-
return description;
|
|
646
663
|
}
|
|
647
|
-
return
|
|
664
|
+
return description;
|
|
648
665
|
}
|
|
649
666
|
|
|
650
667
|
export function addPlatformClass(element: HTMLElement): void {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Copyright 2021 The Chromium Authors
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
|
-
/* eslint-disable @devtools/no-imperative-dom-api */
|
|
5
4
|
|
|
6
5
|
/*
|
|
7
6
|
* Copyright (C) 2011 Google Inc. All rights reserved.
|
|
@@ -34,17 +33,18 @@
|
|
|
34
33
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
35
34
|
*/
|
|
36
35
|
|
|
37
|
-
import * as Common from '../../../../core/common/common.js';
|
|
38
36
|
import * as i18n from '../../../../core/i18n/i18n.js';
|
|
39
37
|
import * as SDK from '../../../../core/sdk/sdk.js';
|
|
40
|
-
import type * as Protocol from '../../../../generated/protocol.js';
|
|
41
38
|
import * as StackTrace from '../../../../models/stack_trace/stack_trace.js';
|
|
42
39
|
import * as Workspace from '../../../../models/workspace/workspace.js';
|
|
40
|
+
import {Directives, html, render} from '../../../lit/lit.js';
|
|
43
41
|
import * as VisualLogging from '../../../visual_logging/visual_logging.js';
|
|
44
42
|
import * as UI from '../../legacy.js';
|
|
45
43
|
|
|
46
44
|
import jsUtilsStyles from './jsUtils.css.js';
|
|
47
|
-
import {
|
|
45
|
+
import {Linkifier} from './Linkifier.js';
|
|
46
|
+
|
|
47
|
+
const {classMap, createRef, ref} = Directives;
|
|
48
48
|
|
|
49
49
|
const UIStrings = {
|
|
50
50
|
/**
|
|
@@ -63,10 +63,6 @@ const UIStrings = {
|
|
|
63
63
|
* @description A link to rehide frames that are by default hidden.
|
|
64
64
|
*/
|
|
65
65
|
showLess: 'Show less',
|
|
66
|
-
/**
|
|
67
|
-
* @description Text indicating that source url of a link is currently unknown
|
|
68
|
-
*/
|
|
69
|
-
unknownSource: 'unknown',
|
|
70
66
|
} as const;
|
|
71
67
|
const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/utils/JSPresentationUtils.ts', UIStrings);
|
|
72
68
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
@@ -95,97 +91,53 @@ function populateContextMenu(link: Element, event: Event): void {
|
|
|
95
91
|
void contextMenu.show();
|
|
96
92
|
}
|
|
97
93
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
updateCallback?: (arg0: Array<StackTraceRegularRow|StackTraceAsyncRow>) => void,
|
|
105
|
-
showColumnNumber?: boolean,
|
|
106
|
-
): Array<StackTraceRegularRow|StackTraceAsyncRow> {
|
|
107
|
-
const stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow> = [];
|
|
108
|
-
|
|
109
|
-
if (updateCallback) {
|
|
110
|
-
const throttler = new Common.Throttler.Throttler(100);
|
|
111
|
-
linkifier.addEventListener(LinkifierEvents.LIVE_LOCATION_UPDATED, () => {
|
|
112
|
-
void throttler.schedule(async () => updateCallback(stackTraceRows));
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function buildStackTraceRowsHelper(
|
|
117
|
-
stackTrace: Protocol.Runtime.StackTrace,
|
|
118
|
-
previousCallFrames: Protocol.Runtime.CallFrame[]|undefined = undefined): void {
|
|
119
|
-
let asyncRow: StackTraceAsyncRow|null = null;
|
|
120
|
-
if (previousCallFrames) {
|
|
121
|
-
asyncRow = {
|
|
122
|
-
asyncDescription: UI.UIUtils.asyncStackTraceLabel(stackTrace.description, previousCallFrames),
|
|
123
|
-
};
|
|
124
|
-
stackTraceRows.push(asyncRow);
|
|
125
|
-
}
|
|
126
|
-
let previousStackFrameWasBreakpointCondition = false;
|
|
127
|
-
for (const stackFrame of stackTrace.callFrames) {
|
|
128
|
-
const functionName = UI.UIUtils.beautifyFunctionName(stackFrame.functionName);
|
|
129
|
-
const link = linkifier.maybeLinkifyConsoleCallFrame(target, stackFrame, {
|
|
130
|
-
showColumnNumber,
|
|
131
|
-
tabStop: Boolean(tabStops),
|
|
132
|
-
inlineFrameIndex: 0,
|
|
133
|
-
revealBreakpoint: previousStackFrameWasBreakpointCondition,
|
|
134
|
-
});
|
|
135
|
-
if (link) {
|
|
136
|
-
link.setAttribute('jslog', `${VisualLogging.link('stack-trace').track({click: true})}`);
|
|
137
|
-
link.addEventListener('contextmenu', populateContextMenu.bind(null, link));
|
|
138
|
-
|
|
139
|
-
if (!link.textContent) {
|
|
140
|
-
link.textContent = i18nString(UIStrings.unknownSource);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
stackTraceRows.push({functionName, link});
|
|
144
|
-
previousStackFrameWasBreakpointCondition = [
|
|
145
|
-
SDK.DebuggerModel.COND_BREAKPOINT_SOURCE_URL,
|
|
146
|
-
SDK.DebuggerModel.LOGPOINT_SOURCE_URL,
|
|
147
|
-
].includes(stackFrame.url);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
buildStackTraceRowsHelper(stackTrace);
|
|
152
|
-
let previousCallFrames = stackTrace.callFrames;
|
|
153
|
-
for (let asyncStackTrace = stackTrace.parent; asyncStackTrace; asyncStackTrace = asyncStackTrace.parent) {
|
|
154
|
-
if (asyncStackTrace.callFrames.length) {
|
|
155
|
-
buildStackTraceRowsHelper(asyncStackTrace, previousCallFrames);
|
|
156
|
-
}
|
|
157
|
-
previousCallFrames = asyncStackTrace.callFrames;
|
|
158
|
-
}
|
|
159
|
-
return stackTraceRows;
|
|
94
|
+
export interface ViewInput {
|
|
95
|
+
stackTrace?: StackTrace.StackTrace.StackTrace;
|
|
96
|
+
tabStops?: boolean;
|
|
97
|
+
widthConstrained?: boolean;
|
|
98
|
+
showColumnNumber?: boolean;
|
|
99
|
+
expandable?: boolean;
|
|
160
100
|
}
|
|
161
101
|
|
|
162
|
-
|
|
102
|
+
export type View = (input: ViewInput, output: {table?: HTMLElement}, target: HTMLElement) => void;
|
|
103
|
+
|
|
104
|
+
export const DEFAULT_VIEW: View = (input, output, target) => {
|
|
105
|
+
const classes = {
|
|
106
|
+
'stack-preview-container': true,
|
|
107
|
+
'width-constrained': Boolean(input.widthConstrained),
|
|
108
|
+
};
|
|
109
|
+
// TODO(crbug.com/483576322): Remove once fully migrated.
|
|
110
|
+
const tableRef = createRef<HTMLElement>();
|
|
111
|
+
// clang-format off
|
|
112
|
+
render(html`
|
|
113
|
+
<style>${jsUtilsStyles}</style>
|
|
114
|
+
<table class=${classMap(classes)} ${ref(tableRef)}>
|
|
115
|
+
</table>
|
|
116
|
+
`, target);
|
|
117
|
+
// clang-format on
|
|
118
|
+
output.table = tableRef.value;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
function renderStackTraceTable(
|
|
122
|
+
container: Element,
|
|
123
|
+
parent: Element,
|
|
163
124
|
stackTrace: StackTrace.StackTrace.StackTrace,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
showColumnNumber?: boolean,
|
|
168
|
-
): Array<StackTraceRegularRow|StackTraceAsyncRow> {
|
|
169
|
-
const stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow> = [];
|
|
125
|
+
options: Options,
|
|
126
|
+
): void {
|
|
127
|
+
container.removeChildren();
|
|
170
128
|
|
|
171
|
-
function buildStackTraceRowsHelper(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (previousFragment && isAsync) {
|
|
177
|
-
asyncRow = {
|
|
178
|
-
asyncDescription: UI.UIUtils.asyncStackTraceLabel(
|
|
179
|
-
fragment.description, previousFragment.frames.map(f => ({functionName: f.name ?? ''}))),
|
|
180
|
-
};
|
|
181
|
-
stackTraceRows.push(asyncRow);
|
|
129
|
+
function buildStackTraceRowsHelper(fragment: StackTrace.StackTrace.Fragment|StackTrace.StackTrace.AsyncFragment):
|
|
130
|
+
Array<StackTraceRegularRow|StackTraceAsyncRow> {
|
|
131
|
+
const stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow> = [];
|
|
132
|
+
if ('description' in fragment) {
|
|
133
|
+
stackTraceRows.push({asyncDescription: UI.UIUtils.asyncFragmentLabel(stackTrace, fragment)});
|
|
182
134
|
}
|
|
183
135
|
let previousStackFrameWasBreakpointCondition = false;
|
|
184
136
|
for (const frame of fragment.frames) {
|
|
185
137
|
const functionName = UI.UIUtils.beautifyFunctionName(frame.name ?? '');
|
|
186
138
|
const link = Linkifier.linkifyStackTraceFrame(frame, {
|
|
187
|
-
showColumnNumber,
|
|
188
|
-
tabStop: Boolean(tabStops),
|
|
139
|
+
showColumnNumber: Boolean(options.showColumnNumber),
|
|
140
|
+
tabStop: Boolean(options.tabStops),
|
|
189
141
|
inlineFrameIndex: 0,
|
|
190
142
|
revealBreakpoint: previousStackFrameWasBreakpointCondition,
|
|
191
143
|
maxLength: UI.UIUtils.MaxLengthForDisplayedURLsInConsole,
|
|
@@ -199,65 +151,50 @@ function buildStackTraceRows(
|
|
|
199
151
|
SDK.DebuggerModel.LOGPOINT_SOURCE_URL,
|
|
200
152
|
].includes(frame.url ?? '');
|
|
201
153
|
}
|
|
202
|
-
}
|
|
203
154
|
|
|
204
|
-
|
|
205
|
-
let previousFragment = stackTrace.syncFragment;
|
|
206
|
-
for (const asyncFragment of stackTrace.asyncFragments) {
|
|
207
|
-
if (asyncFragment.frames.length) {
|
|
208
|
-
buildStackTraceRowsHelper(asyncFragment, previousFragment);
|
|
209
|
-
}
|
|
210
|
-
previousFragment = asyncFragment;
|
|
155
|
+
return stackTraceRows;
|
|
211
156
|
}
|
|
212
|
-
return stackTraceRows;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function renderStackTraceTable(
|
|
216
|
-
container: Element, parent: Element, expandable: boolean,
|
|
217
|
-
stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow>): HTMLElement[] {
|
|
218
|
-
container.removeChildren();
|
|
219
|
-
const links: HTMLElement[] = [];
|
|
220
157
|
|
|
221
158
|
// The tableSection groups one or more synchronous call frames together.
|
|
222
159
|
// Wherever there is an asynchronous call, a new section is created.
|
|
223
|
-
let tableSection: Element|null = null;
|
|
224
160
|
let firstRow = true;
|
|
225
|
-
for (const
|
|
226
|
-
if (
|
|
227
|
-
|
|
161
|
+
for (const fragment of [stackTrace.syncFragment, ...stackTrace.asyncFragments]) {
|
|
162
|
+
if (fragment.frames.length === 0) {
|
|
163
|
+
continue;
|
|
228
164
|
}
|
|
229
165
|
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
166
|
+
const stackTraceRows = buildStackTraceRowsHelper(fragment);
|
|
167
|
+
const tableSection = container.createChild('tbody');
|
|
168
|
+
for (const item of stackTraceRows) {
|
|
169
|
+
const row = tableSection.createChild('tr');
|
|
170
|
+
if (firstRow && options.expandable) {
|
|
171
|
+
const button = row.createChild('td').createChild('button', 'arrow-icon-button');
|
|
172
|
+
button.createChild('span', 'arrow-icon');
|
|
173
|
+
parent.classList.add('expandable');
|
|
174
|
+
container.classList.add('expandable');
|
|
175
|
+
button.addEventListener('click', () => {
|
|
176
|
+
button.setAttribute('jslog', `${VisualLogging.expand().track({click: true})}`);
|
|
177
|
+
parent.classList.toggle('expanded');
|
|
178
|
+
container.classList.toggle('expanded');
|
|
179
|
+
});
|
|
180
|
+
firstRow = false;
|
|
181
|
+
} else {
|
|
182
|
+
row.createChild('td').textContent = '\n';
|
|
183
|
+
}
|
|
184
|
+
if ('asyncDescription' in item) {
|
|
185
|
+
row.createChild('td', 'stack-preview-async-description').textContent = item.asyncDescription;
|
|
186
|
+
row.createChild('td');
|
|
187
|
+
row.createChild('td');
|
|
188
|
+
row.classList.add('stack-preview-async-row');
|
|
189
|
+
} else {
|
|
190
|
+
row.createChild('td', 'function-name').textContent = item.functionName;
|
|
191
|
+
row.createChild('td').textContent = ' @ ';
|
|
254
192
|
row.createChild('td', 'link').appendChild(item.link);
|
|
255
|
-
links.push(item.link);
|
|
256
193
|
}
|
|
257
194
|
}
|
|
258
195
|
}
|
|
259
196
|
|
|
260
|
-
tableSection = container.createChild('tfoot');
|
|
197
|
+
const tableSection = container.createChild('tfoot');
|
|
261
198
|
const showAllRow = tableSection.createChild('tr', 'show-all-link');
|
|
262
199
|
showAllRow.createChild('td');
|
|
263
200
|
const cell = showAllRow.createChild('td');
|
|
@@ -286,13 +223,9 @@ function renderStackTraceTable(
|
|
|
286
223
|
// If we are in a popup, this will trigger a re-layout
|
|
287
224
|
UI.GlassPane.GlassPane.containerMoved(container);
|
|
288
225
|
}, false);
|
|
289
|
-
|
|
290
|
-
return links;
|
|
291
226
|
}
|
|
292
227
|
|
|
293
228
|
export interface Options {
|
|
294
|
-
// TODO(crbug.com/456517732): remove when all usages of runtimeStackTrace are migrated.
|
|
295
|
-
runtimeStackTrace?: Protocol.Runtime.StackTrace;
|
|
296
229
|
tabStops?: boolean;
|
|
297
230
|
// Whether the width of stack trace preview
|
|
298
231
|
// is constrained to its container or whether
|
|
@@ -304,7 +237,7 @@ export interface Options {
|
|
|
304
237
|
|
|
305
238
|
interface StackTraceRegularRow {
|
|
306
239
|
functionName: string;
|
|
307
|
-
link: HTMLElement
|
|
240
|
+
link: HTMLElement;
|
|
308
241
|
}
|
|
309
242
|
|
|
310
243
|
interface StackTraceAsyncRow {
|
|
@@ -312,89 +245,40 @@ interface StackTraceAsyncRow {
|
|
|
312
245
|
}
|
|
313
246
|
|
|
314
247
|
export class StackTracePreviewContent extends UI.Widget.Widget {
|
|
315
|
-
#
|
|
316
|
-
#target?: SDK.Target.Target;
|
|
317
|
-
#linkifier?: Linkifier;
|
|
318
|
-
#ownedLinkifier?: Linkifier;
|
|
319
|
-
#options: Options;
|
|
320
|
-
#links: HTMLElement[] = [];
|
|
321
|
-
|
|
322
|
-
readonly #table: HTMLElement;
|
|
323
|
-
/**
|
|
324
|
-
* Updated when we update to define if we have any rows for the StackTrace;
|
|
325
|
-
* allowing the caller to know if this element is empty or not.
|
|
326
|
-
*/
|
|
327
|
-
#hasRows = false;
|
|
328
|
-
|
|
329
|
-
constructor(element?: HTMLElement, target?: SDK.Target.Target, linkifier?: Linkifier, options?: Options) {
|
|
330
|
-
super(element, {useShadowDom: true});
|
|
331
|
-
|
|
332
|
-
this.#target = target;
|
|
333
|
-
this.#linkifier = linkifier;
|
|
334
|
-
if (!this.#linkifier) {
|
|
335
|
-
this.#ownedLinkifier = new Linkifier();
|
|
336
|
-
this.#linkifier = this.#ownedLinkifier;
|
|
337
|
-
}
|
|
338
|
-
this.#options = options || {
|
|
339
|
-
widthConstrained: false,
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
this.element.classList.add('monospace');
|
|
343
|
-
this.element.classList.add('stack-preview-container');
|
|
344
|
-
this.element.classList.toggle('width-constrained', this.#options.widthConstrained ?? false);
|
|
345
|
-
this.element.style.display = 'inline-block';
|
|
346
|
-
|
|
347
|
-
UI.DOMUtilities.appendStyle(this.element.shadowRoot as ShadowRoot, jsUtilsStyles);
|
|
248
|
+
readonly #view: View;
|
|
348
249
|
|
|
349
|
-
|
|
350
|
-
|
|
250
|
+
#stackTrace?: StackTrace.StackTrace.StackTrace;
|
|
251
|
+
#options: Options = {};
|
|
351
252
|
|
|
352
|
-
|
|
253
|
+
constructor(element?: HTMLElement, view = DEFAULT_VIEW) {
|
|
254
|
+
super(element, {useShadowDom: true, classes: ['monospace', 'stack-preview-container']});
|
|
255
|
+
this.#view = view;
|
|
353
256
|
}
|
|
354
257
|
|
|
355
258
|
hasContent(): boolean {
|
|
356
|
-
|
|
259
|
+
if (!this.#stackTrace) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
const {syncFragment, asyncFragments} = this.#stackTrace;
|
|
263
|
+
return syncFragment.frames.length > 0 || asyncFragments.some(f => f.frames.length > 0);
|
|
357
264
|
}
|
|
358
265
|
|
|
359
266
|
override performUpdate(): void {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
this
|
|
370
|
-
this.#links = renderStackTraceTable(this.#table, this.element, this.#options.expandable ?? false, stackTraceRows);
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (runtimeStackTrace) {
|
|
375
|
-
// TODO(crbug.com/456517732): remove when all usages of runtimeStackTrace are migrated.
|
|
376
|
-
const updateCallback =
|
|
377
|
-
renderStackTraceTable.bind(null, this.#table, this.element, this.#options.expandable ?? false);
|
|
378
|
-
const stackTraceRows = buildStackTraceRowsForLegacyRuntimeStackTrace(
|
|
379
|
-
runtimeStackTrace ?? {callFrames: []}, this.#target ?? null, this.#linkifier, tabStops, updateCallback,
|
|
380
|
-
this.#options.showColumnNumber);
|
|
381
|
-
this.#hasRows = stackTraceRows.length > 0;
|
|
382
|
-
this.#links = renderStackTraceTable(this.#table, this.element, this.#options.expandable ?? false, stackTraceRows);
|
|
267
|
+
const output: {table?: HTMLElement} = {};
|
|
268
|
+
this.#view(
|
|
269
|
+
{
|
|
270
|
+
stackTrace: this.#stackTrace,
|
|
271
|
+
...this.#options,
|
|
272
|
+
},
|
|
273
|
+
output, this.contentElement);
|
|
274
|
+
|
|
275
|
+
if (this.#stackTrace && output.table) {
|
|
276
|
+
renderStackTraceTable(output.table, this.element, this.#stackTrace, this.#options);
|
|
383
277
|
}
|
|
384
278
|
}
|
|
385
279
|
|
|
386
280
|
get linkElements(): readonly HTMLElement[] {
|
|
387
|
-
return this
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
set target(target: SDK.Target.Target|undefined) {
|
|
391
|
-
this.#target = target;
|
|
392
|
-
this.requestUpdate();
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
set linkifier(linkifier: Linkifier) {
|
|
396
|
-
this.#linkifier = linkifier;
|
|
397
|
-
this.requestUpdate();
|
|
281
|
+
return [...this.contentElement.querySelectorAll<HTMLElement>('td.link > .devtools-link')];
|
|
398
282
|
}
|
|
399
283
|
|
|
400
284
|
set options(options: Options) {
|
|
@@ -410,8 +294,4 @@ export class StackTracePreviewContent extends UI.Widget.Widget {
|
|
|
410
294
|
this.#stackTrace.addEventListener(StackTrace.StackTrace.Events.UPDATED, this.requestUpdate, this);
|
|
411
295
|
this.requestUpdate();
|
|
412
296
|
}
|
|
413
|
-
|
|
414
|
-
override onDetach(): void {
|
|
415
|
-
this.#ownedLinkifier?.dispose();
|
|
416
|
-
}
|
|
417
297
|
}
|
|
@@ -17,7 +17,7 @@ import * as TextUtils from '../../../../models/text_utils/text_utils.js';
|
|
|
17
17
|
import type * as Trace from '../../../../models/trace/trace.js';
|
|
18
18
|
import * as Workspace from '../../../../models/workspace/workspace.js';
|
|
19
19
|
import * as UIHelpers from '../../../helpers/helpers.js';
|
|
20
|
-
import {Directives, html, type LitTemplate, render} from '../../../lit/lit.js';
|
|
20
|
+
import {Directives, html, type LitTemplate, render, type TemplateResult} from '../../../lit/lit.js';
|
|
21
21
|
import * as VisualLogging from '../../../visual_logging/visual_logging.js';
|
|
22
22
|
import * as UI from '../../legacy.js';
|
|
23
23
|
|
|
@@ -562,7 +562,7 @@ export class Linkifier extends Common.ObjectWrapper.ObjectWrapper<EventTypes> im
|
|
|
562
562
|
info.icon = icon;
|
|
563
563
|
}
|
|
564
564
|
|
|
565
|
-
static renderLinkifiedUrl(url: Platform.DevToolsPath.UrlString, options?: LinkifyURLOptions):
|
|
565
|
+
static renderLinkifiedUrl(url: Platform.DevToolsPath.UrlString, options?: LinkifyURLOptions): TemplateResult {
|
|
566
566
|
options = options || {
|
|
567
567
|
showColumnNumber: false,
|
|
568
568
|
inlineFrameIndex: 0,
|
|
@@ -639,7 +639,8 @@ export class Linkifier extends Common.ObjectWrapper.ObjectWrapper<EventTypes> im
|
|
|
639
639
|
return link;
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
-
private static renderLink(text: string|HTMLElement, className: string, options: CreateLinkOptions = {}):
|
|
642
|
+
private static renderLink(text: string|HTMLElement, className: string, options: CreateLinkOptions = {}):
|
|
643
|
+
TemplateResult {
|
|
643
644
|
const {maxLength, title, href, preventClick, tabStop, bypassURLTrimming, jslogContext} = options;
|
|
644
645
|
const classes: Record<string, boolean> = {
|
|
645
646
|
'devtools-link': true,
|
|
@@ -666,6 +667,7 @@ export class Linkifier extends Common.ObjectWrapper.ObjectWrapper<EventTypes> im
|
|
|
666
667
|
if (!link) {
|
|
667
668
|
return;
|
|
668
669
|
}
|
|
670
|
+
options.onRef?.(link as HTMLElement);
|
|
669
671
|
if (text instanceof HTMLElement) {
|
|
670
672
|
link.appendChild(text);
|
|
671
673
|
} else if (bypassURLTrimming) {
|
|
@@ -1153,6 +1155,7 @@ export interface LinkifyURLOptions {
|
|
|
1153
1155
|
userMetric?: Host.UserMetrics.Action;
|
|
1154
1156
|
jslogContext?: string;
|
|
1155
1157
|
omitOrigin?: boolean;
|
|
1158
|
+
onRef?: (el: HTMLElement) => void;
|
|
1156
1159
|
}
|
|
1157
1160
|
|
|
1158
1161
|
export interface LinkifyOptions {
|
|
@@ -1183,6 +1186,7 @@ interface CreateLinkOptions {
|
|
|
1183
1186
|
lineNumber?: number;
|
|
1184
1187
|
columnNumber?: number;
|
|
1185
1188
|
userMetric?: Host.UserMetrics.Action;
|
|
1189
|
+
onRef?: (el: HTMLElement) => void;
|
|
1186
1190
|
}
|
|
1187
1191
|
|
|
1188
1192
|
interface LinkDisplayOptions {
|
package/package.json
CHANGED