Skip to content

Commit cc928f8

Browse files
committed
style: format TypeScript files with Oxfmt
1 parent b418035 commit cc928f8

173 files changed

Lines changed: 25541 additions & 9357 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎html/help/script.ts‎

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,27 @@ window.onmousedown = (ev) => {
88
vscode.postMessage({
99
message: 'mouseClick',
1010
button: Number(ev.button),
11-
scrollY: window.scrollY
11+
scrollY: window.scrollY,
1212
});
1313
};
1414

15-
1615
// handle requests from vscode ui
1716
window.addEventListener('message', (ev: MessageEvent) => {
1817
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1918
const message = ev.data;
2019
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
21-
if(message.command === 'getScrollY'){
20+
if (message.command === 'getScrollY') {
2221
vscode.postMessage({
2322
message: 'getScrollY',
24-
scrollY: window.scrollY
23+
scrollY: window.scrollY,
2524
});
2625
}
2726
});
2827

29-
3028
// do everything after loading the body
3129
window.document.body.onload = () => {
32-
3330
// make relative path for hyperlinks
34-
const relPath = (document.body.getAttribute('relPath') || '');
31+
const relPath = document.body.getAttribute('relPath') || '';
3532

3633
// notify vscode, used to restore help panels between sessions
3734
vscode.setState(relPath);
@@ -42,42 +39,41 @@ window.document.body.onload = () => {
4239

4340
// scroll to desired position:
4441
const scrollYTo = Number(document.body.getAttribute('scrollYTo') ?? -1);
45-
if(scrollYTo >= 0){
46-
window.scrollTo(0,scrollYTo);
47-
} else if(url1.hash){
42+
if (scrollYTo >= 0) {
43+
window.scrollTo(0, scrollYTo);
44+
} else if (url1.hash) {
4845
document.location.hash = url1.hash;
4946
}
5047

5148
// notify vscode when links are clicked:
5249
const hyperLinks = document.getElementsByTagName('a');
5350

54-
for(let i=0; i<hyperLinks.length; i++){
51+
for (let i = 0; i < hyperLinks.length; i++) {
5552
const hrefAbs = hyperLinks[i].href;
5653
const hrefRel = hyperLinks[i].getAttribute('href') || '';
5754

58-
if(hrefRel.startsWith('#')){
55+
if (hrefRel.startsWith('#')) {
5956
hyperLinks[i].onclick = () => {
6057
document.location.hash = hrefRel;
6158
};
62-
} else if(hrefAbs && hrefAbs.startsWith('vscode-webview://')){
59+
} else if (hrefAbs && hrefAbs.startsWith('vscode-webview://')) {
6360
hyperLinks[i].onclick = () => {
64-
6561
const url2 = new URL(hrefRel, url1);
6662
const finalHref = url2.toString();
6763

6864
vscode.postMessage({
6965
message: 'linkClicked',
7066
href: finalHref,
71-
scrollY: window.scrollY
67+
scrollY: window.scrollY,
7268
});
7369
};
7470
}
7571
}
7672

7773
// notify vscode when code is clicked:
78-
if(document.body.classList.contains('preClickable')){
74+
if (document.body.classList.contains('preClickable')) {
7975
const codeElements = document.getElementsByTagName('pre');
80-
for(let i=0; i<codeElements.length; i++){
76+
for (let i = 0; i < codeElements.length; i++) {
8177
const el = codeElements[i];
8278
el.onclick = (me: MouseEvent) => {
8379
vscode.postMessage({
@@ -88,10 +84,9 @@ window.document.body.onload = () => {
8884
ctrlKey: me.ctrlKey,
8985
shiftKey: me.shiftKey,
9086
metaKey: me.metaKey,
91-
}
87+
},
9288
});
9389
};
9490
}
9591
}
9692
};
97-

‎html/help/webviewMessages.d.ts‎

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,41 @@ interface VsCode {
55
setState: (state: string) => void;
66
}
77

8-
98
interface IOutMessage {
109
message: string;
1110
}
1211
interface LogMessage extends IOutMessage {
13-
message: 'log',
14-
body: any
12+
message: 'log';
13+
body: any;
1514
}
1615
interface MouseClickMessage extends IOutMessage {
17-
message: 'mouseClick',
18-
button: number,
19-
scrollY: number
16+
message: 'mouseClick';
17+
button: number;
18+
scrollY: number;
2019
}
2120
interface LinkClickedMessage extends IOutMessage {
22-
message: 'linkClicked',
23-
href: string,
24-
scrollY: number
21+
message: 'linkClicked';
22+
href: string;
23+
scrollY: number;
2524
}
2625
interface CodeClickedMessage extends IOutMessage {
27-
message: 'codeClicked',
28-
code: string,
26+
message: 'codeClicked';
27+
code: string;
2928
modifiers: {
30-
altKey: boolean,
31-
ctrlKey: boolean,
32-
shiftKey: boolean,
33-
metaKey: boolean,
34-
}
29+
altKey: boolean;
30+
ctrlKey: boolean;
31+
shiftKey: boolean;
32+
metaKey: boolean;
33+
};
3534
}
3635
interface GetScrollYMessage extends IOutMessage {
37-
message: 'getScrollY',
38-
scrollY: number
36+
message: 'getScrollY';
37+
scrollY: number;
3938
}
4039

41-
type OutMessage = LogMessage | MouseClickMessage | LinkClickedMessage | CodeClickedMessage | GetScrollYMessage;
42-
40+
type OutMessage =
41+
| LogMessage
42+
| MouseClickMessage
43+
| LinkClickedMessage
44+
| CodeClickedMessage
45+
| GetScrollYMessage;

‎html/httpgd/index.ts‎

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
/* eslint-disable @typescript-eslint/no-unsafe-call */
55
/* eslint-disable @typescript-eslint/no-explicit-any */
66

7-
87
interface Plot {
98
// unique ID for this plot (w.r.t. this connection/device)
109
id: string;
@@ -24,94 +23,90 @@ const vscode = acquireVsCodeApi();
2423
let oldHeight = -1;
2524
let oldWidth = -1;
2625

27-
2826
const handler = document.querySelector('#handler') as HTMLDivElement;
2927
const largePlotDiv = document.querySelector('#largePlot') as HTMLDivElement;
3028
const largeSvg = largePlotDiv.querySelector('svg') as SVGElement;
3129
const cssLink = document.querySelector('link.overwrites') as HTMLLinkElement;
3230
const smallPlotDiv = document.querySelector('#smallPlots') as HTMLDivElement;
3331

34-
3532
function getSmallPlots(): HTMLAnchorElement[] {
3633
const smallPlots: HTMLAnchorElement[] = [];
37-
document.querySelectorAll('a.focusPlot').forEach(elm => {
34+
document.querySelectorAll('a.focusPlot').forEach((elm) => {
3835
smallPlots.push(elm as HTMLAnchorElement);
3936
});
4037
return smallPlots;
4138
}
4239

4340
let isHandlerDragging = false;
4441

45-
4642
let isFullWindow = false;
4743

48-
function postResizeMessage(userTriggered: boolean = false){
44+
function postResizeMessage(userTriggered: boolean = false) {
4945
let newHeight = largePlotDiv.clientHeight;
5046
let newWidth = largePlotDiv.clientWidth;
51-
if(isFullWindow){
47+
if (isFullWindow) {
5248
newHeight = window.innerHeight;
5349
newWidth = window.innerWidth;
5450
}
55-
if(userTriggered || newHeight !== oldHeight || newWidth !== oldWidth){
51+
if (userTriggered || newHeight !== oldHeight || newWidth !== oldWidth) {
5652
const msg: ResizeMessage = {
5753
message: 'resize',
5854
height: newHeight,
5955
width: newWidth,
60-
userTriggered: userTriggered
56+
userTriggered: userTriggered,
6157
};
6258
vscode.postMessage(msg);
6359
oldHeight = newHeight;
6460
oldWidth = newWidth;
6561
}
6662
}
6763

68-
function postLogMessage(content: any){
64+
function postLogMessage(content: any) {
6965
console.log(content);
7066
vscode.postMessage({
7167
message: 'log',
72-
body: content
68+
body: content,
7369
});
7470
}
7571

7672
window.addEventListener('message', (ev: MessageEvent<InMessage>) => {
7773
const msg = ev.data;
78-
if(msg.message === 'updatePlot'){
74+
if (msg.message === 'updatePlot') {
7975
updatePlot({
8076
id: String(msg.plotId),
81-
svg: msg.svg
77+
svg: msg.svg,
8278
});
83-
} else if(msg.message === 'focusPlot'){
79+
} else if (msg.message === 'focusPlot') {
8480
focusPlot(String(msg.plotId));
85-
} else if(msg.message === 'toggleStyle'){
81+
} else if (msg.message === 'toggleStyle') {
8682
toggleStyle(msg.useOverwrites);
87-
} else if(msg.message === 'hidePlot'){
83+
} else if (msg.message === 'hidePlot') {
8884
hidePlot(msg.plotId);
89-
} else if(msg.message === 'addPlot'){
85+
} else if (msg.message === 'addPlot') {
9086
addPlot(msg.html);
91-
} else if(msg.message === 'togglePreviewPlotLayout'){
87+
} else if (msg.message === 'togglePreviewPlotLayout') {
9288
togglePreviewPlotLayout(msg.style);
93-
} else if(msg.message === 'toggleFullWindow'){
89+
} else if (msg.message === 'toggleFullWindow') {
9490
toggleFullWindowMode(msg.useFullWindow);
9591
}
9692
});
9793

98-
function addPlot(html: string){
94+
function addPlot(html: string) {
9995
const wrapper = document.createElement('div');
10096
wrapper.classList.add('wrapper');
10197
wrapper.innerHTML = html;
10298
smallPlotDiv.appendChild(wrapper);
10399
}
104100

105101
function focusPlot(plotId: string): void {
106-
107102
const smallPlots = getSmallPlots();
108103

109104
const ind = findIndex(plotId, smallPlots);
110-
if(ind < 0){
105+
if (ind < 0) {
111106
return;
112107
}
113108

114-
for(const elm of smallPlots){
109+
for (const elm of smallPlots) {
115110
elm.classList.remove('active');
116111
}
117112

@@ -123,17 +118,16 @@ function focusPlot(plotId: string): void {
123118
}
124119

125120
function updatePlot(plt: Plot): void {
126-
127121
const smallPlots = getSmallPlots();
128122

129123
const ind = findIndex(plt.id, smallPlots);
130-
if(ind<0){
124+
if (ind < 0) {
131125
return;
132126
}
133127

134128
smallPlots[ind].innerHTML = plt.svg;
135129

136-
if(smallPlots[ind].classList.contains('active')){
130+
if (smallPlots[ind].classList.contains('active')) {
137131
largePlotDiv.innerHTML = plt.svg;
138132
}
139133
}
@@ -142,11 +136,11 @@ function hidePlot(plotId: string): void {
142136
const smallPlots = getSmallPlots();
143137

144138
const ind = findIndex(plotId, smallPlots);
145-
if(ind<0){
139+
if (ind < 0) {
146140
return;
147141
}
148142

149-
if(smallPlots[ind].classList.contains('active')){
143+
if (smallPlots[ind].classList.contains('active')) {
150144
largePlotDiv.innerHTML = '';
151145
}
152146

@@ -155,8 +149,8 @@ function hidePlot(plotId: string): void {
155149

156150
function findIndex(plotId: string, smallPlots?: Element[]): number {
157151
smallPlots ||= getSmallPlots();
158-
const ind = smallPlots.findIndex(elm => elm.getAttribute('plotId') === String(plotId));
159-
if(ind<0){
152+
const ind = smallPlots.findIndex((elm) => elm.getAttribute('plotId') === String(plotId));
153+
if (ind < 0) {
160154
console.warn(`plotId not found: ${plotId}`);
161155
}
162156
return ind;
@@ -173,7 +167,7 @@ function togglePreviewPlotLayout(newStyle: PreviewPlotLayout): void {
173167

174168
function toggleFullWindowMode(useFullWindow: boolean): void {
175169
isFullWindow = useFullWindow;
176-
if(useFullWindow){
170+
if (useFullWindow) {
177171
document.body.classList.add('fullWindow');
178172
window.scrollTo(0, 0);
179173
} else {
@@ -191,12 +185,10 @@ window.onload = () => {
191185
postResizeMessage(true);
192186
};
193187

194-
195188
////
196189
// Resize bar
197190
////
198191

199-
200192
document.addEventListener('mousedown', (e) => {
201193
// If mousedown event is fired from .handler, toggle flag to true
202194
if (!isFullWindow && e.target === handler) {
@@ -227,7 +219,7 @@ document.addEventListener('mousemove', (e) => {
227219
const newHeight = Math.max(largePlotMinHeight, pointerRelativeYpos - 5); // <- why 5?
228220
const newHeightString = `${newHeight}px`;
229221

230-
if(largePlotDiv.style.height !== newHeightString){
222+
if (largePlotDiv.style.height !== newHeightString) {
231223
largePlotDiv.style.height = newHeightString;
232224
postResizeMessage();
233225
}
@@ -237,11 +229,10 @@ window.onresize = () => postResizeMessage();
237229

238230
document.addEventListener('mouseup', () => {
239231
// Turn off dragging flag when user mouse is up
240-
if(isHandlerDragging){
232+
if (isHandlerDragging) {
241233
postResizeMessage(true);
242234
document.body.style.cursor = '';
243235
}
244236
handler.classList.remove('dragging');
245237
isHandlerDragging = false;
246238
});
247-

0 commit comments

Comments
 (0)