Skip to content

Commit

Permalink
Update flow-libs (#332)
Browse files Browse the repository at this point in the history
* Add missing flow-libs

* Update flow-libs

* Fix electron usage

* Correct atom calls

* Update flow-libs

* Delete non-used dependency

Even if we plan to support remote connexion later, it's better to avoid keeping unused dependencies
  • Loading branch information
GauthierPLM authored and alanzanattadev committed Apr 10, 2018
1 parent 5bde4ec commit a929d1c
Show file tree
Hide file tree
Showing 15 changed files with 865 additions and 95 deletions.
81 changes: 50 additions & 31 deletions flow-libs/atom.js → flow-libs/atom.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ declare class atom$Decoration {
destroy(): void,
onDidChangeProperties(
callback: (event: {oldProperties: Object, newProperties: Object}) => mixed
): IDisposable,
): IDisposable,
onDidDestroy(callback: () => mixed): IDisposable,
getMarker(): atom$Marker,
getProperties(): Object,
Expand All @@ -240,6 +240,7 @@ declare class atom$DisplayMarkerLayer {
destroy(): void,
clear(): void,
isDestroyed(): boolean,
markBufferPosition(position: atom$PointLike, options?: MarkerOptions): atom$Marker,
markBufferRange(range: atom$Range | atom$RangeLike, options: MarkerOptions): atom$Marker,
getMarkers(): Array<atom$Marker>,
}
Expand Down Expand Up @@ -273,24 +274,26 @@ declare class atom$Gutter {
onDidDestroy(callback: () => void): IDisposable,
}

declare type atom$MarkerChangeEvent = {
oldHeadScreenPosition: atom$Point,
newHeadScreenPosition: atom$Point,
oldTailScreenPosition: atom$Point,
newTailScreenPosition: atom$Point,

oldHeadBufferPosition: atom$Point,
newHeadBufferPosition: atom$Point,
oldTailBufferPosition: atom$Point,
newTailBufferPosition: atom$Point,

isValid: boolean,
textChanged: boolean,
}

declare class atom$Marker {
destroy(): void,
getBufferRange(): atom$Range,
getStartBufferPosition(): atom$Point,
onDidChange(callback: (event: {
oldHeadScreenPosition: atom$Point,
newHeadScreenPosition: atom$Point,
oldTailScreenPosition: atom$Point,
newTailScreenPosition: atom$Point,

oldHeadBufferPosition: atom$Point,
newHeadBufferPosition: atom$Point,
oldTailBufferPosition: atom$Point,
newTailBufferPosition: atom$Point,

isValid: boolean,
textChanged: boolean,
}) => void): IDisposable,
onDidChange(callback: (event: atom$MarkerChangeEvent) => mixed): IDisposable,
isValid(): boolean,
isDestroyed(): boolean,
onDidDestroy(callback: () => mixed): IDisposable,
Expand Down Expand Up @@ -485,7 +488,9 @@ declare interface atom$PaneItem {
+getURI?: () => ?string,
+onDidChangeIcon?: (cb: (icon: string) => void) => IDisposable,
+onDidChangeTitle?: (cb: (title: string) => void) => IDisposable,
+onDidTerminatePendingState?: (() => mixed) => IDisposable;
+serialize?: () => Object,
+terminatePendingState?: () => void,
}

// Undocumented class
Expand All @@ -500,11 +505,11 @@ declare class atom$PaneAxis {
// are typed here as AbstractPaneContainers and, in the current implementation, wrap these.)
declare class atom$PaneContainer {
constructor({
config: atom$Config,
applicationDelegate: atom$applicationDelegate,
notificationManager: atom$NotificationManager,
deserializerManager: atom$DeserializerManager,
}): atom$PaneContainer,
config: atom$Config,
applicationDelegate: atom$applicationDelegate,
notificationManager: atom$NotificationManager,
deserializerManager: atom$DeserializerManager,
}): atom$PaneContainer,
destroy(): void,
getActivePane(): atom$Pane,
getActivePaneItem(): ?Object,
Expand Down Expand Up @@ -541,8 +546,8 @@ declare class atom$Panel {
type atom$PointObject = {row: number, column: number};

type atom$PointLike = atom$Point
| [number, number]
| atom$PointObject;
| [number, number]
| atom$PointObject;

declare class atom$Point {
static fromObject(object: atom$PointLike, copy: ? boolean): atom$Point,
Expand Down Expand Up @@ -578,9 +583,9 @@ type atom$RangeLike = atom$Range
| atom$RangeObject // TODO: Flow doesn't really handle the real signature below...
| [atom$PointLike, atom$PointLike]
| {
start: atom$PointLike,
end: atom$PointLike,
};
start: atom$PointLike,
end: atom$PointLike,
};

declare class atom$Range {
static fromObject(
Expand Down Expand Up @@ -747,12 +752,12 @@ type ChangeCursorPositionEvent = {
cursor: atom$Cursor,
};

type MarkerOptions = {|
type MarkerOptions = {
reversed?: boolean,
tailed?: boolean,
invalidate?: 'never' | 'surround' | 'overlap' | 'inside' | 'touch',
exclusive?: boolean,
|};
};

type ChangeSelectionRangeEvent = {|
oldBufferRange: atom$Range,
Expand All @@ -769,15 +774,15 @@ declare class atom$TextEditor extends atom$Model {
// Event Subscription
onDidChange(callback: () => void): IDisposable,
onDidChangePath(callback: (newPath: string) => mixed): IDisposable,
onDidStopChanging(callback: () => void): IDisposable,
onDidStopChanging(callback: () => mixed): IDisposable,
onDidChangeCursorPosition(callback: (event: ChangeCursorPositionEvent) => mixed):
IDisposable,
onDidDestroy(callback: () => mixed): IDisposable,
onDidSave(callback: (event: {path: string}) => mixed): IDisposable,
getBuffer(): atom$TextBuffer,
observeGrammar(callback: (grammar: atom$Grammar) => mixed): IDisposable,
onWillInsertText(callback: (event: {cancel: () => void, text: string}) => void):
IDisposable,
IDisposable,
// Note that the range property of the event is undocumented.
onDidInsertText(callback: (event: {text: string, range: atom$Range}) => mixed): IDisposable,
onDidChangeSoftWrapped(callback: (softWrapped: boolean) => mixed): IDisposable,
Expand Down Expand Up @@ -814,6 +819,7 @@ declare class atom$TextEditor extends atom$Model {
getText(): string,
getTextInBufferRange(range: atom$RangeLike): string,
getLineCount(): number,
getLastScreenRow(): number,

// Mutating Text
setText(text: string, options?: InsertTextOptions): void,
Expand All @@ -834,8 +840,10 @@ declare class atom$TextEditor extends atom$Model {
// History
createCheckpoint(): atom$TextBufferCheckpoint,
revertToCheckpoint(checkpoint: atom$TextBufferCheckpoint): boolean,
terminatePendingState(): void,
transact(fn: () => mixed, _: void): void,
transact(groupingInterval: number, fn: () => mixed): void,
onDidTerminatePendingState(() => mixed): IDisposable;

// TextEditor Coordinates
screenPositionForBufferPosition(
Expand Down Expand Up @@ -868,11 +876,13 @@ declare class atom$TextEditor extends atom$Model {
getDecorations(options?: {class?: string, type?: string}): Array<atom$Decoration>,

// Markers
addMarkerLayer(): atom$DisplayMarkerLayer,
getDefaultMarkerLayer(): atom$DisplayMarkerLayer,
markBufferPosition(position: atom$PointLike, options?: MarkerOptions): atom$Marker,
markBufferRange(range: atom$RangeLike, options?: MarkerOptions): atom$Marker,
markScreenRange(range: atom$RangeLike, options?: MarkerOptions): atom$Marker,
markScreenPosition(position: atom$PointLike, options?: MarkerOptions): atom$Marker,
findMarkers(options: MarkerOptions): Array<atom$Marker>,
getMarkerCount(): number,

// Cursors
Expand Down Expand Up @@ -966,6 +976,7 @@ declare class atom$TextEditor extends atom$Model {

// Clipboard Operations
pasteText: (options?: Object) => void,
copySelectedText: () => void,

// Managing Syntax Scopes
scopeDescriptorForBufferPosition(
Expand Down Expand Up @@ -1020,7 +1031,7 @@ declare class atom$TextEditor extends atom$Model {
onDidConflict(callback: () => void): IDisposable,
serialize(): Object,
foldBufferRowRange(startRow: number, endRow: number): void,
getNonWordCharacters(scope?: atom$ScopeDescriptor): string,
getNonWordCharacters(position?: atom$PointLike): string,
}

/**
Expand Down Expand Up @@ -1628,7 +1639,11 @@ declare class atom$Project {
onDidChangePaths(callback: (projectPaths: Array<string>) => mixed): IDisposable,
onDidAddBuffer(callback: (buffer: atom$TextBuffer) => mixed): IDisposable,
observeBuffers(callback: (buffer: atom$TextBuffer) => mixed): IDisposable,

replace?: (newSettings: {|
originPath?: string,
paths?: Array<string>,
config?: {[string]: mixed}
|}) => void,
// Accessing the git repository
getRepositories(): Array<?atom$Repository>,
repositoryForDirectory(directory: atom$Directory): Promise<?atom$Repository>,
Expand Down Expand Up @@ -1845,6 +1860,7 @@ declare class atom$NotificationManager {
addWarning(message: string, options?: atom$NotificationOptions): atom$Notification,
addError(message: string, options?: atom$NotificationOptions): atom$Notification,
addFatalError(message: string, options?: atom$NotificationOptions): atom$Notification,
addNotification(notification: atom$Notification): atom$Notification,

// Getting Notifications
getNotifications(): Array<atom$Notification>,
Expand Down Expand Up @@ -2041,6 +2057,9 @@ type atom$AutocompleteProvider = {
+getSuggestions: (
request: atom$AutocompleteRequest,
) => Promise<?Array<atom$AutocompleteSuggestion>> | ?Array<atom$AutocompleteSuggestion>,
+getSuggestionDetailsOnSelect?: (
suggestion: atom$AutocompleteSuggestion
) => Promise<?atom$AutocompleteSuggestion>,
+disableForSelector?: string,
+inclusionPriority?: number,
+excludeLowerPriority?: boolean,
Expand Down
80 changes: 40 additions & 40 deletions flow-libs/electron.js → flow-libs/electron.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ type electron$BrowserWindowOptions = {
darkTheme?: boolean,
transparent?: boolean,
type?: 'desktop' | 'dock' | 'toolbar' | 'splash' | 'notification' |
/* macOS */ 'desktop' | 'textured' |
/* Windows */ 'toolbar',
/* macOS */ 'desktop' | 'textured' |
/* Windows */ 'toolbar',
titleBarStyle?: 'default' | 'hidden' | 'hidden-inset',
thickFrame?: boolean,
webPreferences?: electron$BrowserWindowWebPreferences,
Expand Down Expand Up @@ -343,7 +343,7 @@ declare class electron$BrowserWindow {
click: Function,
tooltip?: string,
flags?: Array<'enabled' | 'disabled' | 'dismissonclick' | 'nobackground' |
'hidden' | 'noninteractive'>,
'hidden' | 'noninteractive'>,
}>): void, // Windows
setThumbnailClip(region: electron$rect): void, // Windows
showDefinitionForSelection(): void, // macOS
Expand Down Expand Up @@ -495,10 +495,10 @@ type electron$MenuItemOptions = {
event: Object
) => void,
role?: 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'pasteandmatchstyle' |
'selectall' | 'delete' | 'minimize' | 'close' | 'quit' | 'togglefullscreen' |
// macOS-only
'about' | 'hide' | 'hideothers' | 'unhide' | 'front' | 'zoom' | 'window' |
'help' | 'services',
'selectall' | 'delete' | 'minimize' | 'close' | 'quit' | 'togglefullscreen' |
// macOS-only
'about' | 'hide' | 'hideothers' | 'unhide' | 'front' | 'zoom' | 'window' |
'help' | 'services',
type?: 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio',
label?: string,
sublabel?: string,
Expand Down Expand Up @@ -561,8 +561,8 @@ declare class electron$Tray {}

type electron$InputEventModifiers =
Array<'shift' | 'control' | 'alt' | 'meta' |
'isKeypad' | 'isAutoRepeat' | 'leftButtonDown' | 'middleButtonDown' |
'rightButtonDown' | 'capsLock' | 'numLock' | 'left' | 'right'>;
'isKeypad' | 'isAutoRepeat' | 'leftButtonDown' | 'middleButtonDown' |
'rightButtonDown' | 'capsLock' | 'numLock' | 'left' | 'right'>;

declare class electron$WebContents extends events$EventEmitter {
loadURL(
Expand Down Expand Up @@ -669,36 +669,36 @@ declare class electron$WebContents extends events$EventEmitter {
modifiers?: electron$InputEventModifiers,
keyCode: string,
} | {
type: 'mouseDown' | 'mouseUp' | 'mouseEnter' | 'mouseLeave' | 'contextMenu',
modifiers?: electron$InputEventModifiers,
x: number,
y: number,
button: 'left' | 'middle' | 'right',
globalX: number,
globalY: number,
movementX: number,
movementY: number,
clickCount: number,
} | {
type: 'mouseWheel',
modifiers?: electron$InputEventModifiers,
x: number,
y: number,
button: 'left' | 'middle' | 'right',
globalX: number,
globalY: number,
movementX: number,
movementY: number,
clickCount: number,
deltaX: number,
deltaY: number,
wheelTicksX: number,
wheelTicksY: number,
accelerationRatioX: number,
accelerationRatioY: number,
hasPreciseScrollingDeltas: boolean,
canScroll: boolean,
},
type: 'mouseDown' | 'mouseUp' | 'mouseEnter' | 'mouseLeave' | 'contextMenu',
modifiers?: electron$InputEventModifiers,
x: number,
y: number,
button: 'left' | 'middle' | 'right',
globalX: number,
globalY: number,
movementX: number,
movementY: number,
clickCount: number,
} | {
type: 'mouseWheel',
modifiers?: electron$InputEventModifiers,
x: number,
y: number,
button: 'left' | 'middle' | 'right',
globalX: number,
globalY: number,
movementX: number,
movementY: number,
clickCount: number,
deltaX: number,
deltaY: number,
wheelTicksX: number,
wheelTicksY: number,
accelerationRatioX: number,
accelerationRatioY: number,
hasPreciseScrollingDeltas: boolean,
canScroll: boolean,
},
): void,
beginFrameSubscription(
callback: (frameBuffer: Buffer, dirtyRect: electron$rect) => void,
Expand Down Expand Up @@ -871,7 +871,7 @@ type electron$Display = {
};

type electron$DisplayEvents =
'display-added'
'display-added'
| 'display-removed'
| 'display-metrics-changed';

Expand Down
Loading

0 comments on commit a929d1c

Please sign in to comment.