Skip to content

Commit

Permalink
Upgrade flow to 0.77
Browse files Browse the repository at this point in the history
  • Loading branch information
Anand Thakker committed Aug 3, 2018
1 parent 3ffa20a commit a7331de
Show file tree
Hide file tree
Showing 37 changed files with 74 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
.*/test/integration/render-tests/.*

[version]
0.69.0
0.77.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"eslint-plugin-react": "^7.3.0",
"esm": "^3.0.72",
"execcommand-copy": "^1.1.0",
"flow-bin": "^0.69.0",
"flow-bin": "^0.77.0",
"flow-coverage-report": "^0.3.0",
"github-slugger": "^1.1.1",
"gl": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/render/draw_background.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function drawBackground(painter: Painter, sourceCache: SourceCache, layer: Backg
painter.tileExtentPatternVAO.bind(context, program, painter.tileExtentBuffer, []);
} else {
program = painter.useProgram('background');
gl.uniform4fv(program.uniforms.u_color, [color.r, color.g, color.b, color.a]);
gl.uniform4fv(program.uniforms.u_color, ([color.r, color.g, color.b, color.a]: Array<number>));
painter.tileExtentVAO.bind(context, program, painter.tileExtentBuffer, []);
}

Expand Down
2 changes: 1 addition & 1 deletion src/render/draw_fill_extrusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function setLight(program, painter) {

const color = light.properties.get('color');

gl.uniform3fv(program.uniforms.u_lightpos, lightPos);
gl.uniform3fv(program.uniforms.u_lightpos, (lightPos: Array<number>));
gl.uniform1f(program.uniforms.u_lightintensity, light.properties.get('intensity'));
gl.uniform3f(program.uniforms.u_lightcolor, color.r, color.g, color.b);
}
4 changes: 2 additions & 2 deletions src/render/draw_hillshade.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function renderHillshade(painter, tile, layer) {
gl.bindTexture(gl.TEXTURE_2D, fbo.colorAttachment.get());

gl.uniformMatrix4fv(program.uniforms.u_matrix, false, posMatrix);
gl.uniform2fv(program.uniforms.u_latrange, latRange);
gl.uniform2fv(program.uniforms.u_latrange, (latRange: Array<number>));
gl.uniform1i(program.uniforms.u_image, 0);

const shadowColor = layer.paint.get("hillshade-shadow-color");
Expand Down Expand Up @@ -154,7 +154,7 @@ function prepareHillshade(painter, tile, sourceMaxZoom) {

gl.uniformMatrix4fv(program.uniforms.u_matrix, false, matrix);
gl.uniform1f(program.uniforms.u_zoom, tile.tileID.overscaledZ);
gl.uniform2fv(program.uniforms.u_dimension, [tileSize * 2, tileSize * 2]);
gl.uniform2fv(program.uniforms.u_dimension, ([tileSize * 2, tileSize * 2]: Array<number>));
gl.uniform1i(program.uniforms.u_image, 1);
gl.uniform1f(program.uniforms.u_maxzoom, sourceMaxZoom);

Expand Down
2 changes: 1 addition & 1 deletion src/render/draw_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function drawLineTile(program, painter, tile, bucket, layer, coord, programConfi
gl.uniform2f(program.uniforms.u_pattern_size_b, imagePosB.displaySize[0] * image.toScale / tileRatio, imagePosB.displaySize[1]);

const {width, height} = painter.imageManager.getPixelSize();
gl.uniform2fv(program.uniforms.u_texsize, [width, height]);
gl.uniform2fv(program.uniforms.u_texsize, ([width, height]: Array<number>));
}

gl.uniform2f(program.uniforms.u_gl_units_to_pixels, 1 / painter.transform.pixelsToGLUnits[0], 1 / painter.transform.pixelsToGLUnits[1]);
Expand Down
4 changes: 2 additions & 2 deletions src/render/draw_raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterSty
gl.uniform1f(program.uniforms.u_brightness_high, layer.paint.get('raster-brightness-max'));
gl.uniform1f(program.uniforms.u_saturation_factor, saturationFactor(layer.paint.get('raster-saturation')));
gl.uniform1f(program.uniforms.u_contrast_factor, contrastFactor(layer.paint.get('raster-contrast')));
gl.uniform3fv(program.uniforms.u_spin_weights, spinWeights(layer.paint.get('raster-hue-rotate')));
gl.uniform3fv(program.uniforms.u_spin_weights, (spinWeights(layer.paint.get('raster-hue-rotate')): Array<number>));
gl.uniform1f(program.uniforms.u_buffer_scale, 1);
gl.uniform1i(program.uniforms.u_image0, 0);
gl.uniform1i(program.uniforms.u_image1, 1);
Expand Down Expand Up @@ -73,7 +73,7 @@ function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterSty
}

// cross-fade parameters
gl.uniform2fv(program.uniforms.u_tl_parent, parentTL || [0, 0]);
gl.uniform2fv(program.uniforms.u_tl_parent, ((parentTL || [0, 0]): Array<number>));
gl.uniform1f(program.uniforms.u_scale_parent, parentScaleBy || 1);
gl.uniform1f(program.uniforms.u_fade_t, fade.mix);
gl.uniform1f(program.uniforms.u_opacity, fade.opacity * layer.paint.get('raster-opacity'));
Expand Down
2 changes: 1 addition & 1 deletion src/render/image_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ImageManager {
}
}

