chrome-devtools-frontend 1.0.1011873 → 1.0.1013237
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/codereview.settings +4 -0
- package/config/gni/devtools_grd_files.gni +3 -0
- package/front_end/core/host/UserMetrics.ts +5 -2
- package/front_end/core/i18n/locales/en-US.json +38 -2
- package/front_end/core/i18n/locales/en-XL.json +38 -2
- package/front_end/core/root/Runtime.ts +2 -0
- package/front_end/core/sdk/CSSFontFace.ts +6 -0
- package/front_end/core/sdk/CSSModel.ts +4 -0
- package/front_end/entrypoints/main/MainImpl.ts +9 -0
- package/front_end/entrypoints/wasmparser_worker/WasmParserWorker.ts +2 -14
- package/front_end/generated/InspectorBackendCommands.js +2 -0
- package/front_end/generated/protocol.ts +20 -0
- package/front_end/models/emulation/EmulatedDevices.ts +29 -2
- package/front_end/models/javascript_metadata/NativeFunctions.js +8 -17
- package/front_end/models/persistence/NetworkPersistenceManager.ts +7 -4
- package/front_end/panels/application/AppManifestView.ts +12 -1
- package/front_end/panels/application/DOMStorageItemsView.ts +5 -5
- package/front_end/panels/application/components/ProtocolHandlersView.ts +182 -0
- package/front_end/panels/application/components/components.ts +2 -0
- package/front_end/panels/application/components/protocolHandlersView.css +39 -0
- package/front_end/panels/profiler/HeapSnapshotView.ts +3 -1
- package/front_end/panels/sources/NavigatorView.ts +50 -22
- package/front_end/panels/sources/SourcesNavigator.ts +45 -1
- package/front_end/panels/sources/SourcesPanel.ts +26 -4
- package/front_end/panels/sources/navigatorTree.css +4 -0
- package/front_end/panels/sources/sourcesNavigator.css +10 -0
- package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +15 -15
- package/front_end/third_party/lighthouse/report/bundle.d.ts +23 -2
- package/front_end/third_party/lighthouse/report/bundle.js +45 -19
- package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +1 -1
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +16 -11
- package/front_end/ui/components/linear_memory_inspector/linearMemoryInspector.css +4 -0
- package/front_end/ui/components/panel_feedback/PreviewToggle.ts +34 -13
- package/front_end/ui/components/panel_feedback/previewToggle.css +21 -1
- package/front_end/ui/components/text_editor/config.ts +2 -2
- package/front_end/ui/legacy/ContextMenu.ts +11 -2
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +15 -12
- package/package.json +1 -1
- package/scripts/build/ninja/devtools_entrypoint.gni +3 -3
- package/scripts/build/ninja/wasm.gni +25 -0
- package/scripts/build/wasm-as.py +87 -0
- package/scripts/build/wasm_sourcemap.mjs +22 -0
- package/scripts/eslint_rules/lib/lit_template_result_or_nothing.js +6 -0
@@ -115,19 +115,22 @@ export class LinearMemoryViewer extends HTMLElement {
|
|
115
115
|
|
116
116
|
// We initially just plot one row with one byte group (here: byte group size of 4).
|
117
117
|
// Depending on that initially plotted row we can determine how many rows and
|
118
|
-
// bytes per row we can fit
|
119
|
-
// >
|
120
|
-
//
|
121
|
-
//
|
122
|
-
//
|
123
|
-
//
|
118
|
+
// bytes per row we can fit.
|
119
|
+
// > 0000000 | b0 b1 b2 b4 | a0 a1 a2 a3 <
|
120
|
+
// ^-------^ ^-^ ^-^
|
121
|
+
// | byteCellWidth textCellWidth
|
122
|
+
// |
|
123
|
+
// addressTextAndDividerWidth
|
124
|
+
// ^--^ + ^----------------------------^
|
125
|
+
// widthToFill
|
124
126
|
|
125
127
|
const firstByteCell = this.shadowRoot.querySelector('.byte-cell');
|
126
128
|
const textCell = this.shadowRoot.querySelector('.text-cell');
|
127
129
|
const divider = this.shadowRoot.querySelector('.divider');
|
128
130
|
const rowElement = this.shadowRoot.querySelector('.row');
|
131
|
+
const addressText = this.shadowRoot.querySelector('.address');
|
129
132
|
|
130
|
-
if (!firstByteCell || !textCell || !divider || !rowElement) {
|
133
|
+
if (!firstByteCell || !textCell || !divider || !rowElement || !addressText) {
|
131
134
|
this.#numBytesInRow = BYTE_GROUP_SIZE;
|
132
135
|
this.#numRows = 1;
|
133
136
|
return;
|
@@ -140,16 +143,18 @@ export class LinearMemoryViewer extends HTMLElement {
|
|
140
143
|
|
141
144
|
// Calculate the width to fill.
|
142
145
|
const dividerWidth = divider.getBoundingClientRect().width;
|
143
|
-
|
146
|
+
const addressTextAndDividerWidth =
|
147
|
+
firstByteCell.getBoundingClientRect().left - addressText.getBoundingClientRect().left;
|
148
|
+
|
149
|
+
// this.clientWidth is rounded, while the other values are not. Subtract 1 to make
|
144
150
|
// sure that we correctly calculate the widths.
|
145
|
-
const widthToFill = this.clientWidth - 1 -
|
146
|
-
|
151
|
+
const widthToFill = this.clientWidth - 1 - addressTextAndDividerWidth - dividerWidth;
|
152
|
+
|
147
153
|
if (widthToFill < groupWidth) {
|
148
154
|
this.#numBytesInRow = BYTE_GROUP_SIZE;
|
149
155
|
this.#numRows = 1;
|
150
156
|
return;
|
151
157
|
}
|
152
|
-
|
153
158
|
this.#numBytesInRow = Math.floor(widthToFill / groupWidth) * BYTE_GROUP_SIZE;
|
154
159
|
this.#numRows = Math.floor(this.clientHeight / rowElement.clientHeight);
|
155
160
|
}
|
@@ -18,6 +18,7 @@ export interface PreviewToggleData {
|
|
18
18
|
helperText: string|null;
|
19
19
|
feedbackURL: string|null;
|
20
20
|
experiment: Root.Runtime.ExperimentName;
|
21
|
+
learnMoreURL?: string;
|
21
22
|
onChangeCallback?: (checked: boolean) => void;
|
22
23
|
}
|
23
24
|
|
@@ -26,6 +27,14 @@ const UIStrings = {
|
|
26
27
|
*@description Link text the user can click to provide feedback to the team.
|
27
28
|
*/
|
28
29
|
previewTextFeedbackLink: 'Send us your feedback.',
|
30
|
+
/**
|
31
|
+
*@description Link text the user can click to provide feedback to the team.
|
32
|
+
*/
|
33
|
+
shortFeedbackLink: 'Send feedback',
|
34
|
+
/**
|
35
|
+
*@description Link text the user can click to see documentation.
|
36
|
+
*/
|
37
|
+
learnMoreLink: 'Learn More',
|
29
38
|
};
|
30
39
|
|
31
40
|
const str_ = i18n.i18n.registerUIStrings('ui/components/panel_feedback/PreviewToggle.ts', UIStrings);
|
@@ -38,6 +47,7 @@ export class PreviewToggle extends HTMLElement {
|
|
38
47
|
#name = '';
|
39
48
|
#helperText: string|null = null;
|
40
49
|
#feedbackURL: string|null = null;
|
50
|
+
#learnMoreURL: string|undefined;
|
41
51
|
#experiment: string = '';
|
42
52
|
#onChangeCallback?: (checked: boolean) => void;
|
43
53
|
|
@@ -49,6 +59,7 @@ export class PreviewToggle extends HTMLElement {
|
|
49
59
|
this.#name = data.name;
|
50
60
|
this.#helperText = data.helperText;
|
51
61
|
this.#feedbackURL = data.feedbackURL;
|
62
|
+
this.#learnMoreURL = data.learnMoreURL;
|
52
63
|
this.#experiment = data.experiment;
|
53
64
|
this.#onChangeCallback = data.onChangeCallback;
|
54
65
|
this.#render();
|
@@ -60,20 +71,30 @@ export class PreviewToggle extends HTMLElement {
|
|
60
71
|
// clang-format off
|
61
72
|
render(
|
62
73
|
html`
|
63
|
-
<div class="
|
64
|
-
<
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
74
|
+
<div class="container">
|
75
|
+
<div class="checkbox-line">
|
76
|
+
<label class="experiment-preview">
|
77
|
+
<input type="checkbox" ?checked=${checked} @change=${this.#checkboxChanged} aria-label=${this.#name}/>
|
78
|
+
<${IconButton.Icon.Icon.litTagName} .data=${{
|
79
|
+
iconName: 'ic_preview_feature',
|
80
|
+
width: '16px',
|
81
|
+
height: '16px',
|
82
|
+
color: 'var(--color-text-secondary)',
|
83
|
+
} as IconButton.Icon.IconData}>
|
84
|
+
</${IconButton.Icon.Icon.litTagName}>${this.#name}
|
85
|
+
</label>
|
86
|
+
${this.#feedbackURL && !this.#helperText
|
87
|
+
? html`<div class="feedback"><x-link class="x-link" href=${this.#feedbackURL}>${i18nString(UIStrings.shortFeedbackLink)}</x-link></div>`
|
88
|
+
: nothing}
|
89
|
+
</div>
|
90
|
+
${this.#learnMoreURL
|
91
|
+
? html`<x-link class="x-link" href=${this.#learnMoreURL}>${i18nString(UIStrings.learnMoreLink)}</x-link>`
|
76
92
|
: nothing}
|
93
|
+
<div class="helper">
|
94
|
+
${this.#helperText && this.#feedbackURL
|
95
|
+
? html`<p>${this.#helperText} <x-link class="x-link" href=${this.#feedbackURL}>${i18nString(UIStrings.previewTextFeedbackLink)}</x-link></p>`
|
96
|
+
: nothing}
|
97
|
+
</div>
|
77
98
|
</div>`,
|
78
99
|
this.#shadow,
|
79
100
|
{
|
@@ -18,7 +18,27 @@
|
|
18
18
|
font-style: italic;
|
19
19
|
}
|
20
20
|
|
21
|
-
|
21
|
+
.feedback {
|
22
|
+
text-align: right;
|
23
|
+
}
|
24
|
+
|
25
|
+
.checkbox-line {
|
26
|
+
display: flex;
|
27
|
+
justify-content: space-between;
|
28
|
+
align-items: center;
|
29
|
+
flex-wrap: wrap;
|
30
|
+
}
|
31
|
+
|
32
|
+
.container {
|
33
|
+
padding: 4px;
|
34
|
+
}
|
35
|
+
|
36
|
+
.x-link {
|
22
37
|
color: var(--color-primary);
|
23
38
|
text-decoration-line: underline;
|
39
|
+
padding: 4px;
|
40
|
+
}
|
41
|
+
|
42
|
+
.feedback .x-link {
|
43
|
+
color: var(--color-text-secondary);
|
24
44
|
}
|
@@ -236,7 +236,7 @@ function getTooltipSpace(): DOMRect {
|
|
236
236
|
return sideBarElement.getBoundingClientRect();
|
237
237
|
}
|
238
238
|
|
239
|
-
export function baseConfiguration(text: string): CM.Extension {
|
239
|
+
export function baseConfiguration(text: string|CM.Text): CM.Extension {
|
240
240
|
return [
|
241
241
|
theme(),
|
242
242
|
CM.highlightSpecialChars(),
|
@@ -252,7 +252,7 @@ export function baseConfiguration(text: string): CM.Extension {
|
|
252
252
|
bracketMatching.instance(),
|
253
253
|
indentUnit.instance(),
|
254
254
|
CM.Prec.lowest(CM.EditorView.contentAttributes.of({'aria-label': i18nString(UIStrings.codeEditor)})),
|
255
|
-
detectLineSeparator(text),
|
255
|
+
text instanceof CM.Text ? [] : detectLineSeparator(text),
|
256
256
|
CM.tooltips({
|
257
257
|
tooltipSpace: getTooltipSpace,
|
258
258
|
}),
|
@@ -111,7 +111,7 @@ export class Item {
|
|
111
111
|
};
|
112
112
|
}
|
113
113
|
case 'checkbox': {
|
114
|
-
|
114
|
+
const result = {
|
115
115
|
type: 'checkbox',
|
116
116
|
id: this.idInternal,
|
117
117
|
label: this.label,
|
@@ -119,6 +119,11 @@ export class Item {
|
|
119
119
|
enabled: !this.disabled,
|
120
120
|
subItems: undefined,
|
121
121
|
};
|
122
|
+
if (this.customElement) {
|
123
|
+
const resultAsSoftContextMenuItem = (result as SoftContextMenuDescriptor);
|
124
|
+
resultAsSoftContextMenuItem.element = (this.customElement as Element);
|
125
|
+
}
|
126
|
+
return result;
|
122
127
|
}
|
123
128
|
}
|
124
129
|
throw new Error('Invalid item type:' + this.typeInternal);
|
@@ -187,12 +192,16 @@ export class Section {
|
|
187
192
|
return item;
|
188
193
|
}
|
189
194
|
|
190
|
-
appendCheckboxItem(
|
195
|
+
appendCheckboxItem(
|
196
|
+
label: string, handler: () => void, checked?: boolean, disabled?: boolean, additionalElement?: Element): Item {
|
191
197
|
const item = new Item(this.contextMenu, 'checkbox', label, disabled, checked);
|
192
198
|
this.items.push(item);
|
193
199
|
if (this.contextMenu) {
|
194
200
|
this.contextMenu.setHandler(item.id(), handler);
|
195
201
|
}
|
202
|
+
if (additionalElement) {
|
203
|
+
item.customElement = additionalElement;
|
204
|
+
}
|
196
205
|
return item;
|
197
206
|
}
|
198
207
|
}
|
@@ -105,7 +105,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
105
105
|
UI.View.SimpleView) implements UI.SearchableView.Searchable, UI.SearchableView.Replaceable, Transformer {
|
106
106
|
private readonly lazyContent: () => Promise<TextUtils.ContentProvider.DeferredContent>;
|
107
107
|
private prettyInternal: boolean;
|
108
|
-
private rawContent: string|null;
|
108
|
+
private rawContent: string|CodeMirror.Text|null;
|
109
109
|
private formattedContentPromise: Promise<Formatter.ScriptFormatter.FormattedContent>|null;
|
110
110
|
private formattedMap: Formatter.ScriptFormatter.FormatterSourceMapping|null;
|
111
111
|
private readonly prettyToggle: UI.Toolbar.ToolbarToggle;
|
@@ -203,7 +203,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
203
203
|
});
|
204
204
|
}
|
205
205
|
|
206
|
-
protected editorConfiguration(doc: string): CodeMirror.Extension {
|
206
|
+
protected editorConfiguration(doc: string|CodeMirror.Text): CodeMirror.Extension {
|
207
207
|
return [
|
208
208
|
CodeMirror.EditorView.updateListener.of(update => this.dispatchEventToListeners(Events.EditorUpdate, update)),
|
209
209
|
TextEditor.Config.baseConfiguration(doc),
|
@@ -459,7 +459,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
459
459
|
const worker = Common.Worker.WorkerWrapper.fromURL(
|
460
460
|
new URL('../../../../entrypoints/wasmparser_worker/wasmparser_worker-entrypoint.js', import.meta.url));
|
461
461
|
const promise = new Promise<{
|
462
|
-
|
462
|
+
lines: string[],
|
463
463
|
offsets: number[],
|
464
464
|
functionBodyOffsets: {
|
465
465
|
start: number,
|
@@ -492,8 +492,8 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
492
492
|
});
|
493
493
|
worker.postMessage({method: 'disassemble', params: {content}});
|
494
494
|
try {
|
495
|
-
const {
|
496
|
-
this.rawContent = content =
|
495
|
+
const {lines, offsets, functionBodyOffsets} = await promise;
|
496
|
+
this.rawContent = content = CodeMirror.Text.of(lines);
|
497
497
|
this.wasmDisassemblyInternal = new Common.WasmDisassembly.WasmDisassembly(offsets, functionBodyOffsets);
|
498
498
|
} catch (e) {
|
499
499
|
this.rawContent = content = error = e.message;
|
@@ -528,8 +528,8 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
528
528
|
if (this.formattedContentPromise) {
|
529
529
|
return this.formattedContentPromise;
|
530
530
|
}
|
531
|
-
this.
|
532
|
-
|
531
|
+
const content = this.rawContent instanceof CodeMirror.Text ? this.rawContent.sliceString(0) : this.rawContent || '';
|
532
|
+
this.formattedContentPromise = Formatter.ScriptFormatter.formatScriptContent(this.contentType, content);
|
533
533
|
return this.formattedContentPromise;
|
534
534
|
}
|
535
535
|
|
@@ -648,7 +648,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
648
648
|
this.prettyToggle.setEnabled(true);
|
649
649
|
}
|
650
650
|
|
651
|
-
private simplifyMimeType(content: string, mimeType: string): string {
|
651
|
+
private simplifyMimeType(content: string|CodeMirror.Text, mimeType: string): string {
|
652
652
|
if (!mimeType) {
|
653
653
|
return '';
|
654
654
|
}
|
@@ -663,8 +663,11 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
663
663
|
return 'text/jsx';
|
664
664
|
}
|
665
665
|
// A hack around the fact that files with "php" extension might be either standalone or html embedded php scripts.
|
666
|
-
if (mimeType === 'text/x-php'
|
667
|
-
|
666
|
+
if (mimeType === 'text/x-php') {
|
667
|
+
const strContent = typeof content === 'string' ? content : content.sliceString(0);
|
668
|
+
if (strContent.match(/\<\?.*\?\>/g)) {
|
669
|
+
return 'application/x-httpd-php';
|
670
|
+
}
|
668
671
|
}
|
669
672
|
if (mimeType === 'application/wasm') {
|
670
673
|
// text/webassembly is not a proper MIME type, but CodeMirror uses it for WAT syntax highlighting.
|
@@ -674,7 +677,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
674
677
|
return mimeType;
|
675
678
|
}
|
676
679
|
|
677
|
-
protected async getLanguageSupport(content: string): Promise<CodeMirror.Extension> {
|
680
|
+
protected async getLanguageSupport(content: string|CodeMirror.Text): Promise<CodeMirror.Extension> {
|
678
681
|
const mimeType = this.simplifyMimeType(content, this.contentType) || '';
|
679
682
|
const languageDesc = await CodeHighlighter.CodeHighlighter.languageFromMIME(mimeType);
|
680
683
|
if (!languageDesc) {
|
@@ -694,7 +697,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
694
697
|
this.textEditor.dispatch({effects: config.language.reconfigure(langExtension)});
|
695
698
|
}
|
696
699
|
|
697
|
-
async setContent(content: string): Promise<void> {
|
700
|
+
async setContent(content: string|CodeMirror.Text): Promise<void> {
|
698
701
|
this.muteChangeEventsForSetContent = true;
|
699
702
|
const {textEditor} = this;
|
700
703
|
const wasLoaded = this.loadedInternal;
|
package/package.json
CHANGED
@@ -121,9 +121,9 @@ template("devtools_entrypoint") {
|
|
121
121
|
|
122
122
|
is_web_worker = _is_web_worker
|
123
123
|
|
124
|
-
if (defined(
|
125
|
-
|
126
|
-
|
124
|
+
if (defined(use_remoteexec) && use_remoteexec &&
|
125
|
+
defined(devtools_use_remoteexec) && devtools_use_remoteexec) {
|
126
|
+
use_remoteexec = false
|
127
127
|
}
|
128
128
|
}
|
129
129
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright 2022 The Chromium Authors. All rights reserved.
|
2
|
+
# Use of this source code is governed by a BSD-style license that can be
|
3
|
+
# found in the LICENSE file.
|
4
|
+
import("./copy.gni")
|
5
|
+
|
6
|
+
template("wasm_module") {
|
7
|
+
assert(defined(invoker.sources), "Need sources in $target_name")
|
8
|
+
action_foreach(target_name) {
|
9
|
+
script = devtools_location_prepend + "scripts/build/wasm-as.py"
|
10
|
+
outputs = [
|
11
|
+
"$target_gen_dir/{{source_name_part}}.wasm",
|
12
|
+
"$target_gen_dir/{{source_name_part}}.wasm.map",
|
13
|
+
"$target_gen_dir/{{source_name_part}}.wasm.map.json",
|
14
|
+
]
|
15
|
+
args = [
|
16
|
+
"{{source}}",
|
17
|
+
rebase_path("$target_gen_dir/{{source_name_part}}.wasm", root_build_dir),
|
18
|
+
]
|
19
|
+
sources = invoker.sources
|
20
|
+
}
|
21
|
+
|
22
|
+
copy_to_gen(target_name + "_sources") {
|
23
|
+
sources = invoker.sources
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Copyright 2022 The Chromium Authors. All rights reserved.
|
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 argparse
|
6
|
+
import json
|
7
|
+
from os import path
|
8
|
+
import platform
|
9
|
+
import re
|
10
|
+
import subprocess
|
11
|
+
import sys
|
12
|
+
|
13
|
+
REPO_DIR = path.join(path.dirname(__file__), '..', '..')
|
14
|
+
|
15
|
+
|
16
|
+
def llvm_readobj():
|
17
|
+
binary_name = {
|
18
|
+
'Darwin': 'llvm-readobj',
|
19
|
+
'Linux': 'llvm-readobj',
|
20
|
+
'Windows': 'llvm-readobj.exe',
|
21
|
+
}[platform.system()]
|
22
|
+
return path.realpath(
|
23
|
+
path.join(REPO_DIR, 'third_party', 'emscripten-releases', 'install',
|
24
|
+
'bin', binary_name))
|
25
|
+
|
26
|
+
|
27
|
+
def wasm_as():
|
28
|
+
binary_name = {
|
29
|
+
'Darwin': 'wasm-as',
|
30
|
+
'Linux': 'wasm-as',
|
31
|
+
'Windows': 'wasm-as.exe',
|
32
|
+
}[platform.system()]
|
33
|
+
return path.realpath(
|
34
|
+
path.join(REPO_DIR, 'third_party', 'emscripten-releases', 'install',
|
35
|
+
'bin', binary_name))
|
36
|
+
|
37
|
+
|
38
|
+
def script_main(args):
|
39
|
+
parser = argparse.ArgumentParser()
|
40
|
+
parser.add_argument('input')
|
41
|
+
parser.add_argument('output')
|
42
|
+
options = parser.parse_args(args)
|
43
|
+
|
44
|
+
sourcemap = f'{options.output}.map'
|
45
|
+
subprocess.check_call([
|
46
|
+
wasm_as(), options.input, '-g', '-sm', sourcemap, '-o', options.output
|
47
|
+
])
|
48
|
+
|
49
|
+
wasm_obj_headers = subprocess.check_output([
|
50
|
+
llvm_readobj(),
|
51
|
+
'-e',
|
52
|
+
# TODO(crbug.com/1328729): use JSON output as soon as that's supported for wasm
|
53
|
+
# '--elf-output-style=JSON',
|
54
|
+
options.output
|
55
|
+
])
|
56
|
+
(size, offset) = re.search(
|
57
|
+
b'Section {[^}]*Type: CODE[^}]*Size: (\d*)[^}]*Offset: (\d*)[^}]*}',
|
58
|
+
wasm_obj_headers).groups()
|
59
|
+
|
60
|
+
# readobj reports as offset the location of the first byte of the header.
|
61
|
+
# Our offsets are relative to the first byte of the section though, so
|
62
|
+
# calculate the offset manually. The header is composed of one byte for the
|
63
|
+
# section id, and an leb128 value for the length.
|
64
|
+
size = int(size)
|
65
|
+
leb_len = 0
|
66
|
+
while size > 0:
|
67
|
+
size >>= 7
|
68
|
+
leb_len += 1
|
69
|
+
offset = int(offset) + 1 + leb_len
|
70
|
+
|
71
|
+
node = path.realpath(path.join(REPO_DIR, 'third_party', 'node', 'node.py'))
|
72
|
+
sourcemap2json = path.realpath(
|
73
|
+
path.join(REPO_DIR, 'scripts', 'build', 'wasm_sourcemap.mjs'))
|
74
|
+
sourcemap_contents = subprocess.check_output([
|
75
|
+
sys.executable, node, '--output', sourcemap2json, sourcemap,
|
76
|
+
'%s' % (offset)
|
77
|
+
])
|
78
|
+
|
79
|
+
json_file = f'{options.output}.map.json'
|
80
|
+
with open(json_file, 'wb') as output:
|
81
|
+
output.write(sourcemap_contents)
|
82
|
+
|
83
|
+
return 0
|
84
|
+
|
85
|
+
|
86
|
+
if __name__ == '__main__':
|
87
|
+
sys.exit(script_main(sys.argv[1:]))
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// Copyright 2022 The Chromium Authors. All rights reserved.
|
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 fs from 'fs';
|
6
|
+
import * as sourceMap from 'source-map';
|
7
|
+
|
8
|
+
if (process.argv.length !== 4) {
|
9
|
+
throw new Error(`usage: ${process.argv[1]} <input.map> <offset>`);
|
10
|
+
}
|
11
|
+
|
12
|
+
const offset = Number(process.argv[3] || 0);
|
13
|
+
const sourceMapContents = JSON.parse(fs.readFileSync(process.argv[2], 'utf-8'));
|
14
|
+
const sourceMapConsumer = new sourceMap.SourceMapConsumer(sourceMapContents);
|
15
|
+
|
16
|
+
const sourceMappings = [];
|
17
|
+
sourceMapConsumer.eachMapping(({source, generatedLine, generatedColumn, originalLine, originalColumn}) => {
|
18
|
+
const bytecodeOffset = generatedColumn - offset;
|
19
|
+
sourceMappings.push({source, generatedLine, generatedColumn, originalLine, originalColumn, bytecodeOffset});
|
20
|
+
});
|
21
|
+
|
22
|
+
console.log(JSON.stringify(sourceMappings));
|
@@ -95,6 +95,9 @@ module.exports = {
|
|
95
95
|
|
96
96
|
function checkTSTypeAnnotationForPotentialIssue(node) {
|
97
97
|
const annotation = node.typeAnnotation;
|
98
|
+
if (!annotation) {
|
99
|
+
return;
|
100
|
+
}
|
98
101
|
if (annotation.type === 'TSUnionType') {
|
99
102
|
// matches foo(): X|Y
|
100
103
|
checkUnionReturnTypeForLit(annotation);
|
@@ -137,6 +140,9 @@ module.exports = {
|
|
137
140
|
},
|
138
141
|
// Match values in interfaces or types.
|
139
142
|
TSPropertySignature(node) {
|
143
|
+
if (!node.typeAnnotation) {
|
144
|
+
return;
|
145
|
+
}
|
140
146
|
checkTSTypeAnnotationForPotentialIssue(node.typeAnnotation);
|
141
147
|
},
|
142
148
|
};
|