Skip to content

Commit

Permalink
Flow & dependencies update (#403)
Browse files Browse the repository at this point in the history
* Update flow definitions

* Update dependencies

* Update outdated jest calls

* Fix eslint errors
  • Loading branch information
GauthierPLM authored Jun 24, 2018
1 parent 84c56a0 commit 1b20b86
Show file tree
Hide file tree
Showing 31 changed files with 2,478 additions and 1,141 deletions.
120 changes: 91 additions & 29 deletions flow-libs/atom.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ type atom$Octicon = 'alert' | 'alignment-align' | 'alignment-aligned-to' | 'alig

type atom$PaneLocation = 'left' | 'right' | 'bottom' | 'center';

declare type atom$Color = {
// Returns a String in the form '#abcdef'.
toHexString(): string;
// Returns a String in the form 'rgba(25, 50, 75, .9)'.
toRGBAString(): string;
}

declare class atom$Model {
destroy(): void,
isDestroyed(): boolean,
Expand All @@ -63,6 +70,7 @@ declare class atom$Package {
path: string,
activateTime: number,
mainModule: any,
mainModulePath: string,
metadata: Object,
name: string,
loadTime: number,
Expand All @@ -75,6 +83,7 @@ declare class atom$Package {
// Undocumented
bundledPackage: boolean,
getCanDeferMainModuleRequireStorageKey(): string,
initializeIfNeeded(): void,
}

/**
Expand Down Expand Up @@ -143,14 +152,20 @@ declare class atom$Config {
// Config Subscription
observe(
keyPath: string,
optionsOrCallback?: Object | (value: any) => void,
callback?: (value: any) => void
optionsOrCallback?:
| {scope?: atom$ScopeDescriptorLike}
| (value: mixed) => void,
callback?: (value: mixed) => mixed,
): IDisposable,

onDidChange(
keyPathOrCallback: string | (event: Object) => void,
optionsOrCallback?: Object | (event: Object) => void,
callback?: (event: Object) => void
keyPathOrCallback:
| string
| (event: {oldValue: mixed, newValue: mixed}) => mixed,
optionsOrCallback?:
| {scope?: atom$ScopeDescriptorLike}
| (event: {oldValue: mixed, newValue: mixed}) => mixed,
callback?: (event: {oldValue: mixed, newValue: mixed}) => mixed
): IDisposable,

// Managing Settings
Expand All @@ -159,7 +174,7 @@ declare class atom$Config {
options?: {
excludeSources?: Array<string>,
sources?: Array<string>,
scope?: Object,
scope?: atom$ScopeDescriptorLike,
}
): mixed,

Expand Down Expand Up @@ -229,7 +244,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 @@ -241,18 +256,29 @@ declare class atom$DisplayMarkerLayer {
clear(): void,
isDestroyed(): boolean,
markBufferPosition(position: atom$PointLike, options?: MarkerOptions): atom$Marker,
markBufferRange(range: atom$Range | atom$RangeLike, options: MarkerOptions): atom$Marker,
markBufferRange(range: atom$Range | atom$RangeLike, options?: MarkerOptions): atom$Marker,
findMarkers(options: MarkerOptions): Array<atom$Marker>,
getMarkers(): Array<atom$Marker>,
}

declare class atom$LayerDecoration {
destroy(): void,
isDestroyed(): boolean,
getProperties(): Object,
setProperties(properties: mixed): void,
setPropertiesForMarker(marker: atom$Marker, properties: mixed): void,
}

declare class atom$Disposable {
constructor(disposalAction?: (...args: Array<any>) => any): void,
disposed: boolean,
dispose(): void,
}

declare class atom$Emitter {
dispose(): void,
on(name: string, callback: (v: any) => mixed): IDisposable,
once(name: string, callback: (v: any) => mixed): IDisposable,
preempt(name: string, callback: (v: any) => void): IDisposable,
// This is a flow hack to prevent emitting more than one value.
// `EventEmitter` allows emitting any number of values - making this a land
Expand Down Expand Up @@ -319,12 +345,15 @@ type atom$PackageMetadata = {
};

declare class atom$PackageManager {
+initialPackagesActivated: boolean,

// Event Subscription
onDidLoadInitialPackages(callback: () => void): IDisposable,
onDidActivateInitialPackages(callback: () => void): IDisposable,
onDidActivatePackage(callback: (pkg: atom$Package) => mixed): IDisposable,
onDidDeactivatePackage(callback: (pkg: atom$Package) => mixed): IDisposable,
onDidLoadPackage(callback: (pkg: atom$Package) => mixed): IDisposable,
onDidUnloadPackage(callback: (pkg: atom$Package) => mixed): IDisposable,
onDidTriggerActivationHook(activationHook: string, callback: () => mixed): IDisposable,

// Package system data
Expand Down Expand Up @@ -443,7 +472,7 @@ declare class atom$Pane {
onDidAddItem(cb: (event: {item: Object, index: number}) => void): IDisposable,
onDidRemoveItem(cb: (event: {item: Object, index: number}) => void): IDisposable,
onWillRemoveItem(cb: (event: {item: Object, index: number}) => void): IDisposable,
onDidDestroy(cb: () => void): IDisposable,
onDidDestroy(cb: () => mixed): IDisposable,
onDidChangeFlexScale(cb: (newFlexScale: number) => void): IDisposable,
onWillDestroy(cb: () => void): IDisposable,
observeActiveItem(cb: (item: ?Object) => void): IDisposable,
Expand All @@ -452,6 +481,7 @@ declare class atom$Pane {
isActive(): boolean,
activate(): void,
destroy(): void,
isDestroyed(): void,

// Splitting
splitLeft(params?: atom$PaneSplitParams): atom$Pane,
Expand Down Expand Up @@ -505,11 +535,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 @@ -546,8 +576,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 @@ -583,9 +613,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 @@ -624,6 +654,8 @@ declare class atom$ScopeDescriptor {
getScopesArray(): Array<string>,
}

type atom$ScopeDescriptorLike = atom$ScopeDescriptor | Array<string>;

/**
* This API is defined at https://github.com/atom/status-bar.
*/
Expand Down Expand Up @@ -694,6 +726,7 @@ type atom$TooltipsAddOptions = {
};

type atom$Tooltip = {
show(): void;
hide(): void;
getTooltipElement(): HTMLElement,
};
Expand All @@ -704,6 +737,7 @@ declare class atom$TooltipManager {
target: HTMLElement,
options: atom$TooltipsAddOptions,
): IDisposable,
findTooltips(HTMLElement): Array<atom$Tooltip>,
}

type InsertTextOptions = {
Expand Down Expand Up @@ -759,7 +793,7 @@ type MarkerOptions = {
exclusive?: boolean,
};

type ChangeSelectionRangeEvent = {|
type atom$ChangeSelectionRangeEvent = {|
oldBufferRange: atom$Range,
oldScreenRange: atom$Range,
newBufferRange: atom$Range,
Expand All @@ -782,11 +816,11 @@ declare class atom$TextEditor extends atom$Model {
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,
onDidChangeSelectionRange(callback: (event: ChangeSelectionRangeEvent) => mixed): IDisposable,
onDidChangeSelectionRange(callback: (event: atom$ChangeSelectionRangeEvent) => mixed): IDisposable,
observeSelections(callback: (selection: atom$Selection) => mixed): IDisposable,

// File Details
Expand Down Expand Up @@ -824,7 +858,7 @@ declare class atom$TextEditor extends atom$Model {
// Mutating Text
setText(text: string, options?: InsertTextOptions): void,
setTextInBufferRange(
range: atom$Range | Array<atom$Point>,
range: atom$RangeLike,
text: string,
options?: {
normalizeLineEndings?: boolean,
Expand Down Expand Up @@ -869,6 +903,10 @@ declare class atom$TextEditor extends atom$Model {

// Decorations
decorateMarker(marker: atom$Marker, decorationParams: DecorateMarkerParams): atom$Decoration,
decorateMarkerLayer(
markerLayer: atom$DisplayMarkerLayer,
decorationParams: DecorateMarkerParams,
): atom$LayerDecoration,
decorationsForScreenRowRange(
startScreenRow: number,
endScreenRow: number,
Expand Down Expand Up @@ -932,6 +970,7 @@ declare class atom$TextEditor extends atom$Model {
preserveFolds?: boolean,
},
): void,
selectWordsContainingCursors(): void,

// Folds
unfoldAll(): void,
Expand Down Expand Up @@ -979,6 +1018,7 @@ declare class atom$TextEditor extends atom$Model {
copySelectedText: () => void,

// Managing Syntax Scopes
getRootScopeDescriptor(): atom$ScopeDescriptor,
scopeDescriptorForBufferPosition(
bufferPosition: atom$PointLike,
): atom$ScopeDescriptor,
Expand Down Expand Up @@ -1032,6 +1072,7 @@ declare class atom$TextEditor extends atom$Model {
serialize(): Object,
foldBufferRowRange(startRow: number, endRow: number): void,
getNonWordCharacters(position?: atom$PointLike): string,
scheduleComponentUpdate(): void,
}

/**
Expand Down Expand Up @@ -1345,6 +1386,13 @@ declare class atom$WorkspaceCenter extends atom$AbstractPaneContainer {

observeActivePaneItem(callback: atom$PaneItem => mixed): IDisposable;
onDidChangeActivePaneItem(callback: (item: mixed) => mixed): IDisposable;
onDidAddTextEditor(
callback: (item: {
textEditor: atom$TextEditor,
pane: atom$Pane,
index: number,
}) => mixed,
): IDisposable;
// This should be removed soon anyway, it's currently deprecated.
paneContainer: Object;
}
Expand Down Expand Up @@ -1596,6 +1644,7 @@ declare class atom$KeymapManager {

// Adding and Removing Bindings
add(source: string, bindings: Object): IDisposable,
removeBindingsFromSource(source: string): void,

// Accessing Bindings
getKeyBindings(): Array<atom$KeyBinding>,
Expand Down Expand Up @@ -1634,16 +1683,19 @@ declare class atom$MenuManager {
template: Array<Object>,
}

type atom$ProjectSpecification = {
originPath: string,
paths?: Array<string>,
config?: {[string]: mixed}
};

declare class atom$Project {
// Event Subscription
onDidChangePaths(callback: (projectPaths: Array<string>) => mixed): IDisposable,
onDidAddBuffer(callback: (buffer: atom$TextBuffer) => mixed): IDisposable,
onDidReplace((settings: atom$ProjectSpecification) => mixed): IDisposable,
observeBuffers(callback: (buffer: atom$TextBuffer) => mixed): IDisposable,
replace?: (newSettings: {|
originPath?: string,
paths?: Array<string>,
config?: {[string]: mixed}
|}) => void,
replace?: (newSettings: atom$ProjectSpecification) => void,
// Accessing the git repository
getRepositories(): Array<?atom$Repository>,
repositoryForDirectory(directory: atom$Directory): Promise<?atom$Repository>,
Expand Down Expand Up @@ -1833,6 +1885,7 @@ declare class atom$Notification {
getMessage(): string,
getOptions(): Object,
dismiss(): void,
isDismissed(): boolean,
}

type atom$NotificationButton = {
Expand All @@ -1846,6 +1899,7 @@ type atom$NotificationOptions = {
dismissable?: boolean,
description?: string,
icon?: string,
stack?: string,
buttons?: Array<atom$NotificationButton>,
};

Expand Down Expand Up @@ -1989,6 +2043,7 @@ declare class atom$Repository {
getType: () => string,
getPath: () => string,
getWorkingDirectory: () => string,
getProjectDirectory: () => string,
isProjectAtRoot: () => boolean,
relativize: (aPath: string) => string,
getOriginURL: (aPath: ?string) => ?string,
Expand Down Expand Up @@ -2041,13 +2096,14 @@ type atom$AutocompleteSuggestion = {
className?: ?string,
iconHTML?: ?string,
description?: ?string,
descriptionMarkdown?: ?string,
descriptionMoreURL?: ?string,
};

type atom$AutocompleteRequest = {
editor: TextEditor,
bufferPosition: atom$Point,
scopeDescriptor: string,
scopeDescriptor: atom$ScopeDescriptor,
prefix: string,
activatedManually?: boolean,
};
Expand Down Expand Up @@ -2077,6 +2133,12 @@ type atom$SuggestionInsertedRequest = {
+suggestion: atom$AutocompleteSuggestion,
};

// https://github.com/atom/autocomplete-plus/blob/master/README.md#the-watcheditor-api
type atom$AutocompleteWatchEditor = (
editor: atom$TextEditor,
labels?: Array<string>,
) => IDisposable;

// Undocumented API.
declare class atom$Token {
value: string,
Expand Down
Loading

0 comments on commit 1b20b86

Please sign in to comment.