Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stepankuzmin committed Mar 6, 2023
1 parent c195a9e commit 0d683be
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 80 deletions.
3 changes: 2 additions & 1 deletion 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.js';
import type Tile from './tile.js';
import type {OverscaledTileID} from './tile_id.js';
import type {Callback} from '../types/callback.js';
import type {MapEvent} from '../ui/events.js';
import {CanonicalTileID} from './tile_id.js';

/**
Expand Down Expand Up @@ -58,7 +59,7 @@ export interface Source {
loaded(): boolean;

fire(event: Event): mixed;
on(type: *, listener: (Object) => any): Evented;
on(type: MapEvent, listener: (Object) => any): Evented;
setEventedParent(parent: ?Evented, data?: Object | () => Object): Evented;

+onAdd?: (map: Map) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/style/evaluation_parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EvaluationParameters {
transition: TransitionSpecification;

// "options" may also be another EvaluationParameters to copy
constructor(zoom: number, options?: *) {
constructor(zoom: number, options?: any) {
this.zoom = zoom;

if (options) {
Expand Down
2 changes: 1 addition & 1 deletion src/style/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export class Layout<Props: Object> {
return clone(this._values[name].value);
}

setValue<S: string>(name: S, value: *) {
setValue<S: string>(name: S, value: any) {
this._values[name] = new PropertyValue(this._values[name].property, value === null ? undefined : clone(value));
}

Expand Down
2 changes: 1 addition & 1 deletion src/style/style_layer/symbol_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SymbolStyleLayer extends StyleLayer {
this._setPaintOverrides();
}

getValueAndResolveTokens(name: *, feature: Feature, canonical: CanonicalTileID, availableImages: Array<string>): string {
getValueAndResolveTokens(name: any, feature: Feature, canonical: CanonicalTileID, availableImages: Array<string>): string {
const value = this.layout.get(name).evaluate(feature, {}, canonical, availableImages);
const unevaluated = this._unevaluatedLayout._values[name];
if (!unevaluated.isDataDriven() && !isExpression(unevaluated.value) && value) {
Expand Down
48 changes: 8 additions & 40 deletions src/symbol/grid_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,39 +87,25 @@ class GridIndex {
this.circles.push(radius);
}

_insertBoxCell: ((
_insertBoxCell: (
x1: number,
y1: number,
x2: number,
y2: number,
cellIndex: number,
uid: number
) => void) = (
x1: number,
y1: number,
x2: number,
y2: number,
cellIndex: number,
uid: number
) => {
) => void = (x1, y1, x2, y2, cellIndex, uid) => {
this.boxCells[cellIndex].push(uid);
};

_insertCircleCell: ((
_insertCircleCell: (
x1: number,
y1: number,
x2: number,
y2: number,
cellIndex: number,
uid: number
) => void) = (
x1: number,
y1: number,
x2: number,
y2: number,
cellIndex: number,
uid: number
) => {
) => void = (x1, y1, x2, y2, cellIndex, uid) => {
this.circleCells[cellIndex].push(uid);
}

Expand Down Expand Up @@ -200,7 +186,7 @@ class GridIndex {
return (this._queryCircle(x, y, radius, true, predicate): any);
}

_queryCell: ((
_queryCell: (
x1: number,
y1: number,
x2: number,
Expand All @@ -209,16 +195,7 @@ class GridIndex {
result: any,
queryArgs: any,
predicate?: any
) => void | boolean) = (
x1: number,
y1: number,
x2: number,
y2: number,
cellIndex: number,
result: any,
queryArgs: any,
predicate?: any,
): void | boolean => {
) => void | boolean = (x1, y1, x2, y2, cellIndex, result, queryArgs, predicate?) => {
const seenUids = queryArgs.seenUids;
const boxCell = this.boxCells[cellIndex];
if (boxCell !== null) {
Expand Down Expand Up @@ -285,7 +262,7 @@ class GridIndex {
}
}

_queryCellCircle: ((
_queryCellCircle: (
x1: number,
y1: number,
x2: number,
Expand All @@ -294,16 +271,7 @@ class GridIndex {
result: any,
queryArgs: any,
predicate?: any
) => void | boolean) = (
x1: number,
y1: number,
x2: number,
y2: number,
cellIndex: number,
result: any,
queryArgs: any,
predicate?: any,
): void | boolean => {
) => void | boolean = (x1, y1, x2, y2, cellIndex, result, queryArgs, predicate?) => {
const circle = queryArgs.circle;
const seenUids = queryArgs.seenUids;
const boxCell = this.boxCells[cellIndex];
Expand Down
5 changes: 3 additions & 2 deletions src/ui/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import type {Callback} from '../types/callback.js';
import type {PointLike} from '@mapbox/point-geometry';
import {Aabb} from '../util/primitives.js';
import type {PaddingOptions} from '../geo/edge_insets.js';
import type {MapEvent} from './events.js';

/**
* A helper type: converts all Object type values to non-maybe types.
Expand Down Expand Up @@ -1782,7 +1783,7 @@ function addAssertions(camera: Camera) { //eslint-disable-line
['drag', 'zoom', 'rotate', 'pitch', 'move'].forEach(name => {
inProgress[name] = false;

camera.on(`${name}start`, () => {
camera.on(((`${name}start`: any): MapEvent), () => {
assert(!inProgress[name], `"${name}start" fired twice without a "${name}end"`);
inProgress[name] = true;
assert(inProgress.move);
Expand All @@ -1793,7 +1794,7 @@ function addAssertions(camera: Camera) { //eslint-disable-line
assert(inProgress.move);
});

camera.on(`${name}end`, () => {
camera.on(((`${name}end`: any): MapEvent), () => {
assert(inProgress.move);
assert(inProgress[name]);
inProgress[name] = false;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/control/attribution_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class AttributionControl {
}
};

_updateData: ((e: any) => void) = (e: any) => {
_updateData: (e: any) => void = (e) => {
if (e && (e.sourceDataType === 'metadata' || e.sourceDataType === 'visibility' || e.dataType === 'style')) {
this._updateAttributions();
this._updateEditLink();
Expand Down
8 changes: 4 additions & 4 deletions src/ui/control/geolocate_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class GeolocateControl extends Evented {
* @param {Position} position the Geolocation API Position
* @private
*/
_onSuccess: ((position: Position) => void) = (position: Position) => {
_onSuccess: (position: Position) => void = (position) => {
if (!this._map) {
// control has since been removed
return;
Expand Down Expand Up @@ -368,7 +368,7 @@ class GeolocateControl extends Evented {
}
};

_onError: ((error: PositionError) => void) = (error: PositionError) => {
_onError: (error: PositionError) => void = (error) => {
if (!this._map) {
// control has since been removed
return;
Expand Down Expand Up @@ -416,7 +416,7 @@ class GeolocateControl extends Evented {
this._timeoutId = undefined;
};

_setupUI: ((supported: boolean) => void) = (supported: boolean) => {
_setupUI: (supported: boolean) => void = (supported) => {
if (this._map === undefined) {
// This control was removed from the map before geolocation
// support was determined.
Expand Down Expand Up @@ -508,7 +508,7 @@ class GeolocateControl extends Evented {
* geolocate.trigger();
* });
*/
_onDeviceOrientation: ((deviceOrientationEvent: DeviceOrientationEvent) => void) = (deviceOrientationEvent: DeviceOrientationEvent) => {
_onDeviceOrientation: (deviceOrientationEvent: DeviceOrientationEvent) => void = (deviceOrientationEvent) => {
// absolute is true if the orientation data is provided as the difference between the Earth's coordinate frame and the device's coordinate frame, or false if the orientation data is being provided in reference to some arbitrary, device-determined coordinate frame.
if (this._userLocationDotMarker) {
if (deviceOrientationEvent.webkitCompassHeading) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/control/logo_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class LogoControl {
return 'bottom-left';
};

_updateLogo: ((e: any) => void) = (e: any) => {
_updateLogo: (e: any) => void = (e) => {
if (!e || e.sourceDataType === 'metadata') {
this._container.style.display = this._logoRequired() ? 'block' : 'none';
}
Expand Down
12 changes: 6 additions & 6 deletions src/ui/control/navigation_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,23 @@ class MouseRotateWrapper {
window.removeEventListener('mouseup', this.mouseup);
}

mousedown: ((e: MouseEvent) => void) = (e: MouseEvent) => {
mousedown: (e: MouseEvent) => void = (e) => {
this.down(extend({}, e, {ctrlKey: true, preventDefault: () => e.preventDefault()}), DOM.mousePos(this.element, e));
window.addEventListener('mousemove', this.mousemove);
window.addEventListener('mouseup', this.mouseup);
};

mousemove: ((e: MouseEvent) => void) = (e: MouseEvent) => {
mousemove: (e: MouseEvent) => void = (e) => {
this.move(e, DOM.mousePos(this.element, e));
};

mouseup: ((e: MouseEvent) => void) = (e: MouseEvent) => {
mouseup: (e: MouseEvent) => void = (e) => {
this.mouseRotate.mouseupWindow(e);
if (this.mousePitch) this.mousePitch.mouseupWindow(e);
this.offTemp();
};

touchstart: ((e: TouchEvent) => void) = (e: TouchEvent) => {
touchstart: (e: TouchEvent) => void = (e) => {
if (e.targetTouches.length !== 1) {
this.reset();
} else {
Expand All @@ -249,7 +249,7 @@ class MouseRotateWrapper {
}
};

touchmove: ((e: TouchEvent) => void) = (e: TouchEvent) => {
touchmove: (e: TouchEvent) => void = (e) => {
if (e.targetTouches.length !== 1) {
this.reset();
} else {
Expand All @@ -258,7 +258,7 @@ class MouseRotateWrapper {
}
};

touchend: ((e: TouchEvent) => void) = (e: TouchEvent) => {
touchend: (e: TouchEvent) => void = (e) => {
if (e.targetTouches.length === 0 &&
this._startPos &&
this._lastPos &&
Expand Down
27 changes: 27 additions & 0 deletions src/ui/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -1521,4 +1521,31 @@ export type MapEvent =
* });
*/
| 'speedindexcompleted'

/**
* Fired after RTL text plugin state changes.
*
* @event pluginStateChange
* @instance
* @private
*/
| 'pluginStateChange'

/**
* Fired in worker.js after sprite loaded.
*
* @event pluginStateChange
* @instance
* @private
*/
| 'isSpriteLoaded'

/**
* Fired in style.js after layer order changed.
*
* @event pluginStateChange
* @instance
* @private
*/
| 'neworder'
;
2 changes: 1 addition & 1 deletion src/ui/handler/box_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class BoxZoomHandler {
delete this._lastPos;
}

_fireEvent(type: string, e: *): Map {
_fireEvent(type: string, e: any): Map {
return this._map.fire(new Event(type, {originalEvent: e}));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/handler/scroll_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class ScrollZoomHandler {
e.preventDefault();
}

_onTimeout: ((initialEvent: WheelEvent) => void) = (initialEvent: WheelEvent) => {
_onTimeout: (initialEvent: WheelEvent) => void = (initialEvent) => {
this._type = 'wheel';
this._delta -= this._lastValue;
if (!this._active) {
Expand Down
6 changes: 3 additions & 3 deletions src/ui/handler_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class HandlerManager {
return false;
}

handleWindowEvent: ((e: InputEvent) => void) = (e: InputEvent) => {
handleWindowEvent: (e: InputEvent) => void = (e) => {
this.handleEvent(e, `${e.type}Window`);
}

Expand All @@ -354,7 +354,7 @@ class HandlerManager {
return ((mapTouches: any): TouchList);
}

handleEvent: ((e: InputEvent | RenderFrameEvent, eventName?: string) => void) = (e: InputEvent | RenderFrameEvent, eventName?: string) => {
handleEvent: (e: InputEvent | RenderFrameEvent, eventName?: string) => void = (e, eventName) => {

this._updatingCamera = true;
assert(e.timeStamp !== undefined);
Expand Down Expand Up @@ -673,7 +673,7 @@ class HandlerManager {

}

_fireEvent(type: string, e: *) {
_fireEvent(type: string, e: any) {
this._map.fire(new Event(type, e ? {originalEvent: e} : {}));
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class Hash {
return hash.split('/');
}

_onHashChange: (() => boolean) = (): boolean => {
_onHashChange: () => boolean = () => {
const map = this._map;
if (!map) return false;
const loc = this._getCurrentHash();
Expand Down
6 changes: 3 additions & 3 deletions src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -2993,7 +2993,7 @@ class Map extends Camera {
webpSupported.testSupport(gl);
}

_contextLost: (event: *) => void = (event: *) => {
_contextLost: (event: any) => void = (event) => {
event.preventDefault();
if (this._frame) {
this._frame.cancel();
Expand All @@ -3002,14 +3002,14 @@ class Map extends Camera {
this.fire(new Event('webglcontextlost', {originalEvent: event}));
}

_contextRestored: (event: *) => void = (event: *) => {
_contextRestored: (event: any) => void = (event) => {
this._setupPainter();
this.resize();
this._update();
this.fire(new Event('webglcontextrestored', {originalEvent: event}));
}

_onMapScroll: (event: *) => ?boolean = (event: *) => {
_onMapScroll: (event: any) => ?boolean = (event) => {
if (event.target !== this._container) return;

// Revert any scroll which would move the canvas outside of the view
Expand Down
Loading

0 comments on commit 0d683be

Please sign in to comment.