Skip to content

Commit 1ec1790

Browse files
committed
feat: convert jscode to flow
``` jsdoc2flow -i lib --overwrite ```
1 parent f40b150 commit 1ec1790

File tree

8 files changed

+164
-164
lines changed

8 files changed

+164
-164
lines changed

lib/decoration-management.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default class DecorationManagement {
8080
*
8181
* @return {Array<Decoration>} all the decorations in this `Minimap`
8282
*/
83-
getDecorations() {
83+
getDecorations(): Array<Decoration> {
8484
return [...this.decorationsById.values()]
8585
}
8686

@@ -96,7 +96,7 @@ export default class DecorationManagement {
9696
* - decoration: the decoration object that was created
9797
* @return {Disposable} a disposable to stop listening to the event
9898
*/
99-
onDidAddDecoration(callback) {
99+
onDidAddDecoration(callback: (event:Object) => void): Disposable {
100100
return this.emitter.on("did-add-decoration", callback)
101101
}
102102

@@ -112,7 +112,7 @@ export default class DecorationManagement {
112112
* - decoration: the decoration object that was created
113113
* @return {Disposable} a disposable to stop listening to the event
114114
*/
115-
onDidRemoveDecoration(callback) {
115+
onDidRemoveDecoration(callback: (event:Object) => void): Disposable {
116116
return this.emitter.on("did-remove-decoration", callback)
117117
}
118118

@@ -131,7 +131,7 @@ export default class DecorationManagement {
131131
* - decoration: the decoration object that was created
132132
* @return {Disposable} a disposable to stop listening to the event
133133
*/
134-
onDidChangeDecoration(callback) {
134+
onDidChangeDecoration(callback: (event:Object) => void): Disposable {
135135
return this.emitter.on("did-change-decoration", callback)
136136
}
137137

@@ -150,7 +150,7 @@ export default class DecorationManagement {
150150
* - decoration: the decoration object that was created
151151
* @return {Disposable} a disposable to stop listening to the event
152152
*/
153-
onDidChangeDecorationRange(callback) {
153+
onDidChangeDecorationRange(callback: (event:Object) => void): Disposable {
154154
return this.emitter.on("did-change-decoration-range", callback)
155155
}
156156

@@ -164,7 +164,7 @@ export default class DecorationManagement {
164164
* triggered
165165
* @return {Disposable} a disposable to stop listening to the event
166166
*/
167-
onDidUpdateDecoration(callback) {
167+
onDidUpdateDecoration(callback: (decoration: Decoration) => void): Disposable {
168168
return this.emitter.on("did-update-decoration", callback)
169169
}
170170

@@ -174,7 +174,7 @@ export default class DecorationManagement {
174174
* @param {number} id the decoration id
175175
* @return {Decoration} the decoration with the given id
176176
*/
177-
decorationForId(id) {
177+
decorationForId(id: number): Decoration {
178178
return this.decorationsById.get(id)
179179
}
180180

@@ -186,7 +186,7 @@ export default class DecorationManagement {
186186
* @return {Record<string, Decoration>} the decorations that intersect the passed-in
187187
* range
188188
*/
189-
decorationsForScreenRowRange(startScreenRow, endScreenRow) {
189+
decorationsForScreenRowRange(startScreenRow: number, endScreenRow: number): Record<string, Decoration> {
190190
const decorationsByMarkerId = {}
191191
const markers = this.findMarkers({
192192
intersectsScreenRowRange: [startScreenRow, endScreenRow],
@@ -231,7 +231,7 @@ export default class DecorationManagement {
231231
* highlight-outine decorations at a given
232232
* row
233233
*/
234-
decorationsByTypeThenRows() {
234+
decorationsByTypeThenRows(): {} {
235235
if (this.decorationsByTypeThenRowsCache != null) {
236236
return this.decorationsByTypeThenRowsCache
237237
}
@@ -328,7 +328,7 @@ export default class DecorationManagement {
328328
* @emits {did-add-decoration} when the decoration is created successfully
329329
* @emits {did-change} when the decoration is created successfully
330330
*/
331-
decorateMarker(marker, decorationParams) {
331+
decorateMarker(marker: Marker, decorationParams: { type: string }) {
332332
if (this.destroyed || this.minimap.destroyed || marker == null) {
333333
return
334334
}
@@ -452,7 +452,7 @@ export default class DecorationManagement {
452452
* @param {Decoration} decoration the decoration for which emitting an event
453453
* @access private
454454
*/
455-
emitDecorationChanges(type, decoration) {
455+
emitDecorationChanges(type: string, decoration: Decoration) {
456456
if (this.destroyed || this.minimap.editorDestroyed()) {
457457
return
458458
}
@@ -476,7 +476,7 @@ export default class DecorationManagement {
476476
* change object
477477
* @access private
478478
*/
479-
emitRangeChanges(type, range, screenDelta) {
479+
emitRangeChanges(type: string, range: { }, screenDelta) {
480480
const startScreenRow = range.start.row
481481
const endScreenRow = range.end.row
482482
const lastRenderedScreenRow = this.minimap.getLastVisibleScreenRow()
@@ -503,7 +503,7 @@ export default class DecorationManagement {
503503
* @emits {did-change} when the decoration is removed
504504
* @emits {did-remove-decoration} when the decoration is removed
505505
*/
506-
removeDecoration(decoration) {
506+
removeDecoration(decoration: Decoration) {
507507
if (decoration == null) {
508508
return
509509
}
@@ -555,7 +555,7 @@ export default class DecorationManagement {
555555
* @emits {did-change} when a decoration have been removed
556556
* @emits {did-remove-decoration} when a decoration have been removed
557557
*/
558-
removeAllDecorationsForMarker(marker) {
558+
removeAllDecorationsForMarker(marker: Marker) {
559559
if (marker == null) {
560560
return
561561
}
@@ -586,7 +586,7 @@ export default class DecorationManagement {
586586
* @param {Marker} marker the marker for which removing decorations
587587
* @access private
588588
*/
589-
removedAllMarkerDecorations(marker) {
589+
removedAllMarkerDecorations(marker: Marker) {
590590
if (marker == null) {
591591
return
592592
}
@@ -666,7 +666,7 @@ function getOriginatorPackageName() {
666666
* @return {Array<Object>} the array of diff ranges
667667
* @access private
668668
*/
669-
function computeRangesDiffs(oldStart, oldEnd, newStart, newEnd) {
669+
function computeRangesDiffs(oldStart: number, oldEnd: number, newStart: number, newEnd: number): Array<{}> {
670670
const diffs = []
671671

672672
if (oldStart.isLessThan(newStart)) {

lib/decoration.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class Decoration {
2121
* @param {string} type the decoration type to match
2222
* @return {boolean} whether the decoration properties match the type
2323
*/
24-
static isType(decorationProperties, type) {
24+
static isType(decorationProperties: { }, type: string): boolean {
2525
if (Array.isArray(decorationProperties.type)) {
2626
if (decorationProperties.type.indexOf(type) >= 0) {
2727
return true
@@ -40,7 +40,7 @@ export default class Decoration {
4040
* be displayed
4141
* @param {Object} properties the decoration's properties
4242
*/
43-
constructor(marker, minimap, properties) {
43+
constructor(marker: Marker, minimap: Minimap, properties: { }) {
4444
/**
4545
* @access private
4646
*/
@@ -100,7 +100,7 @@ export default class Decoration {
100100
*
101101
* @return {boolean} whether this decoration is destroyed or not
102102
*/
103-
isDestroyed() {
103+
isDestroyed(): boolean {
104104
return this.destroyed
105105
}
106106

@@ -113,7 +113,7 @@ export default class Decoration {
113113
* when the event is triggered
114114
* @return {Disposable} a disposable to stop listening to the event
115115
*/
116-
onDidChangeProperties(callback) {
116+
onDidChangeProperties(callback: (change: {}) => void): Disposable {
117117
return this.emitter.on("did-change-properties", callback)
118118
}
119119

@@ -124,7 +124,7 @@ export default class Decoration {
124124
* is triggered
125125
* @return {Disposable} a disposable to stop listening to the event
126126
*/
127-
onDidDestroy(callback) {
127+
onDidDestroy(callback: () => void): Disposable {
128128
return this.emitter.on("did-destroy", callback)
129129
}
130130

@@ -133,7 +133,7 @@ export default class Decoration {
133133
*
134134
* @return {number} the decoration id
135135
*/
136-
getId() {
136+
getId(): number {
137137
return this.id
138138
}
139139

@@ -142,7 +142,7 @@ export default class Decoration {
142142
*
143143
* @return {Marker} the decoration's marker
144144
*/
145-
getMarker() {
145+
getMarker(): Marker {
146146
return this.marker
147147
}
148148

@@ -155,7 +155,7 @@ export default class Decoration {
155155
* matches any in the array.
156156
* @return {boolean} whether this decoration match the passed-in type
157157
*/
158-
isType(type) {
158+
isType(type: string | Array): boolean {
159159
return Decoration.isType(this.properties, type)
160160
}
161161

@@ -164,7 +164,7 @@ export default class Decoration {
164164
*
165165
* @return {Object} the decoration's properties
166166
*/
167-
getProperties() {
167+
getProperties(): {} {
168168
return this.properties
169169
}
170170

@@ -174,7 +174,7 @@ export default class Decoration {
174174
*
175175
* @param {Object} newProperties the new properties for the decoration
176176
*/
177-
setProperties(newProperties) {
177+
setProperties(newProperties: { }) {
178178
if (this.destroyed) {
179179
return
180180
}

lib/dom-styles-reader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default class DOMStylesReader {
4747
* @return {string} the computed property's value
4848
* used in CanvasDrawer
4949
*/
50-
retrieveStyleFromDom(scopes, property, targetNode, getFromCache) {
50+
retrieveStyleFromDom(scopes: Array<string>, property: string, targetNode: Node, getFromCache: boolean): string {
5151
if (!scopes.length) {
5252
return ""
5353
} // no scopes
@@ -104,7 +104,7 @@ export default class DOMStylesReader {
104104
*
105105
* @access private
106106
*/
107-
ensureDummyNodeExistence(targetNode) {
107+
ensureDummyNodeExistence(targetNode: Node) {
108108
if (this.targetNode !== targetNode || this.dummyNode === undefined) {
109109
this.dummyNode = document.createElement("span")
110110
this.dummyNode.style.visibility = "hidden"
@@ -159,7 +159,7 @@ const hueRegexp = /hue-rotate\((\d+)deg\)/
159159
* @return {string} the rotated CSS color
160160
* @access private
161161
*/
162-
function rotateHue(value, filter) {
162+
function rotateHue(value: string, filter: string): string {
163163
const match = value.match(rgbExtractRegexp)
164164
let [, , r, g, b, , a] = match
165165

@@ -186,7 +186,7 @@ function rotateHue(value, filter) {
186186
* @return {Array<number>} the rotated color channels
187187
* @access private
188188
*/
189-
function rotate(r, g, b, angle) {
189+
function rotate(r: number, g: number, b: number, angle: number): Array<number> {
190190
const matrix = [1, 0, 0, 0, 1, 0, 0, 0, 1]
191191
const lumR = 0.2126
192192
const lumG = 0.7152

lib/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ export { default as Minimap } from "./minimap"
2525
* @type {boolean}
2626
* @access private
2727
*/
28-
let active = false
28+
let active: boolean = false
2929
/**
3030
* The toggle state of the package.
3131
*
3232
* @type {boolean}
3333
* @access private
3434
*/
35-
let toggled = false
35+
let toggled: boolean = false
3636
/**
3737
* The `Map` where Minimap instances are stored with the text editor they
3838
* target as key.
@@ -47,14 +47,14 @@ export let editorsMinimaps = null
4747
* @type {CompositeDisposable}
4848
* @access private
4949
*/
50-
let subscriptions = null
50+
let subscriptions: CompositeDisposable = null
5151
/**
5252
* The disposable that stores the package's commands subscription.
5353
*
5454
* @type {Disposable}
5555
* @access private
5656
*/
57-
let subscriptionsOfCommands = null
57+
let subscriptionsOfCommands: Disposable = null
5858

5959
/**
6060
* The package's events emitter.
@@ -186,7 +186,7 @@ export function toggle() {
186186
*
187187
* @param {string} template the name of the template to use
188188
*/
189-
async function generatePlugin(template) {
189+
async function generatePlugin(template: string) {
190190
const { default: MinimapPluginGeneratorElement } = await import("./minimap-plugin-generator-element")
191191
const view = new MinimapPluginGeneratorElement()
192192
view.template = template

0 commit comments

Comments
 (0)