Skip to content

Commit

Permalink
Upgrade flow to 0.69
Browse files Browse the repository at this point in the history
Not upgrading past that due to facebook/flow#6151.
  • Loading branch information
jfirebaugh committed May 2, 2018
1 parent de4648f commit 4761e0b
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
.*/test/integration/render-tests/.*

[version]
0.66.0
0.69.0
1 change: 1 addition & 0 deletions flow-typed/vector-tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare interface VectorTile {
}

declare interface VectorTileLayer {
version?: number;
name: string;
extent: number;
length: number;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-react": "^7.3.0",
"execcommand-copy": "^1.1.0",
"flow-bin": "^0.66.0",
"flow-bin": "^0.69.0",
"flow-coverage-report": "^0.3.0",
"github-slugger": "^1.1.1",
"gl": "^4.0.1",
Expand Down
1 change: 1 addition & 0 deletions src/source/geojson_worker_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type LoadGeoJSONParameters = {
request?: RequestParameters,
data?: string,
source: string,
cluster: boolean,
superclusterOptions?: Object,
geojsonVtOptions?: Object
};
Expand Down
24 changes: 15 additions & 9 deletions src/source/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type Map from '../ui/map';
import type Tile from './tile';
import type {OverscaledTileID} from './tile_id';
import type {Callback} from '../types/callback';
import {CanonicalTileID} from './tile_id';

/**
* The `Source` interface must be implemented by each source type, including "core" types (`vector`, `raster`,
Expand All @@ -34,15 +35,6 @@ import type {Callback} from '../types/callback';
* if they are floor-ed to the nearest integer.
*/
export interface Source {
/**
* An optional URL to a script which, when run by a Worker, registers a {@link WorkerSource}
* implementation for this Source type by calling `self.registerWorkerSource(workerSource: WorkerSource)`.
* @private
*/
// Static interface properties are not supported in flow as of 0.62.0.
// https://github.com/facebook/flow/issues/5590
// static workerSourceURL?: URL;

+type: string;
id: string;
minzoom: number,
Expand All @@ -51,6 +43,9 @@ export interface Source {
attribution?: string,

roundZoom?: boolean,
isTileClipped?: boolean,
mapbox_logo?: boolean,
tileID?: CanonicalTileID;
reparseOverscaled?: boolean,
vectorLayerIds?: Array<string>,

Expand All @@ -77,6 +72,17 @@ export interface Source {
+prepare?: () => void;
}

type SourceStatics = {
/**
* An optional URL to a script which, when run by a Worker, registers a {@link WorkerSource}
* implementation for this Source type by calling `self.registerWorkerSource(workerSource: WorkerSource)`.
* @private
*/
workerSourceURL?: URL;
};

export type SourceClass = Class<Source> & SourceStatics;

import vector from '../source/vector_tile_source';
import raster from '../source/raster_tile_source';
import rasterDem from '../source/raster_dem_tile_source';
Expand Down
4 changes: 2 additions & 2 deletions src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class SourceCache extends Evented {
_tileLoaded(tile: Tile, id: string | number, previousState: TileState, err: ?Error) {
if (err) {
tile.state = 'errored';
if (err.status !== 404) this._source.fire(new ErrorEvent(err, {tile}));
if ((err: any).status !== 404) this._source.fire(new ErrorEvent(err, {tile}));
// continue to try loading parent/children tiles if a tile doesn't exist (404)
else this.update(this.transform);
return;
Expand Down Expand Up @@ -461,7 +461,7 @@ class SourceCache extends Evented {
if (!this.used) {
idealTileIDs = [];
} else if (this._source.tileID) {
idealTileIDs = transform.getVisibleUnwrappedCoordinates((this._source.tileID: any))
idealTileIDs = transform.getVisibleUnwrappedCoordinates(this._source.tileID)
.map((unwrapped) => new OverscaledTileID(unwrapped.canonical.z, unwrapped.wrap, unwrapped.canonical.z, unwrapped.canonical.x, unwrapped.canonical.y));
} else {
idealTileIDs = transform.coveringTiles({
Expand Down
5 changes: 3 additions & 2 deletions src/style-spec/feature_filter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ function isExpressionFilter(filter: any) {
const filterSpec = {
'type': 'boolean',
'default': false,
'function': true,
'function': 'piecewise-constant',
'property-function': true,
'zoom-function': true
'zoom-function': true,
'transition': false
};

/**
Expand Down
21 changes: 14 additions & 7 deletions src/style-spec/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,57 @@

export type StylePropertySpecification = {
type: 'number',
'function': boolean,
'function': 'interpolated' | 'piecewise-constant',
'property-function': boolean,
'zoom-function': boolean,
transition: boolean,
default?: number
} | {
type: 'string',
'function': boolean,
'function': 'interpolated' | 'piecewise-constant',
'property-function': boolean,
'zoom-function': boolean,
default?: string,
transition: boolean,
tokens?: boolean
} | {
type: 'boolean',
'function': boolean,
'function': 'interpolated' | 'piecewise-constant',
'property-function': boolean,
'zoom-function': boolean,
transition: boolean,
default?: boolean
} | {
type: 'enum',
'function': boolean,
'function': 'interpolated' | 'piecewise-constant',
'property-function': boolean,
'zoom-function': boolean,
values: {[string]: {}},
transition: boolean,
default?: string
} | {
type: 'color',
'function': boolean,
'function': 'interpolated' | 'piecewise-constant',
'property-function': boolean,
'zoom-function': boolean,
transition: boolean,
default?: string
} | {
type: 'array',
value: 'number',
'function': boolean,
'function': 'interpolated' | 'piecewise-constant',
'property-function': boolean,
'zoom-function': boolean,
transition: boolean,
length?: number,
default?: Array<number>
} | {
type: 'array',
value: 'string',
'function': boolean,
'function': 'interpolated' | 'piecewise-constant',
'property-function': boolean,
'zoom-function': boolean,
transition: boolean,
length?: number,
default?: Array<string>
};
Expand Down
6 changes: 3 additions & 3 deletions src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import Dispatcher from '../util/dispatcher';
import { validateStyle, emitValidationErrors as _emitValidationErrors } from './validate_style';
import {
getType as getSourceType,
setType as setSourceType
setType as setSourceType,
type SourceClass
} from '../source/source';
import { queryRenderedFeatures, queryRenderedSymbols, querySourceFeatures } from '../source/query_features';
import SourceCache from '../source/source_cache';
Expand All @@ -43,7 +44,6 @@ const emitValidationErrors = (evented: Evented, errors: ?$ReadOnlyArray<{message

import type Map from '../ui/map';
import type Transform from '../geo/transform';
import type {Source} from '../source/source';
import type {StyleImage} from './style_image';
import type {StyleGlyph} from './style_glyph';
import type {Callback} from '../types/callback';
Expand Down Expand Up @@ -914,7 +914,7 @@ class Style extends Evented {
return sourceCache ? querySourceFeatures(sourceCache, params) : [];
}

addSourceType(name: string, SourceType: Class<Source>, callback: Callback<void>) {
addSourceType(name: string, SourceType: SourceClass, callback: Callback<void>) {
if (Style.getSourceType(name)) {
return callback(new Error(`A source type called "${name}" already exists.`));
}
Expand Down
6 changes: 3 additions & 3 deletions src/ui/bind_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const handlers = {
touchZoomRotate
};

export default function bindHandlers(map: Map, options: {}) {
export default function bindHandlers(map: Map, options: {interactive: boolean}) {
const el = map.getCanvasContainer();
let contextMenuEvent = null;
let mouseDown = false;
Expand Down Expand Up @@ -97,15 +97,15 @@ export default function bindHandlers(map: Map, options: {}) {
if (map.dragPan.isActive()) return;
if (map.dragRotate.isActive()) return;

let target: any = e.toElement || e.target;
let target: ?Node = (e.target: any);
while (target && target !== el) target = target.parentNode;
if (target !== el) return;

map.fire(new MapMouseEvent('mousemove', map, e));
}

function onMouseOver(e: MouseEvent) {
let target: any = e.toElement || e.target;
let target: ?Node = (e.target: any);
while (target && target !== el) target = target.parentNode;
if (target !== el) return;

Expand Down
6 changes: 3 additions & 3 deletions src/ui/control/fullscreen_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ class FullscreenControl {
}
} else if (this._mapContainer.requestFullscreen) {
this._mapContainer.requestFullscreen();
} else if (this._mapContainer.mozRequestFullScreen) {
} else if ((this._mapContainer: any).mozRequestFullScreen) {
(this._mapContainer: any).mozRequestFullScreen();
} else if (this._mapContainer.msRequestFullscreen) {
} else if ((this._mapContainer: any).msRequestFullscreen) {
(this._mapContainer: any).msRequestFullscreen();
} else if (this._mapContainer.webkitRequestFullscreen) {
} else if ((this._mapContainer: any).webkitRequestFullscreen) {
(this._mapContainer: any).webkitRequestFullscreen();
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/util/evented.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import { extend, endsWith } from './util';
import { extend } from './util';

type Listener = (Object) => any;
type Listeners = { [string]: Array<Listener> };
Expand Down Expand Up @@ -29,6 +29,8 @@ export class Event {
}

export class ErrorEvent extends Event {
error: Error;

constructor(error: Error, data: Object = {}) {
super('error', extend({error}, data));
}
Expand Down Expand Up @@ -120,10 +122,8 @@ export class Evented {

// To ensure that no error events are dropped, print them to the
// console if they have no listeners.
} else if (endsWith(type, 'error')) {
console.error((event && event.error) || event || 'Empty error event');
} else if (endsWith(type, 'warning')) {
console.warn((event && event.warning) || event || 'Empty warning event');
} else if (event instanceof ErrorEvent) {
console.error(event.error);
}

return this;
Expand Down
2 changes: 1 addition & 1 deletion src/util/worker_pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class WorkerPool {
this.active = {};
}

acquire(mapId: number) {
acquire(mapId: number): Array<WorkerInterface> {
if (!this.workers) {
// Lazily look up the value of mapboxgl.workerCount so that
// client code has had a chance to set it.
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4171,9 +4171,9 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"

flow-bin@^0.66.0:
version "0.66.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.66.0.tgz#a96dde7015dc3343fd552a7b4963c02be705ca26"
flow-bin@^0.69.0:
version "0.69.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.69.0.tgz#053159a684a6051fcbf0b71a2eb19a9679082da6"

flow-coverage-report@^0.3.0:
version "0.3.0"
Expand Down

0 comments on commit 4761e0b

Please sign in to comment.