chrome-devtools-frontend 1.0.945329 → 1.0.945579
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/config/gni/devtools_grd_files.gni +1 -0
- package/config/gni/devtools_image_files.gni +1 -0
- package/front_end/Images/src/circled_exclamation_icon.svg +3 -0
- package/front_end/core/sdk/CSSMetadata.ts +0 -1
- package/front_end/generated/protocol.d.ts +0 -4
- package/front_end/models/emulation/EmulatedDevices.ts +2 -4
- package/front_end/panels/application/BackForwardCacheView.ts +8 -1
- package/front_end/panels/elements/StyleEditorWidget.ts +13 -2
- package/front_end/panels/elements/StylePropertyTreeElement.ts +8 -12
- package/front_end/panels/elements/StylesSidebarPane.ts +35 -9
- package/front_end/ui/components/adorners/Adorner.ts +14 -14
- package/front_end/ui/components/buttons/Button.ts +116 -42
- package/front_end/ui/components/data_grid/DataGrid.ts +122 -122
- package/front_end/ui/components/data_grid/DataGridController.ts +42 -42
- package/front_end/ui/components/diff_view/DiffView.ts +4 -4
- package/front_end/ui/components/docs/button/basic.html +3 -0
- package/front_end/ui/components/docs/button/basic.ts +16 -0
- package/front_end/ui/components/expandable_list/ExpandableList.ts +11 -11
- package/front_end/ui/components/icon_button/Icon.ts +24 -21
- package/front_end/ui/components/icon_button/IconButton.ts +31 -31
- package/front_end/ui/components/issue_counter/IssueCounter.ts +52 -52
- package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +42 -42
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspector.ts +67 -67
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorController.ts +22 -22
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorPane.ts +36 -36
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryNavigator.ts +19 -19
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryValueInterpreter.ts +25 -25
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +52 -52
- package/front_end/ui/components/linear_memory_inspector/ValueInterpreterDisplay.ts +21 -21
- package/front_end/ui/components/linear_memory_inspector/ValueInterpreterSettings.ts +6 -6
- package/front_end/ui/components/markdown_view/MarkdownImage.ts +14 -14
- package/front_end/ui/components/markdown_view/MarkdownLink.ts +8 -8
- package/front_end/ui/components/markdown_view/MarkdownView.ts +6 -6
- package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +33 -33
- package/front_end/ui/components/report_view/ReportView.ts +18 -18
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +53 -53
- package/front_end/ui/components/settings/SettingCheckbox.ts +15 -15
- package/front_end/ui/components/survey_link/SurveyLink.ts +28 -28
- package/front_end/ui/components/text_editor/TextEditor.ts +51 -51
- package/front_end/ui/components/text_editor/javascript.ts +6 -6
- package/front_end/ui/components/text_prompt/TextPrompt.ts +19 -19
- package/front_end/ui/components/tree_outline/TreeOutline.ts +56 -56
- package/front_end/ui/legacy/Infobar.ts +9 -0
- package/front_end/ui/legacy/tabbedPane.css +1 -1
- package/package.json +1 -1
|
@@ -55,73 +55,73 @@ const coordinator = Coordinator.RenderCoordinator.RenderCoordinator.instance();
|
|
|
55
55
|
|
|
56
56
|
export class RequestLinkIcon extends HTMLElement {
|
|
57
57
|
static readonly litTagName = LitHtml.literal`devtools-request-link-icon`;
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
readonly #shadow = this.attachShadow({mode: 'open'});
|
|
59
|
+
#linkToPreflight?: boolean;
|
|
60
60
|
// The value `null` indicates that the request is not available,
|
|
61
61
|
// `undefined` that it is still being resolved.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
#request?: SDK.NetworkRequest.NetworkRequest|null;
|
|
63
|
+
#highlightHeader?: {section: NetworkForward.UIRequestLocation.UIHeaderSection, name: string};
|
|
64
|
+
#requestResolver?: Logs.RequestResolver.RequestResolver;
|
|
65
|
+
#displayURL: boolean = false;
|
|
66
|
+
#networkTab?: NetworkForward.UIRequestLocation.UIRequestTabs;
|
|
67
|
+
#affectedRequest?: {requestId: Protocol.Network.RequestId, url?: string};
|
|
68
|
+
#additionalOnClickAction?: () => void;
|
|
69
|
+
#reveal = Common.Revealer.reveal;
|
|
70
|
+
#requestResolvedPromise = Promise.resolve<void>(undefined);
|
|
71
71
|
|
|
72
72
|
set data(data: RequestLinkIconData) {
|
|
73
|
-
this
|
|
74
|
-
this
|
|
73
|
+
this.#linkToPreflight = data.linkToPreflight;
|
|
74
|
+
this.#request = data.request;
|
|
75
75
|
if (data.affectedRequest) {
|
|
76
|
-
this
|
|
76
|
+
this.#affectedRequest = {...data.affectedRequest};
|
|
77
77
|
}
|
|
78
|
-
this
|
|
79
|
-
this
|
|
80
|
-
this
|
|
81
|
-
this
|
|
82
|
-
this
|
|
78
|
+
this.#highlightHeader = data.highlightHeader;
|
|
79
|
+
this.#networkTab = data.networkTab;
|
|
80
|
+
this.#requestResolver = data.requestResolver;
|
|
81
|
+
this.#displayURL = data.displayURL ?? false;
|
|
82
|
+
this.#additionalOnClickAction = data.additionalOnClickAction;
|
|
83
83
|
if (data.revealOverride) {
|
|
84
|
-
this
|
|
84
|
+
this.#reveal = data.revealOverride;
|
|
85
85
|
}
|
|
86
|
-
if (!this
|
|
87
|
-
this
|
|
86
|
+
if (!this.#request && data.affectedRequest) {
|
|
87
|
+
this.#requestResolvedPromise = this.resolveRequest(data.affectedRequest.requestId);
|
|
88
88
|
}
|
|
89
89
|
this.render();
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
connectedCallback(): void {
|
|
93
|
-
this
|
|
93
|
+
this.#shadow.adoptedStyleSheets = [requestLinkIconStyles];
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
private resolveRequest(requestId: Protocol.Network.RequestId): Promise<void> {
|
|
97
|
-
if (!this
|
|
97
|
+
if (!this.#requestResolver) {
|
|
98
98
|
throw new Error('A `RequestResolver` must be provided if an `affectedRequest` is provided.');
|
|
99
99
|
}
|
|
100
|
-
return this
|
|
100
|
+
return this.#requestResolver.waitFor(requestId)
|
|
101
101
|
.then(request => {
|
|
102
|
-
this
|
|
102
|
+
this.#request = request;
|
|
103
103
|
})
|
|
104
104
|
.catch(() => {
|
|
105
|
-
this
|
|
105
|
+
this.#request = null;
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
get data(): RequestLinkIconData {
|
|
110
110
|
return {
|
|
111
|
-
linkToPreflight: this
|
|
112
|
-
request: this
|
|
113
|
-
affectedRequest: this
|
|
114
|
-
highlightHeader: this
|
|
115
|
-
networkTab: this
|
|
116
|
-
requestResolver: this
|
|
117
|
-
displayURL: this
|
|
118
|
-
additionalOnClickAction: this
|
|
119
|
-
revealOverride: this
|
|
111
|
+
linkToPreflight: this.#linkToPreflight,
|
|
112
|
+
request: this.#request,
|
|
113
|
+
affectedRequest: this.#affectedRequest,
|
|
114
|
+
highlightHeader: this.#highlightHeader,
|
|
115
|
+
networkTab: this.#networkTab,
|
|
116
|
+
requestResolver: this.#requestResolver,
|
|
117
|
+
displayURL: this.#displayURL,
|
|
118
|
+
additionalOnClickAction: this.#additionalOnClickAction,
|
|
119
|
+
revealOverride: this.#reveal !== Common.Revealer.reveal ? this.#reveal : undefined,
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
private iconColor(): string {
|
|
124
|
-
if (!this
|
|
124
|
+
if (!this.#request) {
|
|
125
125
|
return '--issue-color-yellow';
|
|
126
126
|
}
|
|
127
127
|
return '--color-link';
|
|
@@ -140,38 +140,38 @@ export class RequestLinkIcon extends HTMLElement {
|
|
|
140
140
|
if (event.button !== 0) {
|
|
141
141
|
return; // Only handle left-click for now.
|
|
142
142
|
}
|
|
143
|
-
const linkedRequest = this
|
|
143
|
+
const linkedRequest = this.#linkToPreflight ? this.#request?.preflightRequest() : this.#request;
|
|
144
144
|
if (!linkedRequest) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
if (this
|
|
147
|
+
if (this.#highlightHeader) {
|
|
148
148
|
const requestLocation = NetworkForward.UIRequestLocation.UIRequestLocation.header(
|
|
149
|
-
linkedRequest, this
|
|
150
|
-
this
|
|
149
|
+
linkedRequest, this.#highlightHeader.section, this.#highlightHeader.name);
|
|
150
|
+
this.#reveal(requestLocation);
|
|
151
151
|
} else {
|
|
152
152
|
const requestLocation = NetworkForward.UIRequestLocation.UIRequestLocation.tab(
|
|
153
|
-
linkedRequest, this
|
|
154
|
-
this
|
|
153
|
+
linkedRequest, this.#networkTab ?? NetworkForward.UIRequestLocation.UIRequestTabs.Headers);
|
|
154
|
+
this.#reveal(requestLocation);
|
|
155
155
|
}
|
|
156
|
-
this
|
|
156
|
+
this.#additionalOnClickAction?.();
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
private getTooltip(): Platform.UIString.LocalizedString {
|
|
160
|
-
if (this
|
|
161
|
-
return i18nString(UIStrings.clickToShowRequestInTheNetwork, {url: this
|
|
160
|
+
if (this.#request) {
|
|
161
|
+
return i18nString(UIStrings.clickToShowRequestInTheNetwork, {url: this.#request.url()});
|
|
162
162
|
}
|
|
163
163
|
return i18nString(UIStrings.requestUnavailableInTheNetwork);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
private getUrlForDisplaying(): string|undefined {
|
|
167
|
-
if (!this
|
|
168
|
-
return this
|
|
167
|
+
if (!this.#request) {
|
|
168
|
+
return this.#affectedRequest?.url;
|
|
169
169
|
}
|
|
170
|
-
return this
|
|
170
|
+
return this.#request.url();
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
private maybeRenderURL(): LitHtml.TemplateResult|{} {
|
|
174
|
-
if (!this
|
|
174
|
+
if (!this.#displayURL) {
|
|
175
175
|
return LitHtml.nothing;
|
|
176
176
|
}
|
|
177
177
|
const url = this.getUrlForDisplaying();
|
|
@@ -186,9 +186,9 @@ export class RequestLinkIcon extends HTMLElement {
|
|
|
186
186
|
return coordinator.write(() => {
|
|
187
187
|
// clang-format off
|
|
188
188
|
LitHtml.render(LitHtml.html`
|
|
189
|
-
${LitHtml.Directives.until(this
|
|
189
|
+
${LitHtml.Directives.until(this.#requestResolvedPromise.then(() => this.renderComponent()), this.renderComponent())}
|
|
190
190
|
`,
|
|
191
|
-
this
|
|
191
|
+
this.#shadow, {host: this});
|
|
192
192
|
// clang-format on
|
|
193
193
|
});
|
|
194
194
|
}
|
|
@@ -196,7 +196,7 @@ export class RequestLinkIcon extends HTMLElement {
|
|
|
196
196
|
private renderComponent(): LitHtml.TemplateResult {
|
|
197
197
|
// clang-format off
|
|
198
198
|
return LitHtml.html`
|
|
199
|
-
<span class=${LitHtml.Directives.classMap({'link': Boolean(this
|
|
199
|
+
<span class=${LitHtml.Directives.classMap({'link': Boolean(this.#request)})}
|
|
200
200
|
tabindex="0"
|
|
201
201
|
@click=${this.handleClick}>
|
|
202
202
|
<${IconButton.Icon.Icon.litTagName} .data=${this.iconData() as IconButton.Icon.IconData}
|
|
@@ -22,32 +22,32 @@ export interface SettingCheckboxData {
|
|
|
22
22
|
*/
|
|
23
23
|
export class SettingCheckbox extends HTMLElement {
|
|
24
24
|
static readonly litTagName = LitHtml.literal`setting-checkbox`;
|
|
25
|
-
|
|
25
|
+
readonly #shadow = this.attachShadow({mode: 'open'});
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
#setting?: Common.Settings.Setting<boolean>;
|
|
28
|
+
#disabled: boolean = false;
|
|
29
|
+
#changeListenerDescriptor?: Common.EventTarget.EventDescriptor;
|
|
30
30
|
|
|
31
31
|
connectedCallback(): void {
|
|
32
|
-
this
|
|
32
|
+
this.#shadow.adoptedStyleSheets = [settingCheckboxStyles];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
set data(data: SettingCheckboxData) {
|
|
36
|
-
if (this
|
|
37
|
-
this
|
|
36
|
+
if (this.#changeListenerDescriptor && this.#setting) {
|
|
37
|
+
this.#setting.removeChangeListener(this.#changeListenerDescriptor.listener);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
this
|
|
41
|
-
this
|
|
40
|
+
this.#setting = data.setting;
|
|
41
|
+
this.#disabled = Boolean(data.disabled);
|
|
42
42
|
|
|
43
|
-
this
|
|
43
|
+
this.#changeListenerDescriptor = this.#setting.addChangeListener(() => {
|
|
44
44
|
this.render();
|
|
45
45
|
});
|
|
46
46
|
this.render();
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
private render(): void {
|
|
50
|
-
if (!this
|
|
50
|
+
if (!this.#setting) {
|
|
51
51
|
throw new Error('No "Setting" object provided for rendering');
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -55,15 +55,15 @@ export class SettingCheckbox extends HTMLElement {
|
|
|
55
55
|
LitHtml.html`
|
|
56
56
|
<p>
|
|
57
57
|
<label>
|
|
58
|
-
<input type="checkbox" ?checked=${this
|
|
59
|
-
this.checkboxChanged}" aria-label="${this
|
|
58
|
+
<input type="checkbox" ?checked=${this.#setting.get()} ?disabled=${this.#disabled} @change="${
|
|
59
|
+
this.checkboxChanged}" aria-label="${this.#setting.title()}" /> ${this.#setting.title()}
|
|
60
60
|
</label>
|
|
61
61
|
</p>`,
|
|
62
|
-
this
|
|
62
|
+
this.#shadow, {host: this});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
private checkboxChanged(e: Event): void {
|
|
66
|
-
this
|
|
66
|
+
this.#setting?.set((e.target as HTMLInputElement).checked);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -51,74 +51,74 @@ const enum State {
|
|
|
51
51
|
export class SurveyLink extends HTMLElement {
|
|
52
52
|
static readonly litTagName = LitHtml.literal`devtools-survey-link`;
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
readonly #shadow = this.attachShadow({mode: 'open'});
|
|
55
|
+
#trigger = '';
|
|
56
|
+
#promptText = Common.UIString.LocalizedEmptyString;
|
|
57
|
+
#canShowSurvey: (trigger: string, callback: CanShowSurveyCallback) => void = () => {};
|
|
58
|
+
#showSurvey: (trigger: string, callback: ShowSurveyCallback) => void = () => {};
|
|
59
|
+
#state: State = State.Checking;
|
|
60
60
|
|
|
61
61
|
connectedCallback(): void {
|
|
62
|
-
this
|
|
62
|
+
this.#shadow.adoptedStyleSheets = [surveyLinkStyles];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// Re-setting data will cause the state to go back to 'Checking' which hides the link.
|
|
66
66
|
set data(data: SurveyLinkData) {
|
|
67
|
-
this
|
|
68
|
-
this
|
|
69
|
-
this
|
|
70
|
-
this
|
|
67
|
+
this.#trigger = data.trigger;
|
|
68
|
+
this.#promptText = data.promptText;
|
|
69
|
+
this.#canShowSurvey = data.canShowSurvey;
|
|
70
|
+
this.#showSurvey = data.showSurvey;
|
|
71
71
|
|
|
72
72
|
this.checkSurvey();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
private checkSurvey(): void {
|
|
76
|
-
this
|
|
77
|
-
this
|
|
76
|
+
this.#state = State.Checking;
|
|
77
|
+
this.#canShowSurvey(this.#trigger, ({canShowSurvey}) => {
|
|
78
78
|
if (!canShowSurvey) {
|
|
79
|
-
this
|
|
79
|
+
this.#state = State.DontShowLink;
|
|
80
80
|
} else {
|
|
81
|
-
this
|
|
81
|
+
this.#state = State.ShowLink;
|
|
82
82
|
}
|
|
83
83
|
this.render();
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
private sendSurvey(): void {
|
|
88
|
-
this
|
|
88
|
+
this.#state = State.Sending;
|
|
89
89
|
this.render();
|
|
90
|
-
this
|
|
90
|
+
this.#showSurvey(this.#trigger, ({surveyShown}) => {
|
|
91
91
|
if (!surveyShown) {
|
|
92
|
-
this
|
|
92
|
+
this.#state = State.Failed;
|
|
93
93
|
} else {
|
|
94
|
-
this
|
|
94
|
+
this.#state = State.SurveyShown;
|
|
95
95
|
}
|
|
96
96
|
this.render();
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
private render(): void {
|
|
101
|
-
if (this
|
|
101
|
+
if (this.#state === State.Checking || this.#state === State.DontShowLink) {
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
let linkText = this
|
|
106
|
-
if (this
|
|
105
|
+
let linkText = this.#promptText;
|
|
106
|
+
if (this.#state === State.Sending) {
|
|
107
107
|
linkText = i18nString(UIStrings.openingSurvey);
|
|
108
|
-
} else if (this
|
|
108
|
+
} else if (this.#state === State.SurveyShown) {
|
|
109
109
|
linkText = i18nString(UIStrings.thankYouForYourFeedback);
|
|
110
|
-
} else if (this
|
|
110
|
+
} else if (this.#state === State.Failed) {
|
|
111
111
|
linkText = i18nString(UIStrings.anErrorOccurredWithTheSurvey);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
let linkState = '';
|
|
115
|
-
if (this
|
|
115
|
+
if (this.#state === State.Sending) {
|
|
116
116
|
linkState = 'pending-link';
|
|
117
|
-
} else if (this
|
|
117
|
+
} else if (this.#state === State.Failed || this.#state === State.SurveyShown) {
|
|
118
118
|
linkState = 'disabled-link';
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
const ariaDisabled = this
|
|
121
|
+
const ariaDisabled = this.#state !== State.ShowLink;
|
|
122
122
|
|
|
123
123
|
// clang-format off
|
|
124
124
|
// eslint-disable-next-line rulesdir/ban_style_tags_in_lit_html
|
|
@@ -129,7 +129,7 @@ export class SurveyLink extends HTMLElement {
|
|
|
129
129
|
</button>
|
|
130
130
|
`;
|
|
131
131
|
// clang-format on
|
|
132
|
-
LitHtml.render(output, this
|
|
132
|
+
LitHtml.render(output, this.#shadow, {host: this});
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -21,19 +21,19 @@ declare global {
|
|
|
21
21
|
export class TextEditor extends HTMLElement {
|
|
22
22
|
static readonly litTagName = LitHtml.literal`devtools-text-editor`;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (this
|
|
33
|
-
this
|
|
34
|
-
this
|
|
35
|
-
if (this
|
|
36
|
-
CodeMirror.repositionTooltips(this
|
|
24
|
+
readonly #shadow = this.attachShadow({mode: 'open'});
|
|
25
|
+
#activeEditor: CodeMirror.EditorView|undefined = undefined;
|
|
26
|
+
#dynamicSettings: readonly DynamicSetting<unknown>[] = DynamicSetting.none;
|
|
27
|
+
#activeSettingListeners: [Common.Settings.Setting<unknown>, (event: {data: unknown}) => void][] = [];
|
|
28
|
+
#pendingState: CodeMirror.EditorState|undefined;
|
|
29
|
+
#lastScrollPos = {left: 0, top: 0};
|
|
30
|
+
#resizeTimeout = -1;
|
|
31
|
+
#devtoolsResizeObserver = new ResizeObserver(() => {
|
|
32
|
+
if (this.#resizeTimeout < 0) {
|
|
33
|
+
this.#resizeTimeout = window.setTimeout(() => {
|
|
34
|
+
this.#resizeTimeout = -1;
|
|
35
|
+
if (this.#activeEditor) {
|
|
36
|
+
CodeMirror.repositionTooltips(this.#activeEditor);
|
|
37
37
|
}
|
|
38
38
|
}, 50);
|
|
39
39
|
}
|
|
@@ -41,15 +41,15 @@ export class TextEditor extends HTMLElement {
|
|
|
41
41
|
|
|
42
42
|
constructor(pendingState?: CodeMirror.EditorState) {
|
|
43
43
|
super();
|
|
44
|
-
this
|
|
45
|
-
this
|
|
44
|
+
this.#pendingState = pendingState;
|
|
45
|
+
this.#shadow.adoptedStyleSheets = [CodeHighlighter.Style.default];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
private createEditor(): CodeMirror.EditorView {
|
|
49
|
-
this
|
|
49
|
+
this.#activeEditor = new CodeMirror.EditorView({
|
|
50
50
|
state: this.state,
|
|
51
|
-
parent: this
|
|
52
|
-
root: this
|
|
51
|
+
parent: this.#shadow,
|
|
52
|
+
root: this.#shadow,
|
|
53
53
|
dispatch: (tr: CodeMirror.Transaction): void => {
|
|
54
54
|
this.editor.update([tr]);
|
|
55
55
|
if (tr.reconfigured) {
|
|
@@ -57,19 +57,19 @@ export class TextEditor extends HTMLElement {
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
});
|
|
60
|
-
this
|
|
61
|
-
this
|
|
62
|
-
this
|
|
63
|
-
this
|
|
64
|
-
this
|
|
60
|
+
this.#activeEditor.scrollDOM.scrollTop = this.#lastScrollPos.top;
|
|
61
|
+
this.#activeEditor.scrollDOM.scrollLeft = this.#lastScrollPos.left;
|
|
62
|
+
this.#activeEditor.scrollDOM.addEventListener('scroll', (event): void => {
|
|
63
|
+
this.#lastScrollPos.left = (event.target as HTMLElement).scrollLeft;
|
|
64
|
+
this.#lastScrollPos.top = (event.target as HTMLElement).scrollTop;
|
|
65
65
|
});
|
|
66
66
|
this.ensureSettingListeners();
|
|
67
67
|
this.startObservingResize();
|
|
68
|
-
return this
|
|
68
|
+
return this.#activeEditor;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
get editor(): CodeMirror.EditorView {
|
|
72
|
-
return this
|
|
72
|
+
return this.#activeEditor || this.createEditor();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
dispatch(spec: CodeMirror.TransactionSpec): void {
|
|
@@ -77,68 +77,68 @@ export class TextEditor extends HTMLElement {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
get state(): CodeMirror.EditorState {
|
|
80
|
-
if (this
|
|
81
|
-
return this
|
|
80
|
+
if (this.#activeEditor) {
|
|
81
|
+
return this.#activeEditor.state;
|
|
82
82
|
}
|
|
83
|
-
if (!this
|
|
84
|
-
this
|
|
83
|
+
if (!this.#pendingState) {
|
|
84
|
+
this.#pendingState = CodeMirror.EditorState.create({extensions: baseConfiguration('')});
|
|
85
85
|
}
|
|
86
|
-
return this
|
|
86
|
+
return this.#pendingState;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
set state(state: CodeMirror.EditorState) {
|
|
90
|
-
if (this
|
|
91
|
-
this
|
|
90
|
+
if (this.#activeEditor) {
|
|
91
|
+
this.#activeEditor.setState(state);
|
|
92
92
|
} else {
|
|
93
|
-
this
|
|
93
|
+
this.#pendingState = state;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
connectedCallback(): void {
|
|
98
|
-
if (!this
|
|
98
|
+
if (!this.#activeEditor) {
|
|
99
99
|
this.createEditor();
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
disconnectedCallback(): void {
|
|
104
|
-
if (this
|
|
105
|
-
this
|
|
106
|
-
this
|
|
107
|
-
this
|
|
108
|
-
this
|
|
104
|
+
if (this.#activeEditor) {
|
|
105
|
+
this.#pendingState = this.#activeEditor.state;
|
|
106
|
+
this.#devtoolsResizeObserver.disconnect();
|
|
107
|
+
this.#activeEditor.destroy();
|
|
108
|
+
this.#activeEditor = undefined;
|
|
109
109
|
this.ensureSettingListeners();
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
focus(): void {
|
|
114
|
-
if (this
|
|
115
|
-
this
|
|
114
|
+
if (this.#activeEditor) {
|
|
115
|
+
this.#activeEditor.focus();
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
private ensureSettingListeners(): void {
|
|
120
|
-
const dynamicSettings = this
|
|
121
|
-
if (dynamicSettings === this
|
|
120
|
+
const dynamicSettings = this.#activeEditor ? this.#activeEditor.state.facet(dynamicSetting) : DynamicSetting.none;
|
|
121
|
+
if (dynamicSettings === this.#dynamicSettings) {
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
|
-
this
|
|
124
|
+
this.#dynamicSettings = dynamicSettings;
|
|
125
125
|
|
|
126
|
-
for (const [setting, listener] of this
|
|
126
|
+
for (const [setting, listener] of this.#activeSettingListeners) {
|
|
127
127
|
setting.removeChangeListener(listener);
|
|
128
128
|
}
|
|
129
|
-
this
|
|
129
|
+
this.#activeSettingListeners = [];
|
|
130
130
|
|
|
131
131
|
const settings = Common.Settings.Settings.instance();
|
|
132
132
|
for (const dynamicSetting of dynamicSettings) {
|
|
133
133
|
const handler = ({data}: {data: unknown}): void => {
|
|
134
134
|
const change = dynamicSetting.sync(this.state, data);
|
|
135
|
-
if (change && this
|
|
136
|
-
this
|
|
135
|
+
if (change && this.#activeEditor) {
|
|
136
|
+
this.#activeEditor.dispatch({effects: change});
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
const setting = settings.moduleSetting(dynamicSetting.settingName);
|
|
140
140
|
setting.addChangeListener(handler);
|
|
141
|
-
this
|
|
141
|
+
this.#activeSettingListeners.push([setting, handler]);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -146,12 +146,12 @@ export class TextEditor extends HTMLElement {
|
|
|
146
146
|
const devtoolsElement =
|
|
147
147
|
WindowBoundsService.WindowBoundsService.WindowBoundsServiceImpl.instance().getDevToolsBoundingElement();
|
|
148
148
|
if (devtoolsElement) {
|
|
149
|
-
this
|
|
149
|
+
this.#devtoolsResizeObserver.observe(devtoolsElement);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
revealPosition(selection: CodeMirror.EditorSelection, highlight: boolean = true): void {
|
|
154
|
-
const view = this
|
|
154
|
+
const view = this.#activeEditor;
|
|
155
155
|
if (!view) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
@@ -217,10 +217,10 @@ let cacheInstance: PropertyCache|null = null;
|
|
|
217
217
|
// Store recent collections of property completions. The empty string
|
|
218
218
|
// is used to store the set of global bindings.
|
|
219
219
|
class PropertyCache {
|
|
220
|
-
|
|
220
|
+
readonly #cache: Map<string, Promise<CompletionSet>> = new Map();
|
|
221
221
|
|
|
222
222
|
constructor() {
|
|
223
|
-
const clear = (): void => this
|
|
223
|
+
const clear = (): void => this.#cache.clear();
|
|
224
224
|
SDK.ConsoleModel.ConsoleModel.instance().addEventListener(SDK.ConsoleModel.Events.CommandEvaluated, clear);
|
|
225
225
|
UI.Context.Context.instance().addFlavorChangeListener(SDK.RuntimeModel.ExecutionContext, clear);
|
|
226
226
|
SDK.TargetManager.TargetManager.instance().addModelListener(
|
|
@@ -230,14 +230,14 @@ class PropertyCache {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
get(expression: string): Promise<CompletionSet>|undefined {
|
|
233
|
-
return this
|
|
233
|
+
return this.#cache.get(expression);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
set(expression: string, value: Promise<CompletionSet>): void {
|
|
237
|
-
this
|
|
237
|
+
this.#cache.set(expression, value);
|
|
238
238
|
setTimeout(() => {
|
|
239
|
-
if (this
|
|
240
|
-
this
|
|
239
|
+
if (this.#cache.get(expression) === value) {
|
|
240
|
+
this.#cache.delete(expression);
|
|
241
241
|
}
|
|
242
242
|
}, maxCacheAge);
|
|
243
243
|
}
|