Skip to content

Commit 1333274

Browse files
committed
Merge branch 'mapbox'
2 parents 0d02cba + 1a36eca commit 1333274

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1682
-1107
lines changed

.flowconfig

+1-19
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,38 @@
22
.*\.svg
33
.*\.png
44
.*/\.nyc_output/.*
5-
.*/docs/.*
65
.*/node_modules/.cache/.*
76
.*/node_modules/.*/tests?/.*
87
.*/node_modules/@mapbox/jsonlint-lines-primitives/.*
98
.*/node_modules/@mapbox/mvt-fixtures/.*
109
.*/node_modules/@mapbox/geojson-types/fixtures/.*
11-
.*/node_modules/@mapbox/mr-ui/.*
12-
.*/node_modules/@mapbox/dr-ui/.*
13-
.*/node_modules/@mapbox/batfish/.*
1410
.*/node_modules/browserify/.*
15-
.*/node_modules/browser-sync.*/.*
1611
.*/node_modules/nyc/.*
17-
.*/node_modules/fbjs/.*
18-
.*/node_modules/es5-ext/.*
1912
.*/node_modules/jsdom/.*
2013
.*/node_modules/eslint.*/.*
2114
.*/node_modules/highlight.*/.*
22-
.*/node_modules/rxjs/.*
2315
.*/node_modules/@?babel.*/.*
2416
.*/node_modules/svgo/.*
25-
.*/node_modules/moment/.*
26-
.*/node_modules/regenerate-unicode-properties/.*
2717
.*/node_modules/remark.*/.*
28-
.*/node_modules/webpack/.*
2918
.*/node_modules/caniuse-lite/.*
3019
.*/node_modules/d3.*/.*
3120
.*/node_modules/css-tree/.*
3221
.*/node_modules/lodash/.*
3322
.*/node_modules/fsevents/.*
34-
.*/node_modules/browser-sync-client/.*
35-
.*/node_modules/core-js.*/.*
3623
.*/node_modules/stylelint/.*
3724
.*/node_modules/postcss.*/.*
38-
.*/node_modules/prismjs.*/.*
3925
.*/node_modules/documentation/.*
4026
.*/node_modules/module-deps/.*
4127
.*/test/unit/style-spec/fixture/invalidjson.input.json
4228
.*/render-tests/.*
4329
.*/query-tests/.*
4430
.*/expression-tests/.*
4531
.*/test/build/downstream-flow-fixture/.*
46-
.*/_batfish_tmp/.*
47-
.*/_site/.*
4832

4933
[version]
50-
0.142.0
34+
0.145.0
5135

5236
[options]
53-
server.max_workers=4
54-
merge_timeout=180
5537

5638
[strict]
5739
nonstrict-import

bench/benchmarks/query_box.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ export default class QueryBox extends Benchmark {
3737
}
3838

3939
bench() {
40+
const p = [0, 0];
4041
for (const map of this.maps) {
41-
map.queryRenderedFeatures({});
42+
map.queryRenderedFeatures(p);
4243
}
4344
}
4445

bench/lib/tile_parser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22

33
import Protobuf from 'pbf';
4-
import VT from '@mapbox/vector-tile';
4+
import {VectorTile} from '@mapbox/vector-tile';
55
import assert from 'assert';
66

77
import deref from '../../src/style-spec/deref.js';
@@ -137,7 +137,7 @@ export default class TileParser {
137137
projection: getProjection({name: 'mercator'})
138138
});
139139

140-
const vectorTile = new VT.VectorTile(new Protobuf(tile.buffer));
140+
const vectorTile = new VectorTile(new Protobuf(tile.buffer));
141141

