Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flow] Add more missing export types to source/* #11496

Merged
merged 1 commit into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/render/draw_fill_extrusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import StencilMode from '../gl/stencil_mode.js';
import ColorMode from '../gl/color_mode.js';
import CullFaceMode from '../gl/cull_face_mode.js';
import EXTENT from '../data/extent.js';
import FillExtrusionBucket from '../data/bucket/fill_extrusion_bucket.js';
import {
fillExtrusionUniformValues,
fillExtrusionPatternUniformValues,
Expand All @@ -16,7 +17,6 @@ import assert from 'assert';
import type Painter from './painter.js';
import type SourceCache from '../source/source_cache.js';
import type FillExtrusionStyleLayer from '../style/style_layer/fill_extrusion_style_layer.js';
import type FillExtrusionBucket from '../data/bucket/fill_extrusion_bucket.js';

export default draw;

Expand Down Expand Up @@ -208,8 +208,8 @@ function flatRoofsUpdate(context, source, coord, bucket, layer, terrain) {
if (a.length === 0) { bucket.borderDone[i] = true; }
if (bucket.borderDone[i]) continue;
const nid = neighborTileID = neighborCoord[i](coord);
const nBucket: ?FillExtrusionBucket = getLoadedBucket(nid);
if (!nBucket || !nBucket.enableTerrain) continue;
const nBucket = getLoadedBucket(nid);
if (!nBucket || !(nBucket instanceof FillExtrusionBucket) || !nBucket.enableTerrain) continue;

neighborDEMTile = terrain.findDEMTileFor(nid);
if (!neighborDEMTile || !neighborDEMTile.dem) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/source/rtl_text_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const getRTLTextPluginStatus = function (): string {
return pluginStatus;
};

export const registerForPluginStateChange = function(callback: PluginStateSyncCallback) {
export const registerForPluginStateChange = function(callback: PluginStateSyncCallback): PluginStateSyncCallback {
// Do an initial sync of the state
callback({pluginStatus, pluginURL});
// Listen for all future state changes
Expand Down
6 changes: 3 additions & 3 deletions src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ class SourceCache extends Evented {
if (this.transform) this.update(this.transform);
}

_loadTile(tile: Tile, callback: Callback<void>) {
_loadTile(tile: Tile, callback: Callback<void>): void {
tile.isSymbolTile = this._onlySymbols;
return this._source.loadTile(tile, callback);
}

_unloadTile(tile: Tile) {
_unloadTile(tile: Tile): void {
if (this._source.unloadTile)
return this._source.unloadTile(tile, () => {});
}

_abortTile(tile: Tile) {
_abortTile(tile: Tile): void {
if (this._source.abortTile)
return this._source.abortTile(tile, () => {});
}
Expand Down
16 changes: 8 additions & 8 deletions src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ class Tile {
this.fadeEndTime = fadeEndTime;
}

wasRequested() {
wasRequested(): boolean {
return this.state === 'errored' || this.state === 'loaded' || this.state === 'reloading';
}

get tileTransform() {
get tileTransform(): TileTransform {
if (!this._tileTransform) {
this._tileTransform = tileTransform(this.tileID.canonical, this.projection);
}
Expand Down Expand Up @@ -346,7 +346,7 @@ class Tile {
this.state = 'unloaded';
}

getBucket(layer: StyleLayer) {
getBucket(layer: StyleLayer): Bucket {
return this.buckets[layer.id];
}

Expand Down Expand Up @@ -450,12 +450,12 @@ class Tile {
}
}

hasData() {
hasData(): boolean {
return this.state === 'loaded' || this.state === 'reloading' || this.state === 'expired';
}

patternsLoaded() {
return this.imageAtlas && !!Object.keys(this.imageAtlas.patternPositions).length;
patternsLoaded(): boolean {
return !!this.imageAtlas && !!Object.keys(this.imageAtlas.patternPositions).length;
}

setExpiryData(data: any) {
Expand Down Expand Up @@ -507,7 +507,7 @@ class Tile {
}
}

getExpiryTimeout() {
getExpiryTimeout(): void | number {
if (this.expirationTime) {
if (this.expiredRequestCount) {
return 1000 * (1 << Math.min(this.expiredRequestCount - 1, 31));
Expand Down Expand Up @@ -579,7 +579,7 @@ class Tile {
this.dependencies[namespace] = index;
}

hasDependency(namespaces: Array<string>, keys: Array<string>) {
hasDependency(namespaces: Array<string>, keys: Array<string>): boolean {
for (const namespace of namespaces) {
const dependencies = this.dependencies[namespace];
if (dependencies) {
Expand Down
6 changes: 3 additions & 3 deletions src/source/tile_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TileCache {
* @returns {TileCache} Returns itself to allow for method chaining.
* @private
*/
reset() {
reset(): this {
for (const key in this.data) {
for (const removedData of this.data[key]) {
if (removedData.timeout) clearTimeout(removedData.timeout);
Expand All @@ -56,7 +56,7 @@ class TileCache {
* @returns {TileCache} Returns itself to allow for method chaining.
* @private
*/
add(tileID: OverscaledTileID, data: Tile, expiryTimeout: number | void) {
add(tileID: OverscaledTileID, data: Tile, expiryTimeout: number | void): this {
const key = tileID.wrapped().key;
if (this.data[key] === undefined) {
this.data[key] = [];
Expand Down Expand Up @@ -154,7 +154,7 @@ class TileCache {
* @returns {TileCache} this cache
* @private
*/
remove(tileID: OverscaledTileID, value: ?{ value: Tile, timeout: ?TimeoutID}) {
remove(tileID: OverscaledTileID, value: ?{ value: Tile, timeout: ?TimeoutID}): this {
if (!this.has(tileID)) { return this; }
const key = tileID.wrapped().key;

Expand Down
5 changes: 3 additions & 2 deletions src/style/style_layer/fill_extrusion_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class FillExtrusionStyleLayer extends StyleLayer {
const centroid = [0, 0];
const terrainVisible = elevationHelper && transform.elevation;
const exaggeration = transform.elevation ? transform.elevation.exaggeration() : 1;
if (terrainVisible) {
const centroidVertexArray = queryGeometry.tile.getBucket(this).centroidVertexArray;
const bucket = queryGeometry.tile.getBucket(this);
if (terrainVisible && bucket instanceof FillExtrusionBucket) {
const centroidVertexArray = bucket.centroidVertexArray;

// See FillExtrusionBucket#encodeCentroid(), centroid is inserted at vertexOffset + 1
const centroidOffset = layoutVertexArrayOffset + 1;
Expand Down