Skip to content

Commit ef367ad

Browse files
committed
feat: convert flow to typescript
``` flow-to-ts --prettier --write --delete-source .\lib\**\*.js ```
1 parent 5c47c3c commit ef367ad

17 files changed

+499
-347
lines changed

lib/adapters/legacy-adapter.js renamed to lib/adapters/legacy-adapter.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use strict"
2-
32
/**
43
* @access private
54
*/
5+
66
export default class LegacyAdapter {
77
constructor(textEditor) {
88
this.textEditor = textEditor
@@ -33,8 +33,10 @@ export default class LegacyAdapter {
3333
if (!this.heightCache) {
3434
this.heightCache = this.textEditor.getHeight()
3535
}
36+
3637
return this.heightCache
3738
}
39+
3840
return this.textEditor.getHeight()
3941
}
4042

@@ -43,8 +45,10 @@ export default class LegacyAdapter {
4345
if (!this.scrollTopCache) {
4446
this.scrollTopCache = this.textEditor.getScrollTop()
4547
}
48+
4649
return this.scrollTopCache
4750
}
51+
4852
return this.textEditor.getScrollTop()
4953
}
5054

@@ -57,6 +61,7 @@ export default class LegacyAdapter {
5761
if (!this.scrollLeftCache) {
5862
this.scrollLeftCache = this.textEditor.getScrollLeft()
5963
}
64+
6065
return this.scrollLeftCache
6166
}
6267

@@ -67,19 +72,22 @@ export default class LegacyAdapter {
6772
if (this.maxScrollTopCache != null && this.useCache) {
6873
return this.maxScrollTopCache
6974
}
75+
7076
let maxScrollTop = this.textEditor.displayBuffer.getMaxScrollTop()
7177
const lineHeight = this.textEditor.getLineHeightInPixels()
7278

7379
if (this.scrollPastEnd) {
7480
maxScrollTop -= this.getHeight() - 3 * lineHeight
7581
}
82+
7683
if (this.useCache) {
7784
this.maxScrollTopCache = maxScrollTop
7885
}
86+
7987
return maxScrollTop
8088
}
8189

8290
editorDestroyed() {
8391
return !this.textEditor || this.textEditor.isDestroyed()
8492
}
85-
}
93+
}

lib/adapters/stable-adapter.js renamed to lib/adapters/stable-adapter.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use strict"
2-
32
/**
43
* @access private
54
*/
5+
66
export default class StableAdapter {
77
constructor(textEditor) {
88
this.textEditor = textEditor
@@ -38,8 +38,10 @@ export default class StableAdapter {
3838
if (!this.heightCache) {
3939
this.heightCache = this.textEditorElement.getHeight()
4040
}
41+
4142
return this.heightCache
4243
}
44+
4345
return this.textEditorElement.getHeight()
4446
}
4547

@@ -52,8 +54,10 @@ export default class StableAdapter {
5254
if (!this.scrollTopCache) {
5355
this.scrollTopCache = this.computeScrollTop()
5456
}
57+
5558
return this.scrollTopCache
5659
}
60+
5761
return this.computeScrollTop()
5862
}
5963

@@ -100,8 +104,10 @@ export default class StableAdapter {
100104
if (!this.scrollLeftCache) {
101105
this.scrollLeftCache = this.textEditorElement.getScrollLeft()
102106
}
107+
103108
return this.scrollLeftCache
104109
}
110+
105111
return this.textEditorElement.getScrollLeft()
106112
}
107113

@@ -115,6 +121,7 @@ export default class StableAdapter {
115121
}
116122

117123
let maxScrollTop
124+
118125
if (this.textEditorElement.getMaxScrollTop) {
119126
maxScrollTop = this.textEditorElement.getMaxScrollTop()
120127

@@ -149,4 +156,4 @@ export default class StableAdapter {
149156
!this.textEditorElement.parentNode
150157
)
151158
}
152-
}
159+
}

lib/canvas-layer.js renamed to lib/canvas-layer.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
/** @babel */
22
"use strict"
3-
43
/**
54
* @access private
65
*/
6+
77
export default class CanvasLayer {
88
constructor() {
99
/**
1010
* The onscreen canvas.
1111
* @type {HTMLCanvasElement}
1212
*/
1313
this.canvas = document.createElement("canvas")
14-
1514
const desynchronized = false // TODO Electron 9 has color issues #786
1615

1716
/**
1817
* The onscreen canvas context.
1918
* @type {CanvasRenderingContext2D}
2019
*/
21-
this.context = this.canvas.getContext("2d", { desynchronized })
20+
this.context = this.canvas.getContext("2d", {
21+
desynchronized,
22+
})
2223
this.canvas.webkitImageSmoothingEnabled = false
2324
this.context.imageSmoothingEnabled = false
2425

@@ -28,12 +29,15 @@ export default class CanvasLayer {
2829
* @access private
2930
*/
3031
this.offscreenCanvas = document.createElement("canvas")
32+
3133
/**
3234
* The offscreen canvas context.
3335
* @type {CanvasRenderingContext2D}
3436
* @access private
3537
*/
36-
this.offscreenContext = this.offscreenCanvas.getContext("2d", { desynchronized })
38+
this.offscreenContext = this.offscreenCanvas.getContext("2d", {
39+
desynchronized,
40+
})
3741
this.offscreenCanvas.webkitImageSmoothingEnabled = false
3842
this.offscreenContext.imageSmoothingEnabled = false
3943
}
@@ -97,4 +101,4 @@ export default class CanvasLayer {
97101
clearCanvas() {
98102
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height)
99103
}
100-
}
104+
}

0 commit comments

Comments
 (0)