listImages() {
listImages(): Array<string> {
return Object.keys(this.images);
}

Expand Down
2 changes: 1 addition & 1 deletion src/render/pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const prepare = function (image: CrossFaded<string>, painter: Painter, pr
gl.uniform2fv(program.uniforms.u_pattern_tl_b, (imagePosB: any).tl);
gl.uniform2fv(program.uniforms.u_pattern_br_b, (imagePosB: any).br);
const {width, height} = painter.imageManager.getPixelSize();
gl.uniform2fv(program.uniforms.u_texsize, [width, height]);
gl.uniform2fv(program.uniforms.u_texsize, ([width, height]: Array<number>));
gl.uniform1f(program.uniforms.u_mix, image.t);
gl.uniform2fv(program.uniforms.u_pattern_size_a, (imagePosA: any).displaySize);
gl.uniform2fv(program.uniforms.u_pattern_size_b, (imagePosB: any).displaySize);
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 @@ -180,7 +180,7 @@ class SourceCache extends Evented {
return Object.keys(this._tiles).map(Number).sort(compareKeyZoom);
}

getRenderableIds(symbolLayer?: boolean) {
getRenderableIds(symbolLayer?: boolean): Array<number> {
const ids = [];
for (const id in this._tiles) {
if (this._isIdRenderable(+id, symbolLayer)) ids.push(+id);
Expand Down Expand Up @@ -791,7 +791,7 @@ class SourceCache extends Evented {
return tileResults;
}

getVisibleCoordinates(symbolLayer?: boolean) {
getVisibleCoordinates(symbolLayer?: boolean): Array<OverscaledTileID> {
const coords = this.getRenderableIds(symbolLayer).map((id) => this._tiles[id].tileID);
for (const coord of coords) {
coord.posMatrix = this.transform.calculatePosMatrix(coord.toUnwrapped());
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/compound_expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CompoundExpression implements Expression {
return [undefined];
}

serialize() {
serialize(): Array<mixed> {
return [this.name].concat(this.args.map(arg => arg.serialize()));
}

Expand Down
5 changes: 3 additions & 2 deletions src/style-spec/expression/definitions/assertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { typeOf } from '../values';
import type { Expression } from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type { Value } from '../values';
import type { Type } from '../types';

const types = {
Expand Down Expand Up @@ -73,11 +74,11 @@ class Assertion implements Expression {
this.args.forEach(fn);
}

possibleOutputs() {
possibleOutputs(): Array<Value | void> {
return [].concat(...this.args.map((arg) => arg.possibleOutputs()));
}

serialize() {
serialize(): Array<mixed> {
return [this.type.kind].concat(this.args.map(arg => arg.serialize()));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/style-spec/expression/definitions/case.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { BooleanType } from '../types';
import type { Expression } from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type { Value } from '../values';
import type { Type } from '../types';

type Branches = Array<[Expression, Expression]>;
Expand Down Expand Up @@ -71,7 +72,7 @@ class Case implements Expression {
fn(this.otherwise);
}

possibleOutputs() {
possibleOutputs(): Array<Value | void> {
return []
.concat(...this.branches.map(([_, out]) => out.possibleOutputs()))
.concat(this.otherwise.possibleOutputs());
Expand Down
3 changes: 2 additions & 1 deletion src/style-spec/expression/definitions/coalesce.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { checkSubtype, ValueType } from '../types';
import type { Expression } from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type { Value } from '../values';
import type { Type } from '../types';

class Coalesce implements Expression {
Expand Down Expand Up @@ -63,7 +64,7 @@ class Coalesce implements Expression {
this.args.forEach(fn);
}

possibleOutputs() {
possibleOutputs(): Array<Value | void> {
return [].concat(...this.args.map((arg) => arg.possibleOutputs()));
}

Expand Down
3 changes: 2 additions & 1 deletion src/style-spec/expression/definitions/coercion.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import RuntimeError from '../runtime_error';
import type { Expression } from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type { Value } from '../values';
import type { Type } from '../types';

const types = {
Expand Down Expand Up @@ -90,7 +91,7 @@ class Coercion implements Expression {
this.args.forEach(fn);
}

possibleOutputs() {
possibleOutputs(): Array<Value | void> {
return [].concat(...this.args.map((arg) => arg.possibleOutputs()));
}

Expand Down
5 changes: 3 additions & 2 deletions src/style-spec/expression/definitions/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { Stops } from '../stops';
import type { Expression } from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type { Value } from '../values';
import type { Type } from '../types';

export type InterpolationType =
Expand Down Expand Up @@ -175,11 +176,11 @@ class Interpolate implements Expression {
}
}

possibleOutputs() {
possibleOutputs(): Array<Value | void> {
return [].concat(...this.outputs.map((output) => output.possibleOutputs()));
}

serialize() {
serialize(): Array<mixed> {
let interpolation;
if (this.interpolation.name === 'linear') {
interpolation = ["linear"];
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/literal.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Literal implements Expression {
return [this.value];
}

serialize() {
serialize(): Array<mixed> {
if (this.type.kind === 'array' || this.type.kind === 'object') {
return ["literal", this.value];
} else if (this.value instanceof Color) {
Expand Down
5 changes: 3 additions & 2 deletions src/style-spec/expression/definitions/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ValueType, type Type } from '../types';
import type { Expression } from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type { Value } from '../values';

// Map input label values to output expression index
type Cases = {[number | string]: number};
Expand Down Expand Up @@ -111,13 +112,13 @@ class Match implements Expression {
fn(this.otherwise);
}

possibleOutputs() {
possibleOutputs(): Array<Value | void> {
return []
.concat(...this.outputs.map((out) => out.possibleOutputs()))
.concat(this.otherwise.possibleOutputs());
}

serialize() {
serialize(): Array<mixed> {
const serialized = ["match", this.input.serialize()];

// Sort so serialization has an arbitrary defined order, even though
Expand Down
3 changes: 2 additions & 1 deletion src/style-spec/expression/definitions/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { Stops } from '../stops';
import type { Expression } from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type { Value } from '../values';
import type { Type } from '../types';

class Step implements Expression {
Expand Down Expand Up @@ -105,7 +106,7 @@ class Step implements Expression {
}
}

possibleOutputs() {
possibleOutputs(): Array<Value | void> {
return [].concat(...this.outputs.map((output) => output.possibleOutputs()));
}

Expand Down
5 changes: 2 additions & 3 deletions src/style-spec/function/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function convertFunction(parameters: PropertyValueSpecification<any>, propertySp
return expression;
}

function convertIdentityFunction(parameters, propertySpec, defaultExpression) {
function convertIdentityFunction(parameters, propertySpec, defaultExpression): Array<mixed> {
const get = ['get', parameters.property];

if (propertySpec.type === 'color') {
Expand Down Expand Up @@ -235,8 +235,7 @@ function convertTokenString(s) {
const result = ['concat'];
const re = /{([^{}]+)}/g;
let pos = 0;
let match;
while ((match = re.exec(s)) !== null) {
for (let match = re.exec(s); match !== null; match = re.exec(s)) {
const literal = s.slice(pos, re.lastIndex - match[0].length);
pos = re.lastIndex;
if (literal.length > 0) result.push(literal);
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/util/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function color(from: Color, to: Color, t: number) {
);
}

export function array(from: Array<number>, to: Array<number>, t: number) {
export function array(from: Array<number>, to: Array<number>, t: number): Array<number> {
return from.map((d, i) => {
return number(d, to[i], t);
});
Expand Down
2 changes: 1 addition & 1 deletion src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class Style extends Evented {
return true;
}

_serializeLayers(ids: Array<string>) {
_serializeLayers(ids: Array<string>): Array<Object> {
return ids.map((id) => this._layers[id].serialize());
}

Expand Down
2 changes: 1 addition & 1 deletion src/style/style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class StyleLayer extends Evented {
pixelsToTileUnits: number,
posMatrix: Float32Array) => boolean;

constructor(layer: LayerSpecification, properties: {layout?: Properties<*>, paint: Properties<*>}) {
constructor(layer: LayerSpecification, properties: $ReadOnly<{layout?: Properties<*>, paint: Properties<*>}>) {
super();

this.id = layer.id;
Expand Down
4 changes: 3 additions & 1 deletion src/style/style_layer/background_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ const paint: Properties<PaintProps> = new Properties({
"background-opacity": new DataConstantProperty(styleSpec["paint_background"]["background-opacity"]),
});

export default { paint };
export default ({ paint }: $Exact<{
paint: Properties<PaintProps>
}>);
4 changes: 3 additions & 1 deletion src/style/style_layer/circle_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ const paint: Properties<PaintProps> = new Properties({
"circle-stroke-opacity": new DataDrivenProperty(styleSpec["paint_circle"]["circle-stroke-opacity"]),
});

export default { paint };
export default ({ paint }: $Exact<{
paint: Properties<PaintProps>
}>);
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ const paint: Properties<PaintProps> = new Properties({
"fill-extrusion-base": new DataDrivenProperty(styleSpec["paint_fill-extrusion"]["fill-extrusion-base"]),
});

export default { paint };
export default ({ paint }: $Exact<{
paint: Properties<PaintProps>
}>);
4 changes: 3 additions & 1 deletion src/style/style_layer/fill_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ const paint: Properties<PaintProps> = new Properties({
"fill-pattern": new CrossFadedProperty(styleSpec["paint_fill"]["fill-pattern"]),
});

export default { paint };
export default ({ paint }: $Exact<{
paint: Properties<PaintProps>
}>);
4 changes: 3 additions & 1 deletion src/style/style_layer/heatmap_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ const paint: Properties<PaintProps> = new Properties({
"heatmap-opacity": new DataConstantProperty(styleSpec["paint_heatmap"]["heatmap-opacity"]),
});

export default { paint };
export default ({ paint }: $Exact<{
paint: Properties<PaintProps>
}>);
4 changes: 3 additions & 1 deletion src/style/style_layer/hillshade_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ const paint: Properties<PaintProps> = new Properties({
"hillshade-accent-color": new DataConstantProperty(styleSpec["paint_hillshade"]["hillshade-accent-color"]),
});

export default { paint };
export default ({ paint }: $Exact<{
paint: Properties<PaintProps>
}>);
4 changes: 3 additions & 1 deletion src/style/style_layer/layer_properties.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ const paint: Properties<PaintProps> = new Properties({
<% } -%>
});

export default { paint<% if (layoutProperties.length) { %>, layout<% } %> };
export default ({ paint<% if (layoutProperties.length) { %>, layout<% } %> }: $Exact<{
paint: Properties<PaintProps><% if (layoutProperties.length) { %>, layout: Properties<LayoutProps><% } %>
}>);
4 changes: 3 additions & 1 deletion src/style/style_layer/line_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ const paint: Properties<PaintProps> = new Properties({
"line-gradient": new ColorRampProperty(styleSpec["paint_line"]["line-gradient"]),
});

export default { paint, layout };
export default ({ paint, layout }: $Exact<{
paint: Properties<PaintProps>, layout: Properties<LayoutProps>
}>);
4 changes: 3 additions & 1 deletion src/style/style_layer/raster_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ const paint: Properties<PaintProps> = new Properties({
"raster-fade-duration": new DataConstantProperty(styleSpec["paint_raster"]["raster-fade-duration"]),
});

export default { paint };
export default ({ paint }: $Exact<{
paint: Properties<PaintProps>
}>);
4 changes: 3 additions & 1 deletion src/style/style_layer/symbol_style_layer_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,6 @@ const paint: Properties<PaintProps> = new Properties({
"text-translate-anchor": new DataConstantProperty(styleSpec["paint_symbol"]["text-translate-anchor"]),
});

export default { paint, layout };
export default ({ paint, layout }: $Exact<{
paint: Properties<PaintProps>, layout: Properties<LayoutProps>
}>);
Loading

0 comments on commit a7331de

Please sign in to comment.