142142
return new Promise((resolve, reject) => {
143143
workerTile.parse(vectorTile, this.layerIndex, [], (this.actor: any), (err, result) => {

flow-typed/geojson.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// @flow strict
2+
3+
type GeoJSONPosition = [number, number] | [number, number, number];
4+
type Geometry<T, C> = { type: T, coordinates: C }
5+
6+
declare module "@mapbox/geojson-types" {
7+
declare export type GeoJSONPoint = Geometry<'Point', GeoJSONPosition>;
8+
declare export type GeoJSONMultiPoint = Geometry<'MultiPoint', Array<GeoJSONPosition>>;
9+
10+
declare export type GeoJSONLineString = Geometry<'LineString', Array<GeoJSONPosition>>;
11+
declare export type GeoJSONMultiLineString = Geometry<'MultiLineString', Array<Array<GeoJSONPosition>>>;
12+
13+
declare export type GeoJSONPolygon = Geometry<'Polygon', Array<Array<GeoJSONPosition>>>;
14+
declare export type GeoJSONMultiPolygon = Geometry<'MultiPolygon', Array<Array<Array<GeoJSONPosition>>>>;
15+
16+
declare export type GeoJSONGeometry =
17+
| GeoJSONPoint
18+
| GeoJSONMultiPoint
19+
| GeoJSONLineString
20+
| GeoJSONMultiLineString
21+
| GeoJSONPolygon
22+
| GeoJSONMultiPolygon
23+
| GeoJSONGeometryCollection;
24+
25+
declare export type GeoJSONGeometryCollection = {
26+
type: 'GeometryCollection',
27+
geometries: Array<GeoJSONGeometry>
28+
};
29+
30+
declare export type GeoJSONFeature = {
31+
type: 'Feature',
32+
geometry: ?GeoJSONGeometry,
33+
properties: ?{},
34+
id?: number | string
35+
};
36+
37+
declare export type GeoJSONFeatureCollection = {
38+
type: 'FeatureCollection',
39+
features: Array<GeoJSONFeature>
40+
};
41+
42+
declare export type GeoJSON = GeoJSONGeometry | GeoJSONFeature | GeoJSONFeatureCollection;
43+
}

flow-typed/jsdom.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// @flow strict
22

3-
import type Window from '../src/types/window';
4-
53
declare module "jsdom" {
64
declare class JSDOM {
75
constructor(content: string, options: Object): JSDOM;
8-
window: Window;
6+
window: WindowProxy;
97
}
108
declare class VirtualConsole {
119
constructor(): VirtualConsole;

flow-typed/vector-tile.js

+38-31
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,49 @@
11
// @flow
2-
import type Pbf from 'pbf';
3-
import type Point from '@mapbox/point-geometry';
4-
import type { GeoJSONFeature } from '@mapbox/geojson-types';
5-
6-
declare interface VectorTile {
7-
layers: {[_: string]: VectorTileLayer};
8-
}
9-
10-
declare interface VectorTileLayer {
11-
version?: number;
12-
name: string;
13-
extent: number;
14-
length: number;
15-
feature(i: number): VectorTileFeature;
16-
}
2+
declare module "@mapbox/vector-tile" {
3+
import type Pbf from 'pbf';
4+
import type Point from '@mapbox/point-geometry';
5+
import type { GeoJSONFeature } from '@mapbox/geojson-types';
176

18-
declare interface VectorTileFeature {
19-
extent: number;
20-
type: 1 | 2 | 3;
21-
id: number;
22-
properties: {[_: string]: string | number | boolean};
7+
declare export interface IVectorTile {
8+
layers: {[_: string]: IVectorTileLayer};
9+
}
10+
declare export interface IVectorTileLayer {
11+
version?: ?number;
12+
name: string;
13+
extent: number;
14+
length: number;
15+
feature(i: number): IVectorTileFeature;
16+
}
17+
declare export interface IVectorTileFeature {
18+
extent: number;
19+
type: 1 | 2 | 3;
20+
id: number;
21+
properties: {[_: string]: string | number | boolean};
2322

24-
loadGeometry(): Array<Array<Point>>;
25-
toGeoJSON(x: number, y: number, z: number): GeoJSONFeature;
26-
}
23+
loadGeometry(): Array<Array<Point>>;
24+
toGeoJSON(x: number, y: number, z: number): GeoJSONFeature;
25+
}
2726

28-
declare module "@mapbox/vector-tile" {
29-
declare class VectorTileImpl {
27+
declare export class VectorTile implements IVectorTile {
3028
constructor(pbf: Pbf): VectorTile;
29+
layers: {[_: string]: IVectorTileLayer};
30+
}
31+
declare export class VectorTileLayer implements IVectorTileLayer {
32+
version?: ?number;
33+
name: string;
34+
extent: number;
35+
length: number;
36+
feature(i: number): IVectorTileFeature;
3137
}
38+
declare export class VectorTileFeature implements IVectorTileFeature {
39+
extent: number;
40+
type: 1 | 2 | 3;
41+
id: number;
42+
properties: {[_: string]: string | number | boolean};
3243

33-
declare class VectorTileFeatureImpl {
34-
static types: ['Unknown', 'Point', 'LineString', 'Polygon'];
44+
loadGeometry(): Array<Array<Point>>;
3545
toGeoJSON(x: number, y: number, z: number): GeoJSONFeature;
36-
}
3746

38-
declare module.exports: {
39-
VectorTile: typeof VectorTileImpl;
40-
VectorTileFeature: typeof VectorTileFeatureImpl;
47+
static types: ['Unknown', 'Point', 'LineString', 'Polygon'];
4148
}
4249
}

package.json

+9-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
},
1313
"dependencies": {
1414
"@mapbox/geojson-rewind": "^0.5.2",
15-
"@mapbox/geojson-types": "^1.0.2",
1615
"@mapbox/jsonlint-lines-primitives": "^2.0.2",
1716
"@mapbox/mapbox-gl-supported": "^2.0.1",
1817
"@mapbox/point-geometry": "^0.1.0",
@@ -27,7 +26,7 @@
2726
"grid-index": "^1.1.0",
2827
"murmurhash-js": "^1.0.0",
2928
"pbf": "^3.2.1",
30-
"potpack": "^1.0.2",
29+
"potpack": "^2.0.0",
3130
"quickselect": "^2.0.0",
3231
"rw": "^1.3.3",
3332
"supercluster": "^7.1.5",
@@ -41,11 +40,11 @@
4140
"@mapbox/flow-remove-types": "^2.0.0",
4241
"@mapbox/mvt-fixtures": "^3.10.0",
4342
"@octokit/rest": "^19.0.4",
44-
"@rollup/plugin-commonjs": "^22.0.2",
45-
"@rollup/plugin-json": "^4.1.0",
46-
"@rollup/plugin-node-resolve": "^14.1.0",
47-
"@rollup/plugin-replace": "^4.0.0",
48-
"@rollup/plugin-strip": "^2.1.0",
43+
"@rollup/plugin-commonjs": "^23.0.0",
44+
"@rollup/plugin-json": "^5.0.0",
45+
"@rollup/plugin-node-resolve": "^15.0.0",
46+
"@rollup/plugin-replace": "^5.0.0",
47+
"@rollup/plugin-strip": "^3.0.0",
4948
"address": "^1.2.0",
5049
"browserify": "^17.0.0",
5150
"chalk": "^5.0.1",
@@ -63,11 +62,11 @@
6362
"eslint-plugin-html": "^7.1.0",
6463
"eslint-plugin-import": "^2.26.0",
6564
"eslint-plugin-jsdoc": "^39.3.6",
66-
"flow-bin": "0.142.0",
65+
"flow-bin": "0.145.0",
6766
"gl": "5.0.3",
6867
"glob": "^8.0.3",
6968
"is-builtin-module": "^3.2.0",
70-
"jsdom": "^14.1.0",
69+
"jsdom": "^15.2.1",
7170
"json-stringify-pretty-compact": "^4.0.0",
7271
"lodash.template": "^4.5.0",
7372
"mapbox-gl-styles": "^2.0.2",
@@ -82,7 +81,7 @@
8281
"postcss-cli": "^10.0.0",
8382
"postcss-inline-svg": "^5.0.0",
8483
"pretty-bytes": "^6.0.0",
85-
"puppeteer-core": "^18.0.2",
84+
"puppeteer-core": "^19.0.0",
8685
"qrcode-terminal": "^0.12.0",
8786
"rollup": "^2.78.1",
8887
"rollup-plugin-sourcemaps": "^0.6.3",

src/data/bucket.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {CanonicalTileID} from '../source/tile_id.js';
1212
import type {TileTransform} from '../geo/projection/tile_transform.js';
1313
import type Point from '@mapbox/point-geometry';
1414
import type {ProjectionSpecification} from '../style-spec/types.js';
15+
import type {IVectorTileFeature, IVectorTileLayer} from '@mapbox/vector-tile';
1516

1617
export type BucketParameters<Layer: TypedStyleLayer> = {
1718
index: number,
@@ -37,7 +38,7 @@ export type PopulateParameters = {
3738
}
3839

3940
export type IndexedFeature = {
40-
feature: VectorTileFeature,
41+
feature: IVectorTileFeature,
4142
id: number | string | void,
4243
index: number,
4344
sourceLayerIndex: number,
@@ -84,7 +85,7 @@ export interface Bucket {
8485
+stateDependentLayers: Array<any>;
8586
+stateDependentLayerIds: Array<string>;
8687
populate(features: Array<IndexedFeature>, options: PopulateParameters, canonical: CanonicalTileID, tileTransform: TileTransform): void;
87-
update(states: FeatureStates, vtLayer: VectorTileLayer, availableImages: Array<string>, imagePositions: SpritePositions): void;
88+
update(states: FeatureStates, vtLayer: IVectorTileLayer, availableImages: Array<string>, imagePositions: SpritePositions): void;
8889
isEmpty(): boolean;
8990

9091
upload(context: Context): void;

src/data/bucket/circle_bucket.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import type {TileTransform} from '../../geo/projection/tile_transform.js';
3232
import type {ProjectionSpecification} from '../../style-spec/types.js';
3333
import type Projection from '../../geo/projection/projection.js';
3434
import type {Vec3} from 'gl-matrix';
35+
import type {IVectorTileLayer} from '@mapbox/vector-tile';
3536

3637
function addCircleVertex(layoutVertexArray, x, y, extrudeX, extrudeY) {
3738
layoutVertexArray.emplaceBack(
@@ -151,7 +152,7 @@ class CircleBucket<Layer: CircleStyleLayer | HeatmapStyleLayer> implements Bucke
151152
}
152153
}
153154

154-
update(states: FeatureStates, vtLayer: VectorTileLayer, availableImages: Array<string>, imagePositions: SpritePositions) {
155+
update(states: FeatureStates, vtLayer: IVectorTileLayer, availableImages: Array<string>, imagePositions: SpritePositions) {
155156
if (!this.stateDependentLayers.length) return;
156157
this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, availableImages, imagePositions);
157158
}

src/data/bucket/fill_bucket.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {FeatureStates} from '../../source/source_state.js';
3333
import type {SpritePositions} from '../../util/image.js';
3434
import type {ProjectionSpecification} from '../../style-spec/types.js';
3535
import type {TileTransform} from '../../geo/projection/tile_transform.js';
36+
import type {IVectorTileLayer} from '@mapbox/vector-tile';
3637

3738
class FillBucket implements Bucket {
3839
index: number;
@@ -132,7 +133,7 @@ class FillBucket implements Bucket {
132133
}
133134
}
134135

135-
update(states: FeatureStates, vtLayer: VectorTileLayer, availableImages: Array<string>, imagePositions: SpritePositions) {
136+
update(states: FeatureStates, vtLayer: IVectorTileLayer, availableImages: Array<string>, imagePositions: SpritePositions) {
136137
if (!this.stateDependentLayers.length) return;
137138
this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, availableImages, imagePositions);
138139
}

src/data/bucket/fill_extrusion_bucket.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {ProgramConfigurationSet} from '../program_configuration.js';
88
import {TriangleIndexArray} from '../index_array_type.js';
99
import EXTENT from '../extent.js';
1010
import earcut from 'earcut';
11-
import mvt from '@mapbox/vector-tile';
12-
const vectorTileFeatureTypes = mvt.VectorTileFeature.types;
11+
import {VectorTileFeature} from '@mapbox/vector-tile';
12+
const vectorTileFeatureTypes = VectorTileFeature.types;
1313
import classifyRings from '../../util/classify_rings.js';
1414
import assert from 'assert';
1515
const EARCUT_MAX_RINGS = 500;
@@ -32,6 +32,7 @@ import type {
3232
IndexedFeature,
3333
PopulateParameters
3434
} from '../bucket.js';
35+
import {earthRadius} from '../../geo/lng_lat.js';
3536

3637
import type FillExtrusionStyleLayer from '../../style/style_layer/fill_extrusion_style_layer.js';
3738
import type Context from '../../gl/context.js';
@@ -41,7 +42,7 @@ import type {FeatureStates} from '../../source/source_state.js';
4142
import type {SpritePositions} from '../../util/image.js';
4243
import type {ProjectionSpecification} from '../../style-spec/types.js';
4344
import type {TileTransform} from '../../geo/projection/tile_transform.js';
44-
import {earthRadius} from '../../geo/lng_lat.js';
45+
import type {IVectorTileLayer} from '@mapbox/vector-tile';
4546

4647
const FACTOR = Math.pow(2, 13);
4748

@@ -274,7 +275,7 @@ class FillExtrusionBucket implements Bucket {
274275
this.sortBorders();
275276
}
276277

277-
update(states: FeatureStates, vtLayer: VectorTileLayer, availableImages: Array<string>, imagePositions: SpritePositions) {
278+
update(states: FeatureStates, vtLayer: IVectorTileLayer, availableImages: Array<string>, imagePositions: SpritePositions) {
278279
if (!this.stateDependentLayers.length) return;
279280
this.programConfigurations.updatePaintArrays(states, vtLayer, this.stateDependentLayers, availableImages, imagePositions);
280281
}
@@ -615,7 +616,7 @@ class FillExtrusionBucket implements Bucket {
615616
}
616617
}
617618

618-
encodeCentroid(c: Point, metadata: PartMetadata, append: boolean = true) {
619+
encodeCentroid(c: ?Point, metadata: PartMetadata, append: boolean = true) {
619620
let x, y;
620621
// Encoded centroid x and y:
621622
// x y

0 commit comments

Comments
 (